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
6 changes: 3 additions & 3 deletions demo/executor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ mod tests {
// Blake
// hex!("3437bf4b182ab17bb322af5c67e55f6be487a77084ad2b4e27ddac7242e4ad21").into(),
// Keccak
hex!("56c9a542e48ccf4e0821de301ea4384e87425604278b12a9db31c6d4e89ca51e").into(),
hex!("0b401681b95d04e91dbe53835867bdcb5d9e0590b54ae06bd7b347d49f9a737f").into(),
vec![BareExtrinsic {
signed: alice(),
index: 0,
Expand All @@ -273,7 +273,7 @@ mod tests {
// Blake
// hex!("741fcb660e6fa9f625fbcd993b49f6c1cc4040f5e0cc8727afdedf11fd3c464b").into(),
// Keccak
hex!("166a2593d35f2d1bc87eca8cf2e320ed06759000a02aa88e51fa85b12c6f1267").into(),
hex!("03f051dc4f588fdc713145772486a129d33c7f178c133b5801fa79c3ecca2dc9").into(),
vec![
BareExtrinsic {
signed: bob(),
Expand All @@ -296,7 +296,7 @@ mod tests {
// Blake
// hex!("2c7231a9c210a7aa4bea169d944bc4aaacd517862b244b8021236ffa7f697991").into(),
// Keccak
hex!("be186810570e437f0d803493fced9879207b064a0701fd8d68662b9563b4d33e").into(),
hex!("6e3b6aaf0be927394b520e3ebc0c34a7c26519711bc836e116e371273c3aca44").into(),
vec![BareExtrinsic {
signed: alice(),
index: 0,
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
699 changes: 351 additions & 348 deletions substrate/runtime-support/src/storage/generator.rs

Large diffs are not rendered by default.

38 changes: 19 additions & 19 deletions substrate/runtime/contract/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,25 +150,25 @@ decl_module! {
}

decl_storage! {
trait Store for Module<T: Trait>;

// 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.
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 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
Expand Down
103 changes: 52 additions & 51 deletions substrate/runtime/council/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,57 +131,58 @@ decl_module! {
}

decl_storage! {
trait Store for Module<T: Trait>;

// 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;

// 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;

// 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;

// 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
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): 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): 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): 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): (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> {
Expand Down
18 changes: 9 additions & 9 deletions substrate/runtime/council/src/voting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
Expand Down
57 changes: 29 additions & 28 deletions substrate/runtime/democracy/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,34 +84,35 @@ decl_module! {
}

decl_storage! {
trait Store for Module<T: Trait>;

// 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;

// How often (in blocks) to check for new votes.
pub VotingPeriod get(voting_period): b"dem:per" => 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) ];

// Get the voters for the current proposal.
pub VotersFor get(voters_for): b"dem:vtr:" => 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 ];
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): 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): required T::BlockNumber;

// 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): default map [ ReferendumIndex => Vec<T::AccountId> ];

// Get the vote, if Some, of `who`.
pub VoteOf get(vote_of): map [ (ReferendumIndex, T::AccountId) => bool ];
}
}

impl<T: Trait> Module<T> {
Expand Down
4 changes: 2 additions & 2 deletions substrate/runtime/executive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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![], },
},
Expand Down Expand Up @@ -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![], },
},
Expand Down
49 changes: 25 additions & 24 deletions substrate/runtime/session/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,30 +103,31 @@ impl<N> From<RawEvent<N>> for () {
}

decl_storage! {
trait Store for Module<T: Trait>;

// 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;

// 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>;

// 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;
trait Store for Module<T: Trait> as Session {

// 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): 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): 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> {
Expand Down
Loading