Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions cmd/commands/universe.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ func multiverseRoot(ctx *cli.Context) error {

multiverseRoot, err := client.MultiverseRoot(
ctxc, &unirpc.MultiverseRootRequest{
ProofType: *rpcProofType,
ProofType: *rpcProofType,
TreeVersion: universe.TreeVersion,
},
)
if err != nil {
Expand Down Expand Up @@ -225,6 +226,7 @@ func universeRoots(ctx *cli.Context) error {
WithAmountsById: !ctx.Bool(skipAmountsByIdName),
Offset: int32(ctx.Uint64(offsetName)),
Limit: int32(ctx.Uint64(limitName)),
TreeVersion: universe.TreeVersion,
},
)
if err != nil {
Expand All @@ -236,7 +238,8 @@ func universeRoots(ctx *cli.Context) error {
}

rootReq := &unirpc.AssetRootQuery{
Id: universeID,
Id: universeID,
TreeVersion: universe.TreeVersion,
}

universeRoot, err := client.QueryAssetRoots(ctxc, rootReq)
Expand Down Expand Up @@ -374,9 +377,10 @@ func universeKeys(ctx *cli.Context) error {
for {
tempKeys, err := client.AssetLeafKeys(
ctxc, &unirpc.AssetLeafKeysRequest{
Id: universeID,
Offset: int32(offset),
Limit: universe.RequestPageSize,
Id: universeID,
Offset: int32(offset),
Limit: universe.RequestPageSize,
TreeVersion: universe.TreeVersion,
},
)

Expand Down Expand Up @@ -442,9 +446,10 @@ func universeLeaves(ctx *cli.Context) error {
for {
page, err := client.AssetLeaves(
ctxc, &unirpc.AssetLeavesRequest{
Id: universeID,
Offset: int32(offset),
Limit: universe.RequestPageSize,
Id: universeID,
Offset: int32(offset),
Limit: universe.RequestPageSize,
TreeVersion: universe.TreeVersion,
},
)
if err != nil {
Expand Down
33 changes: 33 additions & 0 deletions docs/release-notes/release-notes-0.9.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,16 @@
transfer confirms without the proof being imported into the wallet or the
universe.

* [PR#2402](https://github.com/lightninglabs/taproot-assets/pull/2402)
`AssetKey` gains `asset_id` and `asset_id_str`, and leaf keys in
responses carry the asset ID. A query whose key omits the asset ID
matches any leaf at the outpoint and script key. `InfoResponse` and the
requests that compare universe trees gain a `tree_version` field. Proof
query and insert responses name the universe that holds the proof.
`DeleteAssetLeaf` resolves a grouped asset's ID universe to its group
universe, and refuses a key without an asset ID that matches several
leaves.

## tapcli Updates

## Config Changes
Expand Down Expand Up @@ -478,6 +488,20 @@
replaces `Insecure`, `SkipTlsVerify` and `TLSPathServer` with `TLS`,
and `tapcustody.Config` replaces `MboxInsecure` with `MboxTLS`.

* [Universe leaves are keyed by asset
ID](https://github.com/lightninglabs/taproot-assets/issues/2381).
Every issuance and transfer universe keys a leaf by its outpoint, script
key and asset ID, so grouped assets at one outpoint and script key have
separate leaves. A grouped asset's proofs are held only by its group
universe: an insert or query that names the asset's ID universe is
answered from the group universe. The universe server reports tree
version 1 in `Info` and refuses `AssetRoots`, `QueryAssetRoots`,
`AssetLeafKeys`, `AssetLeaves`, `MultiverseRoot` and `SyncDelta`
requests that don't set `tree_version` to 1. Nodes only sync with
universe servers that report tree version 1. Older nodes can still send
and receive proofs through a v0.9.0 proof courier, but can't sync with a
v0.9.0 universe server.

## Performance Improvements

## Deprecations
Expand All @@ -495,6 +519,15 @@

## Database

* [Migrations 74 and
75](https://github.com/lightninglabs/taproot-assets/issues/2381)
key universe leaves by asset ID. Migration 74 identifies a universe leaf
row by its namespace and tree key. Migration 75 rebuilds every issuance
and transfer universe tree with asset ID leaf keys, merges each grouped
asset's asset ID universe into its group universe, and rebuilds both
multiverse trees. It runs once at startup, and takes longer on large
universe servers.

* [PR#2287](https://github.com/lightninglabs/taproot-assets/pull/2287)
adds database migration 69, an opaque per-site match key and a
unique partial index on the anchoring registry. This lets subsystems recover
Expand Down
33 changes: 24 additions & 9 deletions itest/assertions.go
Original file line number Diff line number Diff line change
Expand Up @@ -1792,7 +1792,9 @@ func AssertUniverseRootEquality(t *testing.T,

ctx := context.Background()

rootRequest := &unirpc.AssetRootRequest{}
rootRequest := &unirpc.AssetRootRequest{
TreeVersion: universe.TreeVersion,
}
universeRootsAlice, err := clientA.AssetRoots(ctx, rootRequest)
require.NoError(t, err)
universeRootsBob, err := clientB.AssetRoots(ctx, rootRequest)
Expand All @@ -1817,7 +1819,9 @@ func AssertUniverseRootEqualityEventually(t *testing.T,
ctx := context.Background()

err := wait.NoError(func() error {
rootRequest := &unirpc.AssetRootRequest{}
rootRequest := &unirpc.AssetRootRequest{
TreeVersion: universe.TreeVersion,
}
universeRootsAlice, err := clientA.AssetRoots(ctx, rootRequest)
require.NoError(t, err)
universeRootsBob, err := clientB.AssetRoots(ctx, rootRequest)
Expand Down Expand Up @@ -1870,7 +1874,9 @@ func AssertUniverseRoot(t *testing.T, client unirpc.UniverseClient,

ctx := context.Background()

uniRoots, err := client.AssetRoots(ctx, &unirpc.AssetRootRequest{})
uniRoots, err := client.AssetRoots(ctx, &unirpc.AssetRootRequest{
TreeVersion: universe.TreeVersion,
})
require.NoError(t, err)

correctRoot := fn.Any(maps.Values(uniRoots.UniverseRoots), matchingRoot)
Expand Down Expand Up @@ -1951,13 +1957,19 @@ func AssertUniverseLeavesEqual(t *testing.T, uniIDs []*unirpc.ID,
for _, uniID := range uniIDs {
aLeaves, err := a.AssetLeaves(
context.Background(),
&unirpc.AssetLeavesRequest{Id: uniID},
&unirpc.AssetLeavesRequest{
Id: uniID,
TreeVersion: universe.TreeVersion,
},
)
require.NoError(t, err)

bLeaves, err := b.AssetLeaves(
context.Background(),
&unirpc.AssetLeavesRequest{Id: uniID},
&unirpc.AssetLeavesRequest{
Id: uniID,
TreeVersion: universe.TreeVersion,
},
)
require.NoError(t, err)

Expand All @@ -1984,15 +1996,17 @@ func AssertUniverseKeysEqual(t *testing.T, uniIDs []*unirpc.ID,
aUniKeys, err := a.AssetLeafKeys(
context.Background(),
&unirpc.AssetLeafKeysRequest{
Id: uniID,
Id: uniID,
TreeVersion: universe.TreeVersion,
},
)
require.NoError(t, err)

bUniKeys, err := b.AssetLeafKeys(
context.Background(),
&unirpc.AssetLeafKeysRequest{
Id: uniID,
Id: uniID,
TreeVersion: universe.TreeVersion,
},
)
require.NoError(t, err)
Expand Down Expand Up @@ -2739,8 +2753,9 @@ func assetRoots(ctx context.Context, uni unirpc.UniverseClient,
res, err := uni.AssetRoots(
ctx,
&unirpc.AssetRootRequest{
Offset: offset,
Limit: pageSize,
Offset: offset,
Limit: pageSize,
TreeVersion: universe.TreeVersion,
},
)
if err != nil {
Expand Down
13 changes: 10 additions & 3 deletions itest/collectible_split_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"github.com/lightninglabs/taproot-assets/taprpc"
"github.com/lightninglabs/taproot-assets/taprpc/mintrpc"
unirpc "github.com/lightninglabs/taproot-assets/taprpc/universerpc"
"github.com/lightninglabs/taproot-assets/universe"
"github.com/lightningnetwork/lnd/lntest/miner"
"github.com/lightningnetwork/lnd/lntest/wait"
"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -299,7 +300,9 @@ func testCollectibleGroupSend(t *harnessTest) {
// The universe tree should reflect the same properties about the batch;
// there should be one root with a group key and balance matching what
// we asserted previously.
uniRoots, err := t.tapd.AssetRoots(ctxb, &unirpc.AssetRootRequest{})
uniRoots, err := t.tapd.AssetRoots(ctxb, &unirpc.AssetRootRequest{
TreeVersion: universe.TreeVersion,
})
require.NoError(t.t, err)
require.Len(t.t, uniRoots.UniverseRoots, groupCount)

Expand All @@ -314,7 +317,10 @@ func testCollectibleGroupSend(t *harnessTest) {
ProofType: unirpc.ProofType_PROOF_TYPE_ISSUANCE,
}
uniLeaves, err := t.tapd.AssetLeaves(
ctxb, &unirpc.AssetLeavesRequest{Id: &collectUniID},
ctxb, &unirpc.AssetLeavesRequest{
Id: &collectUniID,
TreeVersion: universe.TreeVersion,
},
)
require.NoError(t.t, err)
require.Len(t.t, uniLeaves.Leaves, batchSize)
Expand All @@ -324,7 +330,8 @@ func testCollectibleGroupSend(t *harnessTest) {
mintOutpoint := collectibleAnchor.ChainAnchor.AnchorOutpoint
uniKeys, err := t.tapd.AssetLeafKeys(
ctxb, &unirpc.AssetLeafKeysRequest{
Id: &collectUniID,
Id: &collectUniID,
TreeVersion: universe.TreeVersion,
},
)
require.NoError(t.t, err)
Expand Down
35 changes: 33 additions & 2 deletions itest/custom_channels/compat_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,34 @@ func runWithCompatHarness(t *testing.T, scenario func(context.Context,
scenario(ctxt, net, ht)
}

// importIssuanceProof inserts the proofs of the given asset, as held by src,
// into the universe of dst.
func importIssuanceProof(t *testing.T, src, dst *itest.IntegratedNode,
a *taprpc.Asset) {

t.Helper()

ctx := context.Background()
proofFile, err := asTapd(src).ExportProof(
ctx, &taprpc.ExportProofRequest{
AssetId: a.AssetGenesis.AssetId,
ScriptKey: a.ScriptKey,
},
)
require.NoError(t, err)

resp, err := asTapd(dst).UnpackProofFile(
ctx, &taprpc.UnpackProofFileRequest{
RawProofFile: proofFile.RawProofFile,
},
)
require.NoError(t, err)

for _, rawProof := range resp.RawProofs {
itest.InsertProofIntoUniverse(t, asTapd(dst), rawProof)
}
}

// runBackwardsCompatLifecycle exercises the core lifecycle of an asset channel
// between a node running a pinned historical binary (Charlie) and a node
// running the current build (Dave). To cover both on-chain close paths
Expand Down Expand Up @@ -230,8 +258,11 @@ func runBackwardsCompatLifecycle(ctx context.Context,
cents := mintedAssets[0]
assetID := cents.AssetGenesis.AssetId

t.Logf("Minted %d cents, syncing universes...", cents.Amount)
syncUniverses(t.t, charlie, dave)
// The current build doesn't sync universes with an older one, so Dave
// imports the asset's issuance proof from Charlie instead.
t.Logf("Minted %d cents, importing its issuance proof...",
cents.Amount)
importIssuanceProof(t.t, charlie, dave, cents)

// ----------------------------------------------------------------
// Cycle 1: fund -> bidirectional payments -> cooperative close.
Expand Down
5 changes: 4 additions & 1 deletion itest/mint_batch_stress_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"github.com/lightninglabs/taproot-assets/taprpc"
"github.com/lightninglabs/taproot-assets/taprpc/mintrpc"
unirpc "github.com/lightninglabs/taproot-assets/taprpc/universerpc"
"github.com/lightninglabs/taproot-assets/universe"
"github.com/stretchr/testify/require"
)

Expand Down Expand Up @@ -180,7 +181,9 @@ func mintBatchStressTest(
// we asserted previously.
ctx := context.Background()
uniRoots, err := alice.AssetRoots(
ctx, &unirpc.AssetRootRequest{},
ctx, &unirpc.AssetRootRequest{
TreeVersion: universe.TreeVersion,
},
)
require.NoError(t, err)
require.Len(t, uniRoots.UniverseRoots, groupCount)
Expand Down
3 changes: 2 additions & 1 deletion itest/mint_fund_seal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,8 @@ func testMintFundSealAssets(t *harnessTest) {
require.NoError(t.t, err)
collectibleGroupLeaves, err := bobTapd.AssetLeaves(
ctx, &unirpc.AssetLeavesRequest{
Id: rpcCollectibleGroupUniID,
Id: rpcCollectibleGroupUniID,
TreeVersion: universe.TreeVersion,
},
)
require.NoError(t.t, err)
Expand Down
5 changes: 4 additions & 1 deletion itest/universe_federation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

"github.com/lightninglabs/taproot-assets/taprpc/mintrpc"
unirpc "github.com/lightninglabs/taproot-assets/taprpc/universerpc"
"github.com/lightninglabs/taproot-assets/universe"
"github.com/lightningnetwork/lnd/lntest/wait"
"github.com/stretchr/testify/require"
)
Expand Down Expand Up @@ -158,7 +159,9 @@ func testDeleteUniverseAfterFedSync(t *harnessTest) {

// Verify the root is gone.
roots, err := bob.AssetRoots(
ctx, &unirpc.AssetRootRequest{},
ctx, &unirpc.AssetRootRequest{
TreeVersion: universe.TreeVersion,
},
)
require.NoError(t.t, err)
require.Len(t.t, roots.UniverseRoots, 0)
Expand Down
18 changes: 11 additions & 7 deletions itest/universe_pagination_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/lightninglabs/taproot-assets/taprpc"
"github.com/lightninglabs/taproot-assets/taprpc/mintrpc"
unirpc "github.com/lightninglabs/taproot-assets/taprpc/universerpc"
"github.com/lightninglabs/taproot-assets/universe"
"github.com/stretchr/testify/require"
)

Expand Down Expand Up @@ -175,7 +176,8 @@ func mintBatchAssetsTest(
ctx := context.Background()
uniLeaves, err := alice.AssetLeaves(
ctx, &unirpc.AssetLeavesRequest{
Id: &collectUniID,
Id: &collectUniID,
TreeVersion: universe.TreeVersion,
},
)
require.NoError(t, err)
Expand Down Expand Up @@ -230,9 +232,10 @@ func fetchAllLeaves(client commands.RpcClientsBundle,
for {
resp, err := client.AssetLeaves(
context.Background(), &unirpc.AssetLeavesRequest{
Id: id,
Offset: offset,
Limit: testPageSize,
Id: id,
Offset: offset,
Limit: testPageSize,
TreeVersion: universe.TreeVersion,
},
)
if err != nil {
Expand All @@ -259,9 +262,10 @@ func fetchAllLeafKeys(alice commands.RpcClientsBundle,
for {
resp, err := alice.AssetLeafKeys(
context.Background(), &unirpc.AssetLeafKeysRequest{
Id: id,
Offset: offset,
Limit: testPageSize,
Id: id,
Offset: offset,
Limit: testPageSize,
TreeVersion: universe.TreeVersion,
},
)
if err != nil {
Expand Down
Loading
Loading