diff --git a/build.sh b/build.sh index 9a2aaac463093..dd47753730759 100755 --- a/build.sh +++ b/build.sh @@ -10,3 +10,4 @@ cd demo/runtime/wasm && ./build.sh && cd ../../.. cd substrate/executor/wasm && ./build.sh && cd ../../.. cd substrate/test-runtime/wasm && ./build.sh && cd ../../.. cd polkadot/runtime/wasm && ./build.sh && cd ../../.. +cd polkadot/parachain/test-chains && ./build.sh && cd ../../.. diff --git a/polkadot/parachain/test-chains/basic_add/Cargo.toml b/polkadot/parachain/test-chains/basic_add/Cargo.toml index afc9e9f13103d..dd0fc4050d925 100644 --- a/polkadot/parachain/test-chains/basic_add/Cargo.toml +++ b/polkadot/parachain/test-chains/basic_add/Cargo.toml @@ -9,7 +9,7 @@ crate-type = ["cdylib"] [dependencies] polkadot-parachain = { path = "../../", default-features = false } -wee_alloc = "0.2.0" +wee_alloc = "0.4.0" tiny-keccak = "1.4" pwasm-libc = "0.2" diff --git a/polkadot/parachain/test-chains/basic_add/src/lib.rs b/polkadot/parachain/test-chains/basic_add/src/lib.rs index 3f877b16d1bcb..be21a8dec8caa 100644 --- a/polkadot/parachain/test-chains/basic_add/src/lib.rs +++ b/polkadot/parachain/test-chains/basic_add/src/lib.rs @@ -17,7 +17,7 @@ //! Basic parachain that adds a number as part of its state. #![cfg_attr(not(feature = "std"), no_std)] -#![cfg_attr(not(feature = "std"), feature(alloc, core_intrinsics, global_allocator, lang_items))] +#![cfg_attr(not(feature = "std"), feature(alloc, core_intrinsics, global_allocator, lang_items, panic_implementation))] #[cfg(not(feature = "std"))] extern crate alloc; diff --git a/polkadot/parachain/test-chains/basic_add/src/wasm.rs b/polkadot/parachain/test-chains/basic_add/src/wasm.rs index fa1bf64f43cea..3af2dd39a9722 100644 --- a/polkadot/parachain/test-chains/basic_add/src/wasm.rs +++ b/polkadot/parachain/test-chains/basic_add/src/wasm.rs @@ -16,19 +16,23 @@ //! Defines WASM module logic. +use core::intrinsics; + use parachain::{self, ValidationResult}; use parachain::codec::Slicable; use super::{HeadData, BlockData}; -#[lang = "panic_fmt"] +#[panic_implementation] +#[no_mangle] +pub fn rust_begin_panic(_info: &::core::panic::PanicInfo) -> ! { + unsafe { + intrinsics::abort() + } +} + +#[lang = "oom"] #[no_mangle] -pub extern fn panic_fmt( - _args: ::core::fmt::Arguments, - _file: &'static str, - _line: u32, - _col: u32, -) -> ! { - use core::intrinsics; +pub fn oom() -> ! { unsafe { intrinsics::abort(); } diff --git a/polkadot/parachain/test-chains/build.sh b/polkadot/parachain/test-chains/build.sh new file mode 100755 index 0000000000000..2b876634e88c7 --- /dev/null +++ b/polkadot/parachain/test-chains/build.sh @@ -0,0 +1,13 @@ +#!/bin/sh +set -e + +rm -rf ./target +for i in */ +do + i=${i%/} + cd $i + + RUSTFLAGS="-C link-arg=--import-memory" cargo +nightly build --target=wasm32-unknown-unknown --release --no-default-features + wasm-gc target/wasm32-unknown-unknown/release/$i.wasm ../../tests/res/$i.wasm + cd .. +done diff --git a/polkadot/parachain/test-chains/build_test_chains.sh b/polkadot/parachain/test-chains/build_test_chains.sh deleted file mode 100755 index 6523e46f14e7e..0000000000000 --- a/polkadot/parachain/test-chains/build_test_chains.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh -set -e - -rm -rf ./target -for i in */ -do - i=${i%/} - cd $i - - # TODO: stop using exact nightly when wee-alloc works on normal nightly. - RUSTFLAGS="-C link-arg=--import-memory" cargo +nightly-2018-03-07 build --target=wasm32-unknown-unknown --release --no-default-features - wasm-gc target/wasm32-unknown-unknown/release/$i.wasm ../../tests/res/$i.wasm - cd .. -done diff --git a/polkadot/parachain/tests/res/basic_add.wasm b/polkadot/parachain/tests/res/basic_add.wasm index 83f52db817f81..709c111d278c7 100755 Binary files a/polkadot/parachain/tests/res/basic_add.wasm and b/polkadot/parachain/tests/res/basic_add.wasm differ diff --git a/publish-wasm.sh b/publish-wasm.sh index 7ac79a99bf548..2a42504eef6b9 100755 --- a/publish-wasm.sh +++ b/publish-wasm.sh @@ -4,7 +4,7 @@ set -e REPO="github.com/paritytech/polkadot-wasm-bin.git" REPO_AUTH="${GH_TOKEN}:@${REPO}" -SRCS=( "polkadot/runtime/wasm" "substrate/executor/wasm" "demo/runtime/wasm" "substrate/test-runtime/wasm" ) +SRCS=( "polkadot/runtime/wasm" "substrate/executor/wasm" "demo/runtime/wasm" "substrate/test-runtime/wasm" "polkadot/parachain/test-chains" ) DST=".wasm-binaries" TARGET="wasm32-unknown-unknown" UTCDATE=`date -u "+%Y%m%d.%H%M%S.0"`