Skip to content
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2,769 changes: 1,477 additions & 1,292 deletions Cargo.lock

Large diffs are not rendered by default.

275 changes: 132 additions & 143 deletions Cargo.toml

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ substrate-build-script-utils = { workspace = true }
array-bytes = { workspace = true }
async-trait = { version = "0.1" }
clap = { version = "4.4", features = ["derive"] }
color-eyre = { version = "0.6" }
color-print = { version = "0.3" }
futures = { version = "0.3" }
jsonrpsee = { version = "0.23", features = ["server"] }
jsonrpsee = { version = "0.24", features = ["server"] }
log = { workspace = true }
serde = { workspace = true }
serde_json = { version = "1.0", features = ["arbitrary_precision"] }
Expand Down
16 changes: 5 additions & 11 deletions node/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
// along with Darwinia. If not, see <https://www.gnu.org/licenses/>.

// std
use std::{env, fs, io::ErrorKind, net::SocketAddr, path::PathBuf, result::Result as StdResult};
use std::{env, fs, io::ErrorKind, path::PathBuf, result::Result as StdResult};
// darwinia
use crate::{
chain_spec::*,
Expand All @@ -30,7 +30,7 @@ use cumulus_client_cli::CollatorOptions;
use cumulus_primitives_core::ParaId;
use sc_cli::{
CliConfiguration, DefaultConfigurationValues, ImportParams, KeystoreParams, NetworkParams,
Result, SharedParams, SubstrateCli,
Result, RpcEndpoint, SharedParams, SubstrateCli,
};
use sc_network::{
config::NetworkBackendType, Litep2pNetworkBackend, NetworkBackend, NetworkWorker,
Expand Down Expand Up @@ -144,7 +144,7 @@ impl CliConfiguration<Self> for RelayChainCli {
Ok(self.shared_params().base_path()?.or_else(|| self.base_path.clone().map(Into::into)))
}

fn rpc_addr(&self, default_listen_port: u16) -> Result<Option<SocketAddr>> {
fn rpc_addr(&self, default_listen_port: u16) -> Result<Option<Vec<RpcEndpoint>>> {
self.base.base.rpc_addr(default_listen_port)
}

Expand All @@ -156,15 +156,9 @@ impl CliConfiguration<Self> for RelayChainCli {
self.base.base.prometheus_config(default_listen_port, chain_spec)
}

fn init<F>(
&self,
_support_url: &String,
_impl_version: &String,
_logger_hook: F,
_config: &sc_service::Configuration,
) -> Result<()>
fn init<F>(&self, _support_url: &String, _impl_version: &String, _logger_hook: F) -> Result<()>
where
F: FnOnce(&mut sc_cli::LoggerBuilder, &sc_service::Configuration),
F: FnOnce(&mut sc_cli::LoggerBuilder),
{
unreachable!("PolkadotCli is never initialized; qed");
}
Expand Down
2 changes: 2 additions & 0 deletions node/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,7 @@ mod rpc;
mod service;

fn main() -> sc_cli::Result<()> {
color_eyre::install().unwrap();

command::run()
}
62 changes: 29 additions & 33 deletions node/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ pub struct FullDeps<C, P, A: sc_transaction_pool::ChainApi, CIDP> {
pub pool: Arc<P>,
/// Graph pool instance.
pub graph: Arc<sc_transaction_pool::Pool<A>>,
/// Whether to deny unsafe calls
pub deny_unsafe: sc_rpc::DenyUnsafe,
/// The Node authority flag
pub is_authority: bool,
/// Network service
Expand Down Expand Up @@ -88,7 +86,23 @@ where

/// Instantiate all RPC extensions.
pub fn create_full<C, P, Be, A, EC, CIDP>(
deps: FullDeps<C, P, A, CIDP>,
FullDeps {
client,
pool,
graph,
is_authority,
network,
sync,
filter_pool,
frontier_backend,
max_past_logs,
fee_history_cache,
fee_history_cache_limit,
storage_override,
block_data_cache,
forced_parent_hashes,
pending_create_inherent_data_providers,
}: FullDeps<C, P, A, CIDP>,
subscription_task_executor: sc_rpc::SubscriptionTaskExecutor,
pubsub_notification_sinks: Arc<
fc_mapping_sync::EthereumBlockNotificationSinks<
Expand Down Expand Up @@ -132,29 +146,11 @@ where
use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApiServer};
use substrate_frame_rpc_system::{System, SystemApiServer};

let mut module = RpcExtension::new(());
let FullDeps {
client,
pool,
graph,
deny_unsafe,
is_authority,
network,
sync,
filter_pool,
frontier_backend,
max_past_logs,
fee_history_cache,
fee_history_cache_limit,
storage_override,
block_data_cache,
forced_parent_hashes,
pending_create_inherent_data_providers,
} = deps;
let mut io = RpcExtension::new(());

module.merge(System::new(client.clone(), pool.clone(), deny_unsafe).into_rpc())?;
module.merge(TransactionPayment::new(client.clone()).into_rpc())?;
module.merge(
io.merge(System::new(client.clone(), pool.clone()).into_rpc())?;
io.merge(TransactionPayment::new(client.clone()).into_rpc())?;
io.merge(
Eth::<Block, C, P, _, Be, A, CIDP, EC>::new(
client.clone(),
pool.clone(),
Expand All @@ -179,7 +175,7 @@ where

let tx_pool = TxPool::new(client.clone(), graph.clone());
if let Some(filter_pool) = filter_pool {
module.merge(
io.merge(
EthFilter::new(
client.clone(),
frontier_backend,
Expand All @@ -193,7 +189,7 @@ where
)?;
}

module.merge(
io.merge(
EthPubSub::new(
pool,
client.clone(),
Expand All @@ -204,7 +200,7 @@ where
)
.into_rpc(),
)?;
module.merge(
io.merge(
Net::new(
client.clone(),
network,
Expand All @@ -213,21 +209,21 @@ where
)
.into_rpc(),
)?;
module.merge(Web3::new(client.clone()).into_rpc())?;
module.merge(tx_pool.into_rpc())?;
io.merge(Web3::new(client.clone()).into_rpc())?;
io.merge(tx_pool.into_rpc())?;

if let Some(tracing_config) = maybe_tracing_config {
if let Some(trace_filter_requester) = tracing_config.tracing_requesters.trace {
module.merge(
io.merge(
Trace::new(client, trace_filter_requester, tracing_config.trace_filter_max_count)
.into_rpc(),
)?;
}

if let Some(debug_requester) = tracing_config.tracing_requesters.debug {
module.merge(Debug::new(debug_requester).into_rpc())?;
io.merge(Debug::new(debug_requester).into_rpc())?;
}
}

Ok(module)
Ok(io)
}
2 changes: 1 addition & 1 deletion node/src/service/instant_finalize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ where
}

async fn import_block(
&mut self,
&self,
mut block_import_params: sc_consensus::BlockImportParams<Block>,
) -> Result<sc_consensus::ImportResult, Self::Error> {
block_import_params.finalized = true;
Expand Down
37 changes: 21 additions & 16 deletions node/src/service/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ where
Ok((worker, telemetry))
})
.transpose()?;
let executor = sc_service::new_wasm_executor::<HostFunctions>(config);
let executor = sc_service::new_wasm_executor::<HostFunctions>(&config.executor);
let (client, backend, keystore_container, task_manager) =
sc_service::new_full_parts_record_import::<Block, RuntimeApi, _>(
config,
Expand Down Expand Up @@ -297,7 +297,10 @@ where
.then_some(database_path.as_ref().map(|p| {
let _ = std::fs::create_dir_all(p);

sc_sysinfo::gather_hwbench(Some(p))
sc_sysinfo::gather_hwbench(
Some(p),
&frame_benchmarking_cli::SUBSTRATE_REFERENCE_HARDWARE,
)
}))
.flatten();
let (relay_chain_interface, collator_key) =
Expand All @@ -315,8 +318,10 @@ where
let collator = parachain_config.role.is_authority();
let prometheus_registry = parachain_config.prometheus_registry().cloned();
let import_queue_service = import_queue.service();
let net_config =
<sc_network::config::FullNetworkConfiguration<_, _, Net>>::new(&parachain_config.network);
let net_config = <sc_network::config::FullNetworkConfiguration<_, _, Net>>::new(
&parachain_config.network,
prometheus_registry.clone(),
);
let (network, system_rpc_tx, tx_handler_controller, start_network, sync_service) =
cumulus_client_service::build_network(cumulus_client_service::BuildNetworkParams {
parachain_config: &parachain_config,
Expand Down Expand Up @@ -366,7 +371,7 @@ where
> = Default::default();
let pubsub_notification_sinks = Arc::new(pubsub_notification_sinks);
// for ethereum-compatibility rpc.
parachain_config.rpc_id_provider = Some(Box::new(fc_rpc::EthereumSubIdProvider));
parachain_config.rpc.id_provider = Some(Box::new(fc_rpc::EthereumSubIdProvider));
let tracing_requesters = frontier::spawn_tasks(
&task_manager,
client.clone(),
Expand Down Expand Up @@ -424,12 +429,11 @@ where
Ok((timestamp, parachain_inherent_data))
};

Box::new(move |deny_unsafe, subscription_task_executor| {
Box::new(move |subscription_task_executor| {
let deps = crate::rpc::FullDeps {
client: client.clone(),
pool: pool.clone(),
graph: pool.pool().clone(),
deny_unsafe,
is_authority: collator,
network: network.clone(),
sync: sync_service.clone(),
Expand Down Expand Up @@ -494,7 +498,7 @@ where
// in there and swapping out the requirements for your own are probably a good idea. The
// requirements for a para-chain are dictated by its relay-chain.
if let Err(e) =
frame_benchmarking_cli::SUBSTRATE_REFERENCE_HARDWARE.check_hardware(&hwbench)
frame_benchmarking_cli::SUBSTRATE_REFERENCE_HARDWARE.check_hardware(&hwbench, false)
{
log::warn!(
"⚠️ The hardware does not meet the minimal requirements {e} for role 'Authority'.",
Expand Down Expand Up @@ -673,7 +677,7 @@ where
proposer,
collator_service,
// Very limited proposal time.
authoring_duration: Duration::from_millis(1_500),
authoring_duration: Duration::from_millis(2_000),
reinitialize: false,
};
let fut = cumulus_client_consensus_aura::collators::lookahead::run::<
Expand Down Expand Up @@ -734,8 +738,11 @@ where
_telemetry_worker_handle,
),
} = new_partial::<RuntimeApi>(&config, eth_rpc_config)?;
let net_config =
<sc_network::config::FullNetworkConfiguration<_, _, Net>>::new(&config.network);
let prometheus_registry = config.prometheus_registry().cloned();
let net_config = <sc_network::config::FullNetworkConfiguration<_, _, Net>>::new(
&config.network,
prometheus_registry.clone(),
);
let metrics = Net::register_notification_metrics(None);
let (network, system_rpc_tx, tx_handler_controller, start_network, sync_service) =
sc_service::build_network(sc_service::BuildNetworkParams {
Expand All @@ -746,7 +753,7 @@ where
spawn_handle: task_manager.spawn_handle(),
import_queue,
block_announce_validator_builder: None,
warp_sync_params: None,
warp_sync_config: None,
block_relay: None,
metrics,
})?;
Expand Down Expand Up @@ -880,7 +887,6 @@ where
log::warn!("You could add --alice or --bob to make dev chain seal instantly.");
}

let prometheus_registry = config.prometheus_registry().cloned();
let block_data_cache = Arc::new(fc_rpc::EthBlockDataCacheTask::new(
task_manager.spawn_handle(),
storage_override.clone(),
Expand All @@ -893,7 +899,7 @@ where
> = Default::default();
let pubsub_notification_sinks = Arc::new(pubsub_notification_sinks);
// for ethereum-compatibility rpc.
config.rpc_id_provider = Some(Box::new(fc_rpc::EthereumSubIdProvider));
config.rpc.id_provider = Some(Box::new(fc_rpc::EthereumSubIdProvider));
let tracing_requesters = frontier::spawn_tasks(
&task_manager,
client.clone(),
Expand Down Expand Up @@ -952,12 +958,11 @@ where
Ok((timestamp, parachain_inherent_data))
};

Box::new(move |deny_unsafe, subscription_task_executor| {
Box::new(move |subscription_task_executor| {
let deps = crate::rpc::FullDeps {
client: client.clone(),
pool: pool.clone(),
graph: pool.pool().clone(),
deny_unsafe,
is_authority: collator,
network: network.clone(),
sync: sync_service.clone(),
Expand Down
4 changes: 0 additions & 4 deletions pallet/account-migration/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,7 @@ sp-std = { workspace = true }
frame-benchmarking = { workspace = true, optional = true }

[dev-dependencies]
pallet-timestamp = { workspace = true, features = ["std"] }
sp-io = { workspace = true, features = ["std"] }
sp-keyring = { workspace = true, features = ["std"] }
sp-version = { workspace = true, features = ["std"] }

[features]
default = ["std"]
Expand All @@ -50,7 +47,6 @@ std = [
"pallet-assets/std",
"pallet-balances/std",
"sp-core/std",
"sp-io/std",
"sp-runtime/std",
"sp-std/std",
# polkadot-sdk optional
Expand Down
2 changes: 0 additions & 2 deletions pallet/account-migration/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@
#![cfg_attr(not(feature = "std"), no_std)]
#![deny(missing_docs)]

#[cfg(test)]
mod mock;
#[cfg(test)]
mod tests;

Expand Down
Loading
Loading