Decode protobuf-encoded claim values and return them in JSONRPC responses #206
Labels
No labels
area: devops
area: discovery
area: docs
area: livestream
area: proposal
consider soon
Epic
good first issue
hacktoberfest
hard fork
help wanted
icebox
Invalid
level: 0
level: 1
level: 2
level: 3
level: 4
needs: exploration
needs: grooming
needs: priority
needs: repro
needs: tech design
on hold
priority: blocker
priority: high
priority: low
priority: medium
resilience
soft fork
Tom's Wishlist
type: bug
type: discussion
type: improvement
type: new feature
type: refactor
type: task
type: testing
unplanned
work in progress
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: LBRYCommunity/lbrycrd#206
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
RPC commands such as
getclaimbyid
return the value of a claim. For most claims, this value is a protobuf-encoded bytestring that was created using the types in https://github.com/lbryio/types. Such values should be decoded and returned as JSON in a newvalue_decoded
field.The protobuf definitions for c++ are here: https://github.com/lbryio/types/tree/master/cpp
Acceptance Criteria
Definition of Done
Hi! I'd like to tackle this issue. Should the new value_decoded field be returned in the UniValue claim object?
Yes, the new values should be returned in the existing UniValue result. You can safely add fields; try not to modify the other fields already coming out.
Hello there,
Has any pull request been made on this issue? I'd like to give it a try!
I have seen no PRs for this yet.
Ok, I think I may have a solution in mind.
Just a question: whenever commands like getclaimid are called, there is a string that represents a value of the concerned claim. Isn't what I need to do with this number basically convert the represented number in an integer?
This issue is somewhat more complicated than numerical conversion. The claim values are passed in as binary data (hex-encoded). The binary data is output from a protobuf serializer. You won't be able to deserialize that data without the necessary protobuf definitions. The protobuf definitions are defined in an alternate project (mentioned in the first post here). Lbrycrd does have an existing reference to protobuf, so you should be able to use that directly once the types are also referenced. At present lbrycrd has no other lbryio dependencies.
And in thinking about it, I actually think this story would be better implemented as a python script. The script would run the current export command (like the import scripts), process that data some more using the already-existing python metadata defs, and output the results. The script could even pull the metadata definition in from the web when it runs; it wouldn't need a downloaded dependency.
Hi, just to inform that I'm working on this. Still trying to understand some things.
@BrannonKing can you explain how this would work as a python script? when i call
getclaimbyid
, wouldlbrycrd-cli
call the python script somehow?I was picturing a python script that would call lbrycrd-cli (like this script: https://github.com/lbryio/lbrycrd/blob/add_claim_import_scripts/contrib/devtools/import_claims_from_claimsintrie_output.py). It would load that data (with
json.loads
, etc.). It would then pull down the current type definitions from lbryio/types. For each item in the data it would run the metadata through the protobuf parser, specifying the right protobuf def as it went. It would modify the JSON and reoutput it.why is this better than doing the decoding in lbrycrd? it seems like i'd basically always want the json output instead of the protobuf-serialized bytes.
@BrannonKing agreed on historical aspect of (3) but not convinced this is right long-term.
@BrannonKing Can you tell me where to get/how to produce claims for testing. I'm now in phase of testing my python script. I'm using -regtest to produce block. However, the blocks are currently empty.
@vancam-pham , I apologize for never replying to your query last October. That was an oversight.
I'm closing this as rejected. It's out of scope for the foreseeable future. It is easily done in Python3 utilizing the SDK: