From 468944646a771aa057ad06d691f6070392fce24b Mon Sep 17 00:00:00 2001 From: Tarek Mohamed Abdalla Date: Mon, 28 Oct 2024 09:20:47 +0000 Subject: [PATCH] fix breaking changes --- .../nimbus-consensus/src/import_queue.rs | 2 +- precompiles/assets-erc20/src/eip2612.rs | 1 + precompiles/assets-erc20/src/lib.rs | 1 + precompiles/balances-erc20/src/eip2612.rs | 1 + precompiles/balances-erc20/src/lib.rs | 1 + precompiles/pallet-xcm/src/lib.rs | 1 + precompiles/proxy/src/lib.rs | 5 ++++- precompiles/xcm-utils/src/lib.rs | 2 ++ template/node/src/command.rs | 16 ++++---------- template/node/src/rpc.rs | 6 +---- template/node/src/service.rs | 22 +++++++++---------- template/runtime/src/lib.rs | 4 +--- 12 files changed, 29 insertions(+), 33 deletions(-) diff --git a/client/consensus/nimbus-consensus/src/import_queue.rs b/client/consensus/nimbus-consensus/src/import_queue.rs index 174384b5..33babab9 100644 --- a/client/consensus/nimbus-consensus/src/import_queue.rs +++ b/client/consensus/nimbus-consensus/src/import_queue.rs @@ -263,7 +263,7 @@ where } async fn import_block( - &mut self, + &self, mut block_import_params: sc_consensus::BlockImportParams, ) -> Result { // If we are in the parachain context, best block is determined by the relay chain diff --git a/precompiles/assets-erc20/src/eip2612.rs b/precompiles/assets-erc20/src/eip2612.rs index 95f7717c..87bf1a4a 100644 --- a/precompiles/assets-erc20/src/eip2612.rs +++ b/precompiles/assets-erc20/src/eip2612.rs @@ -123,6 +123,7 @@ where <::RuntimeCall as Dispatchable>::RuntimeOrigin: OriginTrait, AssetIdOf: Display, Runtime::AccountId: Into, + ::AddressMapping: AddressMapping, { fn compute_domain_separator(address: H160, asset_id: AssetIdOf) -> [u8; 32] { let asset_name = pallet_assets::Pallet::::name(asset_id.clone()); diff --git a/precompiles/assets-erc20/src/lib.rs b/precompiles/assets-erc20/src/lib.rs index 77c2cf97..d364e842 100644 --- a/precompiles/assets-erc20/src/lib.rs +++ b/precompiles/assets-erc20/src/lib.rs @@ -111,6 +111,7 @@ where <::RuntimeCall as Dispatchable>::RuntimeOrigin: OriginTrait, AssetIdOf: Display, Runtime::AccountId: Into, + ::AddressMapping: AddressMapping, { /// PrecompileSet discriminant. Allows to knows if the address maps to an asset id, /// and if this is the case which one. diff --git a/precompiles/balances-erc20/src/eip2612.rs b/precompiles/balances-erc20/src/eip2612.rs index ccc7ec45..5a338c33 100644 --- a/precompiles/balances-erc20/src/eip2612.rs +++ b/precompiles/balances-erc20/src/eip2612.rs @@ -45,6 +45,7 @@ where BalanceOf: TryFrom + Into, Metadata: Erc20Metadata, Instance: InstanceToPrefix + 'static, + ::AddressMapping: AddressMapping, { pub fn compute_domain_separator(address: H160) -> [u8; 32] { let name: H256 = keccak_256(Metadata::name().as_bytes()).into(); diff --git a/precompiles/balances-erc20/src/lib.rs b/precompiles/balances-erc20/src/lib.rs index 30e92f42..a2e7864b 100644 --- a/precompiles/balances-erc20/src/lib.rs +++ b/precompiles/balances-erc20/src/lib.rs @@ -187,6 +187,7 @@ where BalanceOf: TryFrom + Into, Metadata: Erc20Metadata, Instance: InstanceToPrefix + 'static, + ::AddressMapping: AddressMapping, { #[precompile::public("totalSupply()")] #[precompile::view] diff --git a/precompiles/pallet-xcm/src/lib.rs b/precompiles/pallet-xcm/src/lib.rs index f067142b..335b4ffb 100644 --- a/precompiles/pallet-xcm/src/lib.rs +++ b/precompiles/pallet-xcm/src/lib.rs @@ -74,6 +74,7 @@ where From>, ::RuntimeCall: From>, LocationMatcher: AccountIdToLocationMatcher<::AccountId>, + ::AddressMapping: AddressMapping, { #[precompile::public( "transferAssetsLocation(\ diff --git a/precompiles/proxy/src/lib.rs b/precompiles/proxy/src/lib.rs index a8b4d457..f8dbb918 100644 --- a/precompiles/proxy/src/lib.rs +++ b/precompiles/proxy/src/lib.rs @@ -54,6 +54,7 @@ where ::RuntimeCall: From> + From>, >::Balance: TryFrom + Into, + ::AddressMapping: AddressMapping, { fn is_allowed(_caller: H160, selector: Option) -> bool { match selector { @@ -86,6 +87,7 @@ where ::RuntimeCall: From> + From>, >::Balance: TryFrom + Into, + ::AddressMapping: AddressMapping, { fn is_allowed(_caller: H160, selector: Option) -> bool { match selector { @@ -147,6 +149,7 @@ where ::RuntimeCall: From> + From>, >::Balance: TryFrom + Into, + ::AddressMapping: AddressMapping, { /// Register a proxy account for the sender that is able to make calls on its behalf. /// The dispatch origin for this call must be Signed. @@ -180,7 +183,7 @@ where handle.record_db_read::( 28 + (29 * (::MaxProxies::get() as usize)) + 8, )?; - if ProxyPallet::::proxies(&origin) + if ProxyPallet::::proxies(origin.clone()) .0 .iter() .any(|pd| pd.delegate == delegate) diff --git a/precompiles/xcm-utils/src/lib.rs b/precompiles/xcm-utils/src/lib.rs index 948f0934..ad4667c8 100644 --- a/precompiles/xcm-utils/src/lib.rs +++ b/precompiles/xcm-utils/src/lib.rs @@ -71,6 +71,7 @@ where <::RuntimeCall as Dispatchable>::RuntimeOrigin: From>, ::RuntimeCall: From>, + ::AddressMapping: AddressMapping, { fn is_allowed(_caller: H160, selector: Option) -> bool { match selector { @@ -102,6 +103,7 @@ where <::RuntimeCall as Dispatchable>::RuntimeOrigin: From>, ::RuntimeCall: From>, + ::AddressMapping: AddressMapping, { #[precompile::public("multilocationToAddress((uint8,bytes[]))")] #[precompile::view] diff --git a/template/node/src/command.rs b/template/node/src/command.rs index c17bad7d..fd91bcc6 100644 --- a/template/node/src/command.rs +++ b/template/node/src/command.rs @@ -1,12 +1,10 @@ -use std::net::SocketAddr; - use cumulus_primitives_core::ParaId; use frame_benchmarking_cli::BenchmarkCmd; use log::info; use moonkit_template_runtime::Block; use sc_cli::{ ChainSpec, CliConfiguration, DefaultConfigurationValues, ImportParams, KeystoreParams, - NetworkParams, Result, SharedParams, SubstrateCli, + NetworkParams, Result, RpcEndpoint, SharedParams, SubstrateCli, }; use sc_service::config::{BasePath, PrometheusConfig}; use sp_runtime::traits::AccountIdConversion; @@ -325,7 +323,7 @@ impl CliConfiguration for RelayChainCli { .or_else(|| Some(self.base_path.clone().into()))) } - fn rpc_addr(&self, default_listen_port: u16) -> Result> { + fn rpc_addr(&self, default_listen_port: u16) -> Result>> { self.base.base.rpc_addr(default_listen_port) } @@ -339,15 +337,9 @@ impl CliConfiguration for RelayChainCli { .prometheus_config(default_listen_port, chain_spec) } - fn init( - &self, - _support_url: &String, - _impl_version: &String, - _logger_hook: F, - _config: &sc_service::Configuration, - ) -> Result<()> + fn init(&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"); } diff --git a/template/node/src/rpc.rs b/template/node/src/rpc.rs index 75500396..fd53b0ff 100644 --- a/template/node/src/rpc.rs +++ b/template/node/src/rpc.rs @@ -10,7 +10,6 @@ use std::sync::Arc; use moonkit_template_runtime::{opaque::Block, AccountId, Balance, Nonce}; use sc_client_api::AuxStore; -pub use sc_rpc::DenyUnsafe; use sc_transaction_pool_api::TransactionPool; use sp_api::ProvideRuntimeApi; use sp_block_builder::BlockBuilder; @@ -25,8 +24,6 @@ pub struct FullDeps { pub client: Arc, /// Transaction pool instance. pub pool: Arc

, - /// Whether to deny unsafe calls - pub deny_unsafe: DenyUnsafe, } /// Instantiate all RPC extensions. @@ -53,10 +50,9 @@ where let FullDeps { client, pool, - deny_unsafe, } = deps; - module.merge(System::new(client.clone(), pool, deny_unsafe).into_rpc())?; + module.merge(System::new(client.clone(), pool).into_rpc())?; module.merge(TransactionPayment::new(client).into_rpc())?; Ok(module) diff --git a/template/node/src/service.rs b/template/node/src/service.rs index 7259e745..40f98d5c 100644 --- a/template/node/src/service.rs +++ b/template/node/src/service.rs @@ -101,17 +101,18 @@ pub fn new_partial( .transpose()?; let heap_pages = config + .executor .default_heap_pages .map_or(DEFAULT_HEAP_ALLOC_STRATEGY, |h| HeapAllocStrategy::Static { extra_pages: h as _, }); let wasm = WasmExecutor::builder() - .with_execution_method(config.wasm_method) + .with_execution_method(config.executor.wasm_method) .with_onchain_heap_alloc_strategy(heap_pages) .with_offchain_heap_alloc_strategy(heap_pages) - .with_max_runtime_instances(config.max_runtime_instances) - .with_runtime_cache_size(config.runtime_cache_size) + .with_max_runtime_instances(config.executor.max_runtime_instances) + .with_runtime_cache_size(config.executor.runtime_cache_size) .build(); let executor = ParachainExecutor::new_with_wasm_executor(wasm); @@ -240,7 +241,7 @@ where let transaction_pool = params.transaction_pool.clone(); let import_queue_service = params.import_queue.service(); - let net_config = FullNetworkConfiguration::<_, _, N>::new(¶chain_config.network); + let net_config = FullNetworkConfiguration::<_, _, N>::new(¶chain_config.network, prometheus_registry.clone()); let metrics = N::register_notification_metrics( parachain_config @@ -259,7 +260,7 @@ where block_announce_validator_builder: Some(Box::new(|_| { Box::new(block_announce_validator) })), - warp_sync_params: None, + warp_sync_config: None, net_config, block_relay: None, metrics, @@ -269,11 +270,10 @@ where let client = client.clone(); let transaction_pool = transaction_pool.clone(); - Box::new(move |deny_unsafe, _| { + Box::new(move |_| { let deps = crate::rpc::FullDeps { client: client.clone(), pool: transaction_pool.clone(), - deny_unsafe, }; crate::rpc::create_full(deps).map_err(Into::into) @@ -442,7 +442,8 @@ where other: (_, mut telemetry, _), } = new_partial(&config, false)?; - let net_config = FullNetworkConfiguration::<_, _, N>::new(&config.network); + let prometheus_registry = config.prometheus_registry().cloned(); + let net_config = FullNetworkConfiguration::<_, _, N>::new(&config.network, prometheus_registry.clone()); let metrics = N::register_notification_metrics( config.prometheus_config.as_ref().map(|cfg| &cfg.registry), @@ -456,7 +457,7 @@ where spawn_handle: task_manager.spawn_handle(), import_queue, block_announce_validator_builder: None, - warp_sync_params: None, + warp_sync_config: None, net_config, block_relay: None, metrics, @@ -490,11 +491,10 @@ where let client = client.clone(); let transaction_pool = transaction_pool.clone(); - Box::new(move |deny_unsafe, _| { + Box::new(move |_| { let deps = crate::rpc::FullDeps { client: client.clone(), pool: transaction_pool.clone(), - deny_unsafe, }; crate::rpc::create_full(deps).map_err(Into::into) diff --git a/template/runtime/src/lib.rs b/template/runtime/src/lib.rs index ffc3fbd6..2f30f673 100644 --- a/template/runtime/src/lib.rs +++ b/template/runtime/src/lib.rs @@ -688,9 +688,7 @@ construct_runtime!( { // System support stuff. System: frame_system::{Pallet, Call, Config, Storage, Event} = 0, - ParachainSystem: cumulus_pallet_parachain_system::{ - Pallet, Call, Config, Storage, Inherent, Event, ValidateUnsigned, - } = 1, + ParachainSystem: cumulus_pallet_parachain_system = 1, RandomnessCollectiveFlip: pallet_insecure_randomness_collective_flip::{Pallet, Storage} = 2, Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent} = 3, ParachainInfo: staging_parachain_info::{Pallet, Storage, Config} = 4,