Skip to content

Commit

Permalink
fix: Distribution module balance should be >= module holdings on startup
Browse files Browse the repository at this point in the history
Certain modules (e.g. ccvprovider) assign truncated fractions as
rewards, and transfer the full integer amount to the distribution
module. So a long-running chain will almost always fail the assertion if
the module holdings are expected to equal the balance
  • Loading branch information
fastfadingviolets committed Dec 11, 2024
1 parent a38a6a2 commit 1ec7bb2
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions x/distribution/keeper/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ func (k Keeper) InitGenesis(ctx context.Context, data types.GenesisState) error
}

balances := k.bankKeeper.GetAllBalances(ctx, moduleAcc.GetAddress())
if !balances.Equal(moduleHoldingsInt) {
return fmt.Errorf("distribution module balance does not match the module holdings: %s <-> %s", balances, moduleHoldingsInt)
if balances.IsAllLT(moduleHoldingsInt) {
panic(fmt.Sprintf("distribution module balance is less than module holdings: %s < %s", balances, moduleHoldingsInt))
}
return nil
}
Expand Down

0 comments on commit 1ec7bb2

Please sign in to comment.