Skip to content

Commit

Permalink
fix: allow non-EOA accounts to stake in simulation (backport cosmos#1…
Browse files Browse the repository at this point in the history
…6068) (cosmos#16130)

Co-authored-by: Javier Su <javier.su.weijie@gmail.com>
Co-authored-by: Julien Robert <julien@rbrt.fr>
  • Loading branch information
3 people authored and roy-dydx committed Jul 11, 2023
1 parent 640b8c4 commit df27393
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ Ref: https://keepachangelog.com/en/1.0.0/
* (server) [#15984](https://github.com/cosmos/cosmos-sdk/pull/15984) Use `cosmossdk.io/log` package for logging instead of CometBFT logger. NOTE: v0.45 and v0.46 were not using CometBFT logger either. This keeps the same underlying logger (zerolog) as in v0.45.x+ and v0.46.x+ but now properly supporting filtered logging.
* (gov) [#15979](https://github.com/cosmos/cosmos-sdk/pull/15979) Improve gov error message when failing to convert v1 proposal to v1beta1.
* (store) [#16067](https://github.com/cosmos/cosmos-sdk/pull/16067) Add local snapshots management commands.
* (server) [#16061](https://github.com/cosmos/cosmos-sdk/pull/16061) add comet bootstrap command
* (server) [#16061](https://github.com/cosmos/cosmos-sdk/pull/16061) Add Comet bootstrap command.
* (x/staking) [#16068](https://github.com/cosmos/cosmos-sdk/pull/16068) Update simulation to allow non-EOA accounts to stake.

### Bug Fixes

Expand Down
8 changes: 4 additions & 4 deletions x/staking/simulation/operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -366,9 +366,9 @@ func SimulateMsgUndelegate(ak types.AccountKeeper, bk types.BankKeeper, k *keepe
break
}
}
// if simaccount.PrivKey == nil, delegation address does not exist in accs. Return error
// if simaccount.PrivKey == nil, delegation address does not exist in accs. However, since smart contracts and module accounts can stake, we can ignore the error
if simAccount.PrivKey == nil {
return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "account private key is nil"), nil, fmt.Errorf("delegation addr: %s does not exist in simulation accounts", delAddr)
return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "account private key is nil"), nil, nil
}

account := ak.GetAccount(ctx, delAddr)
Expand Down Expand Up @@ -543,9 +543,9 @@ func SimulateMsgBeginRedelegate(ak types.AccountKeeper, bk types.BankKeeper, k *
}
}

// if simaccount.PrivKey == nil, delegation address does not exist in accs. Return error
// if simaccount.PrivKey == nil, delegation address does not exist in accs. However, since smart contracts and module accounts can stake, we can ignore the error
if simAccount.PrivKey == nil {
return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgBeginRedelegate, "account private key is nil"), nil, fmt.Errorf("delegation addr: %s does not exist in simulation accounts", delAddr)
return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgBeginRedelegate, "account private key is nil"), nil, nil
}

account := ak.GetAccount(ctx, delAddr)
Expand Down

0 comments on commit df27393

Please sign in to comment.