diff --git a/pallets/author-inherent/src/lib.rs b/pallets/author-inherent/src/lib.rs index 2472043c..b448a3ee 100644 --- a/pallets/author-inherent/src/lib.rs +++ b/pallets/author-inherent/src/lib.rs @@ -22,6 +22,7 @@ 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, @@ -29,7 +30,6 @@ use nimbus_primitives::{ use parity_scale_codec::{Decode, Encode, FullCodec}; use sp_inherents::{InherentIdentifier, IsFatalError}; use sp_runtime::{ConsensusEngineId, RuntimeString}; -use alloc::string::String; pub use crate::weights::WeightInfo; pub use exec::BlockExecutor; 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..f7576b33 100644 --- a/precompiles/assets-erc20/src/mock.rs +++ b/precompiles/assets-erc20/src/mock.rs @@ -167,6 +167,10 @@ parameter_types! { let block_gas_limit = BlockGasLimit::get().min(u64::MAX.into()).low_u64(); block_gas_limit.saturating_div(MAX_POV_SIZE) }; + pub GasLimitStorageGrowthRatio: u64 = { + let block_gas_limit = BlockGasLimit::get().min(u64::MAX.into()).low_u64(); + block_gas_limit.saturating_div(BLOCK_STORAGE_LIMIT) + }; } impl pallet_evm::Config for Runtime { @@ -190,6 +194,7 @@ impl pallet_evm::Config for Runtime { type OnCreate = (); type GasLimitPovSizeRatio = GasLimitPovSizeRatio; type SuicideQuickClearLimit = ConstU32<0>; + type GasLimitStorageGrowthRatio = GasLimitStorageGrowthRatio; type Timestamp = Timestamp; type WeightInfo = pallet_evm::weights::SubstrateWeight; } diff --git a/precompiles/balances-erc20/src/lib.rs b/precompiles/balances-erc20/src/lib.rs index 8f04c304..41e98be1 100644 --- a/precompiles/balances-erc20/src/lib.rs +++ b/precompiles/balances-erc20/src/lib.rs @@ -46,6 +46,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)"); @@ -288,7 +292,7 @@ where dest: Runtime::Lookup::unlookup(to), value: value, }, - 0, + SYSTEM_ACCOUNT_SIZE, )?; } @@ -354,7 +358,7 @@ where dest: Runtime::Lookup::unlookup(to), value: value, }, - 0, + SYSTEM_ACCOUNT_SIZE, )?; } @@ -416,7 +420,7 @@ where dest: Runtime::Lookup::unlookup(caller), value: amount, }, - 0, + SYSTEM_ACCOUNT_SIZE, )?; log2( diff --git a/precompiles/balances-erc20/src/mock.rs b/precompiles/balances-erc20/src/mock.rs index 3dc4d1e1..2f35d441 100644 --- a/precompiles/balances-erc20/src/mock.rs +++ b/precompiles/balances-erc20/src/mock.rs @@ -116,6 +116,10 @@ parameter_types! { let block_gas_limit = BlockGasLimit::get().min(u64::MAX.into()).low_u64(); block_gas_limit.saturating_div(MAX_POV_SIZE) }; + pub GasLimitStorageGrowthRatio: u64 = { + let block_gas_limit = BlockGasLimit::get().min(u64::MAX.into()).low_u64(); + block_gas_limit.saturating_div(BLOCK_STORAGE_LIMIT) + }; } impl pallet_evm::Config for Runtime { @@ -139,6 +143,7 @@ impl pallet_evm::Config for Runtime { type OnCreate = (); type GasLimitPovSizeRatio = GasLimitPovSizeRatio; type SuicideQuickClearLimit = ConstU32<0>; + type GasLimitStorageGrowthRatio = GasLimitStorageGrowthRatio; type Timestamp = Timestamp; type WeightInfo = pallet_evm::weights::SubstrateWeight; } diff --git a/precompiles/batch/src/mock.rs b/precompiles/batch/src/mock.rs index fca121d2..1afaad72 100644 --- a/precompiles/batch/src/mock.rs +++ b/precompiles/batch/src/mock.rs @@ -131,6 +131,10 @@ parameter_types! { let block_gas_limit = BlockGasLimit::get().min(u64::MAX.into()).low_u64(); block_gas_limit.saturating_div(MAX_POV_SIZE) }; + pub GasLimitStorageGrowthRatio: u64 = { + let block_gas_limit = BlockGasLimit::get().min(u64::MAX.into()).low_u64(); + block_gas_limit.saturating_div(BLOCK_STORAGE_LIMIT) + }; } impl pallet_evm::Config for Runtime { @@ -154,6 +158,7 @@ impl pallet_evm::Config for Runtime { type OnCreate = (); type GasLimitPovSizeRatio = GasLimitPovSizeRatio; type SuicideQuickClearLimit = ConstU32<0>; + type GasLimitStorageGrowthRatio = GasLimitStorageGrowthRatio; type Timestamp = Timestamp; type WeightInfo = pallet_evm::weights::SubstrateWeight; } diff --git a/precompiles/call-permit/src/mock.rs b/precompiles/call-permit/src/mock.rs index e0848b35..3cf26692 100644 --- a/precompiles/call-permit/src/mock.rs +++ b/precompiles/call-permit/src/mock.rs @@ -140,6 +140,7 @@ impl pallet_evm::Config for Runtime { 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..7841e78f 100644 --- a/precompiles/pallet-xcm/src/mock.rs +++ b/precompiles/pallet-xcm/src/mock.rs @@ -271,6 +271,7 @@ impl pallet_evm::Config for Runtime { type FindAuthor = (); type OnCreate = (); type GasLimitPovSizeRatio = GasLimitPovSizeRatio; + type GasLimitStorageGrowthRatio = GasLimitStorageGrowthRatio; type SuicideQuickClearLimit = ConstU32<0>; type Timestamp = Timestamp; type WeightInfo = pallet_evm::weights::SubstrateWeight; diff --git a/precompiles/proxy/src/lib.rs b/precompiles/proxy/src/lib.rs index 25df5777..28441981 100644 --- a/precompiles/proxy/src/lib.rs +++ b/precompiles/proxy/src/lib.rs @@ -37,6 +37,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; + #[derive(Debug)] pub struct OnlyIsProxy(PhantomData); @@ -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..477f8f4c 100644 --- a/precompiles/proxy/src/mock.rs +++ b/precompiles/proxy/src/mock.rs @@ -155,6 +155,10 @@ parameter_types! { let block_gas_limit = BlockGasLimit::get().min(u64::MAX.into()).low_u64(); block_gas_limit.saturating_div(MAX_POV_SIZE) }; + pub GasLimitStorageGrowthRatio: u64 = { + let block_gas_limit = BlockGasLimit::get().min(u64::MAX.into()).low_u64(); + block_gas_limit.saturating_div(BLOCK_STORAGE_LIMIT) + }; } impl pallet_evm::Config for Runtime { type AccountProvider = pallet_evm::FrameSystemAccountProvider; @@ -179,6 +183,7 @@ impl pallet_evm::Config for Runtime { type SuicideQuickClearLimit = ConstU32<0>; type Timestamp = Timestamp; type WeightInfo = pallet_evm::weights::SubstrateWeight; + type GasLimitStorageGrowthRatio = GasLimitStorageGrowthRatio; } parameter_types! { diff --git a/precompiles/xcm-utils/src/mock.rs b/precompiles/xcm-utils/src/mock.rs index 1b32c305..ef37099a 100644 --- a/precompiles/xcm-utils/src/mock.rs +++ b/precompiles/xcm-utils/src/mock.rs @@ -253,6 +253,10 @@ parameter_types! { let block_gas_limit = BlockGasLimit::get().min(u64::MAX.into()).low_u64(); block_gas_limit.saturating_div(MAX_POV_SIZE) }; + pub GasLimitStorageGrowthRatio: u64 = { + let block_gas_limit = BlockGasLimit::get().min(u64::MAX.into()).low_u64(); + block_gas_limit.saturating_div(BLOCK_STORAGE_LIMIT) + }; } /// A mapping function that converts Ethereum gas to Substrate weight @@ -288,6 +292,7 @@ impl pallet_evm::Config for Runtime { type OnCreate = (); type GasLimitPovSizeRatio = GasLimitPovSizeRatio; type SuicideQuickClearLimit = ConstU32<0>; + type GasLimitStorageGrowthRatio = GasLimitStorageGrowthRatio; type Timestamp = Timestamp; type WeightInfo = pallet_evm::weights::SubstrateWeight; }