-
Notifications
You must be signed in to change notification settings - Fork 132
proof: add decimal display as TLV field to meta reveal #998
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
Conversation
4a52a60
to
3636c9c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 💃🏾
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good overall! Def cleaner than what we had before.
Added comments + I think we want to add this field to the AssetMeta
proto as well + pipe it through there? If it's actually going to be a TLV field.
taproot-assets/taprpc/taprootassets.proto
Line 163 in 5236dea
message AssetMeta { |
rpcserver.go
Outdated
@@ -552,15 +552,13 @@ func (r *rpcServer) MintAsset(ctx context.Context, | |||
// If a custom decimal display was requested, add that to the | |||
// metadata and re-validate it. | |||
if metaType == proof.MetaJson && req.Asset.DecimalDisplay != 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this condition now needs to change and not require the metaType
to be JSON?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point! Fixed this and a couple of other occurrences of similar checks.
Also, I don't see the utility of adding this field as JSON in the metadata any more? IIRC the actual user request was 'it shows up in RPC responses', and if its also discoverable from decoding proofs then it seems redundant. AFAICT we never read it after setting it. |
Good point, we can just leave it out there. |
Technically it's part of the the metal reveal, which contains the raw asset meta, and now these additional bytes. I guess it's useful though to have it there if people want to use |
Just realized it's now also input for |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Discussed offline, and concluded that this approach was a bit too slick to be true:
- Old clients won't know of this meta reveal field.
- They'll parse the meta reveal w/o the new field, then go to check against the meta hash.
- That fails as they didn't include the portion they didn't know about.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So the purpose here was to drop this field to the MetaReveal
level in order to support dec display for custom meta data?
Type: MetaJson, | ||
Data: []byte(`{"key": "value"}`), | ||
DecimalDisplay: 8, | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could also check against Opaque data type and also with 0 dec display
Ah, yes, nice catch. Adding a summary of my comments made offline here for reference: I see two possibilities for something we could do now:
I guess doing the two-level TLV encoding would qualify as "carveout/placeholder for future fields" as described in the issue #997. it just feels very hacky if we need to describe it in the BIP as "two levels of TLV encoding, depending on a feature bit"... but happy to go ahead and implement it, if we think it's the way to go |
3636c9c
to
03b0b0c
Compare
With this commit we add the decimal display as a new TLV field on the meta reveal. We'll still encode it within the JSON meta data if the meta data is of type JSON. For all other types we can now also carry the value, to make sure we don't put any type constraints on future asset mints (in case issuers want to use a different format than JSON). Since we're using TLV, old meta reveals should still be read correctly and the default value of 0 is assumed for any meta reveal that doesn't have the explicit record set. We'll add a unit test for that in the next commit.
03b0b0c
to
4f32e71
Compare
Okay, the current approach doesn't work and any quick hacks are too hacky. I'll implement the proper carve out to be able to do this properly in the next major version in an upcoming PR. |
Minimal implementation that fixes #956.
Also fixes #997.