4

I have a live network working on Substrate V3 and MetadataV12. How can I migrate to the MetadataV14?

The MetadataV14 is a part of the Substrate V4. Unfortunately Substrate V4 isn't released.

1
  • Any of the polkadot-v0.*.* substrate branches represent production quality substrate releases. You can use github.com/bkchr/diener tool to point to a particular version of substrate.
    – Squirrel
    Commented Feb 10, 2022 at 14:12

1 Answer 1

5

To migrate your chain to the V14 metadata system, follow these steps (from this upgrade guide):

  1. Remove any #[pallet::metadata(..)] attributes from your pallet's Event definition.
  2. Add scale-info as a dependency to your pallet and runtime crates:
  • scale-info = { version = "1.0.0", default-features = false, features = ["derive"] }
  • std = [ "scale-info/std" ]
  1. Derive scale_info::TypeInfo for any types which derive Decode, Encode(*). For example:
#[derive(Encode, Decode, Clone, PartialEq, Eq, RuntimeDebug, TypeInfo)]
struct HeartbeatStatus<BlockNumber> {
    pub session_index: SessionIndex,
    pub sent_at: BlockNumber,
}
  1. Update any pallet Call variant constructors to use named structs (previously unnamed tuple structs).
  2. Update the metadata runtime API call:
impl sp_api::Metadata<Block> for Runtime {
    fn metadata() -> OpaqueMetadata {
        OpaqueMetadata::new(Runtime::metadata().into())
    }
}

(*) If the type is in a separate crate to the pallet, add the scale-info dependency as above.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.