Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(fw,tests): Fixes to EOF #513

Merged
merged 25 commits into from
Apr 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
d135808
refactor(fw): compute_create3_address
marioevz Apr 17, 2024
f7c9abd
fix(tests): tox
marioevz Apr 17, 2024
9b21dfe
refactor(fw): eof_v1: use pydantic
marioevz Apr 17, 2024
d382a5d
fix(fw): tpx
marioevz Apr 17, 2024
2aaade1
fix(fw): RJUMPV custom dataportion parser
marioevz Apr 17, 2024
7d268fc
fix(tests): eofv1: RJUMPI calls
marioevz Apr 17, 2024
37757b8
new(fw): RJUMPV unit test
marioevz Apr 17, 2024
0920f36
feat(fw): subscriptable opcodes
marioevz Apr 17, 2024
b28a08f
fix(fw): Opcode add, mul
marioevz Apr 17, 2024
0882c4c
fix(tests): test hardcoding bytecode of initcode
marioevz Apr 17, 2024
9636ce6
fix(fw): fix
marioevz Apr 17, 2024
8377a6f
fix(tests): eof: fix RJUMP*, CALLF data portions
marioevz Apr 17, 2024
cb0ff1a
hack(fw): Add str as allowed EOF exception
marioevz Apr 17, 2024
e9a3030
fix(tests): eof: fix test_execution_function.py
marioevz Apr 17, 2024
650f1b9
changelog
marioevz Apr 17, 2024
7510998
chore: add unknown words to dictionary
danceratopz Apr 18, 2024
ff9e23d
fetch exceptions with evmone
winsvega Apr 18, 2024
469b834
eof .py test example
winsvega Apr 18, 2024
bdd115b
fix(fw): add unchecked_stack opcode property (CALLF)
marioevz Apr 18, 2024
3bba0b8
refactor(fw): eof: refactor and add section creation helpers
marioevz Apr 18, 2024
d8ee6f0
fix: tox
marioevz Apr 18, 2024
f0d5000
fix(tests): eof: refactor
marioevz Apr 18, 2024
b77576a
refactor(tests): replace Section(kind=, with Section.Code, Section.Data
marioevz Apr 18, 2024
e7a4e06
fix(fw): eof: consistent magic, version, and header terminator types.
marioevz Apr 18, 2024
f9a8609
fix(fw): eof: proper magic
marioevz Apr 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Test fixtures for use by clients are available for each release on the [Github r
- ✨ Add Macro enum that represents byte sequence of Op instructions ([#457](https://github.com/ethereum/execution-spec-tests/pull/457))
- ✨ Number of parameters used to call opcodes (to generate bytecode) is now checked ([#492](https://github.com/ethereum/execution-spec-tests/pull/492)).
- ✨ Libraries have been refactored to use `pydantic` for type checking in most test types ([#486](https://github.com/ethereum/execution-spec-tests/pull/486), [#501](https://github.com/ethereum/execution-spec-tests/pull/501), [#508](https://github.com/ethereum/execution-spec-tests/pull/508)).
- ✨ Opcodes are now subscriptable and it's used to define the data portion of the opcode: `Op.PUSH1(1) == Op.PUSH1[1] == b"\x60\x01"` ([#513](https://github.com/ethereum/execution-spec-tests/pull/513))

### 🔧 EVM Tools

Expand Down
21 changes: 8 additions & 13 deletions src/ethereum_test_tools/common/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,22 +71,17 @@ def copy_opcode_cost(length: int) -> int:
return 3 + (ceiling_division(length, 32) * 3) + cost_memory_bytes(length, 0)


def compute_create3_address(address: str | int, salt: int, init_container: bytes) -> str:
def compute_create3_address(
address: FixedSizeBytesConvertible,
salt: FixedSizeBytesConvertible,
init_container: BytesConvertible,
) -> Address:
"""
Compute address of the resulting contract created using the `CREATE2`
Compute address of the resulting contract created using the `CREATE3`
opcode.
"""
ff = bytes([0xFF])
if type(address) is str:
if address.startswith("0x"):
address = address[2:]
address_bytes = bytes.fromhex(address)
elif type(address) is int:
address_bytes = address.to_bytes(length=20, byteorder="big")
salt_bytes = salt.to_bytes(length=32, byteorder="big")
initcode_hash = keccak256(init_container)
hash = keccak256(ff + address_bytes + salt_bytes + initcode_hash)
return "0x" + hash[-20:].hex()
hash = keccak256(b"\xff" + Address(address) + Hash(salt) + keccak256(Bytes(init_container)))
return Address(hash[-20:])


def eip_2028_transaction_data_cost(data: BytesConvertible) -> int:
Expand Down
8 changes: 6 additions & 2 deletions src/ethereum_test_tools/eof/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,20 @@
EVM Object Format generic constants.
Applicable to all EOF versions.
"""
EOF_MAGIC = bytes([0])
EOF_MAGIC = b"\xef\x00"
"""
The second byte found on every EOF formatted contract, which was chosen to
avoid clashes with three contracts which were deployed on Mainnet.
"""
EOF_HEADER_TERMINATOR = bytes([0])
EOF_HEADER_TERMINATOR = b"\x00"
"""
Byte that terminates the header of the EOF format.
"""
LATEST_EOF_VERSION = 1
"""
Latest existing EOF version.
"""
VERSION_BYTE_LENGTH = 1
"""
Length of the version byte.
"""
Loading
Loading