Skip to content

Commit

Permalink
clean up opcodes
Browse files Browse the repository at this point in the history
  • Loading branch information
pacrob committed Jan 10, 2025
1 parent e658662 commit a011f44
Showing 1 changed file with 23 additions and 76 deletions.
99 changes: 23 additions & 76 deletions tests/frontier/opcodes/test_calldatacopy.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"""test `CALLDATACOPY` opcode."""

from re import M

import pytest

from ethereum_test_forks import Fork
Expand All @@ -15,52 +17,35 @@
(
(
Op.CALLDATACOPY(dest_offset=0, offset=1, size=2)
+ Op.PUSH1[0x0]
+ Op.MLOAD
+ Op.PUSH1[0x0]
+ Op.SSTORE
+ Op.SSTORE(key=0x0, value=Op.MLOAD(offset=0))
+ Op.RETURN(offset=0, size=Op.MSIZE)
),
b"\x00",
Account(
storage={
0x00: 0x3456000000000000000000000000000000000000000000000000000000000000
}
storage={0x00: 0x3456000000000000000000000000000000000000000000000000000000000000}
),
Account(
storage={
0x00: 0x3456000000000000000000000000000000000000000000000000000000000000
}
storage={0x00: 0x3456000000000000000000000000000000000000000000000000000000000000}
),
),
(
(
Op.CALLDATACOPY(dest_offset=0, offset=1, size=1)
+ Op.PUSH1[0x0]
+ Op.MLOAD
+ Op.PUSH1[0x0]
+ Op.SSTORE
+ Op.SSTORE(key=0x0, value=Op.MLOAD(offset=0))
+ Op.RETURN(offset=0, size=Op.MSIZE)
),
b"\x01",
Account(
storage={
0x00: 0x3400000000000000000000000000000000000000000000000000000000000000
},
storage={0x00: 0x3400000000000000000000000000000000000000000000000000000000000000},
),
Account(
storage={
0x00: 0x3400000000000000000000000000000000000000000000000000000000000000
},
storage={0x00: 0x3400000000000000000000000000000000000000000000000000000000000000},
),
),
(
(
Op.CALLDATACOPY(dest_offset=0, offset=1, size=0)
+ Op.PUSH1[0x0]
+ Op.MLOAD
+ Op.PUSH1[0x0]
+ Op.SSTORE
+ Op.SSTORE(key=0x0, value=Op.MLOAD(offset=0))
+ Op.RETURN(offset=0, size=Op.MSIZE)
),
b"\x02",
Expand All @@ -74,10 +59,7 @@
(
(
Op.CALLDATACOPY(dest_offset=0, offset=0, size=0)
+ Op.PUSH1[0x0]
+ Op.MLOAD
+ Op.PUSH1[0x0]
+ Op.SSTORE
+ Op.SSTORE(key=0x0, value=Op.MLOAD(offset=0))
+ Op.RETURN(offset=0, size=Op.MSIZE)
),
b"\x03",
Expand All @@ -95,10 +77,7 @@
offset=0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFA,
size=0xFF,
)
+ Op.PUSH1[0x0]
+ Op.MLOAD
+ Op.PUSH1[0x0]
+ Op.SSTORE
+ Op.SSTORE(key=0x0, value=Op.MLOAD(offset=0))
+ Op.RETURN(offset=0, size=Op.MSIZE)
),
b"\x04",
Expand All @@ -112,48 +91,32 @@
offset=0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFA,
size=0x9,
)
+ Op.PUSH1[0x0]
+ Op.MLOAD
+ Op.PUSH1[0x0]
+ Op.SSTORE
+ Op.SSTORE(key=0x0, value=Op.MLOAD(offset=0))
+ Op.RETURN(offset=0, size=Op.MSIZE)
),
b"\x05",
Account(storage={0x00: 0x00}),
Account(storage={0x00: 0x00}),
),
(
(
Op.PUSH1[0x1]
+ Op.PUSH1[0x1]
+ Op.SSTORE
+ Op.PUSH1[0x1]
+ Op.PUSH1[0x2]
+ Op.CALLDATACOPY
),
(Op.SSTORE(key=0x1, value=0x1) + Op.PUSH1[0x1] + Op.PUSH1[0x2] + Op.CALLDATACOPY),
b"\x10",
Account(storage={0x01: 0x00}),
None,
),
(
(
Op.PUSH1[0x5]
+ Op.JUMP
Op.JUMP(pc=0x5)
+ Op.JUMPDEST
+ Op.STOP
+ Op.JUMPDEST
+ Op.MSTORE8(offset=0x1F, value=0x42)
+ Op.CALLDATACOPY(dest_offset=0x1F, offset=0x0, size=0x103)
+ Op.PUSH1[0x0]
+ Op.MLOAD
+ Op.MLOAD(offset=0x0)
+ Op.DUP1
+ Op.PUSH1[0x60]
+ Op.EQ
+ Op.PUSH1[0x3]
+ Op.JUMPI
+ Op.PUSH5[0xBADC0FFEE]
+ Op.PUSH1[0xFF]
+ Op.SSTORE
+ Op.JUMPI(pc=0x3, condition=Op.EQ)
+ Op.SSTORE(key=0xFF, value=0xBADC0FFEE)
),
b"\x11",
Account(storage={0xFF: 0xBADC0FFEE}),
Expand Down Expand Up @@ -188,29 +151,13 @@ def test_calldatacopy(
code_address = pre.deploy_contract(code)
to = pre.deploy_contract(
code=(
Op.PUSH17[0x1234567890ABCDEF01234567890ABCDEF0]
+ Op.PUSH1[0x0]
+ Op.MSTORE
+ Op.PUSH1[0x40]
+ Op.PUSH1[0x20]
+ Op.PUSH1[0x10]
+ Op.PUSH1[0xF]
+ Op.PUSH1[0x0]
+ Op.PUSH1[0x4]
+ Op.CALLDATALOAD
+ Op.PUSH2[0x1000]
+ Op.ADD
+ Op.PUSH3[0xFFFFFF]
+ Op.CALL
Op.MSTORE(offset=0x0, value=0x1234567890ABCDEF01234567890ABCDEF0)
+ Op.CALL(
0xFFFFFF, Op.ADD(0x1000, Op.CALLDATALOAD(offset=0x4)), 0x0, 0xF, 0x10, 0x20, 0x40
)
+ Op.POP
+ Op.PUSH1[0x20]
+ Op.MLOAD
+ Op.PUSH1[0x0]
+ Op.SSTORE
+ Op.PUSH1[0x40]
+ Op.MLOAD
+ Op.PUSH1[0x1]
+ Op.SSTORE
+ Op.SSTORE(key=0x0, value=Op.MLOAD(offset=0x20))
+ Op.SSTORE(key=0x1, value=Op.MLOAD(offset=0x40))
+ Op.STOP
),
nonce=0,
Expand Down

0 comments on commit a011f44

Please sign in to comment.