worldcoin/signup-sequencer

Scan chain events instead of attempting to finalize each root

Dzejkop opened this issue · 0 comments

Currently the sequencer takes each and every root that has been mined on L1 and polls each supported L2 contract to figure out if the given root is either the latest root on that contract or it's present in root history.

With the new bridging setup we might have roots which are missing on L2 - but that shouldn't stop the sequencer from moving forward.

Breakdown:

  1. Scan events on L1 and L2 to monitor roots being added, we can use get_logs. Note that events will be different on L1 contracts and on L2 contracts
  2. Parse the logs and extract post roots
  3. Once a root has been found in the logs from all supported chains - proceed as previously, i.e. mark the root as finalized/mined and update the mined tree.
  4. Cleanup:
    The sequencer should keep track of the roots extracted from logs in step 2 (in memory). But once a given root is finalized on all the chains - roots which are older than this root should be removed from this in-memory storage.
    The sequencer has access to the list of all roots so if we finalize a root N+1, we can see that root N is older and can remove it from the list/mapping.

Some notes:

  1. It's not clear to me how we should determine the block from which to start scanning on each chain - grabbing the latest root at sequencer startup seems reasonable but it means we might miss some roots.