Skip to content

SBliFF fork handling #1566

@brenzi

Description

@brenzi

Under the assumption of BliFF on L1, SCV can detect and handle forks like this:

get sidechain.last_finalized_block
if head.is_lineal_descendant_of(last_finalized_block)
  //all good, no fork. continue
else
  // we're on a fork. 
  find peer who knows last_finalized_block
  fetch blocks backwards from last_finalized_block until we hit a known block in our sidechain_db
  if peer can't deliver or no match is found, kill own state and sidechain_db and request full provisioning from peer (i.e. by bruteforce deleting the state&db on disk and restarting the service)
  if successful, fetch all recent blocks from peer since last_finalized_block
   
  

prior work

Consider thoughts in here:
#687

ForkTree

There is an implementation ForkTree already which we could use here. #1196

import_or_sync_block() (in import queue worker) currently simply tries to import blocks in order of their blocknumber and purges blocks that don't match.

Instead, we should maintain a fork tree of all block candidates we know. upon a new finalization ForkTree can prune branches that are finally abandoned

design

design decisions:

  • validateer fetches LatestSidechainBlockConfirmation directly, without feeding it into STF state first through event listeners, because sidechain state could stall, then we're deadlocked

tracking of finalized sidechain block

STF event

execute_top_pool_trusted_calls_internal()

ProcessBlockImportQueue.process_queue()
fetch LatestSidechainBlockConfirmation
for all competitor blocks in queue for the next sidechain block
ensure is lineal descendant of LatestSidechainBlockConfirmation

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions