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): test set code tx ideas implementation #981

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open
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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,10 @@ cached_downloads/
# pytest report
assets
*.html
*dump*/

# Environment
env.yaml

# Framework logs
logs/
logs/
1 change: 1 addition & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Test fixtures for use by clients are available for each release on the [Github r
- ✨ [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))

### πŸ› οΈ Framework
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 @@ -26,6 +26,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",
]
88 changes: 75 additions & 13 deletions tests/prague/eip7702_set_code_tx/test_set_code_txs.py
Original file line number Diff line number Diff line change
Expand Up @@ -2412,14 +2412,18 @@ def test_nonce_validity(
pre=pre,
tx=tx,
post={
auth_signer: Account(
nonce=(account_nonce + 1) if valid_authorization else account_nonce,
code=Spec.delegation_designation(set_code_to_address)
if valid_authorization
else b"",
)
if authorization_nonce < 2**64 and account_nonce > 0
else Account.NONEXISTENT,
auth_signer: (
Account(
nonce=(account_nonce + 1) if valid_authorization else account_nonce,
code=(
Spec.delegation_designation(set_code_to_address)
if valid_authorization
else b""
),
)
if authorization_nonce < 2**64 and account_nonce > 0
else Account.NONEXISTENT
),
entry_address: Account(
storage={
success_slot: 1,
Expand Down Expand Up @@ -2555,7 +2559,13 @@ def test_set_code_to_log(
@pytest.mark.with_all_call_opcodes(
selector=(
lambda opcode: opcode
not in [Op.STATICCALL, Op.CALLCODE, Op.DELEGATECALL, Op.EXTDELEGATECALL, Op.EXTSTATICCALL]
not in [
Op.STATICCALL,
Op.CALLCODE,
Op.DELEGATECALL,
Op.EXTDELEGATECALL,
Op.EXTSTATICCALL,
]
)
)
@pytest.mark.with_all_precompiles
Expand Down Expand Up @@ -2626,7 +2636,13 @@ def deposit_contract_initial_storage() -> Storage:
@pytest.mark.with_all_call_opcodes(
selector=(
lambda opcode: opcode
not in [Op.STATICCALL, Op.CALLCODE, Op.DELEGATECALL, Op.EXTDELEGATECALL, Op.EXTSTATICCALL]
not in [
Op.STATICCALL,
Op.CALLCODE,
Op.DELEGATECALL,
Op.EXTDELEGATECALL,
Op.EXTSTATICCALL,
]
)
)
@pytest.mark.with_all_system_contracts
Expand Down Expand Up @@ -2760,9 +2776,9 @@ def test_set_code_to_system_contract(
@pytest.mark.with_all_evm_code_types
@pytest.mark.with_all_tx_types(
selector=lambda tx_type: tx_type != 4,
marks=lambda tx_type: pytest.mark.execute(pytest.mark.skip("incompatible tx"))
if tx_type in [0, 3]
else None,
marks=lambda tx_type: (
pytest.mark.execute(pytest.mark.skip("incompatible tx")) if tx_type in [0, 3] else None
),
)
def test_eoa_tx_after_set_code(
blockchain_test: BlockchainTestFiller,
Expand Down Expand Up @@ -3286,6 +3302,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