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

Capability genesis ex- and import fails with panic [Stargate] #8503

Closed
4 tasks
alpe opened this issue Feb 3, 2021 · 4 comments
Closed
4 tasks

Capability genesis ex- and import fails with panic [Stargate] #8503

alpe opened this issue Feb 3, 2021 · 4 comments
Labels

Comments

@alpe
Copy link
Contributor

alpe commented Feb 3, 2021

Summary of Bug

Capability genesis ex- and import fails with panic

panic: SetIndex requires index to not be set [recovered]
	panic: SetIndex requires index to not be set

This issue was discovered by @bragaz in wasmd running simulations. 🥇
See CosmWasm/wasmd#389 (comment)

// cc @ethanfrey

Version

v0.41.0 f8a6987

Steps to Reproduce

package capability_test

import (
	"github.com/cosmos/cosmos-sdk/simapp"
	sdk "github.com/cosmos/cosmos-sdk/types"
	"github.com/cosmos/cosmos-sdk/x/capability"
	capabilitykeeper "github.com/cosmos/cosmos-sdk/x/capability/keeper"
	"github.com/cosmos/cosmos-sdk/x/capability/types"
	host "github.com/cosmos/cosmos-sdk/x/ibc/core/24-host"
	"github.com/stretchr/testify/require"
	tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
	"testing"
)

func TestGenesisIO(t *testing.T) {
	keeper, ctx := newApp()
	chanCap := types.NewCapability(101)

	err := keeper.ScopeToModule("foobar").ClaimCapability(ctx, chanCap, host.ChannelCapabilityPath("portID", "channelID"))
	require.NoError(t, err)
	state := capability.ExportGenesis(ctx, *keeper)
	otherKeeper, otherCtx := newApp()
	// when
	capability.InitGenesis(otherCtx, *otherKeeper, *state)
	// then no panic
}

func newApp() (*capabilitykeeper.Keeper, sdk.Context) {
	checkTx := false
	app := simapp.Setup(checkTx)
	cdc := app.AppCodec()

	keeper := capabilitykeeper.NewKeeper(cdc, app.GetKey(types.StoreKey), app.GetMemKey(types.MemStoreKey))
	ctx := app.BaseApp.NewContext(checkTx, tmproto.Header{Height: 1})
	return keeper, ctx
}

For Admin Use

  • Not duplicate issue
  • Appropriate labels applied
  • Appropriate contributors tagged
  • Contributor assigned/self-assigned
@ethanfrey
Copy link
Contributor

I assume this means "dump state and restart" is now deprecated and we should all just use x/upgrade?
(I am fine with this, it should just be documented clearly)

@tac0turtle
Copy link
Member

This is still present on master. Not sure if this test is correct since we have done a export and restart chain since this module landed.

@AmauryM maybe you have an idea?

@amaury1093
Copy link
Contributor

I think the test is failing because we are calling InitGenesis twice: once in simapp.Setup, and the 2nd manually.

@alpe Did you try running a JSON genesis migration manually? I also recall doing a v042->v044 fine.

@alpe
Copy link
Contributor Author

alpe commented May 20, 2022

There have been state export/imports without issues in the wild. The simapp.Setup does call init indeed. Thanks for looking into this!

@alpe alpe closed this as completed May 20, 2022
Repository owner moved this from Icebox to Done in Cosmos SDK Maintenance May 20, 2022
sybilsingleton added a commit to BlitChain/blitchain that referenced this issue Mar 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
No open projects
Development

No branches or pull requests

4 participants