Skip to content

RPC: Add Ignore Tree Endpoints #1554

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 34 commits into
base: main
Choose a base branch
from

Conversation

ffranr
Copy link
Contributor

@ffranr ffranr commented May 21, 2025

Closes #1534


Sharing early to get early feedback on naming and architecture. Still missing itests and query RPC endpoint.

This PR will not include the verifier, I will add that in a separate PR.

This PR adds RPC endpoints to populate and query from ignore trees.

@ffranr ffranr requested a review from guggero May 21, 2025 15:02
@ffranr ffranr self-assigned this May 21, 2025
@ffranr ffranr changed the title RPC: add ignore tree RPC endpoints RPC: Add Ignore Tree Endpoints May 21, 2025
@coveralls
Copy link

coveralls commented May 21, 2025

Pull Request Test Coverage Report for Build 16072230475

Details

  • 180 of 923 (19.5%) changed or added relevant lines in 20 files are covered.
  • 24 unchanged lines in 10 files lost coverage.
  • Overall coverage decreased (-0.2%) to 39.039%

Changes Missing Coverage Covered Lines Changed/Added Lines %
tapdb/supply_commit.go 8 10 80.0%
log.go 0 4 0.0%
server.go 0 4 0.0%
universe/supplycommit/env.go 17 21 80.95%
universe/supplycommit/log.go 0 6 0.0%
wallet_anchor.go 0 12 0.0%
tapdb/asset_minting.go 70 85 82.35%
itest/utils.go 0 17 0.0%
asset/asset.go 0 24 0.0%
rpcutils/marshal.go 0 30 0.0%
Files with Coverage Reduction New Missed Lines %
tapdb/supply_commit.go 1 69.81%
asset/group_key.go 2 62.64%
rpcserver.go 2 0.0%
tapgarden/caretaker.go 2 68.0%
tappsbt/create.go 2 26.74%
universe/supplycommit/env.go 2 93.02%
universe/supplycommit/transitions.go 2 77.79%
tapchannel/aux_leaf_signer.go 3 43.43%
commitment/tap.go 4 71.59%
tapfreighter/interface.go 4 48.0%
Totals Coverage Status
Change from base Build 16059643780: -0.2%
Covered Lines: 30822
Relevant Lines: 78952

💛 - Coveralls

asset/asset.go Outdated
@@ -569,6 +606,10 @@ func (id PrevID) Hash() [sha256.Size]byte {
return *(*[sha256.Size]byte)(h.Sum(nil))
}

// OutPoint is a type alias for an asset outpoint. It links the anchor outpoint
// to the asset it secures.
type OutPoint = PrevID
Copy link
Member

Choose a reason for hiding this comment

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

PrevOut?

Copy link
Member

Choose a reason for hiding this comment

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

Or AnchorPoint (to be used as asset.AnchorPoint which reads nicely IMO) to not confuse it with a purely on-chain wire.OutPoint?

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.

Looks pretty good, did a quick first pass.

asset/asset.go Outdated
@@ -569,6 +606,10 @@ func (id PrevID) Hash() [sha256.Size]byte {
return *(*[sha256.Size]byte)(h.Sum(nil))
}

// OutPoint is a type alias for an asset outpoint. It links the anchor outpoint
// to the asset it secures.
type OutPoint = PrevID
Copy link
Member

Choose a reason for hiding this comment

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

Or AnchorPoint (to be used as asset.AnchorPoint which reads nicely IMO) to not confuse it with a purely on-chain wire.OutPoint?

@levmi levmi moved this from 🆕 New to 🏗 In progress in Taproot-Assets Project Board May 22, 2025
@ffranr ffranr force-pushed the wip/1534-ignore-tree/1534-add-ignoreasset-rpc branch from 661466c to 32da29f Compare May 27, 2025 22:00
@ffranr ffranr changed the base branch from main to supply-commit-machine May 27, 2025 22:01
@ffranr
Copy link
Contributor Author

ffranr commented May 27, 2025

I've rebased on to branch supply-commit-machine.

@ffranr ffranr force-pushed the wip/1534-ignore-tree/1534-add-ignoreasset-rpc branch from 32da29f to 6fbc382 Compare June 3, 2025 19:07
@Roasbeef Roasbeef force-pushed the supply-commit-machine branch 5 times, most recently from d7efd50 to c2c394f Compare June 12, 2025 01:35
@Roasbeef Roasbeef force-pushed the supply-commit-machine branch 11 times, most recently from 37bdcfa to b5a6c5e Compare June 25, 2025 00:27
@Roasbeef Roasbeef force-pushed the supply-commit-machine branch from b5a6c5e to c59b408 Compare June 25, 2025 02:00
@ffranr
Copy link
Contributor Author

ffranr commented Jul 2, 2025

Current status

Remaining work before we can merge this PR

  1. Merge chainntnfs: export NotifierOptions and internal field for interface use lightningnetwork/lnd#10028 and bump the LND dependency in tapd.
  2. DONE: Populate ErrorReporter in protofsm.StateMachineCfg (see TODO).
  3. DONE: Replace the InternalKey field in oldCommitment (within newRootCommitment) with the full KeyDescriptor so we can spend old commitments (we can already spend pre-commitments in this PR).

@ffranr ffranr force-pushed the wip/1534-ignore-tree/1534-add-ignoreasset-rpc branch 2 times, most recently from 71fcd9f to 4c23905 Compare July 3, 2025 21:41
ffranr added 9 commits July 3, 2025 22:48
Add `DeriveNextKey` method to `LndRpcWalletAnchor`, enabling it to
satisfy the `supplycommit.Wallet` interface.
Add context argument to `SupplyTreeView` interface methods to allow
`tapdb.SupplyTreeStore` to satisfy the interface.
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.
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.
Allows deriving a supply commit TxOut without specifying all
RootCommitment fields.
Refactor newRootCommitment to ensure the commit transaction is fully
defined before it is set as a field in RootCommitment.
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.
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.
@ffranr
Copy link
Contributor Author

ffranr commented Jul 3, 2025

I'm going to split this PR into smaller PRs. Here's the first: #1638

ffranr added 16 commits July 4, 2025 11:48
* Bump lnd to latest master commit.
* Point lnd/sqldb to same commit for local replace compatibility.
* Fix taprootassets.Server implementation to satisfy upgraded
htlcswitch.AuxTrafficShaper.

We bump LND here because the next commit requires access to
chainntnfs.DefaultNotifierOptions and similar functionality that is
currently private.
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.
Update the FetchUnspentPrecommits SQL query to retrieve the full
internal key descriptor for pre-commitment outputs. This enables BIP32
derivation when spending these outputs.
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.
Adds a method to generate a Schnorr signature over the TLV serialization
of an IgnoreTuple.
Introduce a new RPC endpoint to add an asset outpoint to the asset's
ignore tree. This allows asset issuers to explicitly exclude certain
asset outpoints.
Refactored handleEvents by extracting the handleSubEventChan function.
handleSubEventChan now accepts an event channel directly. The original
handleEvents function delegates to handleSubEventChan.
This introduces a new RPC endpoint, `SubscribeSupplyCommitEvents`,
allowing clients to stream event notifications from the supply
commitment state machine.

Subscribing to these events is beneficial for real-time monitoring,
testing, and debugging of the supply commitment process. For example, it
enables developers to trace the lifecycle of a commitment and diagnose
issues without relying solely on logs.
@ffranr ffranr force-pushed the wip/1534-ignore-tree/1534-add-ignoreasset-rpc branch from 4c23905 to 0ed7096 Compare July 4, 2025 10:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 🏗 In progress
Development

Successfully merging this pull request may close these issues.

Add IgnoreAsset RPC endpoint
5 participants