From b79d2d69d768a6e111637190bed13f0d5168084d Mon Sep 17 00:00:00 2001 From: Alain Brenzikofer Date: Sat, 2 May 2020 16:16:22 +0200 Subject: [PATCH] drop wasm build stuff. always build no_std for SGX --- Cargo.lock | 237 +-------------------------------------------- Cargo.toml | 3 + runtime/Cargo.toml | 46 +++------ runtime/build.rs | 10 -- runtime/src/lib.rs | 17 +++- 5 files changed, 31 insertions(+), 282 deletions(-) delete mode 100644 runtime/build.rs diff --git a/Cargo.lock b/Cargo.lock index b1c1131..b52693d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -34,17 +34,6 @@ dependencies = [ "memchr", ] -[[package]] -name = "alga" -version = "0.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f823d037a7ec6ea2197046bafd4ae150e6bc36f9ca347404f46a46823fa84f2" -dependencies = [ - "approx", - "num-complex", - "num-traits 0.2.11", -] - [[package]] name = "ansi_term" version = "0.11.0" @@ -81,15 +70,6 @@ dependencies = [ "xdg", ] -[[package]] -name = "approx" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0e60b75072ecd4168020818c0107f2857bb6c4e64252d8d3983f6263b40a5c3" -dependencies = [ - "num-traits 0.2.11", -] - [[package]] name = "arc-swap" version = "0.4.5" @@ -900,24 +880,6 @@ dependencies = [ "parity-scale-codec", ] -[[package]] -name = "frame-benchmarking" -version = "2.0.0-alpha.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f2fc91a6a976ce87b105722d8d9cdc44d4cb03ad24493d34cbfb64bbaacb7ee" -dependencies = [ - "frame-support", - "frame-system", - "linregress", - "parity-scale-codec", - "paste", - "sp-api", - "sp-io", - "sp-runtime", - "sp-runtime-interface", - "sp-std", -] - [[package]] name = "frame-executive" version = "2.0.0-alpha.6" @@ -927,7 +889,6 @@ dependencies = [ "frame-support", "frame-system", "parity-scale-codec", - "serde", "sp-runtime", "sp-std", ] @@ -1916,12 +1877,6 @@ dependencies = [ "winapi 0.3.8", ] -[[package]] -name = "libm" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7d73b3f436185384286bd8098d17ec07c9a7d2388a6599f824d8502b529702a" - [[package]] name = "libp2p" version = "0.18.0" @@ -2258,17 +2213,6 @@ dependencies = [ "linked-hash-map", ] -[[package]] -name = "linregress" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9290cf6f928576eeb9c096c6fad9d8d452a0a1a70a2bbffa6e36064eedc0aac9" -dependencies = [ - "failure", - "nalgebra", - "statrs", -] - [[package]] name = "lock_api" version = "0.3.4" @@ -2302,15 +2246,6 @@ version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08" -[[package]] -name = "matrixmultiply" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4f7ec66360130972f34830bfad9ef05c6610a43938a467bcc9ab9369ab3478f" -dependencies = [ - "rawpointer", -] - [[package]] name = "maybe-uninit" version = "2.0.0" @@ -2460,23 +2395,6 @@ dependencies = [ "unsigned-varint", ] -[[package]] -name = "nalgebra" -version = "0.18.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aaa9fddbc34c8c35dd2108515587b8ce0cab396f17977b8c738568e4edb521a2" -dependencies = [ - "alga", - "approx", - "generic-array", - "matrixmultiply", - "num-complex", - "num-rational", - "num-traits 0.2.11", - "rand 0.6.5", - "typenum", -] - [[package]] name = "names" version = "0.11.0" @@ -2594,16 +2512,6 @@ dependencies = [ "num-traits 0.2.11", ] -[[package]] -name = "num-complex" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6b19411a9719e753aff12e5187b74d60d3dc449ec3f4dc21e3989c3f554bc95" -dependencies = [ - "autocfg 1.0.0", - "num-traits 0.2.11", -] - [[package]] name = "num-integer" version = "0.1.42" @@ -2642,7 +2550,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c62be47e61d1842b9170f0fdeec8eba98e60e90e5446449a0545e5152acd7096" dependencies = [ "autocfg 1.0.0", - "libm", ] [[package]] @@ -2706,7 +2613,6 @@ dependencies = [ "pallet-session", "pallet-timestamp", "parity-scale-codec", - "serde", "sp-application-crypto", "sp-consensus-aura", "sp-core", @@ -2723,11 +2629,9 @@ version = "2.0.0-alpha.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b9ef08001886d3747220630337f7afbb8f1d7cbfacaa3a8a13317e1cb3e8e366" dependencies = [ - "frame-benchmarking", "frame-support", "frame-system", "parity-scale-codec", - "serde", "sp-io", "sp-runtime", "sp-std", @@ -2761,7 +2665,6 @@ dependencies = [ "pallet-finality-tracker", "pallet-session", "parity-scale-codec", - "serde", "sp-core", "sp-finality-grandpa", "sp-runtime", @@ -2794,12 +2697,10 @@ dependencies = [ "impl-trait-for-tuples", "pallet-timestamp", "parity-scale-codec", - "serde", "sp-io", "sp-runtime", "sp-staking", "sp-std", - "sp-trie", ] [[package]] @@ -2811,7 +2712,6 @@ dependencies = [ "frame-support", "frame-system", "parity-scale-codec", - "serde", "sp-io", "sp-runtime", "sp-std", @@ -2835,12 +2735,10 @@ version = "2.0.0-alpha.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4d9de9af5f5ed3377a6108eed436791bfe18bc3e4e2e416854d0074d31b1be00" dependencies = [ - "frame-benchmarking", "frame-support", "frame-system", "impl-trait-for-tuples", "parity-scale-codec", - "serde", "sp-inherents", "sp-runtime", "sp-std", @@ -2869,7 +2767,6 @@ checksum = "7323ef565470b51bb79fc65d3c3a1bff0ecb317485acc66a64406309c25f1b77" dependencies = [ "frame-support", "parity-scale-codec", - "serde", "sp-api", "sp-runtime", "sp-std", @@ -3368,38 +3265,6 @@ dependencies = [ "winapi 0.3.8", ] -[[package]] -name = "rand" -version = "0.5.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c618c47cd3ebd209790115ab837de41425723956ad3ce2e6a7f09890947cacb9" -dependencies = [ - "cloudabi", - "fuchsia-cprng", - "libc", - "rand_core 0.3.1", - "winapi 0.3.8", -] - -[[package]] -name = "rand" -version = "0.6.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d71dacdc3c88c1fde3885a3be3fbab9f35724e6ce99467f7d9c5026132184ca" -dependencies = [ - "autocfg 0.1.7", - "libc", - "rand_chacha 0.1.1", - "rand_core 0.4.2", - "rand_hc 0.1.0", - "rand_isaac", - "rand_jitter", - "rand_os", - "rand_pcg", - "rand_xorshift", - "winapi 0.3.8", -] - [[package]] name = "rand" version = "0.7.3" @@ -3408,19 +3273,9 @@ checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" dependencies = [ "getrandom", "libc", - "rand_chacha 0.2.2", + "rand_chacha", "rand_core 0.5.1", - "rand_hc 0.2.0", -] - -[[package]] -name = "rand_chacha" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "556d3a1ca6600bfcbab7c7c91ccb085ac7fbbcd70e008a98742e7847f4f7bcef" -dependencies = [ - "autocfg 0.1.7", - "rand_core 0.3.1", + "rand_hc", ] [[package]] @@ -3457,15 +3312,6 @@ dependencies = [ "getrandom", ] -[[package]] -name = "rand_hc" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b40677c7be09ae76218dc623efbf7b18e34bced3f38883af07bb75630a21bc4" -dependencies = [ - "rand_core 0.3.1", -] - [[package]] name = "rand_hc" version = "0.2.0" @@ -3475,65 +3321,6 @@ dependencies = [ "rand_core 0.5.1", ] -[[package]] -name = "rand_isaac" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ded997c9d5f13925be2a6fd7e66bf1872597f759fd9dd93513dd7e92e5a5ee08" -dependencies = [ - "rand_core 0.3.1", -] - -[[package]] -name = "rand_jitter" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1166d5c91dc97b88d1decc3285bb0a99ed84b05cfd0bc2341bdf2d43fc41e39b" -dependencies = [ - "libc", - "rand_core 0.4.2", - "winapi 0.3.8", -] - -[[package]] -name = "rand_os" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b75f676a1e053fc562eafbb47838d67c84801e38fc1ba459e8f180deabd5071" -dependencies = [ - "cloudabi", - "fuchsia-cprng", - "libc", - "rand_core 0.4.2", - "rdrand", - "winapi 0.3.8", -] - -[[package]] -name = "rand_pcg" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abf9b09b01790cfe0364f52bf32995ea3c39f4d2dd011eac241d2914146d0b44" -dependencies = [ - "autocfg 0.1.7", - "rand_core 0.4.2", -] - -[[package]] -name = "rand_xorshift" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cbf7e9e623549b0e21f6e97cf8ecf247c1a8fd2e8a992ae265314300b2455d5c" -dependencies = [ - "rand_core 0.3.1", -] - -[[package]] -name = "rawpointer" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60a357793950651c4ed0f3f52338f53b2f809f32d83a07f72909fa13e4c6c1e3" - [[package]] name = "rayon" version = "1.3.0" @@ -4601,6 +4388,7 @@ dependencies = [ "parity-scale-codec", "serde", "sp-api", + "sp-application-crypto", "sp-block-builder", "sp-consensus-aura", "sp-core", @@ -4612,7 +4400,6 @@ dependencies = [ "sp-std", "sp-transaction-pool", "sp-version", - "substrate-wasm-builder-runner", ] [[package]] @@ -5070,8 +4857,7 @@ dependencies = [ [[package]] name = "sp-io" version = "2.0.0-alpha.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20758b1831f75d58c20ca735d34b96dc792ef8264bf4d4a8c476964d90a6aea7" +source = "git+https://github.com/scs/substraTEE-worker.git?branch=v2.0.0-alpha.6-upgrade#8d4cce863dd861897d43383cd3d1f60fc2357734" dependencies = [ "hash-db", "libsecp256k1", @@ -5350,15 +5136,6 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" -[[package]] -name = "statrs" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10102ac8d55e35db2b3fafc26f81ba8647da2e15879ab686a67e6d19af2685e8" -dependencies = [ - "rand 0.5.6", -] - [[package]] name = "string" version = "0.2.1" @@ -5455,12 +5232,6 @@ dependencies = [ "tokio 0.2.18", ] -[[package]] -name = "substrate-wasm-builder-runner" -version = "1.0.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e30c70de7e7d5fd404fe26db1e7a4d6b553e2760b1ac490f249c04a960c483b8" - [[package]] name = "subtle" version = "1.0.0" diff --git a/Cargo.toml b/Cargo.toml index 9c337cd..675da2a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,3 +5,6 @@ members = [ ] [profile.release] panic = 'unwind' + +[patch.crates-io] +sp-io = { git = "https://github.com/scs/substraTEE-worker.git", branch = "v2.0.0-alpha.6-upgrade", default-features = false, features = ["disable_oom", "disable_panic_handler", "disable_allocator", "sgx"]} diff --git a/runtime/Cargo.toml b/runtime/Cargo.toml index 99cdd20..777ddda 100644 --- a/runtime/Cargo.toml +++ b/runtime/Cargo.toml @@ -52,15 +52,25 @@ version = '0.8.0-alpha.6' [dependencies.sp-core] default-features = false version = '2.0.0-alpha.6' +features = ["full_crypto"] -[dependencies.sp-inherents] +[dependencies.sp-application-crypto] default-features = false version = '2.0.0-alpha.6' +features = ["full_crypto"] -[dependencies.sp-io] +[dependencies.sp-inherents] default-features = false version = '2.0.0-alpha.6' +#[dependencies.sp-io] +#default-features = false +#version = '2.0.0-alpha.6' + +[target.'cfg(not(target_arch = "wasm32"))'.dependencies] +sp-io = { version = "2.0.0-alpha.6", default-features = false, features = [ "disable_oom", "disable_panic_handler" ] } + + [dependencies.sp-offchain] default-features = false version = '2.0.0-alpha.6' @@ -111,9 +121,6 @@ default-features = false package = 'pallet-transaction-payment' version = '2.0.0-alpha.6' -[build-dependencies.wasm-builder-runner] -package = 'substrate-wasm-builder-runner' -version = '1.0.5' [package] authors = ['Anonymous'] @@ -127,32 +134,3 @@ version = '2.0.0-alpha.6' [package.metadata.docs.rs] targets = ['x86_64-unknown-linux-gnu'] -[features] -default = ['std'] -std = [ - 'aura/std', - 'balances/std', - 'codec/std', - 'frame-executive/std', - 'frame-support/std', - 'grandpa/std', - 'randomness-collective-flip/std', - 'serde', - 'sp-api/std', - 'sp-block-builder/std', - 'sp-consensus-aura/std', - 'sp-core/std', - 'sp-inherents/std', - 'sp-io/std', - 'sp-offchain/std', - 'sp-runtime/std', - 'sp-session/std', - 'sp-std/std', - 'sp-transaction-pool/std', - 'sp-version/std', - 'sudo/std', - 'system/std', - 'timestamp/std', - 'transaction-payment/std', - 'template/std', -] diff --git a/runtime/build.rs b/runtime/build.rs deleted file mode 100644 index 39f7f56..0000000 --- a/runtime/build.rs +++ /dev/null @@ -1,10 +0,0 @@ -use wasm_builder_runner::WasmBuilder; - -fn main() { - WasmBuilder::new() - .with_current_project() - .with_wasm_builder_from_crates("1.0.9") - .export_heap_base() - .import_memory() - .build() -} diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 35b5e1c..9b6131d 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -1,6 +1,15 @@ -//! The Substrate Node Template runtime. This can be compiled with `#[no_std]`, ready for Wasm. +//! The Substrate Node Template runtime for SGX. +//! This is only meant to be used inside an SGX enclave with `#[no_std]` +//! +//! you should assemble your runtime to be used with your STF here +//! and get all your needed pallets in + +#![no_std] +#![feature(prelude_import)] +#![feature(structural_match)] +#![feature(core_intrinsics)] +#![feature(derive_eq)] -#![cfg_attr(not(feature = "std"), no_std)] // `construct_runtime!` does a lot of recursion and requires us to increase the limit to 256. #![recursion_limit="256"] @@ -14,9 +23,7 @@ use sp_runtime::traits::{ BlakeTwo256, Block as BlockT, IdentityLookup, Verify, ConvertInto, IdentifyAccount }; use sp_api::impl_runtime_apis; -//use sp_consensus_aura::sr25519::AuthorityId as AuraId; -//use grandpa::AuthorityList as GrandpaAuthorityList; -//use grandpa::fg_primitives; + use sp_version::RuntimeVersion; pub use timestamp::Call as TimestampCall;