diff --git a/substrate/wasm-runtime/polkadot/src/runtime/governance.rs b/substrate/wasm-runtime/polkadot/src/runtime/governance.rs index 1be0b8b03c..4f7f6d8688 100644 --- a/substrate/wasm-runtime/polkadot/src/runtime/governance.rs +++ b/substrate/wasm-runtime/polkadot/src/runtime/governance.rs @@ -31,6 +31,10 @@ use support::storage; use primitives::{AccountID, Hash, BlockNumber, Proposal}; use runtime::{staking, system, session}; +const APPROVALS_REQUIRED: &[u8] = b"gov:apr"; +const CURRENT_PROPOSAL: &[u8] = b"gov:pro"; +const APPROVAL_OF: &[u8] = b"gov:app:"; + /// The proportion of validators required for a propsal to be approved measured as the number out /// of 1000. pub fn approval_ppm_required() -> u32 { @@ -107,10 +111,6 @@ pub mod internal { } } -const APPROVALS_REQUIRED: &[u8] = b"gov:apr"; -const CURRENT_PROPOSAL: &[u8] = b"gov:pro"; -const APPROVAL_OF: &[u8] = b"gov:app:"; - #[cfg(test)] mod tests { use super::*; diff --git a/substrate/wasm-runtime/polkadot/src/runtime/session.rs b/substrate/wasm-runtime/polkadot/src/runtime/session.rs index 48cb6f42d4..0402816fdc 100644 --- a/substrate/wasm-runtime/polkadot/src/runtime/session.rs +++ b/substrate/wasm-runtime/polkadot/src/runtime/session.rs @@ -23,6 +23,18 @@ use support::{storage, StorageVec}; use primitives::{AccountID, SessionKey, BlockNumber}; use runtime::{system, staking, consensus}; +const SESSION_LENGTH: &[u8] = b"ses:len"; +const CURRENT_INDEX: &[u8] = b"ses:ind"; +const LAST_LENGTH_CHANGE: &[u8] = b"ses:llc"; +const NEXT_KEY_FOR: &[u8] = b"ses:nxt:"; +const NEXT_SESSION_LENGTH: &[u8] = b"ses:nln"; + +struct ValidatorStorageVec {} +impl StorageVec for ValidatorStorageVec { + type Item = AccountID; + const PREFIX: &'static[u8] = b"ses:val:"; +} + /// Get the current set of authorities. These are the session keys. pub fn validators() -> Vec { ValidatorStorageVec::items() @@ -93,18 +105,6 @@ pub mod internal { } } -const SESSION_LENGTH: &[u8] = b"ses:len"; -const CURRENT_INDEX: &[u8] = b"ses:ind"; -const LAST_LENGTH_CHANGE: &[u8] = b"ses:llc"; -const NEXT_KEY_FOR: &[u8] = b"ses:nxt:"; -const NEXT_SESSION_LENGTH: &[u8] = b"ses:nln"; - -struct ValidatorStorageVec {} -impl StorageVec for ValidatorStorageVec { - type Item = AccountID; - const PREFIX: &'static[u8] = b"ses:val:"; -} - /// Move onto next session: register the new authority set. fn rotate_session() { // Increment current session index. diff --git a/substrate/wasm-runtime/polkadot/src/runtime/staking.rs b/substrate/wasm-runtime/polkadot/src/runtime/staking.rs index 02644fc940..d9bb971647 100644 --- a/substrate/wasm-runtime/polkadot/src/runtime/staking.rs +++ b/substrate/wasm-runtime/polkadot/src/runtime/staking.rs @@ -29,6 +29,21 @@ pub type Balance = u64; /// The amount of bonding period left in an account. Measured in eras. pub type Bondage = u64; +struct IntentionStorageVec {} +impl StorageVec for IntentionStorageVec { + type Item = AccountID; + const PREFIX: &'static[u8] = b"sta:wil:"; +} + +const BONDING_DURATION: &[u8] = b"sta:loc"; +const VALIDATOR_COUNT: &[u8] = b"sta:vac"; +const SESSIONS_PER_ERA: &[u8] = b"sta:spe"; +const NEXT_SESSIONS_PER_ERA: &[u8] = b"sta:nse"; +const CURRENT_ERA: &[u8] = b"sta:era"; +const LAST_ERA_LENGTH_CHANGE: &[u8] = b"sta:lec"; +const BALANCE_OF: &[u8] = b"sta:bal:"; +const BONDAGE_OF: &[u8] = b"sta:bon:"; + /// The length of the bonding duration in eras. pub fn bonding_duration() -> BlockNumber { storage::get_or_default(BONDING_DURATION) @@ -149,21 +164,6 @@ pub mod internal { } } -struct IntentionStorageVec {} -impl StorageVec for IntentionStorageVec { - type Item = AccountID; - const PREFIX: &'static[u8] = b"sta:wil:"; -} - -const BONDING_DURATION: &[u8] = b"sta:loc"; -const VALIDATOR_COUNT: &[u8] = b"sta:vac"; -const SESSIONS_PER_ERA: &[u8] = b"sta:spe"; -const NEXT_SESSIONS_PER_ERA: &[u8] = b"sta:nse"; -const CURRENT_ERA: &[u8] = b"sta:era"; -const LAST_ERA_LENGTH_CHANGE: &[u8] = b"sta:lec"; -const BALANCE_OF: &[u8] = b"sta:bal:"; -const BONDAGE_OF: &[u8] = b"sta:bon:"; - /// The era has changed - enact new staking set. /// /// NOTE: This always happens immediately before a session change to ensure that new validators diff --git a/substrate/wasm-runtime/polkadot/src/runtime/system.rs b/substrate/wasm-runtime/polkadot/src/runtime/system.rs index 2dcd41c503..a6bf24718e 100644 --- a/substrate/wasm-runtime/polkadot/src/runtime/system.rs +++ b/substrate/wasm-runtime/polkadot/src/runtime/system.rs @@ -24,6 +24,9 @@ use support::{Hashable, storage, with_env}; use primitives::{Block, BlockNumber, Hash, UncheckedTransaction, TxOrder}; use runtime::{staking, session}; +const BLOCK_HASH_AT: &[u8] = b"sys:old:"; +const CODE: &[u8] = b"sys:cod"; + /// The current block number being processed. Set by `execute_block`. pub fn block_number() -> BlockNumber { with_env(|e| e.block_number) @@ -119,9 +122,6 @@ fn final_checks(_block: &Block) { }); } -const BLOCK_HASH_AT: &[u8] = b"sys:old:"; -const CODE: &[u8] = b"sys:cod"; - #[cfg(test)] mod tests { use super::*; diff --git a/substrate/wasm-runtime/polkadot/src/runtime/timestamp.rs b/substrate/wasm-runtime/polkadot/src/runtime/timestamp.rs index 01df210c5f..f0a798d112 100644 --- a/substrate/wasm-runtime/polkadot/src/runtime/timestamp.rs +++ b/substrate/wasm-runtime/polkadot/src/runtime/timestamp.rs @@ -18,6 +18,8 @@ use support::storage; +const CURRENT_TIMESTAMP: &[u8] = b"tim:val"; + /// Representation of a time. pub type Timestamp = u64; @@ -35,8 +37,6 @@ pub mod public { } } -const CURRENT_TIMESTAMP: &[u8] = b"tim:val"; - #[cfg(test)] mod tests { use super::*;