-
Notifications
You must be signed in to change notification settings - Fork 69
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
Metadata_metadata doesn't return the SCALE-encoded metadata but the SCALE-encoded SCALE-encoded metadata #538
Comments
Yes that is intended. The node side should not interpret the metadata and thus, we return SCALE encode the metadata before returning it. The runtime api itself encodes the data again to being able to decode it on the node side. |
But what you're describing is a Substrate-specific problem, which is that Substrate can't make a runtime call without decoding the output. |
This initially substrate-specific behavior is part of the spec and mirrored in other implementations as well, so I think it is here to stay. So if I understood this correctly, the current definition is correct under the assumption of a Runtime API call convention. |
@FlorianFranzen However IMO this should be explicited, as it's very subtle. As a naive reader, my assumption is that "return the SCALE-encoded metadata" means the same SCALE encoding as what section C.3 mentions, and is just repeated as a convenience. This is IMO especially important because |
Also, there are several other functions in the spec, such as BabeApi_submit_report_equivocation_unsigned_extrinsic or BabeApi_generate_key_ownership_proof, where the text says "A SCALE encoded Option ...", even though the function simply returns an |
Yeah good point, I'm okay with changing that. |
This concerns section C.5.
The title is a bit weird, but when the
Metadata_metadata
runtime entry point is called, Substrate encodes the metadata, producing aVec<u8>
, then encodes thatVec<u8>
again, producing a differentVec<u8>
.In practice, what this means is that
Metadata_metadata
returns the SCALE-compact-encoded length of the SCALE-encoded metadata, followed with the SCALE-encoded metadata itself.Note that the JSON-RPC function that returns the metadata correctly returns only the SCALE-encoded metadata. In other words it strips the length.
I would actually suggest to see if this should not be considered a Substrate bug before tweaking the spec.
The text was updated successfully, but these errors were encountered: