-
Notifications
You must be signed in to change notification settings - Fork 137
universe/supplycommit: create new state machine responsible for maintaining the supply commitment for an asset #1464
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
universe/supplycommit: create new state machine responsible for maintaining the supply commitment for an asset #1464
Conversation
90b04f6
to
aaeddf4
Compare
Removed from draft for now. Have unit tests, and additional documentation to commit. |
8d5041c
to
648cb72
Compare
Pull Request Test Coverage Report for Build 15790016249Details
💛 - Coveralls |
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 reviewed this PR to see how I might copy its state‑machine architecture for the verification work.
I saw your note about still adding unit tests and doc comments, so I'm leaving these review comments with that in mind and hoping they're helpful.
go.mod
Outdated
|
||
replace github.com/lightningnetwork/lnd => github.com/roasbeef/lnd v0.2.1-alpha.0.20250505223159-b58451faad16 |
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.
Just a small reminder: this will need to be removed before merge. Maybe it can be removed now?
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 see that this is used for the state transition scaffolding. Is there an LND PR for this that I could help (review) get merged?
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.
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.
Can be bumped to lnd v0.19.1-beta.rc1
.
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 don't think these made it into the minor release, but they are in master.
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.
Looks great!
go.mod
Outdated
|
||
replace github.com/lightningnetwork/lnd => github.com/roasbeef/lnd v0.2.1-alpha.0.20250505223159-b58451faad16 |
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.
Can be bumped to lnd v0.19.1-beta.rc1
.
b65aade
to
a0cdbd9
Compare
FWIW this won't build due to the replace until we fix the tags in lnd. |
a0cdbd9
to
414823f
Compare
@Roasbeef, remember to re-request review from reviewers when ready |
6c86168
to
bab9a94
Compare
This patch fixes the lint and
|
@@ -0,0 +1,553 @@ | |||
package supplycommit |
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.
files in supplycommit
directory start with supply_commit_
. That prefix is probably redundant?
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.
+1
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.
Done!
bab9a94
to
83e4172
Compare
In this commit, we add an IsBurn bool to the Leaf struct. This is needed as we'll re-use this Leaf field for the burn proofs. However, for burns we always want to track the actual amt burned.
This version has updates to `protofsm` that we'll be using in the state machine.
This makes the generator more consistent and useful.
83e4172
to
b5acb6f
Compare
b5acb6f
to
035e250
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.
Very cool, really like the way the new state machine approach works with the different event types!
github.com/lightninglabs/neutrino/cache v1.1.2 | ||
github.com/lightninglabs/taproot-assets/taprpc v1.0.7 | ||
github.com/lightningnetwork/lnd v0.19.0-beta | ||
github.com/lightningnetwork/lnd v0.19.0-beta.rc5.0.20250611041824-9e9524766c8a |
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.
nit: can use v0.19.1-beta
now.
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.
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.
Ah, damn, I thought I added them. But then we have to move them to the 0.19.2 milestone to include them there, otherwise we'll have a problem in litd.
// Amt is the amount of units associated with the coin. | ||
Amt uint64 | ||
|
||
// IsBurn is a boolean that indicates whether the leaf represents a burn |
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.
Is the [temp]
commit message suffix still needed?
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 don't think so, but I consider this a sort of hack. Basically we need this to use the full value of the burnt amount instead of just 1
(as we do for transfers).
It think an alternative here is either to make a new wrapper struct, or modify this logic, but still only conditionally (we still insert just 1
for the multiverse transfer tree.
@@ -0,0 +1,553 @@ | |||
package supplycommit |
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.
+1
31a5fc6
to
03eb6b0
Compare
…achine In this commit, we add the initial set of states for the SupplyCommit state machine. This will be the primary state machine that'll be used to stage, then apply updates to the root supply tree as well as the sub supply trees associated with the root tree.
In this commit, we populate the environment that the state machine will use. This includes the set of fundamental interfaces (related to persistence and the new supply trees).
…state machine In this commit, we build on the two prior commits and add defined state transitions for the supply commit state machine. We start in a default state, until we hear about a new update. We'll continue in that state untli we get a commit tick, at which point we'll enter the main logic of the state machine. After a tick, we'll construct the final tree, make a commit transaction from that, sign it, then write everything to disk. We'll then resume by broadcasting the commit tx. Once we reecive a confirmation, we'll apply the state tranition which will update all the relevant state on disk.
These were from a much earlier draft, well before the current design of the commit state machine.
03eb6b0
to
70c7f3b
Compare
70c7f3b
to
82f4ee3
Compare
In this commit, we add a new sub-package to the
universe
package which adds a new state machine responsible for managing the supply commitment for a given grouped asset.A supply commitment is a special MS-SMT tree that tracks the total supply of a grouped asset. A supply can be modified by: minting new assets, doing an official burn of some assets, or adding some assets to the ignore proof cache.
To create a supply commitment (for an asset that opts into this), we'll spend the pre-commitment from all past minting batches that have been confirmed on chain. We'll then stage all the pending updates, to create new sub-trees (ignore, burn mint) for the grouped asset. With those trees created, we'll create the new root supply commitment.
With the root supply commitment created, we'll make a new transaction and commit to that using the non spendable script leaf that we use elsewhere to commit to asset IDs for a group key.
During this process, we'll continue to serve the old supply commitments. Only once the supply commitments have been confirmed on disk will we apply all the state transitions on disk. After we apply these state transitions, we'll start to serve the new commitments, and go back to our default state.
See the last commit's readme for more details.