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

new(tests): EIP-2935 - Update tests to recent spec change #585

Merged
Merged
2 changes: 1 addition & 1 deletion docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Test fixtures for use by clients are available for each release on the [Github r
- ✨ 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)).
- ✨ 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)).
- ✨ 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)).
- ✨ 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)).
- ✨ 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)).
- ✨ 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)).
- ✨ 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)).
- 🐞 Fix typos in self-destruct collision test from erroneous pytest parametrization ([#608](https://github.com/ethereum/execution-spec-tests/pull/608)).
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ ethereum_test_tools =
py.typed
ethereum_test_forks =
py.typed
forks/*.bin
forks/contracts/*.bin
evm_transition_tool =
py.typed
pytest_plugins =
Expand Down
Binary file not shown.
8 changes: 4 additions & 4 deletions src/ethereum_test_forks/forks/forks.py
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ def pre_allocation_blockchain(cls) -> Mapping:
storage[i] = next_hash
next_hash = sha256(next_hash + next_hash).digest()

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

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

# Add the history storage contract
marioevz marked this conversation as resolved.
Show resolved Hide resolved
with open(CURRENT_FOLDER / "history_contract.bin", mode="rb") as f:
with open(CURRENT_FOLDER / "contracts" / "history_contract.bin", mode="rb") as f:
new_allocation.update(
{
0x25A219378DAD9B3503C8268C9CA836A52427A4FB: {
0x0AAE40965E6800CD9B1F4B05FF21581047E3F91E: {
"nonce": 1,
"code": f.read(),
}
Expand Down
Binary file removed src/ethereum_test_forks/forks/history_contract.bin
Binary file not shown.
7 changes: 7 additions & 0 deletions src/ethereum_test_tools/common/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,13 @@ def must_be_equal(self, address: Address, other: "Storage | None"):
elif other[key] != 0:
raise Storage.KeyValueMismatch(address=address, key=key, want=0, got=other[key])

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


class Account(CopyValidateModel):
"""
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Defines EIP-2935 specification constants and functions.
"""

from dataclasses import dataclass


Expand All @@ -14,7 +15,7 @@ class ReferenceSpec:
version: str


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


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

HISTORY_STORAGE_ADDRESS = 0x25A219378DAD9B3503C8268C9CA836A52427A4FB
FORK_TIMESTAMP = 15_000
HISTORY_STORAGE_ADDRESS = 0x0AAE40965E6800CD9B1F4B05FF21581047E3F91E
HISTORY_SERVE_WINDOW = 8192
BLOCKHASH_OLD_WINDOW = 256
Loading