ethapi, eth: implement eth_baseFee RPC method#2231
Conversation
Assisted-by: Claude:claude-sonnet-4-6
|
@claude review once |
|
Claude finished @pratikspatil024's task in 1m 37s —— View job Code Review:
|
| Item | Severity |
|---|---|
Double CurrentHeader() call (TOCTOU) |
Medium — should fix |
| No dedicated unit test | Low — nice to have |
| Hand-edited mock file | Nit |
The design is sound — adding BaseFee to the Backend interface alongside BlobBaseFee is the right pattern, and the RPC layer wiring is correct. The TOCTOU fix is a one-line change; with that addressed, this looks good to merge.
There was a problem hiding this comment.
LGTM, straightforward read-only RPC method mirroring the existing BlobBaseFee pattern.
Extended reasoning...
Overview
This PR adds a new nonstandard eth_baseFee RPC method that returns the calculated base fee of the next block. It adds BaseFee(ctx) *big.Int to the Backend interface, implements it in EthAPIBackend using eip1559.CalcBaseFee, exposes it via EthereumAPI.BaseFee, and updates the generated gomock and two test backends to satisfy the interface.
Security risks
None identified. This is a read-only RPC method that computes a value already used internally and reachable via other paths (e.g. eth_feeHistory). No state mutation, no auth/crypto/permission surface, no user-controlled input beyond the standard JSON-RPC framing.
Level of scrutiny
Low. The change is mechanical and self-contained: it directly mirrors the adjacent BlobBaseFee implementation in the same file, uses the standard upstream eip1559.CalcBaseFee helper guarded by IsLondon, and the bulk of the diff is regenerated mock/test plumbing required to satisfy the new interface method.
Other factors
- Bug hunting system found no issues.
- SonarCloud quality gate passed (0 new issues, 0 security hotspots).
- Pre-London branch correctly returns nil, matching the BlobBaseFee precedent.
- Test mocks are updated consistently across
api_test.go,transaction_args_test.go, and the generatedeth/filters/IBackend.go.
Assisted-by: Claude:claude-sonnet-4-6
I regenerated it in 7e3a704 using |
|
@wjmelements Please resolve the conflicts and check the claude comments. |
Assisted-by: Claude:claude-sonnet-4-6
Assisted-by: Claude:claude-sonnet-4-6
Assisted-by: Claude:claude-sonnet-4-6
|
One of the test failures was because of the go version. |
Assisted-by: Claude:claude-sonnet-4-6
|
@pratikspatil024 please take a look |
|
@claude review |
There was a problem hiding this comment.
Prior feedback (TOCTOU, regenerated mocks, unit tests) is fully addressed; remaining off-by-one is a one-block nit with no impact on Bor mainnet/Amoy.
Extended reasoning...
Overview
This PR adds the nonstandard eth_baseFee RPC method, which returns the calculated base fee of the next block — mirroring the existing BlobBaseFee pattern. The scope is small: a new method on the Backend interface, a one-liner RPC wrapper, the EthAPIBackend implementation, mock and test-backend conformance, and unit tests for both BaseFee and BlobBaseFee. The PR also bumps Go from 1.26.3 → 1.26.4 across Dockerfile, .golangci.yml, and go.mod files.
Security risks
None of substance. The endpoint is read-only, exposes only the base-fee derivation already computable from public block data, and the underlying eip1559.CalcBaseFee helper already guards pre-London parents internally. No auth, crypto, permissions, or input-validation surface is touched.
Level of scrutiny
Low-to-moderate. This is a non-breaking, additive RPC method following an established pattern. The wiring (interface, RPC layer, backend implementation) is mechanical and matches the sibling BlobBaseFee exactly. The test additions and mock regeneration further reduce risk.
Other factors
My prior review on this PR flagged three items: a TOCTOU race from double-calling CurrentHeader(), a hand-edited mock file, and missing unit tests. All three are resolved in the current revision — BaseFee and BlobBaseFee now capture the header once, IBackend.go was regenerated via golang/mock v1.6.0, and TestBaseFee/TestBlobBaseFee cover the active-fork, inactive-fork, and missing-config paths. SonarQube quality gate passes. The one remaining inline-commented nit — an off-by-one in the IsLondon(header.Number) guard at the London transition block — has negligible practical impact: Bor mainnet (LondonBlock 22640000) and Amoy (73100) crossed London long ago, so it only manifests on future devnets with a non-zero LondonBlock. Approving on that basis.
…transition Assisted-by: Claude:claude-sonnet-4-6
|



Summary
Add the nonstandard
eth_baseFeemethod, which returns the calculated base fee of the next block.Executed tests
None
Rollout notes
Non-breaking