-
Notifications
You must be signed in to change notification settings - Fork 133
tapdb: add implementation of supplycommit.SupplyTreeView #1507
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
7c88480
to
522c3ee
Compare
8d5041c
to
648cb72
Compare
6e0b6a4
to
aa782c8
Compare
tapdb/burn_tree.go
Outdated
txErr := bt.db.ExecTx(ctx, &writeTx, func(db BaseUniverseStore) error { | ||
finalResults, err = insertBurnsInternal( | ||
ctx, db, spec, burnLeaves..., | ||
) | ||
|
||
// TODO(roasbeef): also update the root supply tree? | ||
return err |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suspect it probably would be best to update the supply tree root here also as the TODO suggests. Within the same db transaction. If not here then where?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this is done in the final PR of the series. We broke out these internal functions to add to each supply tree as the final PR uses these to update the root supply tree all at once. Just like we have methods to update an individual universe tree, but in practice we always update the multiverse trees afterwards.
The reason I isolated this logic to the state machine is to ensure that via that interface, the set of supply roots are always consistent.
648cb72
to
a0cdbd9
Compare
b5f3d5e
to
dd1d318
Compare
a0cdbd9
to
414823f
Compare
@Roasbeef, remember to re-request review from reviewers when ready |
dd1d318
to
87fefbc
Compare
414823f
to
6c86168
Compare
87fefbc
to
570e477
Compare
6c86168
to
bab9a94
Compare
faae3fc
to
3b3420a
Compare
035e250
to
31a5fc6
Compare
3b3420a
to
8fff268
Compare
31a5fc6
to
03eb6b0
Compare
8fff268
to
c668391
Compare
03eb6b0
to
70c7f3b
Compare
c668391
to
8b06b69
Compare
70c7f3b
to
82f4ee3
Compare
8b06b69
to
b8988d3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs a linter fix and perhaps a rebase. Otherwise looks good to me.
This patch fixes lint errors:
|
If helpful, I cleaned up the linter errors and rebased the branch here: https://github.com/ffranr/taproot-assets/tree/rebased-universe-supply-trees |
In this commit, we add new namespace routines for the supply tree. We'll use these to modify exactly which namespace we use for the ignore and burn trees. Rather than store using the old universe namespace, we choose to roll a new set of namespaces, as these trees are specific to a given group key.
…space directly In this commit, as a prep for the new universe supply tree routines, we refactor the InsertBurns method to rely on a new internal helper function. We also change the namespace we store things under to use the new supply tree namespaces. Finally, we fix a bug that would use different roots for the merkle tree proofs after insertion. We'll now ensure that the merkle tree proofs all use the same merkle root.
b8988d3
to
85109d9
Compare
…pace Similar to the last commit, in this commit, we refactor the AddTuples method to use a new helper function. We then start to use the new supply tree namespace just like we did for the burn tree.
…ce directly In this commit, we update the helper functions that the ignore and burn tree use to take the namespace directly instead of the universe.Identifier. This makes the functions more flexible, as they don't assume a namespace derivation.
In this commit, we break up the singular universeUpsertProofLeaf function into two: one for inserting into the universe tree, and one for taking the updated universe root to insert into the multi-verse tree.
In this commit, we add a new migration for the universe supply trees. Rather than use the multi-verse pointers (which are namespaced by proof type), we instead move to use a new set of smt tree pointers, that are scoped by the group key instead. We'll use these later to keep track of the new supply sub-trees, and also root supply tree. We also add a new proof type of mint_supply, to distinguish from the normal issuance type.
In this commit, we add a concrete implementation of SupplyTreeStore in tapdb. This is similar to the structs we used to manage the multiverse tree, which is scoped by proof type. Instead, the supply trees are scoped by group key. We can use this to stage a series of updates for a group key (mint, ignore, burn), and insert into a supply tree in a single atomic transaction. We also expose methods to fetch each sub supply tree as well.
In this commit, we add tests for the supply tree store. We use rapid to ensure that we can handle any combiniation of events when we go to update them in the tree.
85109d9
to
1ab7129
Compare
Merging as the unit test failure is unrelated:
|
In this commit, we add an implementation of the
supplycommitment.SupplyTreeView
interface to tapdb. This provides us with a concrete interface to be used along side #1464.The structure is similar to the existing multi-verse trees, but we instead of scoping by proof type (issuance or transfer), we instead scope by the group key of a given asset.
Along the way we do some refactors to allow us to do atomic inserts across all the sub-trees, and also the root tree.