Skip to content

Bugfix supply commit state machine #1655

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

Merged
merged 8 commits into from
Jul 21, 2025

Conversation

ffranr
Copy link
Contributor

@ffranr ffranr commented Jul 17, 2025

Work towards closing: #1534


Multiple small bug fixes for the supply commit state machine.

ffranr added 3 commits July 17, 2025 14:47
Allows deriving a supply commit TxOut without specifying all
RootCommitment fields.

We make RootCommitTxOut exportable so that we can use it in itests.
Refactor newRootCommitment to ensure the commit transaction is fully
defined before it is set as a field in RootCommitment.
Update the FetchUnspentPrecommits SQL query to retrieve the full
internal key descriptor for pre-commitment outputs. This enables BIP32
derivation when spending these outputs.
@ffranr ffranr requested review from Roasbeef and guggero July 17, 2025 13:55
@ffranr ffranr self-assigned this Jul 17, 2025
@ffranr ffranr added the supply commit Work on the supply commitment feature, enabling issuers to attest to total asset supply on-chain. label Jul 17, 2025
@coveralls
Copy link

coveralls commented Jul 17, 2025

Pull Request Test Coverage Report for Build 16369238272

Details

  • 87 of 139 (62.59%) changed or added relevant lines in 5 files are covered.
  • 18 unchanged lines in 8 files lost coverage.
  • Overall coverage increased (+0.3%) to 56.433%

Changes Missing Coverage Covered Lines Changed/Added Lines %
tapdb/supply_commit.go 8 10 80.0%
universe/supplycommit/env.go 18 22 81.82%
universe/supplycommit/transitions.go 52 98 53.06%
Files with Coverage Reduction New Missed Lines %
tapdb/supply_commit.go 1 69.81%
address/mock.go 2 97.39%
asset/group_key.go 2 72.15%
mssmt/compacted_tree.go 2 79.75%
universe/supplycommit/env.go 2 93.02%
universe/supplycommit/transitions.go 2 77.57%
tapchannel/aux_leaf_signer.go 3 43.43%
tapgarden/caretaker.go 4 76.93%
Totals Coverage Status
Change from base Build 16340821890: 0.3%
Covered Lines: 57717
Relevant Lines: 102275

💛 - Coveralls

Copy link
Member

@guggero guggero left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, LGTM 🎉

ffranr added 5 commits July 18, 2025 11:57
SignAndFinalizePsbt can't currently handle tapd family keys.
FetchSupplyCommit now returns the full key descriptor for the internal
key. RootCommitment struct now includes the full internal key descriptor
instead of just the public key.

This enables specifying BIP32 derivations when spending supply
commitment transactions during the creation of a new supply commitment
transaction. And also specifying BIP32 derivations in PSBT outputs, and
so on.
Add PSBT output with BIP32 derivation. This makes use of the full
internal key descriptor that we made available in the previous commit.
When creating a supply commitment transaction, there are two types of
inputs that can be spent:
* Pre-commitment outputs from mint anchor transactions
* Outputs from previous supply commitment transactions

This commit adds support for a PSBT input to handle the latter case,
allowing spending of a previous supply commitment transaction output.
Ensures the tree construction in the supplycommit package matches the
method used in tapdb when storing the tree in the database.
@ffranr ffranr force-pushed the wip/supplycommit/bugfix-state-machine branch from f2015fe to dd17a24 Compare July 18, 2025 11:18
Copy link
Member

@Roasbeef Roasbeef left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🌾

for _, preCommit := range unspentPreCommits {
newCommitTx.AddTxIn(preCommit.TxIn())

bip32Derivation, trBip32Derivation :=
tappsbt.Bip32DerivationFromKeyDesc(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style nit: odd line wrapping here.

// on mint transactions where as the old commitment is the last
// commitment that was broadcast.
//
// TODO(ffranr): Do we have everything we need to fund a PSBT here?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO maybe addressed in a follow up PR?

@@ -447,6 +447,21 @@ func newRootCommitment(ctx context.Context,
}
}

bip32Derivation, trBip32Derivation :=
tappsbt.Bip32DerivationFromKeyDesc(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here re line wrapping.

@Roasbeef Roasbeef merged commit f93cd77 into main Jul 21, 2025
18 checks passed
@github-project-automation github-project-automation bot moved this from 👀 In review to ✅ Done in Taproot-Assets Project Board Jul 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
supply commit Work on the supply commitment feature, enabling issuers to attest to total asset supply on-chain.
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

4 participants