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

* Don't hash constant values; only their types

* Fix a test

* cargo fmt
This commit is contained in:
James Wilson authored and GitHub committed 2022-06-27 17:02:16 +02:00
1 parent f97b8963f5
commit a90697ca29
2 files changed
+7 -12

No files matched your search

+2 -5
View File
@@ -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)
}
@@ -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),