Skip to content

Commit 5ee7a97

Browse files
committed
refactor(tests/prague): use ethereum_test_addresses
1 parent 47a3646 commit 5ee7a97

File tree

6 files changed

+33
-22
lines changed

6 files changed

+33
-22
lines changed

tests/prague/eip2537_bls_12_381_precompiles/spec.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
from dataclasses import dataclass
66
from typing import Callable, List, Sized, SupportsBytes, Tuple
77

8+
from ethereum_test_addresses import Precompile
9+
810
from .helpers import current_python_script_directory
911

1012

@@ -122,15 +124,15 @@ class Spec:
122124
"""
123125

124126
# Addresses
125-
G1ADD = 0x0B
126-
G1MUL = 0x0C
127-
G1MSM = 0x0D
128-
G2ADD = 0x0E
129-
G2MUL = 0x0F
130-
G2MSM = 0x10
131-
PAIRING = 0x11
132-
MAP_FP_TO_G1 = 0x12
133-
MAP_FP2_TO_G2 = 0x13
127+
G1ADD = Precompile.BLS_12_381_G1_ADD
128+
G1MUL = Precompile.BLS_12_381_G1_MUL
129+
G1MSM = Precompile.BLS_12_381_G1_MULTIEXP
130+
G2ADD = Precompile.BLS_12_381_G2_ADD
131+
G2MUL = Precompile.BLS_12_381_G2_MUL
132+
G2MSM = Precompile.BLS_12_381_G2_MULTIEXP
133+
PAIRING = Precompile.BLS_12_381_PAIRING
134+
MAP_FP_TO_G1 = Precompile.BLS_12_381_MAP_FP_TO_G1
135+
MAP_FP2_TO_G2 = Precompile.BLS_12_381_MAP_FP2_TO_G2
134136

135137
# Gas constants
136138
G1ADD_GAS = 500

tests/prague/eip2935_historical_block_hashes_from_state/spec.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
from dataclasses import dataclass
66

7+
from ethereum_test_addresses import SystemContract
8+
79

810
@dataclass(frozen=True)
911
class ReferenceSpec:
@@ -26,6 +28,6 @@ class Spec:
2628
"""
2729

2830
FORK_TIMESTAMP = 15_000
29-
HISTORY_STORAGE_ADDRESS = 0x0AAE40965E6800CD9B1F4B05FF21581047E3F91E
31+
HISTORY_STORAGE_ADDRESS = SystemContract.BLOCK_HISTORY_CONTRACT
3032
HISTORY_SERVE_WINDOW = 8192
3133
BLOCKHASH_OLD_WINDOW = 256

tests/prague/eip6110_deposits/spec.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
"""
44
from dataclasses import dataclass
55

6+
from ethereum_test_addresses import SystemContract
7+
68

79
@dataclass(frozen=True)
810
class ReferenceSpec:
@@ -24,4 +26,4 @@ class Spec:
2426
https://eips.ethereum.org/EIPS/eip-6110
2527
"""
2628

27-
DEPOSIT_CONTRACT_ADDRESS = 0x00000000219AB540356CBB839CBE05303D7705FA
29+
DEPOSIT_CONTRACT_ADDRESS = SystemContract.BEACON_DEPOSIT_CONTRACT

tests/prague/eip7002_el_triggerable_withdrawals/spec.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
from dataclasses import dataclass
77

8+
from ethereum_test_addresses import SYSTEM_ADDRESS, SystemContract
9+
810

911
@dataclass(frozen=True)
1012
class ReferenceSpec:
@@ -30,8 +32,8 @@ class Spec:
3032
out.
3133
"""
3234

33-
WITHDRAWAL_REQUEST_PREDEPLOY_ADDRESS = 0x0000B595F2A73542E60B811C3EB8A231CA3CAAAA
34-
SYSTEM_ADDRESS = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE
35+
WITHDRAWAL_REQUEST_PREDEPLOY_ADDRESS = SystemContract.WITHDRAWAL_REQUESTS_CONTRACT
36+
SYSTEM_ADDRESS = SYSTEM_ADDRESS
3537

3638
EXCESS_WITHDRAWAL_REQUESTS_STORAGE_SLOT = 0
3739
WITHDRAWAL_REQUEST_COUNT_STORAGE_SLOT = 1

tests/prague/eip7251_consolidations/spec.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
from dataclasses import dataclass
66

7+
from ethereum_test_addresses import SYSTEM_ADDRESS, SystemContract
8+
79

810
@dataclass(frozen=True)
911
class ReferenceSpec:
@@ -26,8 +28,8 @@ class Spec:
2628
https://eips.ethereum.org/EIPS/eip-7251#execution-layer
2729
"""
2830

29-
CONSOLIDATION_REQUEST_PREDEPLOY_ADDRESS = 0x000b0cbbCb4A622b212A4c8BF81A3614ceaAbBBB
30-
SYSTEM_ADDRESS = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE
31+
CONSOLIDATION_REQUEST_PREDEPLOY_ADDRESS = SystemContract.CONSOLIDATION_REQUESTS_CONTRACT
32+
SYSTEM_ADDRESS = SYSTEM_ADDRESS
3133

3234
EXCESS_CONSOLIDATION_REQUESTS_STORAGE_SLOT = 0
3335
CONSOLIDATION_REQUEST_COUNT_STORAGE_SLOT = 1

tests/prague/eip7702_set_code_tx/test_set_code_txs.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import pytest
1212
from ethereum.crypto.hash import keccak256
1313

14+
from ethereum_test_addresses import SystemContract
1415
from ethereum_test_tools import (
1516
AccessList,
1617
Account,
@@ -2440,23 +2441,23 @@ def test_set_code_to_system_contract(
24402441

24412442
# Setup the initial storage of the account to mimic the system contract if required
24422443
match system_contract:
2443-
case Address(0x00000000219AB540356CBB839CBE05303D7705FA): # EIP-6110
2444+
case SystemContract.BEACON_DEPOSIT_CONTRACT: # EIP-6110
24442445
# Deposit contract needs specific storage values, so we set them on the account
24452446
auth_signer = pre.fund_eoa(
24462447
auth_account_start_balance, storage=deposit_contract_initial_storage()
24472448
)
2448-
case Address(0x000F3DF6D732807EF1319FB7B8BB8522D0BEAC02): # EIP-4788
2449+
case SystemContract.BEACON_ROOT_HISTORY_CONTRACT: # EIP-4788
24492450
auth_signer = pre.fund_eoa(auth_account_start_balance, storage=Storage({1: 1}))
24502451
case _:
24512452
# Pre-fund without storage
24522453
auth_signer = pre.fund_eoa(auth_account_start_balance)
24532454

24542455
# Fabricate the payload for the system contract
24552456
match system_contract:
2456-
case Address(0x000F3DF6D732807EF1319FB7B8BB8522D0BEAC02): # EIP-4788
2457+
case SystemContract.BEACON_ROOT_HISTORY_CONTRACT: # EIP-4788
24572458
caller_payload = Hash(1)
24582459
caller_code_storage[call_return_data_size_slot] = 32
2459-
case Address(0x00000000219AB540356CBB839CBE05303D7705FA): # EIP-6110
2460+
case SystemContract.BEACON_DEPOSIT_CONTRACT: # EIP-6110
24602461
# Fabricate a valid deposit request to the set-code account
24612462
deposit_request = DepositRequest(
24622463
pubkey=0x01,
@@ -2467,7 +2468,7 @@ def test_set_code_to_system_contract(
24672468
)
24682469
caller_payload = deposit_request.calldata
24692470
call_value = deposit_request.value
2470-
case Address(0x0000B595F2A73542E60B811C3EB8A231CA3CAAAA): # EIP-7002
2471+
case SystemContract.WITHDRAWAL_REQUESTS_CONTRACT: # EIP-7002
24712472
# Fabricate a valid withdrawal request to the set-code account
24722473
withdrawal_request = WithdrawalRequest(
24732474
source_address=0x01,
@@ -2477,7 +2478,7 @@ def test_set_code_to_system_contract(
24772478
)
24782479
caller_payload = withdrawal_request.calldata
24792480
call_value = withdrawal_request.value
2480-
case Address(0x000B0CBBCB4A622B212A4C8BF81A3614CEAABBBB): # EIP-7251
2481+
case SystemContract.CONSOLIDATION_REQUESTS_CONTRACT: # EIP-7251
24812482
# Fabricate a valid consolidation request to the set-code account
24822483
consolidation_request = ConsolidationRequest(
24832484
source_address=0x01,
@@ -2487,7 +2488,7 @@ def test_set_code_to_system_contract(
24872488
)
24882489
caller_payload = consolidation_request.calldata
24892490
call_value = consolidation_request.value
2490-
case Address(0x0AAE40965E6800CD9B1F4B05FF21581047E3F91E): # EIP-2935
2491+
case SystemContract.BLOCK_HISTORY_CONTRACT: # EIP-2935
24912492
caller_payload = Hash(0)
24922493
caller_code_storage[call_return_data_size_slot] = 32
24932494
case _:

0 commit comments

Comments
 (0)