nervosnetwork / ckb-light-client

CKB light client reference implementation
MIT License
14 stars 16 forks source link

fix: long fork could NOT be detected in full sampling turn #128

Closed yangby-cryptape closed 1 year ago

yangby-cryptape commented 1 year ago

Update the process when long fork detected.

  - Turn 1: verify a proof for incremental blocks on a fork chain.
    - Get a forked last state from a CKB node.
    - All checks for the proof are correct.
    - Compare the reorg blocks from forked last state proof and last N blocks in storage.
    - If no ancestor blocks was found, send a request to ask proof for the whole forked chain.
  - Turn 2: do full sampling on the whole chain.
    - All checks for the proof are correct.
-   - Compare the reorg blocks from forked last state proof and last N blocks in storage.
-   - If no ancestor blocks was found, panic.
+   - Panic.

If the a chain has the flag and it is valid, just panic! All other checks are redundant.

Ref: #125