Skip to content

Commit cfd16b4

Browse files
feat(execute): Mainnet marked tests (#1511)
* feat(plugins/shared): Add "mainnet" marker * new(tests): EIP-2537 mainnet tests * fix(tests): EIP-2537 file rename * new(tests): EIP-2935 mainnet tests * new(tests): EIP-7623 mainnet tests * new(tests): EIP-6110 mainnet tests * fix(tests): EIP-7623 * new(tests): EIP-7002,7251 mainnet tests * new(tests): EIP-7702: Mainnet tests * fix(tests): tox on EIP-7623 * fix(tests): EIP-7702, extra parametrization * fix(tests): fix small copy-paste error that caused unknown fixture error * fixup: Remove env from all tests --------- Co-authored-by: danceratopz <[email protected]>
1 parent 4212e87 commit cfd16b4

File tree

10 files changed

+529
-1
lines changed

10 files changed

+529
-1
lines changed

src/pytest_plugins/shared/execute_fill.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,10 @@ def pytest_configure(config: pytest.Config):
157157
"markers",
158158
"valid_for_bpo_forks: Marks a test as valid for BPO forks",
159159
)
160+
config.addinivalue_line(
161+
"markers",
162+
"mainnet: Specialty tests crafted for running on mainnet and sanity checking.",
163+
)
160164

161165

162166
@pytest.fixture(scope="function")

tests/prague/eip2537_bls_12_381_precompiles/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ def call_contract_address(pre: Alloc, call_contract_code: Bytecode) -> Address:
167167
@pytest.fixture
168168
def sender(pre: Alloc) -> EOA:
169169
"""Sender of the transaction."""
170-
return pre.fund_eoa(1_000_000_000_000_000_000)
170+
return pre.fund_eoa()
171171

172172

173173
@pytest.fixture
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
"""
2+
abstract: Crafted tests for mainnet of [EIP-2537: Precompile for BLS12-381 curve operations](https://eips.ethereum.org/EIPS/eip-2537)
3+
Crafted tests for mainnet of [EIP-2537: Precompile for BLS12-381 curve operations](https://eips.ethereum.org/EIPS/eip-2537).
4+
""" # noqa: E501
5+
6+
import pytest
7+
8+
from ethereum_test_tools import Alloc, StateTestFiller, Transaction
9+
10+
from .spec import FP, FP2, Scalar, Spec, ref_spec_2537
11+
12+
REFERENCE_SPEC_GIT_PATH = ref_spec_2537.git_path
13+
REFERENCE_SPEC_VERSION = ref_spec_2537.version
14+
15+
pytestmark = [pytest.mark.valid_at("Prague"), pytest.mark.mainnet]
16+
17+
18+
@pytest.mark.parametrize(
19+
"precompile_address,input_data,expected_output,vector_gas_value",
20+
[
21+
pytest.param(
22+
Spec.G1ADD,
23+
Spec.G1 + Spec.INF_G1,
24+
Spec.G1,
25+
None,
26+
id="G1ADD",
27+
),
28+
pytest.param(
29+
Spec.G1MSM,
30+
Spec.G1 + Scalar(1) + Spec.INF_G1 + Scalar(1),
31+
Spec.G1,
32+
None,
33+
id="G1MSM",
34+
),
35+
pytest.param(
36+
Spec.G2ADD,
37+
Spec.G2 + Spec.INF_G2,
38+
Spec.G2,
39+
None,
40+
id="G2ADD",
41+
),
42+
pytest.param(
43+
Spec.G2MSM,
44+
Spec.G2 + Scalar(1) + Spec.INF_G2 + Scalar(1),
45+
Spec.G2,
46+
None,
47+
id="G2MSM",
48+
),
49+
pytest.param(
50+
Spec.PAIRING,
51+
Spec.G1 + Spec.INF_G2,
52+
Spec.PAIRING_TRUE,
53+
None,
54+
id="PAIRING",
55+
),
56+
pytest.param(
57+
Spec.MAP_FP_TO_G1,
58+
FP(
59+
799950832265136997107648781861994410980648980263584507133499364313075404851459407870655748616451882783569609925573 # noqa: E501
60+
),
61+
Spec.INF_G1,
62+
None,
63+
id="fp_map_to_inf",
64+
),
65+
pytest.param(
66+
Spec.MAP_FP2_TO_G2,
67+
FP2(
68+
(
69+
3510328712861478240121438855244276237335901234329585006107499559909114695366216070652508985150831181717984778988906, # noqa: E501
70+
2924545590598115509050131525615277284817672420174395176262156166974132393611647670391999011900253695923948997972401, # noqa: E501
71+
)
72+
),
73+
Spec.INF_G2,
74+
None,
75+
id="fp_map_to_inf",
76+
),
77+
],
78+
)
79+
def test_eip_2537(
80+
state_test: StateTestFiller,
81+
pre: Alloc,
82+
post: dict,
83+
tx: Transaction,
84+
):
85+
"""Test the all precompiles of EIP-2537."""
86+
state_test(
87+
pre=pre,
88+
tx=tx,
89+
post=post,
90+
)
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
"""
2+
abstract: Crafted tests for mainnet of [EIP-2935: Serve historical block hashes from state](https://eips.ethereum.org/EIPS/eip-2935)
3+
Crafted tests for mainnet of [EIP-2935: Serve historical block hashes from state](https://eips.ethereum.org/EIPS/eip-2935).
4+
""" # noqa: E501
5+
6+
import pytest
7+
8+
from ethereum_test_tools import Account, Alloc, Block, BlockchainTestFiller, Transaction
9+
from ethereum_test_tools import Opcodes as Op
10+
11+
from .spec import Spec, ref_spec_2935
12+
13+
REFERENCE_SPEC_GIT_PATH = ref_spec_2935.git_path
14+
REFERENCE_SPEC_VERSION = ref_spec_2935.version
15+
16+
pytestmark = [pytest.mark.valid_at("Prague"), pytest.mark.mainnet]
17+
18+
19+
def test_eip_2935(
20+
blockchain_test: BlockchainTestFiller,
21+
pre: Alloc,
22+
):
23+
"""Test a simple block hash request from EIP-2935 system contract."""
24+
check_block_number = Op.SUB(Op.NUMBER, 1) # Parent block number
25+
check_contract_code = (
26+
Op.MSTORE(0, check_block_number)
27+
+ Op.POP(
28+
Op.CALL(
29+
address=Spec.HISTORY_STORAGE_ADDRESS,
30+
args_offset=0,
31+
args_size=32,
32+
ret_offset=32,
33+
ret_size=32,
34+
)
35+
)
36+
+ Op.SSTORE(0, Op.EQ(Op.MLOAD(32), Op.BLOCKHASH(check_block_number)))
37+
)
38+
check_contract_address = pre.deploy_contract(check_contract_code)
39+
tx = Transaction(
40+
to=check_contract_address,
41+
gas_limit=50_000,
42+
sender=pre.fund_eoa(),
43+
)
44+
block = Block(txs=[tx])
45+
blockchain_test(
46+
pre=pre,
47+
blocks=[block],
48+
post={
49+
check_contract_address: Account(storage={0: 1}),
50+
},
51+
)
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
"""
2+
abstract: Crafted tests for mainnet of [EIP-6110: Supply validator deposits on chain](https://eips.ethereum.org/EIPS/eip-6110)
3+
Crafted tests for mainnet of [EIP-6110: Supply validator deposits on chain](https://eips.ethereum.org/EIPS/eip-6110).
4+
""" # noqa: E501
5+
6+
from typing import List
7+
8+
import pytest
9+
10+
from ethereum_test_tools import (
11+
Alloc,
12+
Block,
13+
BlockchainTestFiller,
14+
)
15+
16+
from .helpers import DepositRequest, DepositTransaction
17+
from .spec import ref_spec_6110
18+
19+
REFERENCE_SPEC_GIT_PATH = ref_spec_6110.git_path
20+
REFERENCE_SPEC_VERSION = ref_spec_6110.version
21+
22+
pytestmark = [pytest.mark.valid_at("Prague"), pytest.mark.mainnet]
23+
24+
25+
@pytest.mark.parametrize(
26+
"requests",
27+
[
28+
pytest.param(
29+
[
30+
DepositTransaction(
31+
# TODO: Use a real public key to allow recovery of the funds.
32+
requests=[
33+
DepositRequest(
34+
pubkey=0x01,
35+
withdrawal_credentials=0x02,
36+
amount=1_000_000_000,
37+
signature=0x03,
38+
index=0x0,
39+
)
40+
],
41+
),
42+
],
43+
id="single_deposit_from_eoa_minimum",
44+
),
45+
],
46+
)
47+
def test_eip_6110(
48+
blockchain_test: BlockchainTestFiller,
49+
pre: Alloc,
50+
blocks: List[Block],
51+
):
52+
"""Test making a deposit to the beacon chain deposit contract."""
53+
blockchain_test(
54+
pre=pre,
55+
post={},
56+
blocks=blocks,
57+
)
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
"""
2+
abstract: Crafted tests for mainnet of [EIP-7002: Execution layer triggerable withdrawals](https://eips.ethereum.org/EIPS/eip-7002)
3+
Crafted tests for mainnet of [EIP-7002: Execution layer triggerable withdrawals](https://eips.ethereum.org/EIPS/eip-7002).
4+
""" # noqa: E501
5+
6+
from typing import List
7+
8+
import pytest
9+
10+
from ethereum_test_tools import (
11+
Alloc,
12+
Block,
13+
BlockchainTestFiller,
14+
)
15+
16+
from .helpers import WithdrawalRequest, WithdrawalRequestTransaction
17+
from .spec import Spec, ref_spec_7002
18+
19+
REFERENCE_SPEC_GIT_PATH = ref_spec_7002.git_path
20+
REFERENCE_SPEC_VERSION = ref_spec_7002.version
21+
22+
pytestmark = [pytest.mark.valid_at("Prague"), pytest.mark.mainnet]
23+
24+
25+
@pytest.mark.parametrize(
26+
"blocks_withdrawal_requests",
27+
[
28+
pytest.param(
29+
[
30+
[
31+
WithdrawalRequestTransaction(
32+
requests=[
33+
WithdrawalRequest(
34+
validator_pubkey=0x01,
35+
amount=0,
36+
fee=Spec.get_fee(0),
37+
)
38+
],
39+
),
40+
],
41+
],
42+
id="single_withdrawal_request",
43+
),
44+
],
45+
)
46+
def test_eip_7002(
47+
blockchain_test: BlockchainTestFiller,
48+
pre: Alloc,
49+
blocks: List[Block],
50+
):
51+
"""Test making a withdrawal request."""
52+
blockchain_test(
53+
pre=pre,
54+
post={},
55+
blocks=blocks,
56+
)
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
"""
2+
abstract: Crafted tests for mainnet of [EIP-7251: Increase the MAX_EFFECTIVE_BALANCE](https://eips.ethereum.org/EIPS/eip-7251)
3+
Crafted tests for mainnet of [EIP-7251: Increase the MAX_EFFECTIVE_BALANCE](https://eips.ethereum.org/EIPS/eip-7251).
4+
""" # noqa: E501
5+
6+
from typing import List
7+
8+
import pytest
9+
10+
from ethereum_test_tools import (
11+
Alloc,
12+
Block,
13+
BlockchainTestFiller,
14+
)
15+
16+
from .helpers import ConsolidationRequest, ConsolidationRequestTransaction
17+
from .spec import Spec, ref_spec_7251
18+
19+
REFERENCE_SPEC_GIT_PATH = ref_spec_7251.git_path
20+
REFERENCE_SPEC_VERSION = ref_spec_7251.version
21+
22+
pytestmark = [pytest.mark.valid_at("Prague"), pytest.mark.mainnet]
23+
24+
25+
@pytest.mark.parametrize(
26+
"blocks_consolidation_requests",
27+
[
28+
pytest.param(
29+
[
30+
[
31+
ConsolidationRequestTransaction(
32+
requests=[
33+
ConsolidationRequest(
34+
source_pubkey=0x01,
35+
target_pubkey=0x02,
36+
fee=Spec.get_fee(0),
37+
)
38+
],
39+
),
40+
],
41+
],
42+
id="single_consolidation_request",
43+
),
44+
],
45+
)
46+
def test_eip_7251(
47+
blockchain_test: BlockchainTestFiller,
48+
blocks: List[Block],
49+
pre: Alloc,
50+
):
51+
"""Test making a consolidation request."""
52+
blockchain_test(
53+
pre=pre,
54+
post={},
55+
blocks=blocks,
56+
)

0 commit comments

Comments
 (0)