Conversation
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
This reverts commit db542dc.
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
| CARGO_TERM_COLOR: always | ||
| # TODO: Currently pointing at latest substrate; is there a suitable binary we can pin to here? | ||
| SUBSTRATE_URL: https://releases.parity.io/substrate/x86_64-debian:stretch/latest/substrate/substrate | ||
| SUBSTRATE_URL: https://releases.parity.io/substrate/x86_64-debian:bullseye/latest/substrate/substrate |
There was a problem hiding this comment.
Next time it'd prolly be good to get the CI fixes in a separate PR too so we can merge them more easily, but I think this will be able to merge shortly anyway hopefully now :)
| }) | ||
| .collect::<Result<Vec<_>, CodegenError>>()?; | ||
|
|
||
| let outer_event_variants = self.metadata.pallets().filter_map(|p| { |
There was a problem hiding this comment.
Wooo, even more red than last time :D
metadata/src/from_into/v14.rs
Outdated
| let instances = ",Instance".repeat(error_ty.type_params.len() - 1); | ||
| let path = format!("{}<Runtime{}>", error_ty.path, instances); |
There was a problem hiding this comment.
This looks super hacky, and I think it's just to populate the "type_name" thing? My question is; do we actually need this? Would anything break if we set type_name to be eg {PalletName}Error?
There was a problem hiding this comment.
I believe we could use the PalletError name here, have removed it :D
There was a problem hiding this comment.
It seems to work indeed, I have manually modified the test-runtime to convert v15 -> metadata -> v14 -> prefixed bytes; to have access in our testing to the converted version.
I was mainly looking for this test to pass, since it uses as_root_error:
Changes to build.rs (with runtime-api tests disabled -- since we lose that info when going from v15 to v14):
let metadata = RuntimeMetadataPrefixed::decode(&mut &metadata_bytes[..])
.expect("Cannot decode frame-metadata bytes");
let v15 = match metadata.1 {
RuntimeMetadata::V15(v15) => v15,
_ => panic!("Unexpected metadata version"),
};
let metadata: Metadata = v15.try_into().expect("Cannot convert v15 to metadata");
let metadata: RuntimeMetadataV14 = metadata.try_into().expect("Cannot convert v15 to metadata");
let metadata: RuntimeMetadataPrefixed = metadata.into();
let metadata_bytes = metadata.encode();There was a problem hiding this comment.
Have let the tests run with this custom patch that uses v15 converted to v14 converted back to v15 metadata, all good
There was a problem hiding this comment.
Ok awesome! Yeah, I had a look and type_name isn't really relevant; it's just for "disgnostic" info: https://github.com/paritytech/scale-info/blob/cc97f4c6496acf0f92d9caa45856331f094a7f38/src/ty/fields.rs#L55
The name of the field is the enum variant and the thing that decoding/encoding cares about :)
| } | ||
|
|
||
| #[cfg(test)] | ||
| mod tests { |
There was a problem hiding this comment.
Like the tests; converting to v14 and back to v15 again and checking that things line up still is a good way to check :)
metadata/src/utils/validation.rs
Outdated
| .expect("Metadata should contain enum type in registry"); | ||
|
|
||
| if let TypeDef::Variant(variant) = &ty.ty.type_def { | ||
| get_type_def_variant_hash(registry, variant, only_these_variants, visited_ids) |
There was a problem hiding this comment.
I'm pondering the use of visited_ids a bit now; eg is it right to pass the same visited_ids set into the call for each enum? What's the effect of doing so versus not doing so.
Doing so means that hashing things that share types might be faster; any type that's been seen will hash to some fixed "recursive" hash. The downside though is that the individual hashes become "weaker"; a bunch of more primitive types all are assigned the "recursive" hash when hashing the second and third enum. This makes them all effectively interchangeable; we'll no longer catch changes to them.
The point of visited_ids is only to prevent infinite loops, but given the above, let's pass an empty visited_ids set into each new top level call; so here get_enum_hash could create an empty Set each time for instance so that the types are entirely independently hashed.
metadata/src/utils/validation.rs
Outdated
| @@ -481,8 +557,19 @@ impl<'a> MetadataHasher<'a> { | |||
|
|
|||
| let extrinsic_hash = get_extrinsic_hash(&metadata.types, &metadata.extrinsic); | |||
| let runtime_hash = get_type_hash(&metadata.types, metadata.runtime_ty(), &mut visited_ids); | |||
There was a problem hiding this comment.
The visited_ids passed in here is only used in this one place anyway, which is good (see prev comment). Let's just pass in an &mut HashSet::new() to this function to ensure that we don't use it in some other place in the future and be consistent on "pass new visited_ids into each new top level hashing call".
There was a problem hiding this comment.
(looking around this file more I think we should re-think the visited_ids thing a bit or at least check that we're not overly using the same one; something I've probably done in other places too. I think ultimately we will want get_type_hash to not take in visited_ids and instead construct it internally and then an internal version of get_type_hash can accept it for the recursive calls to it. Basically, each unique type that we hash should have start from a fresh set of visited IDs. I'll open an issue to do this more thoroughly)
There was a problem hiding this comment.
Opened #1066 to generally fix/prevent misuse of visited_type_ids
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Co-authored-by: James Wilson <james@jsdw.me>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
|
This looks awesome, nice work! Two minor comments left for me:
I wouldn't worry too much about the |
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
This PR makes use of metadata V15, marking the stabilization of the metadata in Subxt.
(import "env" "memory" (memory 1 1))contracts: switch fromparity-wasm-based towasmi-based module validation substrate#14449Testing