Skip to content

Commit

Permalink
Addressed review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
bermuell committed Nov 8, 2023
1 parent 9dbf847 commit 5f5cd27
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 27 deletions.
6 changes: 3 additions & 3 deletions x/ccv/provider/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand All @@ -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")
}
Expand All @@ -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")
}
Expand Down
28 changes: 14 additions & 14 deletions x/ccv/provider/keeper/proposal.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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) {
Expand Down
14 changes: 7 additions & 7 deletions x/ccv/provider/keeper/proposal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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) {
Expand Down
6 changes: 3 additions & 3 deletions x/ccv/provider/proposal_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit 5f5cd27

Please sign in to comment.