execution-spec-tests
execution-spec-tests copied to clipboard
Create blockchains that consume full gas on single operations.
Requirement for zkevm testing:
Create a test that exhausts the gas stipend of a full block using a single operation, operation meaning:
- An opcode, namely keccak or maybe other relevant ones.
- A precompile
Potentially also parametrizing whether the tx succeeds or fails (reverts or out-of-gas).
cc'ing @kevaundray to expand or correct the definition of operations
Looking into this. Planning to extend ethereum/execution-spec-tests#1456 by @jsign
EVM opcodes
Arithmetic
- [x]
0x01ADD ethereum/execution-spec-tests#1571 - [x]
0x02MUL ethereum/execution-spec-tests#1571 - [x]
0x03SUB ethereum/execution-spec-tests#1571 - [x]
0x04DIV ethereum/execution-spec-tests#1571 - [x]
0x05SDIV ethereum/execution-spec-tests#1571 - [x]
0x06MOD ethereum/execution-spec-tests#1571 - [x]
0x07SMOD ethereum/execution-spec-tests#1571 - [x]
0x08ADDMOD ethereum/execution-spec-tests#1571 - [x]
0x09MULMOD ethereum/execution-spec-tests#1571 - [x]
0x0AEXP ethereum/execution-spec-tests#1571 - [x]
0x0BSIGNEXTEND ethereum/execution-spec-tests#1571 - [x]
0x10LT ethereum/execution-spec-tests#1571 - [x]
0x11GT ethereum/execution-spec-tests#1571 - [x]
0x12SLT ethereum/execution-spec-tests#1571 - [x]
0x13SGT ethereum/execution-spec-tests#1571 - [x]
0x14EQ ethereum/execution-spec-tests#1571 - [x]
0x15ISZERO ethereum/execution-spec-tests#1571 - [x]
0x16AND ethereum/execution-spec-tests#1571 - [x]
0x17OR ethereum/execution-spec-tests#1571 - [x]
0x18XOR ethereum/execution-spec-tests#1571 - [x]
0x19NOT ethereum/execution-spec-tests#1571 - [x]
0x1ABYTE ethereum/execution-spec-tests#1571 - [x]
0x1BSHL ethereum/execution-spec-tests#1571 - [x]
0x1CSHR ethereum/execution-spec-tests#1571 - [x]
0x1DSAR ethereum/execution-spec-tests#1571
Cryptographic
- [x]
0x20KECCAK256 ethereum/execution-spec-tests#1497
Stateful Opcodes
- [x]
0x31BALANCE ethereum/execution-spec-tests#1583 - [x]
0x3BEXTCODESIZE ethereum/execution-spec-tests#1583 - [x]
0x3CEXTCODECOPY ethereum/execution-spec-tests#1583 - [x]
0x3FEXTCODEHASH ethereum/execution-spec-tests#1583 - [x]
0x40BLOCKHASH ethereum/execution-spec-tests#1583 - [x]
0x47SELFBALANCE ethereum/execution-spec-tests#1583 - [x]
0x54SLOAD ethereum/execution-spec-tests#1583 - [x]
0x55SSTORE ethereum/execution-spec-tests#1583 - [x]
0xF1CALL ethereum/execution-spec-tests#1583 - [x]
0xF2CALLCODE ethereum/execution-spec-tests#1583 - [x]
0xF4DELEGATECALL ethereum/execution-spec-tests#1583 - [x]
0xFASTATICCALL ethereum/execution-spec-tests#1583
Termination
- [x]
0x00STOP (Rationale: Cannot fill a block with STOP opcodes) - [x]
0xFEINVALID (Rationale: Cannot fill a block with INVALID opcodes)
Environment
- [x]
0x30ADDRESS ethereum/execution-spec-tests#1651 - [x]
0x32ORIGIN ethereum/execution-spec-tests#1651 - [x]
0x33CALLER ethereum/execution-spec-tests#1651 - [x]
0x34CALLVALUE ethereum/execution-spec-tests#1651 - [x]
0x35CALLDATALOAD ethereum/execution-spec-tests#1657 - [x]
0x36CALLDATASIZE ethereum/execution-spec-tests#1651 - [x]
0x37CALLDATACOPY ethereum/execution-spec-tests#1690 - [x]
0x38CODESIZE ethereum/execution-spec-tests#1651 - [x]
0x39CODECOPY ethereum/execution-spec-tests#1690 - [x]
0x3AGASPRICE ethereum/execution-spec-tests#1651 - [x]
0x3DRETURNDATASIZE ethereum/execution-spec-tests#1651 - [x]
0x3ERETURNDATACOPY ethereum/execution-spec-tests#1690
Block & Chain Info
- [x]
0x41COINBASE ethereum/execution-spec-tests#1651 - [x]
0x42TIMESTAMP ethereum/execution-spec-tests#1651 - [x]
0x43NUMBER ethereum/execution-spec-tests#1651 - [x]
0x44PREVRANDAO ethereum/execution-spec-tests#1651 - [x]
0x45GASLIMIT ethereum/execution-spec-tests#1651 - [x]
0x46CHAINID ethereum/execution-spec-tests#1651 - [x]
0x48BASEFEE ethereum/execution-spec-tests#1651
Blobs
- [x]
0x49BLOBHASH ethereum/execution-spec-tests#1657 - [x]
0x4ABLOBBASEFEE ethereum/execution-spec-tests#1651
Stack & Memory
- [x]
0x50POP ethereum/execution-spec-tests#1657 - [x]
0x51MLOAD ethereum/execution-spec-tests#1657 - [x]
0x52MSTORE ethereum/execution-spec-tests#1668 - [x]
0x53MSTORE8 ethereum/execution-spec-tests#1668 - [x]
0x59MSIZE ethereum/execution-spec-tests#1651 - [x]
0x5AGAS ethereum/execution-spec-tests#1651 - [x]
0x5CTLOAD ethereum/execution-spec-tests#1657 - [x]
0x5DTSTORE ethereum/execution-spec-tests#1657 - [x]
0x5EMCOPY ethereum/execution-spec-tests#1690 - [x]
0x5FPUSH0 ethereum/execution-spec-tests#1651 - [x]
0x60-0x7FPUSH1-PUSH32 ethereum/execution-spec-tests#1687
Control Flow
- [x]
0x56JUMP ethereum/execution-spec-tests#1616 - [x]
0x57JUMPI ethereum/execution-spec-tests#1690 - [x]
0x58PC ethereum/execution-spec-tests#1651 - [x]
0x5BJUMPDEST ethereum/execution-spec-tests#1616
Stack Duplication
- [x]
0x80-0x8FDUP1-DUP16 (Does this make sense to add?) ethereum/execution-spec-tests#1687
Stack Swapping
- [x]
0x90-0x9FSWAP1-SWAP16 (Does this make sense to add?) ethereum/execution-spec-tests#1687
Logging
- [x]
0xA0LOG0 ethereum/execution-spec-tests#1689 - [x]
0xA1LOG1 ethereum/execution-spec-tests#1689 - [x]
0xA2LOG2 ethereum/execution-spec-tests#1689 - [x]
0xA3LOG3 ethereum/execution-spec-tests#1689 - [x]
0xA4LOG4 ethereum/execution-spec-tests#1689
Contract Lifecycle
- [x]
0xF0CREATE ethereum/execution-spec-tests#1689 - [x]
0xF3RETURN ethereum/execution-spec-tests#1689 - [x]
0xF5CREATE2 ethereum/execution-spec-tests#1689 - [x]
0xFDREVERT ethereum/execution-spec-tests#1689 - [x]
0xFFSELFDESTRUCT ethereum/execution-spec-tests#1657
Precompiled Contracts
- [x]
0x01ECDSA signature recovery ethereum/execution-spec-tests#1524 - [x]
0x02SHA-256 hash function ethereum/execution-spec-tests#1524 - [x]
0x03RIPEMD-160 hash function ethereum/execution-spec-tests#1524 - [x]
0x04Identity function ethereum/execution-spec-tests#1524 - [x]
0x05Modular exponentiation (EIP-198) ethereum/execution-spec-tests#1523 - [x]
0x06Elliptic curve addition alt_bn128 (EIP-196) ethereum/execution-spec-tests#1581 - [x]
0x07Elliptic curve scalar multiplication alt_bn128 (EIP-196) ethereum/execution-spec-tests#1581 - [x]
0x08Elliptic curve pairing check alt_bn128 (EIP-197) ethereum/execution-spec-tests#1581 - [x]
0x09BLAKE2f compression function (EIP-152) ethereum/execution-spec-tests#1581 - [x]
0x0AKZG Point evaluation precompile (EIP-4844) ethereum/execution-spec-tests#1581 - [x] (0x0B–0x11) BLS12-381 Curve Operations Precompile (EIP-2537) ethereum/execution-spec-tests#1581 - [x] (0x0B–0x11)
- [X]
0x100P256VERIFY https://github.com/ethereum/execution-spec-tests/pull/1744
Misc
- [x] Empty block (We want an empty block to have some baseline) ethereum/execution-spec-tests#1650
A suggestion by @barnabasbusa is to also tests how the proving time changes with the number of blobs.
ie
- empty block, 0 blobs
- empty block, 32 blobs
- empty block, 48 blobs
Current hypothesis is that it should not change much given the EL validation logic for blobs is this: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-4844.md#execution-layer-validation
But its something to validate with benchmarks
0x00 STOP (Rationale: Cannot fill a block with STOP opcodes) 0xFE INVALID (Rationale: Cannot fill a block with INVALID opcodes)
I disagree, we can target contracts with *CALL* to target a contract which either STOPs or INVALIDs (forwarding 0 gas). This can be directly included in those tests.
0x00 STOP (Rationale: Cannot fill a block with STOP opcodes) 0xFE INVALID (Rationale: Cannot fill a block with INVALID opcodes)
I disagree, we can target contracts with
*CALL*to target a contract which either STOPs or INVALIDs (forwarding 0 gas). This can be directly included in those tests.
Yeah what I wrote was imprecise -- calling a contract with just STOP opcodes would return immediately after encountering the first STOP opcode, so it should be equivalent to having just one STOP opcode -- do you think this is still worth adding to the benchmarks?
@kevaundray, @jochem-brouwer, we have this STOP case already covered in my warm-CALL-like test. See here.
What I do for warm-CALL-like is exactly that. Call a contract that starts with STOP, since I want as much gas as possible to be used for CALL-like and not other stuff.
Ah ok, if wanted you could also insert a variant of that test which forwards 0 gas to the next call frame and instead of STOP execute INVALID. This should not alter the gas costs at all (since frame has 0 gas costs, so spending all costs in the frame will still spend the same). Since the result of the *CALL* opcode is popped this also does not matter.
However, this would thus test two opcodes in the same test which might not be wanted. (However it would be interesting to see the actual cycle difference here, since the net gas costs and the amount of opcodes executed here is the same -> the only "net difference" is the item pushed to stack after the *CALL*)
@pytest.mark.parametrize(
"opcode",
[
Op.BALANCE,
Op.EXTCODESIZE,
Op.EXTCODEHASH,
Op.CALL,
Op.CALLCODE,
Op.DELEGATECALL,
Op.STATICCALL,
],
)
[email protected](
+ "frame_terminator",
+ [
+ Op.STOP,
+ Op.INVALID,
+ ]
+)
opcode: Op,
+frame_terminator: Op,
-iter_block = Op.POP(opcode(address=Op.MLOAD(0)))
+iter_block = Op.POP(opcode(gas=0,address=Op.MLOAD(0)))
if not absent_target:
- code = Op.STOP + Op.JUMPDEST * 100
+ code = frame_terminator + Op.JUMPDEST * 100
@jochem-brouwer, thanks for the idea :)
~But I think we should probably do gas=0 if frame_terminator=Op.INVALID else Op.GAS, if we don't do that we would be missing actually "executing" the STOP which shouldn't have a problem. For the "free frame" we can consider INVALID covering it.~
I'll take a note to iterate on that existing test so we can say that INVALID is covered.
Should have mentioned that, but STOP costs 0 gas thus will also execute if gas=0.
You're right!
Can the JUMP test be checked? It likely jumps to a non-jumpdest opcode. See: https://github.com/ethereum/execution-spec-tests/pull/1693#discussion_r2123023914
Can the JUMP test be checked? It likely jumps to a non-jumpdest opcode. See: #1693 (comment)
Ah, that one was created by Cody, but let I'll check.
Should we have one test that a block is filled with 7702 setCode transaction?
Update: I create one here: https://github.com/ethereum/execution-spec-tests/pull/1758
New precompile (P256VERIFY) and opcode (CLZ) are introduced in Fusaka.
Benchmark for P256VERIFY is implemented here, and this PR is for CLZ opcode.
However, the existing test case in Osaka would not work due to the transaction gas limit gap in EIP-7825, this is documented in the issue as well.
New precompile (
P256VERIFY) and opcode (CLZ) are introduced in Fusaka.Benchmark for P256VERIFY is implemented here, and this PR is for CLZ opcode.
However, the existing test case in Osaka would not work due to the transaction gas limit gap in EIP-7825, this is documented in the issue as well.
Added both to the list with linked PRs.
The only remaining one now is CLZ, but since this isn't still in mainnet, and is also being tracked in this other issue I think we can remove it from this original issue tracker.
Closing this since all mainnet opcodes and precompiles are covered.
Congrats everybody that was involved in this first big iteration!