-
Notifications
You must be signed in to change notification settings - Fork 137
Add proof type to universe identifer #540
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
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
001d789
universe: add universe proof type enum
ffranr 942d074
universe: include `ProofType` in the universe identifier
ffranr f7e3306
rpc: add ProofType to RPC universe ID
ffranr 0a560db
rpc: add marshal/unmarshal functions for ProofType RPC type
ffranr 31e37c5
asset: add method Asset.IsGenesisAsset
ffranr 88094ab
rpc+universe: set unspecified universe ID proof type from asset proof
ffranr 4b02687
rpc+universe: ensure inserted proof type matches universe proof type
ffranr a44f987
universe: add unit tests for ValidateProofUniverseType
ffranr 789fa5a
universe: check issuance and transfer universes for previous proof
ffranr b1a5353
universe: validate proof type when batch inserting proof leaves
ffranr b18f473
tapdb: add proof type to universe_roots table and queries
ffranr 8c260be
universe+tapdb: set universe ID proof type when querying via RootNodes
ffranr d57856d
tapdb: set default universe ID proof type when generating rand uni ID
ffranr ec8a51f
rpc: add issuance uni and transfer uni roots to QueryAssetRoots
ffranr b9935e5
universe-diff: RootNode selectively unmarshals QueryAssetRoots response
ffranr 841fc5e
itest: add basic RPC form sanity check in AssertUniverseRootEqual
ffranr 69ce70d
rpcserver: DeleteAssetRoot takes account of universe proof type
ffranr b2d27d6
itest: account for new uni ID proof type field when syncing
ffranr 911e2b1
fixup! universe+tapdb: set universe ID proof type when querying via R…
ffranr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,11 +11,13 @@ import ( | |
| "github.com/btcsuite/btcd/btcec/v2" | ||
| "github.com/btcsuite/btcd/btcec/v2/schnorr" | ||
| tap "github.com/lightninglabs/taproot-assets" | ||
| "github.com/lightninglabs/taproot-assets/asset" | ||
| "github.com/lightninglabs/taproot-assets/fn" | ||
| "github.com/lightninglabs/taproot-assets/mssmt" | ||
| "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/wait" | ||
| "github.com/stretchr/testify/require" | ||
| "golang.org/x/exp/maps" | ||
|
|
@@ -110,7 +112,12 @@ func testUniverseSync(t *harnessTest) { | |
| } | ||
| }() | ||
|
|
||
| srcRoot, ok := universeRoots.UniverseRoots[uniKey] | ||
| // Construct universe namespace. | ||
| proofType, err := tap.UnmarshalUniProofType(newRoot.Id.ProofType) | ||
| require.NoError(t.t, err) | ||
| uniNamespace := fmt.Sprintf("%s-%s", proofType, uniKey) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, still thinking about if we want to also manifest the prefix on this level, which arguably could/should just be something internal. I think will get a better feel of how it all looks on the CLI. |
||
|
|
||
| srcRoot, ok := universeRoots.UniverseRoots[uniNamespace] | ||
| require.True(t.t, ok) | ||
| require.True(t.t, AssertUniverseRootEqual(srcRoot, newRoot)) | ||
| } | ||
|
|
@@ -130,8 +137,7 @@ func testUniverseSync(t *harnessTest) { | |
| uniRoots := maps.Values(universeRoots.UniverseRoots) | ||
| uniIDs := fn.Map(uniRoots, func(root *unirpc.UniverseRoot) *unirpc.ID { | ||
| return root.Id | ||
| }, | ||
| ) | ||
| }) | ||
| AssertUniverseKeysEqual(t.t, uniIDs, t.tapd, bob) | ||
| AssertUniverseLeavesEqual(t.t, uniIDs, t.tapd, bob) | ||
|
|
||
|
|
@@ -211,6 +217,7 @@ func testUniverseSync(t *harnessTest) { | |
| Id: &unirpc.ID_AssetId{ | ||
| AssetId: firstAssetID, | ||
| }, | ||
| ProofType: unirpc.ProofType_PROOF_TYPE_ISSUANCE, | ||
| }, | ||
| }) | ||
| require.NoError(t.t, err) | ||
|
|
@@ -282,21 +289,29 @@ func testUniverseREST(t *harnessTest) { | |
|
|
||
| // Simple assets are keyed by their asset ID. | ||
| for _, simpleAsset := range rpcSimpleAssets { | ||
| assetID := hex.EncodeToString(simpleAsset.AssetGenesis.AssetId) | ||
| require.Contains(t.t, roots.UniverseRoots, assetID) | ||
| // Ensure that the universe root set contains issuance roots for | ||
| // all of our assets. | ||
| var assetID asset.ID | ||
| copy(assetID[:], simpleAsset.AssetGenesis.AssetId) | ||
| uniID := universe.Identifier{ | ||
| AssetID: assetID, | ||
| ProofType: universe.ProofTypeIssuance, | ||
| } | ||
| uniIDStr := uniID.String() | ||
| require.Contains(t.t, roots.UniverseRoots, uniIDStr) | ||
|
|
||
| require.Equal( | ||
| t.t, simpleAsset.AssetGenesis.Name, | ||
| roots.UniverseRoots[assetID].AssetName, | ||
| roots.UniverseRoots[uniIDStr].AssetName, | ||
| ) | ||
|
|
||
| // Query the specific root to make sure we get the same result. | ||
| assetRoot, err := getJSON[*unirpc.QueryRootResponse]( | ||
| assetRoots, err := getJSON[*unirpc.QueryRootResponse]( | ||
| fmt.Sprintf("%s/roots/asset-id/%s", urlPrefix, assetID), | ||
| ) | ||
| require.NoError(t.t, err) | ||
| require.True(t.t, AssertUniverseRootEqual( | ||
| roots.UniverseRoots[assetID], assetRoot.AssetRoot, | ||
| roots.UniverseRoots[uniIDStr], assetRoots.IssuanceRoot, | ||
| )) | ||
| } | ||
|
|
||
|
|
@@ -309,7 +324,12 @@ func testUniverseREST(t *harnessTest) { | |
| groupKey := issuableAsset.AssetGroup.TweakedGroupKey | ||
| groupKeyHash := sha256.Sum256(groupKey[1:]) | ||
| groupKeyID := hex.EncodeToString(groupKeyHash[:]) | ||
| require.Contains(t.t, roots.UniverseRoots, groupKeyID) | ||
|
|
||
| // Construct universe namespace using the group key ID. | ||
| namespace := fmt.Sprintf( | ||
| "%s-%s", universe.ProofTypeIssuance, groupKeyID, | ||
| ) | ||
| require.Contains(t.t, roots.UniverseRoots, namespace) | ||
|
|
||
| // Query the specific root to make sure we get the same result. | ||
| // Rather than use the hash above, the API exposes the | ||
|
|
@@ -321,9 +341,10 @@ func testUniverseREST(t *harnessTest) { | |
| assetRoot, err := getJSON[*unirpc.QueryRootResponse](queryURI) | ||
| require.NoError(t.t, err) | ||
|
|
||
| uniRoot, foundRoot := roots.UniverseRoots[namespace] | ||
| require.True(t.t, foundRoot) | ||
| require.True(t.t, AssertUniverseRootEqual( | ||
| roots.UniverseRoots[groupKeyID], | ||
| assetRoot.AssetRoot, | ||
| uniRoot, assetRoot.IssuanceRoot, | ||
| )) | ||
| } | ||
| } | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.