Skip to content

supplycommit: add MultiStateMachineManager for managing group state machines #1643

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 13 commits into from
Jul 17, 2025

Conversation

ffranr
Copy link
Contributor

@ffranr ffranr commented Jul 9, 2025

Part of the work towards completing #1534

These commits are split out from #1554


This PR introduces the MultiStateMachineManager, a service that manages supply commitment state machines for multiple asset groups. Each state machine is scoped to a specific asset group. The MultiStateMachineManager caches and orchestrates these group-specific machines, providing a unified interface for the RPC server to start, query, and stop them.


This change is Reviewable

@ffranr ffranr self-assigned this Jul 9, 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 9, 2025
@ffranr
Copy link
Contributor Author

ffranr commented Jul 9, 2025

@guggero have i defined LndFsmDaemonAdapters.RegisterConfirmationsNtfn reasonably here? I think the linter will complain.

@ffranr ffranr requested review from Roasbeef and guggero July 9, 2025 16:08
@coveralls
Copy link

coveralls commented Jul 9, 2025

Pull Request Test Coverage Report for Build 16339924797

Details

  • 119 of 420 (28.33%) changed or added relevant lines in 7 files are covered.
  • 82 unchanged lines in 19 files lost coverage.
  • Overall coverage decreased (-0.1%) to 56.458%

Changes Missing Coverage Covered Lines Changed/Added Lines %
universe/supplycommit/transitions.go 12 13 92.31%
universe/supplycommit/log.go 3 6 50.0%
tapcfg/server.go 28 32 87.5%
server.go 4 16 25.0%
lnd_services.go 31 109 28.44%
universe/supplycommit/multi_sm_manager.go 37 240 15.42%
Files with Coverage Reduction New Missed Lines %
commitment/tap.go 1 85.0%
universe/supplycommit/transitions.go 1 81.55%
rfqmsg/records.go 2 70.25%
tapchannel/aux_leaf_signer.go 2 43.08%
tapdb/mssmt.go 2 91.36%
tapdb/sqlc/assets.sql.go 2 74.29%
tapdb/sqlc/mssmt.sql.go 2 55.63%
tapdb/sqlc/transfers.sql.go 2 82.87%
tapdb/sqlc/universe.sql.go 2 75.88%
tapgarden/planter.go 2 80.2%
Totals Coverage Status
Change from base Build 16322700537: -0.1%
Covered Lines: 57692
Relevant Lines: 102185

💛 - Coveralls

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.

Straight forward diff!

No major comments, nicely done.

@ffranr ffranr force-pushed the wip/supplycommit/add-multi-sm-manager branch 2 times, most recently from 1cf0088 to d538aec Compare July 10, 2025 13:04
@ffranr ffranr requested a review from Roasbeef July 10, 2025 13:05
@levmi levmi moved this from 🆕 New to 👀 In review in Taproot-Assets Project Board Jul 10, 2025
@levmi levmi added the P0 label Jul 10, 2025
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.

Very clean! Got a couple of suggestions, nothing too involved I think.

@ffranr ffranr force-pushed the wip/supplycommit/add-multi-sm-manager branch from d538aec to 8d1dd7e Compare July 14, 2025 14:10
@ffranr ffranr requested a review from guggero July 14, 2025 14:11
@ffranr ffranr force-pushed the wip/supplycommit/add-multi-sm-manager branch 2 times, most recently from 0433cc0 to 09a1823 Compare July 14, 2025 15:43
@ffranr ffranr requested review from guggero and removed request for guggero July 14, 2025 15:50
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.

Very nice, LGTM 🎉

@Roasbeef Roasbeef requested a review from guggero July 16, 2025 23:59
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 🚝

Reviewed 15 of 15 files at r1, 12 of 12 files at r2, all commit messages.
Reviewable status: all files reviewed, 13 unresolved discussions (waiting on @ffranr and @guggero)

@Roasbeef
Copy link
Member

Can land after a rebase!

ffranr added 4 commits July 17, 2025 09:13
This change separates the keyring interface from the wallet interface,
allowing integration with an existing keyring service instead of
extending the wallet service.

We also use DeriveNextTaprootAssetKey as a simplification.
Add context argument to `SupplyTreeView` interface methods to allow
`tapdb.SupplyTreeStore` to satisfy the interface.
ffranr and others added 9 commits July 17, 2025 09:13
Introduces `DefaultCommitConfTarget`, a constant for the default
confirmation target (in blocks) for a supply commitment transaction.

This constant provides a sensible default for fee estimation, ensuring
that the commitment transaction is confirmed in a timely manner without
overpaying. Centralizing this value makes it easier to manage and adjust
in the future.

If we don't set `CommitConfTarget` field in state machine env to a
reasonable value fee estimation will fail.
The state machine that curates a supply commit transaction is specific
to an asset group key. To manage multiple such state machines across
asset groups at the RPC layer, introduce the MultiStateMachineManager.

The manager caches separate state machines for each asset group.
Populate the SupplyCommitManager field in the config so that the
rpcserver can invoke methods on the supply commitment manager.
This allows derivation of PSBT BIP32 paths for a keychain.KeyDescriptor
using network-specific parameters.

The new field is unread in this commit but will be used later.
Introduce LndFsmDaemonAdapters, a struct implementing the
protofsm.DaemonAdapters interface. This is passed into
supplycommit.NewMultiStateMachineManager, which then propagates it to
each asset group-specific state machine.
chain_bridge.go now contains multiple Lightning clients: invoices,
transport, and router. The new name lnd_services.go reflects this richer
scope and improves discoverability.
In this commit, we add logic to resend trigger events for select states.
Along the way, we modify the way the state machine works: we can avoid
having to extract the PSBT again, just by reading it from the state
transition.
@ffranr ffranr force-pushed the wip/supplycommit/add-multi-sm-manager branch from 09a1823 to a3cbff2 Compare July 17, 2025 08:17
@ffranr ffranr enabled auto-merge July 17, 2025 08:18
@ffranr ffranr added this pull request to the merge queue Jul 17, 2025
Merged via the queue into main with commit c4bb5bc Jul 17, 2025
18 checks passed
@github-project-automation github-project-automation bot moved this from 👀 In review to ✅ Done in Taproot-Assets Project Board Jul 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P0 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.

5 participants