Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sidechain Fork Mitigation (Epic) #685

Open
murerfel opened this issue Mar 22, 2022 · 1 comment
Open

Sidechain Fork Mitigation (Epic) #685

murerfel opened this issue Mar 22, 2022 · 1 comment
Assignees
Labels

Comments

@murerfel
Copy link
Contributor

murerfel commented Mar 22, 2022

This epic emerged from #345 - summarizes the results of those discussions and anchors all the tasks created from it.

Specification

Fork detection

  • Each validateer should detect forks, even within a parentchain block cycle
  • Parentchain block determines finalized sidechain blocks and thus the branch that is valid
    • Needs to be checked at each parentchain block import
  • When a fork is detected, a validateer remains on its current branch until finalization by the parentchain
    • This is the 'laziest' approach, minimizes effort (e.g. a 'random' scheme could mean to roll-back and switch branch, but still be wrong in the end)
    • Alternatives: Random choice of branch, stop production, choose the longest branch

Finality

  • Parentchain finalizes sidechain blocks
  • Extrinsic must be extended to include the sidechain block header, not just the block hash
    • Header contains hash of block payload and hash of parent block
  • Parentchain determines order of sidechain block
    • Simple queue, builds order of sidechain blocks - eagerly where possible
    • Queue size in the order of #sidechain blocks per parentchain block ~40
  • Logic must be built into the pallet
    • Execution of logic should be O(1) whenever possible
    • Optimize for 'write' or mutation

Roll-back

  • Store snapshot of state after each block
    • Need some bookkeeping to easily map a block hash to a snapshot
    • Apply specific snapshot on roll-back
  • Transactions are marked 'InBlock' and only removed once finalized
    • For roll-back, see how Substrate does it: Either move 'InBlock' transactions back to 'Ready' or remove entirely from pool
@murerfel
Copy link
Contributor Author

Also linked to #855 for sidechain finality

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant