polytope-labs / hyperbridge

Hyperbridge is a hyperscalable coprocessor for verifiable, cross-chain interoperability
https://docs.hyperbridge.network/
Apache License 2.0
104 stars 33 forks source link

Prevent pruning potentially unfinalized mmr nodes #191

Closed Wizdave97 closed 4 months ago

Wizdave97 commented 4 months ago

We could have fork blocks that have the same child trie root if they were built from the same sequence of transactions. In some cases the stale branch is pruned before the finalized branch which causes the nodes to be deleted before they can be moved to canonical storage.

This PR prevents pruning a node if we cannot find it in the canonical storage yet.

An example from live tests : Nodes with 0x70a62bc49d50f915d6cb98f48f25119859de95fe6b03ff78998449ff8af9a2 child trie root were pruned earlier:
image

The same nodes with the same child trie root from a different block could not be canonicalized later on: image