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

Fork aware offchain Database #184

Closed Wizdave97 closed 4 months ago

Wizdave97 commented 4 months ago

This PR refactors the merkle mountain range overlay tree to a separate pallet that stores nodes in the offchain db in a fork-aware manner (indexing_prefix + pos + parent_hash => node). This avoids corrupting the tree whenever forks happen and the chain re-orgs. This didn't used to be an issue until async-backing was introduced.

This new pallet is paired with an offchain task that "canonicalizes" (indexing_prefix + pos => node) the mmr nodes in the offchaindb by removing the parent hash part of the key when finality notifications are observed. This subsystem has been integration tested with simnode.