Skip to content

Commit 6f8d75b

Browse files
authored
polkadot v2512 upgrade (#53)
* polkadot v2512 upgrade * bump and ci deps * update version to match polkadot-sdk version number * nit * introduce fork aware proposer factory * introduce fork aware proposer factory * revert changes to simnode
1 parent 6b871bc commit 6f8d75b

14 files changed

Lines changed: 88 additions & 44 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ jobs:
2525
components: rust-src
2626

2727
- uses: Swatinem/rust-cache@v2
28-
- name: Install protoc
28+
- name: Install dependencies
2929
run: |
3030
sudo apt-get update
31-
sudo apt-get install protobuf-compiler
31+
sudo apt-get install -y protobuf-compiler llvm clang libclang-dev
3232
3333
- name: cargo check simnode
3434
run: cargo check -p sc-simnode
@@ -48,10 +48,10 @@ jobs:
4848

4949
- uses: Swatinem/rust-cache@v2
5050

51-
- name: Install protoc
51+
- name: Install dependencies
5252
run: |
5353
sudo apt-get update
54-
sudo apt-get install -y protobuf-compiler build-essential
54+
sudo apt-get install -y protobuf-compiler build-essential llvm clang libclang-dev
5555
5656
- name: Build all binaries
5757
run: |

‎Cargo.toml‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,17 @@ scale-info = { version = "2.1.1", default-features = false, features = [
2525
"derive",
2626
] }
2727
jsonrpsee = "0.24"
28-
polkadot-sdk = { version = "2506.0.0", default-features = false }
28+
polkadot-sdk = { version = "2512.1.0", default-features = false }
2929

3030
# crates which cannot be used from polkadot-sdk
31-
sp-core = { version = "37.0.0", default-features = false }
32-
sp-runtime-interface = { version = "30.0.0", default-features = false }
33-
cumulus-pallet-parachain-system = { version = "0.21.0", default-features = false }
34-
substrate-wasm-builder = "27.0.0"
35-
sc-service = "0.52.0"
36-
sc-network-sync = "0.50.0"
37-
sc-tracing = "40.0.0"
31+
sp-core = { version = "39.0.0", default-features = false }
32+
sp-runtime-interface = { version = "33.0.0", default-features = false }
33+
cumulus-pallet-parachain-system = { version = "0.25.0", default-features = false }
34+
substrate-wasm-builder = "31.1.0"
35+
sc-service = "0.56.0"
36+
sc-network-sync = "0.54.0"
37+
sc-tracing = "44.0.0"
3838

3939
# local crates
40-
simnode-runtime-api = { path = "./runtime-api", version = "2506.0.0", default-features = false }
41-
sc-simnode = { path = "./simnode", version = "2506.0.0" }
40+
simnode-runtime-api = { path = "./runtime-api", version = "2512.0.0", default-features = false }
41+
sc-simnode = { path = "./simnode", version = "2512.0.0" }

‎examples/aura/node/src/service.rs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,7 @@ pub fn new_full(config: Configuration) -> Result<TaskManager, ServiceError> {
241241
sync_service: sync_service.clone(),
242242
config,
243243
telemetry: telemetry.as_mut(),
244+
tracing_execute_block: None,
244245
})?;
245246

246247
if role.is_authority() {

‎examples/aura/runtime/src/lib.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ impl_runtime_apis! {
335335
VERSION
336336
}
337337

338-
fn execute_block(block: Block) {
338+
fn execute_block(block: <Block as BlockT>::LazyBlock) {
339339
Executive::execute_block(block);
340340
}
341341

@@ -372,7 +372,7 @@ impl_runtime_apis! {
372372
}
373373

374374
fn check_inherents(
375-
block: Block,
375+
block: <Block as BlockT>::LazyBlock,
376376
data: sp_inherents::InherentData,
377377
) -> sp_inherents::CheckInherentsResult {
378378
data.check_extrinsics(&block)

‎examples/babe/node/Cargo.toml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ crate-type = ["cdylib", "rlib"]
3636
[dependencies]
3737
# third-party dependencies
3838
array-bytes = "4.1"
39+
async-trait = "0.1"
3940
clap = { version = "4.0.9", features = ["derive"], optional = true }
4041
codec = { workspace = true }
4142
serde = { version = "1.0.136", features = ["derive"] }

‎examples/babe/node/src/service.rs‎

Lines changed: 45 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,42 @@ type FullSelectChain = sc_consensus::LongestChain<FullBackend, Block>;
5151
type FullGrandpaBlockImport<E = WasmExecutor<sp_io::SubstrateHostFunctions>> =
5252
sc_consensus_grandpa::GrandpaBlockImport<FullBackend, Block, FullClient<E>, FullSelectChain>;
5353

54+
/// Inherent data provider for BABE consensus.
55+
#[derive(Clone)]
56+
pub struct BabeInherentDataProvider {
57+
slot_duration: sp_consensus_babe::SlotDuration,
58+
}
59+
60+
impl BabeInherentDataProvider {
61+
pub fn new(slot_duration: sp_consensus_babe::SlotDuration) -> Self {
62+
Self { slot_duration }
63+
}
64+
}
65+
66+
#[async_trait::async_trait]
67+
impl sp_inherents::CreateInherentDataProviders<Block, ()> for BabeInherentDataProvider {
68+
type InherentDataProviders = (
69+
sp_consensus_babe::inherents::InherentDataProvider,
70+
sp_timestamp::InherentDataProvider,
71+
);
72+
73+
async fn create_inherent_data_providers(
74+
&self,
75+
_parent: <Block as sp_runtime::traits::Block>::Hash,
76+
_extra_args: (),
77+
) -> Result<Self::InherentDataProviders, Box<dyn std::error::Error + Send + Sync>> {
78+
let timestamp = sp_timestamp::InherentDataProvider::from_system_time();
79+
let slot = sp_consensus_babe::inherents::InherentDataProvider::from_timestamp_and_slot_duration(
80+
*timestamp,
81+
self.slot_duration,
82+
);
83+
Ok((slot, timestamp))
84+
}
85+
}
86+
87+
type FullBabeBlockImport<E = WasmExecutor<sp_io::SubstrateHostFunctions>> =
88+
sc_consensus_babe::BabeBlockImport<Block, FullClient<E>, FullGrandpaBlockImport<E>, BabeInherentDataProvider, FullSelectChain>;
89+
5490
/// Our native executor instance.
5591
pub struct ExecutorDispatch;
5692

@@ -166,7 +202,7 @@ pub fn new_partial<E>(
166202
sc_rpc::SubscriptionTaskExecutor,
167203
) -> Result<jsonrpsee::RpcModule<()>, sc_service::Error>,
168204
(
169-
sc_consensus_babe::BabeBlockImport<Block, FullClient<E>, FullGrandpaBlockImport<E>>,
205+
FullBabeBlockImport<E>,
170206
sc_consensus_grandpa::LinkHalf<Block, FullClient<E>, FullSelectChain>,
171207
sc_consensus_babe::BabeLink<Block>,
172208
),
@@ -226,35 +262,27 @@ where
226262

227263
let justification_import = grandpa_block_import.clone();
228264

265+
let slot_duration = sc_consensus_babe::configuration(&*client)?.slot_duration();
266+
let inherent_data_provider = BabeInherentDataProvider::new(slot_duration);
229267
let (block_import, babe_link) = sc_consensus_babe::block_import(
230268
sc_consensus_babe::configuration(&*client)?,
231269
grandpa_block_import,
232270
client.clone(),
271+
inherent_data_provider,
272+
select_chain.clone(),
273+
OffchainTransactionPoolFactory::new(transaction_pool.clone()),
233274
)?;
234275

235-
let slot_duration = babe_link.config().slot_duration();
236276
let (import_queue, babe_worker_handle) =
237277
sc_consensus_babe::import_queue(sc_consensus_babe::ImportQueueParams {
238278
link: babe_link.clone(),
239279
block_import: block_import.clone(),
240280
justification_import: Some(Box::new(justification_import)),
241281
client: client.clone(),
242-
select_chain: select_chain.clone(),
243-
create_inherent_data_providers: move |_, ()| async move {
244-
let timestamp = sp_timestamp::InherentDataProvider::from_system_time();
245-
246-
let slot =
247-
sp_consensus_babe::inherents::InherentDataProvider::from_timestamp_and_slot_duration(
248-
*timestamp,
249-
slot_duration,
250-
);
251-
252-
Ok((slot, timestamp))
253-
},
282+
slot_duration,
254283
spawner: &task_manager.spawn_essential_handle(),
255284
registry: config.prometheus_registry(),
256285
telemetry: telemetry.as_ref().map(|x| x.handle()),
257-
offchain_tx_pool_factory: OffchainTransactionPoolFactory::new(transaction_pool.clone()),
258286
})?;
259287

260288
let import_setup = (block_import, grandpa_link, babe_link);
@@ -337,7 +365,7 @@ pub fn new_full_base(
337365
config: Configuration,
338366
disable_hardware_benchmarks: bool,
339367
with_startup_data: impl FnOnce(
340-
&sc_consensus_babe::BabeBlockImport<Block, FullClient, FullGrandpaBlockImport>,
368+
&FullBabeBlockImport,
341369
&sc_consensus_babe::BabeLink<Block>,
342370
),
343371
) -> Result<NewFullBase, ServiceError> {
@@ -448,6 +476,7 @@ pub fn new_full_base(
448476
tx_handler_controller,
449477
sync_service: sync_service.clone(),
450478
telemetry: telemetry.as_mut(),
479+
tracing_execute_block: None,
451480
})?;
452481

453482
if let Some(hwbench) = hwbench {

‎examples/babe/runtime/src/lib.rs‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,10 @@ impl_opaque_keys! {
440440
}
441441
}
442442

443+
parameter_types! {
444+
pub const SessionKeyDeposit: Balance = ExistentialDeposit::get() * 10;
445+
}
446+
443447
impl pallet_session::Config for Runtime {
444448
type RuntimeEvent = RuntimeEvent;
445449
type ValidatorId = <Self as frame_system::Config>::AccountId;
@@ -451,6 +455,8 @@ impl pallet_session::Config for Runtime {
451455
type Keys = SessionKeys;
452456
type WeightInfo = pallet_session::weights::SubstrateWeight<Runtime>;
453457
type DisablingStrategy = ();
458+
type Currency = Balances;
459+
type KeyDeposit = SessionKeyDeposit;
454460
}
455461

456462
impl pallet_session::historical::Config for Runtime {
@@ -751,7 +757,7 @@ impl_runtime_apis! {
751757
VERSION
752758
}
753759

754-
fn execute_block(block: Block) {
760+
fn execute_block(block: <Block as BlockT>::LazyBlock) {
755761
Executive::execute_block(block);
756762
}
757763

@@ -787,7 +793,7 @@ impl_runtime_apis! {
787793
data.create_extrinsics()
788794
}
789795

790-
fn check_inherents(block: Block, data: InherentData) -> CheckInherentsResult {
796+
fn check_inherents(block: <Block as BlockT>::LazyBlock, data: InherentData) -> CheckInherentsResult {
791797
data.check_extrinsics(&block)
792798
}
793799
}

‎examples/parachain/node/src/service.rs‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,14 @@ use cumulus_primitives_core::ParaId;
2121
use cumulus_relay_chain_interface::{OverseerHandle, RelayChainInterface};
2222

2323
// Substrate Imports
24-
use cumulus_client_consensus_proposer::Proposer;
2524
use frame_benchmarking_cli::SUBSTRATE_REFERENCE_HARDWARE;
2625
use futures::FutureExt;
2726
use parachain_runtime::opaque::Hash;
2827
use polkadot_primitives::{CollatorPair, ValidationCode};
2928
use sc_client_api::Backend;
3029
use sc_consensus::ImportQueue;
3130
use sc_executor::{RuntimeVersionOf, WasmExecutor};
32-
use sc_network::{NetworkBackend, NetworkBlock};
31+
use sc_network::{NetworkBackend, NetworkBlock, PeerId};
3332
use sc_service::{Configuration, PartialComponents, TFullBackend, TFullClient, TaskManager};
3433
use sc_simnode::parachain::ParachainSelectChain;
3534
use sc_telemetry::{Telemetry, TelemetryHandle, TelemetryWorker, TelemetryWorkerHandle};
@@ -245,6 +244,7 @@ async fn start_node_impl(
245244
system_rpc_tx,
246245
tx_handler_controller,
247246
telemetry: telemetry.as_mut(),
247+
tracing_execute_block: None,
248248
})?;
249249

250250
if let Some(hwbench) = hwbench {
@@ -326,6 +326,7 @@ async fn start_node_impl(
326326
relay_chain_slot_duration,
327327
para_id,
328328
collator_key.expect("Command line arguments do not allow this. qed"),
329+
network.local_peer_id(),
329330
overseer_handle,
330331
announce_block,
331332
)?;
@@ -390,22 +391,21 @@ fn start_consensus(
390391
relay_chain_slot_duration: Duration,
391392
para_id: ParaId,
392393
collator_key: CollatorPair,
394+
collator_peer_id: PeerId,
393395
overseer_handle: OverseerHandle,
394396
announce_block: Arc<dyn Fn(Hash, Option<Vec<u8>>) + Send + Sync>,
395397
) -> Result<(), sc_service::Error> {
396398
// NOTE: because we use Aura here explicitly, we can use `CollatorSybilResistance::Resistant`
397399
// when starting the network.
398400

399-
let proposer_factory = sc_basic_authorship::ProposerFactory::with_proof_recording(
401+
let proposer = sc_basic_authorship::ProposerFactory::with_proof_recording(
400402
task_manager.spawn_handle(),
401403
client.clone(),
402404
transaction_pool,
403405
prometheus_registry,
404406
telemetry.clone(),
405407
);
406408

407-
let proposer = Proposer::new(proposer_factory);
408-
409409
let collator_service = CollatorService::new(
410410
client.clone(),
411411
Arc::new(task_manager.spawn_handle()),
@@ -424,6 +424,7 @@ fn start_consensus(
424424
},
425425
keystore,
426426
collator_key,
427+
collator_peer_id,
427428
para_id,
428429
overseer_handle,
429430
reinitialize: true,

‎examples/parachain/runtime/src/lib.rs‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,6 @@ impl cumulus_pallet_parachain_system::Config for Runtime {
390390
type ReservedXcmpWeight = ReservedXcmpWeight;
391391
type CheckAssociatedRelayNumber = RelayNumberStrictlyIncreases;
392392
type ConsensusHook = ConsensusHook;
393-
type SelectCore = cumulus_pallet_parachain_system::DefaultCoreSelector<Self>;
394393
type RelayParentOffset = ConstU32<0>;
395394
}
396395

@@ -450,6 +449,7 @@ impl cumulus_pallet_xcmp_queue::Config for Runtime {
450449
parameter_types! {
451450
pub const Period: u32 = 6 * HOURS;
452451
pub const Offset: u32 = 0;
452+
pub const SessionKeyDeposit: Balance = EXISTENTIAL_DEPOSIT * 10;
453453
}
454454

455455
impl pallet_session::Config for Runtime {
@@ -466,6 +466,8 @@ impl pallet_session::Config for Runtime {
466466
type WeightInfo = ();
467467
// Disable validator slots when they get kicked from the CollatorSelection pallet
468468
type DisablingStrategy = ();
469+
type Currency = Balances;
470+
type KeyDeposit = SessionKeyDeposit;
469471
}
470472

471473
impl pallet_aura::Config for Runtime {
@@ -568,7 +570,7 @@ impl_runtime_apis! {
568570
VERSION
569571
}
570572

571-
fn execute_block(block: Block) {
573+
fn execute_block(block: <Block as BlockT>::LazyBlock) {
572574
Executive::execute_block(block)
573575
}
574576

@@ -605,7 +607,7 @@ impl_runtime_apis! {
605607
}
606608

607609
fn check_inherents(
608-
block: Block,
610+
block: <Block as BlockT>::LazyBlock,
609611
data: sp_inherents::InherentData,
610612
) -> sp_inherents::CheckInherentsResult {
611613
data.check_extrinsics(&block)

‎runtime-api/Cargo.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "simnode-runtime-api"
3-
version = "2506.0.0"
3+
version = "2512.0.0"
44
authors = ["Polytope Labs <hello@polytope.technology>"]
55
edition = "2021"
66
license = "Apache-2.0"

0 commit comments

Comments
 (0)