Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nit: panic with error #4741

Merged
merged 12 commits into from
Sep 22, 2023
Prev Previous commit
Next Next commit
panic with error
crodriguezvega committed Sep 21, 2023
commit 221f38508c062c8d94ca7c44fc1980e62f5b65a0
216 changes: 214 additions & 2 deletions e2e/tests/upgrades/upgrade_test.go
Original file line number Diff line number Diff line change
@@ -9,6 +9,7 @@ import (
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
"github.com/cosmos/gogoproto/proto"

// intertxtypes "github.com/cosmos/interchain-accounts/x/inter-tx/types"
interchaintest "github.com/strangelove-ventures/interchaintest/v8"
"github.com/strangelove-ventures/interchaintest/v8/chain/cosmos"
"github.com/strangelove-ventures/interchaintest/v8/ibc"
@@ -73,8 +74,7 @@ func (s *UpgradeTestSuite) UpgradeChain(ctx context.Context, chain *cosmos.Cosmo
err = chain.StopAllNodes(ctx)
s.Require().NoError(err, "error stopping node(s)")

repository := chain.Nodes()[0].Image.Repository
chain.UpgradeVersion(ctx, s.DockerClient, repository, upgradeVersion)
chain.UpgradeVersion(ctx, s.DockerClient, getChainImage(chain), upgradeVersion)

err = chain.StartAllNodes(ctx)
s.Require().NoError(err, "error starting upgraded node(s)")
@@ -251,6 +251,201 @@ func (s *UpgradeTestSuite) TestChainUpgrade() {
})
}

// func (s *UpgradeTestSuite) TestV5ToV6ChainUpgrade() {
// t := s.T()
// testCfg := testsuite.LoadConfig()

// ctx := context.Background()
// relayer, _ := s.SetupChainsRelayerAndChannel(ctx)
// chainA, chainB := s.GetChains()

// // create separate user specifically for the upgrade proposal to more easily verify starting
// // and end balances of the chainA users.
// chainAUpgradeProposalWallet := s.CreateUserOnChainA(ctx, testvalues.StartingTokenAmount)

// s.Require().NoError(test.WaitForBlocks(ctx, 1, chainA, chainB), "failed to wait for blocks")

// // setup 2 accounts: controller account on chain A, a second chain B account.
// // host account will be created when the ICA is registered
// controllerAccount := s.CreateUserOnChainA(ctx, testvalues.StartingTokenAmount)
// chainBAccount := s.CreateUserOnChainB(ctx, testvalues.StartingTokenAmount)
// var hostAccount string

// t.Run("register interchain account", func(t *testing.T) {
// // explicitly set the version string because intertx with ibfc-go v5 does not support incentivized channels.
// version := icatypes.NewDefaultMetadataString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID)
// msgRegisterAccount := intertxtypes.NewMsgRegisterAccount(controllerAccount.FormattedAddress(), ibctesting.FirstConnectionID, version)
// s.RegisterInterchainAccount(ctx, chainA, controllerAccount, msgRegisterAccount)
// })

// t.Run("start relayer", func(t *testing.T) {
// s.StartRelayer(relayer)
// })

// t.Run("verify interchain account", func(t *testing.T) {
// var err error
// hostAccount, err = s.QueryInterchainAccount(ctx, chainA, controllerAccount.FormattedAddress(), ibctesting.FirstConnectionID)
// s.Require().NoError(err)
// s.Require().NotZero(len(hostAccount))

// channels, err := relayer.GetChannels(ctx, s.GetRelayerExecReporter(), chainA.Config().ChainID)
// s.Require().NoError(err)
// s.Require().Equal(len(channels), 2)
// })

// t.Run("interchain account executes a bank transfer on behalf of the corresponding owner account", func(t *testing.T) {
// t.Run("fund interchain account wallet", func(t *testing.T) {
// // fund the host account, so it has some $$ to send
// err := chainB.SendFunds(ctx, interchaintest.FaucetAccountKeyName, ibc.WalletAmount{
// Address: hostAccount,
// Amount: sdkmath.NewInt(testvalues.StartingTokenAmount),
// Denom: chainB.Config().Denom,
// })
// s.Require().NoError(err)
// })

// t.Run("broadcast MsgSubmitTx (legacy)", func(t *testing.T) {
// // assemble bank transfer message from host account to user account on host chain
// msgSend := &banktypes.MsgSend{
// FromAddress: hostAccount,
// ToAddress: chainBAccount.FormattedAddress(),
// Amount: sdk.NewCoins(testvalues.DefaultTransferAmount(chainB.Config().Denom)),
// }

// // assemble submitMessage tx for intertx
// msgSubmitTx, err := intertxtypes.NewMsgSubmitTx(
// msgSend,
// ibctesting.FirstConnectionID,
// controllerAccount.FormattedAddress(),
// )
// s.Require().NoError(err)

// // broadcast submitMessage tx from controller account on chain A
// // this message should trigger the sending of an ICA packet over channel-1 (channel created between controller and host)
// // this ICA packet contains the assembled bank transfer message from above, which will be executed by the host account on the host chain.
// resp := s.BroadcastMessages(
// ctx,
// chainA,
// controllerAccount,
// msgSubmitTx,
// )

// s.AssertTxSuccess(resp)

// s.Require().NoError(test.WaitForBlocks(ctx, 10, chainA, chainB))
// })

// t.Run("verify tokens transferred", func(t *testing.T) {
// balance, err := chainB.GetBalance(ctx, chainBAccount.FormattedAddress(), chainB.Config().Denom)
// s.Require().NoError(err)

// _, err = chainB.GetBalance(ctx, hostAccount, chainB.Config().Denom)
// s.Require().NoError(err)

// expected := testvalues.IBCTransferAmount + testvalues.StartingTokenAmount
// s.Require().Equal(expected, balance)
// })
// })

// s.Require().NoError(test.WaitForBlocks(ctx, 5, chainA, chainB), "failed to wait for blocks")

// t.Run("upgrade chainA", func(t *testing.T) {
// s.UpgradeChain(ctx, chainA, chainAUpgradeProposalWallet, testCfg.UpgradeConfig.PlanName, testCfg.ChainConfigs[0].Tag, testCfg.UpgradeConfig.Tag)
// })

// t.Run("restart relayer", func(t *testing.T) {
// s.StopRelayer(ctx, relayer)
// s.StartRelayer(relayer)
// })

// t.Run("broadcast MsgSubmitTx (legacy)", func(t *testing.T) {
// // assemble bank transfer message from host account to user account on host chain
// msgSend := &banktypes.MsgSend{
// FromAddress: hostAccount,
// ToAddress: chainBAccount.FormattedAddress(),
// Amount: sdk.NewCoins(testvalues.DefaultTransferAmount(chainB.Config().Denom)),
// }

// // assemble submitMessage tx for intertx
// msgSubmitTx, err := intertxtypes.NewMsgSubmitTx(
// msgSend,
// ibctesting.FirstConnectionID,
// controllerAccount.FormattedAddress(),
// )
// s.Require().NoError(err)

// // broadcast submitMessage tx from controller account on chain A
// // this message should trigger the sending of an ICA packet over channel-1 (channel created between controller and host)
// // this ICA packet contains the assembled bank transfer message from above, which will be executed by the host account on the host chain.
// resp := s.BroadcastMessages(
// ctx,
// chainA,
// controllerAccount,
// msgSubmitTx,
// )

// s.AssertTxSuccess(resp)

// s.Require().NoError(test.WaitForBlocks(ctx, 10, chainA, chainB))
// })

// t.Run("verify tokens transferred", func(t *testing.T) {
// balance, err := chainB.GetBalance(ctx, chainBAccount.FormattedAddress(), chainB.Config().Denom)
// s.Require().NoError(err)

// _, err = chainB.GetBalance(ctx, hostAccount, chainB.Config().Denom)
// s.Require().NoError(err)

// expected := (testvalues.IBCTransferAmount * 2) + testvalues.StartingTokenAmount
// s.Require().Equal(expected, balance)
// })

// t.Run("broadcast MsgSendTx (MsgServer)", func(t *testing.T) {
// // assemble bank transfer message from host account to user account on host chain
// msgSend := &banktypes.MsgSend{
// FromAddress: hostAccount,
// ToAddress: chainBAccount.FormattedAddress(),
// Amount: sdk.NewCoins(testvalues.DefaultTransferAmount(chainB.Config().Denom)),
// }

// data, err := icatypes.SerializeCosmosTx(testsuite.Codec(), []proto.Message{msgSend}, icatypes.EncodingProtobuf)
// s.Require().NoError(err)

// icaPacketData := icatypes.InterchainAccountPacketData{
// Type: icatypes.EXECUTE_TX,
// Data: data,
// }

// relativeTimeoutTimestamp := uint64(time.Hour.Nanoseconds())
// msgSendTx := controllertypes.NewMsgSendTx(controllerAccount.FormattedAddress(), ibctesting.FirstConnectionID, relativeTimeoutTimestamp, icaPacketData)

// // broadcast MsgSendTx tx from controller account on chain A
// // this message should trigger the sending of an ICA packet over channel-1 (channel created between controller and host)
// // this ICA packet contains the assembled bank transfer message from above, which will be executed by the host account on the host chain.
// resp := s.BroadcastMessages(
// ctx,
// chainA,
// controllerAccount,
// msgSendTx,
// )

// s.AssertTxSuccess(resp)

// s.Require().NoError(test.WaitForBlocks(ctx, 10, chainA, chainB))
// })

// t.Run("verify tokens transferred", func(t *testing.T) {
// balance, err := chainB.GetBalance(ctx, chainBAccount.FormattedAddress(), chainB.Config().Denom)
// s.Require().NoError(err)

// _, err = chainB.GetBalance(ctx, hostAccount, chainB.Config().Denom)
// s.Require().NoError(err)

// expected := (testvalues.IBCTransferAmount * 3) + testvalues.StartingTokenAmount
// s.Require().Equal(expected, balance)
// })
// }

// TestV6ToV7ChainUpgrade will test that an upgrade from a v6 ibc-go binary to a v7 ibc-go binary is successful
// and that the automatic migrations associated with the 02-client module are performed. Namely that the solo machine
// proto definition is migrated in state from the v2 to v3 definition. This is checked by creating a solo machine client
@@ -595,6 +790,12 @@ func (s *UpgradeTestSuite) TestV7ToV8ChainUpgrade() {
})
}

// RegisterInterchainAccount will attempt to register an interchain account on the counterparty chain.
// func (s *UpgradeTestSuite) RegisterInterchainAccount(ctx context.Context, chain *cosmos.CosmosChain, user ibc.Wallet, msgRegisterAccount *intertxtypes.MsgRegisterAccount) {
// txResp := s.BroadcastMessages(ctx, chain, user, msgRegisterAccount)
// s.AssertTxSuccess(txResp)
// }

// ClientState queries the current ClientState by clientID
func (s *UpgradeTestSuite) ClientState(ctx context.Context, chain ibc.Chain, clientID string) (*clienttypes.QueryClientStateResponse, error) {
queryClient := s.GetChainGRCPClients(chain).ClientQueryClient
@@ -607,3 +808,14 @@ func (s *UpgradeTestSuite) ClientState(ctx context.Context, chain ibc.Chain, cli

return res, nil
}

// getChainImage returns the image of a given chain.
func getChainImage(chain *cosmos.CosmosChain) string {
tc := testsuite.LoadConfig()
for _, c := range tc.ChainConfigs {
if c.ChainID == chain.Config().ChainID {
return c.Image
}
}
panic(fmt.Errorf("unable to find image for chain: " + chain.Config().ChainID))
}
2 changes: 1 addition & 1 deletion e2e/testsuite/testsuite.go
Original file line number Diff line number Diff line change
@@ -272,7 +272,7 @@ func (s *E2ETestSuite) RecoverRelayerWallets(ctx context.Context, ibcrelayer ibc
// StartRelayer starts the given ibcrelayer.
func (s *E2ETestSuite) StartRelayer(ibcrelayer ibc.Relayer) {
if s.startRelayerFn == nil {
panic("cannot start relayer before it is created!")
panic(fmt.Errorf("cannot start relayer before it is created!"))
}

s.startRelayerFn(ibcrelayer)
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package controller

import (
"fmt"

errorsmod "cosmossdk.io/errors"

sdk "github.com/cosmos/cosmos-sdk/types"
@@ -239,7 +241,7 @@ func (IBCMiddleware) SendPacket(
timeoutTimestamp uint64,
data []byte,
) (uint64, error) {
panic("SendPacket not supported for ICA controller module. Please use SendTx")
panic(fmt.Errorf("SendPacket not supported for ICA controller module. Please use SendTx"))
}

// WriteAcknowledgement implements the ICS4 Wrapper interface
@@ -249,7 +251,7 @@ func (IBCMiddleware) WriteAcknowledgement(
packet ibcexported.PacketI,
ack ibcexported.Acknowledgement,
) error {
panic("WriteAcknowledgement not supported for ICA controller module")
panic(fmt.Errorf("WriteAcknowledgement not supported for ICA controller module"))
}

// GetAppVersion returns the interchain accounts metadata.
Original file line number Diff line number Diff line change
@@ -290,7 +290,7 @@ func (k Keeper) GetParams(ctx sdk.Context) types.Params {
store := ctx.KVStore(k.storeKey)
bz := store.Get([]byte(types.ParamsKey))
if bz == nil { // only panic on unset params and not on empty params
panic("ica/controller params are not set in store")
panic(fmt.Errorf("ica/controller params are not set in store"))
}

var params types.Params
Original file line number Diff line number Diff line change
@@ -243,7 +243,7 @@ func (k Keeper) GetParams(ctx sdk.Context) types.Params {
store := ctx.KVStore(k.storeKey)
bz := store.Get([]byte(types.ParamsKey))
if bz == nil { // only panic on unset params and not on empty params
panic("ica/host params are not set in store")
panic(fmt.Errorf("ica/host params are not set in store"))
}

var params types.Params
2 changes: 1 addition & 1 deletion modules/apps/callbacks/callbacks_test.go
Original file line number Diff line number Diff line change
@@ -46,7 +46,7 @@ func SetupTestingApp() (ibctesting.TestingApp, map[string]json.RawMessage) {
func GetSimApp(chain *ibctesting.TestChain) *simapp.SimApp {
app, ok := chain.App.(*simapp.SimApp)
if !ok {
panic("chain is not a simapp.SimApp")
panic(fmt.Errorf("chain is not a simapp.SimApp"))
}
return app
}
4 changes: 2 additions & 2 deletions modules/apps/callbacks/ibc_middleware_test.go
Original file line number Diff line number Diff line change
@@ -826,7 +826,7 @@ func (s *CallbacksTestSuite) TestProcessCallback() {
func() {
callbackExecutor = func(cachedCtx sdk.Context) error {
cachedCtx.GasMeter().ConsumeGas(expGasConsumed, "callbackExecutor gas consumption")
panic("callbackExecutor panic")
panic(fmt.Errorf("callbackExecutor panic"))
}
},
false,
@@ -862,7 +862,7 @@ func (s *CallbacksTestSuite) TestProcessCallback() {
callbackType = types.CallbackTypeSendPacket
callbackExecutor = func(cachedCtx sdk.Context) error {
cachedCtx.GasMeter().ConsumeGas(expGasConsumed, "callbackExecutor gas consumption")
panic("callbackExecutor panic")
panic(fmt.Errorf("callbackExecutor panic"))
}
},
true,
5 changes: 3 additions & 2 deletions modules/apps/callbacks/testing/simapp/export.go
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@ package simapp

import (
"encoding/json"
"fmt"
"log"

storetypes "cosmossdk.io/store/types"
@@ -206,7 +207,7 @@ func (app *SimApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []
addr := sdk.ValAddress(stakingtypes.AddressFromValidatorsKey(iter.Key()))
validator, err := app.StakingKeeper.GetValidator(ctx, addr)
if err != nil {
panic("expected validator, not found")
panic(fmt.Errorf("expected validator, not found"))
}

validator.UnbondingHeight = 0
@@ -216,7 +217,7 @@ func (app *SimApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []

err = app.StakingKeeper.SetValidator(ctx, validator)
if err != nil {
panic("couldn't set validator")
panic(fmt.Errorf("couldn't set validator"))
}
counter++
}
2 changes: 1 addition & 1 deletion modules/apps/transfer/keeper/keeper.go
Original file line number Diff line number Diff line change
@@ -128,7 +128,7 @@ func (k Keeper) GetParams(ctx sdk.Context) types.Params {
store := ctx.KVStore(k.storeKey)
bz := store.Get([]byte(types.ParamsKey))
if bz == nil { // only panic on unset params and not on empty params
panic("transfer params are not set in store")
panic(fmt.Errorf("transfer params are not set in store"))
}

var params types.Params
8 changes: 4 additions & 4 deletions modules/apps/transfer/keeper/mbt_relay_test.go
Original file line number Diff line number Diff line change
@@ -99,7 +99,7 @@ func AddressFromString(address string) string {

func AddressFromTla(addr []string) string {
if len(addr) != 3 {
panic("failed to convert from TLA+ address: wrong number of address components")
panic(fmt.Errorf("failed to convert from TLA+ address: wrong number of address components"))
}
s := ""
if len(addr[0]) == 0 && len(addr[1]) == 0 { //nolint:gocritic
@@ -109,7 +109,7 @@ func AddressFromTla(addr []string) string {
// escrow address: ics20-1\x00port/channel
s = fmt.Sprintf("%s\x00%s/%s", types.Version, addr[0], addr[1])
} else {
panic("failed to convert from TLA+ address: neither simple nor escrow address")
panic(fmt.Errorf("failed to convert from TLA+ address: neither simple nor escrow address"))
}
return s
}
@@ -333,7 +333,7 @@ func (suite *KeeperTestSuite) TestModelBasedRelay() {
var sender sdk.AccAddress
sender, err = sdk.AccAddressFromBech32(tc.packet.Data.Sender)
if err != nil {
panic("MBT failed to convert sender address")
panic(fmt.Errorf("MBT failed to convert sender address"))
}
registerDenomFn()
denomTrace := types.ParseDenomTrace(tc.packet.Data.Denom)
@@ -342,7 +342,7 @@ func (suite *KeeperTestSuite) TestModelBasedRelay() {
if err == nil {
amount, ok := sdkmath.NewIntFromString(tc.packet.Data.Amount)
if !ok {
panic("MBT failed to parse amount from string")
panic(fmt.Errorf("MBT failed to parse amount from string"))
}
msg := types.NewMsgTransfer(
tc.packet.SourcePort,
12 changes: 6 additions & 6 deletions modules/capability/keeper/keeper.go
Original file line number Diff line number Diff line change
@@ -70,10 +70,10 @@ func NewKeeper(cdc codec.BinaryCodec, storeKey, memKey storetypes.StoreKey) *Kee
// already has a ScopedKeeper.
func (k *Keeper) ScopeToModule(moduleName string) ScopedKeeper {
if k.sealed {
panic("cannot scope to module via a sealed capability keeper")
panic(fmt.Errorf("cannot scope to module via a sealed capability keeper"))
}
if strings.TrimSpace(moduleName) == "" {
panic("cannot scope to an empty module name")
panic(fmt.Errorf("cannot scope to an empty module name"))
}

if _, ok := k.scopedModules[moduleName]; ok {
@@ -95,7 +95,7 @@ func (k *Keeper) ScopeToModule(moduleName string) ScopedKeeper {
// Seal may be called during app initialization for applications that do not wish to create scoped keepers dynamically.
func (k *Keeper) Seal() {
if k.sealed {
panic("cannot initialize and seal an already sealed capability keeper")
panic(fmt.Errorf("cannot initialize and seal an already sealed capability keeper"))
}

k.sealed = true
@@ -156,11 +156,11 @@ func (k *Keeper) IsInitialized(ctx sdk.Context) bool {
// It will panic if the provided index is 0, or if the index is already set.
func (k Keeper) InitializeIndex(ctx sdk.Context, index uint64) error {
if index == 0 {
panic("SetIndex requires index > 0")
panic(fmt.Errorf("SetIndex requires index > 0"))
}
latest := k.GetLatestIndex(ctx)
if latest > 0 {
panic("SetIndex requires index to not be set")
panic(fmt.Errorf("SetIndex requires index to not be set"))
}

// set the global index to the passed index
@@ -390,7 +390,7 @@ func (sk ScopedKeeper) GetCapability(ctx sdk.Context, name string) (*types.Capab

cap := sk.capMap[index]
if cap == nil {
panic("capability found in memstore is missing from map")
panic(fmt.Errorf("capability found in memstore is missing from map"))
}

return cap, true
2 changes: 1 addition & 1 deletion modules/core/02-client/genesis.go
Original file line number Diff line number Diff line change
@@ -27,7 +27,7 @@ func InitGenesis(ctx sdk.Context, k keeper.Keeper, gs types.GenesisState) {
for _, client := range gs.Clients {
cs, ok := client.ClientState.GetCachedValue().(exported.ClientState)
if !ok {
panic("invalid client state")
panic(fmt.Errorf("invalid client state"))
}

if !gs.Params.IsAllowedClient(cs.ClientType()) {
4 changes: 2 additions & 2 deletions modules/core/02-client/keeper/keeper.go
Original file line number Diff line number Diff line change
@@ -120,7 +120,7 @@ func (k Keeper) GetNextClientSequence(ctx sdk.Context) uint64 {
store := ctx.KVStore(k.storeKey)
bz := store.Get([]byte(types.KeyNextClientSequence))
if len(bz) == 0 {
panic("next client sequence is nil")
panic(fmt.Errorf("next client sequence is nil"))
}

return sdk.BigEndianToUint64(bz)
@@ -425,7 +425,7 @@ func (k Keeper) GetParams(ctx sdk.Context) types.Params {
store := ctx.KVStore(k.storeKey)
bz := store.Get([]byte(types.ParamsKey))
if bz == nil { // only panic on unset params and not on empty params
panic("client params are not set in store")
panic(fmt.Errorf("client params are not set in store"))
}

var params types.Params
60 changes: 31 additions & 29 deletions modules/core/02-client/migrations/v7/solomachine.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package v7

import (
fmt "fmt"

storetypes "cosmossdk.io/store/types"

"github.com/cosmos/cosmos-sdk/codec"
@@ -52,99 +54,99 @@ func (cs ConsensusState) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error

// ClientType panics!
func (ClientState) ClientType() string {
panic("legacy solo machine is deprecated!")
panic(fmt.Errorf("legacy solo machine is deprecated!"))
}

// GetLatestHeight panics!
func (ClientState) GetLatestHeight() exported.Height {
panic("legacy solo machine is deprecated!")
panic(fmt.Errorf("legacy solo machine is deprecated!"))
}

// Status panics!
func (ClientState) Status(_ sdk.Context, _ storetypes.KVStore, _ codec.BinaryCodec) exported.Status {
panic("legacy solo machine is deprecated!")
panic(fmt.Errorf("legacy solo machine is deprecated!"))
}

// Validate panics!
func (ClientState) Validate() error {
panic("legacy solo machine is deprecated!")
panic(fmt.Errorf("legacy solo machine is deprecated!"))
}

// ZeroCustomFields panics!
func (ClientState) ZeroCustomFields() exported.ClientState {
panic("legacy solo machine is deprecated!")
panic(fmt.Errorf("legacy solo machine is deprecated!"))
}

// Initialize panics!
func (ClientState) Initialize(_ sdk.Context, _ codec.BinaryCodec, _ storetypes.KVStore, _ exported.ConsensusState) error {
panic("legacy solo machine is deprecated!")
panic(fmt.Errorf("legacy solo machine is deprecated!"))
}

// ExportMetadata panics!
func (ClientState) ExportMetadata(_ storetypes.KVStore) []exported.GenesisMetadata {
panic("legacy solo machine is deprecated!")
panic(fmt.Errorf("legacy solo machine is deprecated!"))
}

// CheckForMisbehaviour panics!
func (ClientState) CheckForMisbehaviour(_ sdk.Context, _ codec.BinaryCodec, _ storetypes.KVStore, _ exported.ClientMessage) bool {
panic("legacy solo machine is deprecated!")
panic(fmt.Errorf("legacy solo machine is deprecated!"))
}

// UpdateStateOnMisbehaviour panics!
func (*ClientState) UpdateStateOnMisbehaviour(
_ sdk.Context, _ codec.BinaryCodec, _ storetypes.KVStore, _ exported.ClientMessage,
) {
panic("legacy solo machine is deprecated!")
panic(fmt.Errorf("legacy solo machine is deprecated!"))
}

// VerifyClientMessage panics!
func (*ClientState) VerifyClientMessage(
_ sdk.Context, _ codec.BinaryCodec, _ storetypes.KVStore, _ exported.ClientMessage,
) error {
panic("legacy solo machine is deprecated!")
panic(fmt.Errorf("legacy solo machine is deprecated!"))
}

// UpdateState panis!
func (*ClientState) UpdateState(_ sdk.Context, _ codec.BinaryCodec, _ storetypes.KVStore, _ exported.ClientMessage) []exported.Height {
panic("legacy solo machine is deprecated!")
panic(fmt.Errorf("legacy solo machine is deprecated!"))
}

// CheckHeaderAndUpdateState panics!
func (*ClientState) CheckHeaderAndUpdateState(
_ sdk.Context, _ codec.BinaryCodec, _ storetypes.KVStore, _ exported.ClientMessage,
) (exported.ClientState, exported.ConsensusState, error) {
panic("legacy solo machine is deprecated!")
panic(fmt.Errorf("legacy solo machine is deprecated!"))
}

// CheckMisbehaviourAndUpdateState panics!
func (ClientState) CheckMisbehaviourAndUpdateState(
_ sdk.Context, _ codec.BinaryCodec, _ storetypes.KVStore, _ exported.ClientMessage,
) (exported.ClientState, error) {
panic("legacy solo machine is deprecated!")
panic(fmt.Errorf("legacy solo machine is deprecated!"))
}

// CheckSubstituteAndUpdateState panics!
func (ClientState) CheckSubstituteAndUpdateState(
ctx sdk.Context, _ codec.BinaryCodec, _, _ storetypes.KVStore,
_ exported.ClientState,
) error {
panic("legacy solo machine is deprecated!")
panic(fmt.Errorf("legacy solo machine is deprecated!"))
}

// VerifyUpgradeAndUpdateState panics!
func (ClientState) VerifyUpgradeAndUpdateState(
_ sdk.Context, _ codec.BinaryCodec, _ storetypes.KVStore,
_ exported.ClientState, _ exported.ConsensusState, _, _ []byte,
) error {
panic("legacy solo machine is deprecated!")
panic(fmt.Errorf("legacy solo machine is deprecated!"))
}

// VerifyClientState panics!
func (ClientState) VerifyClientState(
store storetypes.KVStore, cdc codec.BinaryCodec,
_ exported.Height, _ exported.Prefix, _ string, _ []byte, clientState exported.ClientState,
) error {
panic("legacy solo machine is deprecated!")
panic(fmt.Errorf("legacy solo machine is deprecated!"))
}

// VerifyClientConsensusState panics!
@@ -153,23 +155,23 @@ func (ClientState) VerifyClientConsensusState(
exported.Height, string, exported.Height, exported.Prefix,
[]byte, exported.ConsensusState,
) error {
panic("legacy solo machine is deprecated!")
panic(fmt.Errorf("legacy solo machine is deprecated!"))
}

// VerifyConnectionState panics!
func (ClientState) VerifyConnectionState(
storetypes.KVStore, codec.BinaryCodec, exported.Height,
exported.Prefix, []byte, string, exported.ConnectionI,
) error {
panic("legacy solo machine is deprecated!")
panic(fmt.Errorf("legacy solo machine is deprecated!"))
}

// VerifyChannelState panics!
func (ClientState) VerifyChannelState(
storetypes.KVStore, codec.BinaryCodec, exported.Height, exported.Prefix,
[]byte, string, string, exported.ChannelI,
) error {
panic("legacy solo machine is deprecated!")
panic(fmt.Errorf("legacy solo machine is deprecated!"))
}

// VerifyPacketCommitment panics!
@@ -178,7 +180,7 @@ func (ClientState) VerifyPacketCommitment(
uint64, uint64, exported.Prefix, []byte,
string, string, uint64, []byte,
) error {
panic("legacy solo machine is deprecated!")
panic(fmt.Errorf("legacy solo machine is deprecated!"))
}

// VerifyPacketAcknowledgement panics!
@@ -187,7 +189,7 @@ func (ClientState) VerifyPacketAcknowledgement(
uint64, uint64, exported.Prefix, []byte,
string, string, uint64, []byte,
) error {
panic("legacy solo machine is deprecated!")
panic(fmt.Errorf("legacy solo machine is deprecated!"))
}

// VerifyPacketReceiptAbsence panics!
@@ -196,7 +198,7 @@ func (ClientState) VerifyPacketReceiptAbsence(
uint64, uint64, exported.Prefix, []byte,
string, string, uint64,
) error {
panic("legacy solo machine is deprecated!")
panic(fmt.Errorf("legacy solo machine is deprecated!"))
}

// VerifyNextSequenceRecv panics!
@@ -205,14 +207,14 @@ func (ClientState) VerifyNextSequenceRecv(
uint64, uint64, exported.Prefix, []byte,
string, string, uint64,
) error {
panic("legacy solo machine is deprecated!")
panic(fmt.Errorf("legacy solo machine is deprecated!"))
}

// GetTimestampAtHeight panics!
func (ClientState) GetTimestampAtHeight(
sdk.Context, storetypes.KVStore, codec.BinaryCodec, exported.Height,
) (uint64, error) {
panic("legacy solo machine is deprecated!")
panic(fmt.Errorf("legacy solo machine is deprecated!"))
}

// VerifyMembership panics!
@@ -227,7 +229,7 @@ func (*ClientState) VerifyMembership(
path exported.Path,
value []byte,
) error {
panic("legacy solo machine is deprecated!")
panic(fmt.Errorf("legacy solo machine is deprecated!"))
}

// VerifyNonMembership panics!
@@ -241,20 +243,20 @@ func (*ClientState) VerifyNonMembership(
proof []byte,
path exported.Path,
) error {
panic("legacy solo machine is deprecated")
panic(fmt.Errorf("legacy solo machine is deprecated"))
}

// ClientType panics!
func (ConsensusState) ClientType() string {
panic("legacy solo machine is deprecated!")
panic(fmt.Errorf("legacy solo machine is deprecated!"))
}

// GetTimestamp panics!
func (ConsensusState) GetTimestamp() uint64 {
panic("legacy solo machine is deprecated!")
panic(fmt.Errorf("legacy solo machine is deprecated!"))
}

// ValidateBasic panics!
func (ConsensusState) ValidateBasic() error {
panic("legacy solo machine is deprecated!")
panic(fmt.Errorf("legacy solo machine is deprecated!"))
}
6 changes: 4 additions & 2 deletions modules/core/03-connection/keeper/keeper.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package keeper

import (
"fmt"

errorsmod "cosmossdk.io/errors"
"cosmossdk.io/log"
storetypes "cosmossdk.io/store/types"
@@ -136,7 +138,7 @@ func (k Keeper) GetNextConnectionSequence(ctx sdk.Context) uint64 {
store := ctx.KVStore(k.storeKey)
bz := store.Get([]byte(types.KeyNextConnectionSequence))
if len(bz) == 0 {
panic("next connection sequence is nil")
panic(fmt.Errorf("next connection sequence is nil"))
}

return sdk.BigEndianToUint64(bz)
@@ -228,7 +230,7 @@ func (k Keeper) GetParams(ctx sdk.Context) types.Params {
store := ctx.KVStore(k.storeKey)
bz := store.Get([]byte(types.ParamsKey))
if bz == nil { // only panic on unset params and not on empty params
panic("connection params are not set in store")
panic(fmt.Errorf("connection params are not set in store"))
}

var params types.Params
3 changes: 2 additions & 1 deletion modules/core/04-channel/keeper/keeper.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package keeper

import (
"fmt"
"strconv"
"strings"

@@ -109,7 +110,7 @@ func (k Keeper) GetNextChannelSequence(ctx sdk.Context) uint64 {
store := ctx.KVStore(k.storeKey)
bz := store.Get([]byte(types.KeyNextChannelSequence))
if len(bz) == 0 {
panic("next channel sequence is nil")
panic(fmt.Errorf("next channel sequence is nil"))
}

return sdk.BigEndianToUint64(bz)
4 changes: 2 additions & 2 deletions modules/core/05-port/types/router.go
Original file line number Diff line number Diff line change
@@ -23,7 +23,7 @@ func NewRouter() *Router {
// Seal will panic if called more than once.
func (rtr *Router) Seal() {
if rtr.sealed {
panic("router already sealed")
panic(fmt.Errorf("router already sealed"))
}
rtr.sealed = true
}
@@ -40,7 +40,7 @@ func (rtr *Router) AddRoute(module string, cbs IBCModule) *Router {
panic(fmt.Sprintf("router sealed; cannot register %s route callbacks", module))
}
if !sdk.IsAlphaNumeric(module) {
panic("route expressions can only contain alphanumeric characters")
panic(fmt.Errorf("route expressions can only contain alphanumeric characters"))
}
if rtr.HasRoute(module) {
panic(fmt.Sprintf("route %s has already been registered", module))
2 changes: 1 addition & 1 deletion modules/core/keeper/keeper.go
Original file line number Diff line number Diff line change
@@ -93,7 +93,7 @@ func (k Keeper) Codec() codec.BinaryCodec {
// there is an existing router that's already sealed.
func (k *Keeper) SetRouter(rtr *porttypes.Router) {
if k.Router != nil && k.Router.Sealed() {
panic("cannot reset a sealed router")
panic(fmt.Errorf("cannot reset a sealed router"))
}

k.PortKeeper.Router = rtr
3 changes: 2 additions & 1 deletion modules/light-clients/06-solomachine/client_state.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package solomachine

import (
fmt "fmt"
"reflect"

errorsmod "cosmossdk.io/errors"
@@ -76,7 +77,7 @@ func (cs ClientState) Validate() error {

// ZeroCustomFields is not implemented for solo machine
func (ClientState) ZeroCustomFields() exported.ClientState {
panic("ZeroCustomFields is not implemented as the solo machine implementation does not support upgrades.")
panic(fmt.Errorf("ZeroCustomFields is not implemented as the solo machine implementation does not support upgrades."))
}

// Initialize checks that the initial consensus state is equal to the latest consensus state of the initial client and
5 changes: 3 additions & 2 deletions testing/simapp/export.go
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@ package simapp

import (
"encoding/json"
"fmt"
"log"

storetypes "cosmossdk.io/store/types"
@@ -209,7 +210,7 @@ func (app *SimApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []
addr := sdk.ValAddress(stakingtypes.AddressFromValidatorsKey(iter.Key()))
validator, err := app.StakingKeeper.GetValidator(ctx, addr)
if err != nil {
panic("expected validator, not found")
panic(fmt.Errorf("expected validator, not found"))
}

validator.UnbondingHeight = 0
@@ -219,7 +220,7 @@ func (app *SimApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []

err = app.StakingKeeper.SetValidator(ctx, validator)
if err != nil {
panic("couldn't set validator")
panic(fmt.Errorf("couldn't set validator"))
}
counter++
}