diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c0dcdfd..4073caa 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,10 +25,10 @@ jobs: components: rust-src - uses: Swatinem/rust-cache@v2 - - name: Install protoc + - name: Install dependencies run: | sudo apt-get update - sudo apt-get install protobuf-compiler + sudo apt-get install -y protobuf-compiler llvm clang libclang-dev - name: cargo check simnode run: cargo check -p sc-simnode @@ -48,10 +48,10 @@ jobs: - uses: Swatinem/rust-cache@v2 - - name: Install protoc + - name: Install dependencies run: | sudo apt-get update - sudo apt-get install -y protobuf-compiler build-essential + sudo apt-get install -y protobuf-compiler build-essential llvm clang libclang-dev - name: Build all binaries run: | diff --git a/Cargo.toml b/Cargo.toml index 7a347ee..3278098 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -25,17 +25,17 @@ scale-info = { version = "2.1.1", default-features = false, features = [ "derive", ] } jsonrpsee = "0.24" -polkadot-sdk = { version = "2506.0.0", default-features = false } +polkadot-sdk = { version = "2512.1.0", default-features = false } # crates which cannot be used from polkadot-sdk -sp-core = { version = "37.0.0", default-features = false } -sp-runtime-interface = { version = "30.0.0", default-features = false } -cumulus-pallet-parachain-system = { version = "0.21.0", default-features = false } -substrate-wasm-builder = "27.0.0" -sc-service = "0.52.0" -sc-network-sync = "0.50.0" -sc-tracing = "40.0.0" +sp-core = { version = "39.0.0", default-features = false } +sp-runtime-interface = { version = "33.0.0", default-features = false } +cumulus-pallet-parachain-system = { version = "0.25.0", default-features = false } +substrate-wasm-builder = "31.1.0" +sc-service = "0.56.0" +sc-network-sync = "0.54.0" +sc-tracing = "44.0.0" # local crates -simnode-runtime-api = { path = "./runtime-api", version = "2506.0.0", default-features = false } -sc-simnode = { path = "./simnode", version = "2506.0.0" } +simnode-runtime-api = { path = "./runtime-api", version = "2512.0.0", default-features = false } +sc-simnode = { path = "./simnode", version = "2512.0.0" } diff --git a/examples/aura/node/src/service.rs b/examples/aura/node/src/service.rs index 51cfb9e..9832d04 100644 --- a/examples/aura/node/src/service.rs +++ b/examples/aura/node/src/service.rs @@ -241,6 +241,7 @@ pub fn new_full(config: Configuration) -> Result { sync_service: sync_service.clone(), config, telemetry: telemetry.as_mut(), + tracing_execute_block: None, })?; if role.is_authority() { diff --git a/examples/aura/runtime/src/lib.rs b/examples/aura/runtime/src/lib.rs index de3fbe7..9ce9110 100644 --- a/examples/aura/runtime/src/lib.rs +++ b/examples/aura/runtime/src/lib.rs @@ -335,7 +335,7 @@ impl_runtime_apis! { VERSION } - fn execute_block(block: Block) { + fn execute_block(block: ::LazyBlock) { Executive::execute_block(block); } @@ -372,7 +372,7 @@ impl_runtime_apis! { } fn check_inherents( - block: Block, + block: ::LazyBlock, data: sp_inherents::InherentData, ) -> sp_inherents::CheckInherentsResult { data.check_extrinsics(&block) diff --git a/examples/babe/node/Cargo.toml b/examples/babe/node/Cargo.toml index 064459b..57318a3 100644 --- a/examples/babe/node/Cargo.toml +++ b/examples/babe/node/Cargo.toml @@ -36,6 +36,7 @@ crate-type = ["cdylib", "rlib"] [dependencies] # third-party dependencies array-bytes = "4.1" +async-trait = "0.1" clap = { version = "4.0.9", features = ["derive"], optional = true } codec = { workspace = true } serde = { version = "1.0.136", features = ["derive"] } diff --git a/examples/babe/node/src/service.rs b/examples/babe/node/src/service.rs index a215b08..360e772 100644 --- a/examples/babe/node/src/service.rs +++ b/examples/babe/node/src/service.rs @@ -51,6 +51,42 @@ type FullSelectChain = sc_consensus::LongestChain; type FullGrandpaBlockImport> = sc_consensus_grandpa::GrandpaBlockImport, FullSelectChain>; +/// Inherent data provider for BABE consensus. +#[derive(Clone)] +pub struct BabeInherentDataProvider { + slot_duration: sp_consensus_babe::SlotDuration, +} + +impl BabeInherentDataProvider { + pub fn new(slot_duration: sp_consensus_babe::SlotDuration) -> Self { + Self { slot_duration } + } +} + +#[async_trait::async_trait] +impl sp_inherents::CreateInherentDataProviders for BabeInherentDataProvider { + type InherentDataProviders = ( + sp_consensus_babe::inherents::InherentDataProvider, + sp_timestamp::InherentDataProvider, + ); + + async fn create_inherent_data_providers( + &self, + _parent: ::Hash, + _extra_args: (), + ) -> Result> { + let timestamp = sp_timestamp::InherentDataProvider::from_system_time(); + let slot = sp_consensus_babe::inherents::InherentDataProvider::from_timestamp_and_slot_duration( + *timestamp, + self.slot_duration, + ); + Ok((slot, timestamp)) + } +} + +type FullBabeBlockImport> = + sc_consensus_babe::BabeBlockImport, FullGrandpaBlockImport, BabeInherentDataProvider, FullSelectChain>; + /// Our native executor instance. pub struct ExecutorDispatch; @@ -166,7 +202,7 @@ pub fn new_partial( sc_rpc::SubscriptionTaskExecutor, ) -> Result, sc_service::Error>, ( - sc_consensus_babe::BabeBlockImport, FullGrandpaBlockImport>, + FullBabeBlockImport, sc_consensus_grandpa::LinkHalf, FullSelectChain>, sc_consensus_babe::BabeLink, ), @@ -226,35 +262,27 @@ where let justification_import = grandpa_block_import.clone(); + let slot_duration = sc_consensus_babe::configuration(&*client)?.slot_duration(); + let inherent_data_provider = BabeInherentDataProvider::new(slot_duration); let (block_import, babe_link) = sc_consensus_babe::block_import( sc_consensus_babe::configuration(&*client)?, grandpa_block_import, client.clone(), + inherent_data_provider, + select_chain.clone(), + OffchainTransactionPoolFactory::new(transaction_pool.clone()), )?; - let slot_duration = babe_link.config().slot_duration(); let (import_queue, babe_worker_handle) = sc_consensus_babe::import_queue(sc_consensus_babe::ImportQueueParams { link: babe_link.clone(), block_import: block_import.clone(), justification_import: Some(Box::new(justification_import)), client: client.clone(), - select_chain: select_chain.clone(), - create_inherent_data_providers: move |_, ()| async move { - let timestamp = sp_timestamp::InherentDataProvider::from_system_time(); - - let slot = - sp_consensus_babe::inherents::InherentDataProvider::from_timestamp_and_slot_duration( - *timestamp, - slot_duration, - ); - - Ok((slot, timestamp)) - }, + slot_duration, spawner: &task_manager.spawn_essential_handle(), registry: config.prometheus_registry(), telemetry: telemetry.as_ref().map(|x| x.handle()), - offchain_tx_pool_factory: OffchainTransactionPoolFactory::new(transaction_pool.clone()), })?; let import_setup = (block_import, grandpa_link, babe_link); @@ -337,7 +365,7 @@ pub fn new_full_base( config: Configuration, disable_hardware_benchmarks: bool, with_startup_data: impl FnOnce( - &sc_consensus_babe::BabeBlockImport, + &FullBabeBlockImport, &sc_consensus_babe::BabeLink, ), ) -> Result { @@ -448,6 +476,7 @@ pub fn new_full_base( tx_handler_controller, sync_service: sync_service.clone(), telemetry: telemetry.as_mut(), + tracing_execute_block: None, })?; if let Some(hwbench) = hwbench { diff --git a/examples/babe/runtime/src/lib.rs b/examples/babe/runtime/src/lib.rs index bbbc84b..7d36915 100644 --- a/examples/babe/runtime/src/lib.rs +++ b/examples/babe/runtime/src/lib.rs @@ -440,6 +440,10 @@ impl_opaque_keys! { } } +parameter_types! { + pub const SessionKeyDeposit: Balance = ExistentialDeposit::get() * 10; +} + impl pallet_session::Config for Runtime { type RuntimeEvent = RuntimeEvent; type ValidatorId = ::AccountId; @@ -451,6 +455,8 @@ impl pallet_session::Config for Runtime { type Keys = SessionKeys; type WeightInfo = pallet_session::weights::SubstrateWeight; type DisablingStrategy = (); + type Currency = Balances; + type KeyDeposit = SessionKeyDeposit; } impl pallet_session::historical::Config for Runtime { @@ -751,7 +757,7 @@ impl_runtime_apis! { VERSION } - fn execute_block(block: Block) { + fn execute_block(block: ::LazyBlock) { Executive::execute_block(block); } @@ -787,7 +793,7 @@ impl_runtime_apis! { data.create_extrinsics() } - fn check_inherents(block: Block, data: InherentData) -> CheckInherentsResult { + fn check_inherents(block: ::LazyBlock, data: InherentData) -> CheckInherentsResult { data.check_extrinsics(&block) } } diff --git a/examples/parachain/node/src/service.rs b/examples/parachain/node/src/service.rs index 6fdcefe..7cf3843 100644 --- a/examples/parachain/node/src/service.rs +++ b/examples/parachain/node/src/service.rs @@ -21,7 +21,6 @@ use cumulus_primitives_core::ParaId; use cumulus_relay_chain_interface::{OverseerHandle, RelayChainInterface}; // Substrate Imports -use cumulus_client_consensus_proposer::Proposer; use frame_benchmarking_cli::SUBSTRATE_REFERENCE_HARDWARE; use futures::FutureExt; use parachain_runtime::opaque::Hash; @@ -29,7 +28,7 @@ use polkadot_primitives::{CollatorPair, ValidationCode}; use sc_client_api::Backend; use sc_consensus::ImportQueue; use sc_executor::{RuntimeVersionOf, WasmExecutor}; -use sc_network::{NetworkBackend, NetworkBlock}; +use sc_network::{NetworkBackend, NetworkBlock, PeerId}; use sc_service::{Configuration, PartialComponents, TFullBackend, TFullClient, TaskManager}; use sc_simnode::parachain::ParachainSelectChain; use sc_telemetry::{Telemetry, TelemetryHandle, TelemetryWorker, TelemetryWorkerHandle}; @@ -245,6 +244,7 @@ async fn start_node_impl( system_rpc_tx, tx_handler_controller, telemetry: telemetry.as_mut(), + tracing_execute_block: None, })?; if let Some(hwbench) = hwbench { @@ -326,6 +326,7 @@ async fn start_node_impl( relay_chain_slot_duration, para_id, collator_key.expect("Command line arguments do not allow this. qed"), + network.local_peer_id(), overseer_handle, announce_block, )?; @@ -390,13 +391,14 @@ fn start_consensus( relay_chain_slot_duration: Duration, para_id: ParaId, collator_key: CollatorPair, + collator_peer_id: PeerId, overseer_handle: OverseerHandle, announce_block: Arc>) + Send + Sync>, ) -> Result<(), sc_service::Error> { // NOTE: because we use Aura here explicitly, we can use `CollatorSybilResistance::Resistant` // when starting the network. - let proposer_factory = sc_basic_authorship::ProposerFactory::with_proof_recording( + let proposer = sc_basic_authorship::ProposerFactory::with_proof_recording( task_manager.spawn_handle(), client.clone(), transaction_pool, @@ -404,8 +406,6 @@ fn start_consensus( telemetry.clone(), ); - let proposer = Proposer::new(proposer_factory); - let collator_service = CollatorService::new( client.clone(), Arc::new(task_manager.spawn_handle()), @@ -424,6 +424,7 @@ fn start_consensus( }, keystore, collator_key, + collator_peer_id, para_id, overseer_handle, reinitialize: true, diff --git a/examples/parachain/runtime/src/lib.rs b/examples/parachain/runtime/src/lib.rs index 281c745..dc7b84f 100644 --- a/examples/parachain/runtime/src/lib.rs +++ b/examples/parachain/runtime/src/lib.rs @@ -390,7 +390,6 @@ impl cumulus_pallet_parachain_system::Config for Runtime { type ReservedXcmpWeight = ReservedXcmpWeight; type CheckAssociatedRelayNumber = RelayNumberStrictlyIncreases; type ConsensusHook = ConsensusHook; - type SelectCore = cumulus_pallet_parachain_system::DefaultCoreSelector; type RelayParentOffset = ConstU32<0>; } @@ -450,6 +449,7 @@ impl cumulus_pallet_xcmp_queue::Config for Runtime { parameter_types! { pub const Period: u32 = 6 * HOURS; pub const Offset: u32 = 0; + pub const SessionKeyDeposit: Balance = EXISTENTIAL_DEPOSIT * 10; } impl pallet_session::Config for Runtime { @@ -466,6 +466,8 @@ impl pallet_session::Config for Runtime { type WeightInfo = (); // Disable validator slots when they get kicked from the CollatorSelection pallet type DisablingStrategy = (); + type Currency = Balances; + type KeyDeposit = SessionKeyDeposit; } impl pallet_aura::Config for Runtime { @@ -568,7 +570,7 @@ impl_runtime_apis! { VERSION } - fn execute_block(block: Block) { + fn execute_block(block: ::LazyBlock) { Executive::execute_block(block) } @@ -605,7 +607,7 @@ impl_runtime_apis! { } fn check_inherents( - block: Block, + block: ::LazyBlock, data: sp_inherents::InherentData, ) -> sp_inherents::CheckInherentsResult { data.check_extrinsics(&block) diff --git a/runtime-api/Cargo.toml b/runtime-api/Cargo.toml index bceffd0..f0aeb25 100644 --- a/runtime-api/Cargo.toml +++ b/runtime-api/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "simnode-runtime-api" -version = "2506.0.0" +version = "2512.0.0" authors = ["Polytope Labs "] edition = "2021" license = "Apache-2.0" diff --git a/simnode/Cargo.toml b/simnode/Cargo.toml index de84269..07deffa 100644 --- a/simnode/Cargo.toml +++ b/simnode/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "sc-simnode" -version = "2506.0.0" +version = "2512.0.0" authors = ["Polytope Labs "] edition = "2021" license = "Apache-2.0" @@ -36,6 +36,7 @@ features = [ "sc-network", "sc-cli", "sc-basic-authorship", + "sc-block-builder", "sc-rpc", "sc-offchain", "sc-tracing", diff --git a/simnode/src/client/aura.rs b/simnode/src/client/aura.rs index 39b0b5c..ae4e7d0 100644 --- a/simnode/src/client/aura.rs +++ b/simnode/src/client/aura.rs @@ -178,6 +178,7 @@ where tx_handler_controller, sync_service, telemetry: telemetry.as_mut(), + tracing_execute_block: None, }; spawn_tasks(params)?; diff --git a/simnode/src/client/babe.rs b/simnode/src/client/babe.rs index 7f8a798..081131e 100644 --- a/simnode/src/client/babe.rs +++ b/simnode/src/client/babe.rs @@ -184,6 +184,7 @@ where tx_handler_controller, sync_service, telemetry: telemetry.as_mut(), + tracing_execute_block: None, }; spawn_tasks(params)?; diff --git a/simnode/src/client/parachain.rs b/simnode/src/client/parachain.rs index 81de9ee..23bc50a 100644 --- a/simnode/src/client/parachain.rs +++ b/simnode/src/client/parachain.rs @@ -317,6 +317,7 @@ where tx_handler_controller, sync_service, telemetry: telemetry.as_mut(), + tracing_execute_block: None, }; spawn_tasks(params)?;