Skip to content

Commit

Permalink
new(tests): EIP-2935, EIP-7002, EIP-7251 deploy tests
Browse files Browse the repository at this point in the history
  • Loading branch information
marioevz committed Dec 18, 2024
1 parent 728d2c0 commit 2cdccc4
Show file tree
Hide file tree
Showing 7 changed files with 179 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,18 @@
tx_gas_limit=0x3D090,
tx_gas_price=0xE8D4A51000,
tx_init_code=bytes.fromhex(
"60538060095f395ff33373fffffffffffffffffffffffffffffffffffffffe14604657602036036042575f35600143038111604257611fff81430311604257611fff9006545f5260205ff35b5f5ffd5b5f35611fff60014303065500"
"60538060095f395ff33373fffffffffffffffffffffffffffffffffffffffe14604657602036036042575f35"
"600143038111604257611fff81430311604257611fff9006545f5260205ff35b5f5ffd5b5f35611fff600143"
"03065500"
),
tx_v=0x1B,
tx_r=0x539,
tx_s=0xBAEFE09F0109759,
expected_deploy_address=Address(Spec.HISTORY_STORAGE_ADDRESS),
expected_system_contract_storage=None,
test_transaction_data=bytes(),
)
def test_system_contract_deployment():
def test_system_contract_deployment(*args, **kwargs):
"""
Verify deployment of the block hashes system contract.
"""
pass
yield from []
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
"maxPriorityFeePerGas": null,
"maxFeePerGas": null,
"value": "0x0",
"input": "0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff5f556101f480602d5f395ff33373fffffffffffffffffffffffffffffffffffffffe1460c7573615156028575f545f5260205ff35b36603814156101f05760115f54807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff146101f057600182026001905f5b5f821115608057810190830284830290049160010191906065565b9093900434106101f057600154600101600155600354806003026004013381556001015f35815560010160203590553360601b5f5260385f601437604c5fa0600101600355005b6003546002548082038060101160db575060105b5f5b81811461017f5780604c02838201600302600401805490600101805490600101549160601b83528260140152807fffffffffffffffffffffffffffffffff0000000000000000000000000000000016826034015260401c906044018160381c81600701538160301c81600601538160281c81600501538160201c81600401538160181c81600301538160101c81600201538160081c81600101535360010160dd565b9101809214610191579060025561019c565b90505f6002555f6003555b5f54807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff14156101c957505f5b6001546002828201116101de5750505f6101e4565b01600290035b5f555f600155604c025ff35b5f5ffd",
"input": "0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff5f556101f880602d5f395ff33373fffffffffffffffffffffffffffffffffffffffe1460cb5760115f54807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff146101f457600182026001905f5b5f82111560685781019083028483029004916001019190604d565b909390049250505036603814608857366101f457346101f4575f5260205ff35b34106101f457600154600101600155600354806003026004013381556001015f35815560010160203590553360601b5f5260385f601437604c5fa0600101600355005b6003546002548082038060101160df575060105b5f5b8181146101835782810160030260040181604c02815460601b8152601401816001015481526020019060020154807fffffffffffffffffffffffffffffffff00000000000000000000000000000000168252906010019060401c908160381c81600701538160301c81600601538160281c81600501538160201c81600401538160181c81600301538160101c81600201538160081c81600101535360010160e1565b910180921461019557906002556101a0565b90505f6002555f6003555b5f54807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff14156101cd57505f5b6001546002828201116101e25750505f6101e8565b01600290035b5f555f600155604c025ff35b5f5ffd",
"v": "0x1b",
"r": "0x539",
"s": "0x10e740537d4d36b9",
"hash": "0x1cd8bf929988b27b07ba1c7b898b396c08c484bb0db83fdeb992aa21b5cdf0ce",
"s": "0xeb793ed1dcd82833",
"hash": "0xe89c48ef3308192a0768aefaa5128559e68ab87b5b9a6d113824551867746a20",
"protected": false
}
2 changes: 1 addition & 1 deletion tests/prague/eip7002_el_triggerable_withdrawals/spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class Spec:
"""

WITHDRAWAL_REQUEST_PREDEPLOY_ADDRESS = 0x0C15F14308530B7CDB8460094BBB9CC28B9AAAAA
WITHDRAWAL_REQUEST_PREDEPLOY_SENDER = Address(0x57B8C3C2766D0623EA0A499365A6F5A26AD38B47)
WITHDRAWAL_REQUEST_PREDEPLOY_SENDER = Address(0xA05D9EED37862DAB22B002B8F6668B8FB0C4D798)
SYSTEM_ADDRESS = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE

EXCESS_WITHDRAWAL_REQUESTS_STORAGE_SLOT = 0
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
"""
abstract: Tests [EIP-7002: Execution layer triggerable withdrawals](https://eips.ethereum.org/EIPS/eip-7002)
Test system contract deployment for [EIP-7002: Execution layer triggerable withdrawals](https://eips.ethereum.org/EIPS/eip-7002)
""" # noqa: E501

from typing import Generator, Tuple

from ethereum_test_forks import Fork, Prague
from ethereum_test_tools import (
Address,
Alloc,
Header,
Requests,
Transaction,
generate_system_contract_deploy_test,
)

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

REFERENCE_SPEC_GIT_PATH = ref_spec_7002.git_path
REFERENCE_SPEC_VERSION = ref_spec_7002.version


@generate_system_contract_deploy_test(
fork=Prague,
tx_gas_limit=0x3D090,
tx_gas_price=0xE8D4A51000,
tx_init_code=bytes.fromhex(
"7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff5f556101f880602d5f395f"
"f33373fffffffffffffffffffffffffffffffffffffffe1460cb5760115f54807fffffffffffffffffffffff"
"ffffffffffffffffffffffffffffffffffffffffff146101f457600182026001905f5b5f8211156068578101"
"9083028483029004916001019190604d565b909390049250505036603814608857366101f457346101f4575f"
"5260205ff35b34106101f457600154600101600155600354806003026004013381556001015f358155600101"
"60203590553360601b5f5260385f601437604c5fa0600101600355005b6003546002548082038060101160df"
"575060105b5f5b8181146101835782810160030260040181604c02815460601b815260140181600101548152"
"6020019060020154807fffffffffffffffffffffffffffffffff000000000000000000000000000000001682"
"52906010019060401c908160381c81600701538160301c81600601538160281c81600501538160201c816004"
"01538160181c81600301538160101c81600201538160081c81600101535360010160e1565b91018092146101"
"9557906002556101a0565b90505f6002555f6003555b5f54807fffffffffffffffffffffffffffffffffffff"
"ffffffffffffffffffffffffffff14156101cd57505f5b6001546002828201116101e25750505f6101e8565b"
"01600290035b5f555f600155604c025ff35b5f5ffd"
),
tx_v=0x1B,
tx_r=0x539,
tx_s=0xEB793ED1DCD82833,
expected_deploy_address=Address(Spec.WITHDRAWAL_REQUEST_PREDEPLOY_ADDRESS),
expected_system_contract_storage=None,
)
def test_system_contract_deployment(
*,
fork: Fork,
pre: Alloc,
) -> Generator[Tuple[Transaction, Header], None, None]:
"""
Verify calling the withdrawals system contract after deployment.
"""
sender = pre.fund_eoa()
withdrawal_request = WithdrawalRequest(
validator_pubkey=0x01,
amount=1,
fee=Spec.get_fee(0),
source_address=sender,
)
pre.fund_address(sender, withdrawal_request.value)
intrinsic_gas_calculator = fork.transaction_intrinsic_cost_calculator()
test_transaction_gas = intrinsic_gas_calculator(calldata=withdrawal_request.calldata)

test_transaction = Transaction(
data=withdrawal_request.calldata,
gas_limit=test_transaction_gas * 10,
to=Spec.WITHDRAWAL_REQUEST_PREDEPLOY_ADDRESS,
sender=sender,
value=withdrawal_request.value,
)

yield from [
(
test_transaction,
Header(
requests_hash=Requests(withdrawal_request),
),
),
]
6 changes: 3 additions & 3 deletions tests/prague/eip7251_consolidations/contract_deploy_tx.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
"maxPriorityFeePerGas": null,
"maxFeePerGas": null,
"value": "0x0",
"input": "0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff5f5561019e80602d5f395ff33373fffffffffffffffffffffffffffffffffffffffe1460cf573615156028575f545f5260205ff35b366060141561019a5760115f54807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1461019a57600182026001905f5b5f821115608057810190830284830290049160010191906065565b90939004341061019a57600154600101600155600354806004026004013381556001015f358155600101602035815560010160403590553360601b5f5260605f60143760745fa0600101600355005b6003546002548082038060011160e3575060015b5f5b8181146101295780607402838201600402600401805490600101805490600101805490600101549260601b84529083601401528260340152906054015260010160e5565b910180921461013b5790600255610146565b90505f6002555f6003555b5f54807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff141561017357505f5b6001546001828201116101885750505f61018e565b01600190035b5f555f6001556074025ff35b5f5ffd",
"input": "0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff5f5561019e80602d5f395ff33373fffffffffffffffffffffffffffffffffffffffe1460d35760115f54807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1461019a57600182026001905f5b5f82111560685781019083028483029004916001019190604d565b9093900492505050366060146088573661019a573461019a575f5260205ff35b341061019a57600154600101600155600354806004026004013381556001015f358155600101602035815560010160403590553360601b5f5260605f60143760745fa0600101600355005b6003546002548082038060021160e7575060025b5f5b8181146101295782810160040260040181607402815460601b815260140181600101548152602001816002015481526020019060030154905260010160e9565b910180921461013b5790600255610146565b90505f6002555f6003555b5f54807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff141561017357505f5b6001546001828201116101885750505f61018e565b01600190035b5f555f6001556074025ff35b5f5ffd",
"v": "0x1b",
"r": "0x539",
"s": "0x832fdd8c49a416f1",
"hash": "0x5e174f35e55bc53c898f3c5e315d81e054363363a0e95dfd6e43c23e8ebb9407",
"s": "0x332601ef36aa2ce9",
"hash": "0xc7d223eb06267248bcd21f7af0223c8d467ef7e95ff51cef84c616973692169f",
"protected": false
}
2 changes: 1 addition & 1 deletion tests/prague/eip7251_consolidations/spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class Spec:
"""

CONSOLIDATION_REQUEST_PREDEPLOY_ADDRESS = 0x00431F263CE400F4455C2DCF564E53007CA4BBBB
CONSOLIDATION_REQUEST_PREDEPLOY_SENDER = Address(0x81E9AFA909FE8B57AF2A6FD18862AE9DAE3163F4)
CONSOLIDATION_REQUEST_PREDEPLOY_SENDER = Address(0xE24B968AB4319A580D9FFC7AC29466894FEEB361)
SYSTEM_ADDRESS = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE

EXCESS_CONSOLIDATION_REQUESTS_STORAGE_SLOT = 0
Expand Down
82 changes: 82 additions & 0 deletions tests/prague/eip7251_consolidations/test_contract_deployment.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
"""
abstract: Tests [EIP-7251: Increase the MAX_EFFECTIVE_BALANCE](https://eips.ethereum.org/EIPS/eip-7251)
Test system contract deployment for [EIP-7251: Increase the MAX_EFFECTIVE_BALANCE](https://eips.ethereum.org/EIPS/eip-7251)
""" # noqa: E501

from typing import Generator, Tuple

from ethereum_test_forks import Fork, Prague
from ethereum_test_tools import (
Address,
Alloc,
Header,
Requests,
Transaction,
generate_system_contract_deploy_test,
)

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

REFERENCE_SPEC_GIT_PATH = ref_spec_7251.git_path
REFERENCE_SPEC_VERSION = ref_spec_7251.version


@generate_system_contract_deploy_test(
fork=Prague,
tx_gas_limit=0x3D090,
tx_gas_price=0xE8D4A51000,
tx_init_code=bytes.fromhex(
"7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff5f5561019e80602d5f395f"
"f33373fffffffffffffffffffffffffffffffffffffffe1460d35760115f54807fffffffffffffffffffffff"
"ffffffffffffffffffffffffffffffffffffffffff1461019a57600182026001905f5b5f8211156068578101"
"9083028483029004916001019190604d565b9093900492505050366060146088573661019a573461019a575f"
"5260205ff35b341061019a57600154600101600155600354806004026004013381556001015f358155600101"
"602035815560010160403590553360601b5f5260605f60143760745fa0600101600355005b60035460025480"
"82038060021160e7575060025b5f5b8181146101295782810160040260040181607402815460601b81526014"
"0181600101548152602001816002015481526020019060030154905260010160e9565b910180921461013b57"
"90600255610146565b90505f6002555f6003555b5f54807fffffffffffffffffffffffffffffffffffffffff"
"ffffffffffffffffffffffff141561017357505f5b6001546001828201116101885750505f61018e565b0160"
"0190035b5f555f6001556074025ff35b5f5ffd"
),
tx_v=0x1B,
tx_r=0x539,
tx_s=0x332601EF36AA2CE9,
expected_deploy_address=Address(Spec.CONSOLIDATION_REQUEST_PREDEPLOY_ADDRESS),
expected_system_contract_storage=None,
)
def test_system_contract_deployment(
*,
fork: Fork,
pre: Alloc,
) -> Generator[Tuple[Transaction, Header], None, None]:
"""
Verify calling the consolidation system contract after deployment.
"""
sender = pre.fund_eoa()
consolidation_request = ConsolidationRequest(
source_pubkey=0x01,
target_pubkey=0x02,
fee=Spec.get_fee(0),
source_address=sender,
)
pre.fund_address(sender, consolidation_request.value)
intrinsic_gas_calculator = fork.transaction_intrinsic_cost_calculator()
test_transaction_gas = intrinsic_gas_calculator(calldata=consolidation_request.calldata)

test_transaction = Transaction(
data=consolidation_request.calldata,
gas_limit=test_transaction_gas * 10,
to=Spec.CONSOLIDATION_REQUEST_PREDEPLOY_ADDRESS,
sender=sender,
value=consolidation_request.value,
)

yield from [
(
test_transaction,
Header(
requests_hash=Requests(consolidation_request),
),
),
]

0 comments on commit 2cdccc4

Please sign in to comment.