From 1988f32c5d967c1552562ca1bfd4fd2b9d4905e6 Mon Sep 17 00:00:00 2001 From: Manuel Mauro Date: Mon, 24 Feb 2025 11:03:39 +0100 Subject: [PATCH] Upgrade to `polkadot-sdk` 2412 (#59) * feat: :arrow_up: upgrade to polkadot-sdk 2412 * fix: :bug: fix compilation errors * chore: :arrow_up: upgrade frontier in lock file * test: :white_check_mark: update expected_cost * test: :white_check_mark: update more expected_costs * test: :white_check_mark: fix more expected costs * refactor: :coffin: remove dead code * use storage growth in precompiles (mbip-5) * refactor: :rotating_light: lint/fmt * fix: tests to also create account metadata * improve async backing logs --- Cargo.toml | 22 ++++---- .../src/collators/lookahead.rs | 51 +++++++++++++++++-- pallets/async-backing/src/consensus_hook.rs | 3 -- pallets/async-backing/src/mock.rs | 1 + pallets/author-inherent/src/lib.rs | 14 +++-- pallets/author-inherent/src/mock.rs | 1 + pallets/author-mapping/src/mock.rs | 2 + pallets/author-slot-filter/src/mock.rs | 1 + pallets/emergency-para-xcm/src/mock.rs | 2 + pallets/foreign-asset-creator/src/mock.rs | 2 + pallets/maintenance-mode/src/mock.rs | 1 + pallets/migrations/src/mock.rs | 2 + pallets/randomness/src/lib.rs | 8 ++- pallets/randomness/src/mock.rs | 2 + pallets/relay-storage-roots/src/mock.rs | 2 + precompiles/assets-erc20/src/lib.rs | 14 +++-- precompiles/assets-erc20/src/mock.rs | 4 +- precompiles/assets-erc20/src/tests.rs | 20 ++++---- precompiles/balances-erc20/src/eip2612.rs | 9 ++-- precompiles/balances-erc20/src/lib.rs | 26 ++++++---- precompiles/balances-erc20/src/mock.rs | 10 ++-- precompiles/balances-erc20/src/tests.rs | 12 ++--- precompiles/batch/src/mock.rs | 4 +- precompiles/batch/src/tests.rs | 4 +- precompiles/call-permit/src/mock.rs | 4 +- precompiles/pallet-xcm/src/mock.rs | 4 +- precompiles/pallet-xcm/src/tests.rs | 8 +-- precompiles/proxy/src/lib.rs | 6 ++- precompiles/proxy/src/mock.rs | 6 ++- precompiles/proxy/src/tests.rs | 6 +-- precompiles/xcm-utils/src/lib.rs | 35 ++++++++++--- precompiles/xcm-utils/src/mock.rs | 40 +++------------ precompiles/xcm-utils/src/tests.rs | 18 +++---- primitives/session-keys/src/inherent.rs | 6 ++- template/node/src/service.rs | 7 ++- template/pallets/template/src/mock.rs | 1 + template/runtime/src/lib.rs | 7 ++- 37 files changed, 222 insertions(+), 143 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 6a3bdf80..13b4f093 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,12 +1,12 @@ [workspace] members = [ - "client/consensus/nimbus-consensus", - "precompiles/*", - "pallets/*", - "primitives/*", - "template/node", - "template/runtime", - "template/pallets/template", + "client/consensus/nimbus-consensus", + "precompiles/*", + "pallets/*", + "primitives/*", + "template/node", + "template/runtime", + "template/pallets/template", ] resolver = "2" @@ -26,12 +26,14 @@ async-trait = { version = "0.1.42" } environmental = { version = "1.1.2", default-features = false } hex = { version = "0.4.3", default-features = false } impl-trait-for-tuples = "0.2.1" -parity-scale-codec = { version = "3.0.0", default-features = false, features = [ "derive" ] } -futures = { version = "0.3.24", features = [ "compat" ] } +parity-scale-codec = { version = "3.0.0", default-features = false, features = [ + "derive", +] } +futures = { version = "0.3.31", features = ["compat"] } log = { version = "0.4.22", default-features = false } parking_lot = "0.12" scale-info = { version = "2.11.2", default-features = false, features = [ - "derive", + "derive", ] } schnorrkel = { version = "0.11.4", default-features = false } serde = { version = "1.0.195", default-features = false } diff --git a/client/consensus/nimbus-consensus/src/collators/lookahead.rs b/client/consensus/nimbus-consensus/src/collators/lookahead.rs index d5fc01ae..45a29194 100644 --- a/client/consensus/nimbus-consensus/src/collators/lookahead.rs +++ b/client/consensus/nimbus-consensus/src/collators/lookahead.rs @@ -146,10 +146,18 @@ where } }; - // React to each new relmy block + // React to each new relay block while let Some(relay_parent_header) = import_notifications.next().await { let relay_parent = relay_parent_header.hash(); + tracing::trace!( + target: crate::LOG_TARGET, + ?relay_parent, + relay_parent_number = ?relay_parent_header.number(), + ?params.para_id, + "Notified of a new relay block", + ); + // TODO: Currently we use just the first core here, but for elastic scaling // we iterate and build on all of the cores returned. // More info: https://github.com/paritytech/polkadot-sdk/issues/1829 @@ -201,7 +209,15 @@ where &relay_parent_header, params.relay_chain_slot_duration, ) { - None => continue, + None => { + tracing::trace!( + target: crate::LOG_TARGET, + relay_parent = ?relay_parent_header, + relay_chain_slot_duration = ?params.relay_chain_slot_duration, + "Fail to get the relay slot for this relay block!" + ); + continue; + } Some((relay_slot, relay_timestamp)) => { let our_slot = if let Some(slot_duration) = params.slot_duration { Slot::from_timestamp(relay_timestamp, slot_duration) @@ -299,6 +315,7 @@ where tracing::debug!( target: crate::LOG_TARGET, + ?slot_now, ?relay_parent, unincluded_segment_len = initial_parent.depth + n_built, "Slot claimed. Building" @@ -442,10 +459,34 @@ where // collator against chains which have not yet upgraded their runtime. if parent.hash() != included_block { match runtime_api.can_build_upon(parent.hash(), included_block, slot) { - Ok(true) => Some(nimbus_id), - Ok(false) => None, + Ok(true) => { + tracing::trace!( + target: crate::LOG_TARGET, + parent_number = ?parent.number(), + parent_hash = ?parent.hash(), + relay_parent_number = ?relay_parent.number(), + relay_parent_hash = ?relay_parent.hash(), + ?included_block, + ?slot, + "Runtime api UnincludedSegmentApi::can_build_upon return TRUE", + ); + Some(nimbus_id) + } + Ok(false) => { + tracing::debug!( + target: crate::LOG_TARGET, + parent_number = ?parent.number(), + parent_hash = ?parent.hash(), + relay_parent_number = ?relay_parent.number(), + relay_parent_hash = ?relay_parent.hash(), + ?included_block, + ?slot, + "Runtime api UnincludedSegmentApi::can_build_upon return FALSE", + ); + None + } Err(err) => { - tracing::error!( + tracing::warn!( target: crate::LOG_TARGET, ?err, ?parent, diff --git a/pallets/async-backing/src/consensus_hook.rs b/pallets/async-backing/src/consensus_hook.rs index 6c1e206e..d7b48354 100644 --- a/pallets/async-backing/src/consensus_hook.rs +++ b/pallets/async-backing/src/consensus_hook.rs @@ -29,9 +29,6 @@ use frame_support::pallet_prelude::*; use sp_consensus_slots::Slot; use sp_std::{marker::PhantomData, num::NonZeroU32}; -#[cfg(tests)] -type RelayChainStateProof = crate::mock::FakeRelayChainStateProof; - /// A consensus hook for a fixed block processing velocity and unincluded segment capacity. /// /// Relay chain slot duration must be provided in milliseconds. diff --git a/pallets/async-backing/src/mock.rs b/pallets/async-backing/src/mock.rs index 1786826d..0f0f6fac 100644 --- a/pallets/async-backing/src/mock.rs +++ b/pallets/async-backing/src/mock.rs @@ -45,6 +45,7 @@ parameter_types! { } impl frame_system::Config for Test { + type ExtensionsWeightInfo = (); type BaseCallFilter = frame_support::traits::Everything; type BlockWeights = (); type BlockLength = (); diff --git a/pallets/author-inherent/src/lib.rs b/pallets/author-inherent/src/lib.rs index 2472043c..a0398da8 100644 --- a/pallets/author-inherent/src/lib.rs +++ b/pallets/author-inherent/src/lib.rs @@ -22,14 +22,14 @@ extern crate alloc; +use alloc::string::String; use frame_support::traits::{FindAuthor, Get}; use nimbus_primitives::{ AccountLookup, CanAuthor, NimbusId, SlotBeacon, INHERENT_IDENTIFIER, NIMBUS_ENGINE_ID, }; use parity_scale_codec::{Decode, Encode, FullCodec}; use sp_inherents::{InherentIdentifier, IsFatalError}; -use sp_runtime::{ConsensusEngineId, RuntimeString}; -use alloc::string::String; +use sp_runtime::ConsensusEngineId; pub use crate::weights::WeightInfo; pub use exec::BlockExecutor; @@ -163,11 +163,9 @@ pub mod pallet { fn is_inherent_required(_: &InherentData) -> Result, Self::Error> { // Return Ok(Some(_)) unconditionally because this inherent is required in every block // If it is not found, throw an AuthorInherentRequired error. - Ok(Some(InherentError::Other( - String::from( - "Inherent required to manually initiate author validation", - ), - ))) + Ok(Some(InherentError::Other(String::from( + "Inherent required to manually initiate author validation", + )))) } // Regardless of whether the client is still supplying the author id, @@ -235,7 +233,7 @@ pub mod pallet { #[derive(Encode)] #[cfg_attr(feature = "std", derive(Debug, Decode))] pub enum InherentError { - Other(RuntimeString), + Other(String), } impl IsFatalError for InherentError { diff --git a/pallets/author-inherent/src/mock.rs b/pallets/author-inherent/src/mock.rs index a807ab85..c2f1ff0d 100644 --- a/pallets/author-inherent/src/mock.rs +++ b/pallets/author-inherent/src/mock.rs @@ -45,6 +45,7 @@ parameter_types! { } impl frame_system::Config for Test { + type ExtensionsWeightInfo = (); type BaseCallFilter = frame_support::traits::Everything; type BlockWeights = (); type BlockLength = (); diff --git a/pallets/author-mapping/src/mock.rs b/pallets/author-mapping/src/mock.rs index 0e205fef..f5064ea4 100644 --- a/pallets/author-mapping/src/mock.rs +++ b/pallets/author-mapping/src/mock.rs @@ -74,6 +74,7 @@ parameter_types! { pub const AvailableBlockRatio: Perbill = Perbill::one(); } impl frame_system::Config for Runtime { + type ExtensionsWeightInfo = (); type BaseCallFilter = Everything; type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; @@ -121,6 +122,7 @@ impl pallet_balances::Config for Runtime { type FreezeIdentifier = (); type MaxFreezes = (); type RuntimeFreezeReason = (); + type DoneSlashHandler = (); } parameter_types! { diff --git a/pallets/author-slot-filter/src/mock.rs b/pallets/author-slot-filter/src/mock.rs index 8c3c8ecd..66eaafaf 100644 --- a/pallets/author-slot-filter/src/mock.rs +++ b/pallets/author-slot-filter/src/mock.rs @@ -45,6 +45,7 @@ parameter_types! { } impl frame_system::Config for Test { + type ExtensionsWeightInfo = (); type BaseCallFilter = frame_support::traits::Everything; type BlockWeights = (); type BlockLength = (); diff --git a/pallets/emergency-para-xcm/src/mock.rs b/pallets/emergency-para-xcm/src/mock.rs index e9a7ea9f..3d6876ff 100644 --- a/pallets/emergency-para-xcm/src/mock.rs +++ b/pallets/emergency-para-xcm/src/mock.rs @@ -49,6 +49,7 @@ parameter_types! { pub type AccountId = u64; impl frame_system::Config for Test { + type ExtensionsWeightInfo = (); type BaseCallFilter = frame_support::traits::Everything; type BlockWeights = (); type BlockLength = (); @@ -97,6 +98,7 @@ impl cumulus_pallet_parachain_system::Config for Test { type CheckAssociatedRelayNumber = EmergencyParaXcm; type WeightInfo = (); type ConsensusHook = cumulus_pallet_parachain_system::ExpectParentIncluded; + type SelectCore = cumulus_pallet_parachain_system::DefaultCoreSelector; } parameter_types! { diff --git a/pallets/foreign-asset-creator/src/mock.rs b/pallets/foreign-asset-creator/src/mock.rs index bf3bbd6f..871f08ad 100644 --- a/pallets/foreign-asset-creator/src/mock.rs +++ b/pallets/foreign-asset-creator/src/mock.rs @@ -48,6 +48,7 @@ parameter_types! { pub const BlockHashCount: u32 = 250; } impl frame_system::Config for Test { + type ExtensionsWeightInfo = (); type BaseCallFilter = Everything; type BlockWeights = (); type BlockLength = (); @@ -97,6 +98,7 @@ impl pallet_balances::Config for Test { type RuntimeFreezeReason = (); type FreezeIdentifier = (); type MaxFreezes = (); + type DoneSlashHandler = (); } parameter_types! { diff --git a/pallets/maintenance-mode/src/mock.rs b/pallets/maintenance-mode/src/mock.rs index 84a62910..c1a7b15e 100644 --- a/pallets/maintenance-mode/src/mock.rs +++ b/pallets/maintenance-mode/src/mock.rs @@ -51,6 +51,7 @@ parameter_types! { pub const SS58Prefix: u8 = 42; } impl frame_system::Config for Test { + type ExtensionsWeightInfo = (); type BaseCallFilter = MaintenanceMode; type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; diff --git a/pallets/migrations/src/mock.rs b/pallets/migrations/src/mock.rs index b96c717f..c3de2450 100644 --- a/pallets/migrations/src/mock.rs +++ b/pallets/migrations/src/mock.rs @@ -56,6 +56,7 @@ parameter_types! { pub const SS58Prefix: u8 = 42; } impl frame_system::Config for Runtime { + type ExtensionsWeightInfo = (); type BaseCallFilter = Everything; type DbWeight = RocksDbWeight; type RuntimeOrigin = RuntimeOrigin; @@ -104,6 +105,7 @@ impl pallet_balances::Config for Runtime { type FreezeIdentifier = (); type MaxFreezes = (); type RuntimeFreezeReason = (); + type DoneSlashHandler = (); } parameter_types! { diff --git a/pallets/randomness/src/lib.rs b/pallets/randomness/src/lib.rs index dbe1cdeb..b1d56df0 100644 --- a/pallets/randomness/src/lib.rs +++ b/pallets/randomness/src/lib.rs @@ -277,11 +277,9 @@ pub mod pallet { fn is_inherent_required(_: &InherentData) -> Result, Self::Error> { // Return Ok(Some(_)) unconditionally because this inherent is required in every block // If it is not found, throw a VrfInherentRequired error. - Ok(Some(InherentError::Other( - String::from( - "Inherent required to set babe randomness results", - ), - ))) + Ok(Some(InherentError::Other(String::from( + "Inherent required to set babe randomness results", + )))) } // The empty-payload inherent extrinsic. diff --git a/pallets/randomness/src/mock.rs b/pallets/randomness/src/mock.rs index 4601c6b2..5894eb74 100644 --- a/pallets/randomness/src/mock.rs +++ b/pallets/randomness/src/mock.rs @@ -51,6 +51,7 @@ parameter_types! { pub const SS58Prefix: u8 = 42; } impl frame_system::Config for Test { + type ExtensionsWeightInfo = (); type BaseCallFilter = Everything; type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; @@ -99,6 +100,7 @@ impl pallet_balances::Config for Test { type FreezeIdentifier = (); type MaxFreezes = (); type RuntimeFreezeReason = (); + type DoneSlashHandler = (); } parameter_types! { diff --git a/pallets/relay-storage-roots/src/mock.rs b/pallets/relay-storage-roots/src/mock.rs index 557c9d99..13d6db94 100644 --- a/pallets/relay-storage-roots/src/mock.rs +++ b/pallets/relay-storage-roots/src/mock.rs @@ -50,6 +50,7 @@ parameter_types! { pub const SS58Prefix: u8 = 42; } impl frame_system::Config for Test { + type ExtensionsWeightInfo = (); type BaseCallFilter = Everything; type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; @@ -98,6 +99,7 @@ impl pallet_balances::Config for Test { type FreezeIdentifier = (); type MaxFreezes = (); type RuntimeFreezeReason = (); + type DoneSlashHandler = (); } pub struct PersistedValidationDataGetter; diff --git a/precompiles/assets-erc20/src/lib.rs b/precompiles/assets-erc20/src/lib.rs index fef03544..d5159c52 100644 --- a/precompiles/assets-erc20/src/lib.rs +++ b/precompiles/assets-erc20/src/lib.rs @@ -48,6 +48,10 @@ mod mock; #[cfg(test)] mod tests; +/// System account size in bytes = Pallet_Name_Hash (16) + Storage_name_hash (16) + +/// Blake2_128Concat (16) + AccountId (20) + AccountInfo (4 + 12 + AccountData (4* 16)) = 148 +pub const SYSTEM_ACCOUNT_SIZE: u64 = 148; + /// Solidity selector of the Transfer log, which is the Keccak of the Log signature. pub const SELECTOR_LOG_TRANSFER: [u8; 32] = keccak256!("Transfer(address,address,uint256)"); @@ -257,7 +261,7 @@ where id: asset_id.clone().into(), delegate: Runtime::Lookup::unlookup(spender.clone()), }, - 0, + 0, )?; } // Dispatch call (if enough gas). @@ -269,7 +273,7 @@ where delegate: Runtime::Lookup::unlookup(spender), amount, }, - 0, + 0, )?; Ok(()) @@ -301,7 +305,7 @@ where target: Runtime::Lookup::unlookup(to), amount: value, }, - 0, + SYSTEM_ACCOUNT_SIZE, )?; } @@ -349,7 +353,7 @@ where destination: Runtime::Lookup::unlookup(to), amount: value, }, - 0, + SYSTEM_ACCOUNT_SIZE, )?; } else { // Dispatch call (if enough gas). @@ -361,7 +365,7 @@ where target: Runtime::Lookup::unlookup(to), amount: value, }, - 0, + SYSTEM_ACCOUNT_SIZE, )?; } } diff --git a/precompiles/assets-erc20/src/mock.rs b/precompiles/assets-erc20/src/mock.rs index 31316095..04355176 100644 --- a/precompiles/assets-erc20/src/mock.rs +++ b/precompiles/assets-erc20/src/mock.rs @@ -83,6 +83,7 @@ parameter_types! { } impl frame_system::Config for Runtime { + type ExtensionsWeightInfo = (); type BaseCallFilter = Everything; type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; @@ -143,6 +144,7 @@ impl pallet_balances::Config for Runtime { type FreezeIdentifier = (); type MaxFreezes = (); type RuntimeFreezeReason = (); + type DoneSlashHandler = (); } pub type Precompiles = PrecompileSetBuilder< @@ -189,7 +191,7 @@ impl pallet_evm::Config for Runtime { type FindAuthor = (); type OnCreate = (); type GasLimitPovSizeRatio = GasLimitPovSizeRatio; - type SuicideQuickClearLimit = ConstU32<0>; + type GasLimitStorageGrowthRatio = (); type Timestamp = Timestamp; type WeightInfo = pallet_evm::weights::SubstrateWeight; } diff --git a/precompiles/assets-erc20/src/tests.rs b/precompiles/assets-erc20/src/tests.rs index ade8314b..05d1f82d 100644 --- a/precompiles/assets-erc20/src/tests.rs +++ b/precompiles/assets-erc20/src/tests.rs @@ -245,7 +245,7 @@ fn approve() { value: 500.into(), }, ) - .expect_cost(31625756) + .expect_cost(37024756) .expect_log(log3( ForeignAssetId(0u128), SELECTOR_LOG_APPROVAL, @@ -286,7 +286,7 @@ fn approve_saturating() { value: U256::MAX, }, ) - .expect_cost(31625756) + .expect_cost(37024756) .expect_log(log3( ForeignAssetId(0u128), SELECTOR_LOG_APPROVAL, @@ -415,7 +415,7 @@ fn transfer() { value: 400.into(), }, ) - .expect_cost(44795756) // 1 weight => 1 gas in mock + .expect_cost(50509756) // 1 weight => 1 gas in mock .expect_log(log3( ForeignAssetId(0u128), SELECTOR_LOG_TRANSFER, @@ -542,7 +542,7 @@ fn transfer_from() { value: 400.into(), }, ) - .expect_cost(66146756) // 1 weight => 1 gas in mock + .expect_cost(70172756) // 1 weight => 1 gas in mock .expect_log(log3( ForeignAssetId(0u128), SELECTOR_LOG_TRANSFER, @@ -620,7 +620,7 @@ fn transfer_from_non_incremental_approval() { value: 500.into(), }, ) - .expect_cost(31625756) + .expect_cost(37024756) .expect_log(log3( ForeignAssetId(0u128), SELECTOR_LOG_APPROVAL, @@ -643,7 +643,7 @@ fn transfer_from_non_incremental_approval() { value: 300.into(), }, ) - .expect_cost(65259756) + .expect_cost(76042756) .expect_log(log3( ForeignAssetId(0u128), SELECTOR_LOG_APPROVAL, @@ -751,7 +751,7 @@ fn transfer_from_self() { value: 400.into(), }, ) - .expect_cost(44795756) // 1 weight => 1 gas in mock + .expect_cost(50509756) // 1 weight => 1 gas in mock .expect_log(log3( ForeignAssetId(0u128), SELECTOR_LOG_TRANSFER, @@ -898,7 +898,7 @@ fn permit_valid() { s: H256::from(rs.s.b32()), }, ) - .expect_cost(31624000) + .expect_cost(37023000) .expect_log(log3( ForeignAssetId(0u128), SELECTOR_LOG_APPROVAL, @@ -1007,7 +1007,7 @@ fn permit_valid_named_asset() { s: H256::from(rs.s.b32()), }, ) - .expect_cost(31624000) + .expect_cost(37023000) .expect_log(log3( ForeignAssetId(0u128), SELECTOR_LOG_APPROVAL, @@ -1485,7 +1485,7 @@ fn permit_valid_with_metamask_signed_data() { s: H256::from(s_real), }, ) - .expect_cost(31624000) + .expect_cost(37023000) .expect_log(log3( ForeignAssetId(1u128), SELECTOR_LOG_APPROVAL, diff --git a/precompiles/balances-erc20/src/eip2612.rs b/precompiles/balances-erc20/src/eip2612.rs index 5a338c33..2d529b5d 100644 --- a/precompiles/balances-erc20/src/eip2612.rs +++ b/precompiles/balances-erc20/src/eip2612.rs @@ -34,9 +34,11 @@ const PERMIT_DOMAIN: [u8; 32] = keccak256!( "EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)" ); -pub struct Eip2612(PhantomData<(Runtime, Metadata, Instance)>); +pub struct Eip2612( + PhantomData<(Runtime, Metadata, StorageGrowth, Instance)>, +); -impl Eip2612 +impl Eip2612 where Runtime: pallet_balances::Config + pallet_evm::Config, Runtime::RuntimeCall: Dispatchable + GetDispatchInfo, @@ -46,6 +48,7 @@ where Metadata: Erc20Metadata, Instance: InstanceToPrefix + 'static, ::AddressMapping: AddressMapping, + StorageGrowth: Get, { pub fn compute_domain_separator(address: H160) -> [u8; 32] { let name: H256 = keccak_256(Metadata::name().as_bytes()).into(); @@ -144,7 +147,7 @@ where { let amount = - Erc20BalancesPrecompile::::u256_to_amount(value) + Erc20BalancesPrecompile::::u256_to_amount(value) .unwrap_or_else(|_| Bounded::max_value()); let owner: Runtime::AccountId = Runtime::AddressMapping::into_account_id(owner); diff --git a/precompiles/balances-erc20/src/lib.rs b/precompiles/balances-erc20/src/lib.rs index 8f04c304..161c4693 100644 --- a/precompiles/balances-erc20/src/lib.rs +++ b/precompiles/balances-erc20/src/lib.rs @@ -21,6 +21,7 @@ use fp_evm::PrecompileHandle; use frame_support::{ dispatch::{GetDispatchInfo, PostDispatchInfo}, + pallet_prelude::Get, sp_runtime::traits::{Bounded, CheckedSub, Dispatchable, StaticLookup}, storage::types::{StorageDoubleMap, StorageMap, ValueQuery}, traits::StorageInstance, @@ -173,12 +174,16 @@ pub trait Erc20Metadata { /// Precompile exposing a pallet_balance as an ERC20. /// Multiple precompiles can support instances of pallet_balance. /// The precompile uses an additional storage to store approvals. -pub struct Erc20BalancesPrecompile( - PhantomData<(Runtime, Metadata, Instance)>, -); +pub struct Erc20BalancesPrecompile< + Runtime, + Metadata: Erc20Metadata, + StorageGrowth, + Instance: 'static = (), +>(PhantomData<(Runtime, Metadata, StorageGrowth, Instance)>); #[precompile_utils::precompile] -impl Erc20BalancesPrecompile +impl + Erc20BalancesPrecompile where Runtime: pallet_balances::Config + pallet_evm::Config, Runtime::RuntimeCall: Dispatchable + GetDispatchInfo, @@ -188,6 +193,7 @@ where Metadata: Erc20Metadata, Instance: InstanceToPrefix + 'static, ::AddressMapping: AddressMapping, + StorageGrowth: Get, { #[precompile::public("totalSupply()")] #[precompile::view] @@ -288,7 +294,7 @@ where dest: Runtime::Lookup::unlookup(to), value: value, }, - 0, + StorageGrowth::get(), )?; } @@ -354,7 +360,7 @@ where dest: Runtime::Lookup::unlookup(to), value: value, }, - 0, + StorageGrowth::get(), )?; } @@ -416,7 +422,7 @@ where dest: Runtime::Lookup::unlookup(caller), value: amount, }, - 0, + StorageGrowth::get(), )?; log2( @@ -471,7 +477,7 @@ where r: H256, s: H256, ) -> EvmResult { - >::permit( + >::permit( handle, owner, spender, value, deadline, v, r, s, ) } @@ -479,13 +485,13 @@ where #[precompile::public("nonces(address)")] #[precompile::view] fn eip2612_nonces(handle: &mut impl PrecompileHandle, owner: Address) -> EvmResult { - >::nonces(handle, owner) + >::nonces(handle, owner) } #[precompile::public("DOMAIN_SEPARATOR()")] #[precompile::view] fn eip2612_domain_separator(handle: &mut impl PrecompileHandle) -> EvmResult { - >::domain_separator(handle) + >::domain_separator(handle) } fn u256_to_amount(value: U256) -> MayRevert> { diff --git a/precompiles/balances-erc20/src/mock.rs b/precompiles/balances-erc20/src/mock.rs index 3dc4d1e1..341103b5 100644 --- a/precompiles/balances-erc20/src/mock.rs +++ b/precompiles/balances-erc20/src/mock.rs @@ -21,7 +21,7 @@ use super::*; use frame_support::{construct_runtime, parameter_types, traits::Everything, weights::Weight}; use pallet_evm::{EnsureAddressNever, EnsureAddressRoot}; use precompile_utils::{precompile_set::*, testing::MockAccount}; -use sp_core::{ConstU32, H256, U256}; +use sp_core::{H256, U256}; use sp_runtime::{ traits::{BlakeTwo256, IdentityLookup}, BuildStorage, @@ -37,6 +37,7 @@ parameter_types! { } impl frame_system::Config for Runtime { + type ExtensionsWeightInfo = (); type BaseCallFilter = Everything; type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; @@ -97,14 +98,15 @@ impl pallet_balances::Config for Runtime { type FreezeIdentifier = (); type MaxFreezes = (); type RuntimeFreezeReason = (); + type DoneSlashHandler = (); } pub type Precompiles = PrecompileSetBuilder< R, - (PrecompileAt, Erc20BalancesPrecompile>,), + (PrecompileAt, Erc20BalancesPrecompile>,), >; -pub type PCall = Erc20BalancesPrecompileCall; +pub type PCall = Erc20BalancesPrecompileCall; const MAX_POV_SIZE: u64 = 5 * 1024 * 1024; @@ -138,7 +140,7 @@ impl pallet_evm::Config for Runtime { type FindAuthor = (); type OnCreate = (); type GasLimitPovSizeRatio = GasLimitPovSizeRatio; - type SuicideQuickClearLimit = ConstU32<0>; + type GasLimitStorageGrowthRatio = (); type Timestamp = Timestamp; type WeightInfo = pallet_evm::weights::SubstrateWeight; } diff --git a/precompiles/balances-erc20/src/tests.rs b/precompiles/balances-erc20/src/tests.rs index 79a7e373..f8f715d5 100644 --- a/precompiles/balances-erc20/src/tests.rs +++ b/precompiles/balances-erc20/src/tests.rs @@ -280,7 +280,7 @@ fn transfer() { value: 400.into(), }, ) - .expect_cost(173364756) // 1 weight => 1 gas in mock + .expect_cost(176106756) // 1 weight => 1 gas in mock .expect_log(log3( Precompile1, SELECTOR_LOG_TRANSFER, @@ -370,7 +370,7 @@ fn transfer_from() { value: 400.into(), }, ) - .expect_cost(173364756) // 1 weight => 1 gas in mock + .expect_cost(176106756) // 1 weight => 1 gas in mock .expect_log(log3( Precompile1, SELECTOR_LOG_TRANSFER, @@ -466,7 +466,7 @@ fn transfer_from_self() { value: 400.into(), }, ) - .expect_cost(173364756) // 1 weight => 1 gas in mock + .expect_cost(176106756) // 1 weight => 1 gas in mock .expect_log(log3( Precompile1, SELECTOR_LOG_TRANSFER, @@ -834,7 +834,7 @@ fn permit_valid() { let value: U256 = 500u16.into(); let deadline: U256 = 0u8.into(); // todo: proper timestamp - let permit = Eip2612::::generate_permit( + let permit = Eip2612::::generate_permit( Precompile1.into(), owner, spender, @@ -921,7 +921,7 @@ fn permit_invalid_nonce() { let value: U256 = 500u16.into(); let deadline: U256 = 0u8.into(); - let permit = Eip2612::::generate_permit( + let permit = Eip2612::::generate_permit( Precompile1.into(), owner, spender, @@ -1068,7 +1068,7 @@ fn permit_invalid_deadline() { let value: U256 = 500u16.into(); let deadline: U256 = 5u8.into(); // deadline < timestamp => expired - let permit = Eip2612::::generate_permit( + let permit = Eip2612::::generate_permit( Precompile1.into(), owner, spender, diff --git a/precompiles/batch/src/mock.rs b/precompiles/batch/src/mock.rs index fca121d2..eb02e28c 100644 --- a/precompiles/batch/src/mock.rs +++ b/precompiles/batch/src/mock.rs @@ -51,6 +51,7 @@ parameter_types! { } impl frame_system::Config for Runtime { + type ExtensionsWeightInfo = (); type BaseCallFilter = Everything; type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; @@ -98,6 +99,7 @@ impl pallet_balances::Config for Runtime { type FreezeIdentifier = (); type MaxFreezes = (); type RuntimeFreezeReason = (); + type DoneSlashHandler = (); } pub type Precompiles = PrecompileSetBuilder< @@ -153,7 +155,7 @@ impl pallet_evm::Config for Runtime { type FindAuthor = (); type OnCreate = (); type GasLimitPovSizeRatio = GasLimitPovSizeRatio; - type SuicideQuickClearLimit = ConstU32<0>; + type GasLimitStorageGrowthRatio = (); type Timestamp = Timestamp; type WeightInfo = pallet_evm::weights::SubstrateWeight; } diff --git a/precompiles/batch/src/tests.rs b/precompiles/batch/src/tests.rs index 1baa23d8..a0e484c0 100644 --- a/precompiles/batch/src/tests.rs +++ b/precompiles/batch/src/tests.rs @@ -1008,7 +1008,7 @@ fn batch_not_callable_by_smart_contract() { .execute_with(|| { // "deploy" SC to alice address let alice_h160: H160 = Alice.into(); - pallet_evm::AccountCodes::::insert(alice_h160, vec![10u8]); + pallet_evm::Pallet::::create_account(alice_h160, vec![10u8]); // succeeds if not called by SC, see `evm_batch_recursion_under_limit` let input = PCall::batch_all { @@ -1049,7 +1049,7 @@ fn batch_is_not_callable_by_dummy_code() { .execute_with(|| { // "deploy" dummy code to alice address let alice_h160: H160 = Alice.into(); - pallet_evm::AccountCodes::::insert( + pallet_evm::Pallet::::create_account( alice_h160, [0x60, 0x00, 0x60, 0x00, 0xfd].to_vec(), ); diff --git a/precompiles/call-permit/src/mock.rs b/precompiles/call-permit/src/mock.rs index e0848b35..4737bbb4 100644 --- a/precompiles/call-permit/src/mock.rs +++ b/precompiles/call-permit/src/mock.rs @@ -51,6 +51,7 @@ parameter_types! { } impl frame_system::Config for Runtime { + type ExtensionsWeightInfo = (); type BaseCallFilter = Everything; type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; @@ -98,6 +99,7 @@ impl pallet_balances::Config for Runtime { type FreezeIdentifier = (); type MaxFreezes = (); type RuntimeFreezeReason = (); + type DoneSlashHandler = (); } mock_account!(CallPermit, |_| MockAccount::from_u64(1)); @@ -139,7 +141,7 @@ impl pallet_evm::Config for Runtime { type FindAuthor = (); type OnCreate = (); type GasLimitPovSizeRatio = (); - type SuicideQuickClearLimit = SuicideQuickClearLimit; + type GasLimitStorageGrowthRatio = (); type Timestamp = Timestamp; type WeightInfo = pallet_evm::weights::SubstrateWeight; } diff --git a/precompiles/pallet-xcm/src/mock.rs b/precompiles/pallet-xcm/src/mock.rs index ec3cad6e..67d8993d 100644 --- a/precompiles/pallet-xcm/src/mock.rs +++ b/precompiles/pallet-xcm/src/mock.rs @@ -78,6 +78,7 @@ parameter_types! { } impl frame_system::Config for Runtime { + type ExtensionsWeightInfo = (); type BaseCallFilter = Everything; type DbWeight = MockDbWeight; type RuntimeOrigin = RuntimeOrigin; @@ -125,6 +126,7 @@ impl pallet_balances::Config for Runtime { type FreezeIdentifier = (); type MaxFreezes = (); type RuntimeFreezeReason = (); + type DoneSlashHandler = (); } parameter_types! { pub const AssetDeposit: u64 = 0; @@ -271,7 +273,7 @@ impl pallet_evm::Config for Runtime { type FindAuthor = (); type OnCreate = (); type GasLimitPovSizeRatio = GasLimitPovSizeRatio; - type SuicideQuickClearLimit = ConstU32<0>; + type GasLimitStorageGrowthRatio = (); type Timestamp = Timestamp; type WeightInfo = pallet_evm::weights::SubstrateWeight; } diff --git a/precompiles/pallet-xcm/src/tests.rs b/precompiles/pallet-xcm/src/tests.rs index 91508c43..b6294b54 100644 --- a/precompiles/pallet-xcm/src/tests.rs +++ b/precompiles/pallet-xcm/src/tests.rs @@ -430,7 +430,7 @@ fn test_transfer_assets_using_type_and_then_location_no_remote_reserve() { let destination_asset_location = Location::new(1, [Parachain(2), PalletInstance(3)]); let origin_asset_location = Location::new(0, [PalletInstance(1)]); - let message: Vec = xcm::VersionedXcm::<()>::V4(Xcm(vec![ClearOrigin])).encode(); + let message: Vec = xcm::VersionedXcm::<()>::from(Xcm(vec![ClearOrigin])).encode(); precompiles() .prepare_test( @@ -472,7 +472,7 @@ fn test_transfer_assets_using_type_and_then_location_remote_reserve() { let dest = Location::new(1, [Parachain(2)]); let relay_asset_location = Location::parent(); - let message: Vec = xcm::VersionedXcm::<()>::V4(Xcm(vec![ClearOrigin])).encode(); + let message: Vec = xcm::VersionedXcm::<()>::from(Xcm(vec![ClearOrigin])).encode(); precompiles() .prepare_test( @@ -513,7 +513,7 @@ fn test_transfer_assets_using_type_and_then_address_no_remote_reserve() { // We send the native currency of the origin chain and pay fees with it. let pallet_balances_address = H160::from_low_u64_be(2050); - let message: Vec = xcm::VersionedXcm::<()>::V4(Xcm(vec![ClearOrigin])).encode(); + let message: Vec = xcm::VersionedXcm::<()>::from(Xcm(vec![ClearOrigin])).encode(); precompiles() .prepare_test( @@ -557,7 +557,7 @@ fn test_transfer_assets_using_type_and_then_address_remote_reserve() { H160::from_str("0xfFfFFFffFffFFFFffFFfFfffFfFFFFFfffFF0005").unwrap(); let dest = Location::new(1, [Parachain(2)]); - let message: Vec = xcm::VersionedXcm::<()>::V4(Xcm(vec![ClearOrigin])).encode(); + let message: Vec = xcm::VersionedXcm::<()>::from(Xcm(vec![ClearOrigin])).encode(); precompiles() .prepare_test( diff --git a/precompiles/proxy/src/lib.rs b/precompiles/proxy/src/lib.rs index 25df5777..6bf32709 100644 --- a/precompiles/proxy/src/lib.rs +++ b/precompiles/proxy/src/lib.rs @@ -32,6 +32,10 @@ use sp_runtime::{ }; use sp_std::marker::PhantomData; +/// System account size in bytes = Pallet_Name_Hash (16) + Storage_name_hash (16) + +/// Blake2_128Concat (16) + AccountId (20) + AccountInfo (4 + 12 + AccountData (4* 16)) = 148 +pub const SYSTEM_ACCOUNT_SIZE: u64 = 148; + #[cfg(test)] mod mock; #[cfg(test)] @@ -425,7 +429,7 @@ where balance }, }, - 0, + SYSTEM_ACCOUNT_SIZE, )?; Some(Transfer { diff --git a/precompiles/proxy/src/mock.rs b/precompiles/proxy/src/mock.rs index 3aa689e1..e7d9d1bd 100644 --- a/precompiles/proxy/src/mock.rs +++ b/precompiles/proxy/src/mock.rs @@ -30,7 +30,7 @@ use precompile_utils::{ testing::MockAccount, }; use scale_info::TypeInfo; -use sp_core::{ConstU32, H160, H256, U256}; +use sp_core::{H160, H256, U256}; use sp_io; use sp_runtime::traits::{BlakeTwo256, IdentityLookup}; use sp_runtime::{ @@ -58,6 +58,7 @@ parameter_types! { pub const SS58Prefix: u8 = 42; } impl frame_system::Config for Runtime { + type ExtensionsWeightInfo = (); type BaseCallFilter = Everything; type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; @@ -105,6 +106,7 @@ impl pallet_balances::Config for Runtime { type FreezeIdentifier = (); type MaxFreezes = (); type RuntimeFreezeReason = (); + type DoneSlashHandler = (); } pub type Precompiles = PrecompileSetBuilder< @@ -176,7 +178,7 @@ impl pallet_evm::Config for Runtime { type FindAuthor = (); type OnCreate = (); type GasLimitPovSizeRatio = GasLimitPovSizeRatio; - type SuicideQuickClearLimit = ConstU32<0>; + type GasLimitStorageGrowthRatio = (); type Timestamp = Timestamp; type WeightInfo = pallet_evm::weights::SubstrateWeight; } diff --git a/precompiles/proxy/src/tests.rs b/precompiles/proxy/src/tests.rs index 587600e6..b055d53a 100644 --- a/precompiles/proxy/src/tests.rs +++ b/precompiles/proxy/src/tests.rs @@ -578,7 +578,7 @@ fn fails_if_called_by_smart_contract() { .build() .execute_with(|| { // Set code to Alice address as it if was a smart contract. - pallet_evm::AccountCodes::::insert(H160::from(Alice), vec![10u8]); + pallet_evm::Pallet::::create_account(H160::from(Alice), vec![10u8]); PrecompilesValue::get() .prepare_test( @@ -776,8 +776,8 @@ fn proxy_proxy_should_fail_if_called_by_smart_contract_for_a_non_eoa_account() { .build() .execute_with(|| { // Set code to Alice & Bob addresses as if they are smart contracts. - pallet_evm::AccountCodes::::insert(H160::from(Alice), vec![10u8]); - pallet_evm::AccountCodes::::insert(H160::from(Bob), vec![10u8]); + pallet_evm::Pallet::::create_account(H160::from(Alice), vec![10u8]); + pallet_evm::Pallet::::create_account(H160::from(Bob), vec![10u8]); // Bob allows Alice to make calls on his behalf assert_ok!(RuntimeCall::Proxy(ProxyCall::add_proxy { diff --git a/precompiles/xcm-utils/src/lib.rs b/precompiles/xcm-utils/src/lib.rs index 0fa5c4a3..9c057049 100644 --- a/precompiles/xcm-utils/src/lib.rs +++ b/precompiles/xcm-utils/src/lib.rs @@ -22,6 +22,7 @@ use fp_evm::PrecompileHandle; use frame_support::traits::ConstU32; use frame_support::{ dispatch::{GetDispatchInfo, PostDispatchInfo}, + pallet_prelude::Get, traits::OriginTrait, }; use pallet_evm::AddressMapping; @@ -58,14 +59,18 @@ mod mock; mod tests; #[derive(Debug)] -pub struct AllExceptXcmExecute(PhantomData<(Runtime, XcmConfig)>); +pub struct AllExceptXcmExecute( + PhantomData<(Runtime, XcmConfig, StorageGrowth)>, +); -impl SelectorFilter for AllExceptXcmExecute +impl SelectorFilter + for AllExceptXcmExecute where Runtime: pallet_evm::Config + frame_system::Config + pallet_xcm::Config, XcmOriginOf: OriginTrait, XcmAccountIdOf: Into, XcmConfig: xcm_executor::Config, + StorageGrowth: Get, ::RuntimeCall: Dispatchable + Decode + GetDispatchInfo, <::RuntimeCall as Dispatchable>::RuntimeOrigin: @@ -77,8 +82,9 @@ where match selector { None => true, Some(selector) => { - !XcmUtilsPrecompileCall::::xcm_execute_selectors() - .contains(&selector) + !XcmUtilsPrecompileCall::::xcm_execute_selectors( + ) + .contains(&selector) } } } @@ -89,15 +95,18 @@ where } /// A precompile to wrap the functionality from xcm-utils -pub struct XcmUtilsPrecompile(PhantomData<(Runtime, XcmConfig)>); +pub struct XcmUtilsPrecompile( + PhantomData<(Runtime, XcmConfig, StorageGrowth)>, +); #[precompile_utils::precompile] -impl XcmUtilsPrecompile +impl XcmUtilsPrecompile where Runtime: pallet_evm::Config + frame_system::Config + pallet_xcm::Config, XcmOriginOf: OriginTrait, XcmAccountIdOf: Into, XcmConfig: xcm_executor::Config, + StorageGrowth: Get, ::RuntimeCall: Dispatchable + Decode + GetDispatchInfo, <::RuntimeCall as Dispatchable>::RuntimeOrigin: @@ -224,7 +233,12 @@ where max_weight: Weight::from_parts(weight, DEFAULT_PROOF_SIZE), }; - RuntimeHelper::::try_dispatch(handle, Some(origin).into(), call, 0)?; + RuntimeHelper::::try_dispatch( + handle, + Some(origin).into(), + call, + StorageGrowth::get(), + )?; Ok(()) } @@ -251,7 +265,12 @@ where message: Box::new(xcm), }; - RuntimeHelper::::try_dispatch(handle, Some(origin).into(), call, 0)?; + RuntimeHelper::::try_dispatch( + handle, + Some(origin).into(), + call, + StorageGrowth::get(), + )?; Ok(()) } diff --git a/precompiles/xcm-utils/src/mock.rs b/precompiles/xcm-utils/src/mock.rs index 1b32c305..95cf42a8 100644 --- a/precompiles/xcm-utils/src/mock.rs +++ b/precompiles/xcm-utils/src/mock.rs @@ -18,7 +18,7 @@ use super::*; use frame_support::{ construct_runtime, parameter_types, - traits::{ConstU32, EnsureOrigin, Everything, Nothing, OriginTrait, PalletInfo as _}, + traits::{ConstU32, Everything, Nothing, OriginTrait, PalletInfo as _}, weights::{RuntimeDbWeight, Weight}, }; use pallet_evm::{EnsureAddressNever, EnsureAddressRoot, GasWeightMapping}; @@ -120,20 +120,6 @@ pub type LocationToAccountId = ( xcm_builder::AccountKey20Aliases, ); -pub struct AccountIdToLocation; -impl sp_runtime::traits::Convert for AccountIdToLocation { - fn convert(account: AccountId) -> Location { - let as_h160: H160 = account.into(); - Location::new( - 0, - [AccountKey20 { - network: None, - key: as_h160.as_fixed_bytes().clone(), - }], - ) - } -} - parameter_types! { pub ParachainId: cumulus_primitives_core::ParaId = 100.into(); pub LocalNetworkId: Option = None; @@ -149,6 +135,7 @@ parameter_types! { } impl frame_system::Config for Runtime { + type ExtensionsWeightInfo = (); type BaseCallFilter = Everything; type DbWeight = MockDbWeight; type RuntimeOrigin = RuntimeOrigin; @@ -196,6 +183,7 @@ impl pallet_balances::Config for Runtime { type FreezeIdentifier = (); type MaxFreezes = (); type RuntimeFreezeReason = (); + type DoneSlashHandler = (); } parameter_types! { @@ -235,13 +223,13 @@ pub type Precompiles = PrecompileSetBuilder< ( PrecompileAt< AddressU64<1>, - XcmUtilsPrecompile, - CallableByContract>, + XcmUtilsPrecompile, + CallableByContract>, >, ), >; -pub type PCall = XcmUtilsPrecompileCall; +pub type PCall = XcmUtilsPrecompileCall; const MAX_POV_SIZE: u64 = 5 * 1024 * 1024; @@ -287,7 +275,7 @@ impl pallet_evm::Config for Runtime { type FindAuthor = (); type OnCreate = (); type GasLimitPovSizeRatio = GasLimitPovSizeRatio; - type SuicideQuickClearLimit = ConstU32<0>; + type GasLimitStorageGrowthRatio = (); type Timestamp = Timestamp; type WeightInfo = pallet_evm::weights::SubstrateWeight; } @@ -303,20 +291,6 @@ impl pallet_timestamp::Config for Runtime { } pub type Barrier = AllowUnpaidExecutionFrom; -pub struct ConvertOriginToLocal; -impl EnsureOrigin for ConvertOriginToLocal { - type Success = Location; - - fn try_origin(_: Origin) -> Result { - Ok(Location::here()) - } - - #[cfg(feature = "runtime-benchmarks")] - fn try_successful_origin() -> Result { - Ok(Origin::root()) - } -} - use sp_std::cell::RefCell; use xcm::latest::opaque; // Simulates sending a XCM message diff --git a/precompiles/xcm-utils/src/tests.rs b/precompiles/xcm-utils/src/tests.rs index cdf4fe8c..6fccf41b 100644 --- a/precompiles/xcm-utils/src/tests.rs +++ b/precompiles/xcm-utils/src/tests.rs @@ -86,7 +86,7 @@ fn test_get_account_sibling() { #[test] fn test_weight_message() { ExtBuilder::default().build().execute_with(|| { - let message: Vec = xcm::VersionedXcm::<()>::V4(Xcm(vec![ClearOrigin])).encode(); + let message: Vec = xcm::VersionedXcm::<()>::from(Xcm(vec![ClearOrigin])).encode(); let input = PCall::weight_message { message: message.into(), @@ -118,7 +118,7 @@ fn test_get_units_per_second() { #[test] fn test_executor_clear_origin() { ExtBuilder::default().build().execute_with(|| { - let xcm_to_execute = VersionedXcm::<()>::V4(Xcm(vec![ClearOrigin])).encode(); + let xcm_to_execute = VersionedXcm::<()>::from(Xcm(vec![ClearOrigin])).encode(); let input = PCall::xcm_execute { message: xcm_to_execute.into(), @@ -137,7 +137,7 @@ fn test_executor_clear_origin() { fn test_executor_send() { ExtBuilder::default().build().execute_with(|| { let withdrawn_asset: Asset = (Location::parent(), 1u128).into(); - let xcm_to_execute = VersionedXcm::<()>::V4(Xcm(vec![ + let xcm_to_execute = VersionedXcm::<()>::from(Xcm(vec![ WithdrawAsset(vec![withdrawn_asset].into()), InitiateReserveWithdraw { assets: AssetFilter::Wild(All), @@ -184,9 +184,9 @@ fn test_executor_transact() { } .encode(); encoded.append(&mut call_bytes); - let xcm_to_execute = VersionedXcm::<()>::V4(Xcm(vec![Transact { + let xcm_to_execute = VersionedXcm::<()>::from(Xcm(vec![Transact { origin_kind: OriginKind::SovereignAccount, - require_weight_at_most: Weight::from_parts(1_000_000_000u64, 5206u64), + fallback_max_weight: Some(Weight::from_parts(1_000_000_000u64, 5206u64)), call: encoded.into(), }])) .encode(); @@ -198,7 +198,7 @@ fn test_executor_transact() { precompiles() .prepare_test(CryptoAlith, Precompile1, input) - .expect_cost(1100001001) + .expect_cost(276106001) .expect_no_logs() .execute_returns(()); @@ -211,7 +211,7 @@ fn test_executor_transact() { #[test] fn test_send_clear_origin() { ExtBuilder::default().build().execute_with(|| { - let xcm_to_send = VersionedXcm::<()>::V4(Xcm(vec![ClearOrigin])).encode(); + let xcm_to_send = VersionedXcm::<()>::from(Xcm(vec![ClearOrigin])).encode(); let input = PCall::xcm_send { dest: Location::parent(), @@ -242,9 +242,9 @@ fn execute_fails_if_called_by_smart_contract() { .build() .execute_with(|| { // Set code to Alice address as it if was a smart contract. - pallet_evm::AccountCodes::::insert(H160::from(Alice), vec![10u8]); + pallet_evm::Pallet::::create_account(H160::from(Alice), vec![10u8]); - let xcm_to_execute = VersionedXcm::<()>::V4(Xcm(vec![ClearOrigin])).encode(); + let xcm_to_execute = VersionedXcm::<()>::from(Xcm(vec![ClearOrigin])).encode(); let input = PCall::xcm_execute { message: xcm_to_execute.into(), diff --git a/primitives/session-keys/src/inherent.rs b/primitives/session-keys/src/inherent.rs index 09592653..52690fe0 100644 --- a/primitives/session-keys/src/inherent.rs +++ b/primitives/session-keys/src/inherent.rs @@ -13,14 +13,16 @@ // You should have received a copy of the GNU General Public License // along with Moonkit. If not, see . +extern crate alloc; + +use alloc::string::String; use parity_scale_codec::{Decode, Encode}; use sp_inherents::{Error, InherentData, InherentIdentifier, IsFatalError}; -use sp_runtime::RuntimeString; #[derive(Encode)] #[cfg_attr(feature = "std", derive(Debug, Decode))] pub enum InherentError { - Other(RuntimeString), + Other(String), } impl IsFatalError for InherentError { diff --git a/template/node/src/service.rs b/template/node/src/service.rs index cdf505b4..b73c126d 100644 --- a/template/node/src/service.rs +++ b/template/node/src/service.rs @@ -23,11 +23,13 @@ use cumulus_primitives_core::CollectCollationInfo; use cumulus_client_service::{ prepare_node_config, start_relay_chain_tasks, DARecoveryProfile, StartRelayChainTasksParams, }; +use cumulus_primitives_core::CollectCollationInfo; use cumulus_primitives_core::ParaId; use cumulus_relay_chain_inprocess_interface::build_inprocess_relay_chain; use cumulus_relay_chain_interface::{OverseerHandle, RelayChainInterface, RelayChainResult}; use cumulus_relay_chain_minimal_node::build_minimal_relay_chain_node_with_rpc; +use polkadot_primitives::UpgradeGoAhead; use polkadot_service::CollatorPair; use polkadot_primitives::UpgradeGoAhead; @@ -191,8 +193,9 @@ async fn build_relay_chain_interface( { build_minimal_relay_chain_node_with_rpc(polkadot_config, parachain_config.prometheus_registry(), - task_manager, rpc_target_urls) - .await + task_manager, rpc_target_urls, + ) + .await } else { build_inprocess_relay_chain( polkadot_config, diff --git a/template/pallets/template/src/mock.rs b/template/pallets/template/src/mock.rs index 3b92d12a..fbbe3d2a 100644 --- a/template/pallets/template/src/mock.rs +++ b/template/pallets/template/src/mock.rs @@ -24,6 +24,7 @@ parameter_types! { } impl system::Config for Test { + type ExtensionsWeightInfo = (); type BaseCallFilter = Everything; type BlockWeights = (); type BlockLength = (); diff --git a/template/runtime/src/lib.rs b/template/runtime/src/lib.rs index bb884b59..b9ecaeca 100644 --- a/template/runtime/src/lib.rs +++ b/template/runtime/src/lib.rs @@ -10,11 +10,10 @@ use smallvec::smallvec; use sp_api::impl_runtime_apis; use sp_core::{crypto::KeyTypeId, ConstU32, OpaqueMetadata}; use sp_runtime::{ - Cow, generic, impl_opaque_keys, traits::{AccountIdLookup, BlakeTwo256, Block as BlockT, IdentifyAccount, Verify}, transaction_validity::{TransactionSource, TransactionValidity}, - ApplyExtrinsicResult, MultiSignature, + ApplyExtrinsicResult, Cow, MultiSignature, }; pub use nimbus_primitives::NimbusId; @@ -348,7 +347,7 @@ impl frame_system::Config for Runtime { type PreInherents = (); type PostInherents = (); type PostTransactions = (); - type ExtensionsWeightInfo = (); + type ExtensionsWeightInfo = (); } parameter_types! { @@ -385,7 +384,7 @@ impl pallet_balances::Config for Runtime { type RuntimeFreezeReason = (); type FreezeIdentifier = (); type MaxFreezes = ConstU32<0>; - type DoneSlashHandler = (); + type DoneSlashHandler = (); } parameter_types! {