mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-11 16:31:07 +00:00
frame-system: uniques remove one encode call (#14154)
* frame-system: `uniques` remove one `encode` call * ".git/.scripts/commands/fmt/fmt.sh" --------- Co-authored-by: command-bot <>
This commit is contained in:
@@ -1618,21 +1618,21 @@ impl<T: Config> Pallet<T> {
|
||||
.ok_or(Error::<T>::FailedToExtractRuntimeVersion)?;
|
||||
|
||||
cfg_if::cfg_if! {
|
||||
if #[cfg(all(feature = "runtime-benchmarks", not(test)))] {
|
||||
if #[cfg(all(feature = "runtime-benchmarks", not(test)))] {
|
||||
// Let's ensure the compiler doesn't optimize our fetching of the runtime version away.
|
||||
core::hint::black_box((new_version, current_version));
|
||||
Ok(())
|
||||
} else {
|
||||
if new_version.spec_name != current_version.spec_name {
|
||||
return Err(Error::<T>::InvalidSpecName.into())
|
||||
}
|
||||
} else {
|
||||
if new_version.spec_name != current_version.spec_name {
|
||||
return Err(Error::<T>::InvalidSpecName.into())
|
||||
}
|
||||
|
||||
if new_version.spec_version <= current_version.spec_version {
|
||||
return Err(Error::<T>::SpecVersionNeedsToIncrease.into())
|
||||
}
|
||||
if new_version.spec_version <= current_version.spec_version {
|
||||
return Err(Error::<T>::SpecVersionNeedsToIncrease.into())
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1643,7 +1643,7 @@ pub fn unique(entropy: impl Encode) -> [u8; 32] {
|
||||
let mut last = [0u8; 32];
|
||||
sp_io::storage::read(well_known_keys::INTRABLOCK_ENTROPY, &mut last[..], 0);
|
||||
let next = (b"frame_system::unique", entropy, last).using_encoded(blake2_256);
|
||||
sp_io::storage::set(well_known_keys::INTRABLOCK_ENTROPY, &next.encode());
|
||||
sp_io::storage::set(well_known_keys::INTRABLOCK_ENTROPY, &next);
|
||||
next
|
||||
}
|
||||
|
||||
|
||||
@@ -41,13 +41,29 @@ fn unique_datum_works() {
|
||||
assert!(sp_io::storage::exists(well_known_keys::INTRABLOCK_ENTROPY));
|
||||
|
||||
let h1 = unique(b"");
|
||||
assert_eq!(
|
||||
32,
|
||||
sp_io::storage::read(well_known_keys::INTRABLOCK_ENTROPY, &mut [], 0).unwrap()
|
||||
);
|
||||
let h2 = unique(b"");
|
||||
assert_eq!(
|
||||
32,
|
||||
sp_io::storage::read(well_known_keys::INTRABLOCK_ENTROPY, &mut [], 0).unwrap()
|
||||
);
|
||||
assert_ne!(h1, h2);
|
||||
|
||||
let h3 = unique(b"Hello");
|
||||
assert_eq!(
|
||||
32,
|
||||
sp_io::storage::read(well_known_keys::INTRABLOCK_ENTROPY, &mut [], 0).unwrap()
|
||||
);
|
||||
assert_ne!(h2, h3);
|
||||
|
||||
let h4 = unique(b"Hello");
|
||||
assert_eq!(
|
||||
32,
|
||||
sp_io::storage::read(well_known_keys::INTRABLOCK_ENTROPY, &mut [], 0).unwrap()
|
||||
);
|
||||
assert_ne!(h3, h4);
|
||||
|
||||
System::finalize();
|
||||
|
||||
Reference in New Issue
Block a user