-
Notifications
You must be signed in to change notification settings - Fork 248
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
Runtime call fails with IncompatibleCodegen error code when filtering pallets in generated code #1659
Comments
I dug into this, and the type that has an incompatible hash is the thing returned from the runtime API call ( In the validation logic we have this One possible fix for this issue is to extend the validation logic so that we can always pass an optional list of the pallets we actually want to compare, and then pass this through to places. However, I'm not sure if this is a valid fix or not. It's ok if the user passes some types (eg arguments to a runtime call) that are stripped down, because they will still be compatible with the full types. But what do we do if we get handed back a full type from the node, and only have a stripped down type to put it into (like what would be the case here with the Possibly, we need to change the metadata stripping to:
An alternative to all of this is to acknowledge that trying to strip metadata adds a ton of complexity, and just to remove the ability to strip metadata in the first place, avoiding all of these issues and simplifying the codebase a bunch. For reference, the metadata SCALE files I used: metadata-small.scale.txt I modified the repro to this to highlight the issue (assuming subxt is checked out in an adjacent folder and checked out to c3267ed; current head on master): use subxt_metadata::Metadata;
use parity_scale_codec::Decode;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let files = [
(172, "full", "./metadata.scale"),
(165, "small", "./metadata-small.scale"),
];
for (type_id, name, file) in files {
println!("###################################");
println!("Metadata: {name}");
println!("###################################\n");
let md = std::fs::read(file).expect("cannot read metadata");
let md = Metadata::decode(&mut &*md).expect("cannot decode metadata");
let outer_enum_hashes = subxt_metadata::OuterEnumHashes::empty();
let hash = subxt_metadata::get_type_hash(md.types(), type_id, &outer_enum_hashes);
println!("\n{}\n", hex::encode(hash));
}
Ok(())
} [package]
name = "subxt-repro"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
hex = "0.4.3"
parity-scale-codec = "3.6.12"
subxt-metadata = "0.37.0"
[patch.crates-io]
subxt-metadata = { path = "../subxt/metadata" } |
Here is the repro walk through:
cd templates/minimal && cargo build
./target/debug/minimal-template-node --dev
The example should work if you generate the metadata with
subxt metadata --url ws://localhost:9944 -o metadata.scale
It will fail with
Error: Metadata(IncompatibleCodegen)
when the code is generated with
subxt metadata --pallets "Balances,Timestamp,Contracts,ContractsEvm,System" --url ws://localhost:9944 -o metadata.scale
The text was updated successfully, but these errors were encountered: