Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(tests): EIP-7702: test set code tx ideas implementation #981

Merged
merged 13 commits into from
Jan 23, 2025
1 change: 1 addition & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Release tarball changes:
- ✨ [EIP-7702](https://eips.ethereum.org/EIPS/eip-7702) many delegations test ([#923](https://github.com/ethereum/execution-spec-tests/pull/923))
- ✨ [EIP-7702](https://eips.ethereum.org/EIPS/eip-7702) set code of non-empty-storage account test ([#948](https://github.com/ethereum/execution-spec-tests/pull/948))
- ✨ [EIP-7702](https://eips.ethereum.org/EIPS/eip-7702) Remove delegation behavior of EXTCODE* ([#984](https://github.com/ethereum/execution-spec-tests/pull/984))
- ✨ [EIP-7702](https://eips.ethereum.org/EIPS/eip-7702) implement 7702 test ideas ([#981](https://github.com/ethereum/execution-spec-tests/pull/981))
- ✨ [EIP-7623](https://eips.ethereum.org/EIPS/eip-7623) Increase calldata cost ([#1004](https://github.com/ethereum/execution-spec-tests/pull/1004))
- ✨ Add generic precompile-absence test ([#1036](https://github.com/ethereum/execution-spec-tests/pull/1036))
- ✨ Add test for [EIP-2537](https://eips.ethereum.org/EIPS/eip-2537) which uses the full discount table of G2 MSM ([#1038](https://github.com/ethereum/execution-spec-tests/pull/1038))
Expand Down
2 changes: 2 additions & 0 deletions src/ethereum_test_forks/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
ParisToShanghaiAtTime15k,
ShanghaiToCancunAtTime15k,
)
from .gas_costs import GasCosts
from .helpers import (
InvalidForkError,
forks_from,
Expand Down Expand Up @@ -83,4 +84,5 @@
"get_last_descendants",
"transition_fork_from_to",
"transition_fork_to",
"GasCosts",
]
46 changes: 46 additions & 0 deletions tests/prague/eip7702_set_code_tx/test_set_code_txs.py
Original file line number Diff line number Diff line change
Expand Up @@ -3237,6 +3237,52 @@ def test_deploying_delegation_designation_contract(
)


@pytest.mark.parametrize("create_opcode", [Op.CREATE, Op.CREATE2])
def test_creating_delegation_designation_contract(
state_test: StateTestFiller, pre: Alloc, create_opcode: Op
):
"""
Tx -> create -> pointer bytecode
Attempt to deploy contract with magic bytes result in no contract being created.
"""
env = Environment()

storage: Storage = Storage()

sender = pre.fund_eoa()

# An attempt to deploy code starting with ef01 result in no
# contract being created as it is prohibited

create_init = Initcode(deploy_code=Spec.delegation_designation(sender))
contract_a = pre.deploy_contract(
balance=100,
code=Op.MSTORE(0, Op.CALLDATALOAD(0))
+ Op.SSTORE(
storage.store_next(0, "contract_a_create_result"),
create_opcode(value=1, offset=0, size=Op.CALLDATASIZE(), salt=0),
)
+ Op.STOP,
)

tx = Transaction(
to=contract_a,
gas_limit=1_000_000,
data=create_init,
value=0,
sender=sender,
)

create_address = compute_create_address(
address=contract_a, nonce=1, initcode=create_init, salt=0, opcode=create_opcode
)
post = {
contract_a: Account(balance=100, storage=storage),
create_address: Account.NONEXISTENT,
}
state_test(env=env, pre=pre, post=post, tx=tx)


@pytest.mark.parametrize(
"signer_balance",
[
Expand Down
Loading
Loading