From 5f5cd27fa1384c2216455023466a3e259ad98bfb Mon Sep 17 00:00:00 2001 From: Bernd Mueller Date: Wed, 8 Nov 2023 14:17:53 +0100 Subject: [PATCH] Addressed review comments --- x/ccv/provider/keeper/msg_server.go | 6 +++--- x/ccv/provider/keeper/proposal.go | 28 +++++++++++++------------- x/ccv/provider/keeper/proposal_test.go | 14 ++++++------- x/ccv/provider/proposal_handler.go | 6 +++--- 4 files changed, 27 insertions(+), 27 deletions(-) diff --git a/x/ccv/provider/keeper/msg_server.go b/x/ccv/provider/keeper/msg_server.go index ff7137d805..491e585f60 100644 --- a/x/ccv/provider/keeper/msg_server.go +++ b/x/ccv/provider/keeper/msg_server.go @@ -118,7 +118,7 @@ func (k msgServer) ConsumerAddition(goCtx context.Context, msg *types.MsgConsume } ctx := sdk.UnwrapSDKContext(goCtx) - err := k.Keeper.HandleNewConsumerAdditionProposal(ctx, msg) + err := k.Keeper.HandleConsumerAdditionProposal(ctx, msg) if err != nil { return nil, errorsmod.Wrapf(err, "failed handling ConsumerAddition proposal") } @@ -134,7 +134,7 @@ func (k msgServer) ConsumerRemoval( } ctx := sdk.UnwrapSDKContext(goCtx) - err := k.Keeper.HandleNewConsumerRemovalProposal(ctx, msg) + err := k.Keeper.HandleConsumerRemovalProposal(ctx, msg) if err != nil { return nil, errorsmod.Wrapf(err, "failed handling ConsumerAddition proposal") } @@ -149,7 +149,7 @@ func (k msgServer) ChangeRewardDenoms(goCtx context.Context, msg *types.MsgChang } sdkCtx := sdk.UnwrapSDKContext(goCtx) - err := k.Keeper.HandleNewConsumerRewardDenomProposal(sdkCtx, msg) + err := k.Keeper.HandleConsumerRewardDenomProposal(sdkCtx, msg) if err != nil { return nil, errorsmod.Wrapf(err, "failed handling Change Reward Denoms proposal") } diff --git a/x/ccv/provider/keeper/proposal.go b/x/ccv/provider/keeper/proposal.go index 9b97305c0d..8f90e14448 100644 --- a/x/ccv/provider/keeper/proposal.go +++ b/x/ccv/provider/keeper/proposal.go @@ -25,8 +25,8 @@ import ( ) // Wrapper for the new proposal message MsgConsumerAddition -// Will replace legacy handler HandleConsumerAdditionProposal -func (k Keeper) HandleNewConsumerAdditionProposal(ctx sdk.Context, proposal *types.MsgConsumerAddition) error { +// Will replace legacy handler HandleLegacyConsumerAdditionProposal +func (k Keeper) HandleConsumerAdditionProposal(ctx sdk.Context, proposal *types.MsgConsumerAddition) error { p := types.ConsumerAdditionProposal{ Title: "New ConsumerAddition Proposal", ChainId: proposal.ChainId, @@ -42,39 +42,39 @@ func (k Keeper) HandleNewConsumerAdditionProposal(ctx sdk.Context, proposal *typ HistoricalEntries: proposal.HistoricalEntries, DistributionTransmissionChannel: proposal.DistributionTransmissionChannel, } - return k.HandleConsumerAdditionProposal(ctx, &p) + return k.HandleLegacyConsumerAdditionProposal(ctx, &p) } // Wrapper for the new proposal message MsgConsumerRemoval -// Will replace legacy handler HandleConsumerRemovalProposal -func (k Keeper) HandleNewConsumerRemovalProposal(ctx sdk.Context, proposal *types.MsgConsumerRemoval) error { +// Will replace legacy handler HandleLegacyConsumerRemovalProposal +func (k Keeper) HandleConsumerRemovalProposal(ctx sdk.Context, proposal *types.MsgConsumerRemoval) error { p := types.ConsumerRemovalProposal{ ChainId: proposal.ChainId, StopTime: proposal.StopTime, } - return k.HandleConsumerRemovalProposal(ctx, &p) + return k.HandleLegacyConsumerRemovalProposal(ctx, &p) } // Wrapper for the new proposal message MsgChangeRewardDenoms -// Will replace legacy handler HandleConsumerRewardDenomProposal -func (k Keeper) HandleNewConsumerRewardDenomProposal(ctx sdk.Context, proposal *types.MsgChangeRewardDenoms) error { +// Will replace legacy handler HandleLegacyConsumerRewardDenomProposal +func (k Keeper) HandleConsumerRewardDenomProposal(ctx sdk.Context, proposal *types.MsgChangeRewardDenoms) error { p := types.ChangeRewardDenomsProposal{ Title: "New ChangeRewardDenomsProposal", DenomsToAdd: proposal.DenomsToAdd, DenomsToRemove: proposal.DenomsToRemove, } - return k.HandleConsumerRewardDenomProposal(ctx, &p) + return k.HandleLegacyConsumerRewardDenomProposal(ctx, &p) } -// HandleConsumerAdditionProposal will receive the consumer chain's client state from the proposal. +// HandleLegacyConsumerAdditionProposal will receive the consumer chain's client state from the proposal. // If the client can be successfully created in a cached context, it stores the proposal as a pending proposal. // // Note: This method implements SpawnConsumerChainProposalHandler in spec. // See: https://github.com/cosmos/ibc/blob/main/spec/app/ics-028-cross-chain-validation/methods.md#ccv-pcf-hcaprop1 // Spec tag: [CCV-PCF-HCAPROP.1] -func (k Keeper) HandleConsumerAdditionProposal(ctx sdk.Context, p *types.ConsumerAdditionProposal) error { +func (k Keeper) HandleLegacyConsumerAdditionProposal(ctx sdk.Context, p *types.ConsumerAdditionProposal) error { // verify the consumer addition proposal execution // in cached context and discard the cached writes if _, _, err := k.CreateConsumerClientInCachedCtx(ctx, *p); err != nil { @@ -167,13 +167,13 @@ func (k Keeper) CreateConsumerClient(ctx sdk.Context, prop *types.ConsumerAdditi return nil } -// HandleConsumerRemovalProposal stops a consumer chain and released the outstanding unbonding operations. +// HandleLegacyConsumerRemovalProposal stops a consumer chain and released the outstanding unbonding operations. // If the consumer can be successfully stopped in a cached context, it stores the proposal as a pending proposal. // // This method implements StopConsumerChainProposalHandler from spec. // See: https://github.com/cosmos/ibc/blob/main/spec/app/ics-028-cross-chain-validation/methods.md#ccv-pcf-hcrprop1 // Spec tag: [CCV-PCF-HCRPROP.1] -func (k Keeper) HandleConsumerRemovalProposal(ctx sdk.Context, p *types.ConsumerRemovalProposal) error { +func (k Keeper) HandleLegacyConsumerRemovalProposal(ctx sdk.Context, p *types.ConsumerRemovalProposal) error { // verify the consumer removal proposal execution // in cached context and discard the cached writes if _, _, err := k.StopConsumerChainInCachedCtx(ctx, *p); err != nil { @@ -655,7 +655,7 @@ func (k Keeper) StopConsumerChainInCachedCtx(ctx sdk.Context, p types.ConsumerRe return } -func (k Keeper) HandleConsumerRewardDenomProposal(ctx sdk.Context, p *types.ChangeRewardDenomsProposal) error { +func (k Keeper) HandleLegacyConsumerRewardDenomProposal(ctx sdk.Context, p *types.ChangeRewardDenomsProposal) error { for _, denomToAdd := range p.DenomsToAdd { // Log error and move on if one of the denoms is already registered if k.ConsumerRewardDenomExists(ctx, denomToAdd) { diff --git a/x/ccv/provider/keeper/proposal_test.go b/x/ccv/provider/keeper/proposal_test.go index 5bf25c7e68..5899e058b1 100644 --- a/x/ccv/provider/keeper/proposal_test.go +++ b/x/ccv/provider/keeper/proposal_test.go @@ -29,10 +29,10 @@ import ( // Initialization sub-protocol related tests of proposal.go // -// Tests the HandleConsumerAdditionProposal method against the SpawnConsumerChainProposalHandler spec. +// Tests the HandleLegacyConsumerAdditionProposal method against the SpawnConsumerChainProposalHandler spec. // See: https://github.com/cosmos/ibc/blob/main/spec/app/ics-028-cross-chain-validation/methods.md#ccv-pcf-hcaprop1 // Spec tag: [CCV-PCF-HCAPROP.1] -func TestHandleConsumerAdditionProposal(t *testing.T) { +func TestHandleLegacyConsumerAdditionProposal(t *testing.T) { type testCase struct { description string malleate func(ctx sdk.Context, k providerkeeper.Keeper, chainID string) @@ -113,7 +113,7 @@ func TestHandleConsumerAdditionProposal(t *testing.T) { tc.malleate(ctx, providerKeeper, tc.prop.ChainId) - err := providerKeeper.HandleConsumerAdditionProposal(ctx, tc.prop) + err := providerKeeper.HandleLegacyConsumerAdditionProposal(ctx, tc.prop) if tc.expAppendProp { require.NoError(t, err) @@ -371,11 +371,11 @@ func TestGetAllConsumerAdditionProps(t *testing.T) { // Consumer Chain Removal sub-protocol related tests of proposal.go // -// TestHandleConsumerRemovalProposal tests HandleConsumerRemovalProposal against its corresponding spec method. +// TestHandleLegacyConsumerRemovalProposal tests HandleLegacyConsumerRemovalProposal against its corresponding spec method. // // See: https://github.com/cosmos/ibc/blob/main/spec/app/ics-028-cross-chain-validation/methods.md#ccv-pcf-hcrprop1 // Spec tag: [CCV-PCF-HCRPROP.1] -func TestHandleConsumerRemovalProposal(t *testing.T) { +func TestHandleLegacyConsumerRemovalProposal(t *testing.T) { type testCase struct { description string setupMocks func(ctx sdk.Context, k providerkeeper.Keeper, chainID string) @@ -479,7 +479,7 @@ func TestHandleConsumerRemovalProposal(t *testing.T) { tc.setupMocks(ctx, providerKeeper, tc.prop.ChainId) - err := providerKeeper.HandleConsumerRemovalProposal(ctx, tc.prop) + err := providerKeeper.HandleLegacyConsumerRemovalProposal(ctx, tc.prop) if tc.expAppendProp { require.NoError(t, err) @@ -505,7 +505,7 @@ func TestHandleConsumerRemovalProposal(t *testing.T) { } // Tests the StopConsumerChain method against the spec, -// with more granularity than what's covered in TestHandleConsumerRemovalProposal, or integration tests. +// with more granularity than what's covered in TestHandleLegacyConsumerRemovalProposal, or integration tests. // See: https://github.com/cosmos/ibc/blob/main/spec/app/ics-028-cross-chain-validation/methods.md#ccv-pcf-stcc1 // Spec tag: [CCV-PCF-STCC.1] func TestStopConsumerChain(t *testing.T) { diff --git a/x/ccv/provider/proposal_handler.go b/x/ccv/provider/proposal_handler.go index ff230b69ce..8f2671e086 100644 --- a/x/ccv/provider/proposal_handler.go +++ b/x/ccv/provider/proposal_handler.go @@ -17,11 +17,11 @@ func NewProviderProposalHandler(k keeper.Keeper) govv1beta1.Handler { return func(ctx sdk.Context, content govv1beta1.Content) error { switch c := content.(type) { case *types.ConsumerAdditionProposal: - return k.HandleConsumerAdditionProposal(ctx, c) + return k.HandleLegacyConsumerAdditionProposal(ctx, c) case *types.ConsumerRemovalProposal: - return k.HandleConsumerRemovalProposal(ctx, c) + return k.HandleLegacyConsumerRemovalProposal(ctx, c) case *types.ChangeRewardDenomsProposal: - return k.HandleConsumerRewardDenomProposal(ctx, c) + return k.HandleLegacyConsumerRewardDenomProposal(ctx, c) default: return errorsmod.Wrapf(sdkerrors.ErrUnknownRequest, "unrecognized ccv proposal content type: %T", c) }