Skip to content

Conversation

@m-Peter
Copy link
Collaborator

@m-Peter m-Peter commented Nov 14, 2025

Depends on: onflow/flow-go#8148
Closes: #920

Description

For the gas estimation to work properly for EIP-7702 transactions, we must apply any given SetCodeAuthorization list to DryCall.


For contributor use:

  • Targeted PR against master branch
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work.
  • Code follows the standards mentioned here.
  • Updated relevant documentation
  • Re-reviewed Files changed in the Github PR explorer
  • Added appropriate labels

Summary by CodeRabbit

  • New Features

    • Dry-run transactions now include code authorizations.
    • Transactions with authorization lists now use pre-send gas estimation.
  • Tests

    • Updated tests to apply estimated gas and explicit gas parameters where relevant.
  • Chores

    • Bumped Flow framework and emulator versions.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 14, 2025

Walkthrough

Adds transaction code authorizations to dry-run/gas-estimate call sites, updates tests to use eth_estimateGas and adjust transaction gas/destinations, and bumps Flow-related dependency versions in module files.

Changes

Cohort / File(s) Summary
DryCall — include code authorizations
api/debug.go, services/requester/requester.go
Pass tx.SetCodeAuthorizations() as an additional argument into the dry-run (view.DryCall / DryCall) invocation so dry-run/gas-estimate includes the transaction's code authorization list.
Dependency bumps
go.mod, tests/go.mod
Bumped github.com/onflow/flow-go in go.mod; bumped github.com/onflow/flow-go and github.com/onflow/flow-emulator versions in tests/go.mod.
EIP-7702 test adjustments
tests/web3js/eth_eip_7702_sending_transactions_test.js
Added eth_estimateGas calls to compute gas before sending transactions; apply estimated gas to sendTransaction calls; changed several transaction destinations to use relay.address in specific tests.
Pectra test gas param
tests/web3js/eth_pectra_upgrade_test.js
Added explicit gas: 63779n to a walletClient.writeContract call in the pre-Pectra relay-account test.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant Gateway
    participant DryCall
    participant Executor

    rect rgb(245, 250, 255)
    Note over Gateway,DryCall: Dry-run now receives Code Authorizations
    Client->>Gateway: Request eth_estimateGas / submit tx
    Gateway->>DryCall: DryCall(tx.Data(), tx.SetCodeAuthorizations(), tx.Value(), ...)
    DryCall->>Executor: Execute dry-run with code-auth context
    Executor-->>DryCall: Gas usage result
    DryCall-->>Gateway: Return gas estimate
    Gateway-->>Client: Use returned gas for tx submission
    end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

  • Pay attention to the two DryCall call sites where the extra argument is inserted and ensure argument ordering matches the DryCall signature.
  • Verify tests that now call eth_estimateGas and transactions with adjusted destinations/gas.

Possibly related PRs

Suggested reviewers

  • zhangchiqing
  • janezpodhostnik
  • peterargue

Poem

🐇 I hopped through code with tiny paws,
I slipped auth lists into dry-run laws.
Gas now counts who can set the code,
Tests repaved and deps in tow —
A joyful hop, then off I pause.

Pre-merge checks and finishing touches

✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main purpose of the pull request: fixing gas estimation for EIP-7702 transactions by applying SetCodeAuthorizations to DryCall.
Linked Issues check ✅ Passed The pull request addresses all core requirements from issue #920: applying SetCodeAuthorizations to DryCall for proper gas estimation in EIP-7702 transactions.
Out of Scope Changes check ✅ Passed All changes align with the stated objective; dependency version updates and test modifications support the primary fix of enabling SetCodeAuthorizations in dry-run estimation.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch mpeter/dry-call-apply-set-code-authorizations

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f51e9ef and 80bd06b.

⛔ Files ignored due to path filters (2)
  • go.sum is excluded by !**/*.sum
  • tests/go.sum is excluded by !**/*.sum
📒 Files selected for processing (2)
  • go.mod (1 hunks)
  • tests/go.mod (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • go.mod
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Lint
  • GitHub Check: Test
🔇 Additional comments (1)
tests/go.mod (1)

10-10: Dependency versions verified as available and compatible.

Both updated Flow dependency versions exist in their repositories and the code changes correctly use the new DryCall signature with SetCodeAuthorizations. The transition from experimental to stable flow-go v0.44.0 is confirmed, and no build or runtime incompatibilities exist.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
tests/web3js/eth_pectra_upgrade_test.js (1)

60-60: Consider using gas estimation instead of hardcoding.

The hardcoded gas value 63779n could become outdated if gas calculation logic changes. Since this test validates pre-Pectra rejection behavior rather than gas correctness, consider either:

  • Using eth_estimateGas to dynamically determine the gas value, or
  • Adding a comment explaining the hardcoded value's origin
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ad19290 and 61b7330.

⛔ Files ignored due to path filters (2)
  • go.sum is excluded by !**/*.sum
  • tests/go.sum is excluded by !**/*.sum
📒 Files selected for processing (6)
  • api/debug.go (1 hunks)
  • go.mod (1 hunks)
  • services/requester/requester.go (1 hunks)
  • tests/go.mod (1 hunks)
  • tests/web3js/eth_eip_7702_sending_transactions_test.js (5 hunks)
  • tests/web3js/eth_pectra_upgrade_test.js (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-01-29T17:20:28.143Z
Learnt from: m-Peter
Repo: onflow/flow-evm-gateway PR: 738
File: .github/workflows/ci.yml:19-19
Timestamp: 2025-01-29T17:20:28.143Z
Learning: Go 1.23 was released and is available for use in CI/CD pipelines and Docker images.

Applied to files:

  • tests/go.mod
🧬 Code graph analysis (1)
tests/web3js/eth_eip_7702_sending_transactions_test.js (6)
tests/web3js/eth_pectra_upgrade_test.js (11)
  • conf (2-2)
  • require (1-1)
  • require (6-6)
  • require (7-7)
  • require (8-8)
  • helpers (3-3)
  • web3 (4-4)
  • eoa (11-11)
  • authorization (47-50)
  • response (118-121)
  • hash (22-22)
tests/web3js/eth_deploy_contract_and_interact_test.js (5)
  • conf (2-2)
  • require (1-1)
  • helpers (3-3)
  • web3 (4-4)
  • response (281-284)
tests/web3js/debug_traces_test.js (6)
  • conf (2-2)
  • require (1-1)
  • helpers (3-3)
  • web3 (4-4)
  • response (22-25)
  • response (457-460)
tests/web3js/contract_call_overrides_test.js (6)
  • conf (2-2)
  • require (1-1)
  • helpers (3-3)
  • web3 (4-4)
  • response (35-38)
  • response (125-128)
tests/web3js/eth_eip_7702_contract_write_test.js (10)
  • require (1-1)
  • require (2-2)
  • require (3-3)
  • require (4-4)
  • eoa (7-7)
  • authorization (43-46)
  • authorization (106-109)
  • hash (18-18)
  • hash (49-54)
  • hash (112-117)
tests/web3js/viem/config.js (5)
  • require (1-1)
  • require (2-2)
  • require (3-3)
  • relay (24-24)
  • walletClient (26-30)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Lint
  • GitHub Check: Test
🔇 Additional comments (8)
api/debug.go (1)

239-247: LGTM! Authorization list correctly added to trace path.

The addition of tx.SetCodeAuthorizations() ensures that debug_traceCall properly accounts for EIP-7702 SetCode authorizations during dry-run execution, which is essential for accurate tracing of EIP-7702 transactions.

services/requester/requester.go (1)

570-578: LGTM! Core fix for EIP-7702 gas estimation.

The addition of tx.SetCodeAuthorizations() to the DryCall invocation ensures that gas estimation correctly accounts for SetCode authorization processing. This addresses the PR's primary objective: making eth_estimateGas apply the authorization list during dry-run execution, yielding accurate gas estimates for EIP-7702 transactions.

Note that lines 439-441 properly add the per-authorization gas overhead (CallNewAccountGas) on top of the base dry-run estimate.

tests/go.mod (1)

10-12: LGTM! Test dependencies properly aligned.

The version bumps for flow-emulator and flow-go ensure the test environment has the updated DryCall signature and maintains consistency with the main module's dependencies.

tests/web3js/eth_eip_7702_sending_transactions_test.js (5)

6-8: LGTM! Imports added for gas estimation functionality.

The added imports provide the necessary utilities for calling eth_estimateGas via RPC and performing hex conversions for the authorization list parameters.


52-77: LGTM! Gas estimation validation correctly implemented.

The test properly constructs transaction arguments including the authorization list, calls eth_estimateGas, and validates the result. This confirms that the fix correctly accounts for EIP-7702 SetCode authorizations during gas estimation.

The expected value 63779n provides a regression test to catch future gas calculation changes.


87-87: LGTM! Test uses estimated gas for transaction execution.

Using the estimated gas value validates that the estimation is not only correct numerically but also sufficient for actual transaction execution, confirming the fix works end-to-end.


142-177: LGTM! Self-executing test correctly implements gas estimation and address handling.

The gas estimation pattern mirrors the first test, and the change to relay.address as the transaction target is correct for self-executing EIP-7702 transactions where the sender designates the contract onto their own address.


212-212: LGTM! Correct target address for post-designation transaction.

After self-executing designation, the ping transaction correctly targets relay.address, which now has the contract code designated onto it.

go.mod Outdated
github.com/onflow/atree v0.11.0
github.com/onflow/cadence v1.8.3
github.com/onflow/flow-go v0.44.0-experimental-cadence-v1.8.3.0.20251111112227-097f521427a5
github.com/onflow/flow-go v0.44.0-experimental-cadence-v1.8.3.0.20251114081035-3a1a77607d8a
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a tagged version for this yet?

Copy link
Collaborator Author

@m-Peter m-Peter Nov 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at https://github.com/onflow/flow-go/tags, there doesn't seem to be any tagged version for the v0.44 release/feature branch.
I did update the version to the latest commit on that branch, as I was still using the commit from a PR.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update: I have used the newly tagged version of v0.44, in 80bd06b .

@m-Peter m-Peter force-pushed the mpeter/dry-call-apply-set-code-authorizations branch from 929a78f to f51e9ef Compare November 20, 2025 09:47
@m-Peter m-Peter requested a review from peterargue November 20, 2025 14:05
@m-Peter m-Peter force-pushed the mpeter/dry-call-apply-set-code-authorizations branch from f51e9ef to 80bd06b Compare November 20, 2025 17:08
@m-Peter m-Peter merged commit bbeb971 into main Nov 21, 2025
2 checks passed
@m-Peter m-Peter deleted the mpeter/dry-call-apply-set-code-authorizations branch November 21, 2025 09:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Gas estimation fails for EIP-7702 transactions

4 participants