mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-19 08:45:41 +00:00
Fix up polkadot runtime
This commit is contained in:
+21
-17
@@ -10,23 +10,25 @@ serde = { version = "1.0", default_features = false }
|
||||
serde_derive = { version = "1.0", optional = true }
|
||||
safe-mix = { version = "1.0", default_features = false}
|
||||
polkadot-primitives = { path = "../primitives", default_features = false }
|
||||
substrate-codec = { git = "https://github.com/paritytech/substrate" }
|
||||
substrate-serializer = { git = "https://github.com/paritytech/substrate" }
|
||||
substrate-runtime-std = { git = "https://github.com/paritytech/substrate" }
|
||||
substrate-runtime-io = { git = "https://github.com/paritytech/substrate" }
|
||||
substrate-runtime-support = { git = "https://github.com/paritytech/substrate" }
|
||||
substrate-primitives = { git = "https://github.com/paritytech/substrate" }
|
||||
substrate-keyring = { git = "https://github.com/paritytech/substrate" }
|
||||
substrate-runtime-consensus = { git = "https://github.com/paritytech/substrate" }
|
||||
substrate-runtime-council = { git = "https://github.com/paritytech/substrate" }
|
||||
substrate-runtime-democracy = { git = "https://github.com/paritytech/substrate" }
|
||||
substrate-runtime-executive = { git = "https://github.com/paritytech/substrate" }
|
||||
substrate-runtime-primitives = { git = "https://github.com/paritytech/substrate" }
|
||||
substrate-runtime-session = { git = "https://github.com/paritytech/substrate" }
|
||||
substrate-runtime-staking = { git = "https://github.com/paritytech/substrate" }
|
||||
substrate-runtime-system = { git = "https://github.com/paritytech/substrate" }
|
||||
substrate-runtime-timestamp = { git = "https://github.com/paritytech/substrate" }
|
||||
substrate-runtime-version = { git = "https://github.com/paritytech/substrate" }
|
||||
substrate-codec = { git = "https://github.com/paritytech/substrate", branch = "polkadot" }
|
||||
substrate-codec-derive = { git = "https://github.com/paritytech/substrate", branch = "polkadot" }
|
||||
substrate-serializer = { git = "https://github.com/paritytech/substrate", branch = "polkadot" }
|
||||
substrate-runtime-std = { git = "https://github.com/paritytech/substrate", branch = "polkadot" }
|
||||
substrate-runtime-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot" }
|
||||
substrate-runtime-support = { git = "https://github.com/paritytech/substrate", branch = "polkadot" }
|
||||
substrate-primitives = { git = "https://github.com/paritytech/substrate", branch = "polkadot" }
|
||||
substrate-keyring = { git = "https://github.com/paritytech/substrate", branch = "polkadot" }
|
||||
substrate-runtime-balances = { git = "https://github.com/paritytech/substrate", branch = "polkadot" }
|
||||
substrate-runtime-consensus = { git = "https://github.com/paritytech/substrate", branch = "polkadot" }
|
||||
substrate-runtime-council = { git = "https://github.com/paritytech/substrate", branch = "polkadot" }
|
||||
substrate-runtime-democracy = { git = "https://github.com/paritytech/substrate", branch = "polkadot" }
|
||||
substrate-runtime-executive = { git = "https://github.com/paritytech/substrate", branch = "polkadot" }
|
||||
substrate-runtime-primitives = { git = "https://github.com/paritytech/substrate", branch = "polkadot" }
|
||||
substrate-runtime-session = { git = "https://github.com/paritytech/substrate", branch = "polkadot" }
|
||||
substrate-runtime-staking = { git = "https://github.com/paritytech/substrate", branch = "polkadot" }
|
||||
substrate-runtime-system = { git = "https://github.com/paritytech/substrate", branch = "polkadot" }
|
||||
substrate-runtime-timestamp = { git = "https://github.com/paritytech/substrate", branch = "polkadot" }
|
||||
substrate-runtime-version = { git = "https://github.com/paritytech/substrate", branch = "polkadot" }
|
||||
|
||||
[dev-dependencies]
|
||||
hex-literal = "0.1.0"
|
||||
@@ -36,10 +38,12 @@ default = ["std"]
|
||||
std = [
|
||||
"polkadot-primitives/std",
|
||||
"substrate-codec/std",
|
||||
"substrate-codec-derive/std",
|
||||
"substrate-primitives/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",
|
||||
|
||||
@@ -16,10 +16,10 @@
|
||||
|
||||
//! Typesafe block interaction.
|
||||
|
||||
use super::{Call, Block, TIMESTAMP_SET_POSITION, PARACHAINS_SET_POSITION, NOTE_OFFLINE_POSITION};
|
||||
use super::{Call, Block, TIMESTAMP_SET_POSITION, PARACHAINS_SET_POSITION, NOTE_MISSED_PROPOSAL_POSITION};
|
||||
use timestamp::Call as TimestampCall;
|
||||
use parachains::Call as ParachainsCall;
|
||||
use session::Call as SessionCall;
|
||||
use staking::Call as StakingCall;
|
||||
use primitives::parachain::CandidateReceipt;
|
||||
|
||||
/// Provides a type-safe wrapper around a structurally valid block.
|
||||
@@ -90,10 +90,10 @@ impl CheckedBlock {
|
||||
}
|
||||
}
|
||||
|
||||
/// Extract the noted offline validator indices (if any) from the block.
|
||||
pub fn noted_offline(&self) -> &[u32] {
|
||||
self.inner.extrinsics.get(NOTE_OFFLINE_POSITION as usize).and_then(|xt| match xt.extrinsic.function {
|
||||
Call::Session(SessionCall::note_offline(ref x)) => Some(&x[..]),
|
||||
/// Extract the noted missed proposal validator indices (if any) from the block.
|
||||
pub fn noted_missed_proposal(&self) -> &[u32] {
|
||||
self.inner.extrinsics.get(NOTE_MISSED_PROPOSAL_POSITION as usize).and_then(|xt| match xt.extrinsic.function {
|
||||
Call::Staking(StakingCall::note_missed_proposal(ref x)) => Some(&x[..]),
|
||||
_ => None,
|
||||
}).unwrap_or(&[])
|
||||
}
|
||||
|
||||
+36
-14
@@ -45,9 +45,12 @@ extern crate substrate_primitives;
|
||||
|
||||
#[macro_use]
|
||||
extern crate substrate_runtime_std as rstd;
|
||||
#[macro_use]
|
||||
extern crate substrate_codec_derive;
|
||||
|
||||
extern crate polkadot_primitives as primitives;
|
||||
extern crate substrate_codec as codec;
|
||||
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;
|
||||
@@ -67,7 +70,7 @@ mod utils;
|
||||
#[cfg(feature = "std")]
|
||||
pub use checked_block::CheckedBlock;
|
||||
pub use utils::{inherent_extrinsics, check_extrinsic};
|
||||
pub use staking::address::Address as RawAddress;
|
||||
pub use balances::address::Address as RawAddress;
|
||||
|
||||
use primitives::{AccountId, AccountIndex, Balance, BlockNumber, Hash, Index, Log, SessionKey, Signature};
|
||||
use runtime_primitives::{generic, traits::{HasPublicAux, BlakeTwo256, Convert}};
|
||||
@@ -85,11 +88,11 @@ pub use primitives::Header;
|
||||
pub const TIMESTAMP_SET_POSITION: u32 = 0;
|
||||
/// The position of the parachains set extrinsic.
|
||||
pub const PARACHAINS_SET_POSITION: u32 = 1;
|
||||
/// The position of the offline nodes noting extrinsic.
|
||||
pub const NOTE_OFFLINE_POSITION: u32 = 2;
|
||||
/// The position of the note_missed_proposal extrinsic in the block, if it exists.
|
||||
pub const NOTE_MISSED_PROPOSAL_POSITION: u32 = 2;
|
||||
|
||||
/// The address format for describing accounts.
|
||||
pub type Address = staking::Address<Concrete>;
|
||||
pub type Address = balances::Address<Concrete>;
|
||||
/// Block Id type for this block.
|
||||
pub type BlockId = generic::BlockId<Block>;
|
||||
/// Unchecked extrinsic type as expected by this runtime.
|
||||
@@ -136,10 +139,21 @@ impl system::Trait for Concrete {
|
||||
type Digest = generic::Digest<Log>;
|
||||
type AccountId = AccountId;
|
||||
type Header = Header;
|
||||
type Event = Event;
|
||||
}
|
||||
/// 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 IsAccountLiquid = Staking;
|
||||
type Event = Event;
|
||||
}
|
||||
/// Staking module for this concrete runtime.
|
||||
pub type Balances = balances::Module<Concrete>;
|
||||
|
||||
impl consensus::Trait for Concrete {
|
||||
type SessionKey = SessionKey;
|
||||
}
|
||||
@@ -162,17 +176,16 @@ impl Convert<AccountId, SessionKey> for SessionKeyConversion {
|
||||
}
|
||||
|
||||
impl session::Trait for Concrete {
|
||||
const NOTE_OFFLINE_POSITION: u32 = NOTE_OFFLINE_POSITION;
|
||||
type ConvertAccountIdToSessionKey = SessionKeyConversion;
|
||||
type OnSessionChange = Staking;
|
||||
type Event = Event;
|
||||
}
|
||||
/// Session module for this concrete runtime.
|
||||
pub type Session = session::Module<Concrete>;
|
||||
|
||||
impl staking::Trait for Concrete {
|
||||
type Balance = Balance;
|
||||
type AccountIndex = AccountIndex;
|
||||
type OnAccountKill = ();
|
||||
const NOTE_MISSED_PROPOSAL_POSITION: u32 = NOTE_MISSED_PROPOSAL_POSITION;
|
||||
type Event = Event;
|
||||
}
|
||||
/// Staking module for this concrete runtime.
|
||||
pub type Staking = staking::Module<Concrete>;
|
||||
@@ -196,15 +209,22 @@ impl parachains::Trait for Concrete {
|
||||
}
|
||||
pub type Parachains = parachains::Module<Concrete>;
|
||||
|
||||
impl_outer_event! {
|
||||
pub enum Event for Concrete {
|
||||
balances, session, staking
|
||||
}
|
||||
}
|
||||
|
||||
impl_outer_dispatch! {
|
||||
/// Call type for polkadot transactions.
|
||||
#[derive(Clone, PartialEq, Eq)]
|
||||
#[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,
|
||||
@@ -216,8 +236,9 @@ impl_outer_dispatch! {
|
||||
#[cfg_attr(feature = "std", derive(Debug, Serialize, Deserialize))]
|
||||
pub enum PrivCall {
|
||||
Consensus = 0,
|
||||
Session = 1,
|
||||
Staking = 2,
|
||||
Balances = 1,
|
||||
Session = 2,
|
||||
Staking = 3,
|
||||
Democracy = 5,
|
||||
Council = 6,
|
||||
CouncilVoting = 7,
|
||||
@@ -226,13 +247,14 @@ impl_outer_dispatch! {
|
||||
}
|
||||
|
||||
/// 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,
|
||||
(((((((), Parachains), Council), Democracy), Staking), Session), Timestamp)>;
|
||||
|
||||
impl_outer_config! {
|
||||
pub struct GenesisConfig for Concrete {
|
||||
ConsensusConfig => consensus,
|
||||
SystemConfig => system,
|
||||
BaalncesConfig => balances,
|
||||
SessionConfig => session,
|
||||
StakingConfig => staking,
|
||||
DemocracyConfig => democracy,
|
||||
|
||||
@@ -158,7 +158,7 @@ impl<T: Trait> Module<T> {
|
||||
ensure!(aux.is_empty(), "set_heads must not be signed");
|
||||
ensure!(!<DidUpdate<T>>::exists(), "Parachain heads must be updated only once in the block");
|
||||
ensure!(
|
||||
<system::Module<T>>::extrinsic_index() == T::SET_POSITION,
|
||||
<system::Module<T>>::extrinsic_index() == Some(T::SET_POSITION),
|
||||
"Parachain heads update extrinsic must be at position {} in the block"
|
||||
// , T::SET_POSITION
|
||||
);
|
||||
|
||||
@@ -17,11 +17,11 @@
|
||||
//! Utils for block interaction.
|
||||
|
||||
use rstd::prelude::*;
|
||||
use super::{Call, UncheckedExtrinsic, Extrinsic, Staking};
|
||||
use super::{Call, UncheckedExtrinsic, Extrinsic, Balances};
|
||||
use runtime_primitives::traits::{Checkable, AuxLookup};
|
||||
use timestamp::Call as TimestampCall;
|
||||
use parachains::Call as ParachainsCall;
|
||||
use session::Call as SessionCall;
|
||||
use staking::Call as StakingCall;
|
||||
|
||||
/// Produces the list of inherent extrinsics.
|
||||
pub fn inherent_extrinsics(data: ::primitives::InherentData) -> Vec<UncheckedExtrinsic> {
|
||||
@@ -41,7 +41,7 @@ pub fn inherent_extrinsics(data: ::primitives::InherentData) -> Vec<UncheckedExt
|
||||
|
||||
if !data.offline_indices.is_empty() {
|
||||
inherent.push(make_inherent(
|
||||
Call::Session(SessionCall::note_offline(data.offline_indices))
|
||||
Call::Staking(StakingCall::note_missed_proposal(data.offline_indices))
|
||||
));
|
||||
}
|
||||
|
||||
@@ -50,5 +50,5 @@ pub fn inherent_extrinsics(data: ::primitives::InherentData) -> Vec<UncheckedExt
|
||||
|
||||
/// Checks an unchecked extrinsic for validity.
|
||||
pub fn check_extrinsic(xt: UncheckedExtrinsic) -> bool {
|
||||
xt.check_with(Staking::lookup).is_ok()
|
||||
xt.check_with(Balances::lookup).is_ok()
|
||||
}
|
||||
|
||||
@@ -10,21 +10,21 @@ crate-type = ["cdylib"]
|
||||
integer-sqrt = { git = "https://github.com/paritytech/integer-sqrt-rs.git", branch = "master" }
|
||||
polkadot-primitives = { path = "../../primitives", default-features = false }
|
||||
safe-mix = { version = "1.0", default-features = false }
|
||||
substrate-codec = { git = "https://github.com/paritytech/substrate", default-features = false }
|
||||
substrate-primitives = { git = "https://github.com/paritytech/substrate", default-features = false }
|
||||
substrate-runtime-std = { git = "https://github.com/paritytech/substrate", default-features = false }
|
||||
substrate-runtime-io = { git = "https://github.com/paritytech/substrate", default-features = false }
|
||||
substrate-runtime-support = { git = "https://github.com/paritytech/substrate", default-features = false }
|
||||
substrate-runtime-consensus = { git = "https://github.com/paritytech/substrate", default-features = false }
|
||||
substrate-runtime-council = { git = "https://github.com/paritytech/substrate", default-features = false }
|
||||
substrate-runtime-democracy = { git = "https://github.com/paritytech/substrate", default-features = false }
|
||||
substrate-runtime-executive = { git = "https://github.com/paritytech/substrate", default-features = false }
|
||||
substrate-runtime-primitives = { git = "https://github.com/paritytech/substrate", default-features = false }
|
||||
substrate-runtime-session = { git = "https://github.com/paritytech/substrate", default-features = false }
|
||||
substrate-runtime-staking = { git = "https://github.com/paritytech/substrate", default-features = false }
|
||||
substrate-runtime-system = { git = "https://github.com/paritytech/substrate", default-features = false }
|
||||
substrate-runtime-timestamp = { git = "https://github.com/paritytech/substrate", default-features = false }
|
||||
substrate-runtime-version = { git = "https://github.com/paritytech/substrate", default-features = false }
|
||||
substrate-codec = { git = "https://github.com/paritytech/substrate", branch = "polkadot", default-features = false }
|
||||
substrate-primitives = { git = "https://github.com/paritytech/substrate", branch = "polkadot", default-features = false }
|
||||
substrate-runtime-std = { git = "https://github.com/paritytech/substrate", branch = "polkadot", default-features = false }
|
||||
substrate-runtime-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot", default-features = false }
|
||||
substrate-runtime-support = { git = "https://github.com/paritytech/substrate", branch = "polkadot", default-features = false }
|
||||
substrate-runtime-consensus = { git = "https://github.com/paritytech/substrate", branch = "polkadot", default-features = false }
|
||||
substrate-runtime-council = { git = "https://github.com/paritytech/substrate", branch = "polkadot", default-features = false }
|
||||
substrate-runtime-democracy = { git = "https://github.com/paritytech/substrate", branch = "polkadot", default-features = false }
|
||||
substrate-runtime-executive = { git = "https://github.com/paritytech/substrate", branch = "polkadot", default-features = false }
|
||||
substrate-runtime-primitives = { git = "https://github.com/paritytech/substrate", branch = "polkadot", default-features = false }
|
||||
substrate-runtime-session = { git = "https://github.com/paritytech/substrate", branch = "polkadot", default-features = false }
|
||||
substrate-runtime-staking = { git = "https://github.com/paritytech/substrate", branch = "polkadot", default-features = false }
|
||||
substrate-runtime-system = { git = "https://github.com/paritytech/substrate", branch = "polkadot", default-features = false }
|
||||
substrate-runtime-timestamp = { git = "https://github.com/paritytech/substrate", branch = "polkadot", default-features = false }
|
||||
substrate-runtime-version = { git = "https://github.com/paritytech/substrate", branch = "polkadot", default-features = false }
|
||||
|
||||
[features]
|
||||
default = []
|
||||
|
||||
Reference in New Issue
Block a user