Skip to content
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

Bugfix: trimmed metadata hash comparison fails in is_codegen_valid_for #1306

Merged
merged 7 commits into from
Dec 6, 2023
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions metadata/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ mod utils;
use scale_info::{form::PortableForm, PortableRegistry, Variant};
use std::collections::HashMap;
use std::sync::Arc;
use utils::ordered_map::OrderedMap;
use utils::variant_index::VariantIndex;
use utils::{ordered_map::OrderedMap, validation::OuterEnumHashes};

type ArcStr = Arc<str>;

Expand Down Expand Up @@ -163,7 +163,7 @@ impl Metadata {
Some(crate::utils::validation::get_type_hash(
&self.types,
id,
&mut HashMap::new(),
&OuterEnumHashes::empty(),
))
}

Expand Down Expand Up @@ -324,7 +324,7 @@ impl<'a> PalletMetadata<'a> {

/// Return a hash for the entire pallet.
pub fn hash(&self) -> [u8; HASH_LEN] {
crate::utils::validation::get_pallet_hash(*self)
crate::utils::validation::get_pallet_hash(*self, &OuterEnumHashes::empty())
}
}

Expand Down Expand Up @@ -643,7 +643,7 @@ impl<'a> RuntimeApiMetadata<'a> {

/// Return a hash for the runtime API trait.
pub fn hash(&self) -> [u8; HASH_LEN] {
crate::utils::validation::get_runtime_trait_hash(*self)
crate::utils::validation::get_runtime_trait_hash(*self, &OuterEnumHashes::empty())
}
}

Expand Down Expand Up @@ -766,8 +766,7 @@ impl<'a> CustomValueMetadata<'a> {

/// Calculates the hash for the CustomValueMetadata.
pub fn hash(&self) -> [u8; HASH_LEN] {
let mut cache = HashMap::new();
get_custom_value_hash(self, &mut cache)
get_custom_value_hash(self, &OuterEnumHashes::empty())
}
}

Expand Down
Loading
Loading