@pytest.mark.parametrize(
"requests",
[
pytest.param(
[
SystemContractInteractionTransaction(
requests=[
DepositRequest(
pubkey=0x01,
withdrawal_credentials=0x02,
amount=32_000_000_000,
signature=0x03,
index=0x0,
)
],
),
],
id="single_deposit_from_eoa",
),
pytest.param(
[
SystemContractInteractionTransaction(
requests=[
DepositRequest(
pubkey=0x01,
withdrawal_credentials=0x02,
amount=120_000_000_000_000_000,
signature=0x03,
index=0x0,
)
],
),
],
id="single_deposit_from_eoa_huge_amount",
),
pytest.param(
[
SystemContractInteractionTransaction(
requests=[
DepositRequest(
pubkey=0x01,
withdrawal_credentials=0x02,
amount=32_000_000_000,
signature=0x03,
index=0x0,
),
DepositRequest(
pubkey=0x01,
withdrawal_credentials=0x02,
amount=32_000_000_000,
signature=0x03,
index=0x1,
),
],
),
],
id="multiple_deposit_from_same_eoa",
),
pytest.param(
[
SystemContractInteractionTransaction(
requests=[
DepositRequest(
pubkey=0x01,
withdrawal_credentials=0x02,
amount=1_000_000_000,
signature=0x03,
index=i,
)
for i in range(200)
],
)
],
id="multiple_deposit_from_same_eoa_high_count",
),
pytest.param(
[
SystemContractInteractionTransaction(
requests=[
DepositRequest(
pubkey=0x01,
withdrawal_credentials=0x02,
amount=32_000_000_000,
signature=0x03,
index=0x0,
)
],
),
SystemContractInteractionTransaction(
requests=[
DepositRequest(
pubkey=0x01,
withdrawal_credentials=0x02,
amount=32_000_000_000,
signature=0x03,
index=0x1,
)
],
),
],
id="multiple_deposit_from_different_eoa",
),
pytest.param(
[
SystemContractInteractionTransaction(
requests=[
DepositRequest(
pubkey=0x01,
withdrawal_credentials=0x02,
amount=999_999_999,
signature=0x03,
index=0x0,
),
DepositRequest(
pubkey=0x01,
withdrawal_credentials=0x02,
amount=32_000_000_000,
signature=0x03,
index=0x0,
),
],
),
],
id="multiple_deposit_from_same_eoa_first_reverts",
),
pytest.param(
[
SystemContractInteractionTransaction(
requests=[
DepositRequest(
pubkey=0x01,
withdrawal_credentials=0x02,
amount=32_000_000_000,
signature=0x03,
index=0x0,
),
DepositRequest(
pubkey=0x01,
withdrawal_credentials=0x02,
amount=999_999_999,
signature=0x03,
index=0x0,
),
],
),
],
id="multiple_deposit_from_same_eoa_last_reverts",
),
pytest.param(
[
SystemContractInteractionTransaction(
requests=[
DepositRequest(
pubkey=0x01,
withdrawal_credentials=0x02,
amount=32_000_000_000,
signature=0x03,
index=0x0,
calldata_modifier=lambda _: b"",
valid=False,
)
],
),
],
id="send_eth_from_eoa",
),
pytest.param(
[
SystemContractInteractionContract(
requests=[
DepositRequest(
pubkey=0x01,
withdrawal_credentials=0x02,
amount=32_000_000_000,
signature=0x03,
index=0x0,
valid=False,
calldata_modifier=lambda _: b"",
)
],
),
],
# TODO: EIP-5920: Send using PAY opcode
id="send_eth_to_contract_no_deposit_data",
),
pytest.param(
[
SystemContractInteractionContract(
requests=[
DepositRequest(
pubkey=0x01,
withdrawal_credentials=0x02,
amount=32_000_000_000,
signature=0x03,
index=0x0,
)
],
),
],
id="single_deposit_from_contract",
),
pytest.param(
[
SystemContractInteractionContract(
requests=[
DepositRequest(
pubkey=0x01,
withdrawal_credentials=0x02,
amount=32_000_000_000,
signature=0x03,
index=0x0,
),
DepositRequest(
pubkey=0x01,
withdrawal_credentials=0x02,
amount=1_000_000_000,
signature=0x03,
index=0x1,
),
],
),
],
id="multiple_deposits_from_contract",
),
pytest.param(
[
SystemContractInteractionContract(
requests=[
DepositRequest(
pubkey=0x01,
withdrawal_credentials=0x02,
amount=1_000_000_000,
signature=0x03,
index=i,
)
for i in range(450)
],
),
],
id="many_deposits_from_contract",
marks=pytest.mark.slow,
),
pytest.param(
[
SystemContractInteractionContract(
requests=[
DepositRequest(
pubkey=0x01,
withdrawal_credentials=0x02,
amount=999_999_999,
signature=0x03,
index=0x0,
valid=False,
),
DepositRequest(
pubkey=0x01,
withdrawal_credentials=0x02,
amount=1_000_000_000,
signature=0x03,
index=0x0,
),
],
),
],
id="multiple_deposits_from_contract_first_reverts",
),
pytest.param(
[
SystemContractInteractionContract(
requests=[
DepositRequest(
pubkey=0x01,
withdrawal_credentials=0x02,
amount=1_000_000_000,
signature=0x03,
index=0x0,
),
DepositRequest(
pubkey=0x01,
withdrawal_credentials=0x02,
amount=999_999_999,
signature=0x03,
index=0x1,
valid=False,
),
],
),
],
id="multiple_deposits_from_contract_last_reverts",
),
pytest.param(
[
SystemContractInteractionContract(
requests=[
DepositRequest(
pubkey=0x01,
withdrawal_credentials=0x02,
amount=32_000_000_000,
signature=0x03,
index=0x0,
valid=False,
),
DepositRequest(
pubkey=0x01,
withdrawal_credentials=0x02,
amount=1_000_000_000,
signature=0x03,
index=0x1,
valid=False,
),
],
extra_code=Op.REVERT(0, 0),
),
],
id="multiple_deposits_from_contract_caller_reverts",
),
pytest.param(
[
SystemContractInteractionContract(
requests=[
DepositRequest(
pubkey=0x01,
withdrawal_credentials=0x02,
amount=32_000_000_000,
signature=0x03,
index=0x0,
valid=False,
),
DepositRequest(
pubkey=0x01,
withdrawal_credentials=0x02,
amount=1_000_000_000,
signature=0x03,
index=0x1,
valid=False,
),
],
extra_code=Macros.OOG(),
),
],
id="multiple_deposits_from_contract_caller_oog",
),
pytest.param(
[
SystemContractInteractionContract(
requests=[
DepositRequest(
pubkey=0x01,
withdrawal_credentials=0x02,
amount=32_000_000_000,
signature=0x03,
index=0x0,
),
],
),
SystemContractInteractionTransaction(
requests=[
DepositRequest(
pubkey=0x01,
withdrawal_credentials=0x02,
amount=32_000_000_000,
signature=0x03,
index=0x1,
)
],
),
],
id="single_deposit_from_contract_single_deposit_from_eoa",
),
pytest.param(
[
SystemContractInteractionTransaction(
requests=[
DepositRequest(
pubkey=0x01,
withdrawal_credentials=0x02,
amount=32_000_000_000,
signature=0x03,
index=0x0,
)
],
),
SystemContractInteractionContract(
requests=[
DepositRequest(
pubkey=0x01,
withdrawal_credentials=0x02,
amount=32_000_000_000,
signature=0x03,
index=0x1,
),
],
),
],
id="single_deposit_from_eoa_single_deposit_from_contract",
),
pytest.param(
[
SystemContractInteractionTransaction(
requests=[
DepositRequest(
pubkey=0x01,
withdrawal_credentials=0x02,
amount=32_000_000_000,
signature=0x03,
index=0x0,
)
],
),
SystemContractInteractionContract(
requests=[
DepositRequest(
pubkey=0x01,
withdrawal_credentials=0x02,
amount=32_000_000_000,
signature=0x03,
index=0x1,
),
],
),
SystemContractInteractionTransaction(
requests=[
DepositRequest(
pubkey=0x01,
withdrawal_credentials=0x02,
amount=32_000_000_000,
signature=0x03,
index=0x2,
)
],
),
],
id="single_deposit_from_contract_between_eoa_deposits",
),
pytest.param(
[
SystemContractInteractionContract(
requests=[
DepositRequest(
pubkey=0x01,
withdrawal_credentials=0x02,
amount=32_000_000_000,
signature=0x03,
index=0x0,
),
],
),
SystemContractInteractionTransaction(
requests=[
DepositRequest(
pubkey=0x01,
withdrawal_credentials=0x02,
amount=32_000_000_000,
signature=0x03,
index=0x1,
)
],
),
SystemContractInteractionContract(
requests=[
DepositRequest(
pubkey=0x01,
withdrawal_credentials=0x02,
amount=32_000_000_000,
signature=0x03,
index=0x2,
),
],
),
],
id="single_deposit_from_eoa_between_contract_deposits",
),
pytest.param(
[
SystemContractInteractionContract(
requests=[
DepositRequest(
pubkey=0x01,
withdrawal_credentials=0x02,
amount=32_000_000_000,
signature=0x03,
index=0x0,
valid=False,
)
],
call_type=Op.DELEGATECALL,
),
],
id="single_deposit_from_contract_delegatecall",
),
pytest.param(
[
SystemContractInteractionContract(
requests=[
DepositRequest(
pubkey=0x01,
withdrawal_credentials=0x02,
amount=32_000_000_000,
signature=0x03,
index=0x0,
valid=False,
)
],
call_type=Op.STATICCALL,
),
],
id="single_deposit_from_contract_staticcall",
),
pytest.param(
[
SystemContractInteractionContract(
requests=[
DepositRequest(
pubkey=0x01,
withdrawal_credentials=0x02,
amount=32_000_000_000,
signature=0x03,
index=0x0,
valid=False,
)
],
call_type=Op.CALLCODE,
),
],
id="single_deposit_from_contract_callcode",
),
pytest.param(
[
SystemContractInteractionContract(
requests=[
DepositRequest(
pubkey=0x01,
withdrawal_credentials=0x02,
amount=32_000_000_000,
signature=0x03,
index=0x0,
)
],
call_depth=3,
),
],
id="single_deposit_from_contract_call_depth_3",
),
# High depth under Amsterdam: EIP-7825 caps execution gas at 2^24, and
# EIP-8037/8038 raise intrinsic + cold-account costs, so a 271-frame
# 63/64 chain OOGs before the deposit lands (270 still passes). Use
# 256 so the case stays deep with margin past EIP-8037.
pytest.param(
[
SystemContractInteractionContract(
requests=[
DepositRequest(
pubkey=0x01,
withdrawal_credentials=0x02,
amount=32_000_000_000,
signature=0x03,
index=0x0,
)
],
call_depth=256,
),
],
id="single_deposit_from_contract_call_depth_high",
),
pytest.param(
[
SystemContractInteractionTransaction(
requests=[
DepositRequest(
pubkey=0x01,
withdrawal_credentials=0x02,
amount=1_000_000_001,
signature=0x03,
index=0x0,
)
],
),
],
id="single_deposit_from_eoa_minimum_plus_one",
),
pytest.param(
[
SystemContractInteractionTransaction(
requests=[
DepositRequest(
pubkey=0x01,
withdrawal_credentials=0x02,
amount=1_000_000_000,
signature=0x03,
index=0x0,
extra_wei=1,
valid=False,
)
],
),
],
id="single_deposit_from_eoa_minimum_plus_one_wei",
),
pytest.param(
[
SystemContractInteractionTransaction(
requests=[
DepositRequest(
pubkey=0x01,
withdrawal_credentials=0x02,
amount=1_000_000_000,
signature=0x03,
index=0x0,
extra_wei=-1,
valid=False,
)
],
),
],
id="single_deposit_from_eoa_minimum_minus_one_wei",
),
pytest.param(
[
SystemContractInteractionContract(
requests=[
DepositRequest(
pubkey=0x01,
withdrawal_credentials=0x02,
amount=1_000_000_000,
signature=0x03,
index=0x0,
extra_wei=1,
valid=False,
)
],
),
],
id="single_deposit_from_contract_minimum_plus_one_wei",
),
pytest.param(
[
SystemContractInteractionContract(
requests=[
DepositRequest(
pubkey=0x01,
withdrawal_credentials=0x02,
amount=1_000_000_000,
signature=0x03,
index=0x0,
extra_wei=-1,
valid=False,
)
],
),
],
id="single_deposit_from_contract_minimum_minus_one_wei",
),
pytest.param(
[
SystemContractInteractionTransaction(
requests=[
DepositRequest(
pubkey=0x01,
withdrawal_credentials=0x02,
amount=1_000_000_001,
signature=0x03,
index=0x0,
),
DepositRequest(
pubkey=0x01,
withdrawal_credentials=0x02,
amount=999_999_999,
signature=0x03,
index=0x1,
valid=False,
),
],
),
],
id="multiple_deposits_from_eoa_minimum_plus_one_minimum_minus_one",
),
pytest.param(
[
SystemContractInteractionContract(
requests=[
DepositRequest(
pubkey=0x01,
withdrawal_credentials=0x02,
amount=32_000_000_000,
signature=0x03,
index=0x0,
valid=False,
)
],
# Send 32 ETH minus 1 wei to the contract, note
# `DepositRequest.amount` is in gwei
tx_value=32_000_000_000 * 10**9 - 1,
contract_balance=0,
),
],
id="send_not_enough_eth_to_contract_with_zero_balance",
),
pytest.param(
[
SystemContractInteractionContract(
requests=[
DepositRequest(
pubkey=0x01,
withdrawal_credentials=0x02,
amount=999_999_999,
signature=0x03,
index=0x0,
valid=False,
)
],
tx_value=1_000_000_000 * 10**9,
),
],
id="send_eth_to_contract_insufficient_deposit",
),
pytest.param(
[
SystemContractInteractionContract(
requests=[
DepositRequest(
pubkey=0x01,
withdrawal_credentials=0x02,
amount=32_000_000_000,
signature=0x03,
index=0x0,
)
],
# Send 32 ETH (in wei) to the contract
tx_value=32_000_000_000 * 10**9,
contract_balance=0,
),
],
id="send_exact_eth_amount_for_deposit",
),
pytest.param(
[
SystemContractInteractionContract(
requests=[
DepositRequest(
pubkey=0x01,
withdrawal_credentials=0x02,
amount=32_000_000_000,
signature=0x03,
index=0x0,
),
DepositRequest(
pubkey=0x01,
withdrawal_credentials=0x02,
amount=32_000_000_000,
signature=0x03,
index=0x1,
),
],
# Send 64 ETH (in wei) to the contract
tx_value=64_000_000_000 * 10**9,
contract_balance=0,
),
],
id="send_exact_eth_amount_for_multiple_deposits",
),
],
)
@pytest.mark.slow()
def test_deposit(
blockchain_test: BlockchainTestFiller,
pre: Alloc,
blocks: List[Block],
) -> None:
"""Test making a deposit to the beacon chain deposit contract."""
blockchain_test(
pre=pre,
post={},
blocks=blocks,
)