Skip to content

feat(evmonly): add eth_getTransactionCount, eth_blockNumber, eth_chainId RPC, backport eth_getBalance - #4192

Merged
shemnon merged 5 commits into
giga-1from
scope/giga-evmonly-nonce-blocknumber-chainid-giga1
Sep 15, 2026
Merged

shemnon merged 5 commits into
giga-1from
scope/giga-evmonly-nonce-blocknumber-chainid-giga1

Conversation

@shemnon

@shemnon shemnon commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

Describe your changes and provide context

Backports the eth_getTransactionCount, eth_blockNumber, and eth_chainId
RPC methods to giga-1, on top of the eth_getBalance backport (#4174).

  • add eth_getTransactionCount, eth_blockNumber, eth_chainId, backed
    by new Backend.EvmTransactionCount/EvmBlockNumber/EvmChainID
    methods
  • rename Backend.EvmNonce to Backend.EvmTransactionCount to match the
    RPC method name; the underlying abci.Application.EvmNonce is
    unchanged
  • reorganize giga/evmonly/rpc to group methods by JSON-RPC namespace
    (state.go, tx.go, info.go, send.go), matching evmrpc's
    layout instead of one file per method
  • cover the new endpoints in the Autobahn integration test and README

Testing performed to validate your change

  • go build ./...
  • go test ./giga/evmonly/... ./sei-tendermint/internal/evmonlyapp/... ./sei-tendermint/internal/rpc/core/... ./sei-cosmos/server/... ./app/...
  • gofmt -s / goimports clean

…nId RPC

Extends the EVM-only JSON-RPC server with the remaining read-only chain
metadata endpoints, and reorganizes the package to group methods by
JSON-RPC namespace (state.go, tx.go, info.go, send.go) matching evmrpc's
layout instead of one file per method.

- add eth_getTransactionCount, eth_blockNumber, eth_chainId, backed by
  new Backend.EvmTransactionCount/EvmBlockNumber/EvmChainID methods
- rename Backend.EvmNonce to Backend.EvmTransactionCount to match the
  RPC method name; the underlying abci.Application.EvmNonce is unchanged
- cover the new endpoints in the Autobahn integration test and README
- add EvmChainID to sei-cosmos/server/rollback_test.go's mockApplication
  to satisfy the updated abci.Application interface
@shemnon shemnon changed the title Backport giga-1: feat(evmonly): add eth_getTransactionCount, eth_blockNumber, eth_chainId RPC feat(evmonly): add eth_getTransactionCount, eth_blockNumber, eth_chainId RPC, backport eth_getBalance Sep 15, 2026
@cursor

cursor Bot commented Sep 15, 2026

Copy link
Copy Markdown

PR Summary

Medium Risk
Touches the public RPC contract and ABCI Application interface; incorrect committed-state reads could mislead wallets and tooling, though scope is read-only current state.

Overview
Expands the Autobahn EVM-only JSON-RPC surface beyond send/receipt: eth_getBalance, eth_getTransactionCount, eth_blockNumber, and eth_chainId, wired through new Backend hooks and Tendermint Environment helpers that read committed app state (balance/nonce via ABCI, height via LastBlockHeight, chain ID via new EvmChainID() on Application).

The giga/evmonly/rpc package is split into send, tx, state, and info handlers (replacing inline server.go logic). Balance and nonce calls accept latest/safe/finalized/pending only; explicit heights, hashes, and earliest return a clear historical-state unsupported error.

Autobahn integration tests and the README now cover cast nonce, block-number, and chain-id, and assert the new methods across validators after load.

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

@github-actions

github-actions Bot commented Sep 15, 2026

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, 3:49 PM

@shemnon
shemnon enabled auto-merge September 15, 2026 15:30

@seidroid seidroid Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Clean, well-tested backport of eth_getTransactionCount/eth_blockNumber/eth_chainId plus the eth_getBalance backport; the interface change is propagated to every abci.Application implementer and the file reorganization is behaviour-preserving. Two non-blocking notes: pending nonce semantics and a gap between the PR description's claimed integration-test coverage and what is actually asserted.

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

Blockers

  • None at the file/PR level.

Non-blocking

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

Comment thread giga/evmonly/rpc/tx.go
}

// GetTransactionCount returns the address nonce from the current committed EVM state.
func (api *txAPI) GetTransactionCount(_ context.Context, address common.Address, block ethrpc.BlockNumberOrHash) (*hexutil.Uint64, error) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[suggestion] pending is accepted here but resolves to the committed nonce (evmOnlyApplication.EvmNonce reads the committed StateDB view; the Autobahn mempool is not consulted). Standard Ethereum tooling — cast send, ethers, viem — requests eth_getTransactionCount(addr, "pending") to pick the next nonce, so two back-to-back sends from the same key will reuse a nonce while the first transaction is still in flight, and the second is rejected.

The README rationale added for this (integration_test/autobahn/README.md:437-438, "all four read the same current committed state, because Sei has instant finality") isn't quite right: instant finality removes reorg risk, not the broadcast-to-commit window that pending exists to cover. Returning latest is a defensible tradeoff (rejecting pending would break cast send outright), but the caveat is worth stating accurately in the README so the next person debugging a nonce collision doesn't have to rediscover it.

assertEVMOnlyReceipts(t, ctx, clients, block.Txs)
assertEVMOnlyBalances(t, ctx, clients, block.Txs)
assertEVMOnlyChainID(t, ctx, clients)
assertEVMOnlyBlockNumber(t, ctx, clients, lastHeight)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[suggestion] The PR description says the new endpoints are covered in the Autobahn integration test, but eth_getTransactionCount is the one new endpoint with no assertion here — only balance, chain ID, and block number are checked (grep getTransactionCount integration_test/autobahn/autobahn_test.go returns nothing). The README also advertises cast nonce against this RPC, so it's the endpoint most likely to be exercised by users.

An assertEVMOnlyTransactionCount mirroring assertEVMOnlyBalances would close this: decode txs[nodeIndex], recover the sender, and assert the nonce advanced past the transaction's own nonce (and/or assert the fresh recipient's nonce is 0).

@codecov

codecov Bot commented Sep 15, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 57.81250% with 27 lines in your changes missing coverage. Please review.
✅ Project coverage is 65.53%. Comparing base (7e3ca24) to head (b484653).
⚠️ Report is 4 commits behind head on giga-1.

Files with missing lines Patch % Lines
sei-tendermint/abci/types/mocks/application.go 0.00% 8 Missing ⚠️
giga/evmonly/rpc/send.go 81.81% 4 Missing ⚠️
giga/evmonly/rpc/server.go 42.85% 4 Missing ⚠️
sei-tendermint/internal/rpc/core/mempool.go 0.00% 4 Missing ⚠️
sei-tendermint/internal/proxy/proxy.go 0.00% 2 Missing ⚠️
app/abci.go 0.00% 1 Missing ⚠️
sei-cosmos/baseapp/baseapp.go 0.00% 1 Missing ⚠️
sei-tendermint/abci/types/application.go 0.00% 1 Missing ⚠️
sei-tendermint/internal/evmonlyapp/app.go 0.00% 1 Missing ⚠️
sei-tendermint/node/mock_app.go 0.00% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           giga-1    #4192      +/-   ##
==========================================
- Coverage   65.55%   65.53%   -0.03%     
==========================================
  Files        2081     2080       -1     
  Lines      157460   157147     -313     
==========================================
- Hits       103222   102985     -237     
+ Misses      54097    54021      -76     
  Partials      141      141              
Flag Coverage Δ
sei-chain-pr 62.90% <57.81%> (?)
sei-db ?

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

Files with missing lines Coverage Δ
giga/evmonly/rpc/info.go 100.00% <100.00%> (ø)
giga/evmonly/rpc/state.go 100.00% <100.00%> (ø)
giga/evmonly/rpc/tx.go 87.87% <100.00%> (ø)
app/abci.go 62.50% <0.00%> (-0.40%) ⬇️
sei-cosmos/baseapp/baseapp.go 82.25% <0.00%> (-0.19%) ⬇️
sei-tendermint/abci/types/application.go 47.61% <0.00%> (-2.39%) ⬇️
sei-tendermint/internal/evmonlyapp/app.go 81.34% <0.00%> (-0.43%) ⬇️
sei-tendermint/node/mock_app.go 88.18% <0.00%> (-0.70%) ⬇️
sei-tendermint/internal/proxy/proxy.go 87.23% <0.00%> (-3.88%) ⬇️
giga/evmonly/rpc/send.go 81.81% <81.81%> (ø)
... and 3 more

... and 5 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.

@shemnon
shemnon disabled auto-merge September 15, 2026 15:41
…ionCount

Addresses seidroid review notes on #4192.

- eth_getTransactionCount accepts pending for tooling compatibility but
  resolves it to the committed nonce; the README previously attributed
  this to instant finality, which explains away reorg risk, not the
  broadcast-to-commit window pending exists to cover
- add assertEVMOnlyTransactionCount to the Autobahn integration test,
  mirroring assertEVMOnlyBalances, closing the gap between the PR
  description's claimed coverage and what was actually asserted
…mber-chainid-giga1' into scope/giga-evmonly-nonce-blocknumber-chainid-giga1
@shemnon
shemnon enabled auto-merge September 15, 2026 15:50
@shemnon
shemnon added this pull request to the merge queue Sep 15, 2026
Merged via the queue into giga-1 with commit 2a9c010 Sep 15, 2026
67 of 69 checks passed
@shemnon
shemnon deleted the scope/giga-evmonly-nonce-blocknumber-chainid-giga1 branch September 15, 2026 21:15
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.

2 participants