Correct handling of InSet's keys

This commit is contained in:
Luke Parker 2023-10-11 01:05:48 -04:00
parent 13cbc99149
commit 04f9a1fa31
No known key found for this signature in database

View file

@ -83,8 +83,12 @@ pub mod pallet {
ValueQuery, ValueQuery,
>; >;
/// The validators selected to be in-set, yet with the ability to perform a check for presence. /// The validators selected to be in-set, yet with the ability to perform a check for presence.
// Uses Identity so we can call clear_prefix over network, manually inserting a Blake2 hash
// before the spammable key.
// TODO: Review child trees?
#[pallet::storage] #[pallet::storage]
pub type InSet<T: Config> = StorageMap<_, Blake2_128Concat, (NetworkId, Public), (), OptionQuery>; pub type InSet<T: Config> =
StorageMap<_, Identity, (NetworkId, [u8; 16], Public), (), OptionQuery>;
/// The current amount allocated to a validator set by a validator. /// The current amount allocated to a validator set by a validator.
#[pallet::storage] #[pallet::storage]
@ -197,7 +201,10 @@ pub mod pallet {
} }
let key = Public(next[(next.len() - 32) .. next.len()].try_into().unwrap()); let key = Public(next[(next.len() - 32) .. next.len()].try_into().unwrap());
InSet::<T>::set((network, key), Some(())); InSet::<T>::set(
(network, sp_io::hashing::blake2_128(&(network, key).encode()), key),
Some(()),
);
participants.push(key); participants.push(key);
last = next; last = next;