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

Don't hash constant values; only their types #587

Merged
merged 3 commits into from
Jun 27, 2022
Merged
Changes from 1 commit
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
7 changes: 2 additions & 5 deletions metadata/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -302,10 +302,8 @@ pub fn get_constant_hash(
.find(|c| c.name == constant_name)
.ok_or(NotFound::Item)?;

let mut bytes = get_type_hash(&metadata.types, constant.ty.id(), &mut HashSet::new());
bytes = xor(bytes, hash(constant.name.as_bytes()));
bytes = xor(bytes, hash(&constant.value));

// We only need to check that the type of the constant asked for matches.
let bytes = get_type_hash(&metadata.types, constant.ty.id(), &mut HashSet::new());
Ok(bytes)
}

Expand Down Expand Up @@ -363,7 +361,6 @@ pub fn get_pallet_hash(
}
for constant in pallet.constants.iter() {
bytes = xor(bytes, hash(constant.name.as_bytes()));
bytes = xor(bytes, hash(&constant.value));
bytes = xor(
bytes,
get_type_hash(registry, constant.ty.id(), &mut visited_ids),
Expand Down