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 4 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
13 changes: 4 additions & 9 deletions metadata/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,7 @@ impl Metadata {
/// Get type hash for a type in the registry
pub fn type_hash(&self, id: u32) -> Option<[u8; HASH_LEN]> {
self.types.resolve(id)?;
Some(crate::utils::validation::get_type_hash(
&self.types,
id,
&mut HashMap::new(),
))
Some(crate::utils::validation::get_type_hash(&self.types, id))
}

/// Ensure that every unique type we'll be generating or referring to also has a
Expand Down Expand Up @@ -324,7 +320,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, &HashMap::new())
}
}

Expand Down Expand Up @@ -643,7 +639,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, &HashMap::new())
}
}

Expand Down Expand Up @@ -766,8 +762,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, &HashMap::new())
}
}

Expand Down
Loading
Loading