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
Implement CheckMetadataHash
extension
#4274
base: master
Are you sure you want to change the base?
Conversation
Basically combines all the recommended calls into one `build_using_defaults()` call or `init_with_defaults()` when there are some custom changes required.
…o bkchr-metadata-hash
None => Err(UnknownTransaction::CannotLookup.into()), | ||
}, | ||
// Unknown `mode`, let's reject it. | ||
_ => Err(UnknownTransaction::CannotLookup.into()), |
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 it not use an enum for mode, so that it already fails to decode an invalid mode?
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.
Ha! smart idea :D
0 => Ok(EncodeNoneToEmpty(None)), | ||
1 => match option_env!("RUNTIME_METADATA_HASH") { | ||
Some(hash) => Ok(EncodeNoneToEmpty(Some(array_bytes::hex2array_unchecked(hash)))), | ||
None => Err(UnknownTransaction::CannotLookup.into()), |
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.
Not sure if this error variant help so much with debugging... alternatively there is only Other(_)
, which is not so nice either.
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.
Yeah, maybe something in general that we could fix with a better "system" for error reporting in this case. Just returning strings is also not such a great idea.
substrate/frame/support/procedural/src/pallet/expand/constants.rs
Outdated
Show resolved
Hide resolved
|
||
/// Extract the `SS58` from the constants in the given `metadata`. | ||
fn extract_ss58_prefix(metadata: &RuntimeMetadata) -> u16 { | ||
let RuntimeMetadata::V15(ref metadata) = metadata else { |
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.
OT: what do you use for Runtime API debugging?
I have been using some CLI like this, but nothing proper: https://github.com/ggwpez/frame-runtime-api
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.
Debugging for what? I mean what did you debug? Just that the return value is correct?
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.
Yea just calling runtime APIs and inspecting the return values.
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.
Never really needed to debug them, so I did not require anything like that so far 🙈
The CI pipeline was cancelled due to failure one of the required jobs. |
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
(probably waiting for audit i guess)
@bkchr will this be backported to earlier releases of the polkadot-sdk and if so, which ones? |
I think at least back to 1.7.0 for use in polkadot-fellows/runtimes#288 |
Thanks, thats great! |
We probably even go back until 1.1. Need to check how complicated that will get. |
Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
This implements the
CheckMetadataHash
extension as described in RFC78.Besides the signed extension, the
substrate-wasm-builder
is extended to support generating the metadata-hash.Closes: #291