Skip to content

Commit e42007d

Browse files
committed
Merge remote-tracking branch 'upstream/eip-2935-contract-update' into pectra-devnet-5
2 parents c205172 + 5180518 commit e42007d

File tree

8 files changed

+124
-11
lines changed

8 files changed

+124
-11
lines changed

docs/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ Test fixtures for use by clients are available for each release on the [Github r
7171
- 🔀 Update EIP-7251 according to [spec updates](https://github.com/ethereum/EIPs/pull/9127) ([#1024](https://github.com/ethereum/execution-spec-tests/pull/1024))
7272
- 🔀 Update EIP-7002 according to [spec updates](https://github.com/ethereum/EIPs/pull/9119) ([#1024](https://github.com/ethereum/execution-spec-tests/pull/1024))
7373
- ✨ Disable EIP-7742 framework changes for Prague ([#1023](https://github.com/ethereum/execution-spec-tests/pull/1023)).
74+
- 🔀 Update EIP-2935 according to [spec updates](https://github.com/ethereum/EIPs/pull/9144) ([#1046](https://github.com/ethereum/execution-spec-tests/pull/1046))
7475

7576
### 🔧 EVM Tools
7677

Binary file not shown.

src/ethereum_test_forks/forks/forks.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1061,7 +1061,7 @@ def system_contracts(cls, block_number: int = 0, timestamp: int = 0) -> List[Add
10611061
Address(0x00000000219AB540356CBB839CBE05303D7705FA),
10621062
Address(0x0C15F14308530B7CDB8460094BBB9CC28B9AAAAA),
10631063
Address(0x00431F263CE400F4455C2DCF564E53007CA4BBBB),
1064-
Address(0x0AAE40965E6800CD9B1F4B05FF21581047E3F91E),
1064+
Address(0x0F792BE4B0C0CB4DAE440EF133E90C0ECD48CCCC),
10651065
] + super(Prague, cls).system_contracts(block_number, timestamp)
10661066

10671067
@classmethod
@@ -1216,7 +1216,7 @@ def pre_allocation_blockchain(cls) -> Mapping:
12161216
with open(CURRENT_FOLDER / "contracts" / "history_contract.bin", mode="rb") as f:
12171217
new_allocation.update(
12181218
{
1219-
0x0AAE40965E6800CD9B1F4B05FF21581047E3F91E: {
1219+
0x0F792BE4B0C0CB4DAE440EF133E90C0ECD48CCCC: {
12201220
"nonce": 1,
12211221
"code": f.read(),
12221222
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"type": "0x0",
3+
"nonce": "0x0",
4+
"to": null,
5+
"gas": "0x3d090",
6+
"gasPrice": "0xe8d4a51000",
7+
"maxPriorityFeePerGas": null,
8+
"maxFeePerGas": null,
9+
"value": "0x0",
10+
"input": "0x60538060095f395ff33373fffffffffffffffffffffffffffffffffffffffe14604657602036036042575f35600143038111604257611fff81430311604257611fff9006545f5260205ff35b5f5ffd5b5f35611fff60014303065500",
11+
"v": "0x1b",
12+
"r": "0x539",
13+
"s": "0xbaefe09f0109759",
14+
"hash": "0x8c7bd2d3713a0b2bb693463d2a78c4d612ac47dd38ecb74f8996a4b6fc96f03c"
15+
}

tests/prague/eip2935_historical_block_hashes_from_state/spec.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class ReferenceSpec:
1111
version: str
1212

1313

14-
ref_spec_2935 = ReferenceSpec("EIPS/eip-2935.md", "68d54a80a4f5b9c0cf4ae3a10586d63ef221de36")
14+
ref_spec_2935 = ReferenceSpec("EIPS/eip-2935.md", "a04da454a5a6ba86a87bb9e15f811feaff3c849a")
1515

1616

1717
@dataclass(frozen=True)
@@ -22,6 +22,6 @@ class Spec:
2222
"""
2323

2424
FORK_TIMESTAMP = 15_000
25-
HISTORY_STORAGE_ADDRESS = 0x0AAE40965E6800CD9B1F4B05FF21581047E3F91E
26-
HISTORY_SERVE_WINDOW = 8192
25+
HISTORY_STORAGE_ADDRESS = 0x0F792BE4B0C0CB4DAE440EF133E90C0ECD48CCCC
26+
HISTORY_SERVE_WINDOW = 8191
2727
BLOCKHASH_OLD_WINDOW = 256

tests/prague/eip2935_historical_block_hashes_from_state/test_block_hashes.py

Lines changed: 76 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -311,9 +311,9 @@ def test_block_hashes_history(
311311
@pytest.mark.parametrize(
312312
"block_number,reverts",
313313
[
314-
pytest.param(1, False, id="current_block"),
315-
pytest.param(2, False, id="future_block"),
316-
pytest.param(2**64 - 1, False, id="2**64-1"),
314+
pytest.param(1, True, id="current_block"),
315+
pytest.param(2, True, id="future_block"),
316+
pytest.param(2**64 - 1, True, id="2**64-1"),
317317
pytest.param(2**64, True, id="2**64"),
318318
],
319319
)
@@ -337,13 +337,24 @@ def test_invalid_history_contract_calls(
337337
returned_block_hash_slot = storage.store_next(0)
338338
block_hash_opcode_slot = storage.store_next(0)
339339

340+
return_offset = 64
341+
return_size = 32
342+
args_size = 32
343+
340344
# Check the first block outside of the window if any
341345
code = (
342346
Op.MSTORE(0, block_number)
343347
+ Op.SSTORE(
344-
return_code_slot, Op.CALL(Op.GAS, Spec.HISTORY_STORAGE_ADDRESS, 0, 0, 32, 32, 64)
348+
return_code_slot,
349+
Op.CALL(
350+
address=Spec.HISTORY_STORAGE_ADDRESS,
351+
args_offset=0,
352+
args_size=args_size,
353+
ret_offset=return_offset,
354+
ret_size=return_size,
355+
),
345356
)
346-
+ Op.SSTORE(returned_block_hash_slot, Op.MLOAD(32))
357+
+ Op.SSTORE(returned_block_hash_slot, Op.MLOAD(return_offset))
347358
+ Op.SSTORE(block_hash_opcode_slot, Op.BLOCKHASH(block_number))
348359
)
349360
check_contract_address = pre.deploy_contract(code, storage=storage.canary())
@@ -364,3 +375,63 @@ def test_invalid_history_contract_calls(
364375
post=post,
365376
reverts=reverts,
366377
)
378+
379+
380+
@pytest.mark.parametrize(
381+
"args_size,reverts",
382+
[
383+
pytest.param(0, True, id="zero_size"),
384+
pytest.param(33, True, id="too_large"),
385+
pytest.param(31, True, id="too_small"),
386+
],
387+
)
388+
@pytest.mark.valid_from("Prague")
389+
def test_invalid_history_contract_calls_input_size(
390+
blockchain_test: BlockchainTestFiller,
391+
pre: Alloc,
392+
reverts: bool,
393+
args_size: int,
394+
):
395+
"""Test calling the history contract with invalid input sizes."""
396+
storage = Storage()
397+
398+
return_code_slot = storage.store_next(not reverts)
399+
returned_block_hash_slot = storage.store_next(0)
400+
401+
return_offset = 64
402+
return_size = 32
403+
block_number = 0
404+
405+
# Check the first block outside of the window if any
406+
code = (
407+
Op.MSTORE(0, block_number)
408+
+ Op.SSTORE(
409+
return_code_slot,
410+
Op.CALL(
411+
address=Spec.HISTORY_STORAGE_ADDRESS,
412+
args_offset=0,
413+
args_size=args_size,
414+
ret_offset=return_offset,
415+
ret_size=return_size,
416+
),
417+
)
418+
+ Op.SSTORE(returned_block_hash_slot, Op.MLOAD(return_offset))
419+
)
420+
check_contract_address = pre.deploy_contract(code, storage=storage.canary())
421+
422+
txs = [
423+
Transaction(
424+
to=check_contract_address,
425+
gas_limit=10_000_000,
426+
sender=pre.fund_eoa(),
427+
)
428+
]
429+
post = {check_contract_address: Account(storage=storage)}
430+
431+
blocks = [Block(txs=txs)]
432+
blockchain_test(
433+
pre=pre,
434+
blocks=blocks,
435+
post=post,
436+
reverts=reverts,
437+
)
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
"""
2+
abstract: Tests [EIP-2935: Serve historical block hashes from state](https://eips.ethereum.org/EIPS/eip-2935).
3+
Test system contract deployment for [EIP-2935: Serve historical block hashes from state](https://eips.ethereum.org/EIPS/eip-2935).
4+
""" # noqa: E501
5+
6+
from os.path import realpath
7+
from pathlib import Path
8+
9+
from ethereum_test_forks import Prague
10+
from ethereum_test_tools import Address, generate_system_contract_deploy_test
11+
12+
from .spec import Spec, ref_spec_2935
13+
14+
REFERENCE_SPEC_GIT_PATH = ref_spec_2935.git_path
15+
REFERENCE_SPEC_VERSION = ref_spec_2935.version
16+
17+
18+
@generate_system_contract_deploy_test(
19+
fork=Prague,
20+
tx_json_path=Path(realpath(__file__)).parent / "contract_deploy_tx.json",
21+
expected_deploy_address=Address(Spec.HISTORY_STORAGE_ADDRESS),
22+
expected_system_contract_storage=None,
23+
)
24+
def test_system_contract_deployment(*args, **kwargs):
25+
"""Verify deployment of the block hashes system contract."""
26+
yield from []

tests/prague/eip7702_set_code_tx/test_set_code_txs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2654,7 +2654,7 @@ def test_set_code_to_system_contract(
26542654
)
26552655
caller_payload = consolidation_request.calldata
26562656
call_value = consolidation_request.value
2657-
case Address(0x0AAE40965E6800CD9B1F4B05FF21581047E3F91E): # EIP-2935
2657+
case Address(0x0F792BE4B0C0CB4DAE440EF133E90C0ECD48CCCC): # EIP-2935
26582658
caller_payload = Hash(0)
26592659
caller_code_storage[call_return_data_size_slot] = 32
26602660
case _:

0 commit comments

Comments
 (0)