Skip to content

Commit ed1b8e5

Browse files
committed
fix benchmarking for different node templates (#179)
1 parent 22aaafe commit ed1b8e5

File tree

4 files changed

+81
-9
lines changed

4 files changed

+81
-9
lines changed

frame/evm/src/benchmarking.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ benchmarks! {
7171

7272
let caller = "1000000000000000000000000000000000000001".parse::<H160>().unwrap();
7373

74-
let mut nonce: u64 = 1;
74+
let mut nonce: u64 = 0;
7575
let nonce_as_u256: U256 = nonce.into();
7676

7777
let value = U256::default();
@@ -83,8 +83,8 @@ benchmarks! {
8383
contract_bytecode,
8484
value,
8585
gas_limit_create,
86-
Some(U256::from(1_000_000_000)),
87-
Some(U256::from(1_000_000_000)),
86+
Some(U256::from(1_000_000_000_000_000u128)),
87+
Some(U256::from(1_000_000_000_000_000u128)),
8888
Some(nonce_as_u256),
8989
Vec::new(),
9090
is_transactional,
@@ -120,8 +120,8 @@ benchmarks! {
120120
encoded_call,
121121
value,
122122
gas_limit_call,
123-
Some(U256::from(1_000_000_000)),
124-
Some(U256::from(1_000_000_000)),
123+
Some(U256::from(1_000_000_000_000_000u128)),
124+
Some(U256::from(1_000_000_000_000_000u128)),
125125
Some(nonce_as_u256),
126126
Vec::new(),
127127
is_transactional,

frame/evm/src/weights.rs

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,23 +48,93 @@ use core::marker::PhantomData;
4848

4949
/// Weight functions needed for pallet_evm.
5050
pub trait WeightInfo {
51+
fn runner_execute(x: u32, ) -> Weight;
5152
fn withdraw() -> Weight;
5253
}
5354

5455
/// Weights for pallet_evm using the Substrate node and recommended hardware.
5556
pub struct SubstrateWeight<T>(PhantomData<T>);
5657
impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
58+
/// Storage: BaseFee BaseFeePerGas (r:1 w:0)
59+
/// Proof: BaseFee BaseFeePerGas (max_values: Some(1), max_size: Some(32), added: 527, mode: MaxEncodedLen)
60+
/// Storage: System Account (r:2 w:1)
61+
/// Proof: System Account (max_values: None, max_size: Some(116), added: 2591, mode: MaxEncodedLen)
62+
/// Storage: EVMChainId ChainId (r:1 w:0)
63+
/// Proof: EVMChainId ChainId (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen)
64+
/// Storage: EVM AccountCodes (r:2 w:0)
65+
/// Proof Skipped: EVM AccountCodes (max_values: None, max_size: None, mode: Measured)
66+
/// Storage: System Number (r:1 w:0)
67+
/// Proof: System Number (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen)
68+
/// Storage: System ExecutionPhase (r:1 w:0)
69+
/// Proof: System ExecutionPhase (max_values: Some(1), max_size: Some(5), added: 500, mode: MaxEncodedLen)
70+
/// Storage: System EventCount (r:1 w:1)
71+
/// Proof: System EventCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen)
72+
/// Storage: System Events (r:1 w:1)
73+
/// Proof Skipped: System Events (max_values: Some(1), max_size: None, mode: Measured)
74+
/// Storage: System Digest (r:1 w:0)
75+
/// Proof Skipped: System Digest (max_values: Some(1), max_size: None, mode: Measured)
76+
/// Storage: EVM AccountStorages (r:1 w:0)
77+
/// Proof Skipped: EVM AccountStorages (max_values: None, max_size: None, mode: Measured)
78+
/// Storage: Balances TotalIssuance (r:1 w:1)
79+
/// Proof: Balances TotalIssuance (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen)
80+
/// The range of component `x` is `[1, 10000000]`.
81+
fn runner_execute(x: u32, ) -> Weight {
82+
// Proof Size summary in bytes:
83+
// Measured: `913`
84+
// Estimated: `6853`
85+
// Minimum execution time: 20_400_192_000 picoseconds.
86+
Weight::from_parts(20_767_272_339, 6853)
87+
// Standard Error: 33
88+
.saturating_add(Weight::from_parts(42, 0).saturating_mul(x.into()))
89+
.saturating_add(T::DbWeight::get().reads(13_u64))
90+
.saturating_add(T::DbWeight::get().writes(4_u64))
91+
}
5792
fn withdraw() -> Weight {
5893
// Proof Size summary in bytes:
5994
// Measured: `0`
6095
// Estimated: `0`
6196
// Minimum execution time: 2_000_000 picoseconds.
6297
Weight::from_parts(2_000_000, 0)
6398
}
99+
64100
}
65101

66102
// For backwards compatibility and tests
67103
impl WeightInfo for () {
104+
/// Storage: BaseFee BaseFeePerGas (r:1 w:0)
105+
/// Proof: BaseFee BaseFeePerGas (max_values: Some(1), max_size: Some(32), added: 527, mode: MaxEncodedLen)
106+
/// Storage: System Account (r:2 w:1)
107+
/// Proof: System Account (max_values: None, max_size: Some(116), added: 2591, mode: MaxEncodedLen)
108+
/// Storage: EVMChainId ChainId (r:1 w:0)
109+
/// Proof: EVMChainId ChainId (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen)
110+
/// Storage: EVM AccountCodes (r:2 w:0)
111+
/// Proof Skipped: EVM AccountCodes (max_values: None, max_size: None, mode: Measured)
112+
/// Storage: System Number (r:1 w:0)
113+
/// Proof: System Number (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen)
114+
/// Storage: System ExecutionPhase (r:1 w:0)
115+
/// Proof: System ExecutionPhase (max_values: Some(1), max_size: Some(5), added: 500, mode: MaxEncodedLen)
116+
/// Storage: System EventCount (r:1 w:1)
117+
/// Proof: System EventCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen)
118+
/// Storage: System Events (r:1 w:1)
119+
/// Proof Skipped: System Events (max_values: Some(1), max_size: None, mode: Measured)
120+
/// Storage: System Digest (r:1 w:0)
121+
/// Proof Skipped: System Digest (max_values: Some(1), max_size: None, mode: Measured)
122+
/// Storage: EVM AccountStorages (r:1 w:0)
123+
/// Proof Skipped: EVM AccountStorages (max_values: None, max_size: None, mode: Measured)
124+
/// Storage: Balances TotalIssuance (r:1 w:1)
125+
/// Proof: Balances TotalIssuance (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen)
126+
/// The range of component `x` is `[1, 10000000]`.
127+
fn runner_execute(x: u32, ) -> Weight {
128+
// Proof Size summary in bytes:
129+
// Measured: `913`
130+
// Estimated: `6853`
131+
// Minimum execution time: 20_400_192_000 picoseconds.
132+
Weight::from_parts(20_767_272_339, 6853)
133+
// Standard Error: 33
134+
.saturating_add(Weight::from_parts(42, 0).saturating_mul(x.into()))
135+
.saturating_add(RocksDbWeight::get().reads(13_u64))
136+
.saturating_add(RocksDbWeight::get().writes(4_u64))
137+
}
68138
fn withdraw() -> Weight {
69139
// Proof Size summary in bytes:
70140
// Measured: `0`

scripts/benchmark.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,9 @@ function bench {
3333
--extrinsic="${2}" \
3434
--execution=wasm \
3535
--wasm-execution=compiled \
36+
--header=HEADER-APACHE2 \
3637
--output=weights.rs \
37-
--template=./benchmarking/frame-weight-template.hbs
38+
--template=./.maintain/frame-weight-template.hbs
3839
}
3940

4041
if [[ $# -eq 1 && "${1}" == "--help" ]]; then

template/node/src/chain_spec.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -255,10 +255,11 @@ fn testnet_genesis(
255255
H160::from_str("1000000000000000000000000000000000000001")
256256
.expect("internal H160 is valid; qed"),
257257
fp_evm::GenesisAccount {
258-
nonce: U256::from(1),
259-
balance: U256::from(1_000_000_000_000_000_000_000_000u128),
258+
nonce: Default::default(),
259+
balance: U256::from_str("0xffffffffffffffffffffffffffffffff")
260+
.expect("internal U256 is valid; qed"),
260261
storage: Default::default(),
261-
code: vec![0x00],
262+
code: Default::default(),
262263
},
263264
);
264265
map

0 commit comments

Comments
 (0)