Open
Description
Is your feature request related to a problem? Please describe.
Once #1450 is completed, we have everything we need to implement the state machine that drives the canonical universe commitments.
Describe the solution you'd like
A new state machine should be created that lives in the Universe package. The state machine will be responsible for the following reconciliation loop:
- Persistently maintaining a log of future updates to the canonical universe commitments.
- We maintain a log, as we only want to serve a consistent root.
- Any pending changes will exist in the log (a new DB table) until either we've reached our batch threshold, or enough time has passed.
- The events that trigger the addition of a new entry into the log are: issuance, burning, ignore invalid proofs.
- Once enough items are in the log, we should examine the
mint_anchor_uni_commitments
table to find the last unspent pre-commitment output(s) that belong to the target asset group.- Along the way, we'll want to either create a new associative table, or add a new
spent_by REFERENCES(chain_txn)
field to the table.- This can help us easily find all the pre-commitments that haven't been spent yet.
- For the associative table, be able to look up the leaves that were part of a prior commitment on-chain, along with the leaf.
- Along the way, we'll want to either create a new associative table, or add a new
- After we've found the set of pre-commitment output to spend, we should construct the new universe anchor transaction:
- This should spend all the unspent pre-commitment outputs, and also the last universe commitment.
- We'll need another table/log to track a snapshot of the current on-chain commitment for a given asset group.
- This should spend all the unspent pre-commitment outputs, and also the last universe commitment.
- Once the transaction has been constructed, it should be signed, checkpointed in our log, then broadcast.
- Upon restart, we should re-broadcast any unconfirmed commitment transactions.
Finally, we should add a series of RPCs to query what the current state is.