tangle-network / relayer

🕸️ The Webb Relayer Network
https://webb-tools.github.io/relayer/
Apache License 2.0
22 stars 13 forks source link

[TASK] Implement validation over leaf caching for substrate chains #490

Open salman01zp opened 1 year ago

salman01zp commented 1 year ago

Use a local Merkle tree instance in the relayer to validate the leaves against the Merkle root on the chain. You can use the Merkle tree found in: https://github.com/webb-tools/zero-knowledge-gadgets/blob/master/arkworks/native-gadgets/src/merkle_tree.rs.

Each time we add a leaf, it should be imperative to check the state of our local tree against the state on-chain. If it matches, we can proceed. If it doesn't match we need to:

Clear our cache Start over (fetch all the events using the fast sync for events) Rebuild the tree Validate and continue until we get this right.

Evm implementation for reference: https://github.com/webb-tools/relayer/pull/354

shekohex commented 1 year ago

Decreased the priority as this feature is not actually need right now, but it is good to have in the future.