Skip to content

fix: distribution precompile 32-byte withdraw address inflates native…#16

Open
mattkii wants to merge 1 commit into
mainfrom
fix/distribution-32byte-withdraw
Open

fix: distribution precompile 32-byte withdraw address inflates native…#16
mattkii wants to merge 1 commit into
mainfrom
fix/distribution-32byte-withdraw

Conversation

@mattkii

@mattkii mattkii commented Jun 12, 2026

Copy link
Copy Markdown

Description

Fixes the distribution-precompile 32-byte withdraw address supply-inflation bug. When a balance event's account is not exactly 20 bytes (e.g. a 32-byte bech32 withdraw, module, or CosmWasm contract account), common.BytesToAddress truncates it to the trailing 20 bytes, causing the StateDB commit to mint a duplicate balance and inflate native supply.

AfterBalanceChange now skips mirroring any non-20-byte account (isMirrorableEVMAddress guard) in the CoinSpent, CoinReceived, and FractionalBalanceChange cases, so only bijective SDK↔EVM accounts are mirrored.

Most critical to review: precompiles/common/balance_handler.go


Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • tackled an existing issue or discussed with a team member
  • left instructions on how to review the changes
  • targeted the main branch — N/A: targets feat/v0.6.0 (the v0.6.0-fork.1 release lineage kiichain pins); a v0.6.0-fork.2 tag will follow

@coderabbitai

coderabbitai Bot commented Jun 12, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 0a7109b5-faea-4962-93fb-ddd855bdc0f8

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/distribution-32byte-withdraw

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 and usage tips.

@mattkii mattkii force-pushed the fix/distribution-32byte-withdraw branch 2 times, most recently from 11ac5c6 to a7e1839 Compare June 12, 2026 14:29
@github-actions github-actions Bot added the build label Jun 12, 2026
@mattkii mattkii marked this pull request as draft June 12, 2026 15:16
@mattkii mattkii force-pushed the fix/distribution-32byte-withdraw branch 5 times, most recently from e52c33e to cc5caea Compare June 14, 2026 22:13
@mattkii mattkii marked this pull request as ready for review June 14, 2026 22:24
@mattkii mattkii force-pushed the fix/distribution-32byte-withdraw branch from cc5caea to c8f7153 Compare June 14, 2026 23:10
@jhelison jhelison requested a review from Copilot June 15, 2026 11:59

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Fixes a native-supply inflation bug in the distribution precompile’s balance mirroring by ensuring only SDK accounts with a bijective 20-byte EVM mapping are mirrored into the EVM StateDB.

Changes:

  • Add an isMirrorableEVMAddress guard to skip mirroring balance events for non-20-byte SDK addresses (prevents common.BytesToAddress truncation collisions).
  • Add a regression test covering the 32-byte address mirroring case.
  • Update system/solidity test infrastructure (systemtest helper usage, consensus-timeout defaults, truffle/solc configuration, and a targeted test skip).

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/systemtests/upgrade_test.go Updates systemtest helper invocation for awaiting upgrade height.
tests/systemtests/suite/test_suite.go Ensures ModifyConsensusTimeout uses default node args when none are provided.
tests/systemtests/mempool/test_replacement.go Skips a known-flaky DynamicFeeTx replacement scenario across nodes.
tests/systemtests/mempool/test_broadcast.go Changes per-case setup in tx broadcasting tests (removes prior “no blocks produced” assertion).
tests/solidity/suites/opcode/truffle-config.js Pins solc to a local soljson.js path for deterministic compilation.
tests/solidity/suites/opcode/package.json Adds solc@0.5.17 for the opcode suite.
tests/solidity/suites/exception/truffle-config.js Pins solc to a local soljson.js path.
tests/solidity/suites/eip1559/truffle-config.js Pins solc to a local soljson.js path.
tests/solidity/suites/basic/truffle-config.js Pins solc to a local soljson.js path.
tests/solidity/package.json Adds solc@0.8.18 to the solidity test harness dependencies.
precompiles/common/balance_handler.go Skips mirroring for non-20-byte SDK addresses to prevent truncated-address duplication in EVM state.
precompiles/common/balance_handler_test.go Adds a regression test for skipping 32-byte address mirroring.
Makefile Updates the legacy binary build checkout ref used by system tests.
CHANGELOG.md Documents the bug fix in the changelog.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/systemtests/mempool/test_broadcast.go
Comment thread precompiles/common/balance_handler_test.go Outdated
@mattkii mattkii force-pushed the fix/distribution-32byte-withdraw branch 3 times, most recently from 203ea0c to cc72173 Compare June 17, 2026 03:04
@mattkii mattkii force-pushed the fix/distribution-32byte-withdraw branch from cc72173 to ceddeaf Compare June 17, 2026 03:45
jhelison
jhelison previously approved these changes Jun 17, 2026
@jhelison jhelison changed the base branch from feat/v0.6.0 to main June 19, 2026 12:39
@jhelison jhelison dismissed their stale review June 19, 2026 12:39

The base branch was changed.

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.

3 participants