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 all 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
4 changes: 2 additions & 2 deletions frame/assets/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,11 +228,11 @@ decl_error! {
decl_storage! {
trait Store for Module<T: Trait> as Assets {
/// The number of units of assets held by any given account.
Balances: map (T::AssetId, T::AccountId) => T::Balance;
Balances: map hasher(blake2_256) (T::AssetId, T::AccountId) => T::Balance;
/// The next asset identifier up for grabs.
NextAssetId get(fn next_asset_id): T::AssetId;
/// The total unit supply of an asset.
TotalSupply: map T::AssetId => T::Balance;
TotalSupply: map hasher(blake2_256) T::AssetId => T::Balance;
}
}

Expand Down
2 changes: 1 addition & 1 deletion frame/babe/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ decl_storage! {
/// We reset all segments and return to `0` at the beginning of every
/// epoch.
SegmentIndex build(|_| 0): u32;
UnderConstruction: map u32 => Vec<[u8; 32 /* VRF_OUTPUT_LENGTH */]>;
UnderConstruction: map hasher(blake2_256) u32 => Vec<[u8; 32 /* VRF_OUTPUT_LENGTH */]>;

/// Temporary value (cleared at block finalization) which is `Some`
/// if per-block initialization has already been called for current block.
Expand Down
12 changes: 8 additions & 4 deletions frame/balances/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,9 @@ decl_storage! {
})
})
}).collect::<Vec<_>>()
}): map T::AccountId => Option<VestingSchedule<T::Balance, T::BlockNumber>>;
}):
map hasher(blake2_256) T::AccountId
=> Option<VestingSchedule<T::Balance, T::BlockNumber>>;

/// The 'free' balance of a given account.
///
Expand All @@ -389,7 +391,7 @@ decl_storage! {
/// collapsed to zero if it ever becomes less than `ExistentialDeposit`.
pub FreeBalance get(fn free_balance)
build(|config: &GenesisConfig<T, I>| config.balances.clone()):
map T::AccountId => T::Balance;
map hasher(blake2_256) T::AccountId => T::Balance;

/// The amount of the balance of a given account that is externally reserved; this can still get
/// slashed, but gets slashed last of all.
Expand All @@ -402,10 +404,12 @@ decl_storage! {
///
/// `frame_system::AccountNonce` is also deleted if `FreeBalance` is also zero (it also gets
/// collapsed to zero if it ever becomes less than `ExistentialDeposit`.)
pub ReservedBalance get(fn reserved_balance): map T::AccountId => T::Balance;
pub ReservedBalance get(fn reserved_balance):
map hasher(blake2_256) T::AccountId => T::Balance;

/// Any liquidity locks on some account balances.
pub Locks get(fn locks): map T::AccountId => Vec<BalanceLock<T::Balance, T::BlockNumber>>;
pub Locks get(fn locks):
map hasher(blake2_256) T::AccountId => Vec<BalanceLock<T::Balance, T::BlockNumber>>;
}
add_extra_genesis {
config(balances): Vec<(T::AccountId, T::Balance)>;
Expand Down
6 changes: 4 additions & 2 deletions frame/collective/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,11 @@ decl_storage! {
/// The hashes of the active proposals.
pub Proposals get(fn proposals): Vec<T::Hash>;
/// Actual proposal for a given hash, if it's current.
pub ProposalOf get(fn proposal_of): map T::Hash => Option<<T as Trait<I>>::Proposal>;
pub ProposalOf get(fn proposal_of):
map hasher(blake2_256) T::Hash => Option<<T as Trait<I>>::Proposal>;
/// Votes on a given proposal, if it is ongoing.
pub Voting get(fn voting): map T::Hash => Option<Votes<T::AccountId>>;
pub Voting get(fn voting):
map hasher(blake2_256) T::Hash => Option<Votes<T::AccountId>>;
/// Proposals so far.
pub ProposalCount get(fn proposal_count): u32;
/// The current members of the collective. This is stored sorted (just by value).
Expand Down
6 changes: 3 additions & 3 deletions frame/contracts/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -942,13 +942,13 @@ decl_storage! {
/// Current cost schedule for contracts.
CurrentSchedule get(fn current_schedule) config(): Schedule = Schedule::default();
/// A mapping from an original code hash to the original code, untouched by instrumentation.
pub PristineCode: map CodeHash<T> => Option<Vec<u8>>;
pub PristineCode: map hasher(blake2_256) CodeHash<T> => Option<Vec<u8>>;
/// A mapping between an original code hash and instrumented wasm code, ready for execution.
pub CodeStorage: map CodeHash<T> => Option<wasm::PrefabWasmModule>;
pub CodeStorage: map hasher(blake2_256) CodeHash<T> => Option<wasm::PrefabWasmModule>;
/// The subtrie counter.
pub AccountCounter: u64 = 0;
/// The code associated with a given account.
pub ContractInfoOf: map T::AccountId => Option<ContractInfo<T>>;
pub ContractInfoOf: map hasher(blake2_256) T::AccountId => Option<ContractInfo<T>>;
/// The price of one unit of gas.
GasPrice get(fn gas_price) config(): BalanceOf<T> = 1.into();
}
Expand Down
25 changes: 16 additions & 9 deletions frame/democracy/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,9 +268,12 @@ decl_storage! {
pub PublicProps get(fn public_props): Vec<(PropIndex, T::Hash, T::AccountId)>;
/// Map of hashes to the proposal preimage, along with who registered it and their deposit.
/// The block number is the block at which it was deposited.
pub Preimages: map T::Hash => Option<(Vec<u8>, T::AccountId, BalanceOf<T>, T::BlockNumber)>;
pub Preimages:
map hasher(blake2_256) T::Hash
=> Option<(Vec<u8>, T::AccountId, BalanceOf<T>, T::BlockNumber)>;
/// Those who have locked a deposit.
pub DepositOf get(fn deposit_of): map PropIndex => Option<(BalanceOf<T>, Vec<T::AccountId>)>;
pub DepositOf get(fn deposit_of):
map hasher(blake2_256) PropIndex => Option<(BalanceOf<T>, Vec<T::AccountId>)>;

/// The next free referendum index, aka the number of referenda started so far.
pub ReferendumCount get(fn referendum_count) build(|_| 0 as ReferendumIndex): ReferendumIndex;
Expand All @@ -279,25 +282,28 @@ decl_storage! {
pub LowestUnbaked get(fn lowest_unbaked) build(|_| 0 as ReferendumIndex): ReferendumIndex;
/// Information concerning any given referendum.
pub ReferendumInfoOf get(fn referendum_info):
map ReferendumIndex => Option<ReferendumInfo<T::BlockNumber, T::Hash>>;
map hasher(blake2_256) ReferendumIndex
=> Option<ReferendumInfo<T::BlockNumber, T::Hash>>;
/// Queue of successful referenda to be dispatched. Stored ordered by block number.
pub DispatchQueue get(fn dispatch_queue): Vec<(T::BlockNumber, T::Hash, ReferendumIndex)>;

/// Get the voters for the current proposal.
pub VotersFor get(fn voters_for): map ReferendumIndex => Vec<T::AccountId>;
pub VotersFor get(fn voters_for):
map hasher(blake2_256) ReferendumIndex => Vec<T::AccountId>;

/// Get the vote in a given referendum of a particular voter. The result is meaningful only
/// if `voters_for` includes the voter when called with the referendum (you'll get the
/// default `Vote` value otherwise). If you don't want to check `voters_for`, then you can
/// also check for simple existence with `VoteOf::exists` first.
pub VoteOf get(fn vote_of): map (ReferendumIndex, T::AccountId) => Vote;
pub VoteOf get(fn vote_of): map hasher(blake2_256) (ReferendumIndex, T::AccountId) => Vote;

/// Who is able to vote for whom. Value is the fund-holding account, key is the
/// vote-transaction-sending account.
pub Proxy get(fn proxy): map T::AccountId => Option<T::AccountId>;
pub Proxy get(fn proxy): map hasher(blake2_256) T::AccountId => Option<T::AccountId>;

/// Get the account (and lock periods) to which another account is delegating vote.
pub Delegations get(fn delegations): linked_map T::AccountId => (T::AccountId, Conviction);
pub Delegations get(fn delegations):
linked_map hasher(blake2_256) T::AccountId => (T::AccountId, Conviction);

/// True if the last referendum tabled was submitted externally. False if it was a public
/// proposal.
Expand All @@ -311,10 +317,11 @@ decl_storage! {

/// A record of who vetoed what. Maps proposal hash to a possible existent block number
/// (until when it may not be resubmitted) and who vetoed it.
pub Blacklist get(fn blacklist): map T::Hash => Option<(T::BlockNumber, Vec<T::AccountId>)>;
pub Blacklist get(fn blacklist):
map hasher(blake2_256) T::Hash => Option<(T::BlockNumber, Vec<T::AccountId>)>;

/// Record of all proposals that have been subject to emergency cancellation.
pub Cancellations: map T::Hash => bool;
pub Cancellations: map hasher(blake2_256) T::Hash => bool;
}
}

Expand Down
4 changes: 2 additions & 2 deletions frame/elections-phragmen/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,9 @@ decl_storage! {
pub ElectionRounds get(fn election_rounds): u32 = Zero::zero();

/// Votes of a particular voter, with the round index of the votes.
pub VotesOf get(fn votes_of): linked_map T::AccountId => Vec<T::AccountId>;
pub VotesOf get(fn votes_of): linked_map hasher(blake2_256) T::AccountId => Vec<T::AccountId>;
/// Locked stake of a voter.
pub StakeOf get(fn stake_of): map T::AccountId => BalanceOf<T>;
pub StakeOf get(fn stake_of): map hasher(blake2_256) T::AccountId => BalanceOf<T>;

/// The present candidate list. Sorted based on account-id. A current member or a runner can
/// never enter this vector and is always implicitly assumed to be a candidate.
Expand Down
13 changes: 8 additions & 5 deletions frame/elections/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,14 +235,17 @@ decl_storage! {
// bit-wise manner. In order to get a human-readable representation (`Vec<bool>`), use
// [`all_approvals_of`]. Furthermore, each vector of scalars is chunked with the cap of
// `APPROVAL_SET_SIZE`.
pub ApprovalsOf get(fn approvals_of): map (T::AccountId, SetIndex) => Vec<ApprovalFlag>;
pub ApprovalsOf get(fn approvals_of):
map hasher(blake2_256) (T::AccountId, SetIndex) => Vec<ApprovalFlag>;
/// The vote index and list slot that the candidate `who` was registered or `None` if they
/// are not currently registered.
pub RegisterInfoOf get(fn candidate_reg_info): map T::AccountId => Option<(VoteIndex, u32)>;
pub RegisterInfoOf get(fn candidate_reg_info):
map hasher(blake2_256) T::AccountId => Option<(VoteIndex, u32)>;
/// Basic information about a voter.
pub VoterInfoOf get(fn voter_info): map T::AccountId => Option<VoterInfo<BalanceOf<T>>>;
pub VoterInfoOf get(fn voter_info):
map hasher(blake2_256) T::AccountId => Option<VoterInfo<BalanceOf<T>>>;
/// The present voter list (chunked and capped at [`VOTER_SET_SIZE`]).
pub Voters get(fn voters): map SetIndex => Vec<Option<T::AccountId>>;
pub Voters get(fn voters): map hasher(blake2_256) SetIndex => Vec<Option<T::AccountId>>;
/// the next free set to store a voter in. This will keep growing.
pub NextVoterSet get(fn next_nonfull_voter_set): SetIndex = 0;
/// Current number of Voters.
Expand All @@ -263,7 +266,7 @@ decl_storage! {

/// Who is able to vote for whom. Value is the fund-holding account, key is the
/// vote-transaction-sending account.
pub Proxy get(fn proxy): map T::AccountId => Option<T::AccountId>;
pub Proxy get(fn proxy): map hasher(blake2_256) T::AccountId => Option<T::AccountId>;
}
}

Expand Down
6 changes: 3 additions & 3 deletions frame/evm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,9 @@ pub trait Trait: frame_system::Trait + pallet_timestamp::Trait {

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, H256 => H256;
Accounts get(fn accounts) config(): map hasher(blake2_256) H160 => Account;
AccountCodes: map hasher(blake2_256) H160 => Vec<u8>;
AccountStorages: double_map hasher(blake2_256) H160, hasher(blake2_256) H256 => H256;
}
}

Expand Down
6 changes: 3 additions & 3 deletions frame/example/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ decl_storage! {
// `pub? Name get(fn getter_name)? [config()|config(myname)] [build(|_| {...})] : <type> (= <new_default_value>)?;`
// where `<type>` is either:
// - `Type` (a basic value item); or
// - `map KeyType => ValueType` (a map item).
// - `map hasher(HasherKind) KeyType => ValueType` (a map item).
//
// Note that there are two optional modifiers for the storage type declaration.
// - `Foo: Option<u32>`:
Expand All @@ -339,7 +339,7 @@ decl_storage! {
// - `Foo::put(1); Foo::get()` returns `1`;
// - `Foo::kill(); Foo::get()` returns `0` (u32::default()).
// e.g. Foo: u32;
// e.g. pub Bar get(fn bar): map T::AccountId => Vec<(T::Balance, u64)>;
// e.g. pub Bar get(fn bar): map hasher(blake2_256) T::AccountId => Vec<(T::Balance, u64)>;
//
// For basic value items, you'll get a type which implements
// `frame_support::StorageValue`. For map items, you'll get a type which
Expand All @@ -351,7 +351,7 @@ decl_storage! {
Dummy get(fn dummy) config(): Option<T::Balance>;

// A map that has enumerable entries.
Bar get(fn bar) config(): linked_map T::AccountId => T::Balance;
Bar get(fn bar) config(): linked_map hasher(blake2_256) T::AccountId => T::Balance;

// this one uses the default, we'll demonstrate the usage of 'mutate' API.
Foo get(fn foo) config(): T::Balance;
Expand Down
14 changes: 9 additions & 5 deletions frame/generic-asset/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -454,22 +454,26 @@ decl_storage! {
pub TotalIssuance get(fn total_issuance) build(|config: &GenesisConfig<T>| {
let issuance = config.initial_balance * (config.endowed_accounts.len() as u32).into();
config.assets.iter().map(|id| (id.clone(), issuance)).collect::<Vec<_>>()
}): map T::AssetId => T::Balance;
}): map hasher(blake2_256) T::AssetId => T::Balance;

/// The free balance of a given asset under an account.
pub FreeBalance: double_map T::AssetId, hasher(twox_128) T::AccountId => T::Balance;
pub FreeBalance:
double_map hasher(blake2_256) 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, hasher(twox_128) T::AccountId => T::Balance;
pub ReservedBalance:
double_map hasher(blake2_256) 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;

/// Permission options for a given asset.
pub Permissions get(fn get_permission): map T::AssetId => PermissionVersions<T::AccountId>;
pub Permissions get(fn get_permission):
map hasher(blake2_256) T::AssetId => PermissionVersions<T::AccountId>;

/// Any liquidity locks on some account balances.
pub Locks get(fn locks): map T::AccountId => Vec<BalanceLock<T::Balance, T::BlockNumber>>;
pub Locks get(fn locks):
map hasher(blake2_256) T::AccountId => Vec<BalanceLock<T::Balance, T::BlockNumber>>;

/// The identity of the asset which is the one that is designated for the chain's staking system.
pub StakingAssetId get(fn staking_asset_id) config(): T::AssetId;
Expand Down
2 changes: 1 addition & 1 deletion frame/grandpa/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ decl_storage! {
CurrentSetId get(fn current_set_id) build(|_| fg_primitives::SetId::default()): SetId;

/// A mapping from grandpa set ID to the index of the *most recent* session for which its members were responsible.
SetIdSession get(fn session_for_set): map SetId => Option<SessionIndex>;
SetIdSession get(fn session_for_set): map hasher(blake2_256) SetId => Option<SessionIndex>;
}
add_extra_genesis {
config(authorities): AuthorityList;
Expand Down
9 changes: 6 additions & 3 deletions frame/identity/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -377,16 +377,19 @@ pub struct RegistrarInfo<
decl_storage! {
trait Store for Module<T: Trait> as Sudo {
/// Information that is pertinent to identify the entity behind an account.
pub IdentityOf get(fn identity): map T::AccountId => Option<Registration<BalanceOf<T>>>;
pub IdentityOf get(fn identity):
map hasher(blake2_256) T::AccountId => Option<Registration<BalanceOf<T>>>;

/// The super-identity of an alternative "sub" identity together with its name, within that
/// context. If the account is not some other account's sub-identity, then just `None`.
pub SuperOf get(fn super_of): map T::AccountId => Option<(T::AccountId, Data)>;
pub SuperOf get(fn super_of):
map hasher(blake2_256) T::AccountId => Option<(T::AccountId, Data)>;

/// Alternative "sub" identities of this account.
///
/// The first item is the deposit, the second is a vector of the accounts.
pub SubsOf get(fn subs): map T::AccountId => (BalanceOf<T>, Vec<T::AccountId>);
pub SubsOf get(fn subs):
map hasher(blake2_256) T::AccountId => (BalanceOf<T>, Vec<T::AccountId>);

/// The set of registrars. Not expected to get very big as can only be added through a
/// special origin (likely a council motion).
Expand Down
6 changes: 4 additions & 2 deletions frame/im-online/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,12 +233,14 @@ decl_storage! {

/// For each session index, we keep a mapping of `AuthIndex`
/// to `offchain::OpaqueNetworkState`.
ReceivedHeartbeats get(fn received_heartbeats): double_map SessionIndex, AuthIndex
ReceivedHeartbeats get(fn received_heartbeats):
double_map hasher(blake2_256) SessionIndex, hasher(blake2_256) 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, T::ValidatorId => u32;
AuthoredBlocks get(fn authored_blocks):
double_map hasher(blake2_256) SessionIndex, hasher(blake2_256) T::ValidatorId => u32;
}
add_extra_genesis {
config(keys): Vec<T::AuthorityId>;
Expand Down
2 changes: 1 addition & 1 deletion frame/indices/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ decl_storage! {
].to_owned(),
))
.collect::<Vec<_>>()
}): map T::AccountIndex => Vec<T::AccountId>;
}): map hasher(blake2_256) T::AccountIndex => Vec<T::AccountId>;
}
add_extra_genesis {
config(ids): Vec<T::AccountId>;
Expand Down
2 changes: 1 addition & 1 deletion frame/nicks/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ pub trait Trait: frame_system::Trait {
decl_storage! {
trait Store for Module<T: Trait> as Sudo {
/// The lookup table for names.
NameOf: map T::AccountId => Option<(Vec<u8>, BalanceOf<T>)>;
NameOf: map hasher(blake2_256) T::AccountId => Option<(Vec<u8>, BalanceOf<T>)>;
}
}

Expand Down
8 changes: 5 additions & 3 deletions frame/offences/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,18 +54,20 @@ pub trait Trait: frame_system::Trait {
decl_storage! {
trait Store for Module<T: Trait> as Offences {
/// The primary structure that holds all offence records keyed by report identifiers.
Reports get(fn reports): map ReportIdOf<T> => Option<OffenceDetails<T::AccountId, T::IdentificationTuple>>;
Reports get(fn reports): map hasher(blake2_256) 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, OpaqueTimeSlot => Vec<ReportIdOf<T>>;
ConcurrentReportsIndex:
double_map hasher(blake2_256) Kind, hasher(blake2_256) OpaqueTimeSlot
=> Vec<ReportIdOf<T>>;

/// Enumerates all reports of a kind along with the time they happened.
///
/// All reports are sorted by the time of offence.
///
/// Note that the actual type of this mapping is `Vec<u8>`, this is because values of
/// different types are not supported at the moment so we are doing the manual serialization.
ReportsByKindIndex: map Kind => Vec<u8>; // (O::TimeSlot, ReportIdOf<T>)
ReportsByKindIndex: map hasher(blake2_256) Kind => Vec<u8>; // (O::TimeSlot, ReportIdOf<T>)
}
}

Expand Down
6 changes: 4 additions & 2 deletions frame/recovery/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,8 @@ decl_storage! {
trait Store for Module<T: Trait> as Recovery {
/// The set of recoverable accounts and their recovery configuration.
pub Recoverable get(fn recovery_config):
map T::AccountId => Option<RecoveryConfig<T::BlockNumber, BalanceOf<T>, T::AccountId>>;
map hasher(blake2_256) T::AccountId
=> Option<RecoveryConfig<T::BlockNumber, BalanceOf<T>, T::AccountId>>;
/// Active recovery attempts.
///
/// First account is the account to be recovered, and the second account
Expand All @@ -253,7 +254,8 @@ decl_storage! {
/// The final list of recovered accounts.
///
/// Map from the recovered account to the user who can access it.
pub Recovered get(fn recovered_account): map T::AccountId => Option<T::AccountId>;
pub Recovered get(fn recovered_account):
map hasher(blake2_256) T::AccountId => Option<T::AccountId>;
}
}

Expand Down
2 changes: 1 addition & 1 deletion frame/scored-pool/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ decl_storage! {
/// check if a candidate is already in the pool, without having to
/// iterate over the entire pool (the `Pool` is not sorted by
/// `T::AccountId`, but by `T::Score` instead).
CandidateExists get(fn candidate_exists): map T::AccountId => bool;
CandidateExists get(fn candidate_exists): map hasher(blake2_256) T::AccountId => bool;

/// The current membership, stored as an ordered Vec.
Members get(fn members): Vec<T::AccountId>;
Expand Down
Loading