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

feat(app): rollback many blocks #349

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

feat(app): rollback many blocks #349

wants to merge 5 commits into from

Conversation

jdubpark
Copy link
Contributor

@jdubpark jdubpark commented Nov 7, 2024

rollback multiple Cosmos App blocks and corresponding CometBFT states

issue: none

cmd.Flags().BoolVar(&cfg.RemoveBlock, "hard", false, "remove last block as well as state")
func bindRollbackFlags(cmd *cobra.Command, cfg *rollbackConfig) {
cmd.Flags().BoolVar(&cfg.RemoveBlock, "hard", false, "remove Cosmos & CometBFT blocks as well as states")
cmd.Flags().BoolVar(&cfg.RemoveBlock, "rollback-evm", false, "remove EVM blocks as well")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the evm rollback is using the same config param as the hard, is it intentional?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we don't support rollback-evm, I think we can remove this flag.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reflected in e78cb90


// newRollbackCmd returns a new cobra command that rolls back one block of the story consensus client.
func newRollbackCmd(appCreateFunc func(context.Context, app.Config) *app.App) *cobra.Command {
rollbackCfg := rollbackConfig{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can use the similar pattern that use rollbackConfig.DefaultConfig()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed in 5cc6dd4

return err
} else if latestBlock.BeaconRoot() == nil {
return errors.New("cannot rollback EVM with nil beacon root", "height", latestHeigth)
if !rollbackEVM || rollbackHeights <= 1 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need || rollbackHeights <= 1 ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reflected in e78cb90

}

db, err := dbm.NewDB("application", cfg.BackendType(), cfg.DataDir())
engineCl, err := newEngineClient(ctx, appCfg)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think based on what we discussed with Omni and this PR, we cannot support EVM rollback and hence this part of the code was removed by Omni

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reflected in e78cb90

client/app/rollback.go Outdated Show resolved Hide resolved
client/cmd/rollback.go Outdated Show resolved Hide resolved
func bindRollbackFlags(cmd *cobra.Command, cfg *config.Config) {
cmd.Flags().BoolVar(&cfg.RemoveBlock, "hard", false, "remove last block as well as state")
func bindRollbackFlags(cmd *cobra.Command, cfg *config.RollbackConfig) {
cmd.Flags().BoolVar(&cfg.RemoveBlock, "hard", false, "remove Cosmos & CometBFT blocks as well as states")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We probably don't need to support RemoveBlock flag since as we discussed, removeBlock currently won't work in our case.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a parameter accepted by Rollback exposed in CometBFT. We could set it to false and not take the parameter externally if that's what you mean.

A state rollback is performed to recover from an incorrect application state transition,
when CometBFT has persisted an incorrect app hash and is thus unable to make
progress. Rollback overwrites a state at height n with the state at height n - X.
The application also rolls back to height n - X. If --hard=true, the block
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to update the description here. --hard is not supported any more.

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.

3 participants