集成自定义checkers模块至chain-minimal启动时遇SetOrderInitGenesis缺失错误
问题与解决
环境信息
- Ubuntu:22.04 LTS
- Golang:1.21.0
- Cosmos SDK:v0.50.10
- minid:mini-v050
问题描述
已构建自定义checkers模块并集成到chain-minimal中,执行minid start命令时触发如下panic错误:
panic: all modules must be defined when setting SetOrderInitGenesis, missing: [checkers] goroutine 1 [running]: github.com/cosmos/cosmos-sdk/types/module.(*Manager).assertNoForgottenModules(0xc0015a1ee0, {0x22822b8, 0x13}, {0xc000cba480, 0x5, 0xc000cf56c0?}, 0xc001398500) /home/rahul/go/pkg/mod/github.com/cosmos/cosmos-sdk@v0.50.10/types/module/module.go:634 +0x365 github.com/cosmos/cosmos-sdk/types/module.(*Manager).SetOrderInitGenesis(0xc0015a1ee0, {0xc000cba480, 0x5, 0x8}) /home/rahul/go/pkg/mod/github.com/cosmos/cosmos-sdk@v0.50.10/types/module/module.go:347 +0x5c github.com/cosmos/cosmos-sdk/runtime.(*App).Load(0xc0007cd500, 0x1) /home/rahul/go/pkg/mod/github.com/cosmos/cosmos-sdk@v0.50.10/runtime/app.go:106 +0x4b github.com/cosmosregistry/chain-minimal/app.NewMiniApp({0x2c69428?, 0xc000a85110}, {0x2c79260, 0xc00031a010}, {0x0, 0x0}, 0x12?, {0x2c3d8e0?, 0xc000af5a40}, {0xc000a84150, ...}) /home/rahul/Desktop/Learning/cosmos/chain-minimal/app/app.go:153 +0x7a5 github.com/cosmosregistry/chain-minimal/cmd/minid/cmd.newApp({0x2c69428, 0xc000a85110}, {0x2c79260, 0xc00031a010}, {0x0, 0x0}, {0x2c3d8e0, 0xc000af5a40}) /home/rahul/Desktop/Learning/cosmos/chain-minimal/cmd/minid/cmd/commands.go:104 +0xaa github.com/cosmos/cosmos-sdk/server.startApp(0xc0004e2940, 0x2a0ac08, {0x2a0b368, 0x0, 0x0, 0x0, 0x2a0b378}) /home/rahul/go/pkg/mod/github.com/cosmos/cosmos-sdk@v0.50.10/server/start.go:618 +0x215 github.com/cosmos/cosmos-sdk/server.start(_, {{0x0, 0x0, 0x0}, {0x2c7e8c8, 0xc000905860}, 0x0, {0xc0008754a8, 0x4}, {0x2c92420, ...}, ...}, ...) /home/rahul/go/pkg/mod/github.com/cosmos/cosmos-sdk@v0.50.10/server/start.go:224 +0x159 github.com/cosmos/cosmos-sdk/server.StartCmdWithOptions.func2.1() /home/rahul/go/pkg/mod/github.com/cosmos/cosmos-sdk@v0.50.10/server/start.go:198 +0x6d github.com/cosmos/cosmos-sdk/server.wrapCPUProfile(0xc0004e2940, 0xc000c9f808) /home/rahul/go/pkg/mod/github.com/cosmos/cosmos-sdk@v0.50.10/server/start.go:570 +0x1b3 github.com/cosmos/cosmos-sdk/server.StartCmdWithOptions.func2(0xc00087dd00?, {0x4060c60?, 0x0?, 0x0?}) /home/rahul/go/pkg/mod/github.com/cosmos/cosmos-sdk@v0.50.10/server/start.go:197 +0x212 github.com/spf13/cobra.(*Command).execute(0xc0002e3500, {0x4060c60, 0x0, 0x0}) /home/rahul/go/pkg/mod/github.com/spf13/cobra@v1.8.1/command.go:985 +0xabc github.com/spf13/cobra.(*Command).ExecuteC(0xc000be9500) /home/rahul/go/pkg/mod/github.com/spf13/cobra@v1.8.1/command.go:1117 +0x3ff github.com/spf13/cobra.(*Command).Execute(...) /home/rahul/go/pkg/mod/github.com/spf13/cobra@v1.8.1/command.go:1041 github.com/spf13/cobra.(*Command).ExecuteContext(...) /home/rahul/go/pkg/mod/github.com/spf13/cobra@v1.8.1/command.go:1034 github.com/cosmos/cosmos-sdk/server/cmd.Execute(0x40b34b?, {0x0, 0x0}, {0xc000cb65b8, 0x12}) /home/rahul/go/pkg/mod/github.com/cosmos/cosmos-sdk@v0.50.10/server/cmd/execute.go:34 +0x187 main.main() /home/rahul/Desktop/Learning/cosmos/chain-minimal/cmd/minid/main.go:18 +0x38
解决方法
这个错误是因为Cosmos SDK的模块管理器在初始化Genesis时,找不到已声明的checkers模块,或者该模块未被加入初始化顺序列表。按以下步骤修复:
- 打开
chain-minimal/app/app.go文件,找到ModuleManager的初始化代码,确保checkers模块已被添加到Modules集合中 - 在
SetOrderInitGenesis方法的参数里加入"checkers",保证模块初始化顺序包含该自定义模块 - 重新编译并安装项目:
make install - 再次执行
minid start即可启动节点
内容的提问来源于stack exchange,提问作者rahul_eth
相关产品推荐
相关产品推荐

