2019-01-30 12:29:04 +00:00
|
|
|
import
|
2023-03-22 11:18:37 +00:00
|
|
|
macro_assembler,
|
|
|
|
unittest2,
|
2023-01-31 12:38:08 +00:00
|
|
|
eth/common
|
2019-01-30 12:29:04 +00:00
|
|
|
|
2019-09-21 05:45:23 +00:00
|
|
|
proc opCustomMain*() =
|
|
|
|
suite "Custom Opcodes Test":
|
|
|
|
assembler: # CALLDATASIZE OP
|
|
|
|
title: "CALLDATASIZE_1"
|
|
|
|
data:
|
|
|
|
"0x00000000000000000000000000000000000000000000000000000000000000A1"
|
|
|
|
"0x00000000000000000000000000000000000000000000000000000000000000B1"
|
|
|
|
code:
|
|
|
|
CallDataSize
|
|
|
|
stack: "0x0000000000000000000000000000000000000000000000000000000000000040"
|
|
|
|
|
|
|
|
assembler: # CALLDATALOAD OP
|
|
|
|
title: "CALLDATALOAD_1"
|
|
|
|
data:
|
|
|
|
"0x00000000000000000000000000000000000000000000000000000000000000A1"
|
|
|
|
"0x00000000000000000000000000000000000000000000000000000000000000B1"
|
|
|
|
code:
|
|
|
|
Push1 "0x00"
|
|
|
|
CallDataLoad
|
|
|
|
stack: "0x00000000000000000000000000000000000000000000000000000000000000A1"
|
|
|
|
|
|
|
|
assembler: # CALLDATALOAD OP
|
|
|
|
title: "CALLDATALOAD_2"
|
|
|
|
data:
|
|
|
|
"0x00000000000000000000000000000000000000000000000000000000000000A1"
|
|
|
|
"0x00000000000000000000000000000000000000000000000000000000000000B1"
|
|
|
|
code:
|
|
|
|
Push1 "0x02"
|
|
|
|
CallDataLoad
|
|
|
|
stack: "0x0000000000000000000000000000000000000000000000000000000000A10000"
|
|
|
|
|
|
|
|
assembler: # CALLDATALOAD OP
|
|
|
|
title: "CALLDATALOAD_3"
|
|
|
|
data:
|
|
|
|
"0x00000000000000000000000000000000000000000000000000000000000000A1"
|
|
|
|
"0x00000000000000000000000000000000000000000000000000000000000000B1"
|
|
|
|
code:
|
|
|
|
Push1 "0x20"
|
|
|
|
CallDataLoad
|
|
|
|
stack: "0x00000000000000000000000000000000000000000000000000000000000000B1"
|
|
|
|
|
|
|
|
assembler: # CALLDATALOAD OP
|
|
|
|
title: "CALLDATALOAD_4"
|
|
|
|
data:
|
|
|
|
"0x00000000000000000000000000000000000000000000000000000000000000A1"
|
|
|
|
"0x00000000000000000000000000000000000000000000000000000000000000B1"
|
|
|
|
code:
|
|
|
|
Push1 "0x23"
|
|
|
|
CallDataLoad
|
|
|
|
stack: "0x00000000000000000000000000000000000000000000000000000000B1000000"
|
|
|
|
|
|
|
|
assembler: # CALLDATALOAD OP
|
|
|
|
title: "CALLDATALOAD_5"
|
|
|
|
data:
|
|
|
|
"0x00000000000000000000000000000000000000000000000000000000000000A1"
|
|
|
|
"0x00000000000000000000000000000000000000000000000000000000000000B1"
|
|
|
|
code:
|
|
|
|
Push1 "0x3F"
|
|
|
|
CallDataLoad
|
|
|
|
stack: "0xB100000000000000000000000000000000000000000000000000000000000000"
|
|
|
|
|
|
|
|
assembler: # CALLDATALOAD OP mal
|
|
|
|
title: "CALLDATALOAD_6"
|
|
|
|
code:
|
|
|
|
CallDataLoad
|
|
|
|
success: false
|
|
|
|
|
|
|
|
assembler: # CALLDATALOAD OP
|
|
|
|
title: "CALLDATALOAD_7"
|
|
|
|
data:
|
|
|
|
"0x00000000000000000000000000000000000000000000000000000000000000A1"
|
|
|
|
"0x00000000000000000000000000000000000000000000000000000000000000B1"
|
|
|
|
code:
|
|
|
|
Push1 "0x40"
|
|
|
|
CallDataLoad
|
|
|
|
stack: "0x00"
|
|
|
|
|
|
|
|
assembler: # CALLDATACOPY OP
|
|
|
|
title: "CALLDATACOPY_1"
|
|
|
|
data:
|
|
|
|
"0x00000000000000000000000000000000000000000000000000000000000000A1"
|
|
|
|
"0x00000000000000000000000000000000000000000000000000000000000000B1"
|
|
|
|
code:
|
|
|
|
Push1 "0x20"
|
|
|
|
Push1 "0x00"
|
|
|
|
Push1 "0x00"
|
|
|
|
CallDataCopy
|
|
|
|
memory: "0x00000000000000000000000000000000000000000000000000000000000000A1"
|
|
|
|
|
|
|
|
assembler: # CALLDATACOPY OP
|
|
|
|
title: "CALLDATACOPY_2"
|
|
|
|
data:
|
|
|
|
"0x00000000000000000000000000000000000000000000000000000000000000A1"
|
|
|
|
"0x00000000000000000000000000000000000000000000000000000000000000B1"
|
|
|
|
code:
|
|
|
|
Push1 "0x40"
|
|
|
|
Push1 "0x00"
|
|
|
|
Push1 "0x00"
|
|
|
|
CallDataCopy
|
|
|
|
memory:
|
|
|
|
"0x00000000000000000000000000000000000000000000000000000000000000A1"
|
|
|
|
"0x00000000000000000000000000000000000000000000000000000000000000B1"
|
|
|
|
|
|
|
|
assembler: # CALLDATACOPY OP
|
|
|
|
title: "CALLDATACOPY_3"
|
|
|
|
data:
|
|
|
|
"0x00000000000000000000000000000000000000000000000000000000000000A1"
|
|
|
|
"0x00000000000000000000000000000000000000000000000000000000000000B1"
|
|
|
|
code:
|
|
|
|
Push1 "0x40"
|
|
|
|
Push1 "0x04"
|
|
|
|
Push1 "0x00"
|
|
|
|
CallDataCopy
|
|
|
|
memory:
|
|
|
|
"0x000000000000000000000000000000000000000000000000000000A100000000"
|
|
|
|
"0x000000000000000000000000000000000000000000000000000000B100000000"
|
|
|
|
|
|
|
|
assembler: # CALLDATACOPY OP
|
|
|
|
title: "CALLDATACOPY_4"
|
|
|
|
data:
|
|
|
|
"0x00000000000000000000000000000000000000000000000000000000000000A1"
|
|
|
|
"0x00000000000000000000000000000000000000000000000000000000000000B1"
|
|
|
|
code:
|
|
|
|
Push1 "0x40"
|
|
|
|
Push1 "0x00"
|
|
|
|
Push1 "0x04"
|
|
|
|
CallDataCopy
|
|
|
|
memory:
|
|
|
|
"0x0000000000000000000000000000000000000000000000000000000000000000"
|
|
|
|
"0x000000A100000000000000000000000000000000000000000000000000000000"
|
|
|
|
"0x000000B100000000000000000000000000000000000000000000000000000000"
|
|
|
|
|
|
|
|
assembler: # CALLDATACOPY OP
|
|
|
|
title: "CALLDATACOPY_5"
|
|
|
|
data:
|
|
|
|
"0x00000000000000000000000000000000000000000000000000000000000000A1"
|
|
|
|
"0x00000000000000000000000000000000000000000000000000000000000000B1"
|
|
|
|
code:
|
|
|
|
Push1 "0x40"
|
|
|
|
Push1 "0x00"
|
|
|
|
Push1 "0x04"
|
|
|
|
CallDataCopy
|
|
|
|
memory:
|
|
|
|
"0x0000000000000000000000000000000000000000000000000000000000000000"
|
|
|
|
"0x000000A100000000000000000000000000000000000000000000000000000000"
|
|
|
|
"0x000000B100000000000000000000000000000000000000000000000000000000"
|
|
|
|
|
|
|
|
assembler: # CALLDATACOPY OP mal
|
|
|
|
title: "CALLDATACOPY_6"
|
|
|
|
data:
|
|
|
|
"0x00000000000000000000000000000000000000000000000000000000000000A1"
|
|
|
|
"0x00000000000000000000000000000000000000000000000000000000000000B1"
|
|
|
|
code:
|
|
|
|
Push1 "0x40"
|
|
|
|
Push1 "0x00"
|
|
|
|
CallDataCopy
|
|
|
|
success: false
|
|
|
|
stack:
|
|
|
|
"0x40"
|
|
|
|
"0x00"
|
|
|
|
|
|
|
|
assembler: # CALLDATACOPY OP mal
|
|
|
|
title: "CALLDATACOPY_7"
|
|
|
|
data:
|
|
|
|
"0x00000000000000000000000000000000000000000000000000000000000000A1"
|
|
|
|
"0x00000000000000000000000000000000000000000000000000000000000000B1"
|
|
|
|
code: "0x6020600073CC0929EB16730E7C14FEFC63006AC2D794C5795637"
|
|
|
|
success: false
|
|
|
|
|
|
|
|
assembler: # ADDRESS OP
|
|
|
|
title: "ADDRESS_1"
|
|
|
|
code:
|
|
|
|
Address
|
2021-10-14 08:00:02 +00:00
|
|
|
stack: "0x000000000000000000000000460121576cc7df020759730751f92bd62fd78dd6"
|
2019-09-21 05:45:23 +00:00
|
|
|
|
|
|
|
assembler: # BALANCE OP
|
|
|
|
title: "BALANCE_1"
|
|
|
|
code:
|
|
|
|
Address
|
|
|
|
Balance
|
2021-10-14 08:00:02 +00:00
|
|
|
stack: "0x00000000000000000000000000000000000000000000000000000000000f4434"
|
2019-09-21 05:45:23 +00:00
|
|
|
|
2021-09-22 02:34:13 +00:00
|
|
|
assembler: # EIP2929 BALANCE OP
|
|
|
|
title: "EIP2929 BALANCE_1"
|
|
|
|
code:
|
|
|
|
Address
|
|
|
|
Balance
|
2021-10-14 08:00:02 +00:00
|
|
|
stack: "0x00000000000000000000000000000000000000000000000000000000000f4434"
|
2023-03-22 11:18:37 +00:00
|
|
|
fork: Berlin
|
2021-10-14 08:00:02 +00:00
|
|
|
gasused: 102
|
2021-09-22 02:34:13 +00:00
|
|
|
|
2019-09-21 05:45:23 +00:00
|
|
|
assembler: # ORIGIN OP
|
|
|
|
title: "ORIGIN_1"
|
|
|
|
code:
|
|
|
|
Origin
|
2021-10-14 08:00:02 +00:00
|
|
|
stack: "0x0000000000000000000000008aeeda4d805471df9b2a5b0f38a0c3bcba786b"
|
2019-09-21 05:45:23 +00:00
|
|
|
|
|
|
|
assembler: # CALLER OP
|
|
|
|
title: "CALLER_1"
|
|
|
|
code:
|
|
|
|
Caller
|
2021-10-14 08:00:02 +00:00
|
|
|
stack: "0x0000000000000000000000008aeeda4d805471df9b2a5b0f38a0c3bcba786b"
|
2019-09-21 05:45:23 +00:00
|
|
|
|
|
|
|
assembler: # CALLVALUE OP
|
|
|
|
title: "CALLVALUE_1"
|
|
|
|
code:
|
|
|
|
CallValue
|
2021-10-14 08:00:02 +00:00
|
|
|
stack: "0x01f4"
|
2019-09-21 05:45:23 +00:00
|
|
|
|
|
|
|
assembler: # SHA3 OP
|
|
|
|
title: "SHA3_1"
|
|
|
|
code:
|
|
|
|
Push1 "0x01"
|
|
|
|
Push1 "0x00"
|
|
|
|
Mstore8
|
|
|
|
Push1 "0x01"
|
|
|
|
Push1 "0x00"
|
|
|
|
Sha3
|
|
|
|
stack: "0x5FE7F977E71DBA2EA1A68E21057BEEBB9BE2AC30C6410AA38D4F3FBE41DCFFD2"
|
|
|
|
memory: "0x0100000000000000000000000000000000000000000000000000000000000000"
|
|
|
|
|
|
|
|
assembler: # SHA3 OP
|
|
|
|
title: "SHA3_2"
|
|
|
|
code:
|
|
|
|
Push2 "0x0201"
|
|
|
|
Push1 "0x00"
|
|
|
|
Mstore
|
|
|
|
Push1 "0x02"
|
|
|
|
Push1 "0x1E"
|
|
|
|
Sha3
|
|
|
|
stack: "0x114A3FE82A0219FCC31ABD15617966A125F12B0FD3409105FC83B487A9D82DE4"
|
|
|
|
memory: "0x0000000000000000000000000000000000000000000000000000000000000201"
|
|
|
|
|
|
|
|
assembler: # SHA3 OP mal
|
|
|
|
title: "SHA3_3"
|
|
|
|
code:
|
|
|
|
Push2 "0x0201"
|
|
|
|
Push1 "0x00"
|
|
|
|
Mstore
|
|
|
|
Push1 "0x02"
|
|
|
|
Sha3
|
|
|
|
success: false
|
|
|
|
stack: "0x02"
|
|
|
|
memory: "0x0000000000000000000000000000000000000000000000000000000000000201"
|
|
|
|
|
|
|
|
assembler: # BLOCKHASH OP
|
|
|
|
title: "BLOCKHASH_1"
|
|
|
|
code:
|
2021-10-14 08:00:02 +00:00
|
|
|
Push1 "0x00"
|
2019-09-21 05:45:23 +00:00
|
|
|
Blockhash
|
2023-03-22 11:18:37 +00:00
|
|
|
stack: "0xc3bd2d00745c03048a5616146a96f5ff78e54efb9e5b04af208cdaff6f3830ee"
|
2019-09-21 05:45:23 +00:00
|
|
|
|
|
|
|
# current block coinbase/miner
|
|
|
|
assembler: # COINBASE OP
|
|
|
|
title: "COINBASE_1"
|
|
|
|
code:
|
|
|
|
Coinbase
|
|
|
|
stack: "0x000000000000000000000000bb7b8287f3f0a933474a79eae42cbca977791171"
|
|
|
|
|
|
|
|
# current block timestamp
|
|
|
|
assembler: # TIMESTAMP OP
|
|
|
|
title: "TIMESTAMP_1"
|
|
|
|
code:
|
|
|
|
TimeStamp
|
2023-03-22 11:18:37 +00:00
|
|
|
stack: "0x0000000000000000000000000000000000000000000000000000000000001234"
|
2019-09-21 05:45:23 +00:00
|
|
|
|
|
|
|
# current block number
|
|
|
|
assembler: # NUMBER OP
|
|
|
|
title: "NUMBER_1"
|
|
|
|
code:
|
|
|
|
Number
|
2021-10-14 08:00:02 +00:00
|
|
|
stack: "0x0000000000000000000000000000000000000000000000000000000000000001"
|
2019-09-21 05:45:23 +00:00
|
|
|
|
|
|
|
# current difficulty
|
|
|
|
assembler: # DIFFICULTY OP
|
|
|
|
title: "DIFFICULTY_1"
|
|
|
|
code:
|
|
|
|
Difficulty
|
2023-03-22 11:18:37 +00:00
|
|
|
stack: "0x00000000000000000000000000000000000000000000000000000000000003eb"
|
2019-09-21 05:45:23 +00:00
|
|
|
|
2021-10-14 08:00:02 +00:00
|
|
|
# tx gas price
|
2019-09-21 05:45:23 +00:00
|
|
|
assembler: # GASPRICE OP
|
|
|
|
title: "GASPRICE_1"
|
|
|
|
code:
|
|
|
|
GasPrice
|
2021-10-14 08:00:02 +00:00
|
|
|
stack: "0x0000000000000000000000000000000000000000000000000000000000000001"
|
2019-09-21 05:45:23 +00:00
|
|
|
|
2021-10-14 08:00:02 +00:00
|
|
|
# gas remaining
|
2019-09-21 05:45:23 +00:00
|
|
|
assembler: # GAS OP
|
|
|
|
title: "GAS_1"
|
|
|
|
code:
|
|
|
|
Gas
|
|
|
|
stack: "0x000000000000000000000000000000000000000000000000000000001dcd64fe"
|
|
|
|
|
2021-10-14 08:00:02 +00:00
|
|
|
# block gas limit
|
2019-09-21 05:45:23 +00:00
|
|
|
assembler: # GASLIMIT OP
|
|
|
|
title: "GASLIMIT_1"
|
|
|
|
code:
|
|
|
|
GasLimit
|
2021-10-14 08:00:02 +00:00
|
|
|
stack: "0x00000000000000000000000000000000000000000000000000000000000186a0"
|
2019-09-21 05:45:23 +00:00
|
|
|
|
|
|
|
assembler: # INVALID OP
|
|
|
|
title: "INVALID_1"
|
|
|
|
code: "0x60012F6002"
|
|
|
|
stack: "0x0000000000000000000000000000000000000000000000000000000000000001"
|
|
|
|
success: false
|
2021-09-22 02:34:13 +00:00
|
|
|
|
|
|
|
when isMainModule:
|
|
|
|
opCustomMain()
|