Skip to content
This repository was archived by the owner on Jul 5, 2024. It is now read-only.

Commit e26176d

Browse files
authored
chores: add create/create2 in stats (#1721)
### Description - add create/create2 in stats - in stats, separate dynamic gas with constant gas - sort by height per constant gas to derive worst case
1 parent f05f6cb commit e26176d

File tree

2 files changed

+15
-14
lines changed

2 files changed

+15
-14
lines changed

Diff for: zkevm-circuits/src/bin/stats/helpers.rs

+11-3
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,13 @@ struct Row {
8686
opcode: OpcodeId,
8787
#[table(title = "Height", justify = "Justify::Right")]
8888
height: usize,
89-
#[table(title = "Gas Cost", justify = "Justify::Right")]
89+
#[table(title = "Const Gas Cost", justify = "Justify::Right")]
9090
gas_cost: u64,
91-
#[table(title = "Height per Gas", justify = "Justify::Right")]
91+
#[table(title = "Dynamic Gas Cost", justify = "Justify::Right")]
92+
dynamic_gas_cost: u64,
93+
#[table(title = "Height per dynamic Gas", justify = "Justify::Right")]
94+
height_per_dynamic_gas: PrettyF64,
95+
#[table(title = "Height per const Gas", justify = "Justify::Right")]
9296
height_per_gas: PrettyF64,
9397
}
9498

@@ -213,13 +217,17 @@ pub(crate) fn print_circuit_stats_by_states(
213217
// in the geth trace.
214218
let geth_step = &block.geth_traces[0].struct_logs[step_index - 1];
215219
assert_eq!(opcode, geth_step.op);
216-
let gas_cost = geth_step.gas_cost;
220+
221+
let dynamic_gas_cost = geth_step.gas_cost;
222+
let gas_cost = opcode.constant_gas_cost();
217223
rows.push(Row {
218224
state,
219225
opcode,
220226
height,
227+
dynamic_gas_cost,
221228
gas_cost,
222229
height_per_gas: (height as f64 / gas_cost as f64).into(),
230+
height_per_dynamic_gas: (height as f64 / dynamic_gas_cost as f64).into(),
223231
});
224232
}
225233
}

Diff for: zkevm-circuits/src/bin/stats/main.rs

+4-11
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,9 @@ fn main() {
3333
fn evm_states_stats() {
3434
print_circuit_stats_by_states(
3535
|state| {
36-
// TODO: Enable CREATE/CREATE2 once they are supported
3736
!matches!(
3837
state,
39-
ExecutionState::ErrorInvalidOpcode
40-
| ExecutionState::CREATE
41-
| ExecutionState::CREATE2
42-
| ExecutionState::SELFDESTRUCT
38+
ExecutionState::ErrorInvalidOpcode | ExecutionState::SELFDESTRUCT
4339
)
4440
},
4541
|opcode| match opcode {
@@ -71,13 +67,9 @@ fn evm_states_stats() {
7167
fn state_states_stats() {
7268
print_circuit_stats_by_states(
7369
|state| {
74-
// TODO: Enable CREATE/CREATE2 once they are supported
7570
!matches!(
7671
state,
77-
ExecutionState::ErrorInvalidOpcode
78-
| ExecutionState::CREATE
79-
| ExecutionState::CREATE2
80-
| ExecutionState::SELFDESTRUCT
72+
ExecutionState::ErrorInvalidOpcode | ExecutionState::SELFDESTRUCT
8173
)
8274
},
8375
bytecode_prefix_op_big_rws,
@@ -93,7 +85,6 @@ fn state_states_stats() {
9385
fn copy_states_stats() {
9486
print_circuit_stats_by_states(
9587
|state| {
96-
// TODO: Enable CREATE/CREATE2 once they are supported
9788
matches!(
9889
state,
9990
ExecutionState::RETURNDATACOPY
@@ -102,6 +93,8 @@ fn copy_states_stats() {
10293
| ExecutionState::CALLDATACOPY
10394
| ExecutionState::EXTCODECOPY
10495
| ExecutionState::RETURN_REVERT
96+
| ExecutionState::CREATE
97+
| ExecutionState::CREATE2
10598
)
10699
},
107100
bytecode_prefix_op_big_rws,

0 commit comments

Comments
 (0)