Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/pytest_plugins/shared/execute_fill.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,10 @@ def pytest_configure(config: pytest.Config):
"markers",
"valid_for_bpo_forks: Marks a test as valid for BPO forks",
)
config.addinivalue_line(
"markers",
"mainnet: Specialty tests crafted for running on mainnet and sanity checking.",
)


@pytest.fixture(scope="function")
Expand Down
2 changes: 1 addition & 1 deletion tests/prague/eip2537_bls_12_381_precompiles/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def call_contract_address(pre: Alloc, call_contract_code: Bytecode) -> Address:
@pytest.fixture
def sender(pre: Alloc) -> EOA:
"""Sender of the transaction."""
return pre.fund_eoa(1_000_000_000_000_000_000)
return pre.fund_eoa()


@pytest.fixture
Expand Down
90 changes: 90 additions & 0 deletions tests/prague/eip2537_bls_12_381_precompiles/test_eip_mainnet.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
"""
abstract: Crafted tests for mainnet of [EIP-2537: Precompile for BLS12-381 curve operations](https://eips.ethereum.org/EIPS/eip-2537)
Crafted tests for mainnet of [EIP-2537: Precompile for BLS12-381 curve operations](https://eips.ethereum.org/EIPS/eip-2537).
""" # noqa: E501

import pytest

from ethereum_test_tools import Alloc, StateTestFiller, Transaction

from .spec import FP, FP2, Scalar, Spec, ref_spec_2537

REFERENCE_SPEC_GIT_PATH = ref_spec_2537.git_path
REFERENCE_SPEC_VERSION = ref_spec_2537.version

pytestmark = [pytest.mark.valid_at("Prague"), pytest.mark.mainnet]


@pytest.mark.parametrize(
"precompile_address,input_data,expected_output,vector_gas_value",
[
pytest.param(
Spec.G1ADD,
Spec.G1 + Spec.INF_G1,
Spec.G1,
None,
id="G1ADD",
),
pytest.param(
Spec.G1MSM,
Spec.G1 + Scalar(1) + Spec.INF_G1 + Scalar(1),
Spec.G1,
None,
id="G1MSM",
),
pytest.param(
Spec.G2ADD,
Spec.G2 + Spec.INF_G2,
Spec.G2,
None,
id="G2ADD",
),
pytest.param(
Spec.G2MSM,
Spec.G2 + Scalar(1) + Spec.INF_G2 + Scalar(1),
Spec.G2,
None,
id="G2MSM",
),
pytest.param(
Spec.PAIRING,
Spec.G1 + Spec.INF_G2,
Spec.PAIRING_TRUE,
None,
id="PAIRING",
),
pytest.param(
Spec.MAP_FP_TO_G1,
FP(
799950832265136997107648781861994410980648980263584507133499364313075404851459407870655748616451882783569609925573 # noqa: E501
),
Spec.INF_G1,
None,
id="fp_map_to_inf",
),
pytest.param(
Spec.MAP_FP2_TO_G2,
FP2(
(
3510328712861478240121438855244276237335901234329585006107499559909114695366216070652508985150831181717984778988906, # noqa: E501
2924545590598115509050131525615277284817672420174395176262156166974132393611647670391999011900253695923948997972401, # noqa: E501
)
),
Spec.INF_G2,
None,
id="fp_map_to_inf",
),
],
)
def test_eip_2537(
state_test: StateTestFiller,
pre: Alloc,
post: dict,
tx: Transaction,
):
"""Test the all precompiles of EIP-2537."""
state_test(
pre=pre,
tx=tx,
post=post,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
"""
abstract: Crafted tests for mainnet of [EIP-2935: Serve historical block hashes from state](https://eips.ethereum.org/EIPS/eip-2935)
Crafted tests for mainnet of [EIP-2935: Serve historical block hashes from state](https://eips.ethereum.org/EIPS/eip-2935).
""" # noqa: E501

import pytest

from ethereum_test_tools import Account, Alloc, Block, BlockchainTestFiller, Transaction
from ethereum_test_tools import Opcodes as Op

from .spec import Spec, ref_spec_2935

REFERENCE_SPEC_GIT_PATH = ref_spec_2935.git_path
REFERENCE_SPEC_VERSION = ref_spec_2935.version

pytestmark = [pytest.mark.valid_at("Prague"), pytest.mark.mainnet]


def test_eip_2935(
blockchain_test: BlockchainTestFiller,
pre: Alloc,
):
"""Test a simple block hash request from EIP-2935 system contract."""
check_block_number = Op.SUB(Op.NUMBER, 1) # Parent block number
check_contract_code = (
Op.MSTORE(0, check_block_number)
+ Op.POP(
Op.CALL(
address=Spec.HISTORY_STORAGE_ADDRESS,
args_offset=0,
args_size=32,
ret_offset=32,
ret_size=32,
)
)
+ Op.SSTORE(0, Op.EQ(Op.MLOAD(32), Op.BLOCKHASH(check_block_number)))
)
check_contract_address = pre.deploy_contract(check_contract_code)
tx = Transaction(
to=check_contract_address,
gas_limit=50_000,
sender=pre.fund_eoa(),
)
block = Block(txs=[tx])
blockchain_test(
pre=pre,
blocks=[block],
post={
check_contract_address: Account(storage={0: 1}),
},
)
57 changes: 57 additions & 0 deletions tests/prague/eip6110_deposits/test_eip_mainnet.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
"""
abstract: Crafted tests for mainnet of [EIP-6110: Supply validator deposits on chain](https://eips.ethereum.org/EIPS/eip-6110)
Crafted tests for mainnet of [EIP-6110: Supply validator deposits on chain](https://eips.ethereum.org/EIPS/eip-6110).
""" # noqa: E501

from typing import List

import pytest

from ethereum_test_tools import (
Alloc,
Block,
BlockchainTestFiller,
)

from .helpers import DepositRequest, DepositTransaction
from .spec import ref_spec_6110

REFERENCE_SPEC_GIT_PATH = ref_spec_6110.git_path
REFERENCE_SPEC_VERSION = ref_spec_6110.version

pytestmark = [pytest.mark.valid_at("Prague"), pytest.mark.mainnet]


@pytest.mark.parametrize(
"requests",
[
pytest.param(
[
DepositTransaction(
# TODO: Use a real public key to allow recovery of the funds.
requests=[
DepositRequest(
pubkey=0x01,
withdrawal_credentials=0x02,
amount=1_000_000_000,
signature=0x03,
index=0x0,
)
],
),
],
id="single_deposit_from_eoa_minimum",
),
],
)
def test_eip_6110(
blockchain_test: BlockchainTestFiller,
pre: Alloc,
blocks: List[Block],
):
"""Test making a deposit to the beacon chain deposit contract."""
blockchain_test(
pre=pre,
post={},
blocks=blocks,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
"""
abstract: Crafted tests for mainnet of [EIP-7002: Execution layer triggerable withdrawals](https://eips.ethereum.org/EIPS/eip-7002)
Crafted tests for mainnet of [EIP-7002: Execution layer triggerable withdrawals](https://eips.ethereum.org/EIPS/eip-7002).
""" # noqa: E501

from typing import List

import pytest

from ethereum_test_tools import (
Alloc,
Block,
BlockchainTestFiller,
)

from .helpers import WithdrawalRequest, WithdrawalRequestTransaction
from .spec import Spec, ref_spec_7002

REFERENCE_SPEC_GIT_PATH = ref_spec_7002.git_path
REFERENCE_SPEC_VERSION = ref_spec_7002.version

pytestmark = [pytest.mark.valid_at("Prague"), pytest.mark.mainnet]


@pytest.mark.parametrize(
"blocks_withdrawal_requests",
[
pytest.param(
[
[
WithdrawalRequestTransaction(
requests=[
WithdrawalRequest(
validator_pubkey=0x01,
amount=0,
fee=Spec.get_fee(0),
)
],
),
],
],
id="single_withdrawal_request",
),
],
)
def test_eip_7002(
blockchain_test: BlockchainTestFiller,
pre: Alloc,
blocks: List[Block],
):
"""Test making a withdrawal request."""
blockchain_test(
pre=pre,
post={},
blocks=blocks,
)
56 changes: 56 additions & 0 deletions tests/prague/eip7251_consolidations/test_eip_mainnet.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
"""
abstract: Crafted tests for mainnet of [EIP-7251: Increase the MAX_EFFECTIVE_BALANCE](https://eips.ethereum.org/EIPS/eip-7251)
Crafted tests for mainnet of [EIP-7251: Increase the MAX_EFFECTIVE_BALANCE](https://eips.ethereum.org/EIPS/eip-7251).
""" # noqa: E501

from typing import List

import pytest

from ethereum_test_tools import (
Alloc,
Block,
BlockchainTestFiller,
)

from .helpers import ConsolidationRequest, ConsolidationRequestTransaction
from .spec import Spec, ref_spec_7251

REFERENCE_SPEC_GIT_PATH = ref_spec_7251.git_path
REFERENCE_SPEC_VERSION = ref_spec_7251.version

pytestmark = [pytest.mark.valid_at("Prague"), pytest.mark.mainnet]


@pytest.mark.parametrize(
"blocks_consolidation_requests",
[
pytest.param(
[
[
ConsolidationRequestTransaction(
requests=[
ConsolidationRequest(
source_pubkey=0x01,
target_pubkey=0x02,
fee=Spec.get_fee(0),
)
],
),
],
],
id="single_consolidation_request",
),
],
)
def test_eip_7251(
blockchain_test: BlockchainTestFiller,
blocks: List[Block],
pre: Alloc,
):
"""Test making a consolidation request."""
blockchain_test(
pre=pre,
post={},
blocks=blocks,
)
Loading
Loading