Skip to content
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

Generalise QueryProof and InsertProof RPC endpoints to accept transfer proofs #456

Closed
wants to merge 4 commits into from
Closed
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
4 changes: 2 additions & 2 deletions cmd/tapcli/universe.go
Original file line number Diff line number Diff line change
Expand Up @@ -435,8 +435,8 @@ func universeProofInsert(ctx *cli.Context) error {
LeafKey: assetKey,
},
AssetLeaf: &universerpc.AssetLeaf{
Asset: rpcAsset,
IssuanceProof: rawProof,
Asset: rpcAsset,
RawProof: rawProof,
},
}
resp, err := client.InsertProof(ctxc, req)
Expand Down
4 changes: 2 additions & 2 deletions itest/assertions.go
Original file line number Diff line number Diff line change
Expand Up @@ -1008,8 +1008,8 @@ func assertUniverseLeavesEqual(t *testing.T, uniIDs []*unirpc.ID,
)

require.Equal(
t, aLeaves.Leaves[i].IssuanceProof,
bLeaves.Leaves[i].IssuanceProof,
t, aLeaves.Leaves[i].RawProof,
bLeaves.Leaves[i].RawProof,
)
}
}
Expand Down
22 changes: 11 additions & 11 deletions rpcserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -2575,8 +2575,8 @@ func marshalAssetLeaf(ctx context.Context, keys KeyLookup,
}

return &unirpc.AssetLeaf{
Asset: rpcAsset,
IssuanceProof: assetLeaf.GenesisProof[:],
Asset: rpcAsset,
RawProof: assetLeaf.GenesisProof[:],
}, nil
}

Expand Down Expand Up @@ -2775,11 +2775,11 @@ func (r *rpcServer) marshalIssuanceProof(ctx context.Context,
}, nil
}

// QueryProof attempts to query for an issuance proof for a given asset based
// on its UniverseKey. A UniverseKey is composed of the Universe ID
// QueryProof attempts to query for an issuance or transfer proof for a given
// asset based on its UniverseKey. A UniverseKey is composed of the Universe ID
// (asset_id/group_key) and also a leaf key (outpoint || script_key). If found,
// then the issuance proof is returned that includes an inclusion proof to the
// known Universe root, as well as a Taproot Asset state transition or issuance
// then the proof is returned that includes an inclusion proof to the known
// Universe root, as well as a Taproot Asset state transition or issuance
// proof for the said asset.
func (r *rpcServer) QueryProof(ctx context.Context,
req *unirpc.UniverseKey) (*unirpc.AssetProofResponse, error) {
Expand Down Expand Up @@ -2813,7 +2813,7 @@ func unmarshalAssetLeaf(leaf *unirpc.AssetLeaf) (*universe.MintingLeaf, error) {
// itself.
var assetProof proof.Proof
if err := assetProof.Decode(
bytes.NewReader(leaf.IssuanceProof),
bytes.NewReader(leaf.RawProof),
); err != nil {
return nil, err
}
Expand All @@ -2826,14 +2826,14 @@ func unmarshalAssetLeaf(leaf *unirpc.AssetLeaf) (*universe.MintingLeaf, error) {
Genesis: assetProof.Asset.Genesis,
GroupKey: assetProof.Asset.GroupKey,
},
GenesisProof: leaf.IssuanceProof,
GenesisProof: leaf.RawProof,
Amt: assetProof.Asset.Amount,
}, nil
}

// InsertProof attempts to insert a new issuance proof into the Universe tree
// specified by the UniverseKey. If valid, then the proof is inserted into the
// database, with a new Universe root returned for the updated
// InsertProof attempts to insert a new issuance or transfer proof into the
// Universe tree specified by the UniverseKey. If valid, then the proof is
// inserted into the database, with a new Universe root returned for the updated
// asset_id/group_key.
func (r *rpcServer) InsertProof(ctx context.Context,
req *unirpc.AssetProof) (*unirpc.AssetProofResponse, error) {
Expand Down
583 changes: 291 additions & 292 deletions taprpc/universerpc/universe.pb.go

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions taprpc/universerpc/universe.proto
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,9 @@ message AssetLeaf {

// TODO(roasbeef): only needed for display? can get from proof below ^

// The asset issuance proof, which proves that the asset specified above
// was issued properly.
bytes issuance_proof = 2;
// The raw proof which proves that the asset was issued or transferred
// correctly.
bytes raw_proof = 2;
}

message AssetLeafResponse {
Expand Down
4 changes: 2 additions & 2 deletions taprpc/universerpc/universe.swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -1293,10 +1293,10 @@
"$ref": "#/definitions/taprpcAsset",
"description": "The asset included in the leaf."
},
"issuance_proof": {
"raw_proof": {
"type": "string",
"format": "byte",
"description": "The asset issuance proof, which proves that the asset specified above\nwas issued properly."
"description": "The raw proof which proves that the asset was issued or transferred\ncorrectly."
}
}
},
Expand Down
8 changes: 0 additions & 8 deletions universe/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,14 +213,6 @@ func (a *MintingArchive) RegisterIssuance(ctx context.Context, id Identifier,
return nil, fmt.Errorf("asset id mismatch: expected %v, got %v",
id.AssetID, newAsset.ID())

// The outpoint of the final resting place of the asset should match
// the leaf key
//
// TODO(roasbeef): this restrict to issuance
case assetSnapshot.OutPoint != key.MintingOutpoint:
return nil, fmt.Errorf("outpoint mismatch: expected %v, got %v",
key.MintingOutpoint, assetSnapshot.OutPoint)

// The script key should also match exactly.
case !newAsset.ScriptKey.PubKey.IsEqual(key.ScriptKey.PubKey):
return nil, fmt.Errorf("script key mismatch: expected %v, "+
Expand Down