diff --git a/Cargo.lock b/Cargo.lock index 3ac0de79ff..210f6bc942 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5859,6 +5859,7 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", + "sp-version", ] [[package]] diff --git a/frame/ethereum/Cargo.toml b/frame/ethereum/Cargo.toml index 651d9f4163..77f2d78d4e 100644 --- a/frame/ethereum/Cargo.toml +++ b/frame/ethereum/Cargo.toml @@ -21,6 +21,7 @@ frame-support = { workspace = true } frame-system = { workspace = true } sp-io = { workspace = true } sp-runtime = { workspace = true } +sp-version = { workspace = true } # Frontier fp-consensus = { workspace = true } fp-ethereum = { workspace = true } @@ -54,6 +55,7 @@ std = [ "frame-system/std", "sp-io/std", "sp-runtime/std", + "sp-version/std", # Frontier "fp-consensus/std", "fp-ethereum/std", diff --git a/frame/ethereum/src/lib.rs b/frame/ethereum/src/lib.rs index 508cadfdd9..a211f2478e 100644 --- a/frame/ethereum/src/lib.rs +++ b/frame/ethereum/src/lib.rs @@ -59,6 +59,7 @@ use sp_runtime::{ }, RuntimeDebug, SaturatedConversion, }; +use sp_version::RuntimeVersion; // Frontier use fp_consensus::{PostLog, PreLog, FRONTIER_ENGINE_ID}; pub use fp_ethereum::TransactionData; @@ -192,9 +193,10 @@ pub mod pallet { #[pallet::origin] pub type Origin = RawOrigin; - #[pallet::config] + #[pallet::config(with_default)] pub trait Config: frame_system::Config + pallet_evm::Config { /// The overarching event type. + #[pallet::no_default_bounds] type RuntimeEvent: From + IsType<::RuntimeEvent>; /// How Ethereum state root is calculated. type StateRoot: Get; @@ -204,6 +206,32 @@ pub mod pallet { type ExtraDataLength: Get; } + pub mod config_preludes { + use super::*; + use frame_support::{derive_impl, parameter_types}; + + pub struct TestDefaultConfig; + + #[derive_impl(frame_system::config_preludes::TestDefaultConfig, no_aggregated_types)] + impl frame_system::DefaultConfig for TestDefaultConfig {} + + #[derive_impl(pallet_evm::config_preludes::TestDefaultConfig, no_aggregated_types)] + impl pallet_evm::DefaultConfig for TestDefaultConfig {} + + parameter_types! { + pub const PostBlockAndTxnHashes: PostLogContent = PostLogContent::BlockAndTxnHashes; + } + + #[register_default_impl(TestDefaultConfig)] + impl DefaultConfig for TestDefaultConfig { + #[inject_runtime_type] + type RuntimeEvent = (); + type StateRoot = IntermediateStateRoot; + type PostLogContent = PostBlockAndTxnHashes; + type ExtraDataLength = ConstU32<30>; + } + } + #[pallet::hooks] impl Hooks> for Pallet { fn on_finalize(n: BlockNumberFor) { @@ -968,9 +996,9 @@ pub enum ReturnValue { } pub struct IntermediateStateRoot(PhantomData); -impl Get for IntermediateStateRoot { +impl> Get for IntermediateStateRoot { fn get() -> H256 { - let version = T::Version::get().state_version(); + let version = T::get().state_version(); H256::decode(&mut &sp_io::storage::root(version)[..]) .expect("Node is configured to use the same hash; qed") } diff --git a/frame/ethereum/src/mock.rs b/frame/ethereum/src/mock.rs index 6da28a4b77..5f711ec048 100644 --- a/frame/ethereum/src/mock.rs +++ b/frame/ethereum/src/mock.rs @@ -20,22 +20,16 @@ use ethereum::{TransactionAction, TransactionSignature}; use rlp::RlpStream; // Substrate -use frame_support::{ - derive_impl, parameter_types, - traits::{ConstU32, FindAuthor}, - weights::Weight, - ConsensusEngineId, PalletId, -}; +use frame_support::{derive_impl, parameter_types, traits::FindAuthor, ConsensusEngineId}; use sp_core::{hashing::keccak_256, H160, H256, U256}; use sp_runtime::{ - traits::{BlakeTwo256, Dispatchable, IdentityLookup}, + traits::{Dispatchable, IdentityLookup}, AccountId32, BuildStorage, }; // Frontier -use pallet_evm::{AddressMapping, EnsureAddressTruncated, FeeCalculator}; +use pallet_evm::{config_preludes::ChainId, AddressMapping}; use super::*; -use crate::IntermediateStateRoot; pub type SignedExtra = (frame_system::CheckSpecVersion,); @@ -55,30 +49,11 @@ parameter_types! { #[derive_impl(frame_system::config_preludes::TestDefaultConfig as frame_system::DefaultConfig)] impl frame_system::Config for Test { - type RuntimeEvent = RuntimeEvent; - type BaseCallFilter = frame_support::traits::Everything; - type BlockWeights = (); - type BlockLength = (); - type RuntimeOrigin = RuntimeOrigin; - type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; - type Nonce = u64; - type Hash = H256; - type Hashing = BlakeTwo256; type AccountId = AccountId32; type Lookup = IdentityLookup; type Block = frame_system::mocking::MockBlock; type BlockHashCount = BlockHashCount; - type DbWeight = (); - type Version = (); - type PalletInfo = PalletInfo; type AccountData = pallet_balances::AccountData; - type OnNewAccount = (); - type OnKilledAccount = (); - type SystemWeightInfo = (); - type SS58Prefix = (); - type OnSetCode = (); - type MaxConsumers = ConstU32<16>; } parameter_types! { @@ -89,39 +64,14 @@ parameter_types! { pub const MaxReserves: u32 = 50; } +#[derive_impl(pallet_balances::config_preludes::TestDefaultConfig)] impl pallet_balances::Config for Test { - type RuntimeEvent = RuntimeEvent; - type RuntimeHoldReason = RuntimeHoldReason; - type RuntimeFreezeReason = RuntimeFreezeReason; - type WeightInfo = (); - type Balance = u64; - type DustRemoval = (); type ExistentialDeposit = ExistentialDeposit; type AccountStore = System; - type ReserveIdentifier = [u8; 8]; - type FreezeIdentifier = RuntimeFreezeReason; - type MaxLocks = MaxLocks; - type MaxReserves = MaxReserves; - type MaxFreezes = ConstU32<1>; -} - -parameter_types! { - pub const MinimumPeriod: u64 = 6000 / 2; } -impl pallet_timestamp::Config for Test { - type Moment = u64; - type OnTimestampSet = (); - type MinimumPeriod = MinimumPeriod; - type WeightInfo = (); -} - -pub struct FixedGasPrice; -impl FeeCalculator for FixedGasPrice { - fn min_gas_price() -> (U256, Weight) { - (1.into(), Weight::zero()) - } -} +#[derive_impl(pallet_timestamp::config_preludes::TestDefaultConfig)] +impl pallet_timestamp::Config for Test {} pub struct FindAuthorTruncated; impl FindAuthor for FindAuthorTruncated { @@ -133,66 +83,24 @@ impl FindAuthor for FindAuthorTruncated { } } -const BLOCK_GAS_LIMIT: u64 = 150_000_000; -const MAX_POV_SIZE: u64 = 5 * 1024 * 1024; - parameter_types! { pub const TransactionByteFee: u64 = 1; - pub const ChainId: u64 = 42; - pub const EVMModuleId: PalletId = PalletId(*b"py/evmpa"); - pub BlockGasLimit: U256 = U256::from(BLOCK_GAS_LIMIT); - pub const GasLimitPovSizeRatio: u64 = BLOCK_GAS_LIMIT.saturating_div(MAX_POV_SIZE); - pub const WeightPerGas: Weight = Weight::from_parts(20_000, 0); -} - -pub struct HashedAddressMapping; -impl AddressMapping for HashedAddressMapping { - fn into_account_id(address: H160) -> AccountId32 { - let mut data = [0u8; 32]; - data[0..20].copy_from_slice(&address[..]); - AccountId32::from(Into::<[u8; 32]>::into(data)) - } -} - -parameter_types! { - pub SuicideQuickClearLimit: u32 = 0; } +#[derive_impl(pallet_evm::config_preludes::TestDefaultConfig)] impl pallet_evm::Config for Test { type AccountProvider = pallet_evm::FrameSystemAccountProvider; - type FeeCalculator = FixedGasPrice; - type GasWeightMapping = pallet_evm::FixedGasWeightMapping; - type WeightPerGas = WeightPerGas; type BlockHashMapping = crate::EthereumBlockHashMapping; - type CallOrigin = EnsureAddressTruncated; - type WithdrawOrigin = EnsureAddressTruncated; - type AddressMapping = HashedAddressMapping; type Currency = Balances; - type RuntimeEvent = RuntimeEvent; type PrecompilesType = (); type PrecompilesValue = (); - type ChainId = ChainId; - type BlockGasLimit = BlockGasLimit; type Runner = pallet_evm::runner::stack::Runner; - type OnChargeTransaction = (); - type OnCreate = (); type FindAuthor = FindAuthorTruncated; - type GasLimitPovSizeRatio = GasLimitPovSizeRatio; - type SuicideQuickClearLimit = SuicideQuickClearLimit; type Timestamp = Timestamp; - type WeightInfo = (); -} - -parameter_types! { - pub const PostBlockAndTxnHashes: PostLogContent = PostLogContent::BlockAndTxnHashes; } -impl Config for Test { - type RuntimeEvent = RuntimeEvent; - type StateRoot = IntermediateStateRoot; - type PostLogContent = PostBlockAndTxnHashes; - type ExtraDataLength = ConstU32<30>; -} +#[derive_impl(crate::config_preludes::TestDefaultConfig)] +impl Config for Test {} impl fp_self_contained::SelfContainedCall for RuntimeCall { type SignedInfo = H160; @@ -262,12 +170,9 @@ fn address_build(seed: u8) -> AccountInfo { let public_key = &libsecp256k1::PublicKey::from_secret_key(&secret_key).serialize()[1..65]; let address = H160::from(H256::from(keccak_256(public_key))); - let mut data = [0u8; 32]; - data[0..20].copy_from_slice(&address[..]); - AccountInfo { private_key, - account_id: AccountId32::from(Into::<[u8; 32]>::into(data)), + account_id: ::AddressMapping::into_account_id(address), address, } } @@ -301,7 +206,6 @@ pub fn new_test_ext_with_initial_balance( accounts_len: usize, initial_balance: u64, ) -> (Vec, sp_io::TestExternalities) { - // sc_cli::init_logger(""); let mut ext = frame_system::GenesisConfig::::default() .build_storage() .unwrap(); diff --git a/frame/evm/src/lib.rs b/frame/evm/src/lib.rs index a3332d7061..f94e0ffc18 100644 --- a/frame/evm/src/lib.rs +++ b/frame/evm/src/lib.rs @@ -124,9 +124,10 @@ pub mod pallet { #[pallet::without_storage_info] pub struct Pallet(PhantomData); - #[pallet::config] + #[pallet::config(with_default)] pub trait Config: frame_system::Config { /// Account info provider. + #[pallet::no_default] type AccountProvider: AccountProvider; /// Calculator for current gas price. @@ -139,36 +140,50 @@ pub mod pallet { type WeightPerGas: Get; /// Block number to block hash. + #[pallet::no_default] type BlockHashMapping: BlockHashMapping; /// Allow the origin to call on behalf of given address. + #[pallet::no_default_bounds] type CallOrigin: EnsureAddressOrigin; + /// Allow the origin to withdraw on behalf of given address. + #[pallet::no_default_bounds] type WithdrawOrigin: EnsureAddressOrigin>; /// Mapping from address to account id. + #[pallet::no_default_bounds] type AddressMapping: AddressMapping>; + /// Currency type for withdraw and balance storage. + #[pallet::no_default] type Currency: Currency> + Inspect>; /// The overarching event type. + #[pallet::no_default_bounds] type RuntimeEvent: From> + IsType<::RuntimeEvent>; + /// Precompiles associated with this EVM engine. type PrecompilesType: PrecompileSet; type PrecompilesValue: Get; + /// Chain ID of EVM. type ChainId: Get; /// The block gas limit. Can be a simple constant, or an adjustment algorithm in another pallet. type BlockGasLimit: Get; + /// EVM execution runner. + #[pallet::no_default] type Runner: Runner; /// To handle fee deduction for EVM transactions. An example is this pallet being used by `pallet_ethereum` /// where the chain implementing `pallet_ethereum` should be able to configure what happens to the fees /// Similar to `OnChargeTransaction` of `pallet_transaction_payment` + #[pallet::no_default_bounds] type OnChargeTransaction: OnChargeEVMTransaction; /// Called on create calls, used to record owner + #[pallet::no_default_bounds] type OnCreate: OnCreate; /// Find author for the current block. @@ -181,6 +196,7 @@ pub mod pallet { type SuicideQuickClearLimit: Get; /// Get the timestamp for the current block. + #[pallet::no_default] type Timestamp: Time; /// Weight information for extrinsics in this pallet. @@ -192,6 +208,77 @@ pub mod pallet { } } + pub mod config_preludes { + use super::*; + use core::str::FromStr; + use frame_support::{derive_impl, parameter_types, ConsensusEngineId}; + use sp_runtime::traits::BlakeTwo256; + + pub struct TestDefaultConfig; + + #[derive_impl( + frame_system::config_preludes::SolochainDefaultConfig, + no_aggregated_types + )] + impl frame_system::DefaultConfig for TestDefaultConfig {} + + const BLOCK_GAS_LIMIT: u64 = 150_000_000; + const MAX_POV_SIZE: u64 = 5 * 1024 * 1024; + + parameter_types! { + pub BlockGasLimit: U256 = U256::from(BLOCK_GAS_LIMIT); + pub const ChainId: u64 = 42; + pub const GasLimitPovSizeRatio: u64 = BLOCK_GAS_LIMIT.saturating_div(MAX_POV_SIZE); + pub WeightPerGas: Weight = Weight::from_parts(20_000, 0); + pub SuicideQuickClearLimit: u32 = 0; + } + + #[register_default_impl(TestDefaultConfig)] + impl DefaultConfig for TestDefaultConfig { + type CallOrigin = EnsureAddressRoot; + type WithdrawOrigin = EnsureAddressNever; + type AddressMapping = HashedAddressMapping; + type FeeCalculator = FixedGasPrice; + type GasWeightMapping = FixedGasWeightMapping; + type WeightPerGas = WeightPerGas; + #[inject_runtime_type] + type RuntimeEvent = (); + type PrecompilesType = (); + type PrecompilesValue = (); + type ChainId = ChainId; + type BlockGasLimit = BlockGasLimit; + type OnChargeTransaction = (); + type OnCreate = (); + type FindAuthor = FindAuthorTruncated; + type GasLimitPovSizeRatio = GasLimitPovSizeRatio; + type SuicideQuickClearLimit = SuicideQuickClearLimit; + type WeightInfo = (); + } + + impl FixedGasWeightMappingAssociatedTypes for TestDefaultConfig { + type WeightPerGas = ::WeightPerGas; + type BlockWeights = ::BlockWeights; + type GasLimitPovSizeRatio = ::GasLimitPovSizeRatio; + } + + pub struct FixedGasPrice; + impl FeeCalculator for FixedGasPrice { + fn min_gas_price() -> (U256, Weight) { + (1.into(), Weight::zero()) + } + } + + pub struct FindAuthorTruncated; + impl FindAuthor for FindAuthorTruncated { + fn find_author<'a, I>(_digests: I) -> Option + where + I: 'a + IntoIterator, + { + Some(H160::from_str("1234500000000000000000000000000000000000").unwrap()) + } + } + } + #[pallet::call] impl Pallet { /// Withdraw balance from EVM into currency/balances pallet. @@ -772,8 +859,23 @@ pub trait GasWeightMapping { fn weight_to_gas(weight: Weight) -> u64; } +pub trait FixedGasWeightMappingAssociatedTypes { + type WeightPerGas: Get; + type BlockWeights: Get; + type GasLimitPovSizeRatio: Get; +} + +impl FixedGasWeightMappingAssociatedTypes for T { + type WeightPerGas = T::WeightPerGas; + type BlockWeights = T::BlockWeights; + type GasLimitPovSizeRatio = T::GasLimitPovSizeRatio; +} + pub struct FixedGasWeightMapping(core::marker::PhantomData); -impl GasWeightMapping for FixedGasWeightMapping { +impl GasWeightMapping for FixedGasWeightMapping +where + T: FixedGasWeightMappingAssociatedTypes, +{ fn gas_to_weight(gas: u64, without_base_weight: bool) -> Weight { let mut weight = T::WeightPerGas::get().saturating_mul(gas); if without_base_weight { diff --git a/frame/evm/src/mock.rs b/frame/evm/src/mock.rs index 8cb158d4d0..e72827966c 100644 --- a/frame/evm/src/mock.rs +++ b/frame/evm/src/mock.rs @@ -17,21 +17,12 @@ //! Test mock for unit tests and benchmarking -use core::str::FromStr; -use frame_support::{ - derive_impl, parameter_types, - traits::{ConstU32, FindAuthor}, - weights::Weight, -}; -use sp_core::{H160, H256, U256}; -use sp_runtime::{ - traits::{BlakeTwo256, IdentityLookup}, - ConsensusEngineId, -}; +use frame_support::{derive_impl, parameter_types, weights::Weight}; +use sp_core::{H160, U256}; use crate::{ - EnsureAddressNever, EnsureAddressRoot, FeeCalculator, IdentityAddressMapping, - IsPrecompileResult, Precompile, PrecompileHandle, PrecompileResult, PrecompileSet, + FeeCalculator, IsPrecompileResult, Precompile, PrecompileHandle, PrecompileResult, + PrecompileSet, }; frame_support::construct_runtime! { @@ -49,116 +40,48 @@ parameter_types! { frame_system::limits::BlockWeights::simple_max(Weight::from_parts(1024, 0)); } -#[derive_impl(frame_system::config_preludes::TestDefaultConfig as frame_system::DefaultConfig)] +#[derive_impl(frame_system::config_preludes::SolochainDefaultConfig as frame_system::DefaultConfig)] impl frame_system::Config for Test { - type RuntimeEvent = RuntimeEvent; - type BaseCallFilter = frame_support::traits::Everything; - type BlockWeights = (); - type BlockLength = (); - type RuntimeOrigin = RuntimeOrigin; - type RuntimeCall = RuntimeCall; - type RuntimeTask = RuntimeTask; type Nonce = u64; - type Hash = H256; - type Hashing = BlakeTwo256; - type AccountId = H160; - type Lookup = IdentityLookup; type Block = frame_system::mocking::MockBlock; type BlockHashCount = BlockHashCount; - type DbWeight = (); - type Version = (); - type PalletInfo = PalletInfo; type AccountData = pallet_balances::AccountData; - type OnNewAccount = (); - type OnKilledAccount = (); - type SystemWeightInfo = (); - type SS58Prefix = (); - type OnSetCode = (); - type MaxConsumers = ConstU32<16>; } parameter_types! { pub const ExistentialDeposit: u64 = 0; } +#[derive_impl(pallet_balances::config_preludes::TestDefaultConfig)] impl pallet_balances::Config for Test { - type RuntimeEvent = RuntimeEvent; - type RuntimeHoldReason = RuntimeHoldReason; - type RuntimeFreezeReason = RuntimeFreezeReason; - type WeightInfo = (); - type Balance = u64; - type DustRemoval = (); type ExistentialDeposit = ExistentialDeposit; type AccountStore = System; - type ReserveIdentifier = [u8; 8]; - type FreezeIdentifier = RuntimeFreezeReason; - type MaxLocks = (); - type MaxReserves = (); - type MaxFreezes = (); -} - -parameter_types! { - pub const MinimumPeriod: u64 = 1000; -} -impl pallet_timestamp::Config for Test { - type Moment = u64; - type OnTimestampSet = (); - type MinimumPeriod = MinimumPeriod; - type WeightInfo = (); -} - -pub struct FixedGasPrice; -impl FeeCalculator for FixedGasPrice { - fn min_gas_price() -> (U256, Weight) { - // Return some meaningful gas price and weight - (1_000_000_000u128.into(), Weight::from_parts(7u64, 0)) - } } -pub struct FindAuthorTruncated; -impl FindAuthor for FindAuthorTruncated { - fn find_author<'a, I>(_digests: I) -> Option - where - I: 'a + IntoIterator, - { - Some(H160::from_str("1234500000000000000000000000000000000000").unwrap()) - } -} -const BLOCK_GAS_LIMIT: u64 = 150_000_000; -const MAX_POV_SIZE: u64 = 5 * 1024 * 1024; +#[derive_impl(pallet_timestamp::config_preludes::TestDefaultConfig)] +impl pallet_timestamp::Config for Test {} parameter_types! { - pub BlockGasLimit: U256 = U256::from(BLOCK_GAS_LIMIT); - pub const GasLimitPovSizeRatio: u64 = BLOCK_GAS_LIMIT.saturating_div(MAX_POV_SIZE); - pub WeightPerGas: Weight = Weight::from_parts(20_000, 0); pub MockPrecompiles: MockPrecompileSet = MockPrecompileSet; - pub SuicideQuickClearLimit: u32 = 0; } + +#[derive_impl(crate::config_preludes::TestDefaultConfig)] impl crate::Config for Test { type AccountProvider = crate::FrameSystemAccountProvider; type FeeCalculator = FixedGasPrice; - type GasWeightMapping = crate::FixedGasWeightMapping; - type WeightPerGas = WeightPerGas; - type BlockHashMapping = crate::SubstrateBlockHashMapping; - type CallOrigin = EnsureAddressRoot; - - type WithdrawOrigin = EnsureAddressNever; - type AddressMapping = IdentityAddressMapping; type Currency = Balances; - - type RuntimeEvent = RuntimeEvent; type PrecompilesType = MockPrecompileSet; type PrecompilesValue = MockPrecompiles; - type ChainId = (); - type BlockGasLimit = BlockGasLimit; type Runner = crate::runner::stack::Runner; - type OnChargeTransaction = (); - type OnCreate = (); - type FindAuthor = FindAuthorTruncated; - type GasLimitPovSizeRatio = GasLimitPovSizeRatio; - type SuicideQuickClearLimit = SuicideQuickClearLimit; type Timestamp = Timestamp; - type WeightInfo = (); +} + +pub struct FixedGasPrice; +impl FeeCalculator for FixedGasPrice { + fn min_gas_price() -> (U256, Weight) { + // Return some meaningful gas price and weight + (1_000_000_000u128.into(), Weight::from_parts(7u64, 0)) + } } /// Example PrecompileSet with only Identity precompile. diff --git a/frame/evm/src/tests.rs b/frame/evm/src/tests.rs index f2379c19d5..8bef720c77 100644 --- a/frame/evm/src/tests.rs +++ b/frame/evm/src/tests.rs @@ -663,10 +663,11 @@ pub fn new_test_ext() -> sp_io::TestExternalities { }, ); + // Create the block author account with some balance. + let author = H160::from_str("0x1234500000000000000000000000000000000000").unwrap(); pallet_balances::GenesisConfig:: { - // Create the block author account with some balance. balances: vec![( - H160::from_str("0x1234500000000000000000000000000000000000").unwrap(), + ::AddressMapping::into_account_id(author), 12345, )], } @@ -723,15 +724,15 @@ fn fee_deduction() { // Seed account let _ = ::Currency::deposit_creating(&substrate_addr, 100); - assert_eq!(Balances::free_balance(substrate_addr), 100); + assert_eq!(Balances::free_balance(&substrate_addr), 100); // Deduct fees as 10 units let imbalance = <::OnChargeTransaction as OnChargeEVMTransaction>::withdraw_fee(&evm_addr, U256::from(10)).unwrap(); - assert_eq!(Balances::free_balance(substrate_addr), 90); + assert_eq!(Balances::free_balance(&substrate_addr), 90); // Refund fees as 5 units <::OnChargeTransaction as OnChargeEVMTransaction>::correct_and_deposit_fee(&evm_addr, U256::from(5), U256::from(5), imbalance); - assert_eq!(Balances::free_balance(substrate_addr), 95); + assert_eq!(Balances::free_balance(&substrate_addr), 95); }); } @@ -744,7 +745,7 @@ fn ed_0_refund_patch_works() { let substrate_addr = ::AddressMapping::into_account_id(evm_addr); let _ = ::Currency::deposit_creating(&substrate_addr, 21_777_000_000_000); - assert_eq!(Balances::free_balance(substrate_addr), 21_777_000_000_000); + assert_eq!(Balances::free_balance(&substrate_addr), 21_777_000_000_000); let _ = EVM::call( RuntimeOrigin::root(), @@ -759,7 +760,7 @@ fn ed_0_refund_patch_works() { Vec::new(), ); // All that was due, was refunded. - assert_eq!(Balances::free_balance(substrate_addr), 776_000_000_000); + assert_eq!(Balances::free_balance(&substrate_addr), 776_000_000_000); }); } @@ -772,7 +773,7 @@ fn ed_0_refund_patch_is_required() { let substrate_addr = ::AddressMapping::into_account_id(evm_addr); let _ = ::Currency::deposit_creating(&substrate_addr, 100); - assert_eq!(Balances::free_balance(substrate_addr), 100); + assert_eq!(Balances::free_balance(&substrate_addr), 100); // Drain funds let _ = @@ -781,7 +782,7 @@ fn ed_0_refund_patch_is_required() { U256::from(100), ) .unwrap(); - assert_eq!(Balances::free_balance(substrate_addr), 0); + assert_eq!(Balances::free_balance(&substrate_addr), 0); // Try to refund. With ED 0, although the balance is now 0, the account still exists. // So its expected that calling `deposit_into_existing` results in the AccountData to increase the Balance. @@ -1029,7 +1030,7 @@ fn handle_sufficient_reference() { // Using the create / remove account functions is the correct way to handle it. EVM::create_account(addr_2, vec![1, 2, 3]); - let account_2 = frame_system::Account::::get(substrate_addr_2); + let account_2 = frame_system::Account::::get(&substrate_addr_2); // We increased the sufficient reference by 1. assert_eq!(account_2.sufficients, 1); EVM::remove_account(&addr_2); diff --git a/primitives/evm/src/lib.rs b/primitives/evm/src/lib.rs index 2ae0b344bf..377b9fe2ae 100644 --- a/primitives/evm/src/lib.rs +++ b/primitives/evm/src/lib.rs @@ -61,8 +61,8 @@ pub struct Vicinity { pub origin: H160, } -/// `System::Account` 16(hash) + 20 (key) + 60 (AccountInfo::max_encoded_len) -pub const ACCOUNT_BASIC_PROOF_SIZE: u64 = 96; +/// `System::Account` 16(hash) + 20 (key) + 72 (AccountInfo::max_encoded_len) +pub const ACCOUNT_BASIC_PROOF_SIZE: u64 = 108; /// `AccountCodesMetadata` read, temptatively 16 (hash) + 20 (key) + 40 (CodeMetadata). pub const ACCOUNT_CODES_METADATA_PROOF_SIZE: u64 = 76; /// 16 (hash1) + 20 (key1) + 16 (hash2) + 32 (key2) + 32 (value) diff --git a/template/runtime/src/lib.rs b/template/runtime/src/lib.rs index a2e0152d87..b2fa840edc 100644 --- a/template/runtime/src/lib.rs +++ b/template/runtime/src/lib.rs @@ -378,7 +378,7 @@ parameter_types! { impl pallet_ethereum::Config for Runtime { type RuntimeEvent = RuntimeEvent; - type StateRoot = pallet_ethereum::IntermediateStateRoot; + type StateRoot = pallet_ethereum::IntermediateStateRoot; type PostLogContent = PostBlockAndTxnHashes; type ExtraDataLength = ConstU32<30>; }