Skip to content

Error decoding type on AH Westend #2021

Description

@jsdw

From #2006:

@jsdw looking into this. Yes, from branch master it works well and solves the initial issue raised here.

However it comes with some side effects when decoding extrinsics -- at least on the one i'm currently tracking. I'm keen to open a different issue, but wanted to leave it here in case you have some nice solution/workaround. An example below to be easily reproducible:

#![allow(missing_docs)]
use subxt::{OnlineClient, PolkadotConfig};

#[subxt::subxt(runtime_metadata_path = "../artifacts/westend_metadata.scale")]
pub mod node_runtime {}

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Create a client that subscribes to blocks of the Polkadot network.
    let api = OnlineClient::<PolkadotConfig>::from_url("wss://westend-rpc.polkadot.io").await?;

    let mut blocks_sub = api.blocks().subscribe_finalized().await?;

    while let Some(block) = blocks_sub.next().await {
        let block = block?;
        let block_number = block.header().number;
        let block_hash = block.hash();
        println!("Block #{block_number}  ({block_hash}):");

        let extrinsics = block.extrinsics().await?;
        for extrinsic in extrinsics.find::<node_runtime::para_inherent::calls::types::Enter>() {
            let extrinsic = extrinsic?;

            for availability_bitfield in extrinsic.value.data.bitfields.iter() {
                println!(
                    "    validator_index: {:?}",
                    availability_bitfield.validator_index
                );
            }
        }
    }

    Ok(())
}

Response:

Block #26413894  (0x3443…9e92):
Error: Decode(Error { context: Context { path: [Location { inner: Index(0) }, Location { inner: Field("bitfields") }, Location { inner: Field("data") }] }, kind: CannotFindField { name: "__ignore" } })

Originally posted by @paulormart in #2006

This looks like some mismatch between the expected shape of the type and the actual shape. Need to look into what it is!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions