Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 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
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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: |
Expand Down
20 changes: 10 additions & 10 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
1 change: 1 addition & 0 deletions examples/aura/node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ pub fn new_full(config: Configuration) -> Result<TaskManager, ServiceError> {
sync_service: sync_service.clone(),
config,
telemetry: telemetry.as_mut(),
tracing_execute_block: None,
})?;

if role.is_authority() {
Expand Down
4 changes: 2 additions & 2 deletions examples/aura/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ impl_runtime_apis! {
VERSION
}

fn execute_block(block: Block) {
fn execute_block(block: <Block as BlockT>::LazyBlock) {
Executive::execute_block(block);
}

Expand Down Expand Up @@ -372,7 +372,7 @@ impl_runtime_apis! {
}

fn check_inherents(
block: Block,
block: <Block as BlockT>::LazyBlock,
data: sp_inherents::InherentData,
) -> sp_inherents::CheckInherentsResult {
data.check_extrinsics(&block)
Expand Down
1 change: 1 addition & 0 deletions examples/babe/node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
Expand Down
61 changes: 45 additions & 16 deletions examples/babe/node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,42 @@ type FullSelectChain = sc_consensus::LongestChain<FullBackend, Block>;
type FullGrandpaBlockImport<E = WasmExecutor<sp_io::SubstrateHostFunctions>> =
sc_consensus_grandpa::GrandpaBlockImport<FullBackend, Block, FullClient<E>, 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<Block, ()> for BabeInherentDataProvider {
type InherentDataProviders = (
sp_consensus_babe::inherents::InherentDataProvider,
sp_timestamp::InherentDataProvider,
);

async fn create_inherent_data_providers(
&self,
_parent: <Block as sp_runtime::traits::Block>::Hash,
_extra_args: (),
) -> Result<Self::InherentDataProviders, Box<dyn std::error::Error + Send + Sync>> {
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<E = WasmExecutor<sp_io::SubstrateHostFunctions>> =
sc_consensus_babe::BabeBlockImport<Block, FullClient<E>, FullGrandpaBlockImport<E>, BabeInherentDataProvider, FullSelectChain>;

/// Our native executor instance.
pub struct ExecutorDispatch;

Expand Down Expand Up @@ -166,7 +202,7 @@ pub fn new_partial<E>(
sc_rpc::SubscriptionTaskExecutor,
) -> Result<jsonrpsee::RpcModule<()>, sc_service::Error>,
(
sc_consensus_babe::BabeBlockImport<Block, FullClient<E>, FullGrandpaBlockImport<E>>,
FullBabeBlockImport<E>,
sc_consensus_grandpa::LinkHalf<Block, FullClient<E>, FullSelectChain>,
sc_consensus_babe::BabeLink<Block>,
),
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -337,7 +365,7 @@ pub fn new_full_base(
config: Configuration,
disable_hardware_benchmarks: bool,
with_startup_data: impl FnOnce(
&sc_consensus_babe::BabeBlockImport<Block, FullClient, FullGrandpaBlockImport>,
&FullBabeBlockImport,
&sc_consensus_babe::BabeLink<Block>,
),
) -> Result<NewFullBase, ServiceError> {
Expand Down Expand Up @@ -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 {
Expand Down
10 changes: 8 additions & 2 deletions examples/babe/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 = <Self as frame_system::Config>::AccountId;
Expand All @@ -451,6 +455,8 @@ impl pallet_session::Config for Runtime {
type Keys = SessionKeys;
type WeightInfo = pallet_session::weights::SubstrateWeight<Runtime>;
type DisablingStrategy = ();
type Currency = Balances;
type KeyDeposit = SessionKeyDeposit;
}

impl pallet_session::historical::Config for Runtime {
Expand Down Expand Up @@ -751,7 +757,7 @@ impl_runtime_apis! {
VERSION
}

fn execute_block(block: Block) {
fn execute_block(block: <Block as BlockT>::LazyBlock) {
Executive::execute_block(block);
}

Expand Down Expand Up @@ -787,7 +793,7 @@ impl_runtime_apis! {
data.create_extrinsics()
}

fn check_inherents(block: Block, data: InherentData) -> CheckInherentsResult {
fn check_inherents(block: <Block as BlockT>::LazyBlock, data: InherentData) -> CheckInherentsResult {
data.check_extrinsics(&block)
}
}
Expand Down
11 changes: 6 additions & 5 deletions examples/parachain/node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,14 @@ 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;
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};
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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,
)?;
Expand Down Expand Up @@ -390,22 +391,21 @@ fn start_consensus(
relay_chain_slot_duration: Duration,
para_id: ParaId,
collator_key: CollatorPair,
collator_peer_id: PeerId,
overseer_handle: OverseerHandle,
announce_block: Arc<dyn Fn(Hash, Option<Vec<u8>>) + 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,
prometheus_registry,
telemetry.clone(),
);

let proposer = Proposer::new(proposer_factory);

let collator_service = CollatorService::new(
client.clone(),
Arc::new(task_manager.spawn_handle()),
Expand All @@ -424,6 +424,7 @@ fn start_consensus(
},
keystore,
collator_key,
collator_peer_id,
para_id,
overseer_handle,
reinitialize: true,
Expand Down
8 changes: 5 additions & 3 deletions examples/parachain/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Self>;
type RelayParentOffset = ConstU32<0>;
}

Expand Down Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down Expand Up @@ -568,7 +570,7 @@ impl_runtime_apis! {
VERSION
}

fn execute_block(block: Block) {
fn execute_block(block: <Block as BlockT>::LazyBlock) {
Executive::execute_block(block)
}

Expand Down Expand Up @@ -605,7 +607,7 @@ impl_runtime_apis! {
}

fn check_inherents(
block: Block,
block: <Block as BlockT>::LazyBlock,
data: sp_inherents::InherentData,
) -> sp_inherents::CheckInherentsResult {
data.check_extrinsics(&block)
Expand Down
2 changes: 1 addition & 1 deletion runtime-api/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "simnode-runtime-api"
version = "2506.0.0"
version = "2512.0.0"
authors = ["Polytope Labs <hello@polytope.technology>"]
edition = "2021"
license = "Apache-2.0"
Expand Down
3 changes: 2 additions & 1 deletion simnode/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "sc-simnode"
version = "2506.0.0"
version = "2512.0.0"
authors = ["Polytope Labs <hello@polytope.technology>"]
edition = "2021"
license = "Apache-2.0"
Expand Down Expand Up @@ -36,6 +36,7 @@ features = [
"sc-network",
"sc-cli",
"sc-basic-authorship",
"sc-block-builder",
"sc-rpc",
"sc-offchain",
"sc-tracing",
Expand Down
Loading