tangle-network / relayer

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

feat: Proposals Queue #515

Closed shekohex closed 1 year ago

shekohex commented 1 year ago

Summary of changes

  1. The trait BridgeWatcher was updated to use the QueueStore trait for both transaction::eip2718::TypedTransaction and BridgeCommand.
  2. The ProposalStore trait was removed from the trait bounds.
  3. Import statements for ProposalStore were removed, and import statements for QueueStore were added.
  4. The requirement for the store type to implement ProposalStore was removed, and the requirement to implement QueueStore was added.
  5. The ProposalStore import was removed from webb_relayer_store, and the QueueStore import was added.
  6. A module for the proposal queue was added, along with two types of proposal signing backends.
  7. The signature of the handle_proposal function was updated to accept a generic ProposalSigningBackend type parameter.
  8. Tracing instrumentation was added to the handle_proposal and evm_anchor_update_proposal functions.
  9. Debug logging was added when creating an anchor update proposal.
  10. An in-memory implementation of the proposals queue was added, along with methods for enqueueing, dequeuing, finding, and modifying proposals in the queue.
  11. A ProposalPolicy trait was added, defining a policy applied to proposals in a queue.
  12. Two modules, nonce and time, were added to implement the ProposalPolicy trait.
  13. Implementations of the ProposalPolicy trait were added for tuples of up to 5 elements and Option types.
  14. Several new fields and structs were added to various modules and configurations.
  15. Some dependencies were updated and the workspace configuration for certain dependencies was changed.

Reference issue to close (if applicable)


Code Checklist

shekohex commented 1 year ago

This PR is ready for review, However, DO NOT MERGE IT YET, as I'm working on a Simulation to show the improvements using the Smart Anchor Updates.

shekohex commented 1 year ago

I wrote a simulation that does N deposits across X chains, and ran it with Smart Anchor Updates Disabled and then Enabled.

After Running the Simulation using yarn sim we see this result:

N = 50 # Number of deposits
X = 7 # Number of chains

Simulation Metrics for 7 chains

For 50 deposits: Smart Anchor Updates Total TXs avg. TXs Total Gas Used (ETH) avg. Gas Used (ETH) Total Wait Time To Relay All Roots (ms)
Disabled 298 43 2.3089 0.3299 190886
Enabled 6 1 0.0976 0.01395 95068

Diff (across all chains):

Some Notes:

  1. avg. TXs means the avg number of updates/tx we sent for each chain.
  2. avg. Gas Used means the gas spent on one chain (totalGasUsed / X)