-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
cli should throw error if --chain-id not provided #810
Comments
Can we load the chain ID automatically from the genesis file, if present? |
Will the light client keep a genesis file with chain ID? |
Note we have to implement the See #822 |
This problem is there again with |
Yes, you're right, looks like a regression here. cc @alessio Thoughts? |
There is a function we can already use to get the default chain ID. If the user does not provide one, it seems like a reasonable UX to fall back on the default. Alternatively, we could simply require the chain ID. |
I think this is a bit dangerous - chain ID is part of the signature; if you sign over a message with a chain ID you didn't intend it could have deleterious consequences (e.g. it might be a valid tx on a different blockchain). Better to require chain ID, if it isn't specified in the CLI config. |
Indeed. Seems like we have an actionable item here to require the chain ID flag. |
When func NewTxBuilderFromCLI() TxBuilder {
// if chain ID is not specified manually, read default chain ID
chainID := viper.GetString(client.FlagChainID)
if chainID == "" {
defaultChainID, err := sdk.DefaultChainID()
if err != nil {
chainID = defaultChainID
}
} [snip] Well, // DefaultChainID returns the chain ID from the genesis file if present. An
// error is returned if the file cannot be read or parsed.
//
// TODO: This should be removed and the chainID should always be provided by
// the end user.
func DefaultChainID() (string, error) {
cfg, err := tcmd.ParseConfig()
if err != nil {
return "", err
}
doc, err := tmtypes.GenesisDocFromFile(cfg.GenesisFile())
if err != nil {
return "", err
}
return doc.ChainID, nil
} IMO we should get rid of |
- Remove DefaultChainID(). User needs to suplly chain ID via either config or flag. - Mark --chain-id as required by all tx commands. - Fix gaiacli config values containing underscores. Underscore '_' character is not automagically translated into hyphen '-'. Viper values wouldn't be affected. - Refresh gaiacli config tests Closes: #810
- Remove DefaultChainID(). User needs to suplly chain ID via either config or flag. - Mark --chain-id as required by all tx commands. - Fix gaiacli config values containing underscores. Underscore '_' character is not automagically translated into hyphen '-'. Viper values wouldn't be affected. - Refresh gaiacli config tests Closes: #810
- Remove DefaultChainID(). User needs to suplly chain ID via either config or flag. - Mark --chain-id as required by all tx commands. - Fix gaiacli config values containing underscores. Underscore '_' character is not automagically translated into hyphen '-'. Viper values wouldn't be affected. - Refresh gaiacli config tests Closes: #810
- Remove DefaultChainID(). User needs to suplly chain ID via either config or flag. - Mark --chain-id as required by all tx commands. - Fix gaiacli config values containing underscores. Underscore '_' character is not automagically translated into hyphen '-'. Viper values wouldn't be affected. - Refresh gaiacli config tests Closes: #810
I had previously setup my client to pull the chain-id from a config file in the cli settings dir. For our project I had even setup a cli init command. PR #3127 broke this with the addition of Is the intention here to always require cli users to specify the chain-id even if they have a config file setup? |
I'm with @aaronc on this one. This also broke the |
@aaronc Thank you for taking the time to report this bug and helping to make Cosmos SDK better.
No, that was not the intention. I'll look into it ASAP. |
@aaronc can you paste your config file please? |
@alessio Here's a config file I use to connect to our testnet:
|
@aaronc this is done now, please test |
My CLI is giving an error when chainid not provided. |
@jackzampolin please run |
Txs require
--chain-id
to be provided so it can be signed.Note the chainid is not included in the tx itself, but it is part of the bytes that get signed to prevent cross-chain replay attacks.
Unfortunately, it means the error message just comes up as "signature verification failed" and we can't really detect why.
Thus, if the --chain-id is not provided, we should throw an error and tell the user it must be provided.
The text was updated successfully, but these errors were encountered: