Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce a gas-based storage limit [MBIP-5] #2452

Merged
merged 26 commits into from
Aug 30, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
ec950e3
temporarily pim frontier and evm local changes
ahmadkaouk Aug 25, 2023
0aa9802
support to record storage growth in precompiles
ahmadkaouk Aug 25, 2023
38d7d69
add GasLimitStorageGrowth
ahmadkaouk Aug 25, 2023
1429e4d
add GasLimitStorageGrowth in mocks
ahmadkaouk Aug 25, 2023
f805738
Merge branch 'master' into ahmad-mbip-5
ahmadkaouk Aug 27, 2023
5a86eaf
add storage growth for precompiles
ahmadkaouk Aug 27, 2023
8cf9e31
fix tests
ahmadkaouk Aug 28, 2023
995a3b7
add typescript tests
ahmadkaouk Aug 28, 2023
fabcccc
update frontier and evm dependencies
ahmadkaouk Aug 29, 2023
cfb7f69
use the moonbeam-foundation org for the evm dependency
ahmadkaouk Aug 29, 2023
c56abde
fix tests
ahmadkaouk Aug 29, 2023
7acc7a7
Merge branch 'master' into ahmad-mbip-5
ahmadkaouk Aug 29, 2023
3dd1d48
fix formatting
ahmadkaouk Aug 29, 2023
bcf28b8
Merge branch 'master' into ahmad-mbip-5
ahmadkaouk Aug 29, 2023
321fd53
Update precompiles/utils/src/substrate.rs
ahmadkaouk Aug 29, 2023
f8dec39
fix expected gas for precompile proxy
ahmadkaouk Aug 29, 2023
a9d6a72
Update test/suites/dev/test-storage-growth/test-evm-create-storage-gr…
crystalin Aug 29, 2023
627d3e6
add tests of storage growth for precompiles
ahmadkaouk Aug 29, 2023
75771b9
disable MBIP 5 on moonriver and moonbeam
ahmadkaouk Aug 29, 2023
3c30736
fix tests
ahmadkaouk Aug 29, 2023
08ba2bd
fix typo
ahmadkaouk Aug 29, 2023
942a9a3
Merge branch 'master' into ahmad-mbip-5
crystalin Aug 29, 2023
4b54b75
adds rustls-webpki to accepted licenses
crystalin Aug 29, 2023
f55a843
set storage_growth to 0 for add_proxy precompile
ahmadkaouk Aug 29, 2023
555dcae
set growth ratio as a constant
ahmadkaouk Aug 29, 2023
9c1a1af
fix formatting
ahmadkaouk Aug 29, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,105 changes: 589 additions & 516 deletions Cargo.lock

Large diffs are not rendered by default.

48 changes: 24 additions & 24 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -217,36 +217,36 @@ ethereum = { version = "0.14.0", default-features = false, features = [
"with-codec",
] }
ethereum-types = { version = "0.14", default-features = false }
evm = { git = "https://github.com/moonbeam-foundation/evm", branch = "tgm-record-external-cost", default-features = false }
evm-gasometer = { git = "https://github.com/moonbeam-foundation/evm", branch = "tgm-record-external-cost", default-features = false }
evm-runtime = { git = "https://github.com/moonbeam-foundation/evm", branch = "tgm-record-external-cost", default-features = false }
fp-ethereum = { git = "https://github.com/moonbeam-foundation/frontier", branch = "moonbeam-polkadot-v0.9.43", default-features = false }
fp-evm = { git = "https://github.com/moonbeam-foundation/frontier", branch = "moonbeam-polkadot-v0.9.43", default-features = false }
fp-rpc = { git = "https://github.com/moonbeam-foundation/frontier", branch = "moonbeam-polkadot-v0.9.43", default-features = false }
fp-self-contained = { git = "https://github.com/moonbeam-foundation/frontier", branch = "moonbeam-polkadot-v0.9.43", default-features = false }
pallet-base-fee = { git = "https://github.com/moonbeam-foundation/frontier", branch = "moonbeam-polkadot-v0.9.43", default-features = false }
pallet-ethereum = { git = "https://github.com/moonbeam-foundation/frontier", branch = "moonbeam-polkadot-v0.9.43", default-features = false, features = [ "forbid-evm-reentrancy" ] }
pallet-evm = { git = "https://github.com/moonbeam-foundation/frontier", branch = "moonbeam-polkadot-v0.9.43", default-features = false, features = [
evm = { path = "/Users/ahmadkaouk/workspace/moonbeam/evm", default-features = false }
ahmadkaouk marked this conversation as resolved.
Show resolved Hide resolved
evm-gasometer = { path = "/Users/ahmadkaouk/workspace/moonbeam/evm/gasometer", default-features = false }
evm-runtime = { path = "/Users/ahmadkaouk/workspace/moonbeam/evm/runtime", default-features = false }
fp-ethereum = { path = "/Users/ahmadkaouk/workspace/moonbeam/frontier/primitives/ethereum", default-features = false }
fp-evm = { path = "/Users/ahmadkaouk/workspace/moonbeam/frontier/primitives/evm", default-features = false }
fp-rpc = { path = "/Users/ahmadkaouk/workspace/moonbeam/frontier/primitives/rpc", default-features = false }
fp-self-contained = { path = "/Users/ahmadkaouk/workspace/moonbeam/frontier/primitives/self-contained", default-features = false }
pallet-base-fee = { path = "/Users/ahmadkaouk/workspace/moonbeam/frontier/frame/base-fee", default-features = false }
pallet-ethereum = { path = "/Users/ahmadkaouk/workspace/moonbeam/frontier/frame/ethereum", default-features = false, features = [ "forbid-evm-reentrancy" ] }
pallet-evm = { path = "/Users/ahmadkaouk/workspace/moonbeam/frontier/frame/evm", default-features = false, features = [
"forbid-evm-reentrancy",
] }
pallet-evm-precompile-blake2 = { git = "https://github.com/moonbeam-foundation/frontier", branch = "moonbeam-polkadot-v0.9.43", default-features = false }
pallet-evm-precompile-bn128 = { git = "https://github.com/moonbeam-foundation/frontier", branch = "moonbeam-polkadot-v0.9.43", default-features = false }
pallet-evm-precompile-dispatch = { git = "https://github.com/moonbeam-foundation/frontier", branch = "moonbeam-polkadot-v0.9.43", default-features = false }
pallet-evm-precompile-modexp = { git = "https://github.com/moonbeam-foundation/frontier", branch = "moonbeam-polkadot-v0.9.43", default-features = false }
pallet-evm-precompile-sha3fips = { git = "https://github.com/moonbeam-foundation/frontier", branch = "moonbeam-polkadot-v0.9.43", default-features = false }
pallet-evm-precompile-simple = { git = "https://github.com/moonbeam-foundation/frontier", branch = "moonbeam-polkadot-v0.9.43", default-features = false }
pallet-evm-precompile-blake2 = { path = "/Users/ahmadkaouk/workspace/moonbeam/frontier/frame/evm/precompile/blake2", default-features = false }
pallet-evm-precompile-bn128 = { path = "/Users/ahmadkaouk/workspace/moonbeam/frontier/frame/evm/precompile/bn128", default-features = false }
pallet-evm-precompile-dispatch = { path = "/Users/ahmadkaouk/workspace/moonbeam/frontier/frame/evm/precompile/dispatch", default-features = false }
pallet-evm-precompile-modexp = { path = "/Users/ahmadkaouk/workspace/moonbeam/frontier/frame/evm/precompile/modexp", default-features = false }
pallet-evm-precompile-sha3fips = { path = "/Users/ahmadkaouk/workspace/moonbeam/frontier/frame/evm/precompile/sha3fips", default-features = false }
pallet-evm-precompile-simple = { path = "/Users/ahmadkaouk/workspace/moonbeam/frontier/frame/evm/precompile/simple", default-features = false }

# Frontier (client)
fc-consensus = { git = "https://github.com/moonbeam-foundation/frontier", branch = "moonbeam-polkadot-v0.9.43" }
fc-db = { git = "https://github.com/moonbeam-foundation/frontier", branch = "moonbeam-polkadot-v0.9.43" }
fc-mapping-sync = { git = "https://github.com/moonbeam-foundation/frontier", branch = "moonbeam-polkadot-v0.9.43" }
fc-rpc = { git = "https://github.com/moonbeam-foundation/frontier", branch = "moonbeam-polkadot-v0.9.43", features = [
fc-consensus = { path = "/Users/ahmadkaouk/workspace/moonbeam/frontier/client/consensus" }
fc-db = { path = "/Users/ahmadkaouk/workspace/moonbeam/frontier/client/db" }
fc-mapping-sync = { path = "/Users/ahmadkaouk/workspace/moonbeam/frontier/client/mapping-sync" }
fc-rpc = { path = "/Users/ahmadkaouk/workspace/moonbeam/frontier/client/rpc", features = [
"rpc-binary-search-estimate",
] }
fc-rpc-core = { git = "https://github.com/moonbeam-foundation/frontier", branch = "moonbeam-polkadot-v0.9.43" }
fc-storage = { git = "https://github.com/moonbeam-foundation/frontier", branch = "moonbeam-polkadot-v0.9.43" }
fp-consensus = { git = "https://github.com/moonbeam-foundation/frontier", branch = "moonbeam-polkadot-v0.9.43" }
fp-storage = { git = "https://github.com/moonbeam-foundation/frontier", branch = "moonbeam-polkadot-v0.9.43" }
fc-rpc-core = { path = "/Users/ahmadkaouk/workspace/moonbeam/frontier/client/rpc-core" }
fc-storage = { path = "/Users/ahmadkaouk/workspace/moonbeam/frontier/client/storage" }
fp-consensus = { path = "/Users/ahmadkaouk/workspace/moonbeam/frontier/primitives/consensus" }
fp-storage = { path = "/Users/ahmadkaouk/workspace/moonbeam/frontier/primitives/storage" }

# Cumulus (wasm)
cumulus-pallet-dmp-queue = { git = "https://github.com/moonbeam-foundation/cumulus", branch = "moonbeam-polkadot-v0.9.43", default-features = false }
Expand Down
7 changes: 7 additions & 0 deletions pallets/ethereum-xcm/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ impl FindAuthor<H160> for FindAuthorTruncated {
}

const MAX_POV_SIZE: u64 = 5 * 1024 * 1024;
/// Block storage limit in bytes. Set to 40 KB.
const BLOCK_STORAGE_LIMIT: u64 = 40 * 1024;

parameter_types! {
pub const TransactionByteFee: u64 = 1;
Expand All @@ -157,6 +159,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)
};
}

pub struct HashedAddressMapping;
Expand Down Expand Up @@ -188,6 +194,7 @@ impl pallet_evm::Config for Test {
type BlockHashMapping = pallet_ethereum::EthereumBlockHashMapping<Self>;
type OnCreate = ();
type GasLimitPovSizeRatio = GasLimitPovSizeRatio;
type GasLimitStorageGrowthRatio = GasLimitStorageGrowthRatio;
type Timestamp = Timestamp;
type WeightInfo = pallet_evm::weights::SubstrateWeight<Test>;
}
Expand Down
7 changes: 7 additions & 0 deletions precompiles/assets-erc20/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,8 @@ pub type LocalPCall = Erc20AssetsPrecompileSetCall<Runtime, IsLocal, pallet_asse
pub type ForeignPCall = Erc20AssetsPrecompileSetCall<Runtime, IsLocal, pallet_assets::Instance1>;

const MAX_POV_SIZE: u64 = 5 * 1024 * 1024;
/// Block Storage Limit in bytes. Set to 40KB.
const BLOCK_STORAGE_LIMIT: u64 = 40 * 1024;

parameter_types! {
pub BlockGasLimit: U256 = U256::from(u64::MAX);
Expand All @@ -189,6 +191,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 {
Expand All @@ -210,6 +216,7 @@ impl pallet_evm::Config for Runtime {
type FindAuthor = ();
type OnCreate = ();
type GasLimitPovSizeRatio = GasLimitPovSizeRatio;
type GasLimitStorageGrowthRatio = GasLimitStorageGrowthRatio;
type Timestamp = Timestamp;
type WeightInfo = pallet_evm::weights::SubstrateWeight<Runtime>;
}
Expand Down
7 changes: 7 additions & 0 deletions precompiles/author-mapping/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ pub type PCall = AuthorMappingPrecompileCall<Runtime>;
mock_account!(AuthorMappingAccount, |_| MockAccount::from_u64(1));

const MAX_POV_SIZE: u64 = 5 * 1024 * 1024;
/// Block storage limit in bytes. Set to 40 KB.
const BLOCK_STORAGE_LIMIT: u64 = 40 * 1024;

parameter_types! {
pub BlockGasLimit: U256 = U256::from(u64::MAX);
Expand All @@ -117,6 +119,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 {
Expand All @@ -138,6 +144,7 @@ impl pallet_evm::Config for Runtime {
type FindAuthor = ();
type OnCreate = ();
type GasLimitPovSizeRatio = GasLimitPovSizeRatio;
type GasLimitStorageGrowthRatio = GasLimitStorageGrowthRatio;
type Timestamp = Timestamp;
type WeightInfo = pallet_evm::weights::SubstrateWeight<Runtime>;
}
Expand Down
7 changes: 7 additions & 0 deletions precompiles/balances-erc20/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ pub type Precompiles<R> = PrecompileSetBuilder<
pub type PCall = Erc20BalancesPrecompileCall<Runtime, NativeErc20Metadata, ()>;

const MAX_POV_SIZE: u64 = 5 * 1024 * 1024;
/// Block storage limit in bytes. Set to 40 KB.
const BLOCK_STORAGE_LIMIT: u64 = 40 * 1024;

parameter_types! {
pub BlockGasLimit: U256 = U256::from(u64::MAX);
Expand All @@ -110,6 +112,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 {
Expand All @@ -131,6 +137,7 @@ impl pallet_evm::Config for Runtime {
type FindAuthor = ();
type OnCreate = ();
type GasLimitPovSizeRatio = GasLimitPovSizeRatio;
type GasLimitStorageGrowthRatio = GasLimitStorageGrowthRatio;
type Timestamp = Timestamp;
type WeightInfo = pallet_evm::weights::SubstrateWeight<Runtime>;
}
Expand Down
7 changes: 7 additions & 0 deletions precompiles/batch/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ mock_account!(Batch, |_| MockAccount::from_u64(1));
mock_account!(Revert, |_| MockAccount::from_u64(2));

const MAX_POV_SIZE: u64 = 5 * 1024 * 1024;
/// Block storage limit in bytes. Set to 40 KB.
const BLOCK_STORAGE_LIMIT: u64 = 40 * 1024;

parameter_types! {
pub BlockGasLimit: U256 = U256::from(u64::MAX);
Expand All @@ -131,6 +133,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 {
Expand All @@ -152,6 +158,7 @@ impl pallet_evm::Config for Runtime {
type FindAuthor = ();
type OnCreate = ();
type GasLimitPovSizeRatio = GasLimitPovSizeRatio;
type GasLimitStorageGrowthRatio = GasLimitStorageGrowthRatio;
type Timestamp = Timestamp;
type WeightInfo = pallet_evm::weights::SubstrateWeight<Runtime>;
}
Expand Down
1 change: 1 addition & 0 deletions precompiles/call-permit/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ impl pallet_evm::Config for Runtime {
type FindAuthor = ();
type OnCreate = ();
type GasLimitPovSizeRatio = ();
type GasLimitStorageGrowthRatio = ();
type Timestamp = Timestamp;
type WeightInfo = pallet_evm::weights::SubstrateWeight<Runtime>;
}
Expand Down
7 changes: 7 additions & 0 deletions precompiles/collective/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ pub type Precompiles<R> = PrecompileSetBuilder<
pub type PCall = CollectivePrecompileCall<Runtime, pallet_collective::Instance1>;

const MAX_POV_SIZE: u64 = 5 * 1024 * 1024;
/// Block storage limit in bytes. Set to 40 KB.
const BLOCK_STORAGE_LIMIT: u64 = 40 * 1024;

parameter_types! {
pub BlockGasLimit: U256 = U256::from(u64::MAX);
Expand All @@ -125,6 +127,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 {
Expand All @@ -146,6 +152,7 @@ impl pallet_evm::Config for Runtime {
type FindAuthor = ();
type OnCreate = ();
type GasLimitPovSizeRatio = GasLimitPovSizeRatio;
type GasLimitStorageGrowthRatio = GasLimitStorageGrowthRatio;
type Timestamp = Timestamp;
type WeightInfo = pallet_evm::weights::SubstrateWeight<Runtime>;
}
Expand Down
7 changes: 7 additions & 0 deletions precompiles/conviction-voting/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ impl pallet_balances::Config for Runtime {
}

const MAX_POV_SIZE: u64 = 5 * 1024 * 1024;
/// Block storage limit in bytes. Set to 40 KB.
const BLOCK_STORAGE_LIMIT: u64 = 40 * 1024;

parameter_types! {
pub BlockGasLimit: U256 = U256::from(u64::MAX);
Expand All @@ -118,6 +120,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)
};
}

pub type Precompiles<R> =
Expand All @@ -144,6 +150,7 @@ impl pallet_evm::Config for Runtime {
type FindAuthor = ();
type OnCreate = ();
type GasLimitPovSizeRatio = GasLimitPovSizeRatio;
type GasLimitStorageGrowthRatio = GasLimitStorageGrowthRatio;
type Timestamp = Timestamp;
type WeightInfo = pallet_evm::weights::SubstrateWeight<Runtime>;
}
Expand Down
7 changes: 7 additions & 0 deletions precompiles/crowdloan-rewards/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ pub type Precompiles<R> =
pub type PCall = CrowdloanRewardsPrecompileCall<Runtime>;

const MAX_POV_SIZE: u64 = 5 * 1024 * 1024;
/// Block storage limit in bytes. Set to 40 KB.
const BLOCK_STORAGE_LIMIT: u64 = 40 * 1024;

parameter_types! {
pub BlockGasLimit: U256 = U256::from(u64::MAX);
Expand All @@ -142,6 +144,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 {
Expand All @@ -163,6 +169,7 @@ impl pallet_evm::Config for Runtime {
type FindAuthor = ();
type OnCreate = ();
type GasLimitPovSizeRatio = GasLimitPovSizeRatio;
type GasLimitStorageGrowthRatio = GasLimitStorageGrowthRatio;
type Timestamp = Timestamp;
type WeightInfo = pallet_evm::weights::SubstrateWeight<Runtime>;
}
Expand Down
7 changes: 7 additions & 0 deletions precompiles/gmp/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,8 @@ mock_account!(Batch, |_| MockAccount::from_u64(1));
mock_account!(Revert, |_| MockAccount::from_u64(2));

const MAX_POV_SIZE: u64 = 5 * 1024 * 1024;
/// Block storage limit in bytes. Set to 40 KB.
const BLOCK_STORAGE_LIMIT: u64 = 40 * 1024;

parameter_types! {
pub BlockGasLimit: U256 = U256::from(u64::MAX);
Expand All @@ -252,6 +254,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 {
Expand All @@ -269,6 +275,7 @@ impl pallet_evm::Config for Runtime {
type ChainId = ();
type OnChargeTransaction = ();
type BlockGasLimit = BlockGasLimit;
type GasLimitStorageGrowthRatio = GasLimitStorageGrowthRatio;
type BlockHashMapping = pallet_evm::SubstrateBlockHashMapping<Self>;
type FindAuthor = ();
type OnCreate = ();
Expand Down
7 changes: 7 additions & 0 deletions precompiles/pallet-democracy/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ impl pallet_balances::Config for Runtime {
}

const MAX_POV_SIZE: u64 = 5 * 1024 * 1024;
/// Block storage limit in bytes. Set to 40 KB.
const BLOCK_STORAGE_LIMIT: u64 = 40 * 1024;

parameter_types! {
pub BlockGasLimit: U256 = U256::from(u64::MAX);
Expand All @@ -111,6 +113,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)
};
}

pub type Precompiles<R> =
Expand All @@ -137,6 +143,7 @@ impl pallet_evm::Config for Runtime {
type FindAuthor = ();
type OnCreate = ();
type GasLimitPovSizeRatio = GasLimitPovSizeRatio;
type GasLimitStorageGrowthRatio = GasLimitStorageGrowthRatio;
type Timestamp = Timestamp;
type WeightInfo = pallet_evm::weights::SubstrateWeight<Runtime>;
}
Expand Down
7 changes: 7 additions & 0 deletions precompiles/parachain-staking/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ impl pallet_balances::Config for Runtime {
}

const MAX_POV_SIZE: u64 = 5 * 1024 * 1024;
/// Block storage limit in bytes. Set to 40 KB.
const BLOCK_STORAGE_LIMIT: u64 = 40 * 1024;

parameter_types! {
pub BlockGasLimit: U256 = U256::from(u64::MAX);
Expand All @@ -118,6 +120,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)
};
}

pub type Precompiles<R> =
Expand All @@ -144,6 +150,7 @@ impl pallet_evm::Config for Runtime {
type FindAuthor = ();
type OnCreate = ();
type GasLimitPovSizeRatio = GasLimitPovSizeRatio;
type GasLimitStorageGrowthRatio = GasLimitStorageGrowthRatio;
type Timestamp = Timestamp;
type WeightInfo = pallet_evm::weights::SubstrateWeight<Runtime>;
}
Expand Down
1 change: 1 addition & 0 deletions precompiles/precompile-registry/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ impl pallet_evm::Config for Runtime {
type FindAuthor = ();
type OnCreate = ();
type GasLimitPovSizeRatio = ();
type GasLimitStorageGrowthRatio = ();
type Timestamp = Timestamp;
type WeightInfo = pallet_evm::weights::SubstrateWeight<Runtime>;
}
Expand Down
Loading