Skip to content

fix: evm-0.6.1 hotfix - #19

Merged
mattkii merged 3 commits into
mainfrom
fix/evm-v0.6.1-hotfix
Jul 28, 2026
Merged

fix: evm-0.6.1 hotfix#19
mattkii merged 3 commits into
mainfrom
fix/evm-v0.6.1-hotfix

Conversation

@mattkii

@mattkii mattkii commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Description

Ports the July 2026 Cosmos EVM hotfix into the public fork, now that upstream has published it as cosmos/evm v0.6.1.

These changes were carried privately during the coordinated disclosure window and are already running in production: kiichaind v7.3.0 was built from this exact tree and Oro testnet upgraded to it at height 33659735.

Commits, applied directly on top of main:

  • chore: align gas usage with EVM semantics (#1049) — precompile gas accounting
  • fix(statedb): snapshot locked balance on statedb account (backport #1187) (#1190) — StateDB locked-balance snapshotting
  • Merge of changes — accompanying feemarket/StateDB fixes and integration tests

The resulting tree matches the private mirror at v0.6.0-fork.3 exactly, so no source change is introduced relative to the audited v7.3.0 binary.

These are state-machine-breaking and must be adopted at a coordinated upgrade height.

Follow-up once merged: tag v0.6.1-fork.1 and flip the replace in KiiChain/kiichain from KiiChain/evm-private v0.6.0-fork.3 to the public tag, then remove the private-repo CI auth.


Author Checklist

I have...

  • tackled an existing issue or discussed with a team member
  • left instructions on how to review the changes
  • targeted the main branch

vladjdk and others added 3 commits July 15, 2026 12:11
* align gas calculation

* changelog

* lint

* fix tests

* fix test

* Revert "fix test"

This reverts commit 11147e5a609e8e88906922bfa5f1520990b24abc.

* solhint

* lint

* make systemtest time 3s instead of 5s to hit blocktime
…187) (#1190)

* fix(statedb): snapshot locked balance on statedb account  (#1187)

* snapshot locked balance on statedb account creation to calculate spendable + locked bank balance after locked balance changes via precompile

* lint formatting

* modify x/erc20 registering code hash to not silently drop existing accounts locked balacne

* update comments

* Update x/vm/keeper/statedb.go

Co-authored-by: Vlad J <vladjdk@gmail.com>

---------

Co-authored-by: Vlad J <vladjdk@gmail.com>
(cherry picked from commit 008c171178abc8456399e4fc31fe6994ab969da0)

* fix conflicts

* bump sol

---------

Co-authored-by: mattac21 <matt@cosmoslabs.io>
Co-authored-by: Vlad <vladjdk@gmail.com>
@coderabbitai

coderabbitai Bot commented Jul 28, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

The change adds locked-balance snapshots and locked-aware EVM balance updates, including bank-keeper interfaces, implementations, mocks, and integration tests. Native precompile execution now propagates out-of-gas errors directly, with bank precompile coverage measuring consumed gas. Integration tests update gas limits and add vesting, revert, and account-state scenarios. EVM mempool, ERC20 test deployment, consensus defaults, fee-market overflow handling, and test tooling are also updated.

Estimated code review effort: 4 (Complex) | ~60 minutes

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title matches the hotfix theme but is too generic to clearly summarize the main change. Rename it to mention the key change, such as precompile gas accounting and StateDB locked-balance fixes.
✅ Passed checks (3 passed)
Check name Status Explanation
Description check ✅ Passed The description clearly matches the PR scope and summarizes the hotfix, context, and follow-up steps.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/evm-v0.6.1-hotfix

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai 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.

Actionable comments posted: 2

🧹 Nitpick comments (1)
x/vm/statedb/state_object.go (1)

45-48: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Stale doc comment on HasCodeHash.

The comment still reads "IsContract returns..." though the method is HasCodeHash. Minor naming/comment drift, likely predates this diff but is now touched by the line shift.

✏️ Suggested fix
-// IsContract returns if the account contains contract code.
+// HasCodeHash returns if the account contains contract code.
 func (acct Account) HasCodeHash() bool {
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@x/vm/statedb/state_object.go` around lines 45 - 48, Update the doc comment
directly above Account.HasCodeHash to describe HasCodeHash and its boolean
result, replacing the stale IsContract reference while leaving the method
implementation unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@x/precisebank/keeper/keeper.go`:
- Around line 51-54: Update Keeper.LockedCoins to convert the integer-denom
locked coins returned by k.bk.LockedCoins into the extended denomination before
returning them. Preserve the coin amounts while using the denomination
conversion utilities and match the VM BankKeeper contract expected by
lockedCoin() and SetBalance().

In `@x/vm/keeper/statedb.go`:
- Around line 140-147: Update SetBalanceWithLocked to defensively validate
locked before using it in big.Int arithmetic, returning a clear error when it is
nil; preserve the existing amount validation and normal balance-setting behavior
for valid inputs.

---

Nitpick comments:
In `@x/vm/statedb/state_object.go`:
- Around line 45-48: Update the doc comment directly above Account.HasCodeHash
to describe HasCodeHash and its boolean result, replacing the stale IsContract
reference while leaving the method implementation unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 95aecc77-fc27-432e-9bae-62269ed4c6b8

📥 Commits

Reviewing files that changed from the base of the PR and between 9f182d6 and 61ad125.

⛔ Files ignored due to path filters (1)
  • tests/solidity/yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (33)
  • CHANGELOG.md
  • contracts/solidity/ContractCreationTester.sol
  • contracts/solidity/precompiles/bank/testdata/BankCaller.sol
  • evmd/mempool.go
  • evmd/tests/ibc/helper.go
  • evmd/testutil/eth_setup.go
  • precompiles/bank/testdata/BankCaller.json
  • precompiles/bank/testdata/BankCaller.sol
  • precompiles/common/precompile.go
  • tests/integration/precompiles/bank/test_integration.go
  • tests/integration/precompiles/gov/test_integration.go
  • tests/integration/precompiles/staking/test_integration.go
  • tests/integration/precompiles/staking/test_staking.go
  • tests/integration/precompiles/werc20/test_integration.go
  • tests/integration/precompiles/werc20/test_utils.go
  • tests/integration/x/vm/test_call_evm.go
  • tests/integration/x/vm/test_state_transition.go
  • tests/integration/x/vm/test_statedb.go
  • tests/solidity/package.json
  • tests/systemtests/Makefile
  • testutil/integration/params.go
  • x/erc20/keeper/dynamic_precompiles.go
  • x/feemarket/keeper/abci.go
  • x/precisebank/keeper/keeper.go
  • x/precisebank/types/interfaces.go
  • x/precisebank/types/mocks/MockBankKeeper.go
  • x/vm/keeper/keeper.go
  • x/vm/keeper/statedb.go
  • x/vm/statedb/state_object.go
  • x/vm/statedb/statedb.go
  • x/vm/types/interfaces.go
  • x/vm/types/mocks/BankKeeper.go
  • x/vm/wrappers/testutil/mock.go

Comment thread x/precisebank/keeper/keeper.go
Comment thread x/vm/keeper/statedb.go
@mattkii
mattkii merged commit 6375acf into main Jul 28, 2026
13 of 21 checks passed
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.

4 participants