Skip to content

Backport giga-1: feat(evmonly): add eth_getBalance RPC - #4174

Open
seidroid[bot] wants to merge 1 commit into
giga-1from
backport-4140-to-giga-1
Open

seidroid[bot] wants to merge 1 commit into
giga-1from
backport-4140-to-giga-1

Conversation

@seidroid

@seidroid seidroid Bot commented Sep 15, 2026

Copy link
Copy Markdown

Backport of #4140 to giga-1.

## Describe your changes and provide context

- expose `eth_getBalance` from the EVM-only JSON-RPC server
- read balances from the current committed EVM state
- support `latest`, `safe`, `finalized`, and `pending`, while rejecting
block heights and hashes until historical state is wired
- add unit, JSON-RPC registration, and Docker integration coverage
- document the endpoint and its supported block selectors in the
Autobahn README

## Testing performed to validate your change

- `go test -race -count=1 ./giga/evmonly/rpc/...`
- `go test -count=1 ./sei-tendermint/internal/rpc/core/...`
- `make autobahn-evmonly-integration-test` (four local Docker
validators, 4,000 finalized transfers, post-transfer balance checks on
every validator)
- `golangci-lint run ./giga/evmonly/rpc/...
./sei-tendermint/internal/rpc/core/...`
- `golangci-lint fmt --diff`

(cherry picked from commit f0cd46c)
@cursor

cursor Bot commented Sep 15, 2026

Copy link
Copy Markdown

PR Summary

Low Risk
Additive read-only RPC with explicit rejection of historical queries; covered by unit and integration tests with no auth or transaction submission changes.

Overview
Adds eth_getBalance to the Autobahn EVM-only JSON-RPC server so clients can read an address’s balance from current committed EVM state.

The handler accepts latest, safe, finalized, and pending (all mapped to the same committed view); explicit block numbers, block hashes, and other tags return historical state is not supported. The EVM-only Backend gains EvmBalance, wired through Environment.EvmBalanceApp.EvmBalance, and the method is registered alongside existing eth_sendRawTransaction / eth_getTransactionReceipt handlers.

Unit tests cover tag acceptance, historical rejection, and HTTP JSON-RPC serving; Autobahn EVM-only load integration asserts per-validator balances after transfers. Autobahn E2E docs document cast balance and update the supported RPC list (balance is no longer listed as a gap).

Reviewed by Cursor Bugbot for commit 3c8f1ca. Bugbot is set up for automated code reviews on this repo. Configure here.

@github-actions

Copy link
Copy Markdown

The latest Buf updates on your PR. Results from workflow Buf / buf (pull_request).

BuildFormatLintBreakingUpdated (UTC)
✅ passed✅ passed✅ passed✅ passedSep 15, 2026, 12:40 PM

@codecov

codecov Bot commented Sep 15, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 84.61538% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 65.55%. Comparing base (9435e24) to head (3c8f1ca).
⚠️ Report is 1 commits behind head on giga-1.

Files with missing lines Patch % Lines
giga/evmonly/rpc/server.go 50.00% 1 Missing ⚠️
sei-tendermint/internal/rpc/core/mempool.go 0.00% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           giga-1    #4174      +/-   ##
==========================================
- Coverage   66.69%   65.55%   -1.14%     
==========================================
  Files        2202     2082     -120     
  Lines      169563   157618   -11945     
==========================================
- Hits       113087   103334    -9753     
+ Misses      56335    54143    -2192     
  Partials      141      141              
Flag Coverage Δ
sei-chain-pr 42.18% <84.61%> (?)
sei-db 74.50% <ø> (ø)
sei-db-state-db ?

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
giga/evmonly/rpc/balance.go 100.00% <100.00%> (ø)
giga/evmonly/rpc/server.go 42.37% <50.00%> (+0.26%) ⬆️
sei-tendermint/internal/rpc/core/mempool.go 51.12% <0.00%> (-0.29%) ⬇️

... and 121 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@seidroid seidroid Bot left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Clean backport of #4140 (eth_getBalance for the EVM-only RPC surface) — the diff is line-for-line identical in scope and size to the original, the new balanceAPI follows the existing sendAPI/receiptAPI shape, and unit plus integration coverage is present. One non-blocking note about the new Environment.EvmBalance wrapper's semantics outside EVM-only mode.

Findings: 0 blocking | 1 non-blocking | 1 posted inline

Blockers

  • None at the file/PR level.

Non-blocking

  • None at the file/PR level.
  • 1 suggestion(s)/nit(s) flagged inline on specific lines.

Inline comments (could not post inline; listed here)

  • sei-tendermint/internal/rpc/core/mempool.go:32 (RIGHT) -- [suggestion] Environment is the generic RPC environment, but this wrapper's contract only holds for the EVM-only application. App.EvmBalance's second parameter is the associated Sei address (see internal/mempool/tx.go, which passes evm.seiAddress); passing nil is fine for evmOnlyApplication, which ignores it, but on app.App (app/abci.go:181) it takes the non-equal branch and adds GetBalance(ctx, nil), and the result is passed through mempoolBalanceFloor — under the mock_balances build tag that floors the answer to the mock top-off amount, so the godoc's "current committed EVM state" would not be what an RPC caller gets. That path is unreachable today because evmonlyrpc.Start only runs when config.EVMOnly is set (sei-tendermint/node/node.go:698), so this is a latent trap rather than a live bug: consider stating the EVM-only precondition in the doc comment, or sourcing the balance from the EVM-only app directly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant