Skip to content

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

Open
wants to merge 12 commits into
base: asset-commitment-creator
Choose a base branch
from

Conversation

Roasbeef
Copy link
Member

@Roasbeef Roasbeef commented May 3, 2025

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.

@levmi levmi moved this from 🆕 New to 🏗 In progress in Taproot-Assets Project Board May 5, 2025
@Roasbeef Roasbeef force-pushed the universe-supply-trees branch from 7c88480 to 522c3ee Compare May 5, 2025 22:46
@Roasbeef Roasbeef force-pushed the asset-commitment-creator branch 2 times, most recently from 8d5041c to 648cb72 Compare May 5, 2025 23:02
@Roasbeef Roasbeef force-pushed the universe-supply-trees branch 2 times, most recently from d786104 to af5f8f5 Compare May 5, 2025 23:15
Roasbeef added 9 commits May 5, 2025 16:46
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.
…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.
@Roasbeef Roasbeef force-pushed the universe-supply-trees branch from af5f8f5 to 64516c9 Compare May 5, 2025 23:54
Roasbeef added 2 commits May 5, 2025 16:59
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.
@Roasbeef Roasbeef force-pushed the universe-supply-trees branch from 64516c9 to 6e0b6a4 Compare May 6, 2025 01:19
@Roasbeef Roasbeef force-pushed the universe-supply-trees branch from 6e0b6a4 to aa782c8 Compare May 6, 2025 01:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: 🏗 In progress
Development

Successfully merging this pull request may close these issues.

1 participant