Description
Is your feature request related to a problem? Please describe.
This is related to #1451 and #1452.
With those two issues complete, we have the state machine that'll commit the new asset commitment into the chain. We'll then also have a new RPC layer to serve the new supply related trees, and also is meant to have a new on-chain merkle proof associated with each served leaf.
The final missing component is the on-chain verifier state machine.
Describe the solution you'd like
The on-chain verifier state machine keeps track of the set of synced grouped assets that will maintain a universe commitment on chain.
For each of those assets, it first needs to "sync" the on-chain portion of the commitment chain. This amounts to looking at the first issuance event, locating the pre-commitment output, then following that pre-commitment output all the way to the currently unspent commitment output.
Along the way, we may need to implement support for serving old roots to allow the verifier to check that the commitments have been created properly.
Once the final unspent commitment output is reached, then we've finishing sync mode and can now await for a future spend.
A rough state machine that can implement this looks something like:
stateDiagram-v2
direction LR
[*] --> init
init --> sync: initial issuance
sync --> sync: commit spend
sync --> idle: sync finished
idle --> sync: commit spend
The general idea is that in the sync phase you await the spend of a pre-commitment (initial sync), or the commitment. You validate one step, then register for a spend. Once that spend is triggered you validate the next step. You terminate once the output you're validating remains unspent.