From a643d3afcf2159b0ca0a7a0a428f35ff3b237d0a Mon Sep 17 00:00:00 2001 From: Akhil Kumar P <36399231+akhilkumarpilli@users.noreply.github.com> Date: Fri, 13 Dec 2024 17:47:17 +0530 Subject: [PATCH] chore: backport x/staking integration test migration changes (#22863) --- baseapp/abci_utils.go | 29 ++++++++++++++++++++++----- testutil/configurator/configurator.go | 1 + x/staking/keeper/cons_pubkey.go | 2 +- 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/baseapp/abci_utils.go b/baseapp/abci_utils.go index bc0cb9dacc..7a2f8e8bd7 100644 --- a/baseapp/abci_utils.go +++ b/baseapp/abci_utils.go @@ -15,6 +15,7 @@ import ( "github.com/cosmos/gogoproto/proto" "cosmossdk.io/core/comet" + "cosmossdk.io/core/header" cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" @@ -46,11 +47,29 @@ func ValidateVoteExtensions( valStore ValidatorStore, extCommit abci.ExtendedCommitInfo, ) error { - // Get values from context - cp := ctx.ConsensusParams() //nolint:staticcheck // ignore linting error - currentHeight := ctx.HeaderInfo().Height - chainID := ctx.HeaderInfo().ChainID - commitInfo := ctx.CometInfo().LastCommit + return ValidateVoteExtensionsWithParams( + ctx, + ctx.ConsensusParams(), //nolint:staticcheck // ignore linting error + ctx.HeaderInfo(), + ctx.CometInfo(), + valStore, + extCommit, + ) +} + +// ValidateVoteExtensionsWithParams defines a helper function for verifying vote extension +// signatures with consensus params, header info and comet info taken as input +func ValidateVoteExtensionsWithParams( + ctx context.Context, + cp cmtproto.ConsensusParams, + headerInfo header.Info, + cometInfo comet.Info, + valStore ValidatorStore, + extCommit abci.ExtendedCommitInfo, +) error { + currentHeight := headerInfo.Height + chainID := headerInfo.ChainID + commitInfo := cometInfo.LastCommit // Check that both extCommit + commit are ordered in accordance with vp/address. if err := validateExtendedCommitAgainstLastCommit(extCommit, commitInfo); err != nil { diff --git a/testutil/configurator/configurator.go b/testutil/configurator/configurator.go index 82399afa10..70d460c6b2 100644 --- a/testutil/configurator/configurator.go +++ b/testutil/configurator/configurator.go @@ -165,6 +165,7 @@ func AuthModule() ModuleOption { {Account: "fee_collector"}, {Account: testutil.DistributionModuleName, Permissions: []string{"minter"}}, {Account: testutil.MintModuleName, Permissions: []string{"minter"}}, + {Account: testutil.StakingModuleName, Permissions: []string{"minter"}}, {Account: "bonded_tokens_pool", Permissions: []string{"burner", testutil.StakingModuleName}}, {Account: "not_bonded_tokens_pool", Permissions: []string{"burner", testutil.StakingModuleName}}, {Account: testutil.GovModuleName, Permissions: []string{"burner"}}, diff --git a/x/staking/keeper/cons_pubkey.go b/x/staking/keeper/cons_pubkey.go index d60d4628b9..189cdf3efd 100644 --- a/x/staking/keeper/cons_pubkey.go +++ b/x/staking/keeper/cons_pubkey.go @@ -263,7 +263,7 @@ func (k Keeper) GetBlockConsPubKeyRotationHistory(ctx context.Context) ([]types. } // GetValidatorConsPubKeyRotationHistory iterates over all the rotated history objects in the state with the given valAddr and returns. -func (k Keeper) GetValidatorConsPubKeyRotationHistory(ctx sdk.Context, operatorAddress sdk.ValAddress) ([]types.ConsPubKeyRotationHistory, error) { +func (k Keeper) GetValidatorConsPubKeyRotationHistory(ctx context.Context, operatorAddress sdk.ValAddress) ([]types.ConsPubKeyRotationHistory, error) { var historyObjects []types.ConsPubKeyRotationHistory rng := collections.NewPrefixedPairRange[[]byte, uint64](operatorAddress.Bytes())