From 9698eaac65b8fb893279a583a0f7ecec8fe77ff9 Mon Sep 17 00:00:00 2001 From: mpoke Date: Wed, 28 Aug 2024 17:12:14 +0200 Subject: [PATCH] fix error due to rebase --- x/ccv/provider/keeper/hooks.go | 39 +------------------ .../keeper/partial_set_security_test.go | 1 - x/ccv/provider/migrations/v8/migrations.go | 5 ++- 3 files changed, 4 insertions(+), 41 deletions(-) diff --git a/x/ccv/provider/keeper/hooks.go b/x/ccv/provider/keeper/hooks.go index 77e5cb9bee..7813837276 100644 --- a/x/ccv/provider/keeper/hooks.go +++ b/x/ccv/provider/keeper/hooks.go @@ -2,8 +2,8 @@ package keeper import ( "context" + "cosmossdk.io/math" - "fmt" sdk "github.com/cosmos/cosmos-sdk/types" sdkgov "github.com/cosmos/cosmos-sdk/x/gov/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" @@ -108,49 +108,12 @@ func (h Hooks) BeforeTokenizeShareRecordRemoved(_ context.Context, _ uint64) err // AfterProposalSubmission - call hook if registered // If an update consumer message exists in the proposal, a record is created that maps the proposal id to the consumer id func (h Hooks) AfterProposalSubmission(goCtx context.Context, proposalId uint64) error { - ctx := sdk.UnwrapSDKContext(goCtx) - - p, err := h.k.govKeeper.Proposals.Get(ctx, proposalId) - if err != nil { - return fmt.Errorf("cannot retrieve proposal with id: %d", proposalId) - } - - err = DoesNotHaveDeprecatedMessage(&p) - if err != nil { - return err - } - - msgUpdateConsumer, err := h.k.HasAtMostOnceCorrectMsgUpdateConsumer(ctx, &p) - if err != nil { - return err - } - - if msgUpdateConsumer != nil { - // a correctly set `MsgUpdateConsumer` was found - h.k.SetProposalIdToConsumerId(ctx, proposalId, msgUpdateConsumer.ConsumerId) - } - return nil } // AfterProposalVotingPeriodEnded - call hook if registered // After proposal voting ends, the consumer to proposal id record in store is deleted. func (h Hooks) AfterProposalVotingPeriodEnded(goCtx context.Context, proposalId uint64) error { - ctx := sdk.UnwrapSDKContext(goCtx) - - p, err := h.k.govKeeper.Proposals.Get(ctx, proposalId) - if err != nil { - return fmt.Errorf("cannot retrieve proposal with id: %d", proposalId) - } - - for _, msg := range p.GetMessages() { - _, isUpdateConsumer := msg.GetCachedValue().(*providertypes.MsgUpdateConsumer) - if isUpdateConsumer { - h.k.DeleteProposalIdToConsumerId(ctx, proposalId) - return nil - } - } - return nil } diff --git a/x/ccv/provider/keeper/partial_set_security_test.go b/x/ccv/provider/keeper/partial_set_security_test.go index 778a9e6fcc..357811441f 100644 --- a/x/ccv/provider/keeper/partial_set_security_test.go +++ b/x/ccv/provider/keeper/partial_set_security_test.go @@ -198,7 +198,6 @@ func TestHandleSetConsumerCommissionRate(t *testing.T) { consumerId := "0" providerKeeper.FetchAndIncrementConsumerId(ctx) providerKeeper.SetConsumerPhase(ctx, consumerId, types.ConsumerPhase_CONSUMER_PHASE_INITIALIZED) - providerKeeper.SetPendingConsumerAdditionProp(ctx, &types.ConsumerAdditionProposal{ChainId: consumerId}) // check that there's no commission rate set for the validator yet _, found := providerKeeper.GetConsumerCommissionRate(ctx, consumerId, providerAddr) diff --git a/x/ccv/provider/migrations/v8/migrations.go b/x/ccv/provider/migrations/v8/migrations.go index 626f2c3c91..916e3d0a22 100644 --- a/x/ccv/provider/migrations/v8/migrations.go +++ b/x/ccv/provider/migrations/v8/migrations.go @@ -2,9 +2,10 @@ package v8 import ( "encoding/binary" - "github.com/cosmos/cosmos-sdk/types/bech32" "time" + "github.com/cosmos/cosmos-sdk/types/bech32" + errorsmod "cosmossdk.io/errors" storetypes "cosmossdk.io/store/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -260,7 +261,7 @@ func MigrateLaunchedConsumerChains(ctx sdk.Context, store storetypes.KVStore, pk } // set phase to launched - pk.SetConsumerPhase(ctx, consumerId, providerkeeper.Launched) + pk.SetConsumerPhase(ctx, consumerId, providertypes.ConsumerPhase_CONSUMER_PHASE_LAUNCHED) // This is to migrate everything under `ProviderConsAddrToOptedInConsumerIdsKey` // `OptedIn` was already re-keyed earlier (see above) and hence we can use `consumerId` here.