mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 07:01:03 +00:00
Update to latest Substrate master (#320)
* Make `collator::Network` require `Send + Sync` to make it work * Update packages * Update to latest Substrate * Make it compile and make tests work * Use `polkadot-master` * Fix CI * Remove `build.sh` from readmes * Delete old stuff * Bring one back
This commit is contained in:
committed by
André Silva
parent
d99f721540
commit
c0b065837e
@@ -84,7 +84,6 @@ test-linux-stable: &test
|
|||||||
variables:
|
variables:
|
||||||
- $DEPLOY_TAG
|
- $DEPLOY_TAG
|
||||||
script:
|
script:
|
||||||
- ./scripts/build.sh --locked
|
|
||||||
- time cargo test --all --release --verbose --locked
|
- time cargo test --all --release --verbose --locked
|
||||||
- sccache -s
|
- sccache -s
|
||||||
|
|
||||||
@@ -107,7 +106,6 @@ build-linux-release: &build
|
|||||||
tags:
|
tags:
|
||||||
- linux-docker
|
- linux-docker
|
||||||
script:
|
script:
|
||||||
- ./scripts/build.sh --locked
|
|
||||||
- time cargo build --release --verbose
|
- time cargo build --release --verbose
|
||||||
- mkdir -p ./artifacts
|
- mkdir -p ./artifacts
|
||||||
- mv ./target/release/polkadot ./artifacts/.
|
- mv ./target/release/polkadot ./artifacts/.
|
||||||
|
|||||||
Generated
+563
-552
File diff suppressed because it is too large
Load Diff
@@ -142,7 +142,6 @@ Then build the code:
|
|||||||
[source, shell]
|
[source, shell]
|
||||||
----
|
----
|
||||||
./scripts/init.sh # Install WebAssembly. Update Rust
|
./scripts/init.sh # Install WebAssembly. Update Rust
|
||||||
./scripts/build.sh # Builds the WebAssembly binaries
|
|
||||||
cargo build # Builds all native code
|
cargo build # Builds all native code
|
||||||
----
|
----
|
||||||
|
|
||||||
|
|||||||
@@ -23,5 +23,5 @@ native_executor_instance!(
|
|||||||
pub Executor,
|
pub Executor,
|
||||||
polkadot_runtime::api::dispatch,
|
polkadot_runtime::api::dispatch,
|
||||||
polkadot_runtime::native_version,
|
polkadot_runtime::native_version,
|
||||||
include_bytes!("../../runtime/wasm/target/wasm32-unknown-unknown/release/polkadot_runtime.compact.wasm")
|
polkadot_runtime::WASM_BINARY
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -33,9 +33,8 @@ use polkadot_primitives::parachain::{
|
|||||||
StructuredUnroutedIngress,
|
StructuredUnroutedIngress,
|
||||||
};
|
};
|
||||||
use substrate_network::{
|
use substrate_network::{
|
||||||
PeerId, RequestId, Context, Event, message, generic_message,
|
PeerId, RequestId, Context, StatusMessage as GenericFullStatus,
|
||||||
specialization::NetworkSpecialization as Specialization,
|
specialization::{Event, NetworkSpecialization as Specialization},
|
||||||
StatusMessage as GenericFullStatus
|
|
||||||
};
|
};
|
||||||
use self::validation::{LiveValidationSessions, RecentValidatorIds, InsertedRecentKey};
|
use self::validation::{LiveValidationSessions, RecentValidatorIds, InsertedRecentKey};
|
||||||
use self::collator_pool::{CollatorPool, Role, Action};
|
use self::collator_pool::{CollatorPool, Role, Action};
|
||||||
@@ -573,11 +572,9 @@ impl Specialization<Block> for PolkadotProtocol {
|
|||||||
&mut self,
|
&mut self,
|
||||||
ctx: &mut dyn Context<Block>,
|
ctx: &mut dyn Context<Block>,
|
||||||
who: PeerId,
|
who: PeerId,
|
||||||
message: &mut Option<message::Message<Block>>
|
message: Vec<u8>,
|
||||||
) {
|
) {
|
||||||
match message.take() {
|
match Message::decode(&mut &message[..]) {
|
||||||
Some(generic_message::Message::ChainSpecific(raw)) => {
|
|
||||||
match Message::decode(&mut raw.as_slice()) {
|
|
||||||
Some(msg) => {
|
Some(msg) => {
|
||||||
ctx.report_peer(who.clone(), benefit::VALID_FORMAT);
|
ctx.report_peer(who.clone(), benefit::VALID_FORMAT);
|
||||||
self.on_polkadot_message(ctx, who, msg)
|
self.on_polkadot_message(ctx, who, msg)
|
||||||
@@ -585,14 +582,9 @@ impl Specialization<Block> for PolkadotProtocol {
|
|||||||
None => {
|
None => {
|
||||||
trace!(target: "p_net", "Bad message from {}", who);
|
trace!(target: "p_net", "Bad message from {}", who);
|
||||||
ctx.report_peer(who, cost::INVALID_FORMAT);
|
ctx.report_peer(who, cost::INVALID_FORMAT);
|
||||||
*message = Some(generic_message::Message::ChainSpecific(raw));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Some(other) => *message = Some(other),
|
|
||||||
_ => {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn on_event(&mut self, _event: Event) { }
|
fn on_event(&mut self, _event: Event) { }
|
||||||
|
|
||||||
|
|||||||
@@ -29,9 +29,8 @@ use polkadot_primitives::parachain::{
|
|||||||
use substrate_primitives::crypto::UncheckedInto;
|
use substrate_primitives::crypto::UncheckedInto;
|
||||||
use parity_codec::Encode;
|
use parity_codec::Encode;
|
||||||
use substrate_network::{
|
use substrate_network::{
|
||||||
PeerId, Context, config::Roles,
|
PeerId, Context, config::Roles, message::generic::ConsensusMessage,
|
||||||
message::generic::ConsensusMessage,
|
specialization::NetworkSpecialization,
|
||||||
specialization::NetworkSpecialization, generic_message::Message as GenericMessage
|
|
||||||
};
|
};
|
||||||
|
|
||||||
use futures::Future;
|
use futures::Future;
|
||||||
@@ -107,7 +106,7 @@ fn make_validation_session(parent_hash: Hash, local_key: SessionKey) -> SessionP
|
|||||||
|
|
||||||
fn on_message(protocol: &mut PolkadotProtocol, ctx: &mut TestContext, from: PeerId, message: Message) {
|
fn on_message(protocol: &mut PolkadotProtocol, ctx: &mut TestContext, from: PeerId, message: Message) {
|
||||||
let encoded = message.encode();
|
let encoded = message.encode();
|
||||||
protocol.on_message(ctx, from, &mut Some(GenericMessage::ChainSpecific(encoded)));
|
protocol.on_message(ctx, from, encoded);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ rstd = { package = "sr-std", git = "https://github.com/paritytech/substrate", br
|
|||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
tiny-keccak = "1.4"
|
tiny-keccak = "1.4"
|
||||||
|
adder = { path = "../test-parachains/adder" }
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["std"]
|
default = ["std"]
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ impl Externalities for DummyExt {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const TEST_CODE: &[u8] = include_bytes!("res/adder.wasm");
|
const TEST_CODE: &[u8] = adder::WASM_BINARY;
|
||||||
|
|
||||||
fn hash_state(state: u64) -> [u8; 32] {
|
fn hash_state(state: u64) -> [u8; 32] {
|
||||||
tiny_keccak::keccak256(state.encode().as_slice())
|
tiny_keccak::keccak256(state.encode().as_slice())
|
||||||
|
|||||||
Binary file not shown.
@@ -77,6 +77,10 @@ pub type SessionKey = ed25519::Public;
|
|||||||
/// that 32 bits may be multiplied with a balance in 128 bits without worrying about overflow.
|
/// that 32 bits may be multiplied with a balance in 128 bits without worrying about overflow.
|
||||||
pub type Balance = u128;
|
pub type Balance = u128;
|
||||||
|
|
||||||
|
/// The aura crypto scheme defined via the keypair type.
|
||||||
|
#[cfg(feature = "std")]
|
||||||
|
pub type AuraPair = ed25519::Pair;
|
||||||
|
|
||||||
/// The Ed25519 pub key of an session that belongs to an Aura authority of the chain.
|
/// The Ed25519 pub key of an session that belongs to an Aura authority of the chain.
|
||||||
pub type AuraId = ed25519::Public;
|
pub type AuraId = ed25519::Public;
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ name = "polkadot-runtime"
|
|||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
authors = ["Parity Technologies <admin@parity.io>"]
|
authors = ["Parity Technologies <admin@parity.io>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
build = "build.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
bitvec = { version = "0.8", default-features = false, features = ["alloc"] }
|
bitvec = { version = "0.8", default-features = false, features = ["alloc"] }
|
||||||
@@ -46,10 +47,14 @@ libsecp256k1 = "0.2.1"
|
|||||||
tiny-keccak = "1.4.2"
|
tiny-keccak = "1.4.2"
|
||||||
keyring = { package = "substrate-keyring", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
keyring = { package = "substrate-keyring", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
||||||
substrate-trie = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
substrate-trie = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
||||||
trie-db = "0.12"
|
trie-db = "0.14"
|
||||||
|
|
||||||
|
[build-dependencies]
|
||||||
|
wasm-builder-runner = { package = "substrate-wasm-builder-runner", version = "1.0.1" }
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["std"]
|
default = ["std"]
|
||||||
|
no_std = []
|
||||||
std = [
|
std = [
|
||||||
"bitvec/std",
|
"bitvec/std",
|
||||||
"primitives/std",
|
"primitives/std",
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// Copyright 2019 Parity Technologies (UK) Ltd.
|
// Copyright 2019 Parity Technologies (UK) Ltd.
|
||||||
// This file is part of Polkadot.
|
// This file is part of Substrate.
|
||||||
|
|
||||||
// Substrate is free software: you can redistribute it and/or modify
|
// Substrate is free software: you can redistribute it and/or modify
|
||||||
// it under the terms of the GNU General Public License as published by
|
// it under the terms of the GNU General Public License as published by
|
||||||
@@ -14,8 +14,8 @@
|
|||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with Substrate. If not, see <http://www.gnu.org/licenses/>.
|
// along with Substrate. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
//! The Polkadot runtime reexported for WebAssembly compile.
|
use wasm_builder_runner::{build_current_project, WasmBuilderSource};
|
||||||
|
|
||||||
#![cfg_attr(not(feature = "std"), no_std)]
|
fn main() {
|
||||||
|
build_current_project("wasm_binary.rs", WasmBuilderSource::Crates("1.0.3"));
|
||||||
pub use polkadot_runtime::*;
|
}
|
||||||
@@ -37,11 +37,11 @@ use client::{
|
|||||||
runtime_api as client_api, impl_runtime_apis,
|
runtime_api as client_api, impl_runtime_apis,
|
||||||
};
|
};
|
||||||
use sr_primitives::{
|
use sr_primitives::{
|
||||||
ApplyResult, generic, transaction_validity::TransactionValidity, create_runtime_str,
|
ApplyResult, generic, transaction_validity::TransactionValidity, create_runtime_str, key_types,
|
||||||
traits::{BlakeTwo256, Block as BlockT, DigestFor, StaticLookup, Convert}, impl_opaque_keys
|
traits::{BlakeTwo256, Block as BlockT, DigestFor, StaticLookup, Convert}, impl_opaque_keys
|
||||||
};
|
};
|
||||||
use version::RuntimeVersion;
|
use version::RuntimeVersion;
|
||||||
use grandpa::fg_primitives::{self, ScheduledChange};
|
use grandpa::{AuthorityId as GrandpaId, fg_primitives::{self, ScheduledChange}};
|
||||||
use council::motions as council_motions;
|
use council::motions as council_motions;
|
||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
use council::seats as council_seats;
|
use council::seats as council_seats;
|
||||||
@@ -63,6 +63,10 @@ pub use sr_primitives::{Permill, Perbill};
|
|||||||
pub use timestamp::BlockPeriod;
|
pub use timestamp::BlockPeriod;
|
||||||
pub use srml_support::StorageValue;
|
pub use srml_support::StorageValue;
|
||||||
|
|
||||||
|
// Make the WASM binary available.
|
||||||
|
#[cfg(feature = "std")]
|
||||||
|
include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));
|
||||||
|
|
||||||
/// Runtime version.
|
/// Runtime version.
|
||||||
pub const VERSION: RuntimeVersion = RuntimeVersion {
|
pub const VERSION: RuntimeVersion = RuntimeVersion {
|
||||||
spec_name: create_runtime_str!("polkadot"),
|
spec_name: create_runtime_str!("polkadot"),
|
||||||
@@ -182,7 +186,10 @@ parameter_types! {
|
|||||||
|
|
||||||
type SessionHandlers = (Grandpa, Aura);
|
type SessionHandlers = (Grandpa, Aura);
|
||||||
impl_opaque_keys! {
|
impl_opaque_keys! {
|
||||||
pub struct SessionKeys(grandpa::AuthorityId, AuraId);
|
pub struct SessionKeys {
|
||||||
|
#[id(key_types::ED25519)]
|
||||||
|
pub ed25519: GrandpaId,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// NOTE: `SessionHandler` and `SessionKeys` are co-dependent: One key will be used for each handler.
|
// NOTE: `SessionHandler` and `SessionKeys` are co-dependent: One key will be used for each handler.
|
||||||
@@ -197,6 +204,14 @@ impl session::Trait for Runtime {
|
|||||||
type ShouldEndSession = session::PeriodicSessions<Period, Offset>;
|
type ShouldEndSession = session::PeriodicSessions<Period, Offset>;
|
||||||
type Event = Event;
|
type Event = Event;
|
||||||
type Keys = SessionKeys;
|
type Keys = SessionKeys;
|
||||||
|
type SelectInitialValidators = Staking;
|
||||||
|
type ValidatorId = AccountId;
|
||||||
|
type ValidatorIdOf = staking::StashOf<Self>;
|
||||||
|
}
|
||||||
|
|
||||||
|
impl session::historical::Trait for Runtime {
|
||||||
|
type FullIdentification = staking::Exposure<AccountId, Balance>;
|
||||||
|
type FullIdentificationOf = staking::ExposureOf<Self>;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Converter for currencies to votes.
|
/// Converter for currencies to votes.
|
||||||
@@ -228,6 +243,7 @@ impl staking::Trait for Runtime {
|
|||||||
type Reward = ();
|
type Reward = ();
|
||||||
type SessionsPerEra = SessionsPerEra;
|
type SessionsPerEra = SessionsPerEra;
|
||||||
type BondingDuration = BondingDuration;
|
type BondingDuration = BondingDuration;
|
||||||
|
type SessionInterface = Self;
|
||||||
}
|
}
|
||||||
|
|
||||||
parameter_types! {
|
parameter_types! {
|
||||||
@@ -333,7 +349,7 @@ impl parachains::Trait for Runtime {
|
|||||||
}
|
}
|
||||||
|
|
||||||
parameter_types!{
|
parameter_types!{
|
||||||
pub const LeasePeriod: BlockNumber = 100000;
|
pub const LeasePeriod: BlockNumber = 100_000;
|
||||||
pub const EndingPeriod: BlockNumber = 1000;
|
pub const EndingPeriod: BlockNumber = 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -865,6 +865,14 @@ mod tests {
|
|||||||
type ShouldEndSession = session::PeriodicSessions<Period, Offset>;
|
type ShouldEndSession = session::PeriodicSessions<Period, Offset>;
|
||||||
type SessionHandler = ();
|
type SessionHandler = ();
|
||||||
type Event = ();
|
type Event = ();
|
||||||
|
type SelectInitialValidators = staking::Module<Self>;
|
||||||
|
type ValidatorId = crate::AccountId;
|
||||||
|
type ValidatorIdOf = staking::StashOf<Self>;
|
||||||
|
}
|
||||||
|
|
||||||
|
impl session::historical::Trait for Test {
|
||||||
|
type FullIdentification = staking::Exposure<crate::AccountId, Balance>;
|
||||||
|
type FullIdentificationOf = staking::ExposureOf<Self>;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl timestamp::Trait for Test {
|
impl timestamp::Trait for Test {
|
||||||
@@ -914,6 +922,7 @@ mod tests {
|
|||||||
type Reward = ();
|
type Reward = ();
|
||||||
type SessionsPerEra = SessionsPerEra;
|
type SessionsPerEra = SessionsPerEra;
|
||||||
type BondingDuration = BondingDuration;
|
type BondingDuration = BondingDuration;
|
||||||
|
type SessionInterface = Self;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Trait for Test {
|
impl Trait for Test {
|
||||||
@@ -949,7 +958,6 @@ mod tests {
|
|||||||
];
|
];
|
||||||
|
|
||||||
t.extend(session::GenesisConfig::<Test>{
|
t.extend(session::GenesisConfig::<Test>{
|
||||||
validators: validator_keys.iter().map(|k| crate::AccountId::from(*k)).collect(),
|
|
||||||
keys: vec![],
|
keys: vec![],
|
||||||
}.build_storage().unwrap().0);
|
}.build_storage().unwrap().0);
|
||||||
t.extend(GenesisConfig::<Test>{
|
t.extend(GenesisConfig::<Test>{
|
||||||
|
|||||||
Generated
-3974
File diff suppressed because it is too large
Load Diff
@@ -1,25 +0,0 @@
|
|||||||
[package]
|
|
||||||
name = "polkadot-runtime-wasm"
|
|
||||||
version = "0.1.0"
|
|
||||||
authors = ["Parity Technologies <admin@parity.io>"]
|
|
||||||
edition = "2018"
|
|
||||||
|
|
||||||
[lib]
|
|
||||||
name = "polkadot_runtime"
|
|
||||||
crate-type = ["cdylib"]
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
polkadot-runtime = { path = "..", default-features = false }
|
|
||||||
|
|
||||||
[features]
|
|
||||||
default = []
|
|
||||||
std = [
|
|
||||||
"polkadot-runtime/std",
|
|
||||||
]
|
|
||||||
|
|
||||||
[profile.release]
|
|
||||||
panic = "abort"
|
|
||||||
lto = true
|
|
||||||
|
|
||||||
[workspace]
|
|
||||||
members = []
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
set -e
|
|
||||||
|
|
||||||
if cargo --version | grep -q "nightly"; then
|
|
||||||
CARGO_CMD="cargo"
|
|
||||||
else
|
|
||||||
CARGO_CMD="cargo +nightly"
|
|
||||||
fi
|
|
||||||
RUSTFLAGS="-C link-arg=--export-table" $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
|
|
||||||
done
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
# This script assumes that all pre-requisites are installed.
|
|
||||||
|
|
||||||
set -e
|
|
||||||
|
|
||||||
PROJECT_ROOT=`git rev-parse --show-toplevel`
|
|
||||||
source `dirname "$0"`/common.sh
|
|
||||||
|
|
||||||
export CARGO_INCREMENTAL=0
|
|
||||||
|
|
||||||
# Save current directory.
|
|
||||||
pushd .
|
|
||||||
|
|
||||||
cd $ROOT
|
|
||||||
|
|
||||||
for SRC in "${SRCS[@]}"
|
|
||||||
do
|
|
||||||
echo "*** Building wasm binaries in $SRC"
|
|
||||||
cd "$PROJECT_ROOT/$SRC"
|
|
||||||
|
|
||||||
./build.sh "$@"
|
|
||||||
|
|
||||||
cd - >> /dev/null
|
|
||||||
done
|
|
||||||
|
|
||||||
# Restore initial directory.
|
|
||||||
popd
|
|
||||||
@@ -24,6 +24,7 @@ client = { package = "substrate-client", git = "https://github.com/paritytech/su
|
|||||||
aura = { package = "substrate-consensus-aura", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
aura = { package = "substrate-consensus-aura", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
||||||
consensus_common = { package = "substrate-consensus-common", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
consensus_common = { package = "substrate-consensus-common", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
||||||
grandpa = { package = "substrate-finality-grandpa", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
grandpa = { package = "substrate-finality-grandpa", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
||||||
|
grandpa_primitives = { package = "substrate-finality-grandpa-primitives", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
||||||
inherents = { package = "substrate-inherents", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
inherents = { package = "substrate-inherents", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
||||||
service = { package = "substrate-service", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
service = { package = "substrate-service", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
||||||
telemetry = { package = "substrate-telemetry", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
telemetry = { package = "substrate-telemetry", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ use polkadot_primitives::{AccountId, SessionKey};
|
|||||||
use polkadot_runtime::{
|
use polkadot_runtime::{
|
||||||
GenesisConfig, CouncilSeatsConfig, DemocracyConfig, SystemConfig, AuraConfig,
|
GenesisConfig, CouncilSeatsConfig, DemocracyConfig, SystemConfig, AuraConfig,
|
||||||
SessionConfig, StakingConfig, TimestampConfig, BalancesConfig, Perbill, SessionKeys,
|
SessionConfig, StakingConfig, TimestampConfig, BalancesConfig, Perbill, SessionKeys,
|
||||||
GrandpaConfig, SudoConfig, IndicesConfig, CuratedGrandpaConfig, StakerStatus,
|
GrandpaConfig, SudoConfig, IndicesConfig, CuratedGrandpaConfig, StakerStatus, WASM_BINARY,
|
||||||
};
|
};
|
||||||
use telemetry::TelemetryEndpoints;
|
use telemetry::TelemetryEndpoints;
|
||||||
use hex_literal::hex;
|
use hex_literal::hex;
|
||||||
@@ -76,8 +76,7 @@ fn staging_testnet_config_genesis() -> GenesisConfig {
|
|||||||
|
|
||||||
GenesisConfig {
|
GenesisConfig {
|
||||||
system: Some(SystemConfig {
|
system: Some(SystemConfig {
|
||||||
// TODO: Change after Substrate 1252 is fixed (https://github.com/paritytech/substrate/issues/1252)
|
code: WASM_BINARY.to_vec(),
|
||||||
code: include_bytes!("../../runtime/wasm/target/wasm32-unknown-unknown/release/polkadot_runtime.compact.wasm").to_vec(),
|
|
||||||
changes_trie_config: Default::default(),
|
changes_trie_config: Default::default(),
|
||||||
}),
|
}),
|
||||||
balances: Some(BalancesConfig {
|
balances: Some(BalancesConfig {
|
||||||
@@ -93,10 +92,9 @@ fn staging_testnet_config_genesis() -> GenesisConfig {
|
|||||||
.collect::<Vec<_>>(),
|
.collect::<Vec<_>>(),
|
||||||
}),
|
}),
|
||||||
session: Some(SessionConfig {
|
session: Some(SessionConfig {
|
||||||
validators: initial_authorities.iter().map(|x| x.1.clone()).collect(),
|
|
||||||
keys: initial_authorities.iter().map(|x| (
|
keys: initial_authorities.iter().map(|x| (
|
||||||
x.1.clone(),
|
x.1.clone(),
|
||||||
SessionKeys(x.2.clone(), x.2.clone()),
|
SessionKeys { ed25519: x.2.clone() },
|
||||||
)).collect::<Vec<_>>(),
|
)).collect::<Vec<_>>(),
|
||||||
}),
|
}),
|
||||||
staking: Some(StakingConfig {
|
staking: Some(StakingConfig {
|
||||||
@@ -203,8 +201,7 @@ pub fn testnet_genesis(
|
|||||||
|
|
||||||
GenesisConfig {
|
GenesisConfig {
|
||||||
system: Some(SystemConfig {
|
system: Some(SystemConfig {
|
||||||
// TODO: Change after Substrate 1252 is fixed (https://github.com/paritytech/substrate/issues/1252)
|
code: WASM_BINARY.to_vec(),
|
||||||
code: include_bytes!("../../runtime/wasm/target/wasm32-unknown-unknown/release/polkadot_runtime.compact.wasm").to_vec(),
|
|
||||||
changes_trie_config: Default::default(),
|
changes_trie_config: Default::default(),
|
||||||
}),
|
}),
|
||||||
indices: Some(IndicesConfig {
|
indices: Some(IndicesConfig {
|
||||||
@@ -215,10 +212,9 @@ pub fn testnet_genesis(
|
|||||||
vesting: vec![],
|
vesting: vec![],
|
||||||
}),
|
}),
|
||||||
session: Some(SessionConfig {
|
session: Some(SessionConfig {
|
||||||
validators: initial_authorities.iter().map(|x| x.1.clone()).collect(),
|
|
||||||
keys: initial_authorities.iter().map(|x| (
|
keys: initial_authorities.iter().map(|x| (
|
||||||
x.1.clone(),
|
x.1.clone(),
|
||||||
SessionKeys(x.2.clone(), x.2.clone()),
|
SessionKeys { ed25519: x.2.clone() },
|
||||||
)).collect::<Vec<_>>(),
|
)).collect::<Vec<_>>(),
|
||||||
}),
|
}),
|
||||||
staking: Some(StakingConfig {
|
staking: Some(StakingConfig {
|
||||||
@@ -277,7 +273,16 @@ fn development_config_genesis() -> GenesisConfig {
|
|||||||
|
|
||||||
/// Development config (single validator Alice)
|
/// Development config (single validator Alice)
|
||||||
pub fn development_config() -> ChainSpec {
|
pub fn development_config() -> ChainSpec {
|
||||||
ChainSpec::from_genesis("Development", "dev", development_config_genesis, vec![], None, Some(DEFAULT_PROTOCOL_ID), None, None)
|
ChainSpec::from_genesis(
|
||||||
|
"Development",
|
||||||
|
"dev",
|
||||||
|
development_config_genesis,
|
||||||
|
vec![],
|
||||||
|
None,
|
||||||
|
Some(DEFAULT_PROTOCOL_ID),
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn local_testnet_genesis() -> GenesisConfig {
|
fn local_testnet_genesis() -> GenesisConfig {
|
||||||
@@ -293,5 +298,14 @@ fn local_testnet_genesis() -> GenesisConfig {
|
|||||||
|
|
||||||
/// Local testnet config (multivalidator Alice + Bob)
|
/// Local testnet config (multivalidator Alice + Bob)
|
||||||
pub fn local_testnet_config() -> ChainSpec {
|
pub fn local_testnet_config() -> ChainSpec {
|
||||||
ChainSpec::from_genesis("Local Testnet", "local_testnet", local_testnet_genesis, vec![], None, Some(DEFAULT_PROTOCOL_ID), None, None)
|
ChainSpec::from_genesis(
|
||||||
|
"Local Testnet",
|
||||||
|
"local_testnet",
|
||||||
|
local_testnet_genesis,
|
||||||
|
vec![],
|
||||||
|
None,
|
||||||
|
Some(DEFAULT_PROTOCOL_ID),
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
+16
-16
@@ -22,7 +22,7 @@ use client::LongestChain;
|
|||||||
use consensus_common::SelectChain;
|
use consensus_common::SelectChain;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
use polkadot_primitives::{parachain, Block, Hash, BlockId};
|
use polkadot_primitives::{parachain, Block, Hash, BlockId, AuraPair};
|
||||||
use polkadot_runtime::{GenesisConfig, RuntimeApi};
|
use polkadot_runtime::{GenesisConfig, RuntimeApi};
|
||||||
use polkadot_network::gossip::{self as network_gossip, Known};
|
use polkadot_network::gossip::{self as network_gossip, Known};
|
||||||
use primitives::{ed25519, Pair};
|
use primitives::{ed25519, Pair};
|
||||||
@@ -40,7 +40,7 @@ pub use service::config::full_version_from_strs;
|
|||||||
pub use client::{backend::Backend, runtime_api::Core as CoreApi, ExecutionStrategy};
|
pub use client::{backend::Backend, runtime_api::Core as CoreApi, ExecutionStrategy};
|
||||||
pub use polkadot_network::{PolkadotProtocol, NetworkService};
|
pub use polkadot_network::{PolkadotProtocol, NetworkService};
|
||||||
pub use polkadot_primitives::parachain::{CollatorId, ParachainHost};
|
pub use polkadot_primitives::parachain::{CollatorId, ParachainHost};
|
||||||
pub use primitives::{Blake2Hasher};
|
pub use primitives::Blake2Hasher;
|
||||||
pub use sr_primitives::traits::ProvideRuntimeApi;
|
pub use sr_primitives::traits::ProvideRuntimeApi;
|
||||||
pub use chain_spec::ChainSpec;
|
pub use chain_spec::ChainSpec;
|
||||||
|
|
||||||
@@ -163,7 +163,7 @@ service::construct_service_factory! {
|
|||||||
{ |config: FactoryFullConfiguration<Self>| {
|
{ |config: FactoryFullConfiguration<Self>| {
|
||||||
FullComponents::<Factory>::new(config)
|
FullComponents::<Factory>::new(config)
|
||||||
} },
|
} },
|
||||||
AuthoritySetup = { |mut service: Self::FullService, key: Option<Arc<ed25519::Pair>>| {
|
AuthoritySetup = { |mut service: Self::FullService| {
|
||||||
use polkadot_network::validation::ValidationNetwork;
|
use polkadot_network::validation::ValidationNetwork;
|
||||||
|
|
||||||
let (block_import, link_half) = service.config.custom.grandpa_import_setup.take()
|
let (block_import, link_half) = service.config.custom.grandpa_import_setup.take()
|
||||||
@@ -171,14 +171,14 @@ service::construct_service_factory! {
|
|||||||
|
|
||||||
// always run GRANDPA in order to sync.
|
// always run GRANDPA in order to sync.
|
||||||
{
|
{
|
||||||
let local_key = if service.config.disable_grandpa {
|
let grandpa_key = if service.config.disable_grandpa {
|
||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
key.clone()
|
service.authority_key::<grandpa_primitives::AuthorityPair>()
|
||||||
};
|
};
|
||||||
|
|
||||||
let config = grandpa::Config {
|
let config = grandpa::Config {
|
||||||
local_key,
|
local_key: grandpa_key.map(Arc::new),
|
||||||
// FIXME #1578 make this available through chainspec
|
// FIXME #1578 make this available through chainspec
|
||||||
gossip_duration: Duration::from_millis(333),
|
gossip_duration: Duration::from_millis(333),
|
||||||
justification_period: 4096,
|
justification_period: 4096,
|
||||||
@@ -220,22 +220,22 @@ service::construct_service_factory! {
|
|||||||
let mut path = PathBuf::from(service.config.database_path.clone());
|
let mut path = PathBuf::from(service.config.database_path.clone());
|
||||||
path.push("availability");
|
path.push("availability");
|
||||||
|
|
||||||
::av_store::Store::new(::av_store::Config {
|
av_store::Store::new(::av_store::Config {
|
||||||
cache_size: None,
|
cache_size: None,
|
||||||
path,
|
path,
|
||||||
})?
|
})?
|
||||||
};
|
};
|
||||||
|
|
||||||
// run authorship only if authority.
|
// run authorship only if authority.
|
||||||
let key = match key {
|
let aura_key = match service.authority_key::<AuraPair>() {
|
||||||
Some(key) => key,
|
Some(key) => Arc::new(key),
|
||||||
None => return Ok(service),
|
None => return Ok(service),
|
||||||
};
|
};
|
||||||
|
|
||||||
if service.config.custom.collating_for.is_some() {
|
if service.config.custom.collating_for.is_some() {
|
||||||
info!("The node cannot start as an authority because it is also configured\
|
info!(
|
||||||
to run as a collator.");
|
"The node cannot start as an authority because it is also configured to run as a collator."
|
||||||
|
);
|
||||||
return Ok(service);
|
return Ok(service);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -279,23 +279,23 @@ service::construct_service_factory! {
|
|||||||
service.client(),
|
service.client(),
|
||||||
polkadot_network::validation::WrappedExecutor(service.spawn_task_handle()),
|
polkadot_network::validation::WrappedExecutor(service.spawn_task_handle()),
|
||||||
);
|
);
|
||||||
let proposer_factory = ::consensus::ProposerFactory::new(
|
let proposer_factory = consensus::ProposerFactory::new(
|
||||||
client.clone(),
|
client.clone(),
|
||||||
select_chain.clone(),
|
select_chain.clone(),
|
||||||
validation_network.clone(),
|
validation_network.clone(),
|
||||||
validation_network,
|
validation_network,
|
||||||
service.transaction_pool(),
|
service.transaction_pool(),
|
||||||
Arc::new(service.spawn_task_handle()),
|
Arc::new(service.spawn_task_handle()),
|
||||||
key.clone(),
|
aura_key.clone(),
|
||||||
extrinsic_store,
|
extrinsic_store,
|
||||||
SlotDuration::get_or_compute(&*client)?,
|
SlotDuration::get_or_compute(&*client)?,
|
||||||
service.config.custom.max_block_data_size,
|
service.config.custom.max_block_data_size,
|
||||||
);
|
);
|
||||||
|
|
||||||
info!("Using authority key {}", key.public());
|
info!("Using authority key {}", aura_key.public());
|
||||||
let task = start_aura(
|
let task = start_aura(
|
||||||
SlotDuration::get_or_compute(&*client)?,
|
SlotDuration::get_or_compute(&*client)?,
|
||||||
key,
|
aura_key,
|
||||||
client.clone(),
|
client.clone(),
|
||||||
select_chain,
|
select_chain,
|
||||||
block_import,
|
block_import,
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
# Test Parachains
|
# Test Parachains
|
||||||
|
|
||||||
Each parachain consists of three parts: a `#![no_std]` library with the main execution logic, a WASM crate which wraps this logic, and a collator node.
|
Each parachain consists of three parts: a `#![no_std]` library with the main execution logic, a WASM crate which wraps this logic, and a collator node.
|
||||||
|
|
||||||
Run `build.sh` in this directory to build all registered test parachains and copy the generated WASM to the `parachain/tests/res` folder.
|
|
||||||
|
|||||||
@@ -4,8 +4,26 @@ version = "0.1.0"
|
|||||||
authors = ["Parity Technologies <admin@parity.io>"]
|
authors = ["Parity Technologies <admin@parity.io>"]
|
||||||
description = "Test parachain which adds to a number as its state transition"
|
description = "Test parachain which adds to a number as its state transition"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
build = "build.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
parachain = { package = "polkadot-parachain", path = "../../parachain/", default-features = false }
|
parachain = { package = "polkadot-parachain", path = "../../parachain/", default-features = false }
|
||||||
parity-codec = { version = "4.1", default-features = false, features = ["derive"] }
|
parity-codec = { version = "4.1", default-features = false, features = ["derive"] }
|
||||||
tiny-keccak = "1.4"
|
tiny-keccak = "1.5.0"
|
||||||
|
dlmalloc = { version = "0.1.3", features = ["global"], optional = true }
|
||||||
|
|
||||||
|
# We need to make sure the global allocator is disabled until we have support of full substrate externalities
|
||||||
|
rstd = { package = "sr-std", git = "https://github.com/paritytech/substrate", branch = "polkadot-master", default-features = false }
|
||||||
|
|
||||||
|
[build-dependencies]
|
||||||
|
wasm-builder-runner = { package = "substrate-wasm-builder-runner", version = "1.0.2" }
|
||||||
|
|
||||||
|
[features]
|
||||||
|
default = [ "std" ]
|
||||||
|
no_std = [
|
||||||
|
# We need to make sure the global allocator is disabled until we have support of full substrate externalities
|
||||||
|
"rstd/no_global_allocator",
|
||||||
|
"parachain/wasm-api",
|
||||||
|
"dlmalloc",
|
||||||
|
]
|
||||||
|
std = []
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
// Copyright 2019 Parity Technologies (UK) Ltd.
|
||||||
|
// This file is part of Substrate.
|
||||||
|
|
||||||
|
// 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/>.
|
||||||
|
|
||||||
|
use wasm_builder_runner::{build_current_project_with_rustflags, WasmBuilderSource};
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
build_current_project_with_rustflags(
|
||||||
|
"wasm_binary.rs",
|
||||||
|
WasmBuilderSource::Crates("1.0.4"),
|
||||||
|
"-C link-arg=--import-memory",
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -18,8 +18,21 @@
|
|||||||
|
|
||||||
#![no_std]
|
#![no_std]
|
||||||
|
|
||||||
|
#![cfg_attr(feature = "no_std", feature(core_intrinsics, lang_items, core_panic_info, alloc_error_handler))]
|
||||||
|
|
||||||
use parity_codec::{Encode, Decode};
|
use parity_codec::{Encode, Decode};
|
||||||
|
|
||||||
|
#[cfg(feature = "no_std")]
|
||||||
|
mod wasm_validation;
|
||||||
|
|
||||||
|
#[cfg(feature = "no_std")]
|
||||||
|
#[global_allocator]
|
||||||
|
static ALLOC: dlmalloc::GlobalDlmalloc = dlmalloc::GlobalDlmalloc;
|
||||||
|
|
||||||
|
// Make the WASM binary available.
|
||||||
|
#[cfg(feature = "std")]
|
||||||
|
include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));
|
||||||
|
|
||||||
/// Head data for this parachain.
|
/// Head data for this parachain.
|
||||||
#[derive(Default, Clone, Hash, Eq, PartialEq, Encode, Decode)]
|
#[derive(Default, Clone, Hash, Eq, PartialEq, Encode, Decode)]
|
||||||
pub struct HeadData {
|
pub struct HeadData {
|
||||||
|
|||||||
+4
-11
@@ -1,4 +1,4 @@
|
|||||||
// Copyright 2017 Parity Technologies (UK) Ltd.
|
// Copyright 2019 Parity Technologies (UK) Ltd.
|
||||||
// This file is part of Polkadot.
|
// This file is part of Polkadot.
|
||||||
|
|
||||||
// Polkadot is free software: you can redistribute it and/or modify
|
// Polkadot is free software: you can redistribute it and/or modify
|
||||||
@@ -16,17 +16,10 @@
|
|||||||
|
|
||||||
//! WASM validation for adder parachain.
|
//! WASM validation for adder parachain.
|
||||||
|
|
||||||
#![no_std]
|
use crate::{HeadData, BlockData};
|
||||||
|
|
||||||
#![feature(core_intrinsics, lang_items, core_panic_info, alloc_error_handler)]
|
|
||||||
|
|
||||||
#[global_allocator]
|
|
||||||
static ALLOC: dlmalloc::GlobalDlmalloc = dlmalloc::GlobalDlmalloc;
|
|
||||||
|
|
||||||
use core::{intrinsics, panic};
|
use core::{intrinsics, panic};
|
||||||
use parachain::ValidationResult;
|
use parachain::ValidationResult;
|
||||||
use parachain::codec::{Encode, Decode};
|
use parachain::codec::{Encode, Decode};
|
||||||
use adder::{HeadData, BlockData};
|
|
||||||
|
|
||||||
#[panic_handler]
|
#[panic_handler]
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
@@ -57,11 +50,11 @@ pub extern fn validate_block(params: *const u8, len: usize) -> usize {
|
|||||||
|
|
||||||
// we also add based on incoming data from messages. ignoring unknown message
|
// we also add based on incoming data from messages. ignoring unknown message
|
||||||
// kinds.
|
// kinds.
|
||||||
let from_messages = adder::process_messages(
|
let from_messages = crate::process_messages(
|
||||||
params.ingress.iter().map(|incoming| &incoming.data[..])
|
params.ingress.iter().map(|incoming| &incoming.data[..])
|
||||||
);
|
);
|
||||||
|
|
||||||
match adder::execute(parent_hash, parent_head, &block_data, from_messages) {
|
match crate::execute(parent_hash, parent_head, &block_data, from_messages) {
|
||||||
Ok(new_head) => parachain::wasm_api::write_result(
|
Ok(new_head) => parachain::wasm_api::write_result(
|
||||||
ValidationResult { head_data: new_head.encode() }
|
ValidationResult { head_data: new_head.encode() }
|
||||||
),
|
),
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
[package]
|
|
||||||
name = "adder-wasm"
|
|
||||||
version = "0.1.0"
|
|
||||||
authors = ["Parity Technologies <admin@parity.io>"]
|
|
||||||
edition = "2018"
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
adder = { path = ".." }
|
|
||||||
parachain = { package = "polkadot-parachain", path = "../../../parachain", default-features = false, features = ["wasm-api"] }
|
|
||||||
tiny-keccak = "1.4"
|
|
||||||
dlmalloc = { version = "0.1.3", features = ["global"] }
|
|
||||||
|
|
||||||
# We need to make sure the global allocator is disabled until we have support of full substrate externalities
|
|
||||||
rstd = { package = "sr-std", git = "https://github.com/paritytech/substrate", branch = "polkadot-master", default-features = false, features = [ "no_global_allocator" ] }
|
|
||||||
|
|
||||||
[lib]
|
|
||||||
crate-type = ["cdylib"]
|
|
||||||
|
|
||||||
[profile.release]
|
|
||||||
panic = "abort"
|
|
||||||
lto = true
|
|
||||||
|
|
||||||
[workspace]
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
set -e
|
|
||||||
|
|
||||||
# Make LLD produce a binary that imports memory from the outside environment.
|
|
||||||
export RUSTFLAGS="-C link-arg=--import-memory -C link-arg=--export-table -C panic=abort"
|
|
||||||
|
|
||||||
if cargo --version | grep -q "nightly"; then
|
|
||||||
CARGO_CMD="cargo"
|
|
||||||
else
|
|
||||||
CARGO_CMD="cargo +nightly"
|
|
||||||
fi
|
|
||||||
|
|
||||||
for i in adder
|
|
||||||
do
|
|
||||||
cd $i/wasm
|
|
||||||
$CARGO_CMD build --target=wasm32-unknown-unknown --release --no-default-features --target-dir target "$@"
|
|
||||||
wasm-gc target/wasm32-unknown-unknown/release/$i'_'wasm.wasm target/wasm32-unknown-unknown/release/$i.wasm
|
|
||||||
cp target/wasm32-unknown-unknown/release/$i.wasm ../../../parachain/tests/res/
|
|
||||||
rm -rf target
|
|
||||||
cd ../..
|
|
||||||
done
|
|
||||||
Reference in New Issue
Block a user