FFORGE//RS
← Roadmap

blockchain / LEVEL 5

The indexer applied half a new branch

EST.60 MIN
01

THEORY / RETRIEVAL

What to restore

  • Persist reversible effects for every applied block
  • Validate parent links and arithmetic on a staged state
  • Commit a complete branch switch or leave the prior index unchanged

Indexed state is a materialized view of a chosen chain

A non-finalized block can become orphaned. Indexers retain block identity and per-block undo evidence, roll back to the common ancestor in reverse order, then apply the new canonical branch. Deleting block rows without reversing derived aggregates leaves silent corruption.

Branch switch is one observable operation

Parent validation, balance arithmetic and schema writes can fail midway. Stage the rollback and new branch in a database transaction or shadow version, then publish the new head atomically. Finalized and speculative query tiers should be explicit to API consumers.

CHECKPOINT

An indexer finds the common ancestor but fails while applying the second replacement block. What state should readers observe?

ISOLATED RUST 1.96
src/lib.rsEDIT

02 / IMPLEMENTATION

Implement the contract

Implement atomic reconcile. common_height is the retained chain index, or None for genesis. Roll back undo entries in reverse, validate nonzero unique hashes and parent links, checked-add every delta, and replace the real index only if the entire new branch succeeds.

Initializing editor…
CLOUD SANDBOXnetwork off · 256 MB · 12 s
1 / 64 KB
OUTPUT
Runner is waiting for a submission.