Skip to content

Commit 2951e9b

Browse files
committed
remove unnecessary check
1 parent 8e2111a commit 2951e9b

File tree

3 files changed

+3
-18
lines changed

3 files changed

+3
-18
lines changed

x/ccv/provider/keeper/distribution.go

+1-10
Original file line numberDiff line numberDiff line change
@@ -282,21 +282,12 @@ func (k Keeper) IdentifyConsumerChainIDFromIBCPacket(ctx sdk.Context, packet cha
282282
}
283283

284284
// HandleSetConsumerCommissionRate sets a per-consumer chain commission rate for the given provider address
285-
// on the condition that the given consumer chain exists.
286-
func (k Keeper) HandleSetConsumerCommissionRate(ctx sdk.Context, chainID string, providerAddr types.ProviderConsAddress, commissionRate sdk.Dec) error {
287-
// check that the consumer chain exists
288-
if !k.IsConsumerProposedOrRegistered(ctx, chainID) {
289-
return errorsmod.Wrapf(
290-
types.ErrUnknownConsumerChainId,
291-
"unknown consumer chain, with id: %s", chainID)
292-
}
285+
func (k Keeper) HandleSetConsumerCommissionRate(ctx sdk.Context, chainID string, providerAddr types.ProviderConsAddress, commissionRate sdk.Dec) {
293286
// set per-consumer chain commission rate for the validator address
294287
k.SetConsumerCommissionRate(
295288
ctx,
296289
chainID,
297290
providerAddr,
298291
commissionRate,
299292
)
300-
301-
return nil
302293
}

x/ccv/provider/keeper/msg_server.go

+1-3
Original file line numberDiff line numberDiff line change
@@ -213,9 +213,7 @@ func (k msgServer) SetConsumerCommissionRate(goCtx context.Context, msg *types.M
213213
return nil, err
214214
}
215215

216-
if err := k.HandleSetConsumerCommissionRate(ctx, msg.ChainId, types.NewProviderConsAddress(consAddr), msg.Rate); err != nil {
217-
return nil, err
218-
}
216+
k.HandleSetConsumerCommissionRate(ctx, msg.ChainId, types.NewProviderConsAddress(consAddr), msg.Rate)
219217

220218
ctx.EventManager().EmitEvents(sdk.Events{
221219
sdk.NewEvent(

x/ccv/provider/keeper/partial_set_security_test.go

+1-5
Original file line numberDiff line numberDiff line change
@@ -119,18 +119,14 @@ func TestHandleSetConsumerCommissionRate(t *testing.T) {
119119

120120
providerAddr := types.NewProviderConsAddress([]byte("providerAddr"))
121121

122-
// trying to set a commission rate to a unknown consumer chain
123-
require.Error(t, providerKeeper.HandleSetConsumerCommissionRate(ctx, "unknownChainID", providerAddr, sdk.ZeroDec()))
124-
125122
// setup a pending consumer chain
126123
chainID := "pendingChainID"
127-
providerKeeper.SetPendingConsumerAdditionProp(ctx, &types.ConsumerAdditionProposal{ChainId: chainID})
128124

129125
// check that there's no commission rate set for the validator yet
130126
_, found := providerKeeper.GetConsumerCommissionRate(ctx, chainID, providerAddr)
131127
require.False(t, found)
132128

133-
require.NoError(t, providerKeeper.HandleSetConsumerCommissionRate(ctx, chainID, providerAddr, sdk.OneDec()))
129+
providerKeeper.HandleSetConsumerCommissionRate(ctx, chainID, providerAddr, sdk.OneDec())
134130

135131
// check that the commission rate is now set
136132
cr, found := providerKeeper.GetConsumerCommissionRate(ctx, chainID, providerAddr)

0 commit comments

Comments
 (0)