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: Invalid block test #1144

Merged
merged 3 commits into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
Changes from 2 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
8 changes: 8 additions & 0 deletions src/ethereum_clis/clis/execution_specs.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,14 @@ def _mapping_data(self):
TransactionException.PRIORITY_GREATER_THAN_MAX_FEE_PER_GAS,
"nsaction: ",
),
ExceptionMessage(
TransactionException.NONCE_MISMATCH_TOO_HIGH,
"saction: ",
),
ExceptionMessage(
TransactionException.NONCE_MISMATCH_TOO_LOW,
"action: ",
marioevz marked this conversation as resolved.
Show resolved Hide resolved
),
# TODO EVMONE needs to differentiate when the section is missing in the header or body
ExceptionMessage(EOFException.MISSING_STOP_OPCODE, "err: no_terminating_instruction"),
ExceptionMessage(EOFException.MISSING_CODE_HEADER, "err: code_section_missing"),
Expand Down
90 changes: 90 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 @@ -3367,3 +3367,93 @@ def test_many_delegations(
tx=tx,
post=post,
)


def test_invalid_transaction_after_authorization(
blockchain_test: BlockchainTestFiller,
pre: Alloc,
):
"""
Test an invalid block due to a transaction reusing the same nonce as an authorization
included in a prior transaction.
"""
auth_signer = pre.fund_eoa()

txs = [
Transaction(
sender=pre.fund_eoa(),
gas_limit=500_000,
to=Address(0),
value=0,
authorization_list=[
AuthorizationTuple(
address=Address(1),
nonce=0,
signer=auth_signer,
),
],
),
Transaction(
sender=auth_signer, # Nonce is not bumped by the authorization, so it is still 0
marioevz marked this conversation as resolved.
Show resolved Hide resolved
gas_limit=21_000,
to=Address(0),
value=1,
error=TransactionException.NONCE_MISMATCH_TOO_LOW,
),
]

blockchain_test(
pre=pre,
blocks=[
Block(
txs=txs,
exception=TransactionException.NONCE_MISMATCH_TOO_LOW,
)
],
post={
Address(0): None,
},
)


def test_authorization_reusing_nonce(
blockchain_test: BlockchainTestFiller,
pre: Alloc,
):
"""
Test an authorization reusing the same nonce as a prior transaction included in the same
block.
"""
auth_signer = pre.fund_eoa()
sender = pre.fund_eoa()
txs = [
Transaction(
sender=auth_signer,
gas_limit=21_000,
to=Address(0),
marioevz marked this conversation as resolved.
Show resolved Hide resolved
value=1,
),
Transaction(
sender=sender,
gas_limit=500_000,
to=Address(0),
value=0,
authorization_list=[
AuthorizationTuple(
address=Address(1),
nonce=0,
signer=auth_signer,
),
],
),
]

blockchain_test(
pre=pre,
blocks=[Block(txs=txs)],
post={
Address(0): Account(balance=1),
auth_signer: Account(nonce=1, code=b""),
sender: Account(nonce=1),
},
)