Skip to content

perf(evm): cache repeated balance lookups - #3986

Draft
codchen wants to merge 1 commit into
mainfrom
codex/cache-evm-balance-lookups
Draft

perf(evm): cache repeated balance lookups#3986
codchen wants to merge 1 commit into
mainfrom
codex/cache-evm-balance-lookups

Conversation

@codchen

@codchen codchen commented Aug 24, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • cache spendable EVM balances within an execution request so repeated EXTCODEHASH calls for no-code addresses avoid repeated bank, vesting, and auth account work
  • scope cached entries to the active multistore layer and invalidate them at bank and auth write choke points
  • preserve behavior across snapshots, reverts, copies, tracer resets, nested StateDBs, and the Giga implementation

Testing

  • go test ./x/evm/state ./x/evm/keeper ./giga/deps/xevm/state ./giga/deps/xevm/keeper ./sei-cosmos/x/auth/keeper ./sei-cosmos/x/bank/keeper ./giga/deps/xbank/keeper
  • go test -race ./x/evm/state ./giga/deps/xevm/state -run Test(GetCodeHashCachesBalanceForNoCodeAddress|BalanceCache) -count=1
  • go test ./sei-cosmos/types
  • gofmt -d and goimports -d on all touched Go files
  • git diff --check

make fmtcheck could not reach source checks locally because golangci-lint v2.8.0 reported that its Go 1.24.5 build cannot analyze this module targeting Go 1.25.6.

@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✅ passedAug 24, 2026, 2:21 AM

@codecov

codecov Bot commented Aug 24, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 86.41975% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 57.89%. Comparing base (73f917b) to head (c2604af).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
giga/deps/xevm/state/statedb.go 50.00% 6 Missing ⚠️
x/evm/state/statedb.go 66.66% 4 Missing ⚠️
giga/deps/xbank/keeper/send.go 75.00% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3986      +/-   ##
==========================================
- Coverage   58.98%   57.89%   -1.09%     
==========================================
  Files        2310     2212      -98     
  Lines      197500   185998   -11502     
==========================================
- Hits       116487   107683    -8804     
+ Misses      70256    68497    -1759     
+ Partials    10757     9818     -939     
Flag Coverage Δ
sei-chain-pr 77.63% <86.41%> (?)
sei-db 69.80% <ø> (ø)
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/deps/xevm/keeper/balance.go 100.00% <100.00%> (ø)
sei-cosmos/types/context.go 90.94% <100.00%> (+0.06%) ⬆️
sei-cosmos/types/evm_balance_cache.go 100.00% <100.00%> (ø)
sei-cosmos/x/auth/keeper/account.go 69.56% <100.00%> (+1.38%) ⬆️
sei-cosmos/x/bank/keeper/send.go 91.45% <100.00%> (+0.12%) ⬆️
x/evm/keeper/balance.go 100.00% <100.00%> (ø)
giga/deps/xbank/keeper/send.go 84.61% <75.00%> (-0.15%) ⬇️
x/evm/state/statedb.go 78.83% <66.66%> (-0.94%) ⬇️
giga/deps/xevm/state/statedb.go 61.57% <50.00%> (-1.00%) ⬇️

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

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.

1 participant