Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(sims): check before sending RotateConsPubKey #20659

Merged
merged 1 commit into from
Jun 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading