Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add copy circuit stats by exec state (scroll-tech#1222)
### Description feat: Add copy circuit stats by exec state like the ones we had for evm circuit and state circuit. refactor: move duplicate code used to get circuit stats by exec state into a new module, which also contains a helper struct to draw formatted tables feat: add the `warn-unimplemented` fature in `zkevm-circuits` so that it can be enabled/disabled when using the zkevm-circuits crate. ### Type of change - [ ] Bug fix (non-breaking change which fixes an issue) - [x] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] This change requires a documentation update ### Contents Here are the stats for the Copy Circuit | state | opcode | h | g | h/g | | -------------- | -------------- | ---- | ----- | ------ | | CALLDATACOPY | CALLDATACOPY | 8192 | 803 | 10.202 | | CODECOPY | CODECOPY | 8192 | 803 | 10.202 | | EXTCODECOPY | EXTCODECOPY | 8192 | 900 | 9.102 | | RETURNDATACOPY | RETURNDATACOPY | 8192 | 803 | 10.202 | | LOG | LOG0 | 8192 | 33559 | 0.244 | | LOG | LOG1 | 8192 | 33934 | 0.241 | | LOG | LOG2 | 8192 | 34309 | 0.239 | | LOG | LOG3 | 8192 | 34684 | 0.236 | | LOG | LOG4 | 8192 | 35059 | 0.234 | | RETURN_REVERT | RETURN | 8192 | 416 | 19.692 | | RETURN_REVERT | REVERT | 8192 | 416 | 19.692 | <details><summary>Updated stats for EVM Circuit</summary> | state | opcode | h | g | h/g | | -------------- | -------------- | -- | ----- | ----- | | STOP | STOP | 2 | 0 | inf | | ADD_SUB | ADD | 5 | 3 | 1.667 | | ADD_SUB | SUB | 5 | 3 | 1.667 | | MUL_DIV_MOD | MUL | 8 | 5 | 1.600 | | MUL_DIV_MOD | DIV | 8 | 5 | 1.600 | | MUL_DIV_MOD | MOD | 8 | 5 | 1.600 | | SDIV_SMOD | SDIV | 19 | 5 | 3.800 | | SDIV_SMOD | SMOD | 19 | 5 | 3.800 | | SHL_SHR | SHL | 10 | 3 | 3.333 | | SHL_SHR | SHR | 10 | 3 | 3.333 | | ADDMOD | ADDMOD | 17 | 8 | 2.125 | | MULMOD | MULMOD | 20 | 8 | 2.500 | | EXP | EXP | 7 | 60 | 0.117 | | SIGNEXTEND | SIGNEXTEND | 3 | 5 | 0.600 | | CMP | LT | 5 | 3 | 1.667 | | CMP | GT | 5 | 3 | 1.667 | | CMP | EQ | 5 | 3 | 1.667 | | SCMP | SLT | 5 | 3 | 1.667 | | SCMP | SGT | 5 | 3 | 1.667 | | ISZERO | ISZERO | 2 | 3 | 0.667 | | BITWISE | AND | 5 | 3 | 1.667 | | BITWISE | OR | 5 | 3 | 1.667 | | BITWISE | XOR | 5 | 3 | 1.667 | | NOT | NOT | 5 | 3 | 1.667 | | BYTE | BYTE | 3 | 3 | 1.000 | | SAR | SAR | 10 | 3 | 3.333 | | SHA3 | SHA3 | 4 | 57 | 0.070 | | ADDRESS | ADDRESS | 2 | 2 | 1.000 | | BALANCE | BALANCE | 2 | 2600 | 0.001 | | ORIGIN | ORIGIN | 2 | 2 | 1.000 | | CALLER | CALLER | 2 | 2 | 1.000 | | CALLVALUE | CALLVALUE | 1 | 2 | 0.500 | | CALLDATALOAD | CALLDATALOAD | 8 | 3 | 2.667 | | CALLDATASIZE | CALLDATASIZE | 1 | 2 | 0.500 | | CALLDATACOPY | CALLDATACOPY | 3 | 21 | 0.143 | | CODESIZE | CODESIZE | 1 | 2 | 0.500 | | CODECOPY | CODECOPY | 3 | 21 | 0.143 | | GASPRICE | GASPRICE | 1 | 2 | 0.500 | | EXTCODESIZE | EXTCODESIZE | 2 | 2600 | 0.001 | | EXTCODECOPY | EXTCODECOPY | 4 | 2612 | 0.002 | | RETURNDATASIZE | RETURNDATASIZE | 1 | 2 | 0.500 | | RETURNDATACOPY | RETURNDATACOPY | 3 | 9 | 0.333 | | EXTCODEHASH | EXTCODEHASH | 2 | 2600 | 0.001 | | BLOCKHASH | BLOCKHASH | 3 | 20 | 0.150 | | BLOCKCTXU64 | TIMESTAMP | 1 | 2 | 0.500 | | BLOCKCTXU64 | NUMBER | 1 | 2 | 0.500 | | BLOCKCTXU64 | GASLIMIT | 1 | 2 | 0.500 | | BLOCKCTXU160 | COINBASE | 2 | 2 | 1.000 | | BLOCKCTXU256 | DIFFICULTY | 2 | 2 | 1.000 | | BLOCKCTXU256 | BASEFEE | 2 | 2 | 1.000 | | CHAINID | CHAINID | 1 | 2 | 0.500 | | SELFBALANCE | SELFBALANCE | 1 | 5 | 0.200 | | POP | POP | 1 | 2 | 0.500 | | MEMORY | MLOAD | 5 | 15 | 0.333 | | MEMORY | MSTORE | 5 | 15 | 0.333 | | MEMORY | MSTORE8 | 5 | 12 | 0.417 | | SLOAD | SLOAD | 2 | 2100 | 0.001 | | SSTORE | SSTORE | 12 | 22100 | 0.001 | | JUMP | JUMP | 1 | 8 | 0.125 | | JUMPI | JUMPI | 3 | 10 | 0.300 | | PC | PC | 1 | 2 | 0.500 | | MSIZE | MSIZE | 1 | 2 | 0.500 | | GAS | GAS | 1 | 2 | 0.500 | | JUMPDEST | JUMPDEST | 1 | 1 | 1.000 | | PUSH | PUSH1 | 9 | 3 | 3.000 | | PUSH | PUSH2 | 9 | 3 | 3.000 | | PUSH | PUSH3 | 9 | 3 | 3.000 | | PUSH | PUSH4 | 9 | 3 | 3.000 | | PUSH | PUSH5 | 9 | 3 | 3.000 | | PUSH | PUSH6 | 9 | 3 | 3.000 | | PUSH | PUSH7 | 9 | 3 | 3.000 | | PUSH | PUSH8 | 9 | 3 | 3.000 | | PUSH | PUSH9 | 9 | 3 | 3.000 | | PUSH | PUSH10 | 9 | 3 | 3.000 | | PUSH | PUSH11 | 9 | 3 | 3.000 | | PUSH | PUSH12 | 9 | 3 | 3.000 | | PUSH | PUSH13 | 9 | 3 | 3.000 | | PUSH | PUSH14 | 9 | 3 | 3.000 | | PUSH | PUSH15 | 9 | 3 | 3.000 | | PUSH | PUSH16 | 9 | 3 | 3.000 | | PUSH | PUSH17 | 9 | 3 | 3.000 | | PUSH | PUSH18 | 9 | 3 | 3.000 | | PUSH | PUSH19 | 9 | 3 | 3.000 | | PUSH | PUSH20 | 9 | 3 | 3.000 | | PUSH | PUSH21 | 9 | 3 | 3.000 | | PUSH | PUSH22 | 9 | 3 | 3.000 | | PUSH | PUSH23 | 9 | 3 | 3.000 | | PUSH | PUSH24 | 9 | 3 | 3.000 | | PUSH | PUSH25 | 9 | 3 | 3.000 | | PUSH | PUSH26 | 9 | 3 | 3.000 | | PUSH | PUSH27 | 9 | 3 | 3.000 | | PUSH | PUSH28 | 9 | 3 | 3.000 | | PUSH | PUSH29 | 9 | 3 | 3.000 | | PUSH | PUSH30 | 9 | 3 | 3.000 | | PUSH | PUSH31 | 9 | 3 | 3.000 | | PUSH | PUSH32 | 9 | 3 | 3.000 | | DUP | DUP1 | 1 | 3 | 0.333 | | DUP | DUP2 | 1 | 3 | 0.333 | | DUP | DUP3 | 1 | 3 | 0.333 | | DUP | DUP4 | 1 | 3 | 0.333 | | DUP | DUP5 | 1 | 3 | 0.333 | | DUP | DUP6 | 1 | 3 | 0.333 | | DUP | DUP7 | 1 | 3 | 0.333 | | DUP | DUP8 | 1 | 3 | 0.333 | | DUP | DUP9 | 1 | 3 | 0.333 | | DUP | DUP10 | 1 | 3 | 0.333 | | DUP | DUP11 | 1 | 3 | 0.333 | | DUP | DUP12 | 1 | 3 | 0.333 | | DUP | DUP13 | 1 | 3 | 0.333 | | DUP | DUP14 | 1 | 3 | 0.333 | | DUP | DUP15 | 1 | 3 | 0.333 | | DUP | DUP16 | 1 | 3 | 0.333 | | SWAP | SWAP1 | 1 | 3 | 0.333 | | SWAP | SWAP2 | 1 | 3 | 0.333 | | SWAP | SWAP3 | 1 | 3 | 0.333 | | SWAP | SWAP4 | 1 | 3 | 0.333 | | SWAP | SWAP5 | 1 | 3 | 0.333 | | SWAP | SWAP6 | 1 | 3 | 0.333 | | SWAP | SWAP7 | 1 | 3 | 0.333 | | SWAP | SWAP8 | 1 | 3 | 0.333 | | SWAP | SWAP9 | 1 | 3 | 0.333 | | SWAP | SWAP10 | 1 | 3 | 0.333 | | SWAP | SWAP11 | 1 | 3 | 0.333 | | SWAP | SWAP12 | 1 | 3 | 0.333 | | SWAP | SWAP13 | 1 | 3 | 0.333 | | SWAP | SWAP14 | 1 | 3 | 0.333 | | SWAP | SWAP15 | 1 | 3 | 0.333 | | SWAP | SWAP16 | 1 | 3 | 0.333 | | LOG | LOG0 | 2 | 902 | 0.002 | | LOG | LOG1 | 2 | 1277 | 0.002 | | LOG | LOG2 | 2 | 1652 | 0.001 | | LOG | LOG3 | 2 | 2027 | 0.001 | | LOG | LOG4 | 2 | 2402 | 0.001 | | CALL_OP | CALL | 21 | 36686 | 0.001 | | CALL_OP | CALLCODE | 21 | 11686 | 0.002 | | CALL_OP | DELEGATECALL | 21 | 2689 | 0.008 | | CALL_OP | STATICCALL | 21 | 2689 | 0.008 | | RETURN_REVERT | RETURN | 3 | 15 | 0.200 | | RETURN_REVERT | REVERT | 3 | 15 | 0.200 | </details> <details><summary>Updated stats for State Circuit</summary> | state | opcode | h | g | h/g | | -------------- | -------------- | ---- | ----- | ------ | | STOP | STOP | 13 | 0 | inf | | ADD_SUB | ADD | 3 | 3 | 1.000 | | ADD_SUB | SUB | 3 | 3 | 1.000 | | MUL_DIV_MOD | MUL | 3 | 5 | 0.600 | | MUL_DIV_MOD | DIV | 3 | 5 | 0.600 | | MUL_DIV_MOD | MOD | 3 | 5 | 0.600 | | SDIV_SMOD | SDIV | 3 | 5 | 0.600 | | SDIV_SMOD | SMOD | 3 | 5 | 0.600 | | SHL_SHR | SHL | 3 | 3 | 1.000 | | SHL_SHR | SHR | 3 | 3 | 1.000 | | ADDMOD | ADDMOD | 4 | 8 | 0.500 | | MULMOD | MULMOD | 4 | 8 | 0.500 | | EXP | EXP | 3 | 60 | 0.050 | | SIGNEXTEND | SIGNEXTEND | 3 | 5 | 0.600 | | CMP | LT | 3 | 3 | 1.000 | | CMP | GT | 3 | 3 | 1.000 | | CMP | EQ | 3 | 3 | 1.000 | | SCMP | SLT | 3 | 3 | 1.000 | | SCMP | SGT | 3 | 3 | 1.000 | | ISZERO | ISZERO | 2 | 3 | 0.667 | | BITWISE | AND | 3 | 3 | 1.000 | | BITWISE | OR | 3 | 3 | 1.000 | | BITWISE | XOR | 3 | 3 | 1.000 | | NOT | NOT | 2 | 3 | 0.667 | | BYTE | BYTE | 3 | 3 | 1.000 | | SAR | SAR | 3 | 3 | 1.000 | | SHA3 | SHA3 | 4099 | 1214 | 3.376 | | ADDRESS | ADDRESS | 2 | 2 | 1.000 | | BALANCE | BALANCE | 7 | 2600 | 0.003 | | ORIGIN | ORIGIN | 2 | 2 | 1.000 | | CALLER | CALLER | 2 | 2 | 1.000 | | CALLVALUE | CALLVALUE | 2 | 2 | 1.000 | | CALLDATALOAD | CALLDATALOAD | 5 | 3 | 1.667 | | CALLDATASIZE | CALLDATASIZE | 2 | 2 | 1.000 | | CALLDATACOPY | CALLDATACOPY | 4102 | 803 | 5.108 | | CODESIZE | CODESIZE | 1 | 2 | 0.500 | | CODECOPY | CODECOPY | 4099 | 803 | 5.105 | | GASPRICE | GASPRICE | 2 | 2 | 1.000 | | EXTCODESIZE | EXTCODESIZE | 7 | 2600 | 0.003 | | EXTCODECOPY | EXTCODECOPY | 4105 | 900 | 4.561 | | RETURNDATASIZE | RETURNDATASIZE | 2 | 2 | 1.000 | | RETURNDATACOPY | RETURNDATACOPY | 8198 | 803 | 10.209 | | EXTCODEHASH | EXTCODEHASH | 7 | 2600 | 0.003 | | BLOCKHASH | BLOCKHASH | 2 | 20 | 0.100 | | BLOCKCTXU64 | TIMESTAMP | 1 | 2 | 0.500 | | BLOCKCTXU64 | NUMBER | 1 | 2 | 0.500 | | BLOCKCTXU64 | GASLIMIT | 1 | 2 | 0.500 | | BLOCKCTXU160 | COINBASE | 1 | 2 | 0.500 | | BLOCKCTXU256 | DIFFICULTY | 1 | 2 | 0.500 | | BLOCKCTXU256 | BASEFEE | 1 | 2 | 0.500 | | CHAINID | CHAINID | 1 | 2 | 0.500 | | SELFBALANCE | SELFBALANCE | 3 | 5 | 0.600 | | POP | POP | 1 | 2 | 0.500 | | MEMORY | MLOAD | 34 | 15 | 2.267 | | MEMORY | MSTORE | 34 | 15 | 2.267 | | MEMORY | MSTORE8 | 3 | 12 | 0.250 | | SLOAD | SLOAD | 8 | 2100 | 0.004 | | SSTORE | SSTORE | 10 | 22100 | 0.000 | | JUMP | JUMP | 16 | 8 | 2.000 | | JUMPI | JUMPI | 17 | 10 | 1.700 | | PC | PC | 1 | 2 | 0.500 | | MSIZE | MSIZE | 1 | 2 | 0.500 | | GAS | GAS | 1 | 2 | 0.500 | | JUMPDEST | JUMPDEST | 0 | 1 | 0.000 | | PUSH | PUSH1 | 1 | 3 | 0.333 | | PUSH | PUSH2 | 1 | 3 | 0.333 | | PUSH | PUSH3 | 1 | 3 | 0.333 | | PUSH | PUSH4 | 1 | 3 | 0.333 | | PUSH | PUSH5 | 1 | 3 | 0.333 | | PUSH | PUSH6 | 1 | 3 | 0.333 | | PUSH | PUSH7 | 1 | 3 | 0.333 | | PUSH | PUSH8 | 1 | 3 | 0.333 | | PUSH | PUSH9 | 1 | 3 | 0.333 | | PUSH | PUSH10 | 1 | 3 | 0.333 | | PUSH | PUSH11 | 1 | 3 | 0.333 | | PUSH | PUSH12 | 1 | 3 | 0.333 | | PUSH | PUSH13 | 1 | 3 | 0.333 | | PUSH | PUSH14 | 1 | 3 | 0.333 | | PUSH | PUSH15 | 1 | 3 | 0.333 | | PUSH | PUSH16 | 1 | 3 | 0.333 | | PUSH | PUSH17 | 1 | 3 | 0.333 | | PUSH | PUSH18 | 1 | 3 | 0.333 | | PUSH | PUSH19 | 1 | 3 | 0.333 | | PUSH | PUSH20 | 1 | 3 | 0.333 | | PUSH | PUSH21 | 1 | 3 | 0.333 | | PUSH | PUSH22 | 1 | 3 | 0.333 | | PUSH | PUSH23 | 1 | 3 | 0.333 | | PUSH | PUSH24 | 1 | 3 | 0.333 | | PUSH | PUSH25 | 1 | 3 | 0.333 | | PUSH | PUSH26 | 1 | 3 | 0.333 | | PUSH | PUSH27 | 1 | 3 | 0.333 | | PUSH | PUSH28 | 1 | 3 | 0.333 | | PUSH | PUSH29 | 1 | 3 | 0.333 | | PUSH | PUSH30 | 1 | 3 | 0.333 | | PUSH | PUSH31 | 1 | 3 | 0.333 | | PUSH | PUSH32 | 1 | 3 | 0.333 | | DUP | DUP1 | 2 | 3 | 0.667 | | DUP | DUP2 | 2 | 3 | 0.667 | | DUP | DUP3 | 2 | 3 | 0.667 | | DUP | DUP4 | 2 | 3 | 0.667 | | DUP | DUP5 | 2 | 3 | 0.667 | | DUP | DUP6 | 2 | 3 | 0.667 | | DUP | DUP7 | 2 | 3 | 0.667 | | DUP | DUP8 | 2 | 3 | 0.667 | | DUP | DUP9 | 2 | 3 | 0.667 | | DUP | DUP10 | 2 | 3 | 0.667 | | DUP | DUP11 | 2 | 3 | 0.667 | | DUP | DUP12 | 2 | 3 | 0.667 | | DUP | DUP13 | 2 | 3 | 0.667 | | DUP | DUP14 | 2 | 3 | 0.667 | | DUP | DUP15 | 2 | 3 | 0.667 | | DUP | DUP16 | 2 | 3 | 0.667 | | SWAP | SWAP1 | 4 | 3 | 1.333 | | SWAP | SWAP2 | 4 | 3 | 1.333 | | SWAP | SWAP3 | 4 | 3 | 1.333 | | SWAP | SWAP4 | 4 | 3 | 1.333 | | SWAP | SWAP5 | 4 | 3 | 1.333 | | SWAP | SWAP6 | 4 | 3 | 1.333 | | SWAP | SWAP7 | 4 | 3 | 1.333 | | SWAP | SWAP8 | 4 | 3 | 1.333 | | SWAP | SWAP9 | 4 | 3 | 1.333 | | SWAP | SWAP10 | 4 | 3 | 1.333 | | SWAP | SWAP11 | 4 | 3 | 1.333 | | SWAP | SWAP12 | 4 | 3 | 1.333 | | SWAP | SWAP13 | 4 | 3 | 1.333 | | SWAP | SWAP14 | 4 | 3 | 1.333 | | SWAP | SWAP15 | 4 | 3 | 1.333 | | SWAP | SWAP16 | 4 | 3 | 1.333 | | LOG | LOG0 | 8199 | 33559 | 0.244 | | LOG | LOG1 | 8201 | 33934 | 0.242 | | LOG | LOG2 | 8203 | 34309 | 0.239 | | LOG | LOG3 | 8205 | 34684 | 0.237 | | LOG | LOG4 | 8207 | 35059 | 0.234 | | CALL_OP | CALL | 24 | 36686 | 0.001 | | CALL_OP | CALLCODE | 22 | 11686 | 0.002 | | CALL_OP | DELEGATECALL | 23 | 2689 | 0.009 | | CALL_OP | STATICCALL | 21 | 2689 | 0.008 | | RETURN_REVERT | RETURN | 8212 | 416 | 19.740 | | RETURN_REVERT | REVERT | 8213 | 416 | 19.743 | </details>
- Loading branch information