From 936cecc3ad316d6d1e016cb67ca899ce11df709f Mon Sep 17 00:00:00 2001 From: "MouseLess.eth" Date: Tue, 15 Nov 2022 21:36:52 +0200 Subject: [PATCH] Add `op` field to `VMOperation` to determine executed opcode (#1858) * created opcode enum and added to VMOperation. Fixes #1857 * rebuild trace logs to include missing fields * opcode descriptions for docs + changelog * restore traces and indent trace * opcode 0x20 should be SHA3 --- CHANGELOG.md | 1 + .../src/types/trace/example-trace-str.rs | 2334 +++++++++-------- ethers-core/src/types/trace/mod.rs | 6 + ethers-core/src/types/trace/opcodes.rs | 343 +++ 4 files changed, 1593 insertions(+), 1091 deletions(-) create mode 100644 ethers-core/src/types/trace/opcodes.rs diff --git a/CHANGELOG.md b/CHANGELOG.md index f7f4547a..e1075075 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ ### Unreleased +- Add 'ethers_core::types::OpCode' and use in 'ethers_core::types::VMOperation' [1857](https://github.com/gakonst/ethers-rs/issues/1857) - Remove rust_decimals dependency for ethers-core - Add support for numbers greater than 2^96 for `ethers_core::utils::parse_units` [#1822](https://github.com/gakonst/ethers-rs/issues/1822) - Add comment about safety of u8 -> u64 cast in `ethers_core::types::Signature` diff --git a/ethers-core/src/types/trace/example-trace-str.rs b/ethers-core/src/types/trace/example-trace-str.rs index ab76f69d..f9520c28 100644 --- a/ethers-core/src/types/trace/example-trace-str.rs +++ b/ethers-core/src/types/trace/example-trace-str.rs @@ -1,1097 +1,1249 @@ r#"{ - "output": "0x", - "stateDiff": { - "0x01f0eb5c4b0a9d8285b67195f5f10ce22971a102": { - "balance": { - "*": { - "from": "0x7361af5818297800", - "to": "0x734a36bb22448000" + "output": "0x", + "stateDiff": { + "0x01f0eb5c4b0a9d8285b67195f5f10ce22971a102": { + "balance": { + "*": { + "from": "0x7361af5818297800", + "to": "0x734a36bb22448000" + } + }, + "code": "=", + "nonce": { + "*": { + "from": "0x1d6", + "to": "0x1d7" + } + }, + "storage": {} + }, + "0xb2930b35844a230f00e51431acae96fe543a0347": { + "balance": { + "*": { + "from": "0x11b39d46046d14d44e5", + "to": "0x11b39d687ebea8b3ce5" + } + }, + "code": "=", + "nonce": "=", + "storage": {} + }, + "0xc227a75b32ed37d3f9d6341b9904d003dad3b1b3": { + "balance": { + "*": { + "from": "0x109397d7f6f000", + "to": "0x25e48fb49df000" + } + }, + "code": "=", + "nonce": "=", + "storage": {} } - }, - "code": "=", - "nonce": { - "*": { - "from": "0x1d6", - "to": "0x1d7" - } - }, - "storage": {} }, - "0xb2930b35844a230f00e51431acae96fe543a0347": { - "balance": { - "*": { - "from": "0x11b39d46046d14d44e5", - "to": "0x11b39d687ebea8b3ce5" + "trace": [ + { + "action": { + "from": "0x01f0eb5c4b0a9d8285b67195f5f10ce22971a102", + "callType": "call", + "gas": "0xa5f8", + "input": "0x1a695230000000000000000000000000c227a75b32ed37d3f9d6341b9904d003dad3b1b3", + "to": "0x0b95993a39a363d99280ac950f5e4536ab5c5566", + "value": "0x1550f7dca70000" + }, + "result": { + "gasUsed": "0x1ddf", + "output": "0x" + }, + "subtraces": 1, + "traceAddress": [], + "type": "call" + }, + { + "action": { + "from": "0x0b95993a39a363d99280ac950f5e4536ab5c5566", + "callType": "call", + "gas": "0x8fc", + "input": "0x", + "to": "0xc227a75b32ed37d3f9d6341b9904d003dad3b1b3", + "value": "0x1550f7dca70000" + }, + "result": { + "gasUsed": "0x0", + "output": "0x" + }, + "subtraces": 0, + "traceAddress": [ + 0 + ], + "type": "call" } - }, - "code": "=", - "nonce": "=", - "storage": {} - }, - "0xc227a75b32ed37d3f9d6341b9904d003dad3b1b3": { - "balance": { - "*": { - "from": "0x109397d7f6f000", - "to": "0x25e48fb49df000" - } - }, - "code": "=", - "nonce": "=", - "storage": {} + ], + "vmTrace": { + "code": "0x60606040523615610055576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680631a6952301461005e5780637362377b1461008c5780638da5cb5b146100a1575b61005c5b5b565b005b61008a600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919050506100f6565b005b341561009757600080fd5b61009f61013a565b005b34156100ac57600080fd5b6100b4610210565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b8073ffffffffffffffffffffffffffffffffffffffff166108fc349081150290604051600060405180830381858888f19350505050151561013657600080fd5b5b50565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561019557600080fd5b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc3073ffffffffffffffffffffffffffffffffffffffff16319081150290604051600060405180830381858888f19350505050151561020d57600080fd5b5b565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff16815600a165627a7a7230582029eabe8a624d811f3ea09c310d65be79ddefa23e3b702541dc1687b475f091690029", + "ops": [ + { + "cost": 3, + "ex": { + "mem": null, + "push": [ + "0x60" + ], + "store": null, + "used": 42485 + }, + "pc": 0, + "sub": null, + "op": "PUSH1", + "idx": "15-0" + }, + { + "cost": 3, + "ex": { + "mem": null, + "push": [ + "0x40" + ], + "store": null, + "used": 42482 + }, + "pc": 2, + "sub": null, + "op": "PUSH1", + "idx": "15-1" + }, + { + "cost": 12, + "ex": { + "mem": { + "data": "0x0000000000000000000000000000000000000000000000000000000000000060", + "off": 64 + }, + "push": [], + "store": null, + "used": 42470 + }, + "pc": 4, + "sub": null, + "op": "MSTORE", + "idx": "15-2" + }, + { + "cost": 2, + "ex": { + "mem": null, + "push": [ + "0x24" + ], + "store": null, + "used": 42468 + }, + "pc": 5, + "sub": null, + "op": "CALLDATASIZE", + "idx": "15-3" + }, + { + "cost": 3, + "ex": { + "mem": null, + "push": [ + "0x0" + ], + "store": null, + "used": 42465 + }, + "pc": 6, + "sub": null, + "op": "ISZERO", + "idx": "15-4" + }, + { + "cost": 3, + "ex": { + "mem": null, + "push": [ + "0x55" + ], + "store": null, + "used": 42462 + }, + "pc": 7, + "sub": null, + "op": "PUSH2", + "idx": "15-5" + }, + { + "cost": 10, + "ex": { + "mem": null, + "push": [], + "store": null, + "used": 42452 + }, + "pc": 10, + "sub": null, + "op": "JUMPI", + "idx": "15-6" + }, + { + "cost": 3, + "ex": { + "mem": null, + "push": [ + "0x0" + ], + "store": null, + "used": 42449 + }, + "pc": 11, + "sub": null, + "op": "PUSH1", + "idx": "15-7" + }, + { + "cost": 3, + "ex": { + "mem": null, + "push": [ + "0x1a695230000000000000000000000000c227a75b32ed37d3f9d6341b9904d003" + ], + "store": null, + "used": 42446 + }, + "pc": 13, + "sub": null, + "op": "CALLDATALOAD", + "idx": "15-8" + }, + { + "cost": 3, + "ex": { + "mem": null, + "push": [ + "0x100000000000000000000000000000000000000000000000000000000" + ], + "store": null, + "used": 42443 + }, + "pc": 14, + "sub": null, + "op": "PUSH29", + "idx": "15-9" + }, + { + "cost": 3, + "ex": { + "mem": null, + "push": [ + "0x100000000000000000000000000000000000000000000000000000000", + "0x1a695230000000000000000000000000c227a75b32ed37d3f9d6341b9904d003" + ], + "store": null, + "used": 42440 + }, + "pc": 44, + "sub": null, + "op": "SWAP1", + "idx": "15-10" + }, + { + "cost": 5, + "ex": { + "mem": null, + "push": [ + "0x1a695230" + ], + "store": null, + "used": 42435 + }, + "pc": 45, + "sub": null, + "op": "DIV", + "idx": "15-11" + }, + { + "cost": 3, + "ex": { + "mem": null, + "push": [ + "0xffffffff" + ], + "store": null, + "used": 42432 + }, + "pc": 46, + "sub": null, + "op": "PUSH4", + "idx": "15-12" + }, + { + "cost": 3, + "ex": { + "mem": null, + "push": [ + "0x1a695230" + ], + "store": null, + "used": 42429 + }, + "pc": 51, + "sub": null, + "op": "AND", + "idx": "15-13" + }, + { + "cost": 3, + "ex": { + "mem": null, + "push": [ + "0x1a695230", + "0x1a695230" + ], + "store": null, + "used": 42426 + }, + "pc": 52, + "sub": null, + "op": "DUP1", + "idx": "15-14" + }, + { + "cost": 3, + "ex": { + "mem": null, + "push": [ + "0x1a695230" + ], + "store": null, + "used": 42423 + }, + "pc": 53, + "sub": null, + "op": "PUSH4", + "idx": "15-15" + }, + { + "cost": 3, + "ex": { + "mem": null, + "push": [ + "0x1" + ], + "store": null, + "used": 42420 + }, + "pc": 58, + "sub": null, + "op": "EQ", + "idx": "15-16" + }, + { + "cost": 3, + "ex": { + "mem": null, + "push": [ + "0x5e" + ], + "store": null, + "used": 42417 + }, + "pc": 59, + "sub": null, + "op": "PUSH2", + "idx": "15-17" + }, + { + "cost": 10, + "ex": { + "mem": null, + "push": [], + "store": null, + "used": 42407 + }, + "pc": 62, + "sub": null, + "op": "JUMPI", + "idx": "15-18" + }, + { + "cost": 1, + "ex": { + "mem": null, + "push": [], + "store": null, + "used": 42406 + }, + "pc": 94, + "sub": null, + "op": "JUMPDEST", + "idx": "15-19" + }, + { + "cost": 3, + "ex": { + "mem": null, + "push": [ + "0x8a" + ], + "store": null, + "used": 42403 + }, + "pc": 95, + "sub": null, + "op": "PUSH2", + "idx": "15-20" + }, + { + "cost": 3, + "ex": { + "mem": null, + "push": [ + "0x4" + ], + "store": null, + "used": 42400 + }, + "pc": 98, + "sub": null, + "op": "PUSH1", + "idx": "15-21" + }, + { + "cost": 3, + "ex": { + "mem": null, + "push": [ + "0x4", + "0x4" + ], + "store": null, + "used": 42397 + }, + "pc": 100, + "sub": null, + "op": "DUP1", + "idx": "15-22" + }, + { + "cost": 3, + "ex": { + "mem": null, + "push": [ + "0x4", + "0x4" + ], + "store": null, + "used": 42394 + }, + "pc": 101, + "sub": null, + "op": "DUP1", + "idx": "15-23" + }, + { + "cost": 3, + "ex": { + "mem": null, + "push": [ + "0xc227a75b32ed37d3f9d6341b9904d003dad3b1b3" + ], + "store": null, + "used": 42391 + }, + "pc": 102, + "sub": null, + "op": "CALLDATALOAD", + "idx": "15-24" + }, + { + "cost": 3, + "ex": { + "mem": null, + "push": [ + "0xffffffffffffffffffffffffffffffffffffffff" + ], + "store": null, + "used": 42388 + }, + "pc": 103, + "sub": null, + "op": "PUSH20", + "idx": "15-25" + }, + { + "cost": 3, + "ex": { + "mem": null, + "push": [ + "0xc227a75b32ed37d3f9d6341b9904d003dad3b1b3" + ], + "store": null, + "used": 42385 + }, + "pc": 124, + "sub": null, + "op": "AND", + "idx": "15-26" + }, + { + "cost": 3, + "ex": { + "mem": null, + "push": [ + "0xc227a75b32ed37d3f9d6341b9904d003dad3b1b3", + "0x4" + ], + "store": null, + "used": 42382 + }, + "pc": 125, + "sub": null, + "op": "SWAP1", + "idx": "15-27" + }, + { + "cost": 3, + "ex": { + "mem": null, + "push": [ + "0x20" + ], + "store": null, + "used": 42379 + }, + "pc": 126, + "sub": null, + "op": "PUSH1", + "idx": "15-28" + }, + { + "cost": 3, + "ex": { + "mem": null, + "push": [ + "0x24" + ], + "store": null, + "used": 42376 + }, + "pc": 128, + "sub": null, + "op": "ADD", + "idx": "15-29" + }, + { + "cost": 3, + "ex": { + "mem": null, + "push": [ + "0x24", + "0xc227a75b32ed37d3f9d6341b9904d003dad3b1b3" + ], + "store": null, + "used": 42373 + }, + "pc": 129, + "sub": null, + "op": "SWAP1", + "idx": "15-30" + }, + { + "cost": 3, + "ex": { + "mem": null, + "push": [ + "0xc227a75b32ed37d3f9d6341b9904d003dad3b1b3", + "0x24", + "0x4" + ], + "store": null, + "used": 42370 + }, + "pc": 130, + "sub": null, + "op": "SWAP2", + "idx": "15-31" + }, + { + "cost": 3, + "ex": { + "mem": null, + "push": [ + "0x4", + "0x24" + ], + "store": null, + "used": 42367 + }, + "pc": 131, + "sub": null, + "op": "SWAP1", + "idx": "15-32" + }, + { + "cost": 2, + "ex": { + "mem": null, + "push": [], + "store": null, + "used": 42365 + }, + "pc": 132, + "sub": null, + "op": "POP", + "idx": "15-33" + }, + { + "cost": 2, + "ex": { + "mem": null, + "push": [], + "store": null, + "used": 42363 + }, + "pc": 133, + "sub": null, + "op": "POP", + "idx": "15-34" + }, + { + "cost": 3, + "ex": { + "mem": null, + "push": [ + "0xf6" + ], + "store": null, + "used": 42360 + }, + "pc": 134, + "sub": null, + "op": "PUSH2", + "idx": "15-35" + }, + { + "cost": 8, + "ex": { + "mem": null, + "push": [], + "store": null, + "used": 42352 + }, + "pc": 137, + "sub": null, + "op": "JUMP", + "idx": "15-36" + }, + { + "cost": 1, + "ex": { + "mem": null, + "push": [], + "store": null, + "used": 42351 + }, + "pc": 246, + "sub": null, + "op": "JUMPDEST", + "idx": "15-37" + }, + { + "cost": 3, + "ex": { + "mem": null, + "push": [ + "0xc227a75b32ed37d3f9d6341b9904d003dad3b1b3", + "0xc227a75b32ed37d3f9d6341b9904d003dad3b1b3" + ], + "store": null, + "used": 42348 + }, + "pc": 247, + "sub": null, + "op": "DUP1", + "idx": "15-38" + }, + { + "cost": 3, + "ex": { + "mem": null, + "push": [ + "0xffffffffffffffffffffffffffffffffffffffff" + ], + "store": null, + "used": 42345 + }, + "pc": 248, + "sub": null, + "op": "PUSH20", + "idx": "15-39" + }, + { + "cost": 3, + "ex": { + "mem": null, + "push": [ + "0xc227a75b32ed37d3f9d6341b9904d003dad3b1b3" + ], + "store": null, + "used": 42342 + }, + "pc": 269, + "sub": null, + "op": "AND", + "idx": "15-40" + }, + { + "cost": 3, + "ex": { + "mem": null, + "push": [ + "0x8fc" + ], + "store": null, + "used": 42339 + }, + "pc": 270, + "sub": null, + "op": "PUSH2", + "idx": "15-41" + }, + { + "cost": 2, + "ex": { + "mem": null, + "push": [ + "0x1550f7dca70000" + ], + "store": null, + "used": 42337 + }, + "pc": 273, + "sub": null, + "op": "CALLVALUE", + "idx": "15-42" + }, + { + "cost": 3, + "ex": { + "mem": null, + "push": [ + "0x1550f7dca70000", + "0x8fc" + ], + "store": null, + "used": 42334 + }, + "pc": 274, + "sub": null, + "op": "SWAP1", + "idx": "15-43" + }, + { + "cost": 3, + "ex": { + "mem": null, + "push": [ + "0x1550f7dca70000", + "0x8fc", + "0x1550f7dca70000" + ], + "store": null, + "used": 42331 + }, + "pc": 275, + "sub": null, + "op": "DUP2", + "idx": "15-44" + }, + { + "cost": 3, + "ex": { + "mem": null, + "push": [ + "0x0" + ], + "store": null, + "used": 42328 + }, + "pc": 276, + "sub": null, + "op": "ISZERO", + "idx": "15-45" + }, + { + "cost": 5, + "ex": { + "mem": null, + "push": [ + "0x0" + ], + "store": null, + "used": 42323 + }, + "pc": 277, + "sub": null, + "op": "MUL", + "idx": "15-46" + }, + { + "cost": 3, + "ex": { + "mem": null, + "push": [ + "0x0", + "0x1550f7dca70000" + ], + "store": null, + "used": 42320 + }, + "pc": 278, + "sub": null, + "op": "SWAP1", + "idx": "15-47" + }, + { + "cost": 3, + "ex": { + "mem": null, + "push": [ + "0x40" + ], + "store": null, + "used": 42317 + }, + "pc": 279, + "sub": null, + "op": "PUSH1", + "idx": "15-48" + }, + { + "cost": 3, + "ex": { + "mem": { + "data": "0x0000000000000000000000000000000000000000000000000000000000000060", + "off": 64 + }, + "push": [ + "0x60" + ], + "store": null, + "used": 42314 + }, + "pc": 281, + "sub": null, + "op": "MLOAD", + "idx": "15-49" + }, + { + "cost": 3, + "ex": { + "mem": null, + "push": [ + "0x0" + ], + "store": null, + "used": 42311 + }, + "pc": 282, + "sub": null, + "op": "PUSH1", + "idx": "15-50" + }, + { + "cost": 3, + "ex": { + "mem": null, + "push": [ + "0x40" + ], + "store": null, + "used": 42308 + }, + "pc": 284, + "sub": null, + "op": "PUSH1", + "idx": "15-51" + }, + { + "cost": 3, + "ex": { + "mem": { + "data": "0x0000000000000000000000000000000000000000000000000000000000000060", + "off": 64 + }, + "push": [ + "0x60" + ], + "store": null, + "used": 42305 + }, + "pc": 286, + "sub": null, + "op": "MLOAD", + "idx": "15-52" + }, + { + "cost": 3, + "ex": { + "mem": null, + "push": [ + "0x60", + "0x60" + ], + "store": null, + "used": 42302 + }, + "pc": 287, + "sub": null, + "op": "DUP1", + "idx": "15-53" + }, + { + "cost": 3, + "ex": { + "mem": null, + "push": [ + "0x60", + "0x0", + "0x60", + "0x60", + "0x60" + ], + "store": null, + "used": 42299 + }, + "pc": 288, + "sub": null, + "op": "DUP4", + "idx": "15-54" + }, + { + "cost": 3, + "ex": { + "mem": null, + "push": [ + "0x0" + ], + "store": null, + "used": 42296 + }, + "pc": 289, + "sub": null, + "op": "SUB", + "idx": "15-55" + }, + { + "cost": 3, + "ex": { + "mem": null, + "push": [ + "0x60", + "0x0", + "0x60" + ], + "store": null, + "used": 42293 + }, + "pc": 290, + "sub": null, + "op": "DUP2", + "idx": "15-56" + }, + { + "cost": 3, + "ex": { + "mem": null, + "push": [ + "0x1550f7dca70000", + "0x60", + "0x0", + "0x60", + "0x0", + "0x60", + "0x1550f7dca70000" + ], + "store": null, + "used": 42290 + }, + "pc": 291, + "sub": null, + "op": "DUP6", + "idx": "15-57" + }, + { + "cost": 3, + "ex": { + "mem": null, + "push": [ + "0xc227a75b32ed37d3f9d6341b9904d003dad3b1b3", + "0x0", + "0x1550f7dca70000", + "0x60", + "0x0", + "0x60", + "0x0", + "0x60", + "0x1550f7dca70000", + "0xc227a75b32ed37d3f9d6341b9904d003dad3b1b3" + ], + "store": null, + "used": 42287 + }, + "pc": 292, + "sub": null, + "op": "DUP9", + "idx": "15-58" + }, + { + "cost": 3, + "ex": { + "mem": null, + "push": [ + "0x0", + "0x1550f7dca70000", + "0x60", + "0x0", + "0x60", + "0x0", + "0x60", + "0x1550f7dca70000", + "0xc227a75b32ed37d3f9d6341b9904d003dad3b1b3", + "0x0" + ], + "store": null, + "used": 42284 + }, + "pc": 293, + "sub": null, + "op": "DUP9", + "idx": "15-59" + }, + { + "cost": 9700, + "ex": { + "mem": null, + "push": [ + "0x1" + ], + "store": null, + "used": 34884 + }, + "pc": 294, + "sub": { + "code": "0x", + "ops": [] + }, + "op": "CALL", + "idx": "15-60" + }, + { + "cost": 3, + "ex": { + "mem": null, + "push": [ + "0x1", + "0x0", + "0x1550f7dca70000", + "0x60", + "0xc227a75b32ed37d3f9d6341b9904d003dad3b1b3" + ], + "store": null, + "used": 34881 + }, + "pc": 295, + "sub": null, + "op": "SWAP4", + "idx": "15-61" + }, + { + "cost": 2, + "ex": { + "mem": null, + "push": [], + "store": null, + "used": 34879 + }, + "pc": 296, + "sub": null, + "op": "POP", + "idx": "15-62" + }, + { + "cost": 2, + "ex": { + "mem": null, + "push": [], + "store": null, + "used": 34877 + }, + "pc": 297, + "sub": null, + "op": "POP", + "idx": "15-63" + }, + { + "cost": 2, + "ex": { + "mem": null, + "push": [], + "store": null, + "used": 34875 + }, + "pc": 298, + "sub": null, + "op": "POP", + "idx": "15-64" + }, + { + "cost": 2, + "ex": { + "mem": null, + "push": [], + "store": null, + "used": 34873 + }, + "pc": 299, + "sub": null, + "op": "POP", + "idx": "15-65" + }, + { + "cost": 3, + "ex": { + "mem": null, + "push": [ + "0x0" + ], + "store": null, + "used": 34870 + }, + "pc": 300, + "sub": null, + "op": "ISZERO", + "idx": "15-66" + }, + { + "cost": 3, + "ex": { + "mem": null, + "push": [ + "0x1" + ], + "store": null, + "used": 34867 + }, + "pc": 301, + "sub": null, + "op": "ISZERO", + "idx": "15-67" + }, + { + "cost": 3, + "ex": { + "mem": null, + "push": [ + "0x136" + ], + "store": null, + "used": 34864 + }, + "pc": 302, + "sub": null, + "op": "PUSH2", + "idx": "15-68" + }, + { + "cost": 10, + "ex": { + "mem": null, + "push": [], + "store": null, + "used": 34854 + }, + "pc": 305, + "sub": null, + "op": "JUMPI", + "idx": "15-69" + }, + { + "cost": 1, + "ex": { + "mem": null, + "push": [], + "store": null, + "used": 34853 + }, + "pc": 310, + "sub": null, + "op": "JUMPDEST", + "idx": "15-70" + }, + { + "cost": 1, + "ex": { + "mem": null, + "push": [], + "store": null, + "used": 34852 + }, + "pc": 311, + "sub": null, + "op": "JUMPDEST", + "idx": "15-71" + }, + { + "cost": 2, + "ex": { + "mem": null, + "push": [], + "store": null, + "used": 34850 + }, + "pc": 312, + "sub": null, + "op": "POP", + "idx": "15-72" + }, + { + "cost": 8, + "ex": { + "mem": null, + "push": [], + "store": null, + "used": 34842 + }, + "pc": 313, + "sub": null, + "op": "JUMP", + "idx": "15-73" + }, + { + "cost": 1, + "ex": { + "mem": null, + "push": [], + "store": null, + "used": 34841 + }, + "pc": 138, + "sub": null, + "op": "JUMPDEST", + "idx": "15-74" + }, + { + "cost": 0, + "ex": { + "mem": null, + "push": [], + "store": null, + "used": 34841 + }, + "pc": 139, + "sub": null, + "op": "STOP", + "idx": "15-75" + } + ] } - }, - "trace": [ - { - "action": { - "callType": "call", - "from": "0x01f0eb5c4b0a9d8285b67195f5f10ce22971a102", - "gas": "0xa5f8", - "input": "0x1a695230000000000000000000000000c227a75b32ed37d3f9d6341b9904d003dad3b1b3", - "to": "0x0b95993a39a363d99280ac950f5e4536ab5c5566", - "value": "0x1550f7dca70000" - }, - "result": { - "gasUsed": "0x1ddf", - "output": "0x" - }, - "subtraces": 1, - "traceAddress": [], - "type": "call" - }, - { - "action": { - "callType": "call", - "from": "0x0b95993a39a363d99280ac950f5e4536ab5c5566", - "gas": "0x8fc", - "input": "0x", - "to": "0xc227a75b32ed37d3f9d6341b9904d003dad3b1b3", - "value": "0x1550f7dca70000" - }, - "result": { - "gasUsed": "0x0", - "output": "0x" - }, - "subtraces": 0, - "traceAddress": [ - 0 - ], - "type": "call" - } - ], - "vmTrace": { - "code": "0x60606040523615610055576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680631a6952301461005e5780637362377b1461008c5780638da5cb5b146100a1575b61005c5b5b565b005b61008a600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919050506100f6565b005b341561009757600080fd5b61009f61013a565b005b34156100ac57600080fd5b6100b4610210565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b8073ffffffffffffffffffffffffffffffffffffffff166108fc349081150290604051600060405180830381858888f19350505050151561013657600080fd5b5b50565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561019557600080fd5b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc3073ffffffffffffffffffffffffffffffffffffffff16319081150290604051600060405180830381858888f19350505050151561020d57600080fd5b5b565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff16815600a165627a7a7230582029eabe8a624d811f3ea09c310d65be79ddefa23e3b702541dc1687b475f091690029", - "ops": [ - { - "cost": 3, - "ex": { - "mem": null, - "push": [ - "0x60" - ], - "store": null, - "used": 42485 - }, - "pc": 0, - "sub": null - }, - { - "cost": 3, - "ex": { - "mem": null, - "push": [ - "0x40" - ], - "store": null, - "used": 42482 - }, - "pc": 2, - "sub": null - }, - { - "cost": 12, - "ex": { - "mem": { - "data": "0x0000000000000000000000000000000000000000000000000000000000000060", - "off": 64 - }, - "push": [], - "store": null, - "used": 42470 - }, - "pc": 4, - "sub": null - }, - { - "cost": 2, - "ex": { - "mem": null, - "push": [ - "0x24" - ], - "store": null, - "used": 42468 - }, - "pc": 5, - "sub": null - }, - { - "cost": 3, - "ex": { - "mem": null, - "push": [ - "0x0" - ], - "store": null, - "used": 42465 - }, - "pc": 6, - "sub": null - }, - { - "cost": 3, - "ex": { - "mem": null, - "push": [ - "0x55" - ], - "store": null, - "used": 42462 - }, - "pc": 7, - "sub": null - }, - { - "cost": 10, - "ex": { - "mem": null, - "push": [], - "store": null, - "used": 42452 - }, - "pc": 10, - "sub": null - }, - { - "cost": 3, - "ex": { - "mem": null, - "push": [ - "0x0" - ], - "store": null, - "used": 42449 - }, - "pc": 11, - "sub": null - }, - { - "cost": 3, - "ex": { - "mem": null, - "push": [ - "0x1a695230000000000000000000000000c227a75b32ed37d3f9d6341b9904d003" - ], - "store": null, - "used": 42446 - }, - "pc": 13, - "sub": null - }, - { - "cost": 3, - "ex": { - "mem": null, - "push": [ - "0x100000000000000000000000000000000000000000000000000000000" - ], - "store": null, - "used": 42443 - }, - "pc": 14, - "sub": null - }, - { - "cost": 3, - "ex": { - "mem": null, - "push": [ - "0x100000000000000000000000000000000000000000000000000000000", - "0x1a695230000000000000000000000000c227a75b32ed37d3f9d6341b9904d003" - ], - "store": null, - "used": 42440 - }, - "pc": 44, - "sub": null - }, - { - "cost": 5, - "ex": { - "mem": null, - "push": [ - "0x1a695230" - ], - "store": null, - "used": 42435 - }, - "pc": 45, - "sub": null - }, - { - "cost": 3, - "ex": { - "mem": null, - "push": [ - "0xffffffff" - ], - "store": null, - "used": 42432 - }, - "pc": 46, - "sub": null - }, - { - "cost": 3, - "ex": { - "mem": null, - "push": [ - "0x1a695230" - ], - "store": null, - "used": 42429 - }, - "pc": 51, - "sub": null - }, - { - "cost": 3, - "ex": { - "mem": null, - "push": [ - "0x1a695230", - "0x1a695230" - ], - "store": null, - "used": 42426 - }, - "pc": 52, - "sub": null - }, - { - "cost": 3, - "ex": { - "mem": null, - "push": [ - "0x1a695230" - ], - "store": null, - "used": 42423 - }, - "pc": 53, - "sub": null - }, - { - "cost": 3, - "ex": { - "mem": null, - "push": [ - "0x1" - ], - "store": null, - "used": 42420 - }, - "pc": 58, - "sub": null - }, - { - "cost": 3, - "ex": { - "mem": null, - "push": [ - "0x5e" - ], - "store": null, - "used": 42417 - }, - "pc": 59, - "sub": null - }, - { - "cost": 10, - "ex": { - "mem": null, - "push": [], - "store": null, - "used": 42407 - }, - "pc": 62, - "sub": null - }, - { - "cost": 1, - "ex": { - "mem": null, - "push": [], - "store": null, - "used": 42406 - }, - "pc": 94, - "sub": null - }, - { - "cost": 3, - "ex": { - "mem": null, - "push": [ - "0x8a" - ], - "store": null, - "used": 42403 - }, - "pc": 95, - "sub": null - }, - { - "cost": 3, - "ex": { - "mem": null, - "push": [ - "0x4" - ], - "store": null, - "used": 42400 - }, - "pc": 98, - "sub": null - }, - { - "cost": 3, - "ex": { - "mem": null, - "push": [ - "0x4", - "0x4" - ], - "store": null, - "used": 42397 - }, - "pc": 100, - "sub": null - }, - { - "cost": 3, - "ex": { - "mem": null, - "push": [ - "0x4", - "0x4" - ], - "store": null, - "used": 42394 - }, - "pc": 101, - "sub": null - }, - { - "cost": 3, - "ex": { - "mem": null, - "push": [ - "0xc227a75b32ed37d3f9d6341b9904d003dad3b1b3" - ], - "store": null, - "used": 42391 - }, - "pc": 102, - "sub": null - }, - { - "cost": 3, - "ex": { - "mem": null, - "push": [ - "0xffffffffffffffffffffffffffffffffffffffff" - ], - "store": null, - "used": 42388 - }, - "pc": 103, - "sub": null - }, - { - "cost": 3, - "ex": { - "mem": null, - "push": [ - "0xc227a75b32ed37d3f9d6341b9904d003dad3b1b3" - ], - "store": null, - "used": 42385 - }, - "pc": 124, - "sub": null - }, - { - "cost": 3, - "ex": { - "mem": null, - "push": [ - "0xc227a75b32ed37d3f9d6341b9904d003dad3b1b3", - "0x4" - ], - "store": null, - "used": 42382 - }, - "pc": 125, - "sub": null - }, - { - "cost": 3, - "ex": { - "mem": null, - "push": [ - "0x20" - ], - "store": null, - "used": 42379 - }, - "pc": 126, - "sub": null - }, - { - "cost": 3, - "ex": { - "mem": null, - "push": [ - "0x24" - ], - "store": null, - "used": 42376 - }, - "pc": 128, - "sub": null - }, - { - "cost": 3, - "ex": { - "mem": null, - "push": [ - "0x24", - "0xc227a75b32ed37d3f9d6341b9904d003dad3b1b3" - ], - "store": null, - "used": 42373 - }, - "pc": 129, - "sub": null - }, - { - "cost": 3, - "ex": { - "mem": null, - "push": [ - "0xc227a75b32ed37d3f9d6341b9904d003dad3b1b3", - "0x24", - "0x4" - ], - "store": null, - "used": 42370 - }, - "pc": 130, - "sub": null - }, - { - "cost": 3, - "ex": { - "mem": null, - "push": [ - "0x4", - "0x24" - ], - "store": null, - "used": 42367 - }, - "pc": 131, - "sub": null - }, - { - "cost": 2, - "ex": { - "mem": null, - "push": [], - "store": null, - "used": 42365 - }, - "pc": 132, - "sub": null - }, - { - "cost": 2, - "ex": { - "mem": null, - "push": [], - "store": null, - "used": 42363 - }, - "pc": 133, - "sub": null - }, - { - "cost": 3, - "ex": { - "mem": null, - "push": [ - "0xf6" - ], - "store": null, - "used": 42360 - }, - "pc": 134, - "sub": null - }, - { - "cost": 8, - "ex": { - "mem": null, - "push": [], - "store": null, - "used": 42352 - }, - "pc": 137, - "sub": null - }, - { - "cost": 1, - "ex": { - "mem": null, - "push": [], - "store": null, - "used": 42351 - }, - "pc": 246, - "sub": null - }, - { - "cost": 3, - "ex": { - "mem": null, - "push": [ - "0xc227a75b32ed37d3f9d6341b9904d003dad3b1b3", - "0xc227a75b32ed37d3f9d6341b9904d003dad3b1b3" - ], - "store": null, - "used": 42348 - }, - "pc": 247, - "sub": null - }, - { - "cost": 3, - "ex": { - "mem": null, - "push": [ - "0xffffffffffffffffffffffffffffffffffffffff" - ], - "store": null, - "used": 42345 - }, - "pc": 248, - "sub": null - }, - { - "cost": 3, - "ex": { - "mem": null, - "push": [ - "0xc227a75b32ed37d3f9d6341b9904d003dad3b1b3" - ], - "store": null, - "used": 42342 - }, - "pc": 269, - "sub": null - }, - { - "cost": 3, - "ex": { - "mem": null, - "push": [ - "0x8fc" - ], - "store": null, - "used": 42339 - }, - "pc": 270, - "sub": null - }, - { - "cost": 2, - "ex": { - "mem": null, - "push": [ - "0x1550f7dca70000" - ], - "store": null, - "used": 42337 - }, - "pc": 273, - "sub": null - }, - { - "cost": 3, - "ex": { - "mem": null, - "push": [ - "0x1550f7dca70000", - "0x8fc" - ], - "store": null, - "used": 42334 - }, - "pc": 274, - "sub": null - }, - { - "cost": 3, - "ex": { - "mem": null, - "push": [ - "0x1550f7dca70000", - "0x8fc", - "0x1550f7dca70000" - ], - "store": null, - "used": 42331 - }, - "pc": 275, - "sub": null - }, - { - "cost": 3, - "ex": { - "mem": null, - "push": [ - "0x0" - ], - "store": null, - "used": 42328 - }, - "pc": 276, - "sub": null - }, - { - "cost": 5, - "ex": { - "mem": null, - "push": [ - "0x0" - ], - "store": null, - "used": 42323 - }, - "pc": 277, - "sub": null - }, - { - "cost": 3, - "ex": { - "mem": null, - "push": [ - "0x0", - "0x1550f7dca70000" - ], - "store": null, - "used": 42320 - }, - "pc": 278, - "sub": null - }, - { - "cost": 3, - "ex": { - "mem": null, - "push": [ - "0x40" - ], - "store": null, - "used": 42317 - }, - "pc": 279, - "sub": null - }, - { - "cost": 3, - "ex": { - "mem": { - "data": "0x0000000000000000000000000000000000000000000000000000000000000060", - "off": 64 - }, - "push": [ - "0x60" - ], - "store": null, - "used": 42314 - }, - "pc": 281, - "sub": null - }, - { - "cost": 3, - "ex": { - "mem": null, - "push": [ - "0x0" - ], - "store": null, - "used": 42311 - }, - "pc": 282, - "sub": null - }, - { - "cost": 3, - "ex": { - "mem": null, - "push": [ - "0x40" - ], - "store": null, - "used": 42308 - }, - "pc": 284, - "sub": null - }, - { - "cost": 3, - "ex": { - "mem": { - "data": "0x0000000000000000000000000000000000000000000000000000000000000060", - "off": 64 - }, - "push": [ - "0x60" - ], - "store": null, - "used": 42305 - }, - "pc": 286, - "sub": null - }, - { - "cost": 3, - "ex": { - "mem": null, - "push": [ - "0x60", - "0x60" - ], - "store": null, - "used": 42302 - }, - "pc": 287, - "sub": null - }, - { - "cost": 3, - "ex": { - "mem": null, - "push": [ - "0x60", - "0x0", - "0x60", - "0x60", - "0x60" - ], - "store": null, - "used": 42299 - }, - "pc": 288, - "sub": null - }, - { - "cost": 3, - "ex": { - "mem": null, - "push": [ - "0x0" - ], - "store": null, - "used": 42296 - }, - "pc": 289, - "sub": null - }, - { - "cost": 3, - "ex": { - "mem": null, - "push": [ - "0x60", - "0x0", - "0x60" - ], - "store": null, - "used": 42293 - }, - "pc": 290, - "sub": null - }, - { - "cost": 3, - "ex": { - "mem": null, - "push": [ - "0x1550f7dca70000", - "0x60", - "0x0", - "0x60", - "0x0", - "0x60", - "0x1550f7dca70000" - ], - "store": null, - "used": 42290 - }, - "pc": 291, - "sub": null - }, - { - "cost": 3, - "ex": { - "mem": null, - "push": [ - "0xc227a75b32ed37d3f9d6341b9904d003dad3b1b3", - "0x0", - "0x1550f7dca70000", - "0x60", - "0x0", - "0x60", - "0x0", - "0x60", - "0x1550f7dca70000", - "0xc227a75b32ed37d3f9d6341b9904d003dad3b1b3" - ], - "store": null, - "used": 42287 - }, - "pc": 292, - "sub": null - }, - { - "cost": 3, - "ex": { - "mem": null, - "push": [ - "0x0", - "0x1550f7dca70000", - "0x60", - "0x0", - "0x60", - "0x0", - "0x60", - "0x1550f7dca70000", - "0xc227a75b32ed37d3f9d6341b9904d003dad3b1b3", - "0x0" - ], - "store": null, - "used": 42284 - }, - "pc": 293, - "sub": null - }, - { - "cost": 9700, - "ex": { - "mem": null, - "push": [ - "0x1" - ], - "store": null, - "used": 34884 - }, - "pc": 294, - "sub": { - "code": "0x", - "ops": [] - } - }, - { - "cost": 3, - "ex": { - "mem": null, - "push": [ - "0x1", - "0x0", - "0x1550f7dca70000", - "0x60", - "0xc227a75b32ed37d3f9d6341b9904d003dad3b1b3" - ], - "store": null, - "used": 34881 - }, - "pc": 295, - "sub": null - }, - { - "cost": 2, - "ex": { - "mem": null, - "push": [], - "store": null, - "used": 34879 - }, - "pc": 296, - "sub": null - }, - { - "cost": 2, - "ex": { - "mem": null, - "push": [], - "store": null, - "used": 34877 - }, - "pc": 297, - "sub": null - }, - { - "cost": 2, - "ex": { - "mem": null, - "push": [], - "store": null, - "used": 34875 - }, - "pc": 298, - "sub": null - }, - { - "cost": 2, - "ex": { - "mem": null, - "push": [], - "store": null, - "used": 34873 - }, - "pc": 299, - "sub": null - }, - { - "cost": 3, - "ex": { - "mem": null, - "push": [ - "0x0" - ], - "store": null, - "used": 34870 - }, - "pc": 300, - "sub": null - }, - { - "cost": 3, - "ex": { - "mem": null, - "push": [ - "0x1" - ], - "store": null, - "used": 34867 - }, - "pc": 301, - "sub": null - }, - { - "cost": 3, - "ex": { - "mem": null, - "push": [ - "0x136" - ], - "store": null, - "used": 34864 - }, - "pc": 302, - "sub": null - }, - { - "cost": 10, - "ex": { - "mem": null, - "push": [], - "store": null, - "used": 34854 - }, - "pc": 305, - "sub": null - }, - { - "cost": 1, - "ex": { - "mem": null, - "push": [], - "store": null, - "used": 34853 - }, - "pc": 310, - "sub": null - }, - { - "cost": 1, - "ex": { - "mem": null, - "push": [], - "store": null, - "used": 34852 - }, - "pc": 311, - "sub": null - }, - { - "cost": 2, - "ex": { - "mem": null, - "push": [], - "store": null, - "used": 34850 - }, - "pc": 312, - "sub": null - }, - { - "cost": 8, - "ex": { - "mem": null, - "push": [], - "store": null, - "used": 34842 - }, - "pc": 313, - "sub": null - }, - { - "cost": 1, - "ex": { - "mem": null, - "push": [], - "store": null, - "used": 34841 - }, - "pc": 138, - "sub": null - }, - { - "cost": 0, - "ex": { - "mem": null, - "push": [], - "store": null, - "used": 34841 - }, - "pc": 139, - "sub": null - } - ] - } }"# diff --git a/ethers-core/src/types/trace/mod.rs b/ethers-core/src/types/trace/mod.rs index 43bb621f..ce1e7082 100644 --- a/ethers-core/src/types/trace/mod.rs +++ b/ethers-core/src/types/trace/mod.rs @@ -11,6 +11,9 @@ pub use filter::*; mod geth; pub use geth::*; +mod opcodes; +pub use opcodes::*; + #[derive(Debug, PartialEq, Eq, Clone, Deserialize, Serialize)] /// Description of the type of trace to make pub enum TraceType { @@ -131,6 +134,9 @@ pub struct VMOperation { /// Subordinate trace of the CALL/CREATE if applicable. // #[serde(bound="VMTrace: Deserialize")] pub sub: Option, + /// The executed opcode name + #[serde(rename = "op")] + pub op: OpCode, } #[derive(Debug, Clone, PartialEq, Eq, Default, Deserialize, Serialize)] diff --git a/ethers-core/src/types/trace/opcodes.rs b/ethers-core/src/types/trace/opcodes.rs new file mode 100644 index 00000000..0c90a632 --- /dev/null +++ b/ethers-core/src/types/trace/opcodes.rs @@ -0,0 +1,343 @@ +use serde::{Deserialize, Serialize}; + +// opcode descriptions taken from evm.codes https://github.com/comitylabs/evm.codes/blob/bc7f102808055d88365559d40c190c5bd6d164c3/opcodes.json +// https://github.com/ethereum/go-ethereum/blob/2b1299b1c006077c56ecbad32e79fc16febe3dd6/core/vm/opcodes.go +#[derive(Debug, Clone, PartialEq, Eq, Default, Deserialize, Serialize)] +/// Name of executed EVM opcode +pub enum OpCode { + // 0x0 range - arithmetic ops. + /// Opcode 0x0 - Halts execution + STOP, + /// Opcode 0x1 - Addition operation + ADD, + /// Opcode 0x2 - Multiplication operation + MUL, + /// Opcode 0x3 - Subtraction operation + SUB, + /// Opcode 0x4 - Integer division operation + DIV, + /// Opcode 0x5 - Signed integer division operation (truncated) + SDIV, + /// Opcode 0x6 - Modulo remainder operation + MOD, + /// Opcode 0x7 - Signed modulo remainder operation + SMOD, + /// Opcode 0x8 - Modulo addition operation + ADDMOD, + /// Opcode 0x9 - Modulo multiplication operation + MULMOD, + /// Opcode 0xA - Exponential operation + EXP, + /// Opcode 0xB - Extend length of two’s complement signed integer + SIGNEXTEND, + + // 0x0C - 0x0F are invalid + + // 0x10 range - comparison ops. + /// Opcode 0x10 - Less-than comparison + LT, + /// Opcode 0x11 - Greater-than comparison + GT, + /// Opcode 0x12 - Signed less-than comparison + SLT, + /// Opcode 0x13 - Signed greater-than comparison + SGT, + /// Opcode 0x14 - Equality comparison + EQ, + /// Opcode 0x15 - Simple not operator + ISZERO, + /// Opcode 0x16 - Bitwise AND operation + AND, + /// Opcode 0x17 - Bitwise OR operation + OR, + /// Opcode 0x18 - Bitwise XOR operation + XOR, + /// Opcode 0x19 - Bitwise NOT operation + NOT, + /// Opcode 0x1A - Retrieve single byte from word + BYTE, + /// Opcode 0x1B - Left shift operation + SHL, + /// Opcode 0x1C - Logical right shift operation + SHR, + /// Opcode 0x1D - Arithmetic (signed) right shift operation + SAR, + + // 0x1E - 0x1F are invalid + + // 0x20 range - crypto. + /// Opcode 0x20 - Compute Keccak-256 hash + SHA3, + + // 0x21 - 0x2F are invalid + + // 0x30 range - closure state. + /// Opcode 0x30 - Get address of currently executing account + ADDRESS, + /// Opcode 0x31 - Get address of currently executing account + BALANCE, + /// Opcode 0x32 - Get execution origination address + ORIGIN, + /// Opcode 0x33 - Get caller address + CALLER, + /// Opcode 0x34 - Get deposited value by the instruction/transaction responsible for this + /// execution + CALLVALUE, + /// Opcode 0x35 - Get input data of current environment + CALLDATALOAD, + /// Opcode 0x36 - Get size of input data in current environment + CALLDATASIZE, + /// Opcode 0x37 - Copy input data in current environment to memory + CALLDATACOPY, + /// Opcode 0x38 - Get size of code running in current environment + CODESIZE, + /// Opcode 0x39 - Copy code running in current environment to memory + CODECOPY, + /// Opcode 0x3A - Get price of gas in current environment + GASPRICE, + /// Opcode 0x3B - Get size of an account’s code + EXTCODESIZE, + /// Opcode 0x3C - Copy an account’s code to memory + EXTCODECOPY, + /// Opcode 0x3D - Get size of output data from the previous call from the current environment + RETURNDATASIZE, + /// Opcode 0x3E - Copy output data from the previous call to memory + RETURNDATACOPY, + /// Opcode 0x3F - Get hash of an account’s code + EXTCODEHASH, + + // 0x40 range - block operations. + /// Opcode 0x40 - Get the hash of one of the 256 most recent complete blocks + BLOCKHASH, + /// Opcode 0x41 - Get the block’s beneficiary address + COINBASE, + /// Opcode 0x42 - Get the block’s timestamp + TIMESTAMP, + /// Opcode 0x43 - Get the block’s number + NUMBER, + /// Opcode 0x44 - Get the block’s difficulty + DIFFICULTY, + //RANDOM, // 0x44 // Same as DIFFICULTY + //PREVRANDAO, // 0x44 // Same as DIFFICULTY + /// Opcode 0x45 - Get the block’s gas limit + GASLIMIT, + /// Opcode 0x46 - Get the chain ID + CHAINID, + /// Opcode 0x47 - Get balance of currently executing account + SELFBALANCE, + /// Opcode 0x48 - Get the base fee + BASEFEE, + + // 0x49 - 0x4F are invalid + + // 0x50 range - 'storage' and execution. + /// Opcode 0x50 - Remove item from stack + POP, + /// Opcode 0x51 - Load word from memory + MLOAD, + /// Opcode 0x52 - Save word to memory + MSTORE, + /// Opcode 0x53 - Save byte to memory + MSTORE8, + /// Opcode 0x54 - Load word from storage + SLOAD, + /// Opcode 0x55 - Save word to storage + SSTORE, + /// Opcode 0x56 - Alter the program counter + JUMP, + /// Opcode 0x57 - Conditionally alter the program counter + JUMPI, + /// Opcode 0x58 - Get the value of the program counter prior to the increment corresponding to + /// this instruction + PC, + /// Opcode 0x59 - Get the size of active memory in bytes + MSIZE, + /// Opcode 0x5A - Get the amount of available gas, including the corresponding reduction for + /// the cost of this instruction + GAS, + /// Opcode 0x5B - Mark a valid destination for jumps + JUMPDEST, + + // 0x5C - 0x5F are invalid + + // 0x60 range - pushes. + // PUSH0, // 0x5F (https://eips.ethereum.org/EIPS/eip-3855) + /// Opcode 0x60 - Place 1 byte item on stack + PUSH1, + /// Opcode 0x61 - Place 2 byte item on stack + PUSH2, + /// Opcode 0x62 - Place 3 byte item on stack + PUSH3, + /// Opcode 0x63 - Place 4 byte item on stack + PUSH4, + /// Opcode 0x64 - Place 5 byte item on stack + PUSH5, + /// Opcode 0x65 - Place 6 byte item on stack + PUSH6, + /// Opcode 0x66 - Place 7 byte item on stack + PUSH7, + /// Opcode 0x67 - Place 8 byte item on stack + PUSH8, + /// Opcode 0x68 - Place 9 byte item on stack + PUSH9, + /// Opcode 0x69 - Place 10 byte item on stack + PUSH10, + /// Opcode 0x6A - Place 11 byte item on stack + PUSH11, + /// Opcode 0x6B - Place 12 byte item on stack + PUSH12, + /// Opcode 0x6C - Place 13 byte item on stack + PUSH13, + /// Opcode 0x6D - Place 14 byte item on stack + PUSH14, + /// Opcode 0x6E - Place 15 byte item on stack + PUSH15, + /// Opcode 0x6F - Place 16 byte item on stack + PUSH16, + /// Opcode 0x70 - Place 17 byte item on stack + PUSH17, + /// Opcode 0x71 - Place 18 byte item on stack + PUSH18, + /// Opcode 0x72 - Place 19 byte item on stack + PUSH19, + /// Opcode 0x73 - Place 20 byte item on stack + PUSH20, + /// Opcode 0x74 - Place 21 byte item on stack + PUSH21, + /// Opcode 0x75 - Place 22 byte item on stack + PUSH22, + /// Opcode 0x76 - Place 23 byte item on stack + PUSH23, + /// Opcode 0x77 - Place 24 byte item on stack + PUSH24, + /// Opcode 0x78 - Place 25 byte item on stack + PUSH25, + /// Opcode 0x79 - Place 26 byte item on stack + PUSH26, + /// Opcode 0x7A - Place 27 byte item on stack + PUSH27, + /// Opcode 0x7B - Place 28 byte item on stack + PUSH28, + /// Opcode 0x7C - Place 29 byte item on stack + PUSH29, + /// Opcode 0x7D - Place 30 byte item on stack + PUSH30, + /// Opcode 0x7E - Place 31 byte item on stack + PUSH31, + /// Opcode 0x7F - Place 32 byte item on stack + PUSH32, + + // 0x80 range - dups. + /// Opcode 0x80 - Duplicate 1st stack item + DUP1, + /// Opcode 0x81 - Duplicate 2nd stack item + DUP2, + /// Opcode 0x82 - Duplicate 3rd stack item + DUP3, + /// Opcode 0x83 - Duplicate 4th stack item + DUP4, + /// Opcode 0x84 - Duplicate 5th stack item + DUP5, + /// Opcode 0x85 - Duplicate 6th stack item + DUP6, + /// Opcode 0x86 - Duplicate 7th stack item + DUP7, + /// Opcode 0x87 - Duplicate 8th stack item + DUP8, + /// Opcode 0x88 - Duplicate 9th stack item + DUP9, + /// Opcode 0x89 - Duplicate 10th stack item + DUP10, + /// Opcode 0x8A - Duplicate 11th stack item + DUP11, + /// Opcode 0x8B - Duplicate 12th stack item + DUP12, + /// Opcode 0x8C - Duplicate 13th stack item + DUP13, + /// Opcode 0x8D - Duplicate 14th stack item + DUP14, + /// Opcode 0x8E - Duplicate 15th stack item + DUP15, + /// Opcode 0x8F - Duplicate 16th stack item + DUP16, + + // 0x90 range - swaps. + /// Opcode 0x90 - Exchange 1st and 1st stack items + SWAP1, + /// Opcode 0x91 - Exchange 1st and 2nd stack items + SWAP2, + /// Opcode 0x92 - Exchange 1st and 3rd stack items + SWAP3, + /// Opcode 0x93 - Exchange 1st and 4th stack items + SWAP4, + /// Opcode 0x94 - Exchange 1st and 5th stack items + SWAP5, + /// Opcode 0x95 - Exchange 1st and 6th stack items + SWAP6, + /// Opcode 0x96 - Exchange 1st and 7th stack items + SWAP7, + /// Opcode 0x97 - Exchange 1st and 8th stack items + SWAP8, + /// Opcode 0x98 - Exchange 1st and 9th stack items + SWAP9, + /// Opcode 0x99 - Exchange 1st and 10th stack items + SWAP10, + /// Opcode 0x9A - Exchange 1st and 11th stack items + SWAP11, + /// Opcode 0x9B - Exchange 1st and 12th stack items + SWAP12, + /// Opcode 0x9C - Exchange 1st and 13th stack items + SWAP13, + /// Opcode 0x9D - Exchange 1st and 14th stack items + SWAP14, + /// Opcode 0x9E - Exchange 1st and 15th stack items + SWAP15, + /// Opcode 0x9F - Exchange 1st and 16th stack items + SWAP16, + + // 0xA0 range - logging ops. + /// Opcode 0xA0 - Append log record with one topic + LOG0, + /// Opcode 0xA1 - Append log record with two topics + LOG1, + /// Opcode 0xA2 - Append log record with three topics + LOG2, + /// Opcode 0xA3 - Append log record with four topics + LOG3, + /// Opcode 0xA4 - Append log record with five topics + LOG4, + + // 0xA5 - 0xEF are invalid + + // 0xF0 range - closures. + /// Opcode 0xF0 - Create a new account with associated code + CREATE, + /// Opcode 0xF1 - Message-call into an account + CALL, + /// Opcode 0xF2 - Message-call into this account with alternative account’s code + CALLCODE, + /// Opcode 0xF3 - Halt execution returning output data + RETURN, + /// Opcode 0xF4 - Message-call into this account with an alternative account’s code, but + /// persisting the current values for sender and value + DELEGATECALL, + /// Opcode 0xF5 - Create a new account with associated code at a predictable address + CREATE2, + + // 0xF6 - 0xF9 are invalid + + // 0xFA range - closures + /// Opcode 0xFA - Static message-call into an account + STATICCALL, + + // 0xFB - 0xFC are invalid + + // 0xfd range - closures + /// Opcode 0xFD - Halt execution reverting state changes but returning data and remaining gas + REVERT, + #[default] + /// Opcode 0xFE - Designated invalid instruction + INVALID, + /// Opcode 0xFF - Halt execution and register account for later deletion + SELFDESTRUCT, +}