ignite/cli

Simulate fail for chains created with address-prefix setup

Closed this issue · 4 comments

Describe the bug
ignite simulate failed for chains created with a custom address prefix

To reproduce
Steps to reproduce the behavior:

  1. ignite scaffold chain github.com/test/example --address-prefix test
  2. cd example
  3. ignite chain simulate # fails here

Below is the error messages:

panic: invalid bank authority address: hrp does not match bech32 prefix: expected 'test' got 'cosmos': internal logic error [cosmos/cosmos-sdk@v0.50.7/codec/address/bech32_codec.go:37]

goroutine 50 [running]:
github.com/cosmos/cosmos-sdk/x/bank/keeper.NewBaseKeeper({_, _}, {_, _}, {_, _}, _, {_, _}, {0x10861b9e8, ...})

What version are you using?

Ignite CLI version:             v28.4.0
Ignite CLI build date:          2024-05-15T13:42:13Z
Ignite CLI source hash:         83ee9ba5f81f2d2104ed91808f2cb72719a23e41
Ignite CLI config version:      v1
Cosmos SDK version:             v0.50.6
Your OS:                        darwin
Your arch:                      amd64
Your Node.js version:           v22.2.0
Your go version:                go version go1.22.4 darwin/amd64

@pangwa The example chain had already been scaffolded with address prefix 'cosmos' then pushed to github. I beleive you can change the address prefix to 'test' in the app.go file then you should not get an error when you serve the chain or build the binary. Can you please try that?

cc: @salmad3 @julienrbrt

I tried that, cleanup the binaries to make sure everything was rebuilt. ignite chain serve works well. only ignite chain simulate fails.

Thanks @pangwa, I tried scaffolding a new chain from scratch with the 'test' prefix and got the same error message as you. Thanks for flagging this, hopefully a solution can be found.

Due to the leak of the global config still present in the SDK, setting the bech32 prefixes only in the app config isn't sufficient. Currently, we were initializing the bech32 global sdk config when the root command was called. Which wasn't the case in simulations.

The fix is to move the setting of the bech32 prefix in the app (app/) instead of the app commands. See the opened PR for how to do it.