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:
Bastian Köcher
2019-07-09 16:33:49 +02:00
committed by André Silva
parent d99f721540
commit c0b065837e
28 changed files with 728 additions and 4717 deletions
-2
View File
@@ -84,7 +84,6 @@ test-linux-stable: &test
variables:
- $DEPLOY_TAG
script:
- ./scripts/build.sh --locked
- time cargo test --all --release --verbose --locked
- sccache -s
@@ -107,7 +106,6 @@ build-linux-release: &build
tags:
- linux-docker
script:
- ./scripts/build.sh --locked
- time cargo build --release --verbose
- mkdir -p ./artifacts
- mv ./target/release/polkadot ./artifacts/.
+563 -552
View File
File diff suppressed because it is too large Load Diff
-1
View File
@@ -142,7 +142,6 @@ Then build the code:
[source, shell]
----
./scripts/init.sh # Install WebAssembly. Update Rust
./scripts/build.sh # Builds the WebAssembly binaries
cargo build # Builds all native code
----
+1 -1
View File
@@ -23,5 +23,5 @@ native_executor_instance!(
pub Executor,
polkadot_runtime::api::dispatch,
polkadot_runtime::native_version,
include_bytes!("../../runtime/wasm/target/wasm32-unknown-unknown/release/polkadot_runtime.compact.wasm")
polkadot_runtime::WASM_BINARY
);
+11 -19
View File
@@ -33,9 +33,8 @@ use polkadot_primitives::parachain::{
StructuredUnroutedIngress,
};
use substrate_network::{
PeerId, RequestId, Context, Event, message, generic_message,
specialization::NetworkSpecialization as Specialization,
StatusMessage as GenericFullStatus
PeerId, RequestId, Context, StatusMessage as GenericFullStatus,
specialization::{Event, NetworkSpecialization as Specialization},
};
use self::validation::{LiveValidationSessions, RecentValidatorIds, InsertedRecentKey};
use self::collator_pool::{CollatorPool, Role, Action};
@@ -573,24 +572,17 @@ impl Specialization<Block> for PolkadotProtocol {
&mut self,
ctx: &mut dyn Context<Block>,
who: PeerId,
message: &mut Option<message::Message<Block>>
message: Vec<u8>,
) {
match message.take() {
Some(generic_message::Message::ChainSpecific(raw)) => {
match Message::decode(&mut raw.as_slice()) {
Some(msg) => {
ctx.report_peer(who.clone(), benefit::VALID_FORMAT);
self.on_polkadot_message(ctx, who, msg)
},
None => {
trace!(target: "p_net", "Bad message from {}", who);
ctx.report_peer(who, cost::INVALID_FORMAT);
*message = Some(generic_message::Message::ChainSpecific(raw));
}
}
match Message::decode(&mut &message[..]) {
Some(msg) => {
ctx.report_peer(who.clone(), benefit::VALID_FORMAT);
self.on_polkadot_message(ctx, who, msg)
},
None => {
trace!(target: "p_net", "Bad message from {}", who);
ctx.report_peer(who, cost::INVALID_FORMAT);
}
Some(other) => *message = Some(other),
_ => {}
}
}
+3 -4
View File
@@ -29,9 +29,8 @@ use polkadot_primitives::parachain::{
use substrate_primitives::crypto::UncheckedInto;
use parity_codec::Encode;
use substrate_network::{
PeerId, Context, config::Roles,
message::generic::ConsensusMessage,
specialization::NetworkSpecialization, generic_message::Message as GenericMessage
PeerId, Context, config::Roles, message::generic::ConsensusMessage,
specialization::NetworkSpecialization,
};
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) {
let encoded = message.encode();
protocol.on_message(ctx, from, &mut Some(GenericMessage::ChainSpecific(encoded)));
protocol.on_message(ctx, from, encoded);
}
#[test]
+1
View File
@@ -15,6 +15,7 @@ rstd = { package = "sr-std", git = "https://github.com/paritytech/substrate", br
[dev-dependencies]
tiny-keccak = "1.4"
adder = { path = "../test-parachains/adder" }
[features]
default = ["std"]
+1 -1
View File
@@ -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] {
tiny_keccak::keccak256(state.encode().as_slice())
Binary file not shown.
+4
View File
@@ -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.
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.
pub type AuraId = ed25519::Public;
+6 -1
View File
@@ -3,6 +3,7 @@ name = "polkadot-runtime"
version = "0.1.0"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018"
build = "build.rs"
[dependencies]
bitvec = { version = "0.8", default-features = false, features = ["alloc"] }
@@ -46,10 +47,14 @@ libsecp256k1 = "0.2.1"
tiny-keccak = "1.4.2"
keyring = { package = "substrate-keyring", 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]
default = ["std"]
no_std = []
std = [
"bitvec/std",
"primitives/std",
@@ -1,5 +1,5 @@
// 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
// 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
// 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)]
pub use polkadot_runtime::*;
fn main() {
build_current_project("wasm_binary.rs", WasmBuilderSource::Crates("1.0.3"));
}
+20 -4
View File
@@ -37,11 +37,11 @@ use client::{
runtime_api as client_api, impl_runtime_apis,
};
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
};
use version::RuntimeVersion;
use grandpa::fg_primitives::{self, ScheduledChange};
use grandpa::{AuthorityId as GrandpaId, fg_primitives::{self, ScheduledChange}};
use council::motions as council_motions;
#[cfg(feature = "std")]
use council::seats as council_seats;
@@ -63,6 +63,10 @@ pub use sr_primitives::{Permill, Perbill};
pub use timestamp::BlockPeriod;
pub use srml_support::StorageValue;
// Make the WASM binary available.
#[cfg(feature = "std")]
include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));
/// Runtime version.
pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("polkadot"),
@@ -182,7 +186,10 @@ parameter_types! {
type SessionHandlers = (Grandpa, Aura);
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.
@@ -197,6 +204,14 @@ impl session::Trait for Runtime {
type ShouldEndSession = session::PeriodicSessions<Period, Offset>;
type Event = Event;
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.
@@ -228,6 +243,7 @@ impl staking::Trait for Runtime {
type Reward = ();
type SessionsPerEra = SessionsPerEra;
type BondingDuration = BondingDuration;
type SessionInterface = Self;
}
parameter_types! {
@@ -333,7 +349,7 @@ impl parachains::Trait for Runtime {
}
parameter_types!{
pub const LeasePeriod: BlockNumber = 100000;
pub const LeasePeriod: BlockNumber = 100_000;
pub const EndingPeriod: BlockNumber = 1000;
}
+9 -1
View File
@@ -865,6 +865,14 @@ mod tests {
type ShouldEndSession = session::PeriodicSessions<Period, Offset>;
type SessionHandler = ();
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 {
@@ -914,6 +922,7 @@ mod tests {
type Reward = ();
type SessionsPerEra = SessionsPerEra;
type BondingDuration = BondingDuration;
type SessionInterface = Self;
}
impl Trait for Test {
@@ -949,7 +958,6 @@ mod tests {
];
t.extend(session::GenesisConfig::<Test>{
validators: validator_keys.iter().map(|k| crate::AccountId::from(*k)).collect(),
keys: vec![],
}.build_storage().unwrap().0);
t.extend(GenesisConfig::<Test>{
-3974
View File
File diff suppressed because it is too large Load Diff
-25
View File
@@ -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 = []
-13
View File
@@ -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
-28
View File
@@ -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
+1
View File
@@ -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" }
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_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" }
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" }
+25 -11
View File
@@ -21,7 +21,7 @@ use polkadot_primitives::{AccountId, SessionKey};
use polkadot_runtime::{
GenesisConfig, CouncilSeatsConfig, DemocracyConfig, SystemConfig, AuraConfig,
SessionConfig, StakingConfig, TimestampConfig, BalancesConfig, Perbill, SessionKeys,
GrandpaConfig, SudoConfig, IndicesConfig, CuratedGrandpaConfig, StakerStatus,
GrandpaConfig, SudoConfig, IndicesConfig, CuratedGrandpaConfig, StakerStatus, WASM_BINARY,
};
use telemetry::TelemetryEndpoints;
use hex_literal::hex;
@@ -76,8 +76,7 @@ fn staging_testnet_config_genesis() -> GenesisConfig {
GenesisConfig {
system: Some(SystemConfig {
// TODO: Change after Substrate 1252 is fixed (https://github.com/paritytech/substrate/issues/1252)
code: include_bytes!("../../runtime/wasm/target/wasm32-unknown-unknown/release/polkadot_runtime.compact.wasm").to_vec(),
code: WASM_BINARY.to_vec(),
changes_trie_config: Default::default(),
}),
balances: Some(BalancesConfig {
@@ -93,10 +92,9 @@ fn staging_testnet_config_genesis() -> GenesisConfig {
.collect::<Vec<_>>(),
}),
session: Some(SessionConfig {
validators: initial_authorities.iter().map(|x| x.1.clone()).collect(),
keys: initial_authorities.iter().map(|x| (
x.1.clone(),
SessionKeys(x.2.clone(), x.2.clone()),
SessionKeys { ed25519: x.2.clone() },
)).collect::<Vec<_>>(),
}),
staking: Some(StakingConfig {
@@ -203,8 +201,7 @@ pub fn testnet_genesis(
GenesisConfig {
system: Some(SystemConfig {
// TODO: Change after Substrate 1252 is fixed (https://github.com/paritytech/substrate/issues/1252)
code: include_bytes!("../../runtime/wasm/target/wasm32-unknown-unknown/release/polkadot_runtime.compact.wasm").to_vec(),
code: WASM_BINARY.to_vec(),
changes_trie_config: Default::default(),
}),
indices: Some(IndicesConfig {
@@ -215,10 +212,9 @@ pub fn testnet_genesis(
vesting: vec![],
}),
session: Some(SessionConfig {
validators: initial_authorities.iter().map(|x| x.1.clone()).collect(),
keys: initial_authorities.iter().map(|x| (
x.1.clone(),
SessionKeys(x.2.clone(), x.2.clone()),
SessionKeys { ed25519: x.2.clone() },
)).collect::<Vec<_>>(),
}),
staking: Some(StakingConfig {
@@ -277,7 +273,16 @@ fn development_config_genesis() -> GenesisConfig {
/// Development config (single validator Alice)
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 {
@@ -293,5 +298,14 @@ fn local_testnet_genesis() -> GenesisConfig {
/// Local testnet config (multivalidator Alice + Bob)
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
View File
@@ -22,7 +22,7 @@ use client::LongestChain;
use consensus_common::SelectChain;
use std::sync::Arc;
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_network::gossip::{self as network_gossip, Known};
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 polkadot_network::{PolkadotProtocol, NetworkService};
pub use polkadot_primitives::parachain::{CollatorId, ParachainHost};
pub use primitives::{Blake2Hasher};
pub use primitives::Blake2Hasher;
pub use sr_primitives::traits::ProvideRuntimeApi;
pub use chain_spec::ChainSpec;
@@ -163,7 +163,7 @@ service::construct_service_factory! {
{ |config: FactoryFullConfiguration<Self>| {
FullComponents::<Factory>::new(config)
} },
AuthoritySetup = { |mut service: Self::FullService, key: Option<Arc<ed25519::Pair>>| {
AuthoritySetup = { |mut service: Self::FullService| {
use polkadot_network::validation::ValidationNetwork;
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.
{
let local_key = if service.config.disable_grandpa {
let grandpa_key = if service.config.disable_grandpa {
None
} else {
key.clone()
service.authority_key::<grandpa_primitives::AuthorityPair>()
};
let config = grandpa::Config {
local_key,
local_key: grandpa_key.map(Arc::new),
// FIXME #1578 make this available through chainspec
gossip_duration: Duration::from_millis(333),
justification_period: 4096,
@@ -220,22 +220,22 @@ service::construct_service_factory! {
let mut path = PathBuf::from(service.config.database_path.clone());
path.push("availability");
::av_store::Store::new(::av_store::Config {
av_store::Store::new(::av_store::Config {
cache_size: None,
path,
})?
};
// run authorship only if authority.
let key = match key {
Some(key) => key,
let aura_key = match service.authority_key::<AuraPair>() {
Some(key) => Arc::new(key),
None => return Ok(service),
};
if service.config.custom.collating_for.is_some() {
info!("The node cannot start as an authority because it is also configured\
to run as a collator.");
info!(
"The node cannot start as an authority because it is also configured to run as a collator."
);
return Ok(service);
}
@@ -279,23 +279,23 @@ service::construct_service_factory! {
service.client(),
polkadot_network::validation::WrappedExecutor(service.spawn_task_handle()),
);
let proposer_factory = ::consensus::ProposerFactory::new(
let proposer_factory = consensus::ProposerFactory::new(
client.clone(),
select_chain.clone(),
validation_network.clone(),
validation_network,
service.transaction_pool(),
Arc::new(service.spawn_task_handle()),
key.clone(),
aura_key.clone(),
extrinsic_store,
SlotDuration::get_or_compute(&*client)?,
service.config.custom.max_block_data_size,
);
info!("Using authority key {}", key.public());
info!("Using authority key {}", aura_key.public());
let task = start_aura(
SlotDuration::get_or_compute(&*client)?,
key,
aura_key,
client.clone(),
select_chain,
block_import,
-2
View File
@@ -1,5 +1,3 @@
# 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.
Run `build.sh` in this directory to build all registered test parachains and copy the generated WASM to the `parachain/tests/res` folder.
+19 -1
View File
@@ -4,8 +4,26 @@ version = "0.1.0"
authors = ["Parity Technologies <admin@parity.io>"]
description = "Test parachain which adds to a number as its state transition"
edition = "2018"
build = "build.rs"
[dependencies]
parachain = { package = "polkadot-parachain", path = "../../parachain/", default-features = false }
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 = []
+25
View File
@@ -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",
);
}
+13
View File
@@ -18,8 +18,21 @@
#![no_std]
#![cfg_attr(feature = "no_std", feature(core_intrinsics, lang_items, core_panic_info, alloc_error_handler))]
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.
#[derive(Default, Clone, Hash, Eq, PartialEq, Encode, Decode)]
pub struct HeadData {
@@ -1,4 +1,4 @@
// Copyright 2017 Parity Technologies (UK) Ltd.
// Copyright 2019 Parity Technologies (UK) Ltd.
// This file is part of Polkadot.
// Polkadot is free software: you can redistribute it and/or modify
@@ -16,17 +16,10 @@
//! WASM validation for adder parachain.
#![no_std]
#![feature(core_intrinsics, lang_items, core_panic_info, alloc_error_handler)]
#[global_allocator]
static ALLOC: dlmalloc::GlobalDlmalloc = dlmalloc::GlobalDlmalloc;
use crate::{HeadData, BlockData};
use core::{intrinsics, panic};
use parachain::ValidationResult;
use parachain::codec::{Encode, Decode};
use adder::{HeadData, BlockData};
#[panic_handler]
#[no_mangle]
@@ -57,14 +50,14 @@ pub extern fn validate_block(params: *const u8, len: usize) -> usize {
// we also add based on incoming data from messages. ignoring unknown message
// kinds.
let from_messages = adder::process_messages(
let from_messages = crate::process_messages(
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(
ValidationResult { head_data: new_head.encode() }
),
Err(_) => panic!("execution failure"),
}
}
}
@@ -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]
-21
View File
@@ -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