From ec96e79553693aca89430ef9e1c014bc7dbdc498 Mon Sep 17 00:00:00 2001 From: Facundo Medica <14063057+facundomedica@users.noreply.github.com> Date: Thu, 13 Jun 2024 16:09:00 +0200 Subject: [PATCH] fix(sims): check before sending RotateConsPubKey (#20659) --- x/staking/simulation/operations.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/x/staking/simulation/operations.go b/x/staking/simulation/operations.go index bf29192578..5be48161ca 100644 --- a/x/staking/simulation/operations.go +++ b/x/staking/simulation/operations.go @@ -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,