From a3c2f24b7c1066b7d373e8c739a18a3b737e6d4c Mon Sep 17 00:00:00 2001 From: Mario Vega Date: Tue, 28 Jan 2025 21:42:22 +0000 Subject: [PATCH 1/3] fix(clis): Add (dummy) exception to the eels mapper --- src/ethereum_clis/clis/execution_specs.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/ethereum_clis/clis/execution_specs.py b/src/ethereum_clis/clis/execution_specs.py index d61b50f9814..33855e58178 100644 --- a/src/ethereum_clis/clis/execution_specs.py +++ b/src/ethereum_clis/clis/execution_specs.py @@ -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: ", + ), # 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"), From db961c7e07434fcb379059bec62ad08c5affd45f Mon Sep 17 00:00:00 2001 From: Mario Vega Date: Tue, 28 Jan 2025 21:42:43 +0000 Subject: [PATCH 2/3] feat(tests): EIP-7702: Add invalid block tests --- .../eip7702_set_code_tx/test_set_code_txs.py | 90 +++++++++++++++++++ 1 file changed, 90 insertions(+) diff --git a/tests/prague/eip7702_set_code_tx/test_set_code_txs.py b/tests/prague/eip7702_set_code_tx/test_set_code_txs.py index 2f4a7b54410..e9e548d76ea 100644 --- a/tests/prague/eip7702_set_code_tx/test_set_code_txs.py +++ b/tests/prague/eip7702_set_code_tx/test_set_code_txs.py @@ -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 + 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), + 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), + }, + ) From 36fd313e9792ce8092174ecd4aa85a77dcc41fda Mon Sep 17 00:00:00 2001 From: Mario Vega Date: Wed, 29 Jan 2025 17:33:21 +0000 Subject: [PATCH 3/3] fix: explicit nonces --- tests/prague/eip7702_set_code_tx/test_set_code_txs.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/prague/eip7702_set_code_tx/test_set_code_txs.py b/tests/prague/eip7702_set_code_tx/test_set_code_txs.py index e9e548d76ea..37914570d52 100644 --- a/tests/prague/eip7702_set_code_tx/test_set_code_txs.py +++ b/tests/prague/eip7702_set_code_tx/test_set_code_txs.py @@ -3394,7 +3394,8 @@ def test_invalid_transaction_after_authorization( ], ), Transaction( - sender=auth_signer, # Nonce is not bumped by the authorization, so it is still 0 + sender=auth_signer, + nonce=0, gas_limit=21_000, to=Address(0), value=1, @@ -3429,6 +3430,7 @@ def test_authorization_reusing_nonce( txs = [ Transaction( sender=auth_signer, + nonce=0, gas_limit=21_000, to=Address(0), value=1,