cosmos-sdk: cli should throw error if --chain-id not provided

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.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 17 (16 by maintainers)

Commits related to this issue

Most upvoted comments

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.

Can we load the chain ID automatically from the genesis file, if present?

@aaronc this is done now, please test

Indeed. Seems like we have an actionable item here to require the chain ID flag.