mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 04:01:10 +00:00
Updates substrate to latest master (#107)
* Updates substrate to latest master * Use slot_duration and not slot * Update to latest substrate master again to have latest CLI * Rename iherent indentifier * Update after master merge
This commit is contained in:
+28
-25
@@ -11,32 +11,33 @@ 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 }
|
||||
parity-codec = "2.1"
|
||||
parity-codec-derive = "2.1"
|
||||
substrate-serializer = { git = "https://github.com/paritytech/substrate" }
|
||||
sr-std = { git = "https://github.com/paritytech/substrate" }
|
||||
sr-io = { git = "https://github.com/paritytech/substrate" }
|
||||
srml-support = { git = "https://github.com/paritytech/substrate" }
|
||||
substrate-primitives = { git = "https://github.com/paritytech/substrate" }
|
||||
substrate-client = { git = "https://github.com/paritytech/substrate" }
|
||||
parity-codec = { version = "2.2", default-features = false }
|
||||
parity-codec-derive = { version = "2.2", default-features = false }
|
||||
substrate-serializer = { git = "https://github.com/paritytech/substrate", default-features = false }
|
||||
sr-std = { git = "https://github.com/paritytech/substrate", default-features = false }
|
||||
sr-io = { git = "https://github.com/paritytech/substrate", default-features = false }
|
||||
srml-support = { git = "https://github.com/paritytech/substrate", default-features = false }
|
||||
substrate-primitives = { git = "https://github.com/paritytech/substrate", default-features = false }
|
||||
substrate-client = { git = "https://github.com/paritytech/substrate", default-features = false }
|
||||
substrate-inherents = { git = "https://github.com/paritytech/substrate", default-features = false }
|
||||
substrate-consensus-aura-primitives = { git = "https://github.com/paritytech/substrate", default-features = false }
|
||||
srml-aura = { git = "https://github.com/paritytech/substrate" }
|
||||
srml-balances = { git = "https://github.com/paritytech/substrate" }
|
||||
srml-consensus = { git = "https://github.com/paritytech/substrate" }
|
||||
srml-council = { git = "https://github.com/paritytech/substrate" }
|
||||
srml-democracy = { git = "https://github.com/paritytech/substrate" }
|
||||
srml-executive = { git = "https://github.com/paritytech/substrate" }
|
||||
srml-grandpa = { git = "https://github.com/paritytech/substrate" }
|
||||
srml-indices = { git = "https://github.com/paritytech/substrate" }
|
||||
sr-primitives = { git = "https://github.com/paritytech/substrate" }
|
||||
srml-session = { git = "https://github.com/paritytech/substrate" }
|
||||
srml-staking = { git = "https://github.com/paritytech/substrate" }
|
||||
srml-sudo = { git = "https://github.com/paritytech/substrate" }
|
||||
srml-system = { git = "https://github.com/paritytech/substrate" }
|
||||
srml-timestamp = { git = "https://github.com/paritytech/substrate" }
|
||||
srml-treasury = { git = "https://github.com/paritytech/substrate" }
|
||||
srml-upgrade-key = { git = "https://github.com/paritytech/substrate" }
|
||||
sr-version = { git = "https://github.com/paritytech/substrate" }
|
||||
srml-aura = { git = "https://github.com/paritytech/substrate", default-features = false }
|
||||
srml-balances = { git = "https://github.com/paritytech/substrate", default-features = false }
|
||||
srml-consensus = { git = "https://github.com/paritytech/substrate", default-features = false }
|
||||
srml-council = { git = "https://github.com/paritytech/substrate", default-features = false }
|
||||
srml-democracy = { git = "https://github.com/paritytech/substrate", default-features = false }
|
||||
srml-executive = { git = "https://github.com/paritytech/substrate", default-features = false }
|
||||
srml-grandpa = { git = "https://github.com/paritytech/substrate", default-features = false }
|
||||
srml-indices = { git = "https://github.com/paritytech/substrate", default-features = false }
|
||||
sr-primitives = { git = "https://github.com/paritytech/substrate", default-features = false }
|
||||
srml-session = { git = "https://github.com/paritytech/substrate", default-features = false }
|
||||
srml-staking = { git = "https://github.com/paritytech/substrate", default-features = false }
|
||||
srml-sudo = { git = "https://github.com/paritytech/substrate", default-features = false }
|
||||
srml-system = { git = "https://github.com/paritytech/substrate", default-features = false }
|
||||
srml-timestamp = { git = "https://github.com/paritytech/substrate", default-features = false }
|
||||
srml-treasury = { git = "https://github.com/paritytech/substrate", default-features = false }
|
||||
srml-upgrade-key = { git = "https://github.com/paritytech/substrate", default-features = false }
|
||||
sr-version = { git = "https://github.com/paritytech/substrate", default-features = false }
|
||||
libsecp256k1 = "0.2.1"
|
||||
tiny-keccak = "1.4.2"
|
||||
|
||||
@@ -52,6 +53,8 @@ std = [
|
||||
"parity-codec/std",
|
||||
"parity-codec-derive/std",
|
||||
"substrate-primitives/std",
|
||||
"substrate-client/std",
|
||||
"substrate-inherents/std",
|
||||
"sr-std/std",
|
||||
"sr-io/std",
|
||||
"srml-support/std",
|
||||
|
||||
+12
-58
@@ -36,10 +36,10 @@ extern crate parity_codec as codec;
|
||||
|
||||
extern crate substrate_consensus_aura_primitives as consensus_aura;
|
||||
extern crate substrate_primitives;
|
||||
extern crate substrate_inherents as inherents;
|
||||
#[macro_use]
|
||||
extern crate substrate_client as client;
|
||||
|
||||
#[macro_use]
|
||||
extern crate sr_std as rstd;
|
||||
#[cfg(test)]
|
||||
extern crate sr_io;
|
||||
@@ -80,12 +80,11 @@ use primitives::{
|
||||
parachain,
|
||||
};
|
||||
use client::{
|
||||
block_builder::api as block_builder_api,
|
||||
block_builder::api::{self as block_builder_api, InherentData, CheckInherentsResult},
|
||||
runtime_api as client_api,
|
||||
};
|
||||
use consensus_aura::api as aura_api;
|
||||
use sr_primitives::{
|
||||
ApplyResult, CheckInherentError, generic, transaction_validity::TransactionValidity,
|
||||
ApplyResult, generic, transaction_validity::TransactionValidity,
|
||||
traits::{Convert, BlakeTwo256, Block as BlockT, DigestFor, StaticLookup}
|
||||
};
|
||||
use version::RuntimeVersion;
|
||||
@@ -102,15 +101,11 @@ pub use sr_primitives::BuildStorage;
|
||||
pub use consensus::Call as ConsensusCall;
|
||||
pub use timestamp::Call as TimestampCall;
|
||||
pub use balances::Call as BalancesCall;
|
||||
pub use parachains::Call as ParachainsCall;
|
||||
pub use parachains::{Call as ParachainsCall, INHERENT_IDENTIFIER as PARACHAIN_INHERENT_IDENTIFIER};
|
||||
pub use sr_primitives::{Permill, Perbill};
|
||||
pub use timestamp::BlockPeriod;
|
||||
pub use srml_support::{StorageValue, RuntimeMetadata};
|
||||
|
||||
const TIMESTAMP_SET_POSITION: u32 = 0;
|
||||
const PARACHAINS_SET_POSITION: u32 = 1;
|
||||
const NOTE_OFFLINE_POSITION: u32 = 2; // this should be reintroduced
|
||||
|
||||
/// Runtime version.
|
||||
pub const VERSION: RuntimeVersion = RuntimeVersion {
|
||||
spec_name: create_runtime_str!("polkadot"),
|
||||
@@ -164,7 +159,6 @@ impl balances::Trait for Runtime {
|
||||
}
|
||||
|
||||
impl consensus::Trait for Runtime {
|
||||
const NOTE_OFFLINE_POSITION: u32 = NOTE_OFFLINE_POSITION;
|
||||
type Log = Log;
|
||||
type SessionKey = SessionKey;
|
||||
|
||||
@@ -174,7 +168,6 @@ impl consensus::Trait for Runtime {
|
||||
}
|
||||
|
||||
impl timestamp::Trait for Runtime {
|
||||
const TIMESTAMP_SET_POSITION: u32 = TIMESTAMP_SET_POSITION;
|
||||
type Moment = u64;
|
||||
type OnTimestampSet = Aura;
|
||||
}
|
||||
@@ -229,9 +222,7 @@ impl grandpa::Trait for Runtime {
|
||||
type Event = Event;
|
||||
}
|
||||
|
||||
impl parachains::Trait for Runtime {
|
||||
const SET_POSITION: u32 = PARACHAINS_SET_POSITION;
|
||||
}
|
||||
impl parachains::Trait for Runtime {}
|
||||
|
||||
impl upgrade_key::Trait for Runtime {
|
||||
type Event = Event;
|
||||
@@ -250,7 +241,7 @@ construct_runtime!(
|
||||
pub enum Runtime with Log(InternalLog: DigestItem<Hash, SessionKey>) where
|
||||
Block = Block,
|
||||
NodeBlock = primitives::Block,
|
||||
InherentData = primitives::InherentData
|
||||
UncheckedExtrinsic = UncheckedExtrinsic
|
||||
{
|
||||
System: system::{default, Log(ChangesTrieRoot)},
|
||||
Aura: aura::{Module},
|
||||
@@ -317,7 +308,7 @@ impl_runtime_apis! {
|
||||
}
|
||||
}
|
||||
|
||||
impl block_builder_api::BlockBuilder<Block, primitives::InherentData> for Runtime {
|
||||
impl block_builder_api::BlockBuilder<Block> for Runtime {
|
||||
fn apply_extrinsic(extrinsic: <Block as BlockT>::Extrinsic) -> ApplyResult {
|
||||
Executive::apply_extrinsic(extrinsic)
|
||||
}
|
||||
@@ -326,48 +317,12 @@ impl_runtime_apis! {
|
||||
Executive::finalise_block()
|
||||
}
|
||||
|
||||
fn inherent_extrinsics(data: primitives::InherentData) -> Vec<<Block as BlockT>::Extrinsic> {
|
||||
use sr_primitives::traits::ProvideInherent;
|
||||
|
||||
let mut inherent = Vec::new();
|
||||
|
||||
inherent.extend(
|
||||
Timestamp::create_inherent_extrinsics(data.timestamp)
|
||||
.into_iter()
|
||||
.map(|v| (v.0, UncheckedExtrinsic::new_unsigned(Call::Timestamp(v.1))))
|
||||
);
|
||||
|
||||
inherent.extend(
|
||||
Parachains::create_inherent_extrinsics(data.parachains)
|
||||
.into_iter()
|
||||
.map(|v| (v.0, UncheckedExtrinsic::new_unsigned(Call::Parachains(v.1))))
|
||||
);
|
||||
|
||||
inherent.as_mut_slice().sort_unstable_by_key(|v| v.0);
|
||||
inherent.into_iter().map(|v| v.1).collect()
|
||||
fn inherent_extrinsics(data: InherentData) -> Vec<<Block as BlockT>::Extrinsic> {
|
||||
data.create_extrinsics()
|
||||
}
|
||||
|
||||
fn check_inherents(block: Block, data: primitives::InherentData) -> Result<(), CheckInherentError> {
|
||||
let expected_slot = data.aura_expected_slot;
|
||||
|
||||
// draw timestamp out from extrinsics.
|
||||
let set_timestamp = block.extrinsics()
|
||||
.get(TIMESTAMP_SET_POSITION as usize)
|
||||
.and_then(|xt: &UncheckedExtrinsic| match xt.function {
|
||||
Call::Timestamp(TimestampCall::set(ref t)) => Some(t.clone()),
|
||||
_ => None,
|
||||
})
|
||||
.ok_or_else(|| CheckInherentError::Other("No valid timestamp in block.".into()))?;
|
||||
|
||||
// take the "worse" result of normal verification and the timestamp vs. seal
|
||||
// check.
|
||||
CheckInherentError::combine_results(
|
||||
Runtime::check_inherents(block, data),
|
||||
|| {
|
||||
Aura::verify_inherent(set_timestamp.into(), expected_slot)
|
||||
.map_err(|s| CheckInherentError::Other(s.into()))
|
||||
},
|
||||
)
|
||||
fn check_inherents(block: Block, data: InherentData) -> CheckInherentsResult {
|
||||
data.check_extrinsics(&block)
|
||||
}
|
||||
|
||||
fn random_seed() -> <Block as BlockT>::Hash {
|
||||
@@ -419,10 +374,9 @@ impl_runtime_apis! {
|
||||
}
|
||||
}
|
||||
|
||||
impl aura_api::AuraApi<Block> for Runtime {
|
||||
impl consensus_aura::AuraApi<Block> for Runtime {
|
||||
fn slot_duration() -> u64 {
|
||||
Aura::slot_duration()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -20,16 +20,15 @@ use rstd::prelude::*;
|
||||
use codec::Decode;
|
||||
|
||||
use bitvec::BigEndian;
|
||||
use sr_primitives::CheckInherentError;
|
||||
use sr_primitives::traits::{
|
||||
Extrinsic, Block as BlockT, Hash as HashT, BlakeTwo256, ProvideInherent,
|
||||
};
|
||||
use sr_primitives::traits::{Hash as HashT, BlakeTwo256};
|
||||
use primitives::parachain::{Id as ParaId, Chain, DutyRoster, AttestedCandidate, Statement};
|
||||
use {system, session};
|
||||
|
||||
use srml_support::{StorageValue, StorageMap};
|
||||
use srml_support::dispatch::Result;
|
||||
|
||||
use inherents::{ProvideInherent, InherentData, RuntimeString, MakeFatalError, InherentIdentifier};
|
||||
|
||||
#[cfg(any(feature = "std", test))]
|
||||
use sr_primitives::{self, ChildrenStorageMap};
|
||||
|
||||
@@ -38,10 +37,7 @@ use rstd::marker::PhantomData;
|
||||
|
||||
use system::ensure_inherent;
|
||||
|
||||
pub trait Trait: session::Trait {
|
||||
/// The position of the set_heads call in the block.
|
||||
const SET_POSITION: u32;
|
||||
}
|
||||
pub trait Trait: session::Trait {}
|
||||
|
||||
decl_storage! {
|
||||
trait Store for Module<T: Trait> as Parachains {
|
||||
@@ -87,11 +83,6 @@ decl_module! {
|
||||
fn set_heads(origin, heads: Vec<AttestedCandidate>) -> Result {
|
||||
ensure_inherent(origin)?;
|
||||
ensure!(!<DidUpdate<T>>::exists(), "Parachain heads must be updated only once in the block");
|
||||
ensure!(
|
||||
<system::Module<T>>::extrinsic_index() == Some(T::SET_POSITION),
|
||||
"Parachain heads update extrinsic must be at position {} in the block"
|
||||
// , T::SET_POSITION
|
||||
);
|
||||
|
||||
let active_parachains = Self::active_parachains();
|
||||
|
||||
@@ -378,34 +369,21 @@ impl<T: Trait> Module<T> {
|
||||
*/
|
||||
}
|
||||
|
||||
pub const INHERENT_IDENTIFIER: InherentIdentifier = *b"newheads";
|
||||
|
||||
pub type InherentType = Vec<AttestedCandidate>;
|
||||
|
||||
impl<T: Trait> ProvideInherent for Module<T> {
|
||||
type Inherent = Vec<AttestedCandidate>;
|
||||
type Call = Call<T>;
|
||||
type Error = MakeFatalError<RuntimeString>;
|
||||
const INHERENT_IDENTIFIER: InherentIdentifier = INHERENT_IDENTIFIER;
|
||||
|
||||
fn create_inherent_extrinsics(data: Self::Inherent) -> Vec<(u32, Self::Call)> {
|
||||
vec![(T::SET_POSITION, Call::set_heads(data))]
|
||||
}
|
||||
fn create_inherent(data: &InherentData) -> Option<Self::Call> {
|
||||
let data = data.get_data::<InherentType>(&INHERENT_IDENTIFIER)
|
||||
.expect("Parachain heads could not be decoded.")
|
||||
.expect("No parachain heads found in inherent data.");
|
||||
|
||||
fn check_inherent<Block: BlockT, F: Fn(&Block::Extrinsic) -> Option<&Self::Call>>(
|
||||
block: &Block, _data: Self::Inherent, extract_function: &F
|
||||
) -> ::rstd::result::Result<(), CheckInherentError> {
|
||||
let has_heads = block
|
||||
.extrinsics()
|
||||
.get(T::SET_POSITION as usize)
|
||||
.map_or(false, |xt| {
|
||||
xt.is_signed() == Some(false) && match extract_function(&xt) {
|
||||
Some(Call::set_heads(_)) => true,
|
||||
_ => false,
|
||||
}
|
||||
});
|
||||
|
||||
if !has_heads {
|
||||
return Err(CheckInherentError::Other(
|
||||
"No valid parachains inherent in block".into()
|
||||
));
|
||||
}
|
||||
|
||||
Ok(())
|
||||
Some(Call::set_heads(data))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -427,7 +405,6 @@ mod tests {
|
||||
#[derive(Clone, Eq, PartialEq)]
|
||||
pub struct Test;
|
||||
impl consensus::Trait for Test {
|
||||
const NOTE_OFFLINE_POSITION: u32 = 1;
|
||||
type SessionKey = SessionKey;
|
||||
type InherentOfflineReport = ();
|
||||
type Log = ::Log;
|
||||
@@ -451,13 +428,10 @@ mod tests {
|
||||
type Event = ();
|
||||
}
|
||||
impl timestamp::Trait for Test {
|
||||
const TIMESTAMP_SET_POSITION: u32 = 0;
|
||||
type Moment = u64;
|
||||
type OnTimestampSet = ();
|
||||
}
|
||||
impl Trait for Test {
|
||||
const SET_POSITION: u32 = 0;
|
||||
}
|
||||
impl Trait for Test {}
|
||||
|
||||
type Parachains = Module<Test>;
|
||||
|
||||
|
||||
Generated
+1378
-107
File diff suppressed because it is too large
Load Diff
@@ -1,43 +1,20 @@
|
||||
[package]
|
||||
name = "polkadot-runtime"
|
||||
name = "polkadot-runtime-wasm"
|
||||
version = "0.1.0"
|
||||
authors = ["Parity Technologies <admin@parity.io>"]
|
||||
|
||||
[lib]
|
||||
name = "polkadot_runtime"
|
||||
crate-type = ["cdylib"]
|
||||
|
||||
[dependencies]
|
||||
bitvec = { version = "0.8", default-features = false, features = ["alloc"] }
|
||||
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 }
|
||||
parity-codec = { version = "2.1", default-features = false }
|
||||
parity-codec-derive = { version = "2.1", default-features = false }
|
||||
substrate-primitives = { git = "https://github.com/paritytech/substrate", default-features = false }
|
||||
substrate-client = { git = "https://github.com/paritytech/substrate", default-features = false }
|
||||
substrate-consensus-aura-primitives = { git = "https://github.com/paritytech/substrate", default-features = false }
|
||||
sr-std = { git = "https://github.com/paritytech/substrate", default-features = false }
|
||||
sr-io = { git = "https://github.com/paritytech/substrate", default-features = false }
|
||||
srml-support = { git = "https://github.com/paritytech/substrate", default-features = false }
|
||||
srml-aura = { git = "https://github.com/paritytech/substrate", default-features = false }
|
||||
srml-balances = { git = "https://github.com/paritytech/substrate", default-features = false }
|
||||
srml-consensus = { git = "https://github.com/paritytech/substrate", default-features = false }
|
||||
srml-council = { git = "https://github.com/paritytech/substrate", default-features = false }
|
||||
srml-democracy = { git = "https://github.com/paritytech/substrate", default-features = false }
|
||||
srml-executive = { git = "https://github.com/paritytech/substrate", default-features = false }
|
||||
srml-grandpa = { git = "https://github.com/paritytech/substrate", default-features = false }
|
||||
srml-indices = { git = "https://github.com/paritytech/substrate", default-features = false }
|
||||
sr-primitives = { git = "https://github.com/paritytech/substrate", default-features = false }
|
||||
srml-session = { git = "https://github.com/paritytech/substrate", default-features = false }
|
||||
srml-staking = { git = "https://github.com/paritytech/substrate", default-features = false }
|
||||
srml-sudo = { git = "https://github.com/paritytech/substrate", default-features = false }
|
||||
srml-system = { git = "https://github.com/paritytech/substrate", default-features = false }
|
||||
srml-timestamp = { git = "https://github.com/paritytech/substrate", default-features = false }
|
||||
srml-treasury = { git = "https://github.com/paritytech/substrate", default-features = false }
|
||||
srml-upgrade-key = { git = "https://github.com/paritytech/substrate", default-features = false }
|
||||
sr-version = { git = "https://github.com/paritytech/substrate", default-features = false }
|
||||
libsecp256k1 = "0.2.1"
|
||||
tiny-keccak = "1.4.2"
|
||||
polkadot-runtime = { path = "..", default-features = false }
|
||||
|
||||
[features]
|
||||
default = []
|
||||
std = [
|
||||
"polkadot-runtime/std",
|
||||
]
|
||||
|
||||
[profile.release]
|
||||
panic = "abort"
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
cargo +nightly build --target=wasm32-unknown-unknown --release
|
||||
if cargo --version | grep -q "nightly"; then
|
||||
CARGO_CMD="cargo"
|
||||
else
|
||||
CARGO_CMD="cargo +nightly"
|
||||
fi
|
||||
$CARGO_CMD build --target=wasm32-unknown-unknown --release
|
||||
for i in polkadot_runtime
|
||||
do
|
||||
wasm-gc target/wasm32-unknown-unknown/release/$i.wasm target/wasm32-unknown-unknown/release/$i.compact.wasm
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
../src
|
||||
@@ -0,0 +1,22 @@
|
||||
// Copyright 2019 Parity Technologies (UK) Ltd.
|
||||
// This file is part of Polkadot.
|
||||
|
||||
// Substrate is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// Substrate is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Substrate. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
//! The Polkadot runtime reexported for WebAssembly compile.
|
||||
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
|
||||
extern crate polkadot_runtime;
|
||||
pub use polkadot_runtime::*;
|
||||
BIN
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user