Skip to content

feat(unwind): add unwind operation for sdk&greth#631

Open
AshinGau wants to merge 1 commit intoGalxe:mainfrom
AshinGau:main
Open

feat(unwind): add unwind operation for sdk&greth#631
AshinGau wants to merge 1 commit intoGalxe:mainfrom
AshinGau:main

Conversation

@AshinGau
Copy link
Copy Markdown
Contributor

@AshinGau AshinGau commented Mar 30, 2026

PR Description

feat(unwind): add unwind operation for SDK & gReth

This PR implements database unwind (rollback) support for both the execution layer (gReth) and the consensus layer (gravity-sdk), enabling operators to revert the node to a specific block height.

Execution Layer (gravity_node)

  • Wires up the previously unimplemented stage unwind CLI command by adding the Commands::Stage branch in cli.rs.
  • Adds an is_node_command() check in main.rs so utility subcommands (stage, db, config, etc.) bypass full node initialization (consensus, relayer), which would otherwise panic on missing config.
gravity_node stage unwind --datadir <reth-data-dir> to-block <TARGET>

Consensus Layer (gravity_cli)

  • Adds ConsensusDB::unwind_to_block(target) which atomically deletes all blocks, QCs, ledger infos, epoch mappings, randomness, and stale vote/timeout certificates above the target block number.
  • Introduces the gravity-cli unwind subcommand to invoke it.
  • Fixes RecoveryData::find_root_by_block_number to gracefully handle missing committing QCs after an unwind by falling back to the storage ledger info, preventing "No LI found for root" panics on restart.
gravity-cli unwind --consensus-db-path <path-to-consensus-db> --target <TARGET>

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.

1 participant