Separate out staking module into balances and payment (#629)

* Initial commit.

* Split out balances module

* Minimise Balances trait requirements

* Fix up balances, remove balances stuff from staking

* Split off and fix up staking module

* Fix executive tests

* Fix up democracy module

* make council work again

* Remove unneeded cruft from democracy

* Fix up contract module

* Fix up rest of tests

* Fix minor TODOs

* Fix tests

* Remove superfluous code

* Move offline inherents to consensus module.

Fixes #630

* Version needs Decode.

* Move Decode back

* Fix nits

* Refactor to allow custom message
This commit is contained in:
Gav Wood
2018-08-30 18:43:38 +02:00
committed by GitHub
parent 6ae3204f17
commit 8281618e50
52 changed files with 1920 additions and 1688 deletions
+2
View File
@@ -17,6 +17,7 @@ substrate-runtime-io = { path = "../../substrate/runtime-io" }
substrate-runtime-support = { path = "../../substrate/runtime-support" }
substrate-primitives = { path = "../../substrate/primitives" }
substrate-keyring = { path = "../../substrate/keyring" }
substrate-runtime-balances = { path = "../../substrate/runtime/balances" }
substrate-runtime-consensus = { path = "../../substrate/runtime/consensus" }
substrate-runtime-council = { path = "../../substrate/runtime/council" }
substrate-runtime-democracy = { path = "../../substrate/runtime/democracy" }
@@ -37,6 +38,7 @@ std = [
"substrate-runtime-std/std",
"substrate-runtime-io/std",
"substrate-runtime-support/std",
"substrate-runtime-balances/std",
"substrate-runtime-consensus/std",
"substrate-runtime-council/std",
"substrate-runtime-democracy/std",
+29 -16
View File
@@ -40,6 +40,7 @@ extern crate substrate_codec as codec;
extern crate substrate_codec_derive;
extern crate substrate_runtime_std as rstd;
extern crate substrate_runtime_balances as balances;
extern crate substrate_runtime_consensus as consensus;
extern crate substrate_runtime_council as council;
extern crate substrate_runtime_democracy as democracy;
@@ -88,6 +89,7 @@ impl HasPublicAux for Concrete {
}
impl system::Trait for Concrete {
type PublicAux = <Self as HasPublicAux>::PublicAux;
type Index = Index;
type BlockNumber = BlockNumber;
type Hash = Hash;
@@ -101,9 +103,21 @@ impl system::Trait for Concrete {
/// System module for this concrete runtime.
pub type System = system::Module<Concrete>;
impl balances::Trait for Concrete {
type Balance = Balance;
type AccountIndex = AccountIndex;
type OnFreeBalanceZero = Staking;
type EnsureAccountLiquid = Staking;
type Event = Event;
}
/// Staking module for this concrete runtime.
pub type Balances = balances::Module<Concrete>;
impl consensus::Trait for Concrete {
type PublicAux = <Self as HasPublicAux>::PublicAux;
const NOTE_OFFLINE_POSITION: u32 = 1;
type SessionKey = SessionKey;
type OnOfflineValidator = Staking;
}
/// Consensus module for this concrete runtime.
@@ -136,10 +150,6 @@ impl session::Trait for Concrete {
pub type Session = session::Module<Concrete>;
impl staking::Trait for Concrete {
const NOTE_MISSED_PROPOSAL_POSITION: u32 = 1;
type Balance = Balance;
type AccountIndex = AccountIndex;
type OnFreeBalanceZero = ();
type Event = Event;
}
@@ -162,7 +172,7 @@ pub type CouncilVoting = council::voting::Module<Concrete>;
impl_outer_event! {
pub enum Event for Concrete {
session, staking
balances, session, staking
}
}
@@ -171,9 +181,10 @@ impl_outer_dispatch! {
#[cfg_attr(feature = "std", derive(Debug, Serialize, Deserialize))]
pub enum Call where aux: <Concrete as HasPublicAux>::PublicAux {
Consensus = 0,
Session = 1,
Staking = 2,
Timestamp = 3,
Balances = 1,
Session = 2,
Staking = 3,
Timestamp = 4,
Democracy = 5,
Council = 6,
CouncilVoting = 7,
@@ -183,16 +194,17 @@ impl_outer_dispatch! {
#[cfg_attr(feature = "std", derive(Debug, Serialize, Deserialize))]
pub enum PrivCall {
Consensus = 0,
Session = 1,
Staking = 2,
Democracy = 5,
Council = 6,
CouncilVoting = 7,
Balances = 1,
Session = 2,
Staking = 3,
Democracy = 4,
Council = 5,
CouncilVoting = 6,
}
}
/// The address format for describing accounts.
pub type Address = staking::Address<Concrete>;
pub type Address = balances::Address<Concrete>;
/// Block header type as expected by this runtime.
pub type Header = generic::Header<BlockNumber, BlakeTwo256, Vec<u8>>;
/// Block type as expected by this runtime.
@@ -206,13 +218,14 @@ pub type Extrinsic = generic::Extrinsic<Address, Index, Call>;
/// Extrinsic type that is signed.
pub type BareExtrinsic = generic::Extrinsic<AccountId, Index, Call>;
/// Executive: handles dispatch to the various modules.
pub type Executive = executive::Executive<Concrete, Block, Staking, Staking,
pub type Executive = executive::Executive<Concrete, Block, Balances, Balances,
(((((), Council), Democracy), Staking), Session)>;
impl_outer_config! {
pub struct GenesisConfig for Concrete {
ConsensusConfig => consensus,
SystemConfig => system,
BalancesConfig => balances,
SessionConfig => session,
StakingConfig => staking,
DemocracyConfig => democracy,
+27 -4
View File
@@ -103,6 +103,7 @@ dependencies = [
"substrate-codec 0.1.0",
"substrate-codec-derive 0.1.0",
"substrate-primitives 0.1.0",
"substrate-runtime-balances 0.1.0",
"substrate-runtime-consensus 0.1.0",
"substrate-runtime-council 0.1.0",
"substrate-runtime-democracy 0.1.0",
@@ -639,6 +640,29 @@ dependencies = [
"wasmi 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "substrate-runtime-balances"
version = "0.1.0"
dependencies = [
"hex-literal 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.64 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_derive 1.0.64 (registry+https://github.com/rust-lang/crates.io-index)",
"substrate-codec 0.1.0",
"substrate-codec-derive 0.1.0",
"substrate-keyring 0.1.0",
"substrate-primitives 0.1.0",
"substrate-runtime-consensus 0.1.0",
"substrate-runtime-io 0.1.0",
"substrate-runtime-primitives 0.1.0",
"substrate-runtime-sandbox 0.1.0",
"substrate-runtime-session 0.1.0",
"substrate-runtime-std 0.1.0",
"substrate-runtime-support 0.1.0",
"substrate-runtime-system 0.1.0",
"substrate-runtime-timestamp 0.1.0",
]
[[package]]
name = "substrate-runtime-consensus"
version = "0.1.0"
@@ -667,12 +691,11 @@ dependencies = [
"substrate-codec 0.1.0",
"substrate-keyring 0.1.0",
"substrate-primitives 0.1.0",
"substrate-runtime-balances 0.1.0",
"substrate-runtime-consensus 0.1.0",
"substrate-runtime-democracy 0.1.0",
"substrate-runtime-io 0.1.0",
"substrate-runtime-primitives 0.1.0",
"substrate-runtime-session 0.1.0",
"substrate-runtime-staking 0.1.0",
"substrate-runtime-std 0.1.0",
"substrate-runtime-support 0.1.0",
"substrate-runtime-system 0.1.0",
@@ -689,11 +712,10 @@ dependencies = [
"substrate-codec 0.1.0",
"substrate-codec-derive 0.1.0",
"substrate-primitives 0.1.0",
"substrate-runtime-balances 0.1.0",
"substrate-runtime-consensus 0.1.0",
"substrate-runtime-io 0.1.0",
"substrate-runtime-primitives 0.1.0",
"substrate-runtime-session 0.1.0",
"substrate-runtime-staking 0.1.0",
"substrate-runtime-std 0.1.0",
"substrate-runtime-support 0.1.0",
"substrate-runtime-system 0.1.0",
@@ -791,6 +813,7 @@ dependencies = [
"substrate-codec-derive 0.1.0",
"substrate-keyring 0.1.0",
"substrate-primitives 0.1.0",
"substrate-runtime-balances 0.1.0",
"substrate-runtime-consensus 0.1.0",
"substrate-runtime-io 0.1.0",
"substrate-runtime-primitives 0.1.0",
+2
View File
@@ -15,6 +15,7 @@ substrate-primitives = { path = "../../../substrate/primitives", default-feature
substrate-runtime-std = { path = "../../../substrate/runtime-std", default-features = false }
substrate-runtime-io = { path = "../../../substrate/runtime-io", default-features = false }
substrate-runtime-support = { path = "../../../substrate/runtime-support", default-features = false }
substrate-runtime-balances = { path = "../../../substrate/runtime/balances", default-features = false }
substrate-runtime-consensus = { path = "../../../substrate/runtime/consensus", default-features = false }
substrate-runtime-council = { path = "../../../substrate/runtime/council", default-features = false }
substrate-runtime-democracy = { path = "../../../substrate/runtime/democracy", default-features = false }
@@ -36,6 +37,7 @@ std = [
"substrate-runtime-std/std",
"substrate-runtime-io/std",
"substrate-runtime-support/std",
"substrate-runtime-balances/std",
"substrate-runtime-consensus/std",
"substrate-runtime-council/std",
"substrate-runtime-democracy/std",