diff --git a/code/Cargo.lock b/code/Cargo.lock index 232584a786a..bc4a146a9dd 100644 --- a/code/Cargo.lock +++ b/code/Cargo.lock @@ -1550,6 +1550,7 @@ dependencies = [ "sp-consensus-aura", "sp-core", "sp-inherents", + "sp-io", "sp-keystore", "sp-offchain", "sp-runtime", diff --git a/code/parachain/node/Cargo.toml b/code/parachain/node/Cargo.toml index 50dd51fd2a8..f4611396a75 100644 --- a/code/parachain/node/Cargo.toml +++ b/code/parachain/node/Cargo.toml @@ -89,6 +89,7 @@ sp-storage = { git = "https://github.com/paritytech/substrate", branch = "polkad sp-timestamp = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" } sp-transaction-pool = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" } sp-trie = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" } +sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" } # Cumulus dependencies cumulus-client-cli = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.36" } diff --git a/code/parachain/node/src/chain_spec/composable.rs b/code/parachain/node/src/chain_spec/composable.rs index 2db9a794d70..221d04d43e9 100644 --- a/code/parachain/node/src/chain_spec/composable.rs +++ b/code/parachain/node/src/chain_spec/composable.rs @@ -3,6 +3,10 @@ use composable_runtime::GenesisConfig; use super::{Extensions, ParaId}; +// The block number until ed25519-dalek should be used for signature verification. Decided at +// 1_393_300 +pub const DALEK_END_BLOCK: u32 = 1_681_300; + /// Specialized `ChainSpec`. This is a specialization of the general Substrate ChainSpec type. pub type ChainSpec = sc_service::GenericChainSpec; diff --git a/code/parachain/node/src/chain_spec/picasso.rs b/code/parachain/node/src/chain_spec/picasso.rs index d34d763717c..7524124fbf4 100644 --- a/code/parachain/node/src/chain_spec/picasso.rs +++ b/code/parachain/node/src/chain_spec/picasso.rs @@ -3,6 +3,10 @@ use picasso_runtime::GenesisConfig; use super::{Extensions, ParaId}; +// The block number until ed25519-dalek should be used for signature verification. Decided at +// 1_788_000 +pub const DALEK_END_BLOCK: u32 = 2_076_000; + /// Specialized `ChainSpec`. This is a specialization of the general Substrate ChainSpec type. pub type ChainSpec = sc_service::GenericChainSpec; diff --git a/code/parachain/node/src/command.rs b/code/parachain/node/src/command.rs index ddfdb306df3..c8162e4f45b 100644 --- a/code/parachain/node/src/command.rs +++ b/code/parachain/node/src/command.rs @@ -250,13 +250,15 @@ pub fn run() -> Result<()> { let partials = new_partial::< picasso_runtime::RuntimeApi, PicassoExecutor, - >(&config)?; + >(&config, Option::None)?; cmd.run(partials.client) }, #[cfg(feature = "dali")] id if id.contains("dali") => { - let partials = - new_partial::(&config)?; + let partials = new_partial::( + &config, + Option::None, + )?; cmd.run(partials.client) }, #[cfg(feature = "composable")] @@ -264,7 +266,7 @@ pub fn run() -> Result<()> { let partials = new_partial::< composable_runtime::RuntimeApi, ComposableExecutor, - >(&config)?; + >(&config, Option::None)?; cmd.run(partials.client) }, id => panic!("Unknown Chain: {}", id), @@ -278,8 +280,9 @@ pub fn run() -> Result<()> { #[cfg(feature = "runtime-benchmarks")] BenchmarkCmd::Storage(cmd) => runner.sync_run(|config| match config.chain_spec.id() { id if id.contains("picasso") => { - let partials = - new_partial::(&config)?; + let partials = new_partial::( + &config, None, + )?; let db = partials.backend.expose_db(); let storage = partials.backend.expose_storage(); cmd.run(config, partials.client, db, storage) @@ -287,7 +290,7 @@ pub fn run() -> Result<()> { #[cfg(feature = "dali")] id if id.contains("dali") => { let partials = - new_partial::(&config)?; + new_partial::(&config, None)?; let db = partials.backend.expose_db(); let storage = partials.backend.expose_storage(); cmd.run(config, partials.client, db, storage) @@ -297,7 +300,7 @@ pub fn run() -> Result<()> { let partials = new_partial::< composable_runtime::RuntimeApi, ComposableExecutor, - >(&config)?; + >(&config, None)?; let db = partials.backend.expose_db(); let storage = partials.backend.expose_storage(); cmd.run(config, partials.client, db, storage) diff --git a/code/parachain/node/src/service.rs b/code/parachain/node/src/service.rs index 02616d4629d..7dfc8cb6b82 100644 --- a/code/parachain/node/src/service.rs +++ b/code/parachain/node/src/service.rs @@ -18,6 +18,7 @@ use sc_consensus::ImportQueue; use sc_network_common::service::NetworkBlock; // Substrate Imports use crate::{ + chain_spec, client::{Client, FullBackend, FullClient}, rpc, runtime::{ @@ -110,8 +111,10 @@ pub fn new_chain_ops( let components = match config.chain_spec.id() { #[cfg(feature = "composable")] chain if chain.contains("composable") => { - let components = - new_partial::(config)?; + let components = new_partial::( + config, + Some(chain_spec::composable::DALEK_END_BLOCK), + )?; ( Arc::new(Client::from(components.client)), components.backend, @@ -121,7 +124,8 @@ pub fn new_chain_ops( }, #[cfg(feature = "dali")] chain if chain.contains("dali") => { - let components = new_partial::(config)?; + let components = + new_partial::(config, Option::None)?; ( Arc::new(Client::from(components.client)), components.backend, @@ -130,7 +134,10 @@ pub fn new_chain_ops( ) }, chain if chain.contains("picasso") => { - let components = new_partial::(config)?; + let components = new_partial::( + config, + Some(chain_spec::picasso::DALEK_END_BLOCK), + )?; ( Arc::new(Client::from(components.client)), components.backend, @@ -147,6 +154,8 @@ pub fn new_chain_ops( #[allow(clippy::type_complexity)] pub fn new_partial( config: &Configuration, + // The block number until ed25519-dalek should be used for signature verification. + dalek_end_block: Option, ) -> Result< PartialComponents< FullClient, @@ -197,6 +206,13 @@ where )?; let client = Arc::new(client); + use sc_client_api::ExecutorProvider; + client.execution_extensions().set_extensions_factory( + sc_client_api::execution_extensions::ExtensionBeforeBlock::< + crate::client::Block, + sp_io::UseDalekExt, + >::new(dalek_end_block.unwrap_or(0)), + ); let telemetry_worker_handle = telemetry.as_ref().map(|(worker, _)| worker.handle()); let telemetry = telemetry.map(|(worker, telemetry)| { @@ -241,33 +257,38 @@ pub async fn start_node( collator_options: CollatorOptions, id: ParaId, ) -> sc_service::error::Result { - let task_manager = - match config.chain_spec.id() { - #[cfg(feature = "composable")] - chain if chain.contains("composable") => crate::service::start_node_impl::< - composable_runtime::RuntimeApi, - ComposableExecutor, - >(config, polkadot_config, collator_options, id) + let task_manager = match config.chain_spec.id() { + #[cfg(feature = "composable")] + chain if chain.contains("composable") => + crate::service::start_node_impl::( + config, + polkadot_config, + collator_options, + id, + Some(chain_spec::composable::DALEK_END_BLOCK), + ) .await?, - #[cfg(feature = "dali")] - chain if chain.contains("dali") => - crate::service::start_node_impl::( - config, - polkadot_config, - collator_options, - id, - ) - .await?, - chain if chain.contains("picasso") => - crate::service::start_node_impl::( - config, - polkadot_config, - collator_options, - id, - ) - .await?, - _ => panic!("Unknown chain_id: {}", config.chain_spec.id()), - }; + #[cfg(feature = "dali")] + chain if chain.contains("dali") => + crate::service::start_node_impl::( + config, + polkadot_config, + collator_options, + id, + Option::None, + ) + .await?, + chain if chain.contains("picasso") => + crate::service::start_node_impl::( + config, + polkadot_config, + collator_options, + id, + Some(chain_spec::picasso::DALEK_END_BLOCK), + ) + .await?, + _ => panic!("Unknown chain_id: {}", config.chain_spec.id()), + }; Ok(task_manager) } @@ -281,6 +302,8 @@ async fn start_node_impl( polkadot_config: Configuration, collator_options: CollatorOptions, id: ParaId, + // The block number until ed25519-dalek should be used for signature verification. + dalek_end_block: Option, ) -> sc_service::error::Result where RuntimeApi: @@ -298,7 +321,7 @@ where { let parachain_config = prepare_node_config(parachain_config); - let params = new_partial::(¶chain_config)?; + let params = new_partial::(¶chain_config, dalek_end_block)?; #[cfg(feature = "ocw")] {