From 93aff17d60cf6dd503e1718e1ddf59a6ad4b04b1 Mon Sep 17 00:00:00 2001 From: Xavier Lau Date: Wed, 8 Feb 2023 18:36:09 +0800 Subject: [PATCH] Clean imports (#271) * Clean imports * Fix tests --- pallet/message-transact/src/mock.rs | 24 ++- pallet/message-transact/src/tests/mod.rs | 3 +- precompile/assets/src/mock.rs | 3 +- precompile/deposit/src/mock.rs | 3 +- precompile/staking/src/mock.rs | 3 +- precompile/state-storage/src/mock.rs | 4 +- runtime/common/src/lib.rs | 4 +- runtime/crab/src/lib.rs | 137 ++++++++---------- runtime/crab/src/pallets/assets.rs | 6 +- runtime/crab/src/pallets/bridge_dispatch.rs | 4 +- runtime/crab/src/pallets/dmp_queue.rs | 4 +- runtime/crab/src/pallets/evm.rs | 28 ++-- runtime/crab/src/pallets/parachain_system.rs | 6 +- runtime/crab/src/pallets/polkadot_xcm.rs | 2 +- runtime/crab/src/pallets/preimage.rs | 2 +- runtime/crab/src/pallets/system.rs | 21 +-- .../crab/src/pallets/transaction_payment.rs | 2 +- runtime/crab/src/pallets/vesting.rs | 6 +- runtime/crab/src/pallets/xcmp_queue.rs | 6 +- runtime/crab/src/weights/block_weights.rs | 20 +-- runtime/crab/src/weights/extrinsic_weights.rs | 19 +-- runtime/darwinia/src/lib.rs | 137 ++++++++---------- runtime/darwinia/src/pallets/assets.rs | 6 +- .../darwinia/src/pallets/bridge_dispatch.rs | 4 +- runtime/darwinia/src/pallets/dmp_queue.rs | 4 +- runtime/darwinia/src/pallets/evm.rs | 28 ++-- .../darwinia/src/pallets/parachain_system.rs | 6 +- runtime/darwinia/src/pallets/polkadot_xcm.rs | 2 +- runtime/darwinia/src/pallets/preimage.rs | 2 +- runtime/darwinia/src/pallets/system.rs | 21 +-- .../src/pallets/transaction_payment.rs | 2 +- runtime/darwinia/src/pallets/vesting.rs | 6 +- runtime/darwinia/src/pallets/xcmp_queue.rs | 6 +- runtime/darwinia/src/weights/block_weights.rs | 20 +-- .../darwinia/src/weights/extrinsic_weights.rs | 19 +-- runtime/pangolin/src/lib.rs | 137 ++++++++---------- runtime/pangolin/src/pallets/assets.rs | 6 +- runtime/pangolin/src/pallets/dmp_queue.rs | 4 +- runtime/pangolin/src/pallets/evm.rs | 28 ++-- .../pangolin/src/pallets/parachain_system.rs | 6 +- runtime/pangolin/src/pallets/polkadot_xcm.rs | 2 +- runtime/pangolin/src/pallets/preimage.rs | 2 +- runtime/pangolin/src/pallets/system.rs | 21 +-- .../src/pallets/transaction_payment.rs | 2 +- runtime/pangolin/src/pallets/vesting.rs | 6 +- runtime/pangolin/src/pallets/xcmp_queue.rs | 6 +- runtime/pangolin/src/weights/block_weights.rs | 20 +-- .../pangolin/src/weights/extrinsic_weights.rs | 19 +-- 48 files changed, 389 insertions(+), 440 deletions(-) diff --git a/pallet/message-transact/src/mock.rs b/pallet/message-transact/src/mock.rs index ea496d86..c6a9344b 100644 --- a/pallet/message-transact/src/mock.rs +++ b/pallet/message-transact/src/mock.rs @@ -27,10 +27,8 @@ use pallet_ethereum::IntermediateStateRoot; use frame_support::{ dispatch::RawOrigin, ensure, - pallet_prelude::Weight, traits::{ConstU32, Everything}, }; -use sp_core::{H256, U256}; use sp_runtime::{ testing::Header, traits::{BlakeTwo256, DispatchInfoOf, IdentifyAccount, IdentityLookup, Verify}, @@ -43,7 +41,7 @@ use bp_message_dispatch::{CallValidate, IntoDispatchOrigin as IntoDispatchOrigin pub type Block = frame_system::mocking::MockBlock; pub type Balance = u64; -pub type AccountId = H160; +pub type AccountId = sp_core::H160; pub type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; frame_support::parameter_types! { @@ -58,7 +56,7 @@ impl frame_system::Config for TestRuntime { type BlockNumber = u64; type BlockWeights = (); type DbWeight = (); - type Hash = H256; + type Hash = sp_core::H256; type Hashing = BlakeTwo256; type Header = Header; type Index = u64; @@ -105,14 +103,14 @@ impl pallet_timestamp::Config for TestRuntime { frame_support::parameter_types! { pub const TransactionByteFee: u64 = 1; pub const ChainId: u64 = 42; - pub const BlockGasLimit: U256 = U256::MAX; - pub const WeightPerGas: Weight = Weight::from_ref_time(20_000); + pub const BlockGasLimit: sp_core::U256 = sp_core::U256::MAX; + pub const WeightPerGas: frame_support::weights::Weight = frame_support::weights::Weight::from_ref_time(20_000); } pub struct FixedGasPrice; impl FeeCalculator for FixedGasPrice { - fn min_gas_price() -> (U256, Weight) { - (U256::from(5), Weight::zero()) + fn min_gas_price() -> (sp_core::U256, frame_support::weights::Weight) { + (sp_core::U256::from(5), frame_support::weights::Weight::zero()) } } @@ -141,8 +139,8 @@ impl pallet_ethereum::Config for TestRuntime { } pub struct MockAccountIdConverter; -impl sp_runtime::traits::Convert for MockAccountIdConverter { - fn convert(hash: H256) -> AccountId { +impl sp_runtime::traits::Convert for MockAccountIdConverter { + fn convert(hash: sp_core::H256) -> AccountId { hash.into() } } @@ -266,7 +264,7 @@ frame_support::construct_runtime! { } impl fp_self_contained::SelfContainedCall for RuntimeCall { - type SignedInfo = H160; + type SignedInfo = sp_core::H160; fn is_self_contained(&self) -> bool { match self { @@ -323,8 +321,8 @@ impl fp_self_contained::SelfContainedCall for RuntimeCall { } pub(crate) struct AccountInfo { - pub address: H160, - pub private_key: H256, + pub address: sp_core::H160, + pub private_key: sp_core::H256, } pub(crate) fn address_build(seed: u8) -> AccountInfo { diff --git a/pallet/message-transact/src/tests/mod.rs b/pallet/message-transact/src/tests/mod.rs index 9119ddef..412a3a42 100644 --- a/pallet/message-transact/src/tests/mod.rs +++ b/pallet/message-transact/src/tests/mod.rs @@ -32,14 +32,13 @@ use crate::mock::*; use bp_message_dispatch::{CallOrigin, MessageDispatch, MessagePayload, SpecVersion}; use bp_runtime::messages::DispatchFeePayment; // substrate -use frame_support::pallet_prelude::Weight; use sp_core::{H256, U256}; pub(crate) const TEST_SPEC_VERSION: SpecVersion = 0; pub(crate) type SubChainId = [u8; 4]; pub(crate) const SOURCE_CHAIN_ID: SubChainId = *b"srce"; pub(crate) const TARGET_CHAIN_ID: SubChainId = *b"trgt"; -pub(crate) const TEST_WEIGHT: Weight = Weight::from_ref_time(1_000_000_000_000); +pub(crate) const TEST_WEIGHT: frame_support::weights::Weight = frame_support::weights::Weight::from_ref_time(1_000_000_000_000); // This ERC-20 contract mints the maximum amount of tokens to the contract creator. // pragma solidity ^0.5.0; diff --git a/precompile/assets/src/mock.rs b/precompile/assets/src/mock.rs index 470a5ee2..41eba8fb 100644 --- a/precompile/assets/src/mock.rs +++ b/precompile/assets/src/mock.rs @@ -21,7 +21,6 @@ use codec::{Decode, Encode, MaxEncodedLen}; // frontier use fp_evm::{Precompile, PrecompileSet}; // parity -use frame_support::pallet_prelude::Weight; use sp_core::{H160, H256, U256}; use sp_std::{marker::PhantomData, prelude::*}; // darwinia @@ -148,7 +147,7 @@ impl AccountToAssetId for AssetIdConverter { frame_support::parameter_types! { pub const BlockGasLimit: U256 = U256::MAX; - pub const WeightPerGas: Weight = Weight::from_ref_time(20_000); + pub const WeightPerGas: frame_support::weights::Weight = frame_support::weights::Weight::from_ref_time(20_000); pub PrecompilesValue: TestPrecompiles = TestPrecompiles::<_>::new(); } diff --git a/precompile/deposit/src/mock.rs b/precompile/deposit/src/mock.rs index 6fbc0cc5..860170ff 100644 --- a/precompile/deposit/src/mock.rs +++ b/precompile/deposit/src/mock.rs @@ -23,7 +23,6 @@ use crate::*; // frontier use fp_evm::{Precompile, PrecompileSet}; // substrate -use frame_support::pallet_prelude::Weight; use sp_core::{ConstU32, H160, H256, U256}; pub(crate) type Balance = u128; @@ -150,7 +149,7 @@ fn addr(a: u64) -> H160 { frame_support::parameter_types! { pub const BlockGasLimit: U256 = U256::MAX; - pub const WeightPerGas: Weight = Weight::from_ref_time(20_000); + pub const WeightPerGas: frame_support::weights::Weight = frame_support::weights::Weight::from_ref_time(20_000); pub PrecompilesValue: TestPrecompiles = TestPrecompiles::<_>::new(); } diff --git a/precompile/staking/src/mock.rs b/precompile/staking/src/mock.rs index 879e35df..2ee0d902 100644 --- a/precompile/staking/src/mock.rs +++ b/precompile/staking/src/mock.rs @@ -23,7 +23,6 @@ use crate::*; // frontier use fp_evm::{Precompile, PrecompileSet}; // substrate -use frame_support::pallet_prelude::Weight; use sp_core::{ConstU32, H160, H256, U256}; pub(crate) type Balance = u128; @@ -154,7 +153,7 @@ pub type PCall = StakingCall; frame_support::parameter_types! { pub const BlockGasLimit: U256 = U256::MAX; - pub const WeightPerGas: Weight = Weight::from_ref_time(20_000); + pub const WeightPerGas: frame_support::weights::Weight = frame_support::weights::Weight::from_ref_time(20_000); pub PrecompilesValue: TestPrecompiles = TestPrecompiles::<_>::new(); } diff --git a/precompile/state-storage/src/mock.rs b/precompile/state-storage/src/mock.rs index b080d2eb..bed68bee 100644 --- a/precompile/state-storage/src/mock.rs +++ b/precompile/state-storage/src/mock.rs @@ -21,7 +21,7 @@ use codec::{Decode, Encode, MaxEncodedLen}; // frontier use fp_evm::{Precompile, PrecompileSet}; // substrate -use frame_support::{pallet_prelude::Weight, StorageHasher, Twox128}; +use frame_support::{StorageHasher, Twox128}; use sp_core::{H160, H256, U256}; use sp_std::{marker::PhantomData, prelude::*}; // darwinia @@ -134,7 +134,7 @@ fn addr(a: u64) -> H160 { frame_support::parameter_types! { pub const BlockGasLimit: U256 = U256::MAX; - pub const WeightPerGas: Weight = Weight::from_ref_time(20_000); + pub const WeightPerGas: frame_support::weights::Weight = frame_support::weights::Weight::from_ref_time(20_000); pub PrecompilesValue: TestPrecompiles = TestPrecompiles::<_>::new(); } diff --git a/runtime/common/src/lib.rs b/runtime/common/src/lib.rs index 5bb1198c..8966a564 100644 --- a/runtime/common/src/lib.rs +++ b/runtime/common/src/lib.rs @@ -91,7 +91,7 @@ pub const fn darwinia_deposit(items: u32, bytes: u32) -> Balance { macro_rules! impl_self_contained_call { () => { impl fp_self_contained::SelfContainedCall for RuntimeCall { - type SignedInfo = H160; + type SignedInfo = sp_core::H160; fn is_self_contained(&self) -> bool { match self { @@ -119,7 +119,7 @@ macro_rules! impl_self_contained_call { info: &Self::SignedInfo, dispatch_info: &sp_runtime::traits::DispatchInfoOf, len: usize, - ) -> Option { + ) -> Option { match self { RuntimeCall::Ethereum(call) => call.validate_self_contained(info, dispatch_info, len), diff --git a/runtime/crab/src/lib.rs b/runtime/crab/src/lib.rs index 91e8e956..8558a5c2 100644 --- a/runtime/crab/src/lib.rs +++ b/runtime/crab/src/lib.rs @@ -36,34 +36,14 @@ pub use darwinia_common_runtime::*; pub use dc_primitives::*; pub use sp_consensus_aura::sr25519::AuthorityId as AuraId; -// cumulus -use cumulus_pallet_parachain_system::RelayNumberStrictlyIncreases; -// polkadot -use xcm_executor::XcmExecutor; // substrate -use frame_support::{ - dispatch::DispatchClass, - traits::{AsEnsureOriginWithArg, Imbalance, IsInVec, OnUnbalanced, WithdrawReasons}, - weights::{ConstantMultiplier, Weight}, -}; -use frame_system::{EnsureRoot, EnsureSignedBy}; -use sp_core::{crypto::KeyTypeId, OpaqueMetadata, H160, H256, U256}; -use sp_runtime::{ - generic, - traits::Block as BlockT, - transaction_validity::{TransactionSource, TransactionValidity}, - ApplyExtrinsicResult, Perbill, Permill, -}; use sp_std::prelude::*; -#[cfg(feature = "std")] -use sp_version::NativeVersion; -use sp_version::RuntimeVersion; /// Block type as expected by this runtime. -pub type Block = generic::Block; +pub type Block = sp_runtime::generic::Block; /// A Block signed with a Justification -pub type SignedBlock = generic::SignedBlock; +pub type SignedBlock = sp_runtime::generic::SignedBlock; /// The SignedExtension to the basic transaction logic. pub type SignedExtra = ( @@ -84,7 +64,7 @@ pub type UncheckedExtrinsic = /// Extrinsic type that has already been checked. pub type CheckedExtrinsic = - fp_self_contained::CheckedExtrinsic; + fp_self_contained::CheckedExtrinsic; /// Executive: handles dispatch to the various modules. pub type Executive = frame_executive::Executive< @@ -100,7 +80,7 @@ pub const DARWINIA_PROPOSAL_REQUIREMENT: Balance = 5000 * UNIT; /// Runtime version. #[sp_version::runtime_version] -pub const VERSION: RuntimeVersion = RuntimeVersion { +pub const VERSION: sp_version::RuntimeVersion = sp_version::RuntimeVersion { spec_name: sp_runtime::create_runtime_str!("Crab2"), impl_name: sp_runtime::create_runtime_str!("DarwiniaOfficialRust"), authoring_version: 0, @@ -118,37 +98,48 @@ impl frame_support::traits::OnUnbalanced: OnUnbalanced>, + pallet_treasury::Pallet: + frame_support::traits::OnUnbalanced>, { // this seems to be called for substrate-based transactions fn on_unbalanceds( mut fees_then_tips: impl Iterator>, ) { if let Some(fees) = fees_then_tips.next() { + // substrate + use frame_support::traits::Imbalance; + // for fees, 80% are burned, 20% to the treasury let (_, to_treasury) = fees.ration(80, 20); // Balances pallet automatically burns dropped Negative Imbalances by decreasing // total_supply accordingly - as OnUnbalanced<_>>::on_unbalanced(to_treasury); + as frame_support::traits::OnUnbalanced<_>>::on_unbalanced( + to_treasury, + ); } } // this is called from pallet_evm for Ethereum-based transactions // (technically, it calls on_unbalanced, which calls this when non-zero) fn on_nonzero_unbalanced(amount: pallet_balances::NegativeImbalance) { + // substrate + use frame_support::traits::Imbalance; + // Balances pallet automatically burns dropped Negative Imbalances by decreasing // total_supply accordingly let (_, to_treasury) = amount.ration(80, 20); - as OnUnbalanced<_>>::on_unbalanced(to_treasury); + as frame_support::traits::OnUnbalanced<_>>::on_unbalanced( + to_treasury, + ); } } /// The version information used to identify this runtime when compiled natively. #[cfg(feature = "std")] -pub fn native_version() -> NativeVersion { - NativeVersion { runtime_version: VERSION, can_author_with: Default::default() } +pub fn native_version() -> sp_version::NativeVersion { + sp_version::NativeVersion { runtime_version: VERSION, can_author_with: Default::default() } } // Create the runtime by composing the FRAME pallets that were previously configured. @@ -255,7 +246,7 @@ sp_api::impl_runtime_apis! { } impl sp_api::Core for Runtime { - fn version() -> RuntimeVersion { + fn version() -> sp_version::RuntimeVersion { VERSION } @@ -263,27 +254,27 @@ sp_api::impl_runtime_apis! { Executive::execute_block(block) } - fn initialize_block(header: &::Header) { + fn initialize_block(header: &::Header) { Executive::initialize_block(header) } } impl sp_api::Metadata for Runtime { - fn metadata() -> OpaqueMetadata { - OpaqueMetadata::new(Runtime::metadata().into()) + fn metadata() -> sp_core::OpaqueMetadata { + sp_core::OpaqueMetadata::new(Runtime::metadata().into()) } } impl sp_block_builder::BlockBuilder for Runtime { - fn apply_extrinsic(extrinsic: ::Extrinsic) -> ApplyExtrinsicResult { + fn apply_extrinsic(extrinsic: ::Extrinsic) -> sp_runtime::ApplyExtrinsicResult { Executive::apply_extrinsic(extrinsic) } - fn finalize_block() -> ::Header { + fn finalize_block() -> ::Header { Executive::finalize_block() } - fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<::Extrinsic> { + fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<::Extrinsic> { data.create_extrinsics() } @@ -297,16 +288,16 @@ sp_api::impl_runtime_apis! { impl sp_transaction_pool::runtime_api::TaggedTransactionQueue for Runtime { fn validate_transaction( - source: TransactionSource, - tx: ::Extrinsic, - block_hash: ::Hash, - ) -> TransactionValidity { + source: sp_runtime::transaction_validity::TransactionSource, + tx: ::Extrinsic, + block_hash: ::Hash, + ) -> sp_runtime::transaction_validity::TransactionValidity { Executive::validate_transaction(source, tx, block_hash) } } impl sp_offchain::OffchainWorkerApi for Runtime { - fn offchain_worker(header: &::Header) { + fn offchain_worker(header: &::Header) { Executive::offchain_worker(header) } } @@ -318,7 +309,7 @@ sp_api::impl_runtime_apis! { fn decode_session_keys( encoded: Vec, - ) -> Option, KeyTypeId)>> { + ) -> Option, sp_runtime::KeyTypeId)>> { SessionKeys::decode_into_raw_public_keys(&encoded) } } @@ -331,13 +322,13 @@ sp_api::impl_runtime_apis! { impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi for Runtime { fn query_info( - uxt: ::Extrinsic, + uxt: ::Extrinsic, len: u32, ) -> pallet_transaction_payment_rpc_runtime_api::RuntimeDispatchInfo { TransactionPayment::query_info(uxt, len) } fn query_fee_details( - uxt: ::Extrinsic, + uxt: ::Extrinsic, len: u32, ) -> pallet_transaction_payment::FeeDetails { TransactionPayment::query_fee_details(uxt, len) @@ -362,7 +353,7 @@ sp_api::impl_runtime_apis! { } impl cumulus_primitives_core::CollectCollationInfo for Runtime { - fn collect_collation_info(header: &::Header) -> cumulus_primitives_core::CollationInfo { + fn collect_collation_info(header: &::Header) -> cumulus_primitives_core::CollationInfo { ParachainSystem::collect_collation_info(header) } } @@ -372,13 +363,13 @@ sp_api::impl_runtime_apis! { <::ChainId as frame_support::traits::Get>::get() } - fn account_basic(address: H160) -> pallet_evm::Account { + fn account_basic(address: sp_core::H160) -> pallet_evm::Account { let (account, _) = Evm::account_basic(&address); account } - fn gas_price() -> U256 { + fn gas_price() -> sp_core::U256 { // frontier use pallet_evm::FeeCalculator; @@ -387,33 +378,33 @@ sp_api::impl_runtime_apis! { gas_price } - fn account_code_at(address: H160) -> Vec { + fn account_code_at(address: sp_core::H160) -> Vec { Evm::account_codes(address) } - fn author() -> H160 { + fn author() -> sp_core::H160 { >::find_author() } - fn storage_at(address: H160, index: U256) -> H256 { + fn storage_at(address: sp_core::H160, index: sp_core::U256) -> sp_core::H256 { let mut tmp = [0u8; 32]; index.to_big_endian(&mut tmp); - Evm::account_storages(address, H256::from_slice(&tmp[..])) + Evm::account_storages(address, sp_core::H256::from_slice(&tmp[..])) } fn call( - from: H160, - to: H160, + from: sp_core::H160, + to: sp_core::H160, data: Vec, - value: U256, - gas_limit: U256, - max_fee_per_gas: Option, - max_priority_fee_per_gas: Option, - nonce: Option, + value: sp_core::U256, + gas_limit: sp_core::U256, + max_fee_per_gas: Option, + max_priority_fee_per_gas: Option, + nonce: Option, estimate: bool, - access_list: Option)>>, + access_list: Option)>>, ) -> Result { // frontier use pallet_evm::Runner; @@ -449,15 +440,15 @@ sp_api::impl_runtime_apis! { } fn create( - from: H160, + from: sp_core::H160, data: Vec, - value: U256, - gas_limit: U256, - max_fee_per_gas: Option, - max_priority_fee_per_gas: Option, - nonce: Option, + value: sp_core::U256, + gas_limit: sp_core::U256, + max_fee_per_gas: Option, + max_priority_fee_per_gas: Option, + nonce: Option, estimate: bool, - access_list: Option)>>, + access_list: Option)>>, ) -> Result { // frontier use pallet_evm::Runner; @@ -516,7 +507,7 @@ sp_api::impl_runtime_apis! { } fn extrinsic_filter( - xts: Vec<::Extrinsic>, + xts: Vec<::Extrinsic>, ) -> Vec { xts.into_iter().filter_map(|xt| match xt.0.function { RuntimeCall::Ethereum( @@ -526,7 +517,7 @@ sp_api::impl_runtime_apis! { }).collect::>() } - fn elasticity() -> Option { + fn elasticity() -> Option { None } @@ -536,7 +527,7 @@ sp_api::impl_runtime_apis! { impl fp_rpc::ConvertTransactionRuntimeApi for Runtime { fn convert_transaction( transaction: pallet_ethereum::Transaction - ) -> ::Extrinsic { + ) -> ::Extrinsic { UncheckedExtrinsic::new_unsigned( pallet_ethereum::Call::::transact { transaction }.into(), ) @@ -602,7 +593,7 @@ sp_api::impl_runtime_apis! { #[cfg(feature = "try-runtime")] impl frame_try_runtime::TryRuntime for Runtime { - fn on_runtime_upgrade(checks: bool) -> (Weight, Weight) { + fn on_runtime_upgrade(checks: bool) -> (Weight, frame_support::weights::Weight) { // substrate use frame_support::log; @@ -656,15 +647,13 @@ cumulus_pallet_parachain_system::register_validate_block! { #[cfg(test)] mod tests { // darwinia - use super::{Runtime, WeightPerGas}; - // substrate - use frame_support::dispatch::DispatchClass; + use super::*; #[test] fn configured_base_extrinsic_weight_is_evm_compatible() { let min_ethereum_transaction_weight = WeightPerGas::get() * 21_000; let base_extrinsic = ::BlockWeights::get() - .get(DispatchClass::Normal) + .get(frame_support::dispatch::DispatchClass::Normal) .base_extrinsic; assert!(base_extrinsic.ref_time() <= min_ethereum_transaction_weight.ref_time()); diff --git a/runtime/crab/src/pallets/assets.rs b/runtime/crab/src/pallets/assets.rs index ed9bd71c..73f6c29f 100644 --- a/runtime/crab/src/pallets/assets.rs +++ b/runtime/crab/src/pallets/assets.rs @@ -37,10 +37,12 @@ impl pallet_assets::Config for Runtime { type Balance = Balance; #[cfg(feature = "runtime-benchmarks")] type BenchmarkHelper = (); - type CreateOrigin = AsEnsureOriginWithArg, AccountId>>; + type CreateOrigin = frame_support::traits::AsEnsureOriginWithArg< + frame_system::EnsureSignedBy, AccountId>, + >; type Currency = Balances; type Extra = (); - type ForceOrigin = EnsureRoot; + type ForceOrigin = frame_system::EnsureRoot; type Freezer = (); type MetadataDepositBase = ConstU128<0>; type MetadataDepositPerByte = ConstU128<0>; diff --git a/runtime/crab/src/pallets/bridge_dispatch.rs b/runtime/crab/src/pallets/bridge_dispatch.rs index 8fb3d7a7..b89d78a2 100644 --- a/runtime/crab/src/pallets/bridge_dispatch.rs +++ b/runtime/crab/src/pallets/bridge_dispatch.rs @@ -34,7 +34,7 @@ impl bp_message_dispatch::CallValidate fo let total_payment = darwinia_message_transact::total_payment::((&**tx).into()); let relayer = - pallet_evm::Pallet::::account_basic(&H160(relayer_account.0)).0; + pallet_evm::Pallet::::account_basic(&sp_core::H160(relayer_account.0)).0; frame_support::ensure!(relayer.balance >= total_payment, "Insufficient balance"); Ok(()) @@ -87,7 +87,7 @@ impl bp_message_dispatch::IntoDispatchOrigin darwinia_message_transact::LcmpEthOrigin::MessageTransact(H160(id.0)).into(), + }) => darwinia_message_transact::LcmpEthOrigin::MessageTransact(sp_core::H160(id.0)).into(), _ => frame_system::RawOrigin::Signed(*id).into(), } } diff --git a/runtime/crab/src/pallets/dmp_queue.rs b/runtime/crab/src/pallets/dmp_queue.rs index d31b4543..17313c1b 100644 --- a/runtime/crab/src/pallets/dmp_queue.rs +++ b/runtime/crab/src/pallets/dmp_queue.rs @@ -20,7 +20,7 @@ use crate::*; impl cumulus_pallet_dmp_queue::Config for Runtime { - type ExecuteOverweightOrigin = EnsureRoot; + type ExecuteOverweightOrigin = frame_system::EnsureRoot; type RuntimeEvent = RuntimeEvent; - type XcmExecutor = XcmExecutor; + type XcmExecutor = xcm_executor::XcmExecutor; } diff --git a/runtime/crab/src/pallets/evm.rs b/runtime/crab/src/pallets/evm.rs index 9f07703c..38982cf3 100644 --- a/runtime/crab/src/pallets/evm.rs +++ b/runtime/crab/src/pallets/evm.rs @@ -24,16 +24,16 @@ use pallet_evm::Precompile; const WEIGHT_PER_GAS: u64 = 40_000; frame_support::parameter_types! { - pub BlockGasLimit: U256 = U256::from(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT.ref_time() / WEIGHT_PER_GAS); + pub BlockGasLimit: sp_core::U256 = sp_core::U256::from(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT.ref_time() / WEIGHT_PER_GAS); pub PrecompilesValue: CrabPrecompiles = CrabPrecompiles::<_>::new(); - pub WeightPerGas: Weight = Weight::from_ref_time(WEIGHT_PER_GAS); + pub WeightPerGas: frame_support::weights::Weight = frame_support::weights::Weight::from_ref_time(WEIGHT_PER_GAS); } pub struct FindAuthorTruncated(sp_std::marker::PhantomData); -impl> frame_support::traits::FindAuthor +impl> frame_support::traits::FindAuthor for FindAuthorTruncated { - fn find_author<'a, I>(digests: I) -> Option + fn find_author<'a, I>(digests: I) -> Option where I: 'a + IntoIterator, { @@ -45,7 +45,7 @@ impl> frame_support::traits::FindAutho let raw = id.to_raw_vec(); if raw.len() >= 24 { - Some(H160::from_slice(&raw[4..24])) + Some(sp_core::H160::from_slice(&raw[4..24])) } else { None } @@ -56,8 +56,8 @@ impl> frame_support::traits::FindAutho pub struct FixedGasPrice; impl pallet_evm::FeeCalculator for FixedGasPrice { - fn min_gas_price() -> (U256, Weight) { - (U256::from(GWEI), Weight::zero()) + fn min_gas_price() -> (sp_core::U256, frame_support::weights::Weight) { + (sp_core::U256::from(GWEI), frame_support::weights::Weight::zero()) } } @@ -65,9 +65,9 @@ impl pallet_evm::FeeCalculator for FixedGasPrice { pub struct FromH160; impl pallet_evm::AddressMapping for FromH160 where - T: From, + T: From, { - fn into_account_id(address: H160) -> T { + fn into_account_id(address: sp_core::H160) -> T { address.into() } } @@ -75,7 +75,7 @@ where pub struct AssetIdConverter; impl darwinia_precompile_assets::AccountToAssetId for AssetIdConverter { fn account_to_asset_id(account_id: AccountId) -> AssetId { - let addr: H160 = account_id.into(); + let addr: sp_core::H160 = account_id.into(); addr.to_low_u64_be() } } @@ -90,7 +90,7 @@ where Self(Default::default()) } - pub fn used_addresses() -> [H160; 15] { + pub fn used_addresses() -> [sp_core::H160; 15] { [ addr(1), addr(2), @@ -164,7 +164,7 @@ where } } - fn is_precompile(&self, address: H160) -> bool { + fn is_precompile(&self, address: sp_core::H160) -> bool { Self::used_addresses().contains(&address) } } @@ -188,6 +188,6 @@ impl pallet_evm::Config for Runtime { type WithdrawOrigin = pallet_evm::EnsureAddressNever; } -fn addr(a: u64) -> H160 { - H160::from_low_u64_be(a) +fn addr(a: u64) -> sp_core::H160 { + sp_core::H160::from_low_u64_be(a) } diff --git a/runtime/crab/src/pallets/parachain_system.rs b/runtime/crab/src/pallets/parachain_system.rs index 42af9626..0f776807 100644 --- a/runtime/crab/src/pallets/parachain_system.rs +++ b/runtime/crab/src/pallets/parachain_system.rs @@ -20,12 +20,12 @@ use crate::*; frame_support::parameter_types! { - pub const ReservedXcmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT.saturating_div(4); - pub const ReservedDmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT.saturating_div(4); + pub const ReservedXcmpWeight: frame_support::weights::Weight = MAXIMUM_BLOCK_WEIGHT.saturating_div(4); + pub const ReservedDmpWeight: frame_support::weights::Weight = MAXIMUM_BLOCK_WEIGHT.saturating_div(4); } impl cumulus_pallet_parachain_system::Config for Runtime { - type CheckAssociatedRelayNumber = RelayNumberStrictlyIncreases; + type CheckAssociatedRelayNumber = cumulus_pallet_parachain_system::RelayNumberStrictlyIncreases; type DmpMessageHandler = DmpQueue; type OnSystemEvent = (); type OutboundXcmpMessageSource = XcmpQueue; diff --git a/runtime/crab/src/pallets/polkadot_xcm.rs b/runtime/crab/src/pallets/polkadot_xcm.rs index 5046b8de..4d0b7ba0 100644 --- a/runtime/crab/src/pallets/polkadot_xcm.rs +++ b/runtime/crab/src/pallets/polkadot_xcm.rs @@ -135,7 +135,7 @@ impl xcm_executor::Config for XcmExecutorConfig { type RuntimeCall = RuntimeCall; type SubscriptionService = PolkadotXcm; type Trader = xcm_configs::LocalAssetTrader< - ConstantMultiplier, + frame_support::weights::ConstantMultiplier, AnchoringSelfReserve, AccountId, Balances, diff --git a/runtime/crab/src/pallets/preimage.rs b/runtime/crab/src/pallets/preimage.rs index fc31bb73..d049ef1c 100644 --- a/runtime/crab/src/pallets/preimage.rs +++ b/runtime/crab/src/pallets/preimage.rs @@ -23,7 +23,7 @@ impl pallet_preimage::Config for Runtime { type BaseDeposit = ConstU128<{ 500 * UNIT }>; type ByteDeposit = ConstU128<{ darwinia_deposit(0, 1) }>; type Currency = Balances; - type ManagerOrigin = EnsureRoot; + type ManagerOrigin = frame_system::EnsureRoot; type RuntimeEvent = RuntimeEvent; type WeightInfo = (); } diff --git a/runtime/crab/src/pallets/system.rs b/runtime/crab/src/pallets/system.rs index 43a82603..e5f331a7 100644 --- a/runtime/crab/src/pallets/system.rs +++ b/runtime/crab/src/pallets/system.rs @@ -21,17 +21,18 @@ use crate::*; /// We assume that ~5% of the block weight is consumed by `on_initialize` handlers. This is /// used to limit the maximal weight of a single extrinsic. -const AVERAGE_ON_INITIALIZE_RATIO: Perbill = Perbill::from_percent(5); +const AVERAGE_ON_INITIALIZE_RATIO: sp_runtime::Perbill = sp_runtime::Perbill::from_percent(5); /// We allow `Normal` extrinsics to fill up the block up to 75%, the rest can be used by /// `Operational` extrinsics. -pub const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75); +pub const NORMAL_DISPATCH_RATIO: sp_runtime::Perbill = sp_runtime::Perbill::from_percent(75); /// We allow for 0.5 of a second of compute with a 12 second average block time. -pub const MAXIMUM_BLOCK_WEIGHT: Weight = Weight::from_parts( - frame_support::weights::constants::WEIGHT_REF_TIME_PER_SECOND.saturating_div(2), - cumulus_primitives_core::relay_chain::v2::MAX_POV_SIZE as u64, -); +pub const MAXIMUM_BLOCK_WEIGHT: frame_support::weights::Weight = + frame_support::weights::Weight::from_parts( + frame_support::weights::constants::WEIGHT_REF_TIME_PER_SECOND.saturating_div(2), + cumulus_primitives_core::relay_chain::v2::MAX_POV_SIZE as u64, + ); frame_support::parameter_types! { pub const Version: sp_version::RuntimeVersion = VERSION; @@ -39,13 +40,13 @@ frame_support::parameter_types! { frame_system::limits::BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO); pub RuntimeBlockWeights: frame_system::limits::BlockWeights = frame_system::limits::BlockWeights::builder() .base_block(weights::BlockExecutionWeight::get()) - .for_class(DispatchClass::all(), |weights| { + .for_class(frame_support::dispatch::DispatchClass::all(), |weights| { weights.base_extrinsic = weights::ExtrinsicBaseWeight::get(); }) - .for_class(DispatchClass::Normal, |weights| { + .for_class(frame_support::dispatch::DispatchClass::Normal, |weights| { weights.max_total = Some(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT); }) - .for_class(DispatchClass::Operational, |weights| { + .for_class(frame_support::dispatch::DispatchClass::Operational, |weights| { weights.max_total = Some(MAXIMUM_BLOCK_WEIGHT); // Operational transactions have some extra reserved space, so that they // are included even if block reached `MAXIMUM_BLOCK_WEIGHT`. @@ -79,7 +80,7 @@ impl frame_system::Config for Runtime { /// The hashing algorithm used. type Hashing = Hashing; /// The header type. - type Header = generic::Header; + type Header = sp_runtime::generic::Header; /// The index type for storing how many extrinsics an account has signed. type Index = Index; /// The lookup mechanism to get account ID from whatever is passed in dispatchers. diff --git a/runtime/crab/src/pallets/transaction_payment.rs b/runtime/crab/src/pallets/transaction_payment.rs index 970135a5..6080dfeb 100644 --- a/runtime/crab/src/pallets/transaction_payment.rs +++ b/runtime/crab/src/pallets/transaction_payment.rs @@ -22,7 +22,7 @@ use crate::*; impl pallet_transaction_payment::Config for Runtime { type FeeMultiplierUpdate = polkadot_runtime_common::SlowAdjustingFeeUpdate; // Relay Chain `TransactionByteFee` / 10 - type LengthToFee = ConstantMultiplier>; + type LengthToFee = frame_support::weights::ConstantMultiplier>; type OnChargeTransaction = pallet_transaction_payment::CurrencyAdapter>; type OperationalFeeMultiplier = sp_runtime::traits::ConstU8<5>; diff --git a/runtime/crab/src/pallets/vesting.rs b/runtime/crab/src/pallets/vesting.rs index ca01513e..1c0b0b6e 100644 --- a/runtime/crab/src/pallets/vesting.rs +++ b/runtime/crab/src/pallets/vesting.rs @@ -20,8 +20,10 @@ use crate::*; frame_support::parameter_types! { - pub UnvestedFundsAllowedWithdrawReasons: WithdrawReasons = - WithdrawReasons::except(WithdrawReasons::TRANSFER | WithdrawReasons::RESERVE); + pub UnvestedFundsAllowedWithdrawReasons: frame_support::traits::WithdrawReasons = + frame_support::traits::WithdrawReasons::except( + frame_support::traits::WithdrawReasons::TRANSFER | frame_support::traits::WithdrawReasons::RESERVE + ); } impl pallet_vesting::Config for Runtime { diff --git a/runtime/crab/src/pallets/xcmp_queue.rs b/runtime/crab/src/pallets/xcmp_queue.rs index e90975a6..f3f8d642 100644 --- a/runtime/crab/src/pallets/xcmp_queue.rs +++ b/runtime/crab/src/pallets/xcmp_queue.rs @@ -21,11 +21,11 @@ use crate::*; impl cumulus_pallet_xcmp_queue::Config for Runtime { type ChannelInfo = ParachainSystem; - type ControllerOrigin = EnsureRoot; + type ControllerOrigin = frame_system::EnsureRoot; type ControllerOriginConverter = XcmOriginToTransactDispatchOrigin; - type ExecuteOverweightOrigin = EnsureRoot; + type ExecuteOverweightOrigin = frame_system::EnsureRoot; type RuntimeEvent = RuntimeEvent; type VersionWrapper = (); type WeightInfo = weights::cumulus_pallet_xcmp_queue::WeightInfo; - type XcmExecutor = XcmExecutor; + type XcmExecutor = xcm_executor::XcmExecutor; } diff --git a/runtime/crab/src/weights/block_weights.rs b/runtime/crab/src/weights/block_weights.rs index 66279be1..8da49f75 100644 --- a/runtime/crab/src/weights/block_weights.rs +++ b/runtime/crab/src/weights/block_weights.rs @@ -16,35 +16,31 @@ // limitations under the License. pub mod constants { - use frame_support::{ - parameter_types, - weights::{constants, Weight}, - }; - - parameter_types! { + frame_support::parameter_types! { /// Importing a block with 0 Extrinsics. - pub const BlockExecutionWeight: Weight = Weight::from_ref_time(constants::WEIGHT_REF_TIME_PER_NANOS.saturating_mul(5_000_000)); + pub const BlockExecutionWeight: frame_support::weights::Weight = + frame_support::weights::Weight::from_ref_time(frame_support::weights::constants::WEIGHT_REF_TIME_PER_NANOS.saturating_mul(5_000_000)); } #[cfg(test)] mod test_weights { - use frame_support::weights::constants; - /// Checks that the weight exists and is sane. // NOTE: If this test fails but you are sure that the generated values are fine, // you can delete it. #[test] fn sane() { - let w = super::constants::BlockExecutionWeight::get(); + let w = frame_support::weights::constants::BlockExecutionWeight::get(); // At least 100 µs. assert!( - w.ref_time() >= 100u64 * constants::WEIGHT_REF_TIME_PER_MICROS, + w.ref_time() + >= 100u64 * frame_support::weights::constants::WEIGHT_REF_TIME_PER_MICROS, "Weight should be at least 100 µs." ); // At most 50 ms. assert!( - w.ref_time() <= 50u64 * constants::WEIGHT_REF_TIME_PER_MILLIS, + w.ref_time() + <= 50u64 * frame_support::weights::constants::WEIGHT_REF_TIME_PER_MILLIS, "Weight should be at most 50 ms." ); } diff --git a/runtime/crab/src/weights/extrinsic_weights.rs b/runtime/crab/src/weights/extrinsic_weights.rs index 48868670..0c17b0de 100644 --- a/runtime/crab/src/weights/extrinsic_weights.rs +++ b/runtime/crab/src/weights/extrinsic_weights.rs @@ -16,35 +16,30 @@ // limitations under the License. pub mod constants { - use frame_support::{ - parameter_types, - weights::{constants, Weight}, - }; - - parameter_types! { + frame_support::parameter_types! { /// Executing a NO-OP `System::remarks` Extrinsic. - pub const ExtrinsicBaseWeight: Weight = Weight::from_ref_time(constants::WEIGHT_REF_TIME_PER_NANOS.saturating_mul(125_000)); + pub const ExtrinsicBaseWeight: frame_support::weights::Weight = + frame_support::weights::Weight::from_ref_time(frame_support::weights::constants::WEIGHT_REF_TIME_PER_NANOS.saturating_mul(125_000)); } #[cfg(test)] mod test_weights { - use frame_support::weights::constants; - /// Checks that the weight exists and is sane. // NOTE: If this test fails but you are sure that the generated values are fine, // you can delete it. #[test] fn sane() { - let w = super::constants::ExtrinsicBaseWeight::get(); + let w = frame_support::weights::constants::ExtrinsicBaseWeight::get(); // At least 10 µs. assert!( - w.ref_time() >= 10u64 * constants::WEIGHT_REF_TIME_PER_MICROS, + w.ref_time() + >= 10u64 * frame_support::weights::constants::WEIGHT_REF_TIME_PER_MICROS, "Weight should be at least 10 µs." ); // At most 1 ms. assert!( - w.ref_time() <= constants::WEIGHT_REF_TIME_PER_MILLIS, + w.ref_time() <= frame_support::weights::constants::WEIGHT_REF_TIME_PER_MILLIS, "Weight should be at most 1 ms." ); } diff --git a/runtime/darwinia/src/lib.rs b/runtime/darwinia/src/lib.rs index 8e00e144..edd48fe3 100644 --- a/runtime/darwinia/src/lib.rs +++ b/runtime/darwinia/src/lib.rs @@ -36,34 +36,14 @@ pub use darwinia_common_runtime::*; pub use dc_primitives::*; pub use sp_consensus_aura::sr25519::AuthorityId as AuraId; -// cumulus -use cumulus_pallet_parachain_system::RelayNumberStrictlyIncreases; -// polkadot -use xcm_executor::XcmExecutor; // substrate -use frame_support::{ - dispatch::DispatchClass, - traits::{AsEnsureOriginWithArg, Imbalance, IsInVec, OnUnbalanced, WithdrawReasons}, - weights::{ConstantMultiplier, Weight}, -}; -use frame_system::{EnsureRoot, EnsureSignedBy}; -use sp_core::{crypto::KeyTypeId, OpaqueMetadata, H160, H256, U256}; -use sp_runtime::{ - generic, - traits::Block as BlockT, - transaction_validity::{TransactionSource, TransactionValidity}, - ApplyExtrinsicResult, Perbill, Permill, -}; use sp_std::prelude::*; -#[cfg(feature = "std")] -use sp_version::NativeVersion; -use sp_version::RuntimeVersion; /// Block type as expected by this runtime. -pub type Block = generic::Block; +pub type Block = sp_runtime::generic::Block; /// A Block signed with a Justification -pub type SignedBlock = generic::SignedBlock; +pub type SignedBlock = sp_runtime::generic::SignedBlock; /// The SignedExtension to the basic transaction logic. pub type SignedExtra = ( @@ -84,7 +64,7 @@ pub type UncheckedExtrinsic = /// Extrinsic type that has already been checked. pub type CheckedExtrinsic = - fp_self_contained::CheckedExtrinsic; + fp_self_contained::CheckedExtrinsic; /// Executive: handles dispatch to the various modules. pub type Executive = frame_executive::Executive< @@ -100,7 +80,7 @@ pub const DARWINIA_PROPOSAL_REQUIREMENT: Balance = 5000 * UNIT; /// Runtime version. #[sp_version::runtime_version] -pub const VERSION: RuntimeVersion = RuntimeVersion { +pub const VERSION: sp_version::RuntimeVersion = sp_version::RuntimeVersion { spec_name: sp_runtime::create_runtime_str!("Darwinia2"), impl_name: sp_runtime::create_runtime_str!("DarwiniaOfficialRust"), authoring_version: 0, @@ -118,37 +98,48 @@ impl frame_support::traits::OnUnbalanced: OnUnbalanced>, + pallet_treasury::Pallet: + frame_support::traits::OnUnbalanced>, { // this seems to be called for substrate-based transactions fn on_unbalanceds( mut fees_then_tips: impl Iterator>, ) { if let Some(fees) = fees_then_tips.next() { + // substrate + use frame_support::traits::Imbalance; + // for fees, 80% are burned, 20% to the treasury let (_, to_treasury) = fees.ration(80, 20); // Balances pallet automatically burns dropped Negative Imbalances by decreasing // total_supply accordingly - as OnUnbalanced<_>>::on_unbalanced(to_treasury); + as frame_support::traits::OnUnbalanced<_>>::on_unbalanced( + to_treasury, + ); } } // this is called from pallet_evm for Ethereum-based transactions // (technically, it calls on_unbalanced, which calls this when non-zero) fn on_nonzero_unbalanced(amount: pallet_balances::NegativeImbalance) { + // substrate + use frame_support::traits::Imbalance; + // Balances pallet automatically burns dropped Negative Imbalances by decreasing // total_supply accordingly let (_, to_treasury) = amount.ration(80, 20); - as OnUnbalanced<_>>::on_unbalanced(to_treasury); + as frame_support::traits::OnUnbalanced<_>>::on_unbalanced( + to_treasury, + ); } } /// The version information used to identify this runtime when compiled natively. #[cfg(feature = "std")] -pub fn native_version() -> NativeVersion { - NativeVersion { runtime_version: VERSION, can_author_with: Default::default() } +pub fn native_version() -> sp_version::NativeVersion { + sp_version::NativeVersion { runtime_version: VERSION, can_author_with: Default::default() } } // Create the runtime by composing the FRAME pallets that were previously configured. @@ -255,7 +246,7 @@ sp_api::impl_runtime_apis! { } impl sp_api::Core for Runtime { - fn version() -> RuntimeVersion { + fn version() -> sp_version::RuntimeVersion { VERSION } @@ -263,27 +254,27 @@ sp_api::impl_runtime_apis! { Executive::execute_block(block) } - fn initialize_block(header: &::Header) { + fn initialize_block(header: &::Header) { Executive::initialize_block(header) } } impl sp_api::Metadata for Runtime { - fn metadata() -> OpaqueMetadata { - OpaqueMetadata::new(Runtime::metadata().into()) + fn metadata() -> sp_core::OpaqueMetadata { + sp_core::OpaqueMetadata::new(Runtime::metadata().into()) } } impl sp_block_builder::BlockBuilder for Runtime { - fn apply_extrinsic(extrinsic: ::Extrinsic) -> ApplyExtrinsicResult { + fn apply_extrinsic(extrinsic: ::Extrinsic) -> sp_runtime::ApplyExtrinsicResult { Executive::apply_extrinsic(extrinsic) } - fn finalize_block() -> ::Header { + fn finalize_block() -> ::Header { Executive::finalize_block() } - fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<::Extrinsic> { + fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<::Extrinsic> { data.create_extrinsics() } @@ -297,16 +288,16 @@ sp_api::impl_runtime_apis! { impl sp_transaction_pool::runtime_api::TaggedTransactionQueue for Runtime { fn validate_transaction( - source: TransactionSource, - tx: ::Extrinsic, - block_hash: ::Hash, - ) -> TransactionValidity { + source: sp_runtime::transaction_validity::TransactionSource, + tx: ::Extrinsic, + block_hash: ::Hash, + ) -> sp_runtime::transaction_validity::TransactionValidity { Executive::validate_transaction(source, tx, block_hash) } } impl sp_offchain::OffchainWorkerApi for Runtime { - fn offchain_worker(header: &::Header) { + fn offchain_worker(header: &::Header) { Executive::offchain_worker(header) } } @@ -318,7 +309,7 @@ sp_api::impl_runtime_apis! { fn decode_session_keys( encoded: Vec, - ) -> Option, KeyTypeId)>> { + ) -> Option, sp_runtime::KeyTypeId)>> { SessionKeys::decode_into_raw_public_keys(&encoded) } } @@ -331,13 +322,13 @@ sp_api::impl_runtime_apis! { impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi for Runtime { fn query_info( - uxt: ::Extrinsic, + uxt: ::Extrinsic, len: u32, ) -> pallet_transaction_payment_rpc_runtime_api::RuntimeDispatchInfo { TransactionPayment::query_info(uxt, len) } fn query_fee_details( - uxt: ::Extrinsic, + uxt: ::Extrinsic, len: u32, ) -> pallet_transaction_payment::FeeDetails { TransactionPayment::query_fee_details(uxt, len) @@ -362,7 +353,7 @@ sp_api::impl_runtime_apis! { } impl cumulus_primitives_core::CollectCollationInfo for Runtime { - fn collect_collation_info(header: &::Header) -> cumulus_primitives_core::CollationInfo { + fn collect_collation_info(header: &::Header) -> cumulus_primitives_core::CollationInfo { ParachainSystem::collect_collation_info(header) } } @@ -372,13 +363,13 @@ sp_api::impl_runtime_apis! { <::ChainId as frame_support::traits::Get>::get() } - fn account_basic(address: H160) -> pallet_evm::Account { + fn account_basic(address: sp_core::H160) -> pallet_evm::Account { let (account, _) = Evm::account_basic(&address); account } - fn gas_price() -> U256 { + fn gas_price() -> sp_core::U256 { // frontier use pallet_evm::FeeCalculator; @@ -387,33 +378,33 @@ sp_api::impl_runtime_apis! { gas_price } - fn account_code_at(address: H160) -> Vec { + fn account_code_at(address: sp_core::H160) -> Vec { Evm::account_codes(address) } - fn author() -> H160 { + fn author() -> sp_core::H160 { >::find_author() } - fn storage_at(address: H160, index: U256) -> H256 { + fn storage_at(address: sp_core::H160, index: sp_core::U256) -> sp_core::H256 { let mut tmp = [0u8; 32]; index.to_big_endian(&mut tmp); - Evm::account_storages(address, H256::from_slice(&tmp[..])) + Evm::account_storages(address, sp_core::H256::from_slice(&tmp[..])) } fn call( - from: H160, - to: H160, + from: sp_core::H160, + to: sp_core::H160, data: Vec, - value: U256, - gas_limit: U256, - max_fee_per_gas: Option, - max_priority_fee_per_gas: Option, - nonce: Option, + value: sp_core::U256, + gas_limit: sp_core::U256, + max_fee_per_gas: Option, + max_priority_fee_per_gas: Option, + nonce: Option, estimate: bool, - access_list: Option)>>, + access_list: Option)>>, ) -> Result { // frontier use pallet_evm::Runner; @@ -449,15 +440,15 @@ sp_api::impl_runtime_apis! { } fn create( - from: H160, + from: sp_core::H160, data: Vec, - value: U256, - gas_limit: U256, - max_fee_per_gas: Option, - max_priority_fee_per_gas: Option, - nonce: Option, + value: sp_core::U256, + gas_limit: sp_core::U256, + max_fee_per_gas: Option, + max_priority_fee_per_gas: Option, + nonce: Option, estimate: bool, - access_list: Option)>>, + access_list: Option)>>, ) -> Result { // frontier use pallet_evm::Runner; @@ -516,7 +507,7 @@ sp_api::impl_runtime_apis! { } fn extrinsic_filter( - xts: Vec<::Extrinsic>, + xts: Vec<::Extrinsic>, ) -> Vec { xts.into_iter().filter_map(|xt| match xt.0.function { RuntimeCall::Ethereum( @@ -526,7 +517,7 @@ sp_api::impl_runtime_apis! { }).collect::>() } - fn elasticity() -> Option { + fn elasticity() -> Option { None } @@ -537,7 +528,7 @@ sp_api::impl_runtime_apis! { impl fp_rpc::ConvertTransactionRuntimeApi for Runtime { fn convert_transaction( transaction: pallet_ethereum::Transaction - ) -> ::Extrinsic { + ) -> ::Extrinsic { UncheckedExtrinsic::new_unsigned( pallet_ethereum::Call::::transact { transaction }.into(), ) @@ -603,7 +594,7 @@ sp_api::impl_runtime_apis! { #[cfg(feature = "try-runtime")] impl frame_try_runtime::TryRuntime for Runtime { - fn on_runtime_upgrade(checks: bool) -> (Weight, Weight) { + fn on_runtime_upgrade(checks: bool) -> (Weight, frame_support::weights::Weight) { // substrate use frame_support::log; @@ -657,15 +648,13 @@ cumulus_pallet_parachain_system::register_validate_block! { #[cfg(test)] mod tests { // darwinia - use super::{Runtime, WeightPerGas}; - // substrate - use frame_support::dispatch::DispatchClass; + use super::*; #[test] fn configured_base_extrinsic_weight_is_evm_compatible() { let min_ethereum_transaction_weight = WeightPerGas::get() * 21_000; let base_extrinsic = ::BlockWeights::get() - .get(DispatchClass::Normal) + .get(frame_support::dispatch::DispatchClass::Normal) .base_extrinsic; assert!(base_extrinsic.ref_time() <= min_ethereum_transaction_weight.ref_time()); diff --git a/runtime/darwinia/src/pallets/assets.rs b/runtime/darwinia/src/pallets/assets.rs index 903856ed..ebd52e78 100644 --- a/runtime/darwinia/src/pallets/assets.rs +++ b/runtime/darwinia/src/pallets/assets.rs @@ -37,10 +37,12 @@ impl pallet_assets::Config for Runtime { type Balance = Balance; #[cfg(feature = "runtime-benchmarks")] type BenchmarkHelper = (); - type CreateOrigin = AsEnsureOriginWithArg, AccountId>>; + type CreateOrigin = frame_support::traits::AsEnsureOriginWithArg< + frame_system::EnsureSignedBy, AccountId>, + >; type Currency = Balances; type Extra = (); - type ForceOrigin = EnsureRoot; + type ForceOrigin = frame_system::EnsureRoot; type Freezer = (); type MetadataDepositBase = ConstU128<0>; type MetadataDepositPerByte = ConstU128<0>; diff --git a/runtime/darwinia/src/pallets/bridge_dispatch.rs b/runtime/darwinia/src/pallets/bridge_dispatch.rs index 978cf7f1..4db96900 100644 --- a/runtime/darwinia/src/pallets/bridge_dispatch.rs +++ b/runtime/darwinia/src/pallets/bridge_dispatch.rs @@ -34,7 +34,7 @@ impl bp_message_dispatch::CallValidate fo let total_payment = darwinia_message_transact::total_payment::((&**tx).into()); let relayer = - pallet_evm::Pallet::::account_basic(&H160(relayer_account.0)).0; + pallet_evm::Pallet::::account_basic(&sp_core::H160(relayer_account.0)).0; frame_support::ensure!(relayer.balance >= total_payment, "Insufficient balance"); Ok(()) @@ -87,7 +87,7 @@ impl bp_message_dispatch::IntoDispatchOrigin darwinia_message_transact::LcmpEthOrigin::MessageTransact(H160(id.0)).into(), + }) => darwinia_message_transact::LcmpEthOrigin::MessageTransact(sp_core::H160(id.0)).into(), _ => frame_system::RawOrigin::Signed(*id).into(), } } diff --git a/runtime/darwinia/src/pallets/dmp_queue.rs b/runtime/darwinia/src/pallets/dmp_queue.rs index d31b4543..17313c1b 100644 --- a/runtime/darwinia/src/pallets/dmp_queue.rs +++ b/runtime/darwinia/src/pallets/dmp_queue.rs @@ -20,7 +20,7 @@ use crate::*; impl cumulus_pallet_dmp_queue::Config for Runtime { - type ExecuteOverweightOrigin = EnsureRoot; + type ExecuteOverweightOrigin = frame_system::EnsureRoot; type RuntimeEvent = RuntimeEvent; - type XcmExecutor = XcmExecutor; + type XcmExecutor = xcm_executor::XcmExecutor; } diff --git a/runtime/darwinia/src/pallets/evm.rs b/runtime/darwinia/src/pallets/evm.rs index 8578cc1b..a5f35c3e 100644 --- a/runtime/darwinia/src/pallets/evm.rs +++ b/runtime/darwinia/src/pallets/evm.rs @@ -24,16 +24,16 @@ use pallet_evm::Precompile; const WEIGHT_PER_GAS: u64 = 40_000; frame_support::parameter_types! { - pub BlockGasLimit: U256 = U256::from(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT.ref_time() / WEIGHT_PER_GAS); + pub BlockGasLimit: sp_core::U256 = sp_core::U256::from(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT.ref_time() / WEIGHT_PER_GAS); pub PrecompilesValue: DarwiniaPrecompiles = DarwiniaPrecompiles::<_>::new(); - pub WeightPerGas: Weight = Weight::from_ref_time(WEIGHT_PER_GAS); + pub WeightPerGas: frame_support::weights::Weight = frame_support::weights::Weight::from_ref_time(WEIGHT_PER_GAS); } pub struct FindAuthorTruncated(sp_std::marker::PhantomData); -impl> frame_support::traits::FindAuthor +impl> frame_support::traits::FindAuthor for FindAuthorTruncated { - fn find_author<'a, I>(digests: I) -> Option + fn find_author<'a, I>(digests: I) -> Option where I: 'a + IntoIterator, { @@ -45,7 +45,7 @@ impl> frame_support::traits::FindAutho let raw = id.to_raw_vec(); if raw.len() >= 24 { - Some(H160::from_slice(&raw[4..24])) + Some(sp_core::H160::from_slice(&raw[4..24])) } else { None } @@ -56,8 +56,8 @@ impl> frame_support::traits::FindAutho pub struct FixedGasPrice; impl pallet_evm::FeeCalculator for FixedGasPrice { - fn min_gas_price() -> (U256, Weight) { - (U256::from(GWEI), Weight::zero()) + fn min_gas_price() -> (sp_core::U256, frame_support::weights::Weight) { + (sp_core::U256::from(GWEI), frame_support::weights::Weight::zero()) } } @@ -65,9 +65,9 @@ impl pallet_evm::FeeCalculator for FixedGasPrice { pub struct FromH160; impl pallet_evm::AddressMapping for FromH160 where - T: From, + T: From, { - fn into_account_id(address: H160) -> T { + fn into_account_id(address: sp_core::H160) -> T { address.into() } } @@ -75,7 +75,7 @@ where pub struct AssetIdConverter; impl darwinia_precompile_assets::AccountToAssetId for AssetIdConverter { fn account_to_asset_id(account_id: AccountId) -> AssetId { - let addr: H160 = account_id.into(); + let addr: sp_core::H160 = account_id.into(); addr.to_low_u64_be() } } @@ -90,7 +90,7 @@ where Self(Default::default()) } - pub fn used_addresses() -> [H160; 15] { + pub fn used_addresses() -> [sp_core::H160; 15] { [ addr(1), addr(2), @@ -164,7 +164,7 @@ where } } - fn is_precompile(&self, address: H160) -> bool { + fn is_precompile(&self, address: sp_core::H160) -> bool { Self::used_addresses().contains(&address) } } @@ -188,6 +188,6 @@ impl pallet_evm::Config for Runtime { type WithdrawOrigin = pallet_evm::EnsureAddressNever; } -fn addr(a: u64) -> H160 { - H160::from_low_u64_be(a) +fn addr(a: u64) -> sp_core::H160 { + sp_core::H160::from_low_u64_be(a) } diff --git a/runtime/darwinia/src/pallets/parachain_system.rs b/runtime/darwinia/src/pallets/parachain_system.rs index 42af9626..0f776807 100644 --- a/runtime/darwinia/src/pallets/parachain_system.rs +++ b/runtime/darwinia/src/pallets/parachain_system.rs @@ -20,12 +20,12 @@ use crate::*; frame_support::parameter_types! { - pub const ReservedXcmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT.saturating_div(4); - pub const ReservedDmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT.saturating_div(4); + pub const ReservedXcmpWeight: frame_support::weights::Weight = MAXIMUM_BLOCK_WEIGHT.saturating_div(4); + pub const ReservedDmpWeight: frame_support::weights::Weight = MAXIMUM_BLOCK_WEIGHT.saturating_div(4); } impl cumulus_pallet_parachain_system::Config for Runtime { - type CheckAssociatedRelayNumber = RelayNumberStrictlyIncreases; + type CheckAssociatedRelayNumber = cumulus_pallet_parachain_system::RelayNumberStrictlyIncreases; type DmpMessageHandler = DmpQueue; type OnSystemEvent = (); type OutboundXcmpMessageSource = XcmpQueue; diff --git a/runtime/darwinia/src/pallets/polkadot_xcm.rs b/runtime/darwinia/src/pallets/polkadot_xcm.rs index 90785878..cb15c743 100644 --- a/runtime/darwinia/src/pallets/polkadot_xcm.rs +++ b/runtime/darwinia/src/pallets/polkadot_xcm.rs @@ -135,7 +135,7 @@ impl xcm_executor::Config for XcmExecutorConfig { type RuntimeCall = RuntimeCall; type SubscriptionService = PolkadotXcm; type Trader = xcm_configs::LocalAssetTrader< - ConstantMultiplier, + frame_support::weights::ConstantMultiplier, AnchoringSelfReserve, AccountId, Balances, diff --git a/runtime/darwinia/src/pallets/preimage.rs b/runtime/darwinia/src/pallets/preimage.rs index fc31bb73..d049ef1c 100644 --- a/runtime/darwinia/src/pallets/preimage.rs +++ b/runtime/darwinia/src/pallets/preimage.rs @@ -23,7 +23,7 @@ impl pallet_preimage::Config for Runtime { type BaseDeposit = ConstU128<{ 500 * UNIT }>; type ByteDeposit = ConstU128<{ darwinia_deposit(0, 1) }>; type Currency = Balances; - type ManagerOrigin = EnsureRoot; + type ManagerOrigin = frame_system::EnsureRoot; type RuntimeEvent = RuntimeEvent; type WeightInfo = (); } diff --git a/runtime/darwinia/src/pallets/system.rs b/runtime/darwinia/src/pallets/system.rs index 43a82603..e5f331a7 100644 --- a/runtime/darwinia/src/pallets/system.rs +++ b/runtime/darwinia/src/pallets/system.rs @@ -21,17 +21,18 @@ use crate::*; /// We assume that ~5% of the block weight is consumed by `on_initialize` handlers. This is /// used to limit the maximal weight of a single extrinsic. -const AVERAGE_ON_INITIALIZE_RATIO: Perbill = Perbill::from_percent(5); +const AVERAGE_ON_INITIALIZE_RATIO: sp_runtime::Perbill = sp_runtime::Perbill::from_percent(5); /// We allow `Normal` extrinsics to fill up the block up to 75%, the rest can be used by /// `Operational` extrinsics. -pub const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75); +pub const NORMAL_DISPATCH_RATIO: sp_runtime::Perbill = sp_runtime::Perbill::from_percent(75); /// We allow for 0.5 of a second of compute with a 12 second average block time. -pub const MAXIMUM_BLOCK_WEIGHT: Weight = Weight::from_parts( - frame_support::weights::constants::WEIGHT_REF_TIME_PER_SECOND.saturating_div(2), - cumulus_primitives_core::relay_chain::v2::MAX_POV_SIZE as u64, -); +pub const MAXIMUM_BLOCK_WEIGHT: frame_support::weights::Weight = + frame_support::weights::Weight::from_parts( + frame_support::weights::constants::WEIGHT_REF_TIME_PER_SECOND.saturating_div(2), + cumulus_primitives_core::relay_chain::v2::MAX_POV_SIZE as u64, + ); frame_support::parameter_types! { pub const Version: sp_version::RuntimeVersion = VERSION; @@ -39,13 +40,13 @@ frame_support::parameter_types! { frame_system::limits::BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO); pub RuntimeBlockWeights: frame_system::limits::BlockWeights = frame_system::limits::BlockWeights::builder() .base_block(weights::BlockExecutionWeight::get()) - .for_class(DispatchClass::all(), |weights| { + .for_class(frame_support::dispatch::DispatchClass::all(), |weights| { weights.base_extrinsic = weights::ExtrinsicBaseWeight::get(); }) - .for_class(DispatchClass::Normal, |weights| { + .for_class(frame_support::dispatch::DispatchClass::Normal, |weights| { weights.max_total = Some(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT); }) - .for_class(DispatchClass::Operational, |weights| { + .for_class(frame_support::dispatch::DispatchClass::Operational, |weights| { weights.max_total = Some(MAXIMUM_BLOCK_WEIGHT); // Operational transactions have some extra reserved space, so that they // are included even if block reached `MAXIMUM_BLOCK_WEIGHT`. @@ -79,7 +80,7 @@ impl frame_system::Config for Runtime { /// The hashing algorithm used. type Hashing = Hashing; /// The header type. - type Header = generic::Header; + type Header = sp_runtime::generic::Header; /// The index type for storing how many extrinsics an account has signed. type Index = Index; /// The lookup mechanism to get account ID from whatever is passed in dispatchers. diff --git a/runtime/darwinia/src/pallets/transaction_payment.rs b/runtime/darwinia/src/pallets/transaction_payment.rs index 970135a5..6080dfeb 100644 --- a/runtime/darwinia/src/pallets/transaction_payment.rs +++ b/runtime/darwinia/src/pallets/transaction_payment.rs @@ -22,7 +22,7 @@ use crate::*; impl pallet_transaction_payment::Config for Runtime { type FeeMultiplierUpdate = polkadot_runtime_common::SlowAdjustingFeeUpdate; // Relay Chain `TransactionByteFee` / 10 - type LengthToFee = ConstantMultiplier>; + type LengthToFee = frame_support::weights::ConstantMultiplier>; type OnChargeTransaction = pallet_transaction_payment::CurrencyAdapter>; type OperationalFeeMultiplier = sp_runtime::traits::ConstU8<5>; diff --git a/runtime/darwinia/src/pallets/vesting.rs b/runtime/darwinia/src/pallets/vesting.rs index ca01513e..1c0b0b6e 100644 --- a/runtime/darwinia/src/pallets/vesting.rs +++ b/runtime/darwinia/src/pallets/vesting.rs @@ -20,8 +20,10 @@ use crate::*; frame_support::parameter_types! { - pub UnvestedFundsAllowedWithdrawReasons: WithdrawReasons = - WithdrawReasons::except(WithdrawReasons::TRANSFER | WithdrawReasons::RESERVE); + pub UnvestedFundsAllowedWithdrawReasons: frame_support::traits::WithdrawReasons = + frame_support::traits::WithdrawReasons::except( + frame_support::traits::WithdrawReasons::TRANSFER | frame_support::traits::WithdrawReasons::RESERVE + ); } impl pallet_vesting::Config for Runtime { diff --git a/runtime/darwinia/src/pallets/xcmp_queue.rs b/runtime/darwinia/src/pallets/xcmp_queue.rs index e90975a6..f3f8d642 100644 --- a/runtime/darwinia/src/pallets/xcmp_queue.rs +++ b/runtime/darwinia/src/pallets/xcmp_queue.rs @@ -21,11 +21,11 @@ use crate::*; impl cumulus_pallet_xcmp_queue::Config for Runtime { type ChannelInfo = ParachainSystem; - type ControllerOrigin = EnsureRoot; + type ControllerOrigin = frame_system::EnsureRoot; type ControllerOriginConverter = XcmOriginToTransactDispatchOrigin; - type ExecuteOverweightOrigin = EnsureRoot; + type ExecuteOverweightOrigin = frame_system::EnsureRoot; type RuntimeEvent = RuntimeEvent; type VersionWrapper = (); type WeightInfo = weights::cumulus_pallet_xcmp_queue::WeightInfo; - type XcmExecutor = XcmExecutor; + type XcmExecutor = xcm_executor::XcmExecutor; } diff --git a/runtime/darwinia/src/weights/block_weights.rs b/runtime/darwinia/src/weights/block_weights.rs index 66279be1..8da49f75 100644 --- a/runtime/darwinia/src/weights/block_weights.rs +++ b/runtime/darwinia/src/weights/block_weights.rs @@ -16,35 +16,31 @@ // limitations under the License. pub mod constants { - use frame_support::{ - parameter_types, - weights::{constants, Weight}, - }; - - parameter_types! { + frame_support::parameter_types! { /// Importing a block with 0 Extrinsics. - pub const BlockExecutionWeight: Weight = Weight::from_ref_time(constants::WEIGHT_REF_TIME_PER_NANOS.saturating_mul(5_000_000)); + pub const BlockExecutionWeight: frame_support::weights::Weight = + frame_support::weights::Weight::from_ref_time(frame_support::weights::constants::WEIGHT_REF_TIME_PER_NANOS.saturating_mul(5_000_000)); } #[cfg(test)] mod test_weights { - use frame_support::weights::constants; - /// Checks that the weight exists and is sane. // NOTE: If this test fails but you are sure that the generated values are fine, // you can delete it. #[test] fn sane() { - let w = super::constants::BlockExecutionWeight::get(); + let w = frame_support::weights::constants::BlockExecutionWeight::get(); // At least 100 µs. assert!( - w.ref_time() >= 100u64 * constants::WEIGHT_REF_TIME_PER_MICROS, + w.ref_time() + >= 100u64 * frame_support::weights::constants::WEIGHT_REF_TIME_PER_MICROS, "Weight should be at least 100 µs." ); // At most 50 ms. assert!( - w.ref_time() <= 50u64 * constants::WEIGHT_REF_TIME_PER_MILLIS, + w.ref_time() + <= 50u64 * frame_support::weights::constants::WEIGHT_REF_TIME_PER_MILLIS, "Weight should be at most 50 ms." ); } diff --git a/runtime/darwinia/src/weights/extrinsic_weights.rs b/runtime/darwinia/src/weights/extrinsic_weights.rs index 48868670..0c17b0de 100644 --- a/runtime/darwinia/src/weights/extrinsic_weights.rs +++ b/runtime/darwinia/src/weights/extrinsic_weights.rs @@ -16,35 +16,30 @@ // limitations under the License. pub mod constants { - use frame_support::{ - parameter_types, - weights::{constants, Weight}, - }; - - parameter_types! { + frame_support::parameter_types! { /// Executing a NO-OP `System::remarks` Extrinsic. - pub const ExtrinsicBaseWeight: Weight = Weight::from_ref_time(constants::WEIGHT_REF_TIME_PER_NANOS.saturating_mul(125_000)); + pub const ExtrinsicBaseWeight: frame_support::weights::Weight = + frame_support::weights::Weight::from_ref_time(frame_support::weights::constants::WEIGHT_REF_TIME_PER_NANOS.saturating_mul(125_000)); } #[cfg(test)] mod test_weights { - use frame_support::weights::constants; - /// Checks that the weight exists and is sane. // NOTE: If this test fails but you are sure that the generated values are fine, // you can delete it. #[test] fn sane() { - let w = super::constants::ExtrinsicBaseWeight::get(); + let w = frame_support::weights::constants::ExtrinsicBaseWeight::get(); // At least 10 µs. assert!( - w.ref_time() >= 10u64 * constants::WEIGHT_REF_TIME_PER_MICROS, + w.ref_time() + >= 10u64 * frame_support::weights::constants::WEIGHT_REF_TIME_PER_MICROS, "Weight should be at least 10 µs." ); // At most 1 ms. assert!( - w.ref_time() <= constants::WEIGHT_REF_TIME_PER_MILLIS, + w.ref_time() <= frame_support::weights::constants::WEIGHT_REF_TIME_PER_MILLIS, "Weight should be at most 1 ms." ); } diff --git a/runtime/pangolin/src/lib.rs b/runtime/pangolin/src/lib.rs index b74f68d6..a425177f 100644 --- a/runtime/pangolin/src/lib.rs +++ b/runtime/pangolin/src/lib.rs @@ -33,34 +33,14 @@ pub use darwinia_common_runtime::*; pub use dc_primitives::*; pub use sp_consensus_aura::sr25519::AuthorityId as AuraId; -// cumulus -use cumulus_pallet_parachain_system::RelayNumberStrictlyIncreases; -// polkadot -use xcm_executor::XcmExecutor; // substrate -use frame_support::{ - dispatch::DispatchClass, - traits::{AsEnsureOriginWithArg, Imbalance, IsInVec, OnUnbalanced, WithdrawReasons}, - weights::{ConstantMultiplier, Weight}, -}; -use frame_system::{EnsureRoot, EnsureSignedBy}; -use sp_core::{crypto::KeyTypeId, OpaqueMetadata, H160, H256, U256}; -use sp_runtime::{ - generic, - traits::Block as BlockT, - transaction_validity::{TransactionSource, TransactionValidity}, - ApplyExtrinsicResult, Perbill, Permill, -}; use sp_std::prelude::*; -#[cfg(feature = "std")] -use sp_version::NativeVersion; -use sp_version::RuntimeVersion; /// Block type as expected by this runtime. -pub type Block = generic::Block; +pub type Block = sp_runtime::generic::Block; /// A Block signed with a Justification -pub type SignedBlock = generic::SignedBlock; +pub type SignedBlock = sp_runtime::generic::SignedBlock; /// The SignedExtension to the basic transaction logic. pub type SignedExtra = ( @@ -80,7 +60,7 @@ pub type UncheckedExtrinsic = /// Extrinsic type that has already been checked. pub type CheckedExtrinsic = - fp_self_contained::CheckedExtrinsic; + fp_self_contained::CheckedExtrinsic; /// Executive: handles dispatch to the various modules. pub type Executive = frame_executive::Executive< @@ -97,7 +77,7 @@ pub const DARWINIA_PROPOSAL_REQUIREMENT: Balance = 5000 * UNIT; /// Runtime version. #[sp_version::runtime_version] -pub const VERSION: RuntimeVersion = RuntimeVersion { +pub const VERSION: sp_version::RuntimeVersion = sp_version::RuntimeVersion { spec_name: sp_runtime::create_runtime_str!("Pangolin2"), impl_name: sp_runtime::create_runtime_str!("DarwiniaOfficialRust"), authoring_version: 0, @@ -115,37 +95,48 @@ impl frame_support::traits::OnUnbalanced: OnUnbalanced>, + pallet_treasury::Pallet: + frame_support::traits::OnUnbalanced>, { // this seems to be called for substrate-based transactions fn on_unbalanceds( mut fees_then_tips: impl Iterator>, ) { if let Some(fees) = fees_then_tips.next() { + // substrate + use frame_support::traits::Imbalance; + // for fees, 80% are burned, 20% to the treasury let (_, to_treasury) = fees.ration(80, 20); // Balances pallet automatically burns dropped Negative Imbalances by decreasing // total_supply accordingly - as OnUnbalanced<_>>::on_unbalanced(to_treasury); + as frame_support::traits::OnUnbalanced<_>>::on_unbalanced( + to_treasury, + ); } } // this is called from pallet_evm for Ethereum-based transactions // (technically, it calls on_unbalanced, which calls this when non-zero) fn on_nonzero_unbalanced(amount: pallet_balances::NegativeImbalance) { + // substrate + use frame_support::traits::Imbalance; + // Balances pallet automatically burns dropped Negative Imbalances by decreasing // total_supply accordingly let (_, to_treasury) = amount.ration(80, 20); - as OnUnbalanced<_>>::on_unbalanced(to_treasury); + as frame_support::traits::OnUnbalanced<_>>::on_unbalanced( + to_treasury, + ); } } /// The version information used to identify this runtime when compiled natively. #[cfg(feature = "std")] -pub fn native_version() -> NativeVersion { - NativeVersion { runtime_version: VERSION, can_author_with: Default::default() } +pub fn native_version() -> sp_version::NativeVersion { + sp_version::NativeVersion { runtime_version: VERSION, can_author_with: Default::default() } } // Create the runtime by composing the FRAME pallets that were previously configured. @@ -235,7 +226,7 @@ sp_api::impl_runtime_apis! { } impl sp_api::Core for Runtime { - fn version() -> RuntimeVersion { + fn version() -> sp_version::RuntimeVersion { VERSION } @@ -243,27 +234,27 @@ sp_api::impl_runtime_apis! { Executive::execute_block(block) } - fn initialize_block(header: &::Header) { + fn initialize_block(header: &::Header) { Executive::initialize_block(header) } } impl sp_api::Metadata for Runtime { - fn metadata() -> OpaqueMetadata { - OpaqueMetadata::new(Runtime::metadata().into()) + fn metadata() -> sp_core::OpaqueMetadata { + sp_core::OpaqueMetadata::new(Runtime::metadata().into()) } } impl sp_block_builder::BlockBuilder for Runtime { - fn apply_extrinsic(extrinsic: ::Extrinsic) -> ApplyExtrinsicResult { + fn apply_extrinsic(extrinsic: ::Extrinsic) -> sp_runtime::ApplyExtrinsicResult { Executive::apply_extrinsic(extrinsic) } - fn finalize_block() -> ::Header { + fn finalize_block() -> ::Header { Executive::finalize_block() } - fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<::Extrinsic> { + fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<::Extrinsic> { data.create_extrinsics() } @@ -277,16 +268,16 @@ sp_api::impl_runtime_apis! { impl sp_transaction_pool::runtime_api::TaggedTransactionQueue for Runtime { fn validate_transaction( - source: TransactionSource, - tx: ::Extrinsic, - block_hash: ::Hash, - ) -> TransactionValidity { + source: sp_runtime::transaction_validity::TransactionSource, + tx: ::Extrinsic, + block_hash: ::Hash, + ) -> sp_runtime::transaction_validity::TransactionValidity { Executive::validate_transaction(source, tx, block_hash) } } impl sp_offchain::OffchainWorkerApi for Runtime { - fn offchain_worker(header: &::Header) { + fn offchain_worker(header: &::Header) { Executive::offchain_worker(header) } } @@ -298,7 +289,7 @@ sp_api::impl_runtime_apis! { fn decode_session_keys( encoded: Vec, - ) -> Option, KeyTypeId)>> { + ) -> Option, sp_runtime::KeyTypeId)>> { SessionKeys::decode_into_raw_public_keys(&encoded) } } @@ -311,13 +302,13 @@ sp_api::impl_runtime_apis! { impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi for Runtime { fn query_info( - uxt: ::Extrinsic, + uxt: ::Extrinsic, len: u32, ) -> pallet_transaction_payment_rpc_runtime_api::RuntimeDispatchInfo { TransactionPayment::query_info(uxt, len) } fn query_fee_details( - uxt: ::Extrinsic, + uxt: ::Extrinsic, len: u32, ) -> pallet_transaction_payment::FeeDetails { TransactionPayment::query_fee_details(uxt, len) @@ -342,7 +333,7 @@ sp_api::impl_runtime_apis! { } impl cumulus_primitives_core::CollectCollationInfo for Runtime { - fn collect_collation_info(header: &::Header) -> cumulus_primitives_core::CollationInfo { + fn collect_collation_info(header: &::Header) -> cumulus_primitives_core::CollationInfo { ParachainSystem::collect_collation_info(header) } } @@ -352,13 +343,13 @@ sp_api::impl_runtime_apis! { <::ChainId as frame_support::traits::Get>::get() } - fn account_basic(address: H160) -> pallet_evm::Account { + fn account_basic(address: sp_core::H160) -> pallet_evm::Account { let (account, _) = Evm::account_basic(&address); account } - fn gas_price() -> U256 { + fn gas_price() -> sp_core::U256 { // frontier use pallet_evm::FeeCalculator; @@ -367,33 +358,33 @@ sp_api::impl_runtime_apis! { gas_price } - fn account_code_at(address: H160) -> Vec { + fn account_code_at(address: sp_core::H160) -> Vec { Evm::account_codes(address) } - fn author() -> H160 { + fn author() -> sp_core::H160 { >::find_author() } - fn storage_at(address: H160, index: U256) -> H256 { + fn storage_at(address: sp_core::H160, index: sp_core::U256) -> sp_core::H256 { let mut tmp = [0u8; 32]; index.to_big_endian(&mut tmp); - Evm::account_storages(address, H256::from_slice(&tmp[..])) + Evm::account_storages(address, sp_core::H256::from_slice(&tmp[..])) } fn call( - from: H160, - to: H160, + from: sp_core::H160, + to: sp_core::H160, data: Vec, - value: U256, - gas_limit: U256, - max_fee_per_gas: Option, - max_priority_fee_per_gas: Option, - nonce: Option, + value: sp_core::U256, + gas_limit: sp_core::U256, + max_fee_per_gas: Option, + max_priority_fee_per_gas: Option, + nonce: Option, estimate: bool, - access_list: Option)>>, + access_list: Option)>>, ) -> Result { // frontier use pallet_evm::Runner; @@ -429,15 +420,15 @@ sp_api::impl_runtime_apis! { } fn create( - from: H160, + from: sp_core::H160, data: Vec, - value: U256, - gas_limit: U256, - max_fee_per_gas: Option, - max_priority_fee_per_gas: Option, - nonce: Option, + value: sp_core::U256, + gas_limit: sp_core::U256, + max_fee_per_gas: Option, + max_priority_fee_per_gas: Option, + nonce: Option, estimate: bool, - access_list: Option)>>, + access_list: Option)>>, ) -> Result { // frontier use pallet_evm::Runner; @@ -496,7 +487,7 @@ sp_api::impl_runtime_apis! { } fn extrinsic_filter( - xts: Vec<::Extrinsic>, + xts: Vec<::Extrinsic>, ) -> Vec { xts.into_iter().filter_map(|xt| match xt.0.function { RuntimeCall::Ethereum( @@ -506,7 +497,7 @@ sp_api::impl_runtime_apis! { }).collect::>() } - fn elasticity() -> Option { + fn elasticity() -> Option { None } @@ -517,7 +508,7 @@ sp_api::impl_runtime_apis! { impl fp_rpc::ConvertTransactionRuntimeApi for Runtime { fn convert_transaction( transaction: pallet_ethereum::Transaction - ) -> ::Extrinsic { + ) -> ::Extrinsic { UncheckedExtrinsic::new_unsigned( pallet_ethereum::Call::::transact { transaction }.into(), ) @@ -583,7 +574,7 @@ sp_api::impl_runtime_apis! { #[cfg(feature = "try-runtime")] impl frame_try_runtime::TryRuntime for Runtime { - fn on_runtime_upgrade(checks: bool) -> (Weight, Weight) { + fn on_runtime_upgrade(checks: bool) -> (Weight, frame_support::weights::Weight) { // substrate use frame_support::log; @@ -637,15 +628,13 @@ cumulus_pallet_parachain_system::register_validate_block! { #[cfg(test)] mod tests { // darwinia - use super::{Runtime, WeightPerGas}; - // substrate - use frame_support::dispatch::DispatchClass; + use super::*; #[test] fn configured_base_extrinsic_weight_is_evm_compatible() { let min_ethereum_transaction_weight = WeightPerGas::get() * 21_000; let base_extrinsic = ::BlockWeights::get() - .get(DispatchClass::Normal) + .get(frame_support::dispatch::DispatchClass::Normal) .base_extrinsic; assert!(base_extrinsic.ref_time() <= min_ethereum_transaction_weight.ref_time()); diff --git a/runtime/pangolin/src/pallets/assets.rs b/runtime/pangolin/src/pallets/assets.rs index 8ff110b0..1dc4dd54 100644 --- a/runtime/pangolin/src/pallets/assets.rs +++ b/runtime/pangolin/src/pallets/assets.rs @@ -37,10 +37,12 @@ impl pallet_assets::Config for Runtime { type Balance = Balance; #[cfg(feature = "runtime-benchmarks")] type BenchmarkHelper = (); - type CreateOrigin = AsEnsureOriginWithArg, AccountId>>; + type CreateOrigin = frame_support::traits::AsEnsureOriginWithArg< + frame_system::EnsureSignedBy, AccountId>, + >; type Currency = Balances; type Extra = (); - type ForceOrigin = EnsureRoot; + type ForceOrigin = frame_system::EnsureRoot; type Freezer = (); type MetadataDepositBase = ConstU128<0>; type MetadataDepositPerByte = ConstU128<0>; diff --git a/runtime/pangolin/src/pallets/dmp_queue.rs b/runtime/pangolin/src/pallets/dmp_queue.rs index d31b4543..17313c1b 100644 --- a/runtime/pangolin/src/pallets/dmp_queue.rs +++ b/runtime/pangolin/src/pallets/dmp_queue.rs @@ -20,7 +20,7 @@ use crate::*; impl cumulus_pallet_dmp_queue::Config for Runtime { - type ExecuteOverweightOrigin = EnsureRoot; + type ExecuteOverweightOrigin = frame_system::EnsureRoot; type RuntimeEvent = RuntimeEvent; - type XcmExecutor = XcmExecutor; + type XcmExecutor = xcm_executor::XcmExecutor; } diff --git a/runtime/pangolin/src/pallets/evm.rs b/runtime/pangolin/src/pallets/evm.rs index 0174f96c..821ea50c 100644 --- a/runtime/pangolin/src/pallets/evm.rs +++ b/runtime/pangolin/src/pallets/evm.rs @@ -24,16 +24,16 @@ use pallet_evm::Precompile; const WEIGHT_PER_GAS: u64 = 40_000; frame_support::parameter_types! { - pub BlockGasLimit: U256 = U256::from(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT.ref_time() / WEIGHT_PER_GAS); + pub BlockGasLimit: sp_core::U256 = sp_core::U256::from(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT.ref_time() / WEIGHT_PER_GAS); pub PrecompilesValue: PangolinPrecompiles = PangolinPrecompiles::<_>::new(); - pub WeightPerGas: Weight = Weight::from_ref_time(WEIGHT_PER_GAS); + pub WeightPerGas: frame_support::weights::Weight = frame_support::weights::Weight::from_ref_time(WEIGHT_PER_GAS); } pub struct FindAuthorTruncated(sp_std::marker::PhantomData); -impl> frame_support::traits::FindAuthor +impl> frame_support::traits::FindAuthor for FindAuthorTruncated { - fn find_author<'a, I>(digests: I) -> Option + fn find_author<'a, I>(digests: I) -> Option where I: 'a + IntoIterator, { @@ -45,7 +45,7 @@ impl> frame_support::traits::FindAutho let raw = id.to_raw_vec(); if raw.len() >= 24 { - Some(H160::from_slice(&raw[4..24])) + Some(sp_core::H160::from_slice(&raw[4..24])) } else { None } @@ -56,8 +56,8 @@ impl> frame_support::traits::FindAutho pub struct FixedGasPrice; impl pallet_evm::FeeCalculator for FixedGasPrice { - fn min_gas_price() -> (U256, Weight) { - (U256::from(GWEI), Weight::zero()) + fn min_gas_price() -> (sp_core::U256, frame_support::weights::Weight) { + (sp_core::U256::from(GWEI), frame_support::weights::Weight::zero()) } } @@ -65,9 +65,9 @@ impl pallet_evm::FeeCalculator for FixedGasPrice { pub struct FromH160; impl pallet_evm::AddressMapping for FromH160 where - T: From, + T: From, { - fn into_account_id(address: H160) -> T { + fn into_account_id(address: sp_core::H160) -> T { address.into() } } @@ -75,7 +75,7 @@ where pub struct AssetIdConverter; impl darwinia_precompile_assets::AccountToAssetId for AssetIdConverter { fn account_to_asset_id(account_id: AccountId) -> AssetId { - let addr: H160 = account_id.into(); + let addr: sp_core::H160 = account_id.into(); addr.to_low_u64_be() } } @@ -90,7 +90,7 @@ where Self(Default::default()) } - pub fn used_addresses() -> [H160; 15] { + pub fn used_addresses() -> [sp_core::H160; 15] { [ addr(1), addr(2), @@ -164,7 +164,7 @@ where } } - fn is_precompile(&self, address: H160) -> bool { + fn is_precompile(&self, address: sp_core::H160) -> bool { Self::used_addresses().contains(&address) } } @@ -188,6 +188,6 @@ impl pallet_evm::Config for Runtime { type WithdrawOrigin = pallet_evm::EnsureAddressNever; } -fn addr(a: u64) -> H160 { - H160::from_low_u64_be(a) +fn addr(a: u64) -> sp_core::H160 { + sp_core::H160::from_low_u64_be(a) } diff --git a/runtime/pangolin/src/pallets/parachain_system.rs b/runtime/pangolin/src/pallets/parachain_system.rs index 42af9626..0f776807 100644 --- a/runtime/pangolin/src/pallets/parachain_system.rs +++ b/runtime/pangolin/src/pallets/parachain_system.rs @@ -20,12 +20,12 @@ use crate::*; frame_support::parameter_types! { - pub const ReservedXcmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT.saturating_div(4); - pub const ReservedDmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT.saturating_div(4); + pub const ReservedXcmpWeight: frame_support::weights::Weight = MAXIMUM_BLOCK_WEIGHT.saturating_div(4); + pub const ReservedDmpWeight: frame_support::weights::Weight = MAXIMUM_BLOCK_WEIGHT.saturating_div(4); } impl cumulus_pallet_parachain_system::Config for Runtime { - type CheckAssociatedRelayNumber = RelayNumberStrictlyIncreases; + type CheckAssociatedRelayNumber = cumulus_pallet_parachain_system::RelayNumberStrictlyIncreases; type DmpMessageHandler = DmpQueue; type OnSystemEvent = (); type OutboundXcmpMessageSource = XcmpQueue; diff --git a/runtime/pangolin/src/pallets/polkadot_xcm.rs b/runtime/pangolin/src/pallets/polkadot_xcm.rs index 7a0c8f6d..2b64726c 100644 --- a/runtime/pangolin/src/pallets/polkadot_xcm.rs +++ b/runtime/pangolin/src/pallets/polkadot_xcm.rs @@ -135,7 +135,7 @@ impl xcm_executor::Config for XcmExecutorConfig { type RuntimeCall = RuntimeCall; type SubscriptionService = PolkadotXcm; type Trader = xcm_configs::LocalAssetTrader< - ConstantMultiplier, + frame_support::weights::ConstantMultiplier, AnchoringSelfReserve, AccountId, Balances, diff --git a/runtime/pangolin/src/pallets/preimage.rs b/runtime/pangolin/src/pallets/preimage.rs index fc31bb73..d049ef1c 100644 --- a/runtime/pangolin/src/pallets/preimage.rs +++ b/runtime/pangolin/src/pallets/preimage.rs @@ -23,7 +23,7 @@ impl pallet_preimage::Config for Runtime { type BaseDeposit = ConstU128<{ 500 * UNIT }>; type ByteDeposit = ConstU128<{ darwinia_deposit(0, 1) }>; type Currency = Balances; - type ManagerOrigin = EnsureRoot; + type ManagerOrigin = frame_system::EnsureRoot; type RuntimeEvent = RuntimeEvent; type WeightInfo = (); } diff --git a/runtime/pangolin/src/pallets/system.rs b/runtime/pangolin/src/pallets/system.rs index 43a82603..e5f331a7 100644 --- a/runtime/pangolin/src/pallets/system.rs +++ b/runtime/pangolin/src/pallets/system.rs @@ -21,17 +21,18 @@ use crate::*; /// We assume that ~5% of the block weight is consumed by `on_initialize` handlers. This is /// used to limit the maximal weight of a single extrinsic. -const AVERAGE_ON_INITIALIZE_RATIO: Perbill = Perbill::from_percent(5); +const AVERAGE_ON_INITIALIZE_RATIO: sp_runtime::Perbill = sp_runtime::Perbill::from_percent(5); /// We allow `Normal` extrinsics to fill up the block up to 75%, the rest can be used by /// `Operational` extrinsics. -pub const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75); +pub const NORMAL_DISPATCH_RATIO: sp_runtime::Perbill = sp_runtime::Perbill::from_percent(75); /// We allow for 0.5 of a second of compute with a 12 second average block time. -pub const MAXIMUM_BLOCK_WEIGHT: Weight = Weight::from_parts( - frame_support::weights::constants::WEIGHT_REF_TIME_PER_SECOND.saturating_div(2), - cumulus_primitives_core::relay_chain::v2::MAX_POV_SIZE as u64, -); +pub const MAXIMUM_BLOCK_WEIGHT: frame_support::weights::Weight = + frame_support::weights::Weight::from_parts( + frame_support::weights::constants::WEIGHT_REF_TIME_PER_SECOND.saturating_div(2), + cumulus_primitives_core::relay_chain::v2::MAX_POV_SIZE as u64, + ); frame_support::parameter_types! { pub const Version: sp_version::RuntimeVersion = VERSION; @@ -39,13 +40,13 @@ frame_support::parameter_types! { frame_system::limits::BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO); pub RuntimeBlockWeights: frame_system::limits::BlockWeights = frame_system::limits::BlockWeights::builder() .base_block(weights::BlockExecutionWeight::get()) - .for_class(DispatchClass::all(), |weights| { + .for_class(frame_support::dispatch::DispatchClass::all(), |weights| { weights.base_extrinsic = weights::ExtrinsicBaseWeight::get(); }) - .for_class(DispatchClass::Normal, |weights| { + .for_class(frame_support::dispatch::DispatchClass::Normal, |weights| { weights.max_total = Some(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT); }) - .for_class(DispatchClass::Operational, |weights| { + .for_class(frame_support::dispatch::DispatchClass::Operational, |weights| { weights.max_total = Some(MAXIMUM_BLOCK_WEIGHT); // Operational transactions have some extra reserved space, so that they // are included even if block reached `MAXIMUM_BLOCK_WEIGHT`. @@ -79,7 +80,7 @@ impl frame_system::Config for Runtime { /// The hashing algorithm used. type Hashing = Hashing; /// The header type. - type Header = generic::Header; + type Header = sp_runtime::generic::Header; /// The index type for storing how many extrinsics an account has signed. type Index = Index; /// The lookup mechanism to get account ID from whatever is passed in dispatchers. diff --git a/runtime/pangolin/src/pallets/transaction_payment.rs b/runtime/pangolin/src/pallets/transaction_payment.rs index 970135a5..6080dfeb 100644 --- a/runtime/pangolin/src/pallets/transaction_payment.rs +++ b/runtime/pangolin/src/pallets/transaction_payment.rs @@ -22,7 +22,7 @@ use crate::*; impl pallet_transaction_payment::Config for Runtime { type FeeMultiplierUpdate = polkadot_runtime_common::SlowAdjustingFeeUpdate; // Relay Chain `TransactionByteFee` / 10 - type LengthToFee = ConstantMultiplier>; + type LengthToFee = frame_support::weights::ConstantMultiplier>; type OnChargeTransaction = pallet_transaction_payment::CurrencyAdapter>; type OperationalFeeMultiplier = sp_runtime::traits::ConstU8<5>; diff --git a/runtime/pangolin/src/pallets/vesting.rs b/runtime/pangolin/src/pallets/vesting.rs index ca01513e..1c0b0b6e 100644 --- a/runtime/pangolin/src/pallets/vesting.rs +++ b/runtime/pangolin/src/pallets/vesting.rs @@ -20,8 +20,10 @@ use crate::*; frame_support::parameter_types! { - pub UnvestedFundsAllowedWithdrawReasons: WithdrawReasons = - WithdrawReasons::except(WithdrawReasons::TRANSFER | WithdrawReasons::RESERVE); + pub UnvestedFundsAllowedWithdrawReasons: frame_support::traits::WithdrawReasons = + frame_support::traits::WithdrawReasons::except( + frame_support::traits::WithdrawReasons::TRANSFER | frame_support::traits::WithdrawReasons::RESERVE + ); } impl pallet_vesting::Config for Runtime { diff --git a/runtime/pangolin/src/pallets/xcmp_queue.rs b/runtime/pangolin/src/pallets/xcmp_queue.rs index e90975a6..f3f8d642 100644 --- a/runtime/pangolin/src/pallets/xcmp_queue.rs +++ b/runtime/pangolin/src/pallets/xcmp_queue.rs @@ -21,11 +21,11 @@ use crate::*; impl cumulus_pallet_xcmp_queue::Config for Runtime { type ChannelInfo = ParachainSystem; - type ControllerOrigin = EnsureRoot; + type ControllerOrigin = frame_system::EnsureRoot; type ControllerOriginConverter = XcmOriginToTransactDispatchOrigin; - type ExecuteOverweightOrigin = EnsureRoot; + type ExecuteOverweightOrigin = frame_system::EnsureRoot; type RuntimeEvent = RuntimeEvent; type VersionWrapper = (); type WeightInfo = weights::cumulus_pallet_xcmp_queue::WeightInfo; - type XcmExecutor = XcmExecutor; + type XcmExecutor = xcm_executor::XcmExecutor; } diff --git a/runtime/pangolin/src/weights/block_weights.rs b/runtime/pangolin/src/weights/block_weights.rs index 66279be1..8da49f75 100644 --- a/runtime/pangolin/src/weights/block_weights.rs +++ b/runtime/pangolin/src/weights/block_weights.rs @@ -16,35 +16,31 @@ // limitations under the License. pub mod constants { - use frame_support::{ - parameter_types, - weights::{constants, Weight}, - }; - - parameter_types! { + frame_support::parameter_types! { /// Importing a block with 0 Extrinsics. - pub const BlockExecutionWeight: Weight = Weight::from_ref_time(constants::WEIGHT_REF_TIME_PER_NANOS.saturating_mul(5_000_000)); + pub const BlockExecutionWeight: frame_support::weights::Weight = + frame_support::weights::Weight::from_ref_time(frame_support::weights::constants::WEIGHT_REF_TIME_PER_NANOS.saturating_mul(5_000_000)); } #[cfg(test)] mod test_weights { - use frame_support::weights::constants; - /// Checks that the weight exists and is sane. // NOTE: If this test fails but you are sure that the generated values are fine, // you can delete it. #[test] fn sane() { - let w = super::constants::BlockExecutionWeight::get(); + let w = frame_support::weights::constants::BlockExecutionWeight::get(); // At least 100 µs. assert!( - w.ref_time() >= 100u64 * constants::WEIGHT_REF_TIME_PER_MICROS, + w.ref_time() + >= 100u64 * frame_support::weights::constants::WEIGHT_REF_TIME_PER_MICROS, "Weight should be at least 100 µs." ); // At most 50 ms. assert!( - w.ref_time() <= 50u64 * constants::WEIGHT_REF_TIME_PER_MILLIS, + w.ref_time() + <= 50u64 * frame_support::weights::constants::WEIGHT_REF_TIME_PER_MILLIS, "Weight should be at most 50 ms." ); } diff --git a/runtime/pangolin/src/weights/extrinsic_weights.rs b/runtime/pangolin/src/weights/extrinsic_weights.rs index 48868670..0c17b0de 100644 --- a/runtime/pangolin/src/weights/extrinsic_weights.rs +++ b/runtime/pangolin/src/weights/extrinsic_weights.rs @@ -16,35 +16,30 @@ // limitations under the License. pub mod constants { - use frame_support::{ - parameter_types, - weights::{constants, Weight}, - }; - - parameter_types! { + frame_support::parameter_types! { /// Executing a NO-OP `System::remarks` Extrinsic. - pub const ExtrinsicBaseWeight: Weight = Weight::from_ref_time(constants::WEIGHT_REF_TIME_PER_NANOS.saturating_mul(125_000)); + pub const ExtrinsicBaseWeight: frame_support::weights::Weight = + frame_support::weights::Weight::from_ref_time(frame_support::weights::constants::WEIGHT_REF_TIME_PER_NANOS.saturating_mul(125_000)); } #[cfg(test)] mod test_weights { - use frame_support::weights::constants; - /// Checks that the weight exists and is sane. // NOTE: If this test fails but you are sure that the generated values are fine, // you can delete it. #[test] fn sane() { - let w = super::constants::ExtrinsicBaseWeight::get(); + let w = frame_support::weights::constants::ExtrinsicBaseWeight::get(); // At least 10 µs. assert!( - w.ref_time() >= 10u64 * constants::WEIGHT_REF_TIME_PER_MICROS, + w.ref_time() + >= 10u64 * frame_support::weights::constants::WEIGHT_REF_TIME_PER_MICROS, "Weight should be at least 10 µs." ); // At most 1 ms. assert!( - w.ref_time() <= constants::WEIGHT_REF_TIME_PER_MILLIS, + w.ref_time() <= frame_support::weights::constants::WEIGHT_REF_TIME_PER_MILLIS, "Weight should be at most 1 ms." ); }