Skip to content

Commit

Permalink
fix(sims): check before sending RotateConsPubKey (#20659)
Browse files Browse the repository at this point in the history
  • Loading branch information
facundomedica authored Jun 13, 2024
1 parent 748a939 commit ec96e79
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions x/staking/simulation/operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -832,6 +832,17 @@ func SimulateMsgRotateConsPubKey(txGen client.TxConfig, ak types.AccountKeeper,
return simtypes.NoOpMsg(types.ModuleName, msgType, "unable to build msg"), nil, err
}

// check if there's another key rotation for this same key in the same block
allRotations, err := k.GetBlockConsPubKeyRotationHistory(ctx)
if err != nil {
return simtypes.NoOpMsg(types.ModuleName, msgType, "cannot get block cons key rotation history"), nil, err
}
for _, r := range allRotations {
if r.NewConsPubkey.Compare(msg.NewPubkey) == 0 {
return simtypes.NoOpMsg(types.ModuleName, msgType, "cons key already used in this block"), nil, nil
}
}

txCtx := simulation.OperationInput{
R: r,
App: app,
Expand Down

0 comments on commit ec96e79

Please sign in to comment.