mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 04:01:10 +00:00
Avoid need for ident strings in storage (#624)
* Remove need for ident strings for storage items * Fixes * Fix tests * Minor change to macro grammer
This commit is contained in:
@@ -257,7 +257,7 @@ mod tests {
|
||||
// Blake
|
||||
// hex!("3437bf4b182ab17bb322af5c67e55f6be487a77084ad2b4e27ddac7242e4ad21").into(),
|
||||
// Keccak
|
||||
hex!("56c9a542e48ccf4e0821de301ea4384e87425604278b12a9db31c6d4e89ca51e").into(),
|
||||
hex!("0b401681b95d04e91dbe53835867bdcb5d9e0590b54ae06bd7b347d49f9a737f").into(),
|
||||
vec![BareExtrinsic {
|
||||
signed: alice(),
|
||||
index: 0,
|
||||
@@ -273,7 +273,7 @@ mod tests {
|
||||
// Blake
|
||||
// hex!("741fcb660e6fa9f625fbcd993b49f6c1cc4040f5e0cc8727afdedf11fd3c464b").into(),
|
||||
// Keccak
|
||||
hex!("166a2593d35f2d1bc87eca8cf2e320ed06759000a02aa88e51fa85b12c6f1267").into(),
|
||||
hex!("03f051dc4f588fdc713145772486a129d33c7f178c133b5801fa79c3ecca2dc9").into(),
|
||||
vec![
|
||||
BareExtrinsic {
|
||||
signed: bob(),
|
||||
@@ -296,7 +296,7 @@ mod tests {
|
||||
// Blake
|
||||
// hex!("2c7231a9c210a7aa4bea169d944bc4aaacd517862b244b8021236ffa7f697991").into(),
|
||||
// Keccak
|
||||
hex!("be186810570e437f0d803493fced9879207b064a0701fd8d68662b9563b4d33e").into(),
|
||||
hex!("6e3b6aaf0be927394b520e3ebc0c34a7c26519711bc836e116e371273c3aca44").into(),
|
||||
vec![BareExtrinsic {
|
||||
signed: alice(),
|
||||
index: 0,
|
||||
|
||||
BIN
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
File diff suppressed because it is too large
Load Diff
@@ -150,25 +150,25 @@ decl_module! {
|
||||
}
|
||||
|
||||
decl_storage! {
|
||||
trait Store for Module<T: Trait>;
|
||||
trait Store for Module<T: Trait> as Contract {
|
||||
// The fee required to create a contract. At least as big as staking's ReclaimRebate.
|
||||
ContractFee get(contract_fee): required T::Balance;
|
||||
// The fee charged for a call into a contract.
|
||||
CallBaseFee get(call_base_fee): required T::Gas;
|
||||
// The fee charged for a create of a contract.
|
||||
CreateBaseFee get(create_base_fee): required T::Gas;
|
||||
// The price of one unit of gas.
|
||||
GasPrice get(gas_price): required T::Balance;
|
||||
// The maximum nesting level of a call/create stack.
|
||||
MaxDepth get(max_depth): required u32;
|
||||
// The maximum amount of gas that could be expended per block.
|
||||
BlockGasLimit get(block_gas_limit): required T::Gas;
|
||||
// Gas spent so far in this block.
|
||||
GasSpent get(gas_spent): default T::Gas;
|
||||
|
||||
// The fee required to create a contract. At least as big as staking's ReclaimRebate.
|
||||
ContractFee get(contract_fee): b"con:contract_fee" => required T::Balance;
|
||||
// The fee charged for a call into a contract.
|
||||
CallBaseFee get(call_base_fee): b"con:base_call_fee" => required T::Gas;
|
||||
// The fee charged for a create of a contract.
|
||||
CreateBaseFee get(create_base_fee): b"con:base_create_fee" => required T::Gas;
|
||||
// The price of one unit of gas.
|
||||
GasPrice get(gas_price): b"con:gas_price" => required T::Balance;
|
||||
// The maximum nesting level of a call/create stack.
|
||||
MaxDepth get(max_depth): b"con:max_depth" => required u32;
|
||||
// The maximum amount of gas that could be expended per block.
|
||||
BlockGasLimit get(block_gas_limit): b"con:block_gas_limit" => required T::Gas;
|
||||
// Gas spent so far in this block.
|
||||
GasSpent get(gas_spent): b"con:gas_spent" => default T::Gas;
|
||||
|
||||
// The code associated with an account.
|
||||
CodeOf: b"con:cod:" => default map [ T::AccountId => Vec<u8> ]; // TODO Vec<u8> values should be optimised to not do a length prefix.
|
||||
// The code associated with an account.
|
||||
pub CodeOf: default map [ T::AccountId => Vec<u8> ]; // TODO Vec<u8> values should be optimised to not do a length prefix.
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: consider storing upper-bound for contract's gas limit in fixed-length runtime
|
||||
|
||||
@@ -131,57 +131,58 @@ decl_module! {
|
||||
}
|
||||
|
||||
decl_storage! {
|
||||
trait Store for Module<T: Trait>;
|
||||
trait Store for Module<T: Trait> as Council {
|
||||
|
||||
// parameters
|
||||
// How much should be locked up in order to submit one's candidacy.
|
||||
pub CandidacyBond get(candidacy_bond): b"cou:cbo" => required T::Balance;
|
||||
// How much should be locked up in order to be able to submit votes.
|
||||
pub VotingBond get(voting_bond): b"cou:vbo" => required T::Balance;
|
||||
// The punishment, per voter, if you provide an invalid presentation.
|
||||
pub PresentSlashPerVoter get(present_slash_per_voter): b"cou:pss" => required T::Balance;
|
||||
// How many runners-up should have their approvals persist until the next vote.
|
||||
pub CarryCount get(carry_count): b"cou:cco" => required u32;
|
||||
// How long to give each top candidate to present themselves after the vote ends.
|
||||
pub PresentationDuration get(presentation_duration): b"cou:pdu" => required T::BlockNumber;
|
||||
// How many votes need to go by after a voter's last vote before they can be reaped if their
|
||||
// approvals are moot.
|
||||
pub InactiveGracePeriod get(inactivity_grace_period): b"cou:vgp" => required VoteIndex;
|
||||
// How often (in blocks) to check for new votes.
|
||||
pub VotingPeriod get(voting_period): b"cou:per" => required T::BlockNumber;
|
||||
// How long each position is active for.
|
||||
pub TermDuration get(term_duration): b"cou:trm" => required T::BlockNumber;
|
||||
// Number of accounts that should be sitting on the council.
|
||||
pub DesiredSeats get(desired_seats): b"cou:sts" => required u32;
|
||||
// parameters
|
||||
// How much should be locked up in order to submit one's candidacy.
|
||||
pub CandidacyBond get(candidacy_bond): required T::Balance;
|
||||
// How much should be locked up in order to be able to submit votes.
|
||||
pub VotingBond get(voting_bond): required T::Balance;
|
||||
// The punishment, per voter, if you provide an invalid presentation.
|
||||
pub PresentSlashPerVoter get(present_slash_per_voter): required T::Balance;
|
||||
// How many runners-up should have their approvals persist until the next vote.
|
||||
pub CarryCount get(carry_count): required u32;
|
||||
// How long to give each top candidate to present themselves after the vote ends.
|
||||
pub PresentationDuration get(presentation_duration): required T::BlockNumber;
|
||||
// How many votes need to go by after a voter's last vote before they can be reaped if their
|
||||
// approvals are moot.
|
||||
pub InactiveGracePeriod get(inactivity_grace_period): required VoteIndex;
|
||||
// How often (in blocks) to check for new votes.
|
||||
pub VotingPeriod get(voting_period): required T::BlockNumber;
|
||||
// How long each position is active for.
|
||||
pub TermDuration get(term_duration): required T::BlockNumber;
|
||||
// Number of accounts that should be sitting on the council.
|
||||
pub DesiredSeats get(desired_seats): required u32;
|
||||
|
||||
// permanent state (always relevant, changes only at the finalisation of voting)
|
||||
// The current council. When there's a vote going on, this should still be used for executive
|
||||
// matters.
|
||||
pub ActiveCouncil get(active_council): b"cou:act" => default Vec<(T::AccountId, T::BlockNumber)>;
|
||||
// The total number of votes that have happened or are in progress.
|
||||
pub VoteCount get(vote_index): b"cou:vco" => default VoteIndex;
|
||||
// permanent state (always relevant, changes only at the finalisation of voting)
|
||||
// The current council. When there's a vote going on, this should still be used for executive
|
||||
// matters.
|
||||
pub ActiveCouncil get(active_council): default Vec<(T::AccountId, T::BlockNumber)>;
|
||||
// The total number of votes that have happened or are in progress.
|
||||
pub VoteCount get(vote_index): default VoteIndex;
|
||||
|
||||
// persistent state (always relevant, changes constantly)
|
||||
// The last cleared vote index that this voter was last active at.
|
||||
pub ApprovalsOf get(approvals_of): b"cou:apr" => default map [ T::AccountId => Vec<bool> ];
|
||||
// The vote index and list slot that the candidate `who` was registered or `None` if they are not
|
||||
// currently registered.
|
||||
pub RegisterInfoOf get(candidate_reg_info): b"cou:reg" => map [ T::AccountId => (VoteIndex, u32) ];
|
||||
// The last cleared vote index that this voter was last active at.
|
||||
pub LastActiveOf get(voter_last_active): b"cou:lac" => map [ T::AccountId => VoteIndex ];
|
||||
// The present voter list.
|
||||
pub Voters get(voters): b"cou:vrs" => default Vec<T::AccountId>;
|
||||
// The present candidate list.
|
||||
pub Candidates get(candidates): b"cou:can" => default Vec<T::AccountId>; // has holes
|
||||
pub CandidateCount get(candidate_count): b"cou:cnc" => default u32;
|
||||
// persistent state (always relevant, changes constantly)
|
||||
// The last cleared vote index that this voter was last active at.
|
||||
pub ApprovalsOf get(approvals_of): default map [ T::AccountId => Vec<bool> ];
|
||||
// The vote index and list slot that the candidate `who` was registered or `None` if they are not
|
||||
// currently registered.
|
||||
pub RegisterInfoOf get(candidate_reg_info): map [ T::AccountId => (VoteIndex, u32) ];
|
||||
// The last cleared vote index that this voter was last active at.
|
||||
pub LastActiveOf get(voter_last_active): map [ T::AccountId => VoteIndex ];
|
||||
// The present voter list.
|
||||
pub Voters get(voters): default Vec<T::AccountId>;
|
||||
// The present candidate list.
|
||||
pub Candidates get(candidates): default Vec<T::AccountId>; // has holes
|
||||
pub CandidateCount get(candidate_count): default u32;
|
||||
|
||||
// temporary state (only relevant during finalisation/presentation)
|
||||
// The accounts holding the seats that will become free on the next tally.
|
||||
pub NextFinalise get(next_finalise): b"cou:nxt" => (T::BlockNumber, u32, Vec<T::AccountId>);
|
||||
// The stakes as they were at the point that the vote ended.
|
||||
pub SnapshotedStakes get(snapshoted_stakes): b"cou:sss" => required Vec<T::Balance>;
|
||||
// Get the leaderboard if we;re in the presentation phase.
|
||||
pub Leaderboard get(leaderboard): b"cou:win" => Vec<(T::Balance, T::AccountId)>; // ORDERED low -> high
|
||||
// temporary state (only relevant during finalisation/presentation)
|
||||
// The accounts holding the seats that will become free on the next tally.
|
||||
pub NextFinalise get(next_finalise): (T::BlockNumber, u32, Vec<T::AccountId>);
|
||||
// The stakes as they were at the point that the vote ended.
|
||||
pub SnapshotedStakes get(snapshoted_stakes): required Vec<T::Balance>;
|
||||
// Get the leaderboard if we;re in the presentation phase.
|
||||
pub Leaderboard get(leaderboard): Vec<(T::Balance, T::AccountId)>; // ORDERED low -> high
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Trait> Module<T> {
|
||||
|
||||
@@ -43,15 +43,15 @@ decl_module! {
|
||||
}
|
||||
|
||||
decl_storage! {
|
||||
trait Store for Module<T: Trait>;
|
||||
|
||||
pub CooloffPeriod get(cooloff_period): b"cov:cooloff" => required T::BlockNumber;
|
||||
pub VotingPeriod get(voting_period): b"cov:period" => required T::BlockNumber;
|
||||
pub Proposals get(proposals): b"cov:prs" => required Vec<(T::BlockNumber, T::Hash)>; // ordered by expiry.
|
||||
pub ProposalOf get(proposal_of): b"cov:pro" => map [ T::Hash => T::Proposal ];
|
||||
pub ProposalVoters get(proposal_voters): b"cov:voters:" => default map [ T::Hash => Vec<T::AccountId> ];
|
||||
pub CouncilVoteOf get(vote_of): b"cov:vote:" => map [ (T::Hash, T::AccountId) => bool ];
|
||||
pub VetoedProposal get(veto_of): b"cov:veto:" => map [ T::Hash => (T::BlockNumber, Vec<T::AccountId>) ];
|
||||
trait Store for Module<T: Trait> as CouncilVoting {
|
||||
pub CooloffPeriod get(cooloff_period): required T::BlockNumber;
|
||||
pub VotingPeriod get(voting_period): required T::BlockNumber;
|
||||
pub Proposals get(proposals): required Vec<(T::BlockNumber, T::Hash)>; // ordered by expiry.
|
||||
pub ProposalOf get(proposal_of): map [ T::Hash => T::Proposal ];
|
||||
pub ProposalVoters get(proposal_voters): default map [ T::Hash => Vec<T::AccountId> ];
|
||||
pub CouncilVoteOf get(vote_of): map [ (T::Hash, T::AccountId) => bool ];
|
||||
pub VetoedProposal get(veto_of): map [ T::Hash => (T::BlockNumber, Vec<T::AccountId>) ];
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Trait> Module<T> {
|
||||
|
||||
@@ -84,34 +84,35 @@ decl_module! {
|
||||
}
|
||||
|
||||
decl_storage! {
|
||||
trait Store for Module<T: Trait>;
|
||||
trait Store for Module<T: Trait> as Democracy {
|
||||
|
||||
// The number of (public) proposals that have been made so far.
|
||||
pub PublicPropCount get(public_prop_count): b"dem:ppc" => default PropIndex;
|
||||
// The public proposals. Unsorted.
|
||||
pub PublicProps get(public_props): b"dem:pub" => default Vec<(PropIndex, T::Proposal, T::AccountId)>;
|
||||
// Those who have locked a deposit.
|
||||
pub DepositOf get(deposit_of): b"dem:dep:" => map [ PropIndex => (T::Balance, Vec<T::AccountId>) ];
|
||||
// How often (in blocks) new public referenda are launched.
|
||||
pub LaunchPeriod get(launch_period): b"dem:lau" => required T::BlockNumber;
|
||||
// The minimum amount to be used as a deposit for a public referendum proposal.
|
||||
pub MinimumDeposit get(minimum_deposit): b"dem:min" => required T::Balance;
|
||||
// The number of (public) proposals that have been made so far.
|
||||
pub PublicPropCount get(public_prop_count): default PropIndex;
|
||||
// The public proposals. Unsorted.
|
||||
pub PublicProps get(public_props): default Vec<(PropIndex, T::Proposal, T::AccountId)>;
|
||||
// Those who have locked a deposit.
|
||||
pub DepositOf get(deposit_of): map [ PropIndex => (T::Balance, Vec<T::AccountId>) ];
|
||||
// How often (in blocks) new public referenda are launched.
|
||||
pub LaunchPeriod get(launch_period): required T::BlockNumber;
|
||||
// The minimum amount to be used as a deposit for a public referendum proposal.
|
||||
pub MinimumDeposit get(minimum_deposit): required T::Balance;
|
||||
|
||||
// How often (in blocks) to check for new votes.
|
||||
pub VotingPeriod get(voting_period): b"dem:per" => required T::BlockNumber;
|
||||
// How often (in blocks) to check for new votes.
|
||||
pub VotingPeriod get(voting_period): required T::BlockNumber;
|
||||
|
||||
// The next free referendum index, aka the number of referendums started so far.
|
||||
pub ReferendumCount get(referendum_count): b"dem:rco" => required ReferendumIndex;
|
||||
// The next referendum index that should be tallied.
|
||||
pub NextTally get(next_tally): b"dem:nxt" => required ReferendumIndex;
|
||||
// Information concerning any given referendum.
|
||||
pub ReferendumInfoOf get(referendum_info): b"dem:pro:" => map [ ReferendumIndex => (T::BlockNumber, T::Proposal, VoteThreshold) ];
|
||||
// The next free referendum index, aka the number of referendums started so far.
|
||||
pub ReferendumCount get(referendum_count): required ReferendumIndex;
|
||||
// The next referendum index that should be tallied.
|
||||
pub NextTally get(next_tally): required ReferendumIndex;
|
||||
// Information concerning any given referendum.
|
||||
pub ReferendumInfoOf get(referendum_info): map [ ReferendumIndex => (T::BlockNumber, T::Proposal, VoteThreshold) ];
|
||||
|
||||
// Get the voters for the current proposal.
|
||||
pub VotersFor get(voters_for): b"dem:vtr:" => default map [ ReferendumIndex => Vec<T::AccountId> ];
|
||||
// Get the voters for the current proposal.
|
||||
pub VotersFor get(voters_for): default map [ ReferendumIndex => Vec<T::AccountId> ];
|
||||
|
||||
// Get the vote, if Some, of `who`.
|
||||
pub VoteOf get(vote_of): b"dem:vot:" => map [ (ReferendumIndex, T::AccountId) => bool ];
|
||||
// Get the vote, if Some, of `who`.
|
||||
pub VoteOf get(vote_of): map [ (ReferendumIndex, T::AccountId) => bool ];
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Trait> Module<T> {
|
||||
|
||||
@@ -336,7 +336,7 @@ mod tests {
|
||||
// Blake
|
||||
// state_root: hex!("02532989c613369596025dfcfc821339fc9861987003924913a5a1382f87034a").into(),
|
||||
// Keccak
|
||||
state_root: hex!("246ea6d86eefe3fc32f746fdcb1749a5f245570c70a04b43d08b5defac44505a").into(),
|
||||
state_root: hex!("e576ed2adacdc09b61844b5106bfaa18d2a4bfd7feb56d7af97c3421cdefca48").into(),
|
||||
extrinsics_root: hex!("56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421").into(),
|
||||
digest: Digest { logs: vec![], },
|
||||
},
|
||||
@@ -370,7 +370,7 @@ mod tests {
|
||||
header: Header {
|
||||
parent_hash: [69u8; 32].into(),
|
||||
number: 1,
|
||||
state_root: hex!("246ea6d86eefe3fc32f746fdcb1749a5f245570c70a04b43d08b5defac44505a").into(),
|
||||
state_root: hex!("e576ed2adacdc09b61844b5106bfaa18d2a4bfd7feb56d7af97c3421cdefca48").into(),
|
||||
extrinsics_root: [0u8; 32].into(),
|
||||
digest: Digest { logs: vec![], },
|
||||
},
|
||||
|
||||
@@ -103,30 +103,31 @@ impl<N> From<RawEvent<N>> for () {
|
||||
}
|
||||
|
||||
decl_storage! {
|
||||
trait Store for Module<T: Trait>;
|
||||
trait Store for Module<T: Trait> as Session {
|
||||
|
||||
// The current set of validators.
|
||||
pub Validators get(validators): b"ses:val" => required Vec<T::AccountId>;
|
||||
// Current length of the session.
|
||||
pub SessionLength get(length): b"ses:len" => required T::BlockNumber;
|
||||
// Current index of the session.
|
||||
pub CurrentIndex get(current_index): b"ses:ind" => required T::BlockNumber;
|
||||
// Timestamp when current session started.
|
||||
pub CurrentStart get(current_start): b"ses:current_start" => required T::Moment;
|
||||
// The current set of validators.
|
||||
pub Validators get(validators): required Vec<T::AccountId>;
|
||||
// Current length of the session.
|
||||
pub SessionLength get(length): required T::BlockNumber;
|
||||
// Current index of the session.
|
||||
pub CurrentIndex get(current_index): required T::BlockNumber;
|
||||
// Timestamp when current session started.
|
||||
pub CurrentStart get(current_start): required T::Moment;
|
||||
|
||||
// Opinions of the current validator set about the activeness of their peers.
|
||||
// Gets cleared when the validator set changes.
|
||||
pub BadValidators get(bad_validators): b"ses:bad_validators" => Vec<T::AccountId>;
|
||||
// Opinions of the current validator set about the activeness of their peers.
|
||||
// Gets cleared when the validator set changes.
|
||||
pub BadValidators get(bad_validators): Vec<T::AccountId>;
|
||||
|
||||
// New session is being forced is this entry exists; in which case, the boolean value is whether
|
||||
// the new session should be considered a normal rotation (rewardable) or exceptional (slashable).
|
||||
pub ForcingNewSession get(forcing_new_session): b"ses:forcing_new_session" => bool;
|
||||
// Block at which the session length last changed.
|
||||
LastLengthChange: b"ses:llc" => T::BlockNumber;
|
||||
// The next key for a given validator.
|
||||
NextKeyFor: b"ses:nxt:" => map [ T::AccountId => T::SessionKey ];
|
||||
// The next session length.
|
||||
NextSessionLength: b"ses:nln" => T::BlockNumber;
|
||||
// New session is being forced is this entry exists; in which case, the boolean value is whether
|
||||
// the new session should be considered a normal rotation (rewardable) or exceptional (slashable).
|
||||
pub ForcingNewSession get(forcing_new_session): bool;
|
||||
// Block at which the session length last changed.
|
||||
LastLengthChange: T::BlockNumber;
|
||||
// The next key for a given validator.
|
||||
NextKeyFor: map [ T::AccountId => T::SessionKey ];
|
||||
// The next session length.
|
||||
NextSessionLength: T::BlockNumber;
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Trait> Module<T> {
|
||||
|
||||
@@ -190,97 +190,98 @@ impl<B, A, I> From<RawEvent<B, A, I>> for () {
|
||||
}
|
||||
|
||||
decl_storage! {
|
||||
trait Store for Module<T: Trait>;
|
||||
trait Store for Module<T: Trait> as Staking {
|
||||
|
||||
// The length of the bonding duration in eras.
|
||||
pub BondingDuration get(bonding_duration): b"sta:loc" => required T::BlockNumber;
|
||||
// The ideal number of staking participants.
|
||||
pub ValidatorCount get(validator_count): b"sta:vac" => required u32;
|
||||
// Minimum number of staking participants before emergency conditions are imposed.
|
||||
pub MinimumValidatorCount: b"sta:minimum_validator_count" => u32;
|
||||
// The length of a staking era in sessions.
|
||||
pub SessionsPerEra get(sessions_per_era): b"sta:spe" => required T::BlockNumber;
|
||||
// The total amount of stake on the system.
|
||||
// TODO: this doesn't actually track total stake yet - it should do.
|
||||
pub TotalStake get(total_stake): b"sta:tot" => required T::Balance;
|
||||
// The fee to be paid for making a transaction; the base.
|
||||
pub TransactionBaseFee get(transaction_base_fee): b"sta:basefee" => required T::Balance;
|
||||
// The fee to be paid for making a transaction; the per-byte portion.
|
||||
pub TransactionByteFee get(transaction_byte_fee): b"sta:bytefee" => required T::Balance;
|
||||
// The minimum amount allowed to keep an account open.
|
||||
pub ExistentialDeposit get(existential_deposit): b"sta:existential_deposit" => required T::Balance;
|
||||
// The amount credited to a destination's account whose index was reclaimed.
|
||||
pub ReclaimRebate get(reclaim_rebate): b"sta:reclaim_rebate" => required T::Balance;
|
||||
// The fee required to make a transfer.
|
||||
pub TransferFee get(transfer_fee): b"sta:transfer_fee" => required T::Balance;
|
||||
// The fee required to create an account. At least as big as ReclaimRebate.
|
||||
pub CreationFee get(creation_fee): b"sta:creation_fee" => required T::Balance;
|
||||
// Maximum reward, per validator, that is provided per acceptable session.
|
||||
pub SessionReward get(session_reward): b"sta:session_reward" => required T::Balance;
|
||||
// Slash, per validator that is taken per abnormal era end.
|
||||
pub EarlyEraSlash get(early_era_slash): b"sta:early_era_slash" => required T::Balance;
|
||||
// Number of instances of offline reports before slashing begins for validators.
|
||||
pub OfflineSlashGrace get(offline_slash_grace): b"sta:offline_slash_grace" => default u32;
|
||||
// The length of the bonding duration in eras.
|
||||
pub BondingDuration get(bonding_duration): required T::BlockNumber;
|
||||
// The ideal number of staking participants.
|
||||
pub ValidatorCount get(validator_count): required u32;
|
||||
// Minimum number of staking participants before emergency conditions are imposed.
|
||||
pub MinimumValidatorCount: u32;
|
||||
// The length of a staking era in sessions.
|
||||
pub SessionsPerEra get(sessions_per_era): required T::BlockNumber;
|
||||
// The total amount of stake on the system.
|
||||
// TODO: this doesn't actually track total stake yet - it should do.
|
||||
pub TotalStake get(total_stake): required T::Balance;
|
||||
// The fee to be paid for making a transaction; the base.
|
||||
pub TransactionBaseFee get(transaction_base_fee): required T::Balance;
|
||||
// The fee to be paid for making a transaction; the per-byte portion.
|
||||
pub TransactionByteFee get(transaction_byte_fee): required T::Balance;
|
||||
// The minimum amount allowed to keep an account open.
|
||||
pub ExistentialDeposit get(existential_deposit): required T::Balance;
|
||||
// The amount credited to a destination's account whose index was reclaimed.
|
||||
pub ReclaimRebate get(reclaim_rebate): required T::Balance;
|
||||
// The fee required to make a transfer.
|
||||
pub TransferFee get(transfer_fee): required T::Balance;
|
||||
// The fee required to create an account. At least as big as ReclaimRebate.
|
||||
pub CreationFee get(creation_fee): required T::Balance;
|
||||
// Maximum reward, per validator, that is provided per acceptable session.
|
||||
pub SessionReward get(session_reward): required T::Balance;
|
||||
// Slash, per validator that is taken per abnormal era end.
|
||||
pub EarlyEraSlash get(early_era_slash): required T::Balance;
|
||||
// Number of instances of offline reports before slashing begins for validators.
|
||||
pub OfflineSlashGrace get(offline_slash_grace): default u32;
|
||||
|
||||
// The current era index.
|
||||
pub CurrentEra get(current_era): b"sta:era" => required T::BlockNumber;
|
||||
// Preference over how many times the validator should get slashed for being offline before they are automatically unstaked.
|
||||
pub SlashPreferenceOf get(slash_preference_of): b"sta:slash_preference_of" => default map [ T::AccountId => SlashPreference ];
|
||||
// All the accounts with a desire to stake.
|
||||
pub Intentions get(intentions): b"sta:wil:" => default Vec<T::AccountId>;
|
||||
// All nominator -> nominee relationships.
|
||||
pub Nominating get(nominating): b"sta:nominating" => map [ T::AccountId => T::AccountId ];
|
||||
// Nominators for a particular account.
|
||||
pub NominatorsFor get(nominators_for): b"sta:nominators_for" => default map [ T::AccountId => Vec<T::AccountId> ];
|
||||
// Nominators for a particular account that is in action right now.
|
||||
pub CurrentNominatorsFor get(current_nominators_for): b"sta:current_nominators_for" => default map [ T::AccountId => Vec<T::AccountId> ];
|
||||
// The next value of sessions per era.
|
||||
pub NextSessionsPerEra get(next_sessions_per_era): b"sta:nse" => T::BlockNumber;
|
||||
// The session index at which the era length last changed.
|
||||
pub LastEraLengthChange get(last_era_length_change): b"sta:lec" => default T::BlockNumber;
|
||||
// The current era stake threshold
|
||||
pub StakeThreshold get(stake_threshold): b"sta:stake_threshold" => required T::Balance;
|
||||
// The current era index.
|
||||
pub CurrentEra get(current_era): required T::BlockNumber;
|
||||
// Preference over how many times the validator should get slashed for being offline before they are automatically unstaked.
|
||||
pub SlashPreferenceOf get(slash_preference_of): default map [ T::AccountId => SlashPreference ];
|
||||
// All the accounts with a desire to stake.
|
||||
pub Intentions get(intentions): default Vec<T::AccountId>;
|
||||
// All nominator -> nominee relationships.
|
||||
pub Nominating get(nominating): map [ T::AccountId => T::AccountId ];
|
||||
// Nominators for a particular account.
|
||||
pub NominatorsFor get(nominators_for): default map [ T::AccountId => Vec<T::AccountId> ];
|
||||
// Nominators for a particular account that is in action right now.
|
||||
pub CurrentNominatorsFor get(current_nominators_for): default map [ T::AccountId => Vec<T::AccountId> ];
|
||||
// The next value of sessions per era.
|
||||
pub NextSessionsPerEra get(next_sessions_per_era): T::BlockNumber;
|
||||
// The session index at which the era length last changed.
|
||||
pub LastEraLengthChange get(last_era_length_change): default T::BlockNumber;
|
||||
// The current era stake threshold
|
||||
pub StakeThreshold get(stake_threshold): required T::Balance;
|
||||
|
||||
// The number of times a given validator has been reported offline. This gets decremented by one each era that passes.
|
||||
pub SlashCount get(slash_count): b"sta:slash_count" => default map [ T::AccountId => u32 ];
|
||||
// The number of times a given validator has been reported offline. This gets decremented by one each era that passes.
|
||||
pub SlashCount get(slash_count): default map [ T::AccountId => u32 ];
|
||||
|
||||
// The next free enumeration set.
|
||||
pub NextEnumSet get(next_enum_set): b"sta:next_enum" => required T::AccountIndex;
|
||||
// The enumeration sets.
|
||||
pub EnumSet get(enum_set): b"sta:enum_set" => default map [ T::AccountIndex => Vec<T::AccountId> ];
|
||||
// The next free enumeration set.
|
||||
pub NextEnumSet get(next_enum_set): required T::AccountIndex;
|
||||
// The enumeration sets.
|
||||
pub EnumSet get(enum_set): default map [ T::AccountIndex => Vec<T::AccountId> ];
|
||||
|
||||
// We are forcing a new era.
|
||||
pub ForcingNewEra get(forcing_new_era): b"sta:forcing_new_era" => ();
|
||||
// We are forcing a new era.
|
||||
pub ForcingNewEra get(forcing_new_era): ();
|
||||
|
||||
// The "free" balance of a given account.
|
||||
//
|
||||
// This is the only balance that matters in terms of most operations on tokens. It is
|
||||
// alone used to determine the balance when in the contract execution environment. When this
|
||||
// balance falls below the value of `ExistentialDeposit`, then the "current account" is
|
||||
// deleted: specifically, `Bondage` and `FreeBalance`. Furthermore, `OnFreeBalanceZero` callback
|
||||
// is invoked, giving a chance to external modules to cleanup data associated with
|
||||
// the deleted account.
|
||||
//
|
||||
// `system::AccountNonce` is also deleted if `ReservedBalance` is also zero (it also gets
|
||||
// collapsed to zero if it ever becomes less than `ExistentialDeposit`.
|
||||
pub FreeBalance get(free_balance): b"sta:bal:" => default map [ T::AccountId => T::Balance ];
|
||||
// The "free" balance of a given account.
|
||||
//
|
||||
// This is the only balance that matters in terms of most operations on tokens. It is
|
||||
// alone used to determine the balance when in the contract execution environment. When this
|
||||
// balance falls below the value of `ExistentialDeposit`, then the "current account" is
|
||||
// deleted: specifically, `Bondage` and `FreeBalance`. Furthermore, `OnFreeBalanceZero` callback
|
||||
// is invoked, giving a chance to external modules to cleanup data associated with
|
||||
// the deleted account.
|
||||
//
|
||||
// `system::AccountNonce` is also deleted if `ReservedBalance` is also zero (it also gets
|
||||
// collapsed to zero if it ever becomes less than `ExistentialDeposit`.
|
||||
pub FreeBalance get(free_balance): default map [ T::AccountId => T::Balance ];
|
||||
|
||||
// The amount of the balance of a given account that is exterally reserved; this can still get
|
||||
// slashed, but gets slashed last of all.
|
||||
//
|
||||
// This balance is a "reserve" balance that other subsystems use in order to set aside tokens
|
||||
// that are still "owned" by the account holder, but which are unspendable. This is different
|
||||
// and wholly unrelated to the `Bondage` system used for staking.
|
||||
//
|
||||
// When this balance falls below the value of `ExistentialDeposit`, then this "reserve account"
|
||||
// is deleted: specifically, `ReservedBalance`.
|
||||
//
|
||||
// `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(reserved_balance): b"sta:lbo:" => default map [ T::AccountId => T::Balance ];
|
||||
// The amount of the balance of a given account that is exterally reserved; this can still get
|
||||
// slashed, but gets slashed last of all.
|
||||
//
|
||||
// This balance is a "reserve" balance that other subsystems use in order to set aside tokens
|
||||
// that are still "owned" by the account holder, but which are unspendable. This is different
|
||||
// and wholly unrelated to the `Bondage` system used for staking.
|
||||
//
|
||||
// When this balance falls below the value of `ExistentialDeposit`, then this "reserve account"
|
||||
// is deleted: specifically, `ReservedBalance`.
|
||||
//
|
||||
// `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(reserved_balance): default map [ T::AccountId => T::Balance ];
|
||||
|
||||
// The block at which the `who`'s funds become entirely liquid.
|
||||
pub Bondage get(bondage): b"sta:bon:" => default map [ T::AccountId => T::BlockNumber ];
|
||||
// The block at which the `who`'s funds become entirely liquid.
|
||||
pub Bondage get(bondage): default map [ T::AccountId => T::BlockNumber ];
|
||||
}
|
||||
}
|
||||
|
||||
/// Whatever happened about the hint given when creating the new account.
|
||||
|
||||
@@ -108,22 +108,23 @@ pub struct EventRecord<E: Parameter + Member> {
|
||||
}
|
||||
|
||||
decl_storage! {
|
||||
trait Store for Module<T: Trait>;
|
||||
trait Store for Module<T: Trait> as System {
|
||||
|
||||
pub AccountNonce get(account_nonce): b"sys:non" => default map [ T::AccountId => T::Index ];
|
||||
pub BlockHash get(block_hash): b"sys:old" => required map [ T::BlockNumber => T::Hash ];
|
||||
pub AccountNonce get(account_nonce): default map [ T::AccountId => T::Index ];
|
||||
|
||||
ExtrinsicCount: b"sys:extrinsic_count" => u32;
|
||||
pub ExtrinsicIndex get(extrinsic_index): b"sys:xti" => u32;
|
||||
ExtrinsicData get(extrinsic_data): b"sys:xtd" => required map [ u32 => Vec<u8> ];
|
||||
RandomSeed get(random_seed): b"sys:rnd" => required T::Hash;
|
||||
// The current block number being processed. Set by `execute_block`.
|
||||
Number get(block_number): b"sys:num" => required T::BlockNumber;
|
||||
ParentHash get(parent_hash): b"sys:pha" => required T::Hash;
|
||||
ExtrinsicsRoot get(extrinsics_root): b"sys:txr" => required T::Hash;
|
||||
Digest get(digest): b"sys:dig" => default T::Digest;
|
||||
ExtrinsicCount: u32;
|
||||
pub BlockHash get(block_hash): required map [ T::BlockNumber => T::Hash ];
|
||||
pub ExtrinsicIndex get(extrinsic_index): u32;
|
||||
ExtrinsicData get(extrinsic_data): required map [ u32 => Vec<u8> ];
|
||||
RandomSeed get(random_seed): required T::Hash;
|
||||
// The current block number being processed. Set by `execute_block`.
|
||||
Number get(block_number): required T::BlockNumber;
|
||||
ParentHash get(parent_hash): required T::Hash;
|
||||
ExtrinsicsRoot get(extrinsics_root): required T::Hash;
|
||||
Digest get(digest): default T::Digest;
|
||||
|
||||
Events get(events): b"sys:events" => default Vec<EventRecord<T::Event>>;
|
||||
Events get(events): default Vec<EventRecord<T::Event>>;
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Trait> Module<T> {
|
||||
|
||||
@@ -61,13 +61,14 @@ decl_module! {
|
||||
}
|
||||
|
||||
decl_storage! {
|
||||
trait Store for Module<T: Trait>;
|
||||
pub Now get(now): b"tim:val" => required T::Moment;
|
||||
// The minimum (and advised) period between blocks.
|
||||
pub BlockPeriod get(block_period): b"tim:block_period" => required T::Moment;
|
||||
trait Store for Module<T: Trait> as Timestamp {
|
||||
pub Now get(now): required T::Moment;
|
||||
// The minimum (and advised) period between blocks.
|
||||
pub BlockPeriod get(block_period): required T::Moment;
|
||||
|
||||
// Did the timestamp get updated in this block?
|
||||
DidUpdate: b"tim:did" => default bool;
|
||||
// Did the timestamp get updated in this block?
|
||||
DidUpdate: default bool;
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Trait> Module<T> {
|
||||
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
Reference in New Issue
Block a user