Skip to content

Commit

Permalink
new(tests): extend extcode execution test
Browse files Browse the repository at this point in the history
Extend execution test of legacy invoking `EXTCODE*` instruction on EOF
with the case from ethereum/tests.
  • Loading branch information
chfast committed Oct 24, 2024
1 parent 247c312 commit 46ebf43
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
19 changes: 11 additions & 8 deletions tests/osaka/eip7692_eof_v1/eip3540_eof_v1/test_extcode.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ def test_legacy_calls_eof_sstore(
):
"""Test EXTCODE* opcodes calling EOF and legacy contracts"""
env = Environment()
address_eof_contract = pre.deploy_contract(
Container(
sections=[
Section.Code(
code=Op.RJUMP[0] + Op.STOP,
)
]
)
eof_code = Container(
sections=[
Section.Code(
code=Op.RJUMP[0] + Op.STOP,
)
]
)
assert len(eof_code) == 23
address_eof_contract = pre.deploy_contract(eof_code)
legacy_code = Op.PUSH1(2) + Op.JUMPDEST + Op.STOP
address_legacy_contract = pre.deploy_contract(legacy_code)

Expand All @@ -50,6 +50,9 @@ def test_legacy_calls_eof_sstore(
+ Op.SSTORE(storage_test.store_next(2), Op.EXTCODESIZE(address_eof_contract))
+ Op.EXTCODECOPY(address_eof_contract, 0x20, 0, 6)
+ Op.SSTORE(storage_test.store_next(b"\xef" + (b"\0" * 31)), Op.MLOAD(0x20))
+ Op.MSTORE(0x40, b"\xcc" * 32) # clobber memory slot
+ Op.EXTCODECOPY(address_eof_contract, 0x40, len(eof_code) - 4, 8) # out-of-bounds "read"
+ Op.SSTORE(storage_test.store_next(b"\xcc" * 24), Op.MLOAD(0x40))
+ Op.SSTORE(
storage_test.store_next(keccak256(b"\xef\x00")),
Op.EXTCODEHASH(address_eof_contract),
Expand Down
6 changes: 3 additions & 3 deletions tests/osaka/eip7692_eof_v1/eof_tracker.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@
### Execution

- [ ] Execution of EOF contracts (ethereum/tests: src/EIPTestsFiller/StateTests/stEOF/stEIP3540/EOF1_ExecutionFiller.yml)
- [ ] Legacy executing EXTCODESIZE of EOF contract (ethereum/tests: src/EIPTestsFiller/StateTests/stEOF/stEIP3540/EOF1_ExecutionFiller.yml)
- [ ] Legacy executing EXTCODEHASH of EOF contract (ethereum/tests: src/EIPTestsFiller/StateTests/stEOF/stEIP3540/EOF1_ExecutionFiller.yml)
- [ ] Legacy executing EXTCODECOPY of EOF contract (ethereum/tests: src/EIPTestsFiller/StateTests/stEOF/stEIP3540/EOF1_ExecutionFiller.yml)
- [x] Legacy executing EXTCODESIZE of EOF contract ([`tests/osaka/eip7692_eof_v1/eip3540_eof_v1/test_extcode.py::test_legacy_calls_eof_sstore`](./eip3540_eof_v1/test_extcode/test_legacy_calls_eof_sstore.md))
- [x] Legacy executing EXTCODEHASH of EOF contract ([`tests/osaka/eip7692_eof_v1/eip3540_eof_v1/test_extcode.py::test_legacy_calls_eof_sstore`](./eip3540_eof_v1/test_extcode/test_legacy_calls_eof_sstore.md))
- [x] Legacy executing EXTCODECOPY of EOF contract ([`tests/osaka/eip7692_eof_v1/eip3540_eof_v1/test_extcode.py::test_legacy_calls_eof_sstore`](./eip3540_eof_v1/test_extcode/test_legacy_calls_eof_sstore.md))
- [ ] `*CALLs` from legacy contracts to EOF contracts (ethereum/tests: src/EIPTestsFiller/StateTests/stEOF/stEIP3540/EOF1_CallsFiller.yml)
- [ ] `EXT*CALLs` from EOF to legacy contracts (ethereum/tests: src/EIPTestsFiller/StateTests/stEOF/stEIP3540/EOF1_CallsFiller.yml)
- [ ] EXTDELEGATECALL from EOF to EOF contract (ethereum/tests: src/EIPTestsFiller/StateTests/stEOF/stEIP3540/EOF1_CallsFiller.yml)
Expand Down

0 comments on commit 46ebf43

Please sign in to comment.