Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 2 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
2 changes: 1 addition & 1 deletion frame/evm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ decl_storage! {
trait Store for Module<T: Trait> as Example {
Accounts get(fn accounts) config(): map H160 => Account;
AccountCodes: map H160 => Vec<u8>;
AccountStorages: double_map H160, blake2_256(H256) => H256;
AccountStorages: double_map H160, H256 => H256;
}
}

Expand Down
4 changes: 2 additions & 2 deletions frame/generic-asset/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -492,10 +492,10 @@ decl_storage! {
}): map T::AssetId => T::Balance;

/// The free balance of a given asset under an account.
pub FreeBalance: double_map T::AssetId, twox_128(T::AccountId) => T::Balance;
pub FreeBalance: double_map T::AssetId, hasher(twox_128) T::AccountId => T::Balance;

/// The reserved balance of a given asset under an account.
pub ReservedBalance: double_map T::AssetId, twox_128(T::AccountId) => T::Balance;
pub ReservedBalance: double_map T::AssetId, hasher(twox_128) T::AccountId => T::Balance;

/// Next available ID for user-created asset.
pub NextAssetId get(fn next_asset_id) config(): T::AssetId;
Expand Down
7 changes: 3 additions & 4 deletions frame/im-online/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,13 +229,12 @@ decl_storage! {

/// For each session index, we keep a mapping of `AuthIndex`
/// to `offchain::OpaqueNetworkState`.
ReceivedHeartbeats get(fn received_heartbeats): double_map SessionIndex,
blake2_256(AuthIndex) => Option<Vec<u8>>;
ReceivedHeartbeats get(fn received_heartbeats): double_map SessionIndex, AuthIndex
=> Option<Vec<u8>>;

/// For each session index, we keep a mapping of `T::ValidatorId` to the
/// number of blocks authored by the given authority.
AuthoredBlocks get(fn authored_blocks): double_map SessionIndex,
blake2_256(T::ValidatorId) => u32;
AuthoredBlocks get(fn authored_blocks): double_map SessionIndex, T::ValidatorId => u32;
}
add_extra_genesis {
config(keys): Vec<T::AuthorityId>;
Expand Down
2 changes: 1 addition & 1 deletion frame/offences/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ decl_storage! {
Reports get(fn reports): map ReportIdOf<T> => Option<OffenceDetails<T::AccountId, T::IdentificationTuple>>;

/// A vector of reports of the same kind that happened at the same time slot.
ConcurrentReportsIndex: double_map Kind, blake2_256(OpaqueTimeSlot) => Vec<ReportIdOf<T>>;
ConcurrentReportsIndex: double_map Kind, OpaqueTimeSlot => Vec<ReportIdOf<T>>;

/// Enumerates all reports of a kind along with the time they happened.
///
Expand Down
6 changes: 4 additions & 2 deletions frame/session/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -398,13 +398,15 @@ decl_storage! {
///
/// The first key is always `DEDUP_KEY_PREFIX` to have all the data in the same branch of
/// the trie. Having all data in the same branch should prevent slowing down other queries.
NextKeys: double_map hasher(twox_64_concat) Vec<u8>, blake2_256(T::ValidatorId) => Option<T::Keys>;
NextKeys: double_map hasher(twox_64_concat) Vec<u8>, hasher(blake2_256) T::ValidatorId
=> Option<T::Keys>;

/// The owner of a key. The second key is the `KeyTypeId` + the encoded key.
///
/// The first key is always `DEDUP_KEY_PREFIX` to have all the data in the same branch of
/// the trie. Having all data in the same branch should prevent slowing down other queries.
KeyOwner: double_map hasher(twox_64_concat) Vec<u8>, blake2_256((KeyTypeId, Vec<u8>)) => Option<T::ValidatorId>;
KeyOwner: double_map hasher(twox_64_concat) Vec<u8>, hasher(blake2_256) (KeyTypeId, Vec<u8>)
=> Option<T::ValidatorId>;
}
add_extra_genesis {
config(keys): Vec<(T::ValidatorId, T::Keys)>;
Expand Down
4 changes: 2 additions & 2 deletions frame/staking/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -738,11 +738,11 @@ decl_storage! {
/// All slashing events on validators, mapped by era to the highest slash proportion
/// and slash value of the era.
ValidatorSlashInEra:
double_map EraIndex, twox_128(T::AccountId) => Option<(Perbill, BalanceOf<T>)>;
double_map EraIndex, hasher(twox_128) T::AccountId => Option<(Perbill, BalanceOf<T>)>;

/// All slashing events on nominators, mapped by era to the highest slash value of the era.
NominatorSlashInEra:
double_map EraIndex, twox_128(T::AccountId) => Option<BalanceOf<T>>;
double_map EraIndex, hasher(twox_128) T::AccountId => Option<BalanceOf<T>>;

/// Slashing spans for stash accounts.
SlashingSpans: map T::AccountId => Option<slashing::SlashingSpans>;
Expand Down
8 changes: 3 additions & 5 deletions frame/support/procedural/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ use proc_macro::TokenStream;
/// Twox128(module_prefix) ++ Twox128(head_prefix)
/// ```
///
/// * Double map: `Foo: double_map hasher($hash1) u32, $hash2(u32) => u32`: Implements the
/// * Double map: `Foo: double_map hasher($hash1) u32, hasher($hash2) u32 => u32`: Implements the
/// [`StorageDoubleMap`](../frame_support/storage/trait.StorageDoubleMap.html) trait using the
/// [`StorageDoubleMap generator`](../frame_support/storage/generator/trait.StorageDoubleMap.html).
/// And [`StoragePrefixedMap`](../frame_support/storage/trait.StoragePrefixedMap.html).
Expand All @@ -126,10 +126,8 @@ use proc_macro::TokenStream;
/// [`Hashable`](../frame_support/trait.Hashable.html) trait. They must be choosen with care, see
/// generator documentation.
///
/// `hasher($hash)` is optional and its default is `blake2_256`.
///
/// `hasher($hash)` is optional and its default is `blake2_256`. One should use another hasher
/// with care, see generator documentation.
/// `hasher($hash1)` and `hasher($hash2) are optional and default to `blake2_256`.
/// One should use another hasher with care, see generator documentation.
///
/// If the first key is untrusted, a cryptographic `hasher` such as `blake2_256` must be used.
/// Otherwise, other values of all storage items can be compromised.
Expand Down
13 changes: 7 additions & 6 deletions frame/support/procedural/src/storage/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,11 @@ struct DeclStorageLinkedMap {
#[derive(Parse, ToTokens, Debug)]
struct DeclStorageDoubleMap {
pub map_keyword: keyword::double_map,
pub hasher: ext::Opt<SetHasher>,
pub hasher1: ext::Opt<SetHasher>,
pub key1: syn::Type,
pub comma_keyword: Token![,],
pub key2_hasher: Hasher,
pub key2: ext::Parens<syn::Type>,
pub hasher2: ext::Opt<SetHasher>,
pub key2: syn::Type,
pub ass_keyword: Token![=>],
pub value: syn::Type,
}
Expand Down Expand Up @@ -380,11 +380,12 @@ fn parse_storage_line_defs(
),
DeclStorageType::DoubleMap(map) => super::StorageLineTypeDef::DoubleMap(
super::DoubleMapDef {
hasher1: map.hasher.inner.map(Into::into)
hasher1: map.hasher1.inner.map(Into::into)
.unwrap_or(super::HasherKind::Blake2_256),
hasher2: map.hasher2.inner.map(Into::into)
.unwrap_or(super::HasherKind::Blake2_256),
hasher2: map.key2_hasher.into(),
key1: map.key1,
key2: map.key2.content,
key2: map.key2,
value: map.value,
}
),
Expand Down
8 changes: 4 additions & 4 deletions frame/support/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,12 +236,12 @@ mod tests {
pub GetterNoFnKeyword get(no_fn): Option<u32>;

pub DataDM config(test_config) build(|_| vec![(15u32, 16u32, 42u64)]):
double_map hasher(twox_64_concat) u32, blake2_256(u32) => u64;
double_map hasher(twox_64_concat) u32, hasher(blake2_256) u32 => u64;
pub GenericDataDM:
double_map T::BlockNumber, twox_128(T::BlockNumber) => T::BlockNumber;
double_map T::BlockNumber, hasher(twox_128) T::BlockNumber => T::BlockNumber;
pub GenericData2DM:
double_map T::BlockNumber, twox_256(T::BlockNumber) => Option<T::BlockNumber>;
pub AppendableDM: double_map u32, blake2_256(T::BlockNumber) => Vec<u32>;
double_map T::BlockNumber, hasher(twox_256) T::BlockNumber => Option<T::BlockNumber>;
pub AppendableDM: double_map u32, T::BlockNumber => Vec<u32>;
}
}

Expand Down
6 changes: 3 additions & 3 deletions frame/support/test/tests/decl_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -562,9 +562,9 @@ mod test_append_and_len {
MapVecWithDefault: map u32 => Vec<u32> = vec![6, 9];
OptionMapVec: map u32 => Option<Vec<u32>>;

DoubleMapVec: double_map u32, blake2_256(u32) => Vec<u32>;
DoubleMapVecWithDefault: double_map u32, blake2_256(u32) => Vec<u32> = vec![6, 9];
OptionDoubleMapVec: double_map u32, blake2_256(u32) => Option<Vec<u32>>;
DoubleMapVec: double_map u32, u32 => Vec<u32>;
DoubleMapVecWithDefault: double_map u32, u32 => Vec<u32> = vec![6, 9];
OptionDoubleMapVec: double_map u32, u32 => Option<Vec<u32>>;

LinkedMapVec: linked_map u32 => Vec<u32>;
LinkedMapVecWithDefault: linked_map u32 => Vec<u32> = vec![6, 9];
Expand Down
12 changes: 6 additions & 6 deletions frame/support/test/tests/final_keys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ mod no_instance {
pub LinkedMap: linked_map u32 => u32;
pub LinkedMap2: linked_map hasher(twox_128) u32 => u32;

pub DoubleMap: double_map u32, blake2_256(u32) => u32;
pub DoubleMap2: double_map hasher(twox_128) u32, blake2_128(u32) => u32;
pub DoubleMap: double_map u32, u32 => u32;
pub DoubleMap2: double_map hasher(twox_128) u32, hasher(blake2_128) u32 => u32;

pub TestGenericValue get(fn test_generic_value) config(): Option<T::BlockNumber>;
pub TestGenericDoubleMap get(fn foo2) config(test_generic_double_map):
double_map u32, blake2_256(T::BlockNumber) => Option<u32>;
double_map u32, hasher(blake2_256) T::BlockNumber => Option<u32>;
}
}
}
Expand All @@ -71,12 +71,12 @@ mod instance {
pub LinkedMap: linked_map u32 => u32;
pub LinkedMap2: linked_map hasher(twox_128) u32 => u32;

pub DoubleMap: double_map u32, blake2_256(u32) => u32;
pub DoubleMap2: double_map hasher(twox_128) u32, blake2_128(u32) => u32;
pub DoubleMap: double_map u32, u32 => u32;
pub DoubleMap2: double_map hasher(twox_128) u32, hasher(blake2_128) u32 => u32;

pub TestGenericValue get(fn test_generic_value) config(): Option<T::BlockNumber>;
pub TestGenericDoubleMap get(fn foo2) config(test_generic_double_map):
double_map u32, blake2_256(T::BlockNumber) => Option<u32>;
double_map u32, hasher(blake2_256) T::BlockNumber => Option<u32>;
}
add_extra_genesis {
// See `decl_storage` limitation.
Expand Down
2 changes: 1 addition & 1 deletion frame/support/test/tests/genesisconfig.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ frame_support::decl_module! {

frame_support::decl_storage! {
trait Store for Module<T: Trait> as Example {
pub AppendableDM config(t): double_map u32, blake2_256(T::BlockNumber) => Vec<u32>;
pub AppendableDM config(t): double_map u32, T::BlockNumber => Vec<u32>;
}
}

Expand Down
2 changes: 1 addition & 1 deletion frame/support/test/tests/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ mod module2 {
pub Value config(value): T::Amount;
pub Map config(map): map u64 => u64;
pub LinkedMap config(linked_map): linked_map u64 => Vec<u8>;
pub DoubleMap config(double_map): double_map u64, blake2_256(u64) => u64;
pub DoubleMap config(double_map): double_map u64, u64 => u64;
}
}

Expand Down
3 changes: 2 additions & 1 deletion frame/utility/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ pub struct Multisig<BlockNumber, Balance, AccountId> {
decl_storage! {
trait Store for Module<T: Trait> as Utility {
/// The set of open multisig operations.
pub Multisigs: double_map hasher(twox_64_concat) T::AccountId, blake2_128_concat([u8; 32])
pub Multisigs: double_map
hasher(twox_64_concat) T::AccountId, hasher(blake2_128_concat) [u8; 32]
=> Option<Multisig<T::BlockNumber, BalanceOf<T>, T::AccountId>>;
}
}
Expand Down
2 changes: 1 addition & 1 deletion utils/frame/rpc/support/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ use sc_rpc_api::state::StateClient;
/// pub LastActionId: u64;
/// pub Voxels: map Loc => Block;
/// pub Actions: linked_map u64 => Loc;
/// pub Prefab: double_map u128, blake2_256((i8, i8, i8)) => Block;
/// pub Prefab: double_map u128, (i8, i8, i8) => Block;
/// }
/// }
///
Expand Down