Skip to content

Commit

Permalink
fix error due to rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
mpoke committed Aug 28, 2024
1 parent 8abd23d commit 9698eaa
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 41 deletions.
39 changes: 1 addition & 38 deletions x/ccv/provider/keeper/hooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
}

Expand Down
1 change: 0 additions & 1 deletion x/ccv/provider/keeper/partial_set_security_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 3 additions & 2 deletions x/ccv/provider/migrations/v8/migrations.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 9698eaa

Please sign in to comment.