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

🐞 bug(ethereum_clis): Incorrect exception handling #971

Open
raxhvl opened this issue Nov 25, 2024 · 0 comments
Open

🐞 bug(ethereum_clis): Incorrect exception handling #971

raxhvl opened this issue Nov 25, 2024 · 0 comments

Comments

@raxhvl
Copy link
Contributor

raxhvl commented Nov 25, 2024

BUG PRIORITY: LOW

EEST has a module which maps errors from various EVM clients to a common set of exceptions. This mapping is not robust and this results in misleading exceptions being raised.

Steps to reproduce

  1. Create a new test file targeting Frontier fork.
# file: tests/frontier/eip123_abc/test_abc.py
"""
A state test for testing exception.
"""

import pytest

from ethereum_test_tools import Alloc, Environment, StateTestFiller, Transaction

REFERENCE_SPEC_GIT_PATH = "DUMMY/eip-DUMMY.md"
REFERENCE_SPEC_VERSION = "DUMMY_VERSION"

@pytest.mark.valid_from("Frontier")
def test_abc(state_test: StateTestFiller, pre: Alloc):
    """
    Demo tx
    """
    env = Environment()

    tx = Transaction()

    # TODO: Add post-state allocations here.
    post: dict[str, dict] = {}

    state_test(env=env, pre=pre, post=post, tx=tx)
  1. Fill the test
uv run fill tests/frontier/eip123_abc/test_abc.py

This will result in TransactionException.TYPE_4_TX_CONTRACT_CREATION exception which is
misleading since no contract was being created.

Why the fill fails

In EEST, by default, a transaction is protected against replay. Support for protected transactions was added
AFTER Homestead (in Spurious Dragon), and so they get correctly rejected for Frontier and Homestead.

Instance of incorrect exception mapping

The above unsupported transaction is rejected with the reason Failed transaction: .

Screenshot from 2024-11-22 12-16-31

This error is mapped by the following code:

ExceptionMessage(
TransactionException.TYPE_4_TX_CONTRACT_CREATION,
"Failed transaction: ",
),

It appears that the code assumes failed transactions are only caused by failure to create a contract which is wrong, as shown here.

Moreover, several other haphazard mappings expect partial error messages:

ExceptionMessage(
TransactionException.INSUFFICIENT_ACCOUNT_FUNDS,
"ailed transaction: ",
),
ExceptionMessage(
TransactionException.TYPE_3_TX_MAX_BLOB_GAS_ALLOWANCE_EXCEEDED,
"iled transaction: ",
),
ExceptionMessage(
TransactionException.INSUFFICIENT_MAX_FEE_PER_BLOB_GAS,
"led transaction: ",
),
ExceptionMessage(
TransactionException.INSUFFICIENT_MAX_FEE_PER_GAS,
"ed transaction: ",
),

We should have a robust error handling mechanism in EEST that produces reliable exceptions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant