[CHECKLIST] Smart Anchor Updates v2 #359
Labels
difficulty: challenging 🏴☠️
feature ➕
Tasks that are functional additions or enhancements
optimization ⚙️
Tasks that are refactor, optimize, or are considered chores.
p1 🟠
Issue should be resolved sooner than later
Overview
The purpose of this document is to outline the features and intended functionality that will ship smart anchor updates on the relayer.
We have implemented the Smart Anchor Updates before in this PR Smart Anchor Updates (Experimental) #53 but, that implementation was not that all good, nor tested.
Smart Anchors Updates aims to save up gas and transactions to update Anchor’s state.
To understand how the smart anchor updates should be implemented, you first needs to understand how is the current system works.
Example
Alice deposits on chain
A
and sets the destination chainB
. There are 8 chains interconnected in this example: {A, B, C, D, E, F, G, H}. The relayer(s) notice that the state of the anchor on chainA
has changed because a new leaf has been added to the Merkle tree, and a new root has been calculated. We need to update the other chains with this new root. For each chain connected to chainA
, we create a proposal calledAnchorUpdate
. This proposal is sent to a signing system (which could be a DKG system, multisig system, or a mocked signing system). When this proposal is signed, we callexecuteProposalWithSignature
on the Signature Bridge contract. That contract verifies and updates the anchor's neighbor root of chainA
, meaning we will do(N - 1)
updates.Each Relayer will try to send these transactions, but the blockchain will only accept one and reject the others. This can result in a loss of tokens due to the gas paid. However, before sending the transaction, the relayer will check if another relayer has updated the target anchor already. If this is the case, the relayer will cancel the transaction from their queue.
The biggest problem is that we shouldn't rush to update or send our signed proposals. Instead, we should wait and watch for the situation to change, and only send it if nobody else has done so.
Perviously, the implementation was like the following:
smart_anchor_updates
feature is enabled.leaf_index
is greater than thedest_chain.leaf_index
we sleep in a random interval between 10s to 60s first and then we retry again step 3.Features
To improve the implementation of Smart Anchor Updates, we propose the following changes:
By waiting and observing the state, we can avoid sending duplicate proposals and reduce the amount of gas used for updates. This will result in significant cost savings for the Relayer(s) and improve the efficiency of the Smart Anchor Updates feature.
In addition, we suggest implementing the following features to further improve the efficiency of Smart Anchor Updates:
By implementing these additional features, we can further optimize Smart Anchor Updates and improve the overall efficiency of the Relayer system.
Checklist
There are two parts/milestones for this TASK:
The first part is mostly SPEC'ed out, the second part should be implemented after finishing the first part.
The text was updated successfully, but these errors were encountered: