diff --git a/types/simulation/account.go b/types/simulation/account.go index 5bc5bfe14dc6..4fc6fd4dfdb2 100644 --- a/types/simulation/account.go +++ b/types/simulation/account.go @@ -3,6 +3,7 @@ package simulation import ( "fmt" "math/rand" + "strings" "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" @@ -67,14 +68,23 @@ func FindAccount(accs []Account, address sdk.Address) (Account, bool) { // amount from the account's available balance. If the user doesn't have enough // funds for paying fees, it returns empty coins. func RandomFees(r *rand.Rand, ctx sdk.Context, spendableCoins sdk.Coins) (sdk.Coins, error) { - if spendableCoins.Empty() { + spendable := sdk.NewCoins() + // remove liquid staking denoms from spendable coins since fees cannot be paid in those denoms + for _, coin := range spendableCoins { + if strings.Contains(coin.Denom, sdk.Bech32PrefixValAddr) { + continue + } + spendable = append(spendable, coin) + } + + if spendable.Empty() { return nil, nil } - perm := r.Perm(len(spendableCoins)) + perm := r.Perm(len(spendable)) var randCoin sdk.Coin for _, index := range perm { - randCoin = spendableCoins[index] + randCoin = spendable[index] if !randCoin.Amount.IsZero() { break } diff --git a/x/staking/simulation/operations.go b/x/staking/simulation/operations.go index eb8dd643f0cd..f6814660056a 100644 --- a/x/staking/simulation/operations.go +++ b/x/staking/simulation/operations.go @@ -785,6 +785,9 @@ func SimulateMsgTokenizeShares(ak types.AccountKeeper, bk types.BankKeeper, k ke // check that tokenization would not exceed global cap params := k.GetParams(ctx) totalStaked := k.TotalBondedTokens(ctx).ToDec() + if totalStaked.IsZero() { + return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgTokenizeShares, "cannot happend - no validators bonded if stake is 0.0"), nil, nil // skip + } totalLiquidStaked := k.GetTotalLiquidStakedTokens(ctx).Add(tokenizeShareAmt).ToDec() liquidStakedPercent := totalLiquidStaked.Quo(totalStaked) if liquidStakedPercent.GT(params.GlobalLiquidStakingCap) {