← Back to Pull requests

fix(ante): enforce EIP-3607 after Prague, exempting only EIP-7702 delegation designations #1111

Merged
randy-cro merged 4 files (34 lines) on Sep 25, 2026 09:34 UTC
View on GitHub
randy-cro randy-cro commented on Sep 25, 2026 09:06 UTC
Author

Issue


Our current ante handler blocks accounts who holds contract code from executing an evm transaction.
// ante/eth.go
acct := statedb.NewAccountFromSdkAccount(accountGetter(from))
if !rules.IsPrague {                          // line 93
    if acct.IsContract() {
        fromAddr := common.BytesToAddress(from)
        return errorsmod.Wrapf(errortypes.ErrInvalidType,
            "the sender is not EOA: address %s, codeHash <%s>", fromAddr, acct.CodeHash)
    }
}

However, IsPrague = true by default. Therefore this code block doesn't run.

Solution


To allow eip7702 delegated accounts to execute evm transaction

Diff: 34 lines (+26 / -8) across 4 files Reviewer: JayT106 Review duration: 28m
All Vouch review confidence checks passed
Residual risk 0.05 = Change Risk (0.29) × (1 − Review Confidence (0.82)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.29 · 34 lines diff across 4 files
0.29
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.74 · 4 substantive comment(s)
0.74
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 50%
82%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size diff_size
0.213
Real PR Conversation Timeline
6 items
codecov[bot] codecov[bot] commented on Sep 25, 2026 09:17 UTC
Bot

Codecov Report


:x: Patch coverage is 0% with 4 lines in your changes missing coverage. Please review.
:white_check_mark: Project coverage is 47.08%. Comparing base (db757f3) to head (878fb19).
:warning: Report is 2 commits behind head on develop.

| Files with missing lines | Patch % | Lines |
|---|---|---|
| ante/eth.go | 0.00% | 3 Missing :warning: |
| evmd/ante/handler\_options.go | 0.00% | 0 Missing and 1 partial :warning: |

<details><summary>Additional details and impacted files</summary>

![Impacted file tree graph](https://app.codecov.io/gh/crypto-org-chain/ethermint/pull/1111?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=crypto-org-chain)

@@             Coverage Diff             @@
##           develop    #1111      +/-   ##
===========================================
- Coverage    47.09%   47.08%   -0.01%     
===========================================
  Files          200      200              
  Lines        17647    17648       +1     
===========================================
  Hits          8310     8310              
- Misses        8475     8476       +1     
  Partials       862      862              

| Files with missing lines | Coverage Δ | |
|---|---|---|
| evmd/ante/handler\_options.go | 62.88% <0.00%> (ø) | |
| ante/eth.go | 0.00% <0.00%> (ø) | |
</details>
<details><summary> :rocket: New features to boost your workflow: </summary>

  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

  • :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

  • </details>

    JayT106 JayT106 commented on Sep 25, 2026 09:17 UTC
    Contributor

    @claude review

    github-actions[bot] github-actions[bot] commented on Sep 25, 2026 09:18 UTC
    Bot

    Claude finished @JayT106's task in 1m 54s —— View job

    ---

    Code Review

    Tasks

  • Gather context from PR description and changed files

  • Review ante/eth.go changes

  • Review evmd/ante/eth_test.go changes

  • Review evmd/ante/handler_options.go changes

  • Review CHANGELOG.md changes

  • Post final review
  • ---

    Summary

    This PR fixes a real bug: the IsPrague guard was accidentally suppressing EIP-3607 enforcement for all post-Prague chains (the default), allowing any contract-code account to send transactions. The fix correctly re-enforces EIP-3607 while carving out an exemption for EIP-7702 delegation designators.

    ---

    Findings

    ✅ Correctness — logic is right

    The old code:

    if !rules.IsPrague {   // always false → block never ran
        if acct.IsContract() { ... }
    }
    

    The new code runs unconditionally and passes the check only for EIP-7702 delegated accounts. This is exactly the correct EIP-3607 behaviour for post-Prague chains.

    ⚠️ Pre-Prague behaviour change

    The old code silently skipped the check on Prague-enabled chains, and also skipped it on pre-Prague chains where IsPrague=false would have been wrong too. The new code applies uniformly to all forks. On a pre-Prague chain EIP-7702 delegation codes cannot exist, so ParseDelegation always returns false, and every contract sender is rejected — identical to the intended pre-Prague behaviour. This is fine, but worth stating explicitly since the signature change (removing rules) makes the fork-awareness implicit.

    ⚠️ API breaking change — rules parameter removed

    VerifyEthAccount is a public function. Removing rules params.Rules from its signature is a breaking change for any downstream consumer that calls it directly. The CHANGELOG entry should mention this if this library is consumed externally.

    ⚠️ Extra GetCode read on every transaction from a delegated account

    ante/eth.go:94:

    code := evmKeeper.GetCode(ctx, common.BytesToHash(acct.CodeHash))
    

    This is an additional DB read for every ante-handler execution where the sender has a non-empty code hash (i.e., all EIP-7702 delegated accounts). It's unavoidable with the current architecture, but the hot path for regular EOA senders (acct.IsContract() == false) is not affected. Worth noting in a comment.

    ⚠️ Test coverage — Codecov reports 0% for new lines in ante/eth.go

    Codecov's report is 2 commits behind head on develop, so the numbers may be stale. Looking at the test code directly, both new cases are exercised: the delegated-account case calls vmdb.SetCode(addr, ethtypes.AddressToDelegation(...), 0) and the contract-code case uses raw bytecode {0x60, 0x00, 0x60, 0x00, 0xfd}. The test flow (malleate → Commit → VerifyEthAccount) should reach the new code. Coverage should be re-confirmed once the report catches up.

    ✅ ParseDelegation import is consistent

    set_code_authorizations.go uses types.ParseDelegation from "github.com/ethereum/go-ethereum/core/types". The new code aliases the same package as ethtypes — identical function, consistent package. No issue.

    ✅ common.BytesToHash(acct.CodeHash) is consistent

    This is the same pattern used in x/evm/statedb/state_object.go:157. Correct.

    ✅ No consensus/state-breaking changes

    This is an ante-handler change (transaction validation). It affects which transactions are accepted, not how state is written. Validators running the new code will reject non-EIP-7702 contract senders that the old code (incorrectly) allowed. This is a consensus-level tightening of rules, but it is the correct behaviour according to EIP-3607 — the old behaviour was the bug. No migration needed.

    ---

    Minor suggestions

    ante/eth.go:93-99 — consider adding a one-line comment explaining why GetCode is needed (i.e., EIP-7702 exemption), to make the intent obvious to future readers.

    // EIP-3607: reject contract senders, but allow EIP-7702 delegation designators.
    if acct.IsContract() {
        code := evmKeeper.GetCode(ctx, common.BytesToHash(acct.CodeHash))
        if _, delegated := ethtypes.ParseDelegation(code); !delegated {
    

    ---

    Verdict

    The fix is correct and necessary. The two test cases cover the key scenarios. The 0% coverage report is likely stale. Before merging:
    1. Confirm coverage catches up once the CI run on head is reflected.
    2. Consider whether downstream callers of VerifyEthAccount exist outside this repo and need a deprecation note.

    github-actions[bot] github-actions[bot] commented on code on Sep 25, 2026 09:20 UTC
    Code Review
    ante/eth.go:1
    @@ -90,8 +90,9 @@ func VerifyEthAccount(
     		// check whether the sender address is EOA
     		acct := statedb.NewAccountFromSdkAccount(accountGetter(from))
     
    -		if !rules.IsPrague {
    -			if acct.IsContract() {
    +		if acct.IsContract() {

    Consider adding a brief comment here explaining the EIP-7702 exemption intent, since the GetCode call might otherwise look like unnecessary overhead:

    		// EIP-3607: reject contract senders, but allow EIP-7702 delegation designators.
    		if acct.IsContract() {
    

    JayT106 JayT106 approved these changes on Sep 25, 2026 09:29 UTC
    Approved Reviewer

    Approved these changes.

    Reviewers
    Assignees
    randy-cro randy-cro
    Labels
    risk: low confidence: 82.2% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 28.7% (LOW) · Higher = larger blast radius
    28.7%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 82.2% · Lower = rushed or shallow review
    82.2%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 5.1% · Safe to merge
    5.1%