Skip to content

Commit 09607ac

Browse files
spencer-tbmarioevz
andcommitted
new(tests): EIP-2935 - Update tests to recent spec change (#585)
* chore(fw): create contracts folder for bin files. * feat(fw): remove history storage contract. * feat(tests): update eip2935 transtion tests to new spec. * typo * fix(forks): History contract * fix(tests): nits * fix(tests): HISTORY_STORAGE_ADDRESS spec update * fix(tests): refactor transition tests, helper function, add post fork test * fix(tests): logic fixes * fix * fix: ref spec sha * feat(fw): Add `storage.canary()` * new(tests): add invalid block number requests * changelog --------- Co-authored-by: Mario Vega <[email protected]>
1 parent 3e79581 commit 09607ac

File tree

11 files changed

+263
-99
lines changed

11 files changed

+263
-99
lines changed

docs/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Test fixtures for use by clients are available for each release on the [Github r
1717
- ✨ Add tests for [EIP-6110: Supply validator deposits on chain](https://eips.ethereum.org/EIPS/eip-6110) ([#530](https://github.com/ethereum/execution-spec-tests/pull/530)).
1818
- ✨ Add tests for [EIP-7002: Execution layer triggerable withdrawals](https://eips.ethereum.org/EIPS/eip-7002) ([#530](https://github.com/ethereum/execution-spec-tests/pull/530)).
1919
- ✨ Add tests for [EIP-7685: General purpose execution layer requests](https://eips.ethereum.org/EIPS/eip-7685) ([#530](https://github.com/ethereum/execution-spec-tests/pull/530)).
20-
- ✨ Add tests for [EIP-2935: Serve historical block hashes from state](https://eips.ethereum.org/EIPS/eip-2935) ([#564](https://github.com/ethereum/execution-spec-tests/pull/564)).
20+
- ✨ Add tests for [EIP-2935: Serve historical block hashes from state](https://eips.ethereum.org/EIPS/eip-2935) ([#564](https://github.com/ethereum/execution-spec-tests/pull/564), [#585](https://github.com/ethereum/execution-spec-tests/pull/585)).
2121
- ✨ Add tests for [EIP-4200: EOF - Static relative jumps](https://eips.ethereum.org/EIPS/eip-4200) ([#581](https://github.com/ethereum/execution-spec-tests/pull/581)).
2222
- ✨ Add tests for [EIP-7069: EOF - Revamped CALL instructions](https://eips.ethereum.org/EIPS/eip-7069) ([#595](https://github.com/ethereum/execution-spec-tests/pull/595)).
2323
- 🐞 Fix typos in self-destruct collision test from erroneous pytest parametrization ([#608](https://github.com/ethereum/execution-spec-tests/pull/608)).

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ ethereum_test_tools =
5151
py.typed
5252
ethereum_test_forks =
5353
py.typed
54-
forks/*.bin
54+
forks/contracts/*.bin
5555
evm_transition_tool =
5656
py.typed
5757
pytest_plugins =
100 Bytes
Binary file not shown.

src/ethereum_test_forks/forks/forks.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,7 @@ def pre_allocation_blockchain(cls) -> Mapping:
542542
storage[i] = next_hash
543543
next_hash = sha256(next_hash + next_hash).digest()
544544

545-
with open(CURRENT_FOLDER / "deposit_contract.bin", mode="rb") as f:
545+
with open(CURRENT_FOLDER / "contracts" / "deposit_contract.bin", mode="rb") as f:
546546
new_allocation.update(
547547
{
548548
0x00000000219AB540356CBB839CBE05303D7705FA: {
@@ -554,7 +554,7 @@ def pre_allocation_blockchain(cls) -> Mapping:
554554
)
555555

556556
# Add the withdrawal request contract
557-
with open(CURRENT_FOLDER / "withdrawal_request.bin", mode="rb") as f:
557+
with open(CURRENT_FOLDER / "contracts" / "withdrawal_request.bin", mode="rb") as f:
558558
new_allocation.update(
559559
{
560560
0x00A3CA265EBCB825B45F985A16CEFB49958CE017: {
@@ -565,10 +565,10 @@ def pre_allocation_blockchain(cls) -> Mapping:
565565
)
566566

567567
# Add the history storage contract
568-
with open(CURRENT_FOLDER / "history_contract.bin", mode="rb") as f:
568+
with open(CURRENT_FOLDER / "contracts" / "history_contract.bin", mode="rb") as f:
569569
new_allocation.update(
570570
{
571-
0x25A219378DAD9B3503C8268C9CA836A52427A4FB: {
571+
0x0AAE40965E6800CD9B1F4B05FF21581047E3F91E: {
572572
"nonce": 1,
573573
"code": f.read(),
574574
}
-54 Bytes
Binary file not shown.

src/ethereum_test_tools/common/types.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,13 @@ def must_be_equal(self, address: Address, other: "Storage | None"):
324324
elif other[key] != 0:
325325
raise Storage.KeyValueMismatch(address=address, key=key, want=0, got=other[key])
326326

327+
def canary(self) -> "Storage":
328+
"""
329+
Returns a canary storage filled with non-zero values where the current storage expects
330+
zero values, to guarantee that the test overwrites the storage.
331+
"""
332+
return Storage({key: HashInt(0xBA5E) for key in self.keys() if self[key] == 0})
333+
327334

328335
class Account(CopyValidateModel):
329336
"""

tests/prague/eip2935_historical_block_hashes_from_state/spec.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
22
Defines EIP-2935 specification constants and functions.
33
"""
4+
45
from dataclasses import dataclass
56

67

@@ -14,7 +15,7 @@ class ReferenceSpec:
1415
version: str
1516

1617

17-
ref_spec_2935 = ReferenceSpec("EIPS/eip-2935.md", "3ab311ccd6029c080fb2a8b9615d493dfc093377")
18+
ref_spec_2935 = ReferenceSpec("EIPS/eip-2935.md", "68d54a80a4f5b9c0cf4ae3a10586d63ef221de36")
1819

1920

2021
@dataclass(frozen=True)
@@ -24,6 +25,7 @@ class Spec:
2425
https://eips.ethereum.org/EIPS/eip-2935
2526
"""
2627

27-
HISTORY_STORAGE_ADDRESS = 0x25A219378DAD9B3503C8268C9CA836A52427A4FB
28+
FORK_TIMESTAMP = 15_000
29+
HISTORY_STORAGE_ADDRESS = 0x0AAE40965E6800CD9B1F4B05FF21581047E3F91E
2830
HISTORY_SERVE_WINDOW = 8192
2931
BLOCKHASH_OLD_WINDOW = 256

0 commit comments

Comments
 (0)