Skip to content

Bridge-event and peg indexes are not crash-safe across a branch switch #377

Open

Description

@SDL-A1

From the external review of #374.

sync/src/service/beside.rs:54,939-1005 and storage/src/position.rs:273-450.

The head switch itself is one atomic batch. The Bridge-event index and the legacy
peg-event store are then updated afterwards, from an in-memory log.

A crash in the window between leaves:

  • the old branch's events still indexed, and
  • peg records from blocks run beside the chain lost for good

Nothing repairs either on restart.

Scope

This does not affect consensus. The state root and the chain are unaffected.
It affects anything that reads those indexes — eth_getLogs over Bridge events,
peg-in/peg-out reporting, and the peg accounting work tracked separately.

Worth stating plainly because "crash-unsafe index" sounds worse than it is: a
resync or an index rebuild fixes it, if we have one. The problem is that today we
have neither a rebuild path nor detection.

What would settle it

Either fold the index updates into the same atomic batch as the head switch, or
add a repair-on-restart that detects the inconsistency and rebuilds from the
canonical chain.

Reported by the external reviewer; the file:line anchors are theirs and have not
been re-derived here.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions