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
|
|
@pratikspatil024 please take a look |
|
@claude review once |
There was a problem hiding this comment.
All my prior review feedback has been addressed in 3fa2927 and follow-ups — off-by-one at the London transition is now guarded with IsLondon(header.Number + 1), CurrentHeader is snapshotted to fix the TOCTOU, the mock is regenerated, and unit tests cover the transition block + pre-London + Cancun/blob cases.
Extended reasoning...
Overview
This PR adds the nonstandard eth_baseFee RPC method that returns the base fee of the next block, plus a Go toolchain bump from 1.26.3 → 1.26.4 (Dockerfile/Dockerfile.alltools/go.mod/cmd/keeper/go.mod/.golangci.yml).
Code changes are small and well-scoped:
eth/api_backend.go: newBaseFeemethod usingeip1559.CalcBaseFee, plus a drive-by snapshot ofCurrentHeader()inBlobBaseFeeto eliminate a double-call race.internal/ethapi/api.go+internal/ethapi/backend.go: wireeth_baseFeethrough the API layer and addBaseFeeto theBackendinterface.eth/filters/IBackend.go: regenerated mock (includes the newBaseFeeentry and unrelated cosmetic param rename inGetEVM, consistent with mockgen output).- Tests: new
TestBaseFee(LondonActive/LondonTransitionBlock/PreLondon) andTestBlobBaseFee(CancunActive/NoExcessBlobGas/NoBlobScheduleConfig) ineth/api_backend_test.go. Mock stubs added ininternal/ethapi/api_test.goandinternal/ethapi/transaction_args_test.goto satisfy the interface.
Security risks
None material. This is a read-only RPC that returns a derived numeric value from the current head header — no state mutation, no auth surface, no input that reaches storage or consensus. The implementation now matches the established "next block" guard pattern used in graphql/graphql.go and eth/gasprice/feehistory.go, so behavior is consistent across sibling endpoints.
Level of scrutiny
Medium-low. The change is a thin wiring of an existing helper (eip1559.CalcBaseFee) into a new RPC, mirroring BlobBaseFee. The interesting correctness question — what happens at the London transition block — was raised in my earlier review and is now fixed and explicitly covered by a unit test that constructs a chain with LondonBlock = 1 and asserts InitialBaseFee is returned at the genesis (pre-London parent → first 1559 block).
Other factors
- Two prior review rounds from me on this PR; this is the third and the author has addressed every point.
- Quality gate passed (SonarQube), no new issues.
- The Go bump 1.26.3 → 1.26.4 is a patch-level version bump applied consistently across all toolchain files.
- The mock regeneration also included a cosmetic
arg1 → staterename inGetEVM— matches what the current generator emits, unrelated to the BaseFee addition.
pratikspatil024
left a comment
There was a problem hiding this comment.
The changes looks good, overall. Are these go version bumps needed? I would recommend removing them (and merging the latest develop, if needed)
|
Your CI failed the pull request without the golang bumps. |
|
Can you try merging develop now and removing those bumps? I believe it should pass now |
|
| # This file configures github.com/golangci/golangci-lint. | ||
| version: '2' | ||
| run: | ||
| go: '1.26.3' |
There was a problem hiding this comment.
please remove this as well



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