Skip to content

Conversation

@m-Peter
Copy link
Collaborator

@m-Peter m-Peter commented Oct 27, 2025

Work towards: #912
Depends on: onflow/flow-go#8085

Description

Updates the flow-go version to onflow/flow-go#8085, which enables the Fusaka hard-fork for PreviewNet (a.k.a Emulator) & Testnet networks.


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

  • Chores
    • Updated many direct and transitive dependencies to newer patch/minor versions for compatibility and stability.
  • Bug Fix / Behavioral Change
    • Enforced a maximum gas allowance during gas estimation when targeting Osaka (EIP-7825), clamping excessive gas limits.
  • Tests
    • Added validation test for transactions exceeding the gas cap and a web3js test ensuring eth_estimateGas behavior with high gas limits.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 27, 2025

Walkthrough

Adds dependency bumps in go.mod and tests/go.mod, introduces an Osaka gas-cap clamp in services/requester/requester.go during EstimateGas, and adds tests: a unit test asserting transactions with Gas > MaxTxGas fail and a web3 test for eth_estimateGas with high gas limits. No exported API signatures changed.

Changes

Cohort / File(s) Summary
Dependency version bumps (main module)
go.mod
Bumped multiple direct and indirect module versions (examples: github.com/ethereum/go-ethereum v1.16.4→v1.16.5, github.com/onflow/cadence v1.8.1→v1.8.2, github.com/onflow/flow-go commit update, github.com/onflow/flow-go-sdk v1.9.0→v1.9.1, plus various genproto and transitive updates). No code changes.
Dependency version bumps (test module)
tests/go.mod
Updated test-module dependencies including github.com/ethereum/go-ethereum, github.com/onflow/cadence, github.com/onflow/flow-emulator (newer commit), github.com/onflow/flow-go (commit update), github.com/onflow/flow-go-sdk, google.golang.org/grpc v1.75.1→v1.76.0, and related transitive bumps.
EstimateGas behavior change
services/requester/requester.go
Adds logic in EstimateGas to fetch latest EVM height and block, construct emulator config (applying blockOverrides), detect Osaka network, and clamp passingGasLimit to MaxTxGas when block is Osaka. Existing error propagation retained.
Unit test added
models/transaction_test.go
Adds test "tx limit above gas limit cap" to TestValidateTransaction asserting validation fails when Gas > MaxTxGas (example: cap 16,777,216, tx 16,777,316).
Web3 js test added
tests/web3js/estimate_gas_overrides_test.js
Adds test verifying eth_estimateGas accepts high gas-limit input and returns consistent result when no overrides apply (ensures estimate isn't incorrectly blocked).

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant Requester
  participant FlowNode as Flow node / emulator

  Note over Client,Requester: EstimateGas request
  Client->>Requester: eth_estimateGas(tx, blockOverrides?)
  Requester->>Requester: compute initial passingGasLimit
  alt passingGasLimit > MaxTxGas
    Requester->>FlowNode: GetLatestEVMHeight()
    FlowNode-->>Requester: height (or error)
    Requester->>FlowNode: GetBlockByHeight(height)
    FlowNode-->>Requester: block (or error)
    Requester->>Requester: build emulator config with block + blockOverrides
    alt block.detected_as_Osaka
      Requester->>Requester: clamp passingGasLimit := MaxTxGas
      Note right of Requester: Osaka cap applied (EIP-7825)
    else not_Osaka
      Note right of Requester: no clamp
    end
  end
  Requester->>Requester: continue estimate simulation using passingGasLimit
  Requester-->>Client: eth_estimateGas(result / error)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Pay attention to services/requester/requester.go changes: correctness of height/block retrieval, emulator config building, and precise Osaka detection logic.
  • Verify consistency between MaxTxGas constant usage and tests (models/transaction_test.go).
  • Run unit + integration/web3js tests after dependency updates to catch any indirect breakages from bumped modules.

Possibly related PRs

Suggested labels

EVM, Dependencies, Compatibility

Suggested reviewers

  • zhangchiqing
  • janezpodhostnik
  • peterargue

Poem

🐰 I hopped through modules, leaf by leaf,
Found Osaka's cap and tucked it brief,
A test I planted, firm and tight —
No gas above the limit tonight.
Hop on, green CI, shine bright! 🥕

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The PR title "Enable EVM Fusaka hard-fork for PreviewNet & Testnet" is directly related to the main changes in the changeset. The pull request objectives confirm the primary goal is to update the flow-go version to enable the Fusaka hard-fork, and the code changes support this objective by adding EIP-7825 gas limit capping logic, related tests, and dependency updates. The title is concise, specific enough to convey the primary change, and clearly communicates the main purpose of the PR to a teammate reviewing the history.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch mpeter/enable-fusaka-hard-fork

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.

@m-Peter m-Peter force-pushed the mpeter/enable-fusaka-hard-fork branch from 9b59de4 to d24234e Compare October 27, 2025 11:15
@m-Peter m-Peter force-pushed the mpeter/enable-fusaka-hard-fork branch from d24234e to d55cd8a Compare October 29, 2025 10:43
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

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d24234e and d55cd8a.

⛔ Files ignored due to path filters (2)
  • go.sum is excluded by !**/*.sum
  • tests/go.sum is excluded by !**/*.sum
📒 Files selected for processing (5)
  • go.mod (5 hunks)
  • models/transaction_test.go (1 hunks)
  • services/requester/requester.go (1 hunks)
  • tests/go.mod (5 hunks)
  • tests/web3js/estimate_gas_overrides_test.js (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • models/transaction_test.go
⏰ 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: Test
  • GitHub Check: Lint
🔇 Additional comments (3)
tests/web3js/estimate_gas_overrides_test.js (1)

104-122: LGTM! Good test coverage for Osaka gas cap handling.

The test validates that eth_estimateGas continues to work correctly when provided with gas limits exceeding the EIP-7825 cap (16,777,216), ensuring the new capping logic in the gateway doesn't break estimation behavior.

go.mod (1)

7-7: LGTM! Dependency updates align with Fusaka hard-fork enablement.

The dependency bumps, particularly ethereum/go-ethereum to v1.16.5 and the updated onflow/flow-go commit, provide the necessary Osaka/Fusaka hard-fork support for PreviewNet and Testnet.

Also applies to: 13-15, 37-37, 43-43, 92-92, 149-150, 222-223

tests/go.mod (1)

6-6: LGTM! Test dependency updates maintain consistency with main module.

The test module dependencies are properly synchronized with the main go.mod, ensuring the test environment has the necessary Osaka/Fusaka support.

Also applies to: 8-8, 10-10, 12-13, 25-25, 31-31, 91-91, 160-161, 248-250

Comment on lines +348 to +376
// Cap the maximum gas allowance according to EIP-7825 if the estimation targets Osaka
if passingGasLimit > gethParams.MaxTxGas {
latestBlockHeight, err := e.blocks.LatestEVMHeight()
if err != nil {
return 0, err
}
latestBlock, err := e.blocks.GetByHeight(latestBlockHeight)
if err != nil {
return 0, err
}
blockNumber, blockTime := new(big.Int).SetUint64(latestBlock.Height), latestBlock.Timestamp
emulatorConfig := emulator.NewConfig(
emulator.WithChainID(e.config.EVMNetworkID),
emulator.WithBlockNumber(blockNumber),
emulator.WithBlockTime(blockTime),
)

if blockOverrides != nil {
if blockOverrides.Number != nil {
blockNumber = blockOverrides.Number.ToInt()
}
if blockOverrides.Time != nil {
blockTime = uint64(*blockOverrides.Time)
}
}
if emulatorConfig.ChainConfig.IsOsaka(blockNumber, blockTime) {
passingGasLimit = gethParams.MaxTxGas
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

Verify Osaka check uses correct block height.

The logic fetches the latest block to determine Osaka status (line 350), but the EstimateGas function receives a height parameter that specifies which block to estimate against. This creates a potential mismatch:

  • If height points to a pre-Osaka block but the latest block is post-Osaka, the cap would be incorrectly applied
  • Conversely, if height points to a post-Osaka block but the latest block is pre-Osaka, the cap would be incorrectly skipped

The Osaka check should likely use the target height parameter instead of latestBlockHeight to ensure consistency between the block state being estimated and the hard-fork rules being applied.

Apply this diff to use the target height for Osaka detection:

-	// Cap the maximum gas allowance according to EIP-7825 if the estimation targets Osaka
 	if passingGasLimit > gethParams.MaxTxGas {
-		latestBlockHeight, err := e.blocks.LatestEVMHeight()
-		if err != nil {
-			return 0, err
-		}
-		latestBlock, err := e.blocks.GetByHeight(latestBlockHeight)
+		// Cap the maximum gas allowance according to EIP-7825 if the estimation targets Osaka
+		targetBlock, err := e.blocks.GetByHeight(height)
 		if err != nil {
 			return 0, err
 		}
-		blockNumber, blockTime := new(big.Int).SetUint64(latestBlock.Height), latestBlock.Timestamp
+		blockNumber, blockTime := new(big.Int).SetUint64(targetBlock.Height), targetBlock.Timestamp
 		emulatorConfig := emulator.NewConfig(
 			emulator.WithChainID(e.config.EVMNetworkID),
 			emulator.WithBlockNumber(blockNumber),
 			emulator.WithBlockTime(blockTime),
 		)
 
 		if blockOverrides != nil {
 			if blockOverrides.Number != nil {
 				blockNumber = blockOverrides.Number.ToInt()
 			}
 			if blockOverrides.Time != nil {
 				blockTime = uint64(*blockOverrides.Time)
 			}
 		}
 		if emulatorConfig.ChainConfig.IsOsaka(blockNumber, blockTime) {
 			passingGasLimit = gethParams.MaxTxGas
 		}
 	}


---

🏁 Script executed:

```shell
#!/bin/bash
# Extract the EstimateGas function to understand the full context
# Look for the function definition and surrounding code

rg -n "func.*EstimateGas" services/requester/requester.go -A 100 | head -150

Length of output: 4201


🏁 Script executed:

#!/bin/bash
# Find where dryRunTx is called to see what parameters it receives

rg -n "dryRunTx" services/requester/requester.go -B 5 -A 5

Length of output: 1040


🏁 Script executed:

#!/bin/bash
# Check the function signature and see what the height parameter is

rg -n "func \(e \*EVMRPCRequester\) EstimateGas" services/requester/requester.go -A 30

Length of output: 0


Gas capping uses incorrect block height for Osaka detection.

The EstimateGas function receives a height parameter that specifies which block to estimate the transaction against (line 319), and dryRunTx is correctly called with this parameter (line 329). However, the Osaka fork detection at lines 348-376 fetches latestBlockHeight instead of using the target height, creating a mismatch.

If height and latestBlockHeight differ, the gas cap will be applied based on the wrong fork state:

  • When height is pre-Osaka but latest is post-Osaka: cap incorrectly applied
  • When height is post-Osaka but latest is pre-Osaka: cap incorrectly skipped

Use the target height parameter for Osaka detection to ensure consistency with the block being estimated:

-	// Cap the maximum gas allowance according to EIP-7825 if the estimation targets Osaka
 	if passingGasLimit > gethParams.MaxTxGas {
-		latestBlockHeight, err := e.blocks.LatestEVMHeight()
-		if err != nil {
-			return 0, err
-		}
-		latestBlock, err := e.blocks.GetByHeight(latestBlockHeight)
+		// Cap the maximum gas allowance according to EIP-7825 if the estimation targets Osaka
+		targetBlock, err := e.blocks.GetByHeight(height)
 		if err != nil {
 			return 0, err
 		}
-		blockNumber, blockTime := new(big.Int).SetUint64(latestBlock.Height), latestBlock.Timestamp
+		blockNumber, blockTime := new(big.Int).SetUint64(targetBlock.Height), targetBlock.Timestamp
🤖 Prompt for AI Agents
In services/requester/requester.go around lines 348 to 376, the Osaka fork
detection is using latestBlockHeight instead of the target height parameter —
fetch and use the block at the provided height (i.e., call
e.blocks.GetByHeight(height) and set blockNumber/blockTime from that block) and
build the emulator config after applying blockOverrides (or apply overrides to
the blockNumber/blockTime before creating the emulator.Config); keep existing
error handling for the GetByHeight call and then run IsOsaka against the target
blockNumber/blockTime so the gas cap decision matches the block being estimated.

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

Successfully merging this pull request may close these issues.

2 participants