Skip to content

Commit

Permalink
refactor: add proto enum for ConsumerPhase (#2182)
Browse files Browse the repository at this point in the history
* add proto enum for ConsumerPhase

* Update proto/interchain_security/ccv/provider/v1/provider.proto

Co-authored-by: insumity <[email protected]>

* fix indentation

* fix indentation

---------

Co-authored-by: insumity <[email protected]>
  • Loading branch information
mpoke and insumity authored Aug 28, 2024
1 parent 30c3017 commit e86bddc
Show file tree
Hide file tree
Showing 19 changed files with 332 additions and 282 deletions.
17 changes: 17 additions & 0 deletions proto/interchain_security/ccv/provider/v1/provider.proto
Original file line number Diff line number Diff line change
Expand Up @@ -464,3 +464,20 @@ message PowerShapingParameters {
// ConsumerIds contains consumer ids of chains
// Used so we can easily (de)serialize slices of strings
message ConsumerIds { repeated string ids = 1; }

// ConsumerPhase indicates the phases of a consumer chain according to ADR 019
enum ConsumerPhase {
// UNSPECIFIED defines an empty phase.
CONSUMER_PHASE_UNSPECIFIED = 0;
// REGISTERED defines the phase in which a consumer chain has been assigned a unique consumer id.
// A chain in this phase cannot yet launch.
CONSUMER_PHASE_REGISTERED = 1;
// INITIALIZED defines the phase in which a consumer chain has set all the needed parameters to launch but
// has not yet launched (e.g., because the `spawnTime` of the consumer chain has not yet been reached).
CONSUMER_PHASE_INITIALIZED = 2;
// LAUNCHED defines the phase in which a consumer chain is running and consuming a subset of the validator
// set of the provider.
CONSUMER_PHASE_LAUNCHED = 3;
// STOPPED defines the phase in which a previously-launched chain has stopped.
CONSUMER_PHASE_STOPPED = 4;
}
4 changes: 2 additions & 2 deletions tests/integration/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package integration
import (
"context"
"fmt"
"github.com/cosmos/interchain-security/v5/x/ccv/provider/keeper"
"testing"

transfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types"
Expand All @@ -22,6 +21,7 @@ import (
icstestingutils "github.com/cosmos/interchain-security/v5/testutil/ibc_testing"
testutil "github.com/cosmos/interchain-security/v5/testutil/integration"
consumertypes "github.com/cosmos/interchain-security/v5/x/ccv/consumer/types"
providertypes "github.com/cosmos/interchain-security/v5/x/ccv/provider/types"
ccv "github.com/cosmos/interchain-security/v5/x/ccv/types"
)

Expand Down Expand Up @@ -150,7 +150,7 @@ func (suite *CCVTestSuite) SetupTest() {
// 2. MakeGenesis is called on the provider chain
// 3. ibc/testing sets the tendermint header for the consumer chain app

providerKeeper.SetConsumerPhase(suite.providerCtx(), icstestingutils.FirstConsumerId, keeper.Initialized)
providerKeeper.SetConsumerPhase(suite.providerCtx(), icstestingutils.FirstConsumerId, providertypes.ConsumerPhase_CONSUMER_PHASE_INITIALIZED)
preProposalKeyAssignment(suite, icstestingutils.FirstConsumerId)

// start consumer chains
Expand Down
6 changes: 3 additions & 3 deletions testutil/ibc_testing/generic_setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ package ibc_testing
import (
"encoding/json"
"fmt"
clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types"
"github.com/cosmos/interchain-security/v5/x/ccv/provider/keeper"
"testing"

clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types"

ibctesting "github.com/cosmos/ibc-go/v8/testing"
testkeeper "github.com/cosmos/interchain-security/v5/testutil/keeper"
"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -158,7 +158,7 @@ func AddConsumer[Tp testutil.ProviderApp, Tc testutil.ConsumerApp](
providerKeeper.SetConsumerMetadata(providerChain.GetContext(), consumerId, consumerMetadata)
providerKeeper.SetConsumerInitializationParameters(providerChain.GetContext(), consumerId, initializationParameters)
providerKeeper.SetConsumerPowerShapingParameters(providerChain.GetContext(), consumerId, powerShapingParameters)
providerKeeper.SetConsumerPhase(providerChain.GetContext(), consumerId, keeper.Initialized)
providerKeeper.SetConsumerPhase(providerChain.GetContext(), consumerId, providertypes.ConsumerPhase_CONSUMER_PHASE_INITIALIZED)
providerKeeper.AppendConsumerToBeLaunchedOnSpawnTime(providerChain.GetContext(), consumerId, coordinator.CurrentTime)

// opt-in all validators
Expand Down
2 changes: 1 addition & 1 deletion testutil/keeper/unit_test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ func SetupForStoppingConsumerChain(t *testing.T, ctx sdk.Context,
providerKeeper.SetConsumerMetadata(ctx, consumerId, GetTestConsumerMetadata())
providerKeeper.SetConsumerInitializationParameters(ctx, consumerId, GetTestInitializationParameters())
providerKeeper.SetConsumerPowerShapingParameters(ctx, consumerId, GetTestPowerShapingParameters())
providerKeeper.SetConsumerPhase(ctx, consumerId, providerkeeper.Initialized)
providerKeeper.SetConsumerPhase(ctx, consumerId, providertypes.ConsumerPhase_CONSUMER_PHASE_INITIALIZED)

err := providerKeeper.CreateConsumerClient(ctx, consumerId)
require.NoError(t, err)
Expand Down
10 changes: 5 additions & 5 deletions x/ccv/provider/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func TestAssignConsensusKeyMsgHandling(t *testing.T) {
setup: func(ctx sdk.Context,
k keeper.Keeper, mocks testkeeper.MockedKeepers,
) {
k.SetConsumerPhase(ctx, "consumerId", keeper.Initialized)
k.SetConsumerPhase(ctx, "consumerId", providertypes.ConsumerPhase_CONSUMER_PHASE_INITIALIZED)
gomock.InOrder(
mocks.MockStakingKeeper.EXPECT().GetValidator(
ctx, providerCryptoId.SDKValOpAddress(),
Expand Down Expand Up @@ -88,7 +88,7 @@ func TestAssignConsensusKeyMsgHandling(t *testing.T) {
setup: func(ctx sdk.Context,
k keeper.Keeper, mocks testkeeper.MockedKeepers,
) {
k.SetConsumerPhase(ctx, "consumerId", keeper.Initialized)
k.SetConsumerPhase(ctx, "consumerId", providertypes.ConsumerPhase_CONSUMER_PHASE_INITIALIZED)
gomock.InOrder(
mocks.MockStakingKeeper.EXPECT().GetValidator(
ctx, providerCryptoId.SDKValOpAddress(),
Expand All @@ -103,7 +103,7 @@ func TestAssignConsensusKeyMsgHandling(t *testing.T) {
setup: func(ctx sdk.Context,
k keeper.Keeper, mocks testkeeper.MockedKeepers,
) {
k.SetConsumerPhase(ctx, "consumerId", keeper.Initialized)
k.SetConsumerPhase(ctx, "consumerId", providertypes.ConsumerPhase_CONSUMER_PHASE_INITIALIZED)

// Use the consumer key already used by some other validator
k.SetValidatorByConsumerAddr(ctx, "consumerId", consumerConsAddr, providerConsAddr2)
Expand All @@ -127,7 +127,7 @@ func TestAssignConsensusKeyMsgHandling(t *testing.T) {
setup: func(ctx sdk.Context,
k keeper.Keeper, mocks testkeeper.MockedKeepers,
) {
k.SetConsumerPhase(ctx, "consumerId", keeper.Initialized)
k.SetConsumerPhase(ctx, "consumerId", providertypes.ConsumerPhase_CONSUMER_PHASE_INITIALIZED)

// Use the consumer key already
k.SetValidatorByConsumerAddr(ctx, "consumerId", consumerConsAddr, providerConsAddr)
Expand All @@ -149,7 +149,7 @@ func TestAssignConsensusKeyMsgHandling(t *testing.T) {
setup: func(ctx sdk.Context,
k keeper.Keeper, mocks testkeeper.MockedKeepers,
) {
k.SetConsumerPhase(ctx, "consumerId", keeper.Initialized)
k.SetConsumerPhase(ctx, "consumerId", providertypes.ConsumerPhase_CONSUMER_PHASE_INITIALIZED)

// Use the consumer key already used by some other validator
k.SetValidatorByConsumerAddr(ctx, "consumerId", consumerConsAddr, providerConsAddr2)
Expand Down
6 changes: 2 additions & 4 deletions x/ccv/provider/keeper/grpc_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import (
"fmt"
"testing"

"github.com/cosmos/interchain-security/v5/x/ccv/provider/keeper"

"github.com/golang/mock/gomock"
"github.com/stretchr/testify/require"

Expand Down Expand Up @@ -83,7 +81,7 @@ func TestQueryConsumerChainOptedInValidators(t *testing.T) {
require.Error(t, err)

pk.FetchAndIncrementConsumerId(ctx)
pk.SetConsumerPhase(ctx, consumerId, keeper.Initialized)
pk.SetConsumerPhase(ctx, consumerId, types.ConsumerPhase_CONSUMER_PHASE_INITIALIZED)

providerAddr1 := types.NewProviderConsAddress([]byte("providerAddr1"))
providerAddr2 := types.NewProviderConsAddress([]byte("providerAddr2"))
Expand Down Expand Up @@ -253,7 +251,7 @@ func TestQueryValidatorConsumerCommissionRate(t *testing.T) {
require.Error(t, err)

pk.FetchAndIncrementConsumerId(ctx)
pk.SetConsumerPhase(ctx, consumerId, keeper.Initialized)
pk.SetConsumerPhase(ctx, consumerId, types.ConsumerPhase_CONSUMER_PHASE_INITIALIZED)

// validator with set consumer commission rate
expectedCommissionRate := math.LegacyMustNewDecFromStr("0.123")
Expand Down
10 changes: 6 additions & 4 deletions x/ccv/provider/keeper/hooks_test.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package keeper_test

import (
"testing"

sdk "github.com/cosmos/cosmos-sdk/types"
cryptotestutil "github.com/cosmos/interchain-security/v5/testutil/crypto"
testkeeper "github.com/cosmos/interchain-security/v5/testutil/keeper"
providerkeeper "github.com/cosmos/interchain-security/v5/x/ccv/provider/keeper"
"github.com/cosmos/interchain-security/v5/x/ccv/provider/types"
"github.com/golang/mock/gomock"
"testing"
)

func TestValidatorConsensusKeyInUse(t *testing.T) {
Expand All @@ -30,7 +32,7 @@ func TestValidatorConsensusKeyInUse(t *testing.T) {
name: "in use by another validator",
setup: func(ctx sdk.Context, k providerkeeper.Keeper) {
k.FetchAndIncrementConsumerId(ctx)
k.SetConsumerPhase(ctx, "0", providerkeeper.Initialized)
k.SetConsumerPhase(ctx, "0", types.ConsumerPhase_CONSUMER_PHASE_INITIALIZED)

// We are trying to add a new validator, but its address has already been used
// by another validator
Expand All @@ -47,8 +49,8 @@ func TestValidatorConsensusKeyInUse(t *testing.T) {
setup: func(ctx sdk.Context, k providerkeeper.Keeper) {
k.FetchAndIncrementConsumerId(ctx)
k.FetchAndIncrementConsumerId(ctx)
k.SetConsumerPhase(ctx, "0", providerkeeper.Initialized)
k.SetConsumerPhase(ctx, "1", providerkeeper.Initialized)
k.SetConsumerPhase(ctx, "0", types.ConsumerPhase_CONSUMER_PHASE_INITIALIZED)
k.SetConsumerPhase(ctx, "1", types.ConsumerPhase_CONSUMER_PHASE_INITIALIZED)

// We are trying to add a new validator, but its address has already been used
// by another validator, of which there are several, across potentially several chains
Expand Down
6 changes: 4 additions & 2 deletions x/ccv/provider/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -752,8 +752,10 @@ func (k Keeper) GetAllActiveConsumerIds(ctx sdk.Context) []string {
consumerIds := []string{}
for i := uint64(0); i < latestConsumerId; i++ {
consumerId := fmt.Sprintf("%d", i)
phase, foundPhase := k.GetConsumerPhase(ctx, consumerId)
if !foundPhase || (phase != Registered && phase != Initialized && phase != Launched) {
phase := k.GetConsumerPhase(ctx, consumerId)
if phase != types.ConsumerPhase_CONSUMER_PHASE_REGISTERED &&
phase != types.ConsumerPhase_CONSUMER_PHASE_INITIALIZED &&
phase != types.ConsumerPhase_CONSUMER_PHASE_LAUNCHED {
continue
}
consumerIds = append(consumerIds, consumerId)
Expand Down
14 changes: 8 additions & 6 deletions x/ccv/provider/keeper/key_assignment.go
Original file line number Diff line number Diff line change
Expand Up @@ -403,12 +403,14 @@ func (k Keeper) AssignConsumerKey(
validator stakingtypes.Validator,
consumerKey tmprotocrypto.PublicKey,
) error {
phase, found := k.GetConsumerPhase(ctx, consumerId)
if !found || phase == Stopped {
//check that the consumer chain is either registered, initialized, or launched
phase := k.GetConsumerPhase(ctx, consumerId)
if phase != types.ConsumerPhase_CONSUMER_PHASE_REGISTERED &&
phase != types.ConsumerPhase_CONSUMER_PHASE_INITIALIZED &&
phase != types.ConsumerPhase_CONSUMER_PHASE_LAUNCHED {
// check that the consumer chain is either registered, initialized, or launched
return errorsmod.Wrapf(
types.ErrUnknownConsumerId, consumerId,
)
types.ErrInvalidPhase,
"cannot assign a key to a consumer chain that is not in the registered, initialized, or launched phase: %s", consumerId)
}

consAddrTmp, err := ccvtypes.TMCryptoPublicKeyToConsAddr(consumerKey)
Expand Down Expand Up @@ -460,7 +462,7 @@ func (k Keeper) AssignConsumerKey(
oldConsumerAddr := types.NewConsumerConsAddress(oldConsumerAddrTmp)

// check whether the consumer chain has already launched (i.e., a client to the consumer was already created)
if phase == Launched {
if phase == types.ConsumerPhase_CONSUMER_PHASE_LAUNCHED {
// mark the old consumer address as prunable once UnbondingPeriod elapses;
// note: this state is removed on EndBlock
unbondingPeriod, err := k.stakingKeeper.UnbondingTime(ctx)
Expand Down
18 changes: 9 additions & 9 deletions x/ccv/provider/keeper/key_assignment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ func TestAssignConsensusKeyForConsumerChain(t *testing.T) {
)
},
doActions: func(ctx sdk.Context, k providerkeeper.Keeper) {
k.SetConsumerPhase(ctx, consumerId, providerkeeper.Launched)
k.SetConsumerPhase(ctx, consumerId, types.ConsumerPhase_CONSUMER_PHASE_LAUNCHED)
err := k.AssignConsumerKey(ctx, consumerId,
providerIdentities[0].SDKStakingValidator(),
consumerIdentities[0].TMProtoCryptoPublicKey(),
Expand All @@ -420,7 +420,7 @@ func TestAssignConsensusKeyForConsumerChain(t *testing.T) {
)
},
doActions: func(sdkCtx sdk.Context, k providerkeeper.Keeper) {
k.SetConsumerPhase(sdkCtx, consumerId, providerkeeper.Launched)
k.SetConsumerPhase(sdkCtx, consumerId, types.ConsumerPhase_CONSUMER_PHASE_LAUNCHED)
err := k.AssignConsumerKey(sdkCtx, consumerId,
providerIdentities[0].SDKStakingValidator(),
consumerIdentities[0].TMProtoCryptoPublicKey(),
Expand Down Expand Up @@ -450,7 +450,7 @@ func TestAssignConsensusKeyForConsumerChain(t *testing.T) {
)
},
doActions: func(ctx sdk.Context, k providerkeeper.Keeper) {
k.SetConsumerPhase(ctx, consumerId, providerkeeper.Launched)
k.SetConsumerPhase(ctx, consumerId, types.ConsumerPhase_CONSUMER_PHASE_LAUNCHED)
err := k.AssignConsumerKey(ctx, consumerId,
providerIdentities[0].SDKStakingValidator(),
consumerIdentities[0].TMProtoCryptoPublicKey(),
Expand All @@ -477,7 +477,7 @@ func TestAssignConsensusKeyForConsumerChain(t *testing.T) {
)
},
doActions: func(ctx sdk.Context, k providerkeeper.Keeper) {
k.SetConsumerPhase(ctx, consumerId, providerkeeper.Launched)
k.SetConsumerPhase(ctx, consumerId, types.ConsumerPhase_CONSUMER_PHASE_LAUNCHED)
err := k.AssignConsumerKey(ctx, consumerId,
providerIdentities[1].SDKStakingValidator(),
providerIdentities[0].TMProtoCryptoPublicKey(),
Expand All @@ -495,7 +495,7 @@ func TestAssignConsensusKeyForConsumerChain(t *testing.T) {
)
},
doActions: func(ctx sdk.Context, k providerkeeper.Keeper) {
k.SetConsumerPhase(ctx, consumerId, providerkeeper.Initialized)
k.SetConsumerPhase(ctx, consumerId, types.ConsumerPhase_CONSUMER_PHASE_INITIALIZED)
err := k.AssignConsumerKey(ctx, consumerId,
providerIdentities[0].SDKStakingValidator(),
consumerIdentities[0].TMProtoCryptoPublicKey(),
Expand All @@ -520,7 +520,7 @@ func TestAssignConsensusKeyForConsumerChain(t *testing.T) {
)
},
doActions: func(ctx sdk.Context, k providerkeeper.Keeper) {
k.SetConsumerPhase(ctx, consumerId, providerkeeper.Initialized)
k.SetConsumerPhase(ctx, consumerId, types.ConsumerPhase_CONSUMER_PHASE_INITIALIZED)
err := k.AssignConsumerKey(ctx, consumerId,
providerIdentities[0].SDKStakingValidator(),
consumerIdentities[0].TMProtoCryptoPublicKey(),
Expand Down Expand Up @@ -550,7 +550,7 @@ func TestAssignConsensusKeyForConsumerChain(t *testing.T) {
)
},
doActions: func(ctx sdk.Context, k providerkeeper.Keeper) {
k.SetConsumerPhase(ctx, consumerId, providerkeeper.Initialized)
k.SetConsumerPhase(ctx, consumerId, types.ConsumerPhase_CONSUMER_PHASE_INITIALIZED)
err := k.AssignConsumerKey(ctx, consumerId,
providerIdentities[0].SDKStakingValidator(),
consumerIdentities[0].TMProtoCryptoPublicKey(),
Expand All @@ -577,7 +577,7 @@ func TestAssignConsensusKeyForConsumerChain(t *testing.T) {
)
},
doActions: func(ctx sdk.Context, k providerkeeper.Keeper) {
k.SetConsumerPhase(ctx, consumerId, providerkeeper.Initialized)
k.SetConsumerPhase(ctx, consumerId, types.ConsumerPhase_CONSUMER_PHASE_INITIALIZED)
err := k.AssignConsumerKey(ctx, consumerId,
providerIdentities[1].SDKStakingValidator(),
providerIdentities[0].TMProtoCryptoPublicKey(),
Expand Down Expand Up @@ -613,7 +613,7 @@ func TestCannotReassignDefaultKeyAssignment(t *testing.T) {
providerKeeper, ctx, ctrl, mocks := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t))
defer ctrl.Finish()

providerKeeper.SetConsumerPhase(ctx, "consumerId", providerkeeper.Initialized)
providerKeeper.SetConsumerPhase(ctx, "consumerId", types.ConsumerPhase_CONSUMER_PHASE_INITIALIZED)

// Mock that the validator is validating with the single key, as confirmed by provider's staking keeper
gomock.InOrder(
Expand Down
25 changes: 14 additions & 11 deletions x/ccv/provider/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,18 @@ package keeper

import (
"context"
errorsmod "cosmossdk.io/errors"
"fmt"
"strings"
"time"

errorsmod "cosmossdk.io/errors"
tmtypes "github.com/cometbft/cometbft/types"
cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
"github.com/cosmos/interchain-security/v5/x/ccv/provider/types"
ccvtypes "github.com/cosmos/interchain-security/v5/x/ccv/types"
"strings"
"time"
)

type msgServer struct {
Expand Down Expand Up @@ -100,8 +101,8 @@ func (k msgServer) RemoveConsumer(goCtx context.Context, msg *types.MsgRemoveCon
return &types.MsgRemoveConsumerResponse{}, errorsmod.Wrapf(types.ErrUnauthorized, "expected owner address %s, got %s", ownerAddress, msg.Signer)
}

phase, found := k.Keeper.GetConsumerPhase(ctx, consumerId)
if !found || phase != Launched {
phase := k.Keeper.GetConsumerPhase(ctx, consumerId)
if phase != types.ConsumerPhase_CONSUMER_PHASE_LAUNCHED {
return nil, errorsmod.Wrapf(types.ErrInvalidPhase,
"chain with consumer id: %s has to be in its launched phase", consumerId)
}
Expand Down Expand Up @@ -315,7 +316,7 @@ func (k msgServer) CreateConsumer(goCtx context.Context, msg *types.MsgCreateCon

k.Keeper.SetConsumerOwnerAddress(ctx, consumerId, msg.Signer)
k.Keeper.SetConsumerChainId(ctx, consumerId, msg.ChainId)
k.Keeper.SetConsumerPhase(ctx, consumerId, Registered)
k.Keeper.SetConsumerPhase(ctx, consumerId, types.ConsumerPhase_CONSUMER_PHASE_REGISTERED)

if err := k.Keeper.SetConsumerMetadata(ctx, consumerId, msg.Metadata); err != nil {
return &types.MsgCreateConsumerResponse{}, errorsmod.Wrapf(types.ErrInvalidConsumerMetadata,
Expand Down Expand Up @@ -343,7 +344,7 @@ func (k msgServer) CreateConsumer(goCtx context.Context, msg *types.MsgCreateCon
}

if spawnTime, canLaunch := k.Keeper.CanLaunch(ctx, consumerId); canLaunch {
k.Keeper.SetConsumerPhase(ctx, consumerId, Initialized)
k.Keeper.SetConsumerPhase(ctx, consumerId, types.ConsumerPhase_CONSUMER_PHASE_INITIALIZED)
if err := k.Keeper.PrepareConsumerForLaunch(ctx, consumerId, time.Time{}, spawnTime); err != nil {
return &types.MsgCreateConsumerResponse{}, errorsmod.Wrapf(types.ErrCannotPrepareForLaunch,
"cannot prepare chain with consumer id (%s) for launch", consumerId)
Expand All @@ -358,10 +359,12 @@ func (k msgServer) UpdateConsumer(goCtx context.Context, msg *types.MsgUpdateCon
ctx := sdk.UnwrapSDKContext(goCtx)
consumerId := msg.ConsumerId

phase, found := k.Keeper.GetConsumerPhase(ctx, consumerId)
if found && phase == Stopped {
phase := k.Keeper.GetConsumerPhase(ctx, consumerId)
if phase != types.ConsumerPhase_CONSUMER_PHASE_REGISTERED &&
phase != types.ConsumerPhase_CONSUMER_PHASE_INITIALIZED &&
phase != types.ConsumerPhase_CONSUMER_PHASE_LAUNCHED {
return &types.MsgUpdateConsumerResponse{}, errorsmod.Wrapf(types.ErrInvalidPhase,
"cannot update consumer chain that is in the stopped phase: %s", consumerId)
"cannot update consumer chain that is not in the registered, initialized, or launched phase: %s", consumerId)
}

ownerAddress, err := k.Keeper.GetConsumerOwnerAddress(ctx, consumerId)
Expand Down Expand Up @@ -446,7 +449,7 @@ func (k msgServer) UpdateConsumer(goCtx context.Context, msg *types.MsgUpdateCon
}

if spawnTime, canLaunch := k.Keeper.CanLaunch(ctx, consumerId); canLaunch {
k.Keeper.SetConsumerPhase(ctx, consumerId, Initialized)
k.Keeper.SetConsumerPhase(ctx, consumerId, types.ConsumerPhase_CONSUMER_PHASE_INITIALIZED)
if err := k.Keeper.PrepareConsumerForLaunch(ctx, consumerId, previousSpawnTime, spawnTime); err != nil {
return &types.MsgUpdateConsumerResponse{}, errorsmod.Wrapf(types.ErrCannotPrepareForLaunch,
"cannot prepare chain with consumer id (%s) for launch", consumerId)
Expand Down
Loading

0 comments on commit e86bddc

Please sign in to comment.