Skip to content

Conversation

@Eric-Warehime
Copy link
Contributor

@Eric-Warehime Eric-Warehime commented Jan 12, 2026

Makes SetBalance public.

This is required in order to be able to properly parallelize gas token sends in cosmos EVM. The existing implementation uses Mint and Burn in order to update the balances of EVM accounts in the corresponding bank token. However, this requires us to hit the module account on ever gas txn.

Directly setting the balance instead removes the mint/burn in the bank wrapper and therefore removes the store access to the same module account value on every txn.

@github-actions
Copy link
Contributor

@Eric-Warehime your pull request is missing a changelog!

@Eric-Warehime Eric-Warehime changed the title public setbalance feat!: public setbalance Jan 12, 2026
@codecov
Copy link

codecov bot commented Jan 13, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 70.18%. Comparing base (3983cab) to head (2923500).
⚠️ Report is 1 commits behind head on feat/krakatoa.

Additional details and impacted files

Impacted file tree graph

@@                Coverage Diff                @@
##           feat/krakatoa   #25771      +/-   ##
=================================================
- Coverage          70.40%   70.18%   -0.23%     
=================================================
  Files                835      835              
  Lines              54513    54513              
=================================================
- Hits               38381    38258     -123     
- Misses             16132    16255     +123     
Files with missing lines Coverage Δ
x/bank/keeper/keeper.go 89.26% <100.00%> (ø)
x/bank/keeper/send.go 92.10% <100.00%> (ø)

... and 3 files with indirect coverage changes

Impacted file tree graph

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

CreditVirtualAccounts(ctx context.Context) error
SendCoinsFromVirtual(ctx context.Context, fromAddr, toAddr sdk.AccAddress, amt sdk.Coins) error
SendCoinsToVirtual(ctx context.Context, fromAddr, toAddr sdk.AccAddress, amt sdk.Coins) error
SetBalance(ctx context.Context, addr sdk.AccAddress, balance sdk.Coin) error
Copy link
Contributor

Choose a reason for hiding this comment

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

this feels like a dangerous method to include in the base interface

i'm (fairly) certain all of these methods here are fool proof, but SetBalance is not. for example, Mint/BurnCoins handles updating the supply for you. SetBalance can be misused and put the state out of whack.

would it make more sense to have an UnsafeBank or SudoBank-esque interface?

@yihuang
Copy link
Collaborator

yihuang commented Jan 23, 2026

This is required in order to be able to properly parallelize gas token sends in cosmos EVM. The existing implementation uses Mint and Burn in order to update the balances of EVM accounts in the corresponding bank token. However, this requires us to hit the module account on ever gas txn.

What we did before is use SendCoins instead of mint and burn in EVM, but it requires a change in cosmos evm side.

// setBalance sets the coin balance for an account by address.
func (k BaseSendKeeper) setBalance(ctx context.Context, addr sdk.AccAddress, balance sdk.Coin) error {
// SetBalance sets the coin balance for an account by address.
func (k BaseSendKeeper) SetBalance(ctx context.Context, addr sdk.AccAddress, balance sdk.Coin) error {
Copy link
Collaborator

@yihuang yihuang Jan 23, 2026

Choose a reason for hiding this comment

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

Compare SetBalance with SendCoins or Mint/Burn:

  • SetBalance don't check the LockedCoins of vesting accounts.
  • SetBalance don't update supply, it assumes the caller will keep the supply unchanged.
  • SetBalance don't emit events.

Especially the first one, it seems can become a security vulnerability easily if the caller is not careful.

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.

5 participants