fix(sims): check before sending RotateConsPubKey (#20659)

This commit is contained in:
Facundo Medica 2024-06-13 16:09:00 +02:00 committed by GitHub
parent 748a939d92
commit ec96e79553
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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,