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

Revert "fix(server): consensus failure while restart node with wrong chainId #201

Merged

Conversation

mmsqe
Copy link
Collaborator

@mmsqe mmsqe commented Feb 27, 2024

chainId in genesis (cosmos#18920)"

This reverts commit 67aee75.

Description

Closes: #XXXX


Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • included the correct type prefix in the PR title
  • added ! to the type prefix if API or client breaking change
  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • followed the guidelines for building modules
  • included the necessary unit and integration tests
  • added a changelog entry to CHANGELOG.md
  • included comments for documenting Go code
  • updated the relevant documentation or specification
  • reviewed "Files changed" and left comments if necessary
  • confirmed all CI checks have passed

Reviewers Checklist

All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed ! in the type prefix if API or client breaking change
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic
  • reviewed API design and naming
  • reviewed documentation is accurate
  • reviewed tests and test coverage
  • manually tested (if applicable)

@mmsqe mmsqe requested a review from yihuang February 27, 2024 09:27
@julienrbrt
Copy link

I am curious, what's the reason of the revert in your fork?
I know you were suggesting in the sdk too (cosmos#19573 (comment)). You were suggesting to have a chain-id field in the app.toml, but I couldn't find it here: https://github.com/crypto-org-chain/cronos/blob/main/cmd/cronosd/cmd/root.go#L218-L234 / https://github.com/crypto-org-chain/chain-main/blob/master/cmd/chain-maind/app/app.go#L98-L121)

@yihuang
Copy link
Collaborator

yihuang commented Feb 27, 2024

I am curious, what's the reason of the revert in your fork?

Because we are at the final stage of our new release, and I think parsing the cometbft config and opening the cometbft db in SDK seems hacky and error-prone. The original issue is not very so serious, and there's an easy workaround by setting the right genesis file or chain-id in config.

I know you were suggesting in the sdk too (cosmos#19573 (comment)). You were suggesting to have a chain-id field in the app.toml, but I couldn't find it here: https://github.com/crypto-org-chain/cronos/blob/main/cmd/cronosd/cmd/root.go#L218-L234 / https://github.com/crypto-org-chain/chain-main/blob/master/cmd/chain-maind/app/app.go#L98-L121)

Because the items in app.toml and the cmd flags are merged together into the appOpts using the viper library, and since we read the chain-id flag like this:

chainID := cast.ToString(appOpts.Get(flags.FlagChainID))

It actually reads from both cmd flags and app.toml, so setting the correct chain-id in the app.toml can also solve the problem, and user doesn't need to pass the --chain-id cmd flag all the time.
And the --chain-id flag is not available in start command, so user can only set it in the app.toml, or genesis file.

@k-yang
Copy link

k-yang commented Feb 27, 2024

I am curious, what's the reason of the revert in your fork?

Because we are at the final stage of our new release, and I think parsing the cometbft config and opening the cometbft db in SDK seems hacky and error-prone. The original issue is not very so serious, and there's an easy workaround by setting the right genesis file or chain-id in config.

I know you were suggesting in the sdk too (cosmos#19573 (comment)). You were suggesting to have a chain-id field in the app.toml, but I couldn't find it here: https://github.com/crypto-org-chain/cronos/blob/main/cmd/cronosd/cmd/root.go#L218-L234 / https://github.com/crypto-org-chain/chain-main/blob/master/cmd/chain-maind/app/app.go#L98-L121)

Because the items in app.toml and the cmd flags are merged together into the appOpts using the viper library, and since we read the chain-id flag like this:

chainID := cast.ToString(appOpts.Get(flags.FlagChainID))

It actually reads from both cmd flags and app.toml, so setting the correct chain-id in the app.toml can also solve the problem, and user doesn't need to pass the --chain-id cmd flag all the time. And the --chain-id flag is not available in start command, so user can only set it in the app.toml, or genesis file.

Hi @yihuang , there is no chain-id config field in app.toml (https://github.com/cosmos/cosmos-sdk/blob/release/v0.47.x/server/config/config.go).

And like you said, there is no --chain-id flag on the start command, so DefaultBaseappOptions is forced to run readChainIdFromHome, which fails because it defaults to reading the db files as goleveldb and disregards the db_backend settings.

I understand it's messy to mix ComebFT config in the cosmos-sdk startup code, but CometBFT config was initialized here, without regard to the DBBackend config.

I honestly think the best solution is to revert https://github.com/cosmos/cosmos-sdk/pull/18920/files entirely, which has already been done on main. It just needs to be backported onto a v0.47.x release.

@yihuang
Copy link
Collaborator

yihuang commented Feb 27, 2024

Hi @yihuang , there is no chain-id config field in app.toml (https://github.com/cosmos/cosmos-sdk/blob/release/v0.47.x/server/config/config.go).

it's just not in the Config struct, but if the user sets it in the app.toml anyway, it can still be read in appOpts, that's the workaround we are using right now actually.

@mmsqe
Copy link
Collaborator Author

mmsqe commented Feb 27, 2024

we set in the top level of app.toml

@k-yang
Copy link

k-yang commented Feb 27, 2024

Hi @yihuang , there is no chain-id config field in app.toml (https://github.com/cosmos/cosmos-sdk/blob/release/v0.47.x/server/config/config.go).

it's just not in the Config struct, but if the user sets it in the app.toml anyway, it can still be read in appOpts, that's the workaround we are using right now actually.

Interesting... I agree it's a workaround, but it's not documented anywhere.

I still think the best solution is to revert the readChainIdFromHome commit, which is what this PR does.

@yihuang yihuang merged commit 0f7197f into crypto-org-chain:release/v0.47.x Feb 28, 2024
23 of 27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants