Skip to content

feat: add recovery rewind commands - #13

Open
littlehand26 wants to merge 7 commits into
mainfrom
feat/rewind-to-height
Open

littlehand26 wants to merge 7 commits into
mainfrom
feat/rewind-to-height

Conversation

@littlehand26

@littlehand26 littlehand26 commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor

Problem

The existing rollback command removes one height and also rewinds the
application store. Recovering a multi-height fork needs bounded, resumable
commands for removing the CometBFT and index suffixes while the application is
rolled back separately.

Solution

Add two stopped-node recovery commands:

  • cronosd rewind-cometbft <height> validates the target and repeatedly uses
    CometBFT's hard rollback while holding the databases open. It also handles a
    one-block pending blockstore/state mismatch.
  • cronosd rewind-indexes <height> scans the mandatory tx.height namespace,
    uses the persisted FinalizeBlockResponse for each affected height to remove
    the exact transaction event entries, removes block-event entries above the
    target, and starts the EVM iterator at target+1. If the same transaction
    hash exists on both sides of the rewind boundary, the command restores the
    retained raw transaction result instead of deleting it.

Index writes are ordered so interrupted runs retain tx.height entries as
recovery markers until the corresponding event/hash cleanup is complete. Both
commands report progress and are idempotent. Application rollback remains an
explicit separate step.

Tests

  • go test ./cmd/cronosd/cmd -count=1
  • go vet ./cmd/cronosd/cmd
  • git diff --check

Signed-off-by: lihe <he.li@debank.com>
Signed-off-by: lihe <he.li@debank.com>
@littlehand26 littlehand26 changed the title feat: add CometBFT rewind command feat: add recovery rewind commands Sep 1, 2026
Comment thread cmd/cronosd/cmd/rewind_indexes.go Fixed
Signed-off-by: lihe <he.li@debank.com>
Comment on lines +312 to +314
for _, prefix := range prefixes {
resultPrefixes = append(resultPrefixes, prefix)
}
Signed-off-by: lihe <he.li@debank.com>
Signed-off-by: lihe <he.li@debank.com>
Comment on lines +533 to +535
for _, prefix := range prefixes {
result = append(result, prefix)
}
Signed-off-by: lihe <he.li@debank.com>
Signed-off-by: lihe <he.li@debank.com>

This branch has not been deployed

No deployments
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.

2 participants