fix: ensure extrinsic types are collected before pallet types (#110)

This commit is contained in:
Carlo Sala
2025-12-09 12:14:00 +01:00
committed by GitHub
parent fb487bc85d
commit 560f2cae43
2 changed files with 11 additions and 3 deletions
+6 -2
View File
@@ -73,8 +73,10 @@ impl RuntimeMetadataV15 {
custom: CustomMetadata,
) -> Self {
let mut registry = Registry::new();
let pallets = registry.map_into_portable(pallets);
// extrinsic types need to be collected first to ensure CheckMetadataHash hash
// is stable across different metadata versions
let extrinsic = extrinsic.into_portable(&mut registry);
let pallets = registry.map_into_portable(pallets);
let ty = registry.register_type(&runtime_type);
let apis = registry.map_into_portable(apis);
let outer_enums = outer_enums.into_portable(&mut registry);
@@ -206,13 +208,15 @@ impl IntoPortable for ExtrinsicMetadata {
type Output = ExtrinsicMetadata<PortableForm>;
fn into_portable(self, registry: &mut Registry) -> Self::Output {
// the collection order needs to be stable across different metadata versions
// to ensure CheckMetadataHash hash is invariant
ExtrinsicMetadata {
version: self.version,
address_ty: registry.register_type(&self.address_ty),
call_ty: registry.register_type(&self.call_ty),
signature_ty: registry.register_type(&self.signature_ty),
extra_ty: registry.register_type(&self.extra_ty),
signed_extensions: registry.map_into_portable(self.signed_extensions),
extra_ty: registry.register_type(&self.extra_ty),
}
}
}
+5 -1
View File
@@ -72,8 +72,10 @@ impl RuntimeMetadataV16 {
custom: CustomMetadata,
) -> Self {
let mut registry = Registry::new();
let pallets = registry.map_into_portable(pallets);
// extrinsic types need to be collected first to ensure CheckMetadataHash hash
// is stable across different metadata versions
let extrinsic = extrinsic.into_portable(&mut registry);
let pallets = registry.map_into_portable(pallets);
let apis = registry.map_into_portable(apis);
let outer_enums = outer_enums.into_portable(&mut registry);
let custom = custom.into_portable(&mut registry);
@@ -191,6 +193,8 @@ impl IntoPortable for ExtrinsicMetadata {
type Output = ExtrinsicMetadata<PortableForm>;
fn into_portable(self, registry: &mut Registry) -> Self::Output {
// the collection order needs to be stable across different metadata versions
// to ensure CheckMetadataHash hash is invariant
ExtrinsicMetadata {
versions: self.versions,
address_ty: registry.register_type(&self.address_ty),