-
Notifications
You must be signed in to change notification settings - Fork 46
Open
Labels
Description
The parentchain finalizes sidechain blocks (see integritee-network/integritee-node#115) and so when importing a parentchain block, we can determine which sidechain block branch (in case of a fork) is the valid one.
Implement the mechanism that upon parentchain block import checks which sidechain block were finalized. In case we detected a fork, we need to resolve the fork:
Case: We are on the correct branch
- No roll-back needed
- Discard sidechain blocks that were cached from the other branches (if any)
- Mark transactions from the finalized blocks as 'Finalized'
Case: We are on an invalid forked branch
- Roll-back state to last common finalized sidechain block
- Import sidechain blocks from the 'fork' cache that were finalized in the parentchain block
- Collect all transactions from the now invalid sidechain blocks and either:
- Discard them, i.e. delete from the TOP pool
- Change their state back to 'Ready' from 'InBlock'
- Remove now invalidated sidechain blocks from the sidechain block storage