From 42898bbd0c39408f250ce2a904804d40a7df64fe Mon Sep 17 00:00:00 2001 From: brenzi Date: Tue, 26 May 2020 12:51:56 +0200 Subject: [PATCH 01/29] move content to book --- README.md | 157 +----------------------------------------------------- 1 file changed, 2 insertions(+), 155 deletions(-) diff --git a/README.md b/README.md index 4c44ac292f..dffc26aea8 100755 --- a/README.md +++ b/README.md @@ -1,7 +1,4 @@ # substraTEE-worker - -![badge](https://img.shields.io/badge/substrate-2.0.0--alpha.7-success) - SubstraTEE worker for SubstraTEE node This is part of [substraTEE](https://github.com/scs/substraTEE) @@ -9,158 +6,8 @@ This is part of [substraTEE](https://github.com/scs/substraTEE) ## Development environment **Supports Rust nightly-2020-04-07** -### Local installation -You need the following components installed to start developing/compiling the code: -* [Intel SGX driver](https://github.com/intel/linux-sgx-driver), [SGX and PSW](https://github.com/intel/linux-sgx) -* [Rust](https://www.rust-lang.org/) -* [Rust SGX SDK](https://github.com/apache/incubator-teaclave-sgx-sdk) -* [IPFS](https://ipfs.io/) - -### Docker image -We provide docker images with all the required tools installed. They can be found on [dockerhub](https://hub.docker.com/repository/docker/scssubstratee/substratee_dev). - -The tag has the following format: `--`. We don't provide any *latest* so you must specify the tag. - -If you execute -``` -$ docker pull scssubstratee/substratee_dev:18.04-2.9.1-1.1.2 -``` -you get a docker image with -- Ubuntu 18.04 -- Intel SGX SDK 2.9.1 -- Rust SGX SDK 1.1.2 (which includes the correct Rust version) -- IPF 0.4.21 - -To start developing with the docker image, perform these steps: -1. Clone the substraTEE-worker repository: - ``` - git clone https://github.com/scs/substraTEE-worker.git - ``` -2. Pull the docker image with the desired tag: - ``` - docker pull scssubstratee/substratee_dev:18.04-2.9.1-1.1.2 - ``` -3. Start the docker container and mount the local substraTEE-worker directory to `/root/substraTEE-worker`: - ``` - docker run -it -v ${PWD}/substraTEE-worker-DOCKERTEST:/root/substraTEE-worker scssubstratee/substratee_dev:18.04-2.9.1-1.1.2 /bin/bash - ``` -4. Change into the substraTEE-worker directory and build the code: - ``` - cd substraTEE-worker - make - ``` - -This build the code inside the docker, but the compiled binaries are stored on your local working copy. - -## Intel SGX development and production (commercial) license -In order to perform a remote attestation of the enclave, an [Intel SGX Attestation Enhanced Service Privacy ID (EPID)](https://api.portal.trustedservices.intel.com/EPID-attestation) is needed. We use unlinkable quotes in our code. - -### Development Access -Copy your SPID and key to the following files (use Linux line endings): -* `bin/spid.txt`: SPID of your subscription -* `bin/key.txt`: Key of your subscription (primary or secondary works) - -The enclave will be signed with the development key found under `enclave/Enclave_private.pem` and uses the configuration found under `enclave/Enclave.config.xml`. - -### Production Access -Copy your SPID and key to the following files (use Linux line endings): -* `bin/spid_production.txt`: SPID of your subscription -* `bin/key_production.txt`: Key of your subscription (primary or secondary works) -These files are used to access the Intel Remote Attestation Service. - -The enclave will be signed with the private key that was also registered and whitelisted at Intel's (in the process of obtaining a commercial license). Make sure that the key is exported as an environment variable called `SGX_COMMERCIAL_KEY`. - -The enclave in production mode uses the configuration found under `enclave/Enclave.config.production.xml`. - -## Private-tx demo -To run a demo for private tokens do the following: - -Assumptions: -* your machine has SGX support -* Intel SGX SDK installed. -* rust toolchain is ready to build substrate - -in terminal 1 run a substraTEE-node -``` -git clone https://github.com/scs/substraTEE-node -cd substraTEE-node -git checkout tags/M5 -cargo build --release -./target/release/substratee-node --dev --ws-port 9979 --rpc-port 9969 -``` - -in terminal 2, run the worker -``` -git clone https://github.com/scs/substraTEE-worker -cd substraTEE-worker -git checkout tags/M5 -make -cd bin -RUST_LOG=info ./substratee-worker -p 9979 worker -``` - -in terminal 3, run the client -``` -cd substraTEE-worker/bin -./substratee-client --node-ws-port 9979 -``` - -Then you should see this in terminal 3: -``` -*** Getting the amount of the registered workers -[<] Found 1 workers - -[>] Getting the first worker's from the substraTEE-node -[<] Got first worker's coordinates: - W1's public key : "5Gkzji8EtE1hTjVzTmZXWqrs6sqcHcbCooGqVH7iRRuxdnar" - W1's url: "127.0.0.1:2000" - -[>] Get the shielding key from W1 (=5Gkzji8EtE1hTjVzTmZXWqrs6sqcHcbCooGqVH7iRRuxdnar) -[<] Got worker shielding key Rsa3072KeyPair: { n:CF67550FB00AB959A76219EA35188B360380037123FCAA77B683A791A1F980331F9D9E11D04C7F5FB3B63787F8AAB579FDFFE1DCE79A29B6ACED2628635C8463965D5D839BD58072AA77B8CAE124E40562955FE9936DAE2976CD57B41A2DE89EEDBF9DA77C155365E8BB45DCA1E0EC3B32604D9489712762BE63B3D1F04801D796887F70115BFDD440450A04BFE81DEE7BE718F56F766E6B0C2D9DE270583C4DFBA64FD59B4DE39C07977F1FD2956588DDBF73987EECB5BB303AF2115C4E72879C5EC69B7CD5C00DAEF9F9B062B40ADA16984C574246C8AB882A79D2E1C2F597C1017FBA69D7449BAD85ADE822D92A775DB1766F21C886E762C3E260390B72C82515F1D48FD190059B419C639E3688BCC2070E9CDB6BDDD49202B7296EA2AB01EA2D3AC2990C5078446582A4C03194BBF8D7E557B4503FF4645C053D7288398C79781F642F3A8D399195E6D2E6F74B434791D881BC97BAA0F0B228BD031C40E357BC61644E68CC40F3E08BDCBBD92E306FA9353FAEA05FDCBFCF4729FECC008C, e:01000001 } - -[+] Alice's Incognito Pubkey: 5Dt1Wg85pXGLstt36t6TDdvXXoCtG6zkUL17KkyVaPYSrzGH - -[+] Bob's Incognito Pubkey: 5GTTq4EnvMk4oTXYJp2kqTd2T9hbnARuee5awLiKFKsxWgRy - -[+] pre-funding Alice's Incognito account (ROOT call) -[+] Subscribed, waiting for event... - -[+] Received confirm call from 5Gkzji8EtE1hTjVzTmZXWqrs6sqcHcbCooGqVH7iRRuxdnar -[+] query Alice's Incognito account balance - got getter response from worker: Ok("State is 1000000") -[+] query Bob's Incognito account balance - got getter response from worker: Ok("State is 0") - -*** incognito transfer from Alice to Bob - -[+] Subscribed, waiting for event... - -[+] Received confirm call from 5Gkzji8EtE1hTjVzTmZXWqrs6sqcHcbCooGqVH7iRRuxdnar -[+] query Alice's Incognito account balance - got getter response from worker: Ok("State is 900000") -[+] query Bob's Incognito account balance - got getter response from worker: Ok("State is 100000") - -``` - -### So, what happens here? - -Alice wants to transfer 100k tokens privately to Bob. She doesn't use her substraTEE-node account for this as the transfer would be publicly visible. - -Instead, she creates an *incognito* account and she keeps her account secret (also the public key). This account will never hit the substraTEE-node blockchain transparently. - -The *Demo God* then gives Alice some initial Balance of 1M. - -Bob also creates an *incognito* account and tells Alice (and only her) his public key. - -Alice now uses SubstraTEE's *shielded transaction* feature to send 100k to Bob. - -### under the hood - -TODO: -* block diagram -* sequence diagram - +## Build and Run +Please see our [SubstraTEE Book](https://www.substratee.com/howto_worker.html) to learn how to build and run this. ## Tests ### environment From fff3ee572968f289ada32058ec618528a4223cae Mon Sep 17 00:00:00 2001 From: brenzi Date: Tue, 26 May 2020 12:52:27 +0200 Subject: [PATCH 02/29] badge --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index dffc26aea8..49bed08828 100755 --- a/README.md +++ b/README.md @@ -1,4 +1,7 @@ # substraTEE-worker + +![badge](https://img.shields.io/badge/substrate-2.0.0--alpha.7-success) + SubstraTEE worker for SubstraTEE node This is part of [substraTEE](https://github.com/scs/substraTEE) From bfd2516d128bb3f792fd38a1edb14fc685bb20ec Mon Sep 17 00:00:00 2001 From: clangenb <37865735+clangenb@users.noreply.github.com> Date: Wed, 27 May 2020 10:57:10 +0200 Subject: [PATCH 03/29] Cl fixme todos (#138) * [stf] make Alice root, and check root in TrustedCall::set_balance call * [tests/commons] annotate that alice is root * [enclave/attestation] remove weird todo * [stf] fix test compilation * [worker/enclave_api] enclave_shielding_key now returns Rsa3072PubKey instead of Vec * [worker/tests/ecalls] remove todos for testing the get_shielding_key/get_signing_key as successful fetch is verified in all integration tests and we have no means of verifying here that a "correct" key was fetched. Only if the call was successful. --- enclave/src/attestation.rs | 2 - stf/Cargo.toml | 6 +- stf/src/lib.rs | 8 ++- stf/src/sgx.rs | 85 +++++++++++++++------------ worker/src/enclave/api.rs | 6 +- worker/src/tests/commons.rs | 22 ++----- worker/src/tests/ecalls.rs | 3 - worker/src/tests/integration_tests.rs | 6 +- worker/src/ws_server.rs | 6 +- 9 files changed, 72 insertions(+), 72 deletions(-) diff --git a/enclave/src/attestation.rs b/enclave/src/attestation.rs index 0444d229fe..6520bfaac9 100644 --- a/enclave/src/attestation.rs +++ b/enclave/src/attestation.rs @@ -543,8 +543,6 @@ pub fn create_attestation_report( let (attn_report, sig, cert) = get_report_from_intel(ias_sock, quote_vec)?; Ok((attn_report, sig, cert)) - - //TODO: return context as well } fn load_spid(filename: &str) -> SgxResult { diff --git a/stf/Cargo.toml b/stf/Cargo.toml index d8173b27f1..e00e4b74ed 100644 --- a/stf/Cargo.toml +++ b/stf/Cargo.toml @@ -19,7 +19,10 @@ std = [ "clap-nested", "log", "base58", - "sc-keystore" + "sc-keystore", + "system/std", + "metadata/std", + "sp-core/std" ] [dependencies] @@ -91,4 +94,3 @@ optional = true [dev-dependencies.sp-keyring] version = '2.0.0-alpha.7' - diff --git a/stf/src/lib.rs b/stf/src/lib.rs index f96def342d..e29e515ac8 100644 --- a/stf/src/lib.rs +++ b/stf/src/lib.rs @@ -186,7 +186,6 @@ pub struct Stf {} mod tests { use super::*; use sp_keyring::AccountKeyring; - use std::vec::Vec; #[test] fn verify_signature_works() { @@ -194,7 +193,12 @@ mod tests { let mrenclave = [0u8; 32]; let shard = ShardIdentifier::default(); - let call = TrustedCall::balance_set_balance(AccountId::from(AccountKeyring::Alice), 42, 42); + let call = TrustedCall::balance_set_balance( + AccountKeyring::Alice.public(), + AccountKeyring::Alice.public(), + 42, + 42, + ); let signed_call = call.sign(&AccountKeyring::Alice.pair(), nonce, &mrenclave, &shard); assert!(signed_call.verify_signature(&mrenclave, &shard)); diff --git a/stf/src/sgx.rs b/stf/src/sgx.rs index a2c7f5b71a..145007fe66 100644 --- a/stf/src/sgx.rs +++ b/stf/src/sgx.rs @@ -28,6 +28,10 @@ impl Encode for OpaqueCall { type Index = u32; type AccountData = balances::AccountData; type AccountInfo = system::AccountInfo; +const ALICE_ENCODED: [u8; 32] = [ + 212, 53, 147, 199, 21, 253, 211, 28, 97, 20, 26, 189, 4, 169, 159, 214, 130, 44, 133, 88, 133, + 76, 205, 227, 154, 86, 132, 231, 165, 109, 162, 125, +]; impl Stf { pub fn init_state() -> State { @@ -58,6 +62,7 @@ impl Stf { &storage_value_key("Balances", "ExistentialDeposit"), &1u128.encode(), ); + sp_io::storage::set(&storage_value_key("Sudo", "Key"), &ALICE_ENCODED); }); ext } @@ -76,43 +81,41 @@ impl Stf { _nonce: u32, calls: &mut Vec, ) -> Result<(), StfError> { - ext.execute_with(|| { - match call { - TrustedCall::balance_set_balance(_, who, free_balance, reserved_balance) => { - //TODO: ensure this can only be called by ROOT account - sgx_runtime::BalancesCall::::set_balance( - AccountId32::from(who), - free_balance, - reserved_balance, - ) - .dispatch(sgx_runtime::Origin::ROOT) + ext.execute_with(|| match call { + TrustedCall::balance_set_balance(root, who, free_balance, reserved_balance) => { + Self::ensure_root(root)?; + sgx_runtime::BalancesCall::::set_balance( + AccountId32::from(who), + free_balance, + reserved_balance, + ) + .dispatch(sgx_runtime::Origin::ROOT) + .map_err(|_| StfError::Dispatch)?; + Ok(()) + } + TrustedCall::balance_transfer(from, to, value) => { + let origin = sgx_runtime::Origin::signed(AccountId32::from(from)); + sgx_runtime::BalancesCall::::transfer(AccountId32::from(to), value) + .dispatch(origin) .map_err(|_| StfError::Dispatch)?; - Ok(()) - } - TrustedCall::balance_transfer(from, to, value) => { - let origin = sgx_runtime::Origin::signed(AccountId32::from(from)); - sgx_runtime::BalancesCall::::transfer(AccountId32::from(to), value) - .dispatch(origin) - .map_err(|_| StfError::Dispatch)?; - Ok(()) - } - TrustedCall::balance_unshield(account_incognito, beneficiary, value, shard) => { - Self::unshield_funds(account_incognito, value)?; - calls.push(OpaqueCall( - ( - [SUBSRATEE_REGISTRY_MODULE, UNSHIELD], - beneficiary, - value, - shard, - ) - .encode(), - )); - Ok(()) - } - TrustedCall::balance_shield(who, value) => { - Self::shield_funds(who, value)?; - Ok(()) - } + Ok(()) + } + TrustedCall::balance_unshield(account_incognito, beneficiary, value, shard) => { + Self::unshield_funds(account_incognito, value)?; + calls.push(OpaqueCall( + ( + [SUBSRATEE_REGISTRY_MODULE, UNSHIELD], + beneficiary, + value, + shard, + ) + .encode(), + )); + Ok(()) + } + TrustedCall::balance_shield(who, value) => { + Self::shield_funds(who, value)?; + Ok(()) } }) } @@ -138,6 +141,14 @@ impl Stf { }) } + fn ensure_root(account: AccountId) -> Result<(), StfError> { + if sp_io::storage::get(&storage_value_key("Sudo", "Key")).unwrap() == account.encode() { + Ok(()) + } else { + Err(StfError::MissingPrivileges(account)) + } + } + fn shield_funds(account: AccountId, amount: u128) -> Result<(), StfError> { match get_account_info(&account) { Some(account_info) => sgx_runtime::BalancesCall::::set_balance( @@ -276,6 +287,8 @@ fn key_hash(key: &K, hasher: &StorageHasher) -> Vec { #[derive(Debug, Display)] pub enum StfError { + #[display(fmt = "Insufficient privileges {:?}, are you sure you are root?", _0)] + MissingPrivileges(AccountId), #[display(fmt = "Error dispatching runtime call")] Dispatch, #[display(fmt = "Not enough funds to perform operation")] diff --git a/worker/src/enclave/api.rs b/worker/src/enclave/api.rs index f854d57ef1..f9a7adde1b 100644 --- a/worker/src/enclave/api.rs +++ b/worker/src/enclave/api.rs @@ -285,7 +285,7 @@ pub fn enclave_signing_key(eid: sgx_enclave_id_t) -> SgxResult Ok(ed25519::Public::from_raw(pubkey)) } -pub fn enclave_shielding_key(eid: sgx_enclave_id_t) -> SgxResult> { +pub fn enclave_shielding_key(eid: sgx_enclave_id_t) -> SgxResult { let pubkey_size = 8192; let mut pubkey = vec![0u8; pubkey_size as usize]; @@ -300,9 +300,9 @@ pub fn enclave_shielding_key(eid: sgx_enclave_id_t) -> SgxResult> { return Err(result); } - let rsa_pubkey: Rsa3072PubKey = serde_json::from_slice(&pubkey[..]).unwrap(); + let rsa_pubkey: Rsa3072PubKey = serde_json::from_slice(pubkey.as_slice()).unwrap(); debug!("got RSA pubkey {:?}", rsa_pubkey); - Ok(pubkey) + Ok(rsa_pubkey) } pub fn enclave_query_state( diff --git a/worker/src/tests/commons.rs b/worker/src/tests/commons.rs index 93e5ed4265..9477233af9 100644 --- a/worker/src/tests/commons.rs +++ b/worker/src/tests/commons.rs @@ -39,23 +39,17 @@ pub struct Message { pub sha256: sgx_sha256_hash_t, } +/// Who must be root account pub fn encrypted_set_balance(eid: sgx_enclave_id_t, who: AccountKeyring, nonce: u32) -> Vec { info!("*** Get the public key from the TEE\n"); - let rsa_pubkey: Rsa3072PubKey = enclave_shielding_key(eid) - .map(|key| serde_json::from_slice(key.as_slice()).unwrap()) - .unwrap(); + let rsa_pubkey: Rsa3072PubKey = enclave_shielding_key(eid).unwrap(); info!("deserialized rsa key"); - let call = TrustedCall::balance_set_balance( - who.public(), // TODO: this should actually be ROOT acount - who.public(), - 33, - 44, - ); + let call = TrustedCall::balance_set_balance(who.public(), who.public(), 33, 44); encrypt_payload( rsa_pubkey, call.sign( - &who.pair(), // TODO: this should actually be ROOT acount + &who.pair(), nonce, &enclave_mrenclave(eid).unwrap(), &ShardIdentifier::default(), @@ -66,9 +60,7 @@ pub fn encrypted_set_balance(eid: sgx_enclave_id_t, who: AccountKeyring, nonce: pub fn encrypted_unshield(eid: sgx_enclave_id_t, who: AccountKeyring, nonce: u32) -> Vec { info!("*** Get the public key from the TEE\n"); - let rsa_pubkey: Rsa3072PubKey = enclave_shielding_key(eid) - .map(|key| serde_json::from_slice(key.as_slice()).unwrap()) - .unwrap(); + let rsa_pubkey: Rsa3072PubKey = enclave_shielding_key(eid).unwrap(); info!("deserialized rsa key"); let call = @@ -100,9 +92,7 @@ pub fn test_trusted_getter_signed(who: AccountKeyring) -> TrustedGetterSigned { pub fn encrypted_alice(eid: sgx_enclave_id_t) -> Vec { info!("*** Get the public key from the TEE\n"); - let rsa_pubkey: Rsa3072PubKey = enclave_shielding_key(eid) - .map(|key| serde_json::from_slice(key.as_slice()).unwrap()) - .unwrap(); + let rsa_pubkey: Rsa3072PubKey = enclave_shielding_key(eid).unwrap(); encrypt_payload(rsa_pubkey, AccountKeyring::Alice.encode()) } diff --git a/worker/src/tests/ecalls.rs b/worker/src/tests/ecalls.rs index be40db94c3..593e5c50f3 100644 --- a/worker/src/tests/ecalls.rs +++ b/worker/src/tests/ecalls.rs @@ -24,9 +24,6 @@ use sp_keyring::AccountKeyring; use sgx_types::*; use sp_core::hash::H256; -// TODO: test get_ecc_signing_pubkey -// TODO: test get_rsa_encryption_pubkey - pub fn get_state_works(eid: sgx_enclave_id_t) { let alice = AccountKeyring::Alice; let trusted_getter_signed = test_trusted_getter_signed(alice).encode(); diff --git a/worker/src/tests/integration_tests.rs b/worker/src/tests/integration_tests.rs index bbc0891c51..84b824ba80 100644 --- a/worker/src/tests/integration_tests.rs +++ b/worker/src/tests/integration_tests.rs @@ -56,10 +56,11 @@ pub fn call_worker_encrypted_set_balance_works( port: &str, last_synced_head: Header, ) -> Header { - let (api, nonce, shard) = setup(eid, Some(AccountKeyring::Alice), port); + let root = AccountKeyring::Alice; // Alice is configure as root in our STF + let (api, nonce, shard) = setup(eid, Some(root), port); let req = Request { shard, - cyphertext: encrypted_set_balance(eid, AccountKeyring::Alice, nonce.unwrap()), + cyphertext: encrypted_set_balance(eid, root, nonce.unwrap()), }; let xt: UncheckedExtrinsicV4 = @@ -99,7 +100,6 @@ pub fn forward_encrypted_unshield_works( pub fn init_chain_relay(eid: sgx_enclave_id_t, port: &str) -> Header { let (api, _, _) = setup(eid, None, port); - // crate::init_chain_relay(eid, &api) } diff --git a/worker/src/ws_server.rs b/worker/src/ws_server.rs index ff6f3cc106..c2516ed569 100644 --- a/worker/src/ws_server.rs +++ b/worker/src/ws_server.rs @@ -18,7 +18,6 @@ use std::str; use std::thread; -use sgx_crypto_helper::rsa3072::Rsa3072PubKey; use sgx_types::*; use codec::Encode; @@ -88,10 +87,7 @@ fn handle_get_stf_state_msg(eid: sgx_enclave_id_t, getter_str: &str, shard_str: } fn get_worker_pub_key(eid: sgx_enclave_id_t) -> Message { - // request the key - let pubkey = enclave_shielding_key(eid).unwrap(); - let rsa_pubkey: Rsa3072PubKey = - serde_json::from_str(str::from_utf8(&pubkey[..]).unwrap()).unwrap(); + let rsa_pubkey = enclave_shielding_key(eid).unwrap(); debug!(" [WS Server] RSA pubkey {:?}\n", rsa_pubkey); let rsa_pubkey_json = serde_json::to_string(&rsa_pubkey).unwrap(); From ba232e25f197cb04b5357725e272bc739821d72f Mon Sep 17 00:00:00 2001 From: clangenb <37865735+clangenb@users.noreply.github.com> Date: Wed, 27 May 2020 13:53:11 +0200 Subject: [PATCH 04/29] update deps (#143) * bump substrate-api-client: 0.4.6-sub2.0.0-alpha.7. Update compose extrinsic macro call accordingly add tag for sgx-runtime * bump substratee-node-runtime: 0.6.5-sub2.0.0-alpha.7. Change report timestamp unit from seconds to millis [stf] rename my-node-runtime -> substratee-node-runtime to be consistent * bump version: 0.6.4-sub2.0.0-alpha.7 --- Cargo.lock | 28 ++++++------ client/Cargo.toml | 4 +- client/src/main.rs | 5 ++- enclave/Cargo.lock | 62 ++++++++++++++++++++------- enclave/Cargo.toml | 3 +- enclave/chain_relay/Cargo.toml | 2 +- enclave/src/attestation.rs | 2 + enclave/src/lib.rs | 2 + stf/Cargo.toml | 4 +- substratee-node-primitives/Cargo.toml | 8 ++-- substratee-node-primitives/src/lib.rs | 6 +-- worker/Cargo.toml | 4 +- worker/worker-api/Cargo.toml | 2 +- 13 files changed, 87 insertions(+), 45 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 837ac1892b..8f768a28ac 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1183,7 +1183,7 @@ dependencies = [ [[package]] name = "ias-verify" version = "0.1.0" -source = "git+https://github.com/scs/pallet-substratee-registry.git?tag=v0.6.5-sub2.0.0-alpha.7#9d664bbb96e7b529dcb66abf661b2564a3d8f609" +source = "git+https://github.com/scs/pallet-substratee-registry.git?tag=v0.6.7-sub2.0.0-alpha.7#c4bcb69975b96a52a68b95a852d3c4a02c84c241" dependencies = [ "base64", "chrono", @@ -1968,15 +1968,17 @@ dependencies = [ [[package]] name = "pallet-substratee-registry" -version = "0.6.5-sub2.0.0-alpha.7" -source = "git+https://github.com/scs/pallet-substratee-registry.git?tag=v0.6.5-sub2.0.0-alpha.7#9d664bbb96e7b529dcb66abf661b2564a3d8f609" +version = "0.6.7-sub2.0.0-alpha.7" +source = "git+https://github.com/scs/pallet-substratee-registry.git?tag=v0.6.7-sub2.0.0-alpha.7#c4bcb69975b96a52a68b95a852d3c4a02c84c241" dependencies = [ "frame-support", "frame-system", "ias-verify", + "pallet-timestamp", "parity-scale-codec", "sp-core", "sp-io 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-runtime", "sp-std", ] @@ -1998,7 +2000,7 @@ dependencies = [ [[package]] name = "pallet-template" version = "2.0.0-alpha.7" -source = "git+https://github.com/scs/sgx-runtime#32f212bbefffc095bb5ef470b86fd7f776338dbb" +source = "git+https://github.com/scs/sgx-runtime?tag=v2.0.0-alpha.7#32f212bbefffc095bb5ef470b86fd7f776338dbb" dependencies = [ "frame-support", "frame-system", @@ -2960,7 +2962,7 @@ dependencies = [ [[package]] name = "sgx-runtime" version = "2.0.0-alpha.7" -source = "git+https://github.com/scs/sgx-runtime#32f212bbefffc095bb5ef470b86fd7f776338dbb" +source = "git+https://github.com/scs/sgx-runtime?tag=v2.0.0-alpha.7#32f212bbefffc095bb5ef470b86fd7f776338dbb" dependencies = [ "frame-executive", "frame-support", @@ -3714,7 +3716,7 @@ dependencies = [ [[package]] name = "substrate-api-client" version = "0.4.6-sub2.0.0-alpha.7" -source = "git+https://github.com/scs/substrate-api-client?tag=v0.4.6-sub2.0.0-alpha.7#3546fc10f88008a68ba102adbcea66e75ffc5885" +source = "git+https://github.com/scs/substrate-api-client?tag=v0.4.6-sub2.0.0-alpha.7#cce8441c09224ab641619ea077b5b7fb118f6bf6" dependencies = [ "env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "frame-metadata", @@ -3769,7 +3771,7 @@ checksum = "d2a965994514ab35d3893e9260245f2947fd1981cdd4fffd2c6e6d1a9ce02e6a" [[package]] name = "substratee-client" -version = "0.6.3-sub2.0.0-alpha.7" +version = "0.6.4-sub2.0.0-alpha.7" dependencies = [ "base58", "blake2-rfc", @@ -3801,7 +3803,7 @@ dependencies = [ [[package]] name = "substratee-node-primitives" -version = "0.6.3-sub2.0.0-alpha.7" +version = "0.6.4-sub2.0.0-alpha.7" dependencies = [ "base58", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3816,8 +3818,8 @@ dependencies = [ [[package]] name = "substratee-node-runtime" -version = "0.6.3-sub2.0.0-alpha.7" -source = "git+https://github.com/scs/substraTEE-node?tag=v0.6.3-sub2.0.0-alpha.7#b75d1fe59d8ca8764ca486b3c5ca19e0ba9a8039" +version = "0.6.5-sub2.0.0-alpha.7" +source = "git+https://github.com/scs/substraTEE-node?tag=v0.6.5-sub2.0.0-alpha.7#6b0ef0b840c34e0a9beb418125a6dc7904a7862c" dependencies = [ "frame-executive", "frame-support", @@ -3849,7 +3851,7 @@ dependencies = [ [[package]] name = "substratee-stf" -version = "0.2.0" +version = "0.6.4-sub2.0.0-alpha.7" dependencies = [ "base58", "clap", @@ -3874,7 +3876,7 @@ dependencies = [ [[package]] name = "substratee-worker" -version = "0.6.3-sub2.0.0-alpha.7" +version = "0.6.4-sub2.0.0-alpha.7" dependencies = [ "base58", "cid", @@ -3913,7 +3915,7 @@ dependencies = [ [[package]] name = "substratee-worker-api" -version = "0.6.3-sub2.0.0-alpha.7" +version = "0.6.4-sub2.0.0-alpha.7" dependencies = [ "hex 0.4.2", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/client/Cargo.toml b/client/Cargo.toml index d620b81495..f0abe477c5 100644 --- a/client/Cargo.toml +++ b/client/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "substratee-client" -version = "0.6.3-sub2.0.0-alpha.7" +version = "0.6.4-sub2.0.0-alpha.7" authors = ["Supercomputing Systems AG "] edition = "2018" @@ -53,7 +53,7 @@ default-features=false [dependencies.substratee-node-runtime] git = "https://github.com/scs/substraTEE-node" -tag = "v0.6.3-sub2.0.0-alpha.7" +tag = "v0.6.5-sub2.0.0-alpha.7" package = "substratee-node-runtime" [dependencies.substratee-stf] diff --git a/client/src/main.rs b/client/src/main.rs index 838a0971c2..16da252939 100644 --- a/client/src/main.rs +++ b/client/src/main.rs @@ -291,7 +291,7 @@ fn main() { }; let enclave = enclave.unwrap(); let timestamp = DateTime::::from( - UNIX_EPOCH + Duration::from_secs(enclave.timestamp as u64), + UNIX_EPOCH + Duration::from_millis(enclave.timestamp as u64), ); println!("Enclave {}", w); println!(" AccountId: {}", enclave.pubkey.to_ss58check()); @@ -515,6 +515,9 @@ fn send_request(matches: &ArgMatches<'_>, call: TrustedCallSigned) -> Option("ShardIdentifier") .unwrap(); + decoder + .register_type_size::<(Hash, Vec)>("Request") + .unwrap(); loop { let ret: CallConfirmedArgs = _chain_api diff --git a/enclave/Cargo.lock b/enclave/Cargo.lock index 7680aff430..3fe0998449 100644 --- a/enclave/Cargo.lock +++ b/enclave/Cargo.lock @@ -172,7 +172,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "chain-relay" -version = "0.6.3-sub2.0.0-alpha.7" +version = "0.6.4-sub2.0.0-alpha.7" dependencies = [ "derive_more 0.99.5 (registry+https://github.com/rust-lang/crates.io-index)", "finality-grandpa 0.11.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -963,7 +963,7 @@ dependencies = [ [[package]] name = "pallet-template" version = "2.0.0-alpha.7" -source = "git+https://github.com/scs/sgx-runtime#32f212bbefffc095bb5ef470b86fd7f776338dbb" +source = "git+https://github.com/scs/sgx-runtime?tag=v2.0.0-alpha.7#32f212bbefffc095bb5ef470b86fd7f776338dbb" dependencies = [ "frame-support 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "frame-system 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1430,6 +1430,18 @@ dependencies = [ "sgx_tstd 1.1.2 (git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2)", ] +[[package]] +name = "sgx-externalities" +version = "0.2.0" +source = "git+https://github.com/scs/sgx-runtime?tag=v2.0.0-alpha.7#32f212bbefffc095bb5ef470b86fd7f776338dbb" +dependencies = [ + "environmental 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (git+https://github.com/mesalock-linux/log-sgx)", + "sgx_serialize 1.1.2 (git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2)", + "sgx_tstd 1.1.2 (git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2)", + "sgx_types 1.1.2 (git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2)", +] + [[package]] name = "sgx-externalities" version = "0.2.0" @@ -1445,7 +1457,7 @@ dependencies = [ [[package]] name = "sgx-runtime" version = "2.0.0-alpha.7" -source = "git+https://github.com/scs/sgx-runtime#32f212bbefffc095bb5ef470b86fd7f776338dbb" +source = "git+https://github.com/scs/sgx-runtime?tag=v2.0.0-alpha.7#32f212bbefffc095bb5ef470b86fd7f776338dbb" dependencies = [ "frame-executive 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "frame-support 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1455,7 +1467,7 @@ dependencies = [ "pallet-grandpa 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "pallet-randomness-collective-flip 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "pallet-sudo 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", - "pallet-template 2.0.0-alpha.7 (git+https://github.com/scs/sgx-runtime)", + "pallet-template 2.0.0-alpha.7 (git+https://github.com/scs/sgx-runtime?tag=v2.0.0-alpha.7)", "pallet-timestamp 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "pallet-transaction-payment 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1815,6 +1827,24 @@ dependencies = [ "sp-std 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "sp-io" +version = "2.0.0-alpha.7" +source = "git+https://github.com/scs/sgx-runtime?tag=v2.0.0-alpha.7#32f212bbefffc095bb5ef470b86fd7f776338dbb" +dependencies = [ + "environmental 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "hash-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (git+https://github.com/mesalock-linux/log-sgx)", + "parity-scale-codec 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sgx-externalities 0.2.0 (git+https://github.com/scs/sgx-runtime?tag=v2.0.0-alpha.7)", + "sgx_tstd 1.1.2 (git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2)", + "sgx_types 1.1.2 (git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2)", + "sp-core 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-runtime-interface 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-std 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-wasm-interface 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "sp-io" version = "2.0.0-alpha.7" @@ -2016,7 +2046,7 @@ dependencies = [ [[package]] name = "substrate-api-client" version = "0.4.6-sub2.0.0-alpha.7" -source = "git+https://github.com/scs/substrate-api-client?tag=v0.4.6-sub2.0.0-alpha.7#3546fc10f88008a68ba102adbcea66e75ffc5885" +source = "git+https://github.com/scs/substrate-api-client?tag=v0.4.6-sub2.0.0-alpha.7#cce8441c09224ab641619ea077b5b7fb118f6bf6" dependencies = [ "frame-metadata 11.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "frame-support 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2038,7 +2068,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "substratee-node-primitives" -version = "0.6.3-sub2.0.0-alpha.7" +version = "0.6.4-sub2.0.0-alpha.7" dependencies = [ "parity-scale-codec 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "primitive-types 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2048,7 +2078,7 @@ dependencies = [ [[package]] name = "substratee-stf" -version = "0.2.0" +version = "0.6.4-sub2.0.0-alpha.7" dependencies = [ "derive_more 0.99.5 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.7.1 (git+https://github.com/mesalock-linux/env_logger-sgx)", @@ -2057,7 +2087,7 @@ dependencies = [ "log 0.4.8 (git+https://github.com/mesalock-linux/log-sgx)", "pallet-balances 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "sgx-runtime 2.0.0-alpha.7 (git+https://github.com/scs/sgx-runtime)", + "sgx-runtime 2.0.0-alpha.7 (git+https://github.com/scs/sgx-runtime?tag=v2.0.0-alpha.7)", "sgx_tstd 1.1.2 (git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2)", "sp-application-crypto 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "sp-core 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2067,12 +2097,12 @@ dependencies = [ [[package]] name = "substratee-worker-enclave" -version = "0.6.3-sub2.0.0-alpha.7" +version = "0.6.4-sub2.0.0-alpha.7" dependencies = [ "aes 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "base64 0.10.1 (git+https://github.com/mesalock-linux/rust-base64-sgx)", "bit-vec 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", - "chain-relay 0.6.3-sub2.0.0-alpha.7", + "chain-relay 0.6.4-sub2.0.0-alpha.7", "chrono 0.4.11 (git+https://github.com/mesalock-linux/chrono-sgx)", "env_logger 0.7.1 (git+https://github.com/mesalock-linux/env_logger-sgx)", "httparse 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2102,12 +2132,12 @@ dependencies = [ "sgx_types 1.1.2 (git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2)", "sp-core 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "sp-finality-grandpa 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", - "sp-io 2.0.0-alpha.7 (git+https://github.com/scs/sgx-runtime)", + "sp-io 2.0.0-alpha.7 (git+https://github.com/scs/sgx-runtime?tag=v2.0.0-alpha.7)", "sp-runtime 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "sp-std 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "substrate-api-client 0.4.6-sub2.0.0-alpha.7 (git+https://github.com/scs/substrate-api-client?tag=v0.4.6-sub2.0.0-alpha.7)", - "substratee-node-primitives 0.6.3-sub2.0.0-alpha.7", - "substratee-stf 0.2.0", + "substratee-node-primitives 0.6.4-sub2.0.0-alpha.7", + "substratee-stf 0.6.4-sub2.0.0-alpha.7", "webpki 0.21.2 (git+https://github.com/mesalock-linux/webpki?branch=mesalock_sgx)", "webpki-roots 0.19.0 (git+https://github.com/mesalock-linux/webpki-roots?branch=mesalock_sgx)", "yasna 0.3.1 (git+https://github.com/mesalock-linux/yasna.rs-sgx?rev=sgx_1.1.2)", @@ -2455,7 +2485,7 @@ dependencies = [ "checksum pallet-randomness-collective-flip 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)" = "e6f06234e000e7b7554d75d62280e953f902981196d6dcde0d084ad5c7df4809" "checksum pallet-session 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)" = "6aace05f197abe3905182ec817e6fadc3c985b3c2ec41bfc74bb9918d1585e9e" "checksum pallet-sudo 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)" = "246c9c0b5c29baff01d925ebadee6c0c642fa4c56ba8de1957f1ecc1438cc7dc" -"checksum pallet-template 2.0.0-alpha.7 (git+https://github.com/scs/sgx-runtime)" = "" +"checksum pallet-template 2.0.0-alpha.7 (git+https://github.com/scs/sgx-runtime?tag=v2.0.0-alpha.7)" = "" "checksum pallet-timestamp 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)" = "4c90b652dfb8796d657a2df5fa6200ada33b9784554b81a32efd73de2fe00575" "checksum pallet-transaction-payment 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)" = "52333b8598b2bcb3af5e158c61cb2d30821220a5034e92a74c6a4ef116d82a7f" "checksum pallet-transaction-payment-rpc-runtime-api 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)" = "40f6cc2ebdaff949b9f38cc03f19e541bd22773ce32e84532ac1d85a481cb112" @@ -2509,7 +2539,8 @@ dependencies = [ "checksum serde_derive 1.0.110 (registry+https://github.com/rust-lang/crates.io-index)" = "818fbf6bfa9a42d3bfcaca148547aa00c7b915bec71d1757aa2d44ca68771984" "checksum serde_json 1.0.51 (git+https://github.com/mesalock-linux/serde-json-sgx?rev=sgx_1.1.2)" = "" "checksum sgx-externalities 0.2.0 (git+https://github.com/scs/sgx-runtime)" = "" -"checksum sgx-runtime 2.0.0-alpha.7 (git+https://github.com/scs/sgx-runtime)" = "" +"checksum sgx-externalities 0.2.0 (git+https://github.com/scs/sgx-runtime?tag=v2.0.0-alpha.7)" = "" +"checksum sgx-runtime 2.0.0-alpha.7 (git+https://github.com/scs/sgx-runtime?tag=v2.0.0-alpha.7)" = "" "checksum sgx_alloc 1.1.2 (git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2)" = "" "checksum sgx_backtrace_sys 1.1.2 (git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2)" = "" "checksum sgx_build_helper 0.1.3 (git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2)" = "" @@ -2545,6 +2576,7 @@ dependencies = [ "checksum sp-finality-tracker 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)" = "8f050f19f1e07b63f61a872552fecf7239c75e77dc133a5f5ae00dac0e7b348d" "checksum sp-inherents 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)" = "8367b0e285f8c3ab00400a5f5b53ff0dba263005d2458fdc3e9652f824205f0b" "checksum sp-io 2.0.0-alpha.7 (git+https://github.com/scs/sgx-runtime)" = "" +"checksum sp-io 2.0.0-alpha.7 (git+https://github.com/scs/sgx-runtime?tag=v2.0.0-alpha.7)" = "" "checksum sp-offchain 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)" = "e63092c0ecd8fc90971a14a169f62337b78d885873e55dee87f33fe5f76d6591" "checksum sp-runtime 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)" = "0d37f6a2e111dd82dd194fa9ef77ba49b17e70162afc237f99e7c5dc6f95834f" "checksum sp-runtime-interface 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)" = "bc743ea280556cbaf82203ec63ade39f4167402cb571aaf012c6c43f092ccf33" diff --git a/enclave/Cargo.toml b/enclave/Cargo.toml index 0eee1ec4a8..bfd1b308a4 100644 --- a/enclave/Cargo.toml +++ b/enclave/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "substratee-worker-enclave" -version = "0.6.3-sub2.0.0-alpha.7" +version = "0.6.4-sub2.0.0-alpha.7" authors = ["Supercomputing Systems AG "] edition = "2018" @@ -73,6 +73,7 @@ features = ["dangerous_configuration"] [dependencies.sp-io] git = "https://github.com/scs/sgx-runtime" +tag = "v2.0.0-alpha.7" default-features = false optional = true package = "sp-io" diff --git a/enclave/chain_relay/Cargo.toml b/enclave/chain_relay/Cargo.toml index 62026d1796..0a961e4984 100644 --- a/enclave/chain_relay/Cargo.toml +++ b/enclave/chain_relay/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "chain-relay" -version = "0.6.3-sub2.0.0-alpha.7" +version = "0.6.4-sub2.0.0-alpha.7" authors = ["Supercomputing Systems AG "] edition = "2018" diff --git a/enclave/src/attestation.rs b/enclave/src/attestation.rs index 6520bfaac9..32c6f7131b 100644 --- a/enclave/src/attestation.rs +++ b/enclave/src/attestation.rs @@ -644,6 +644,8 @@ pub unsafe extern "C" fn perform_ra( signer, (call, cert_der.to_vec(), url_slice.to_vec()), *nonce, + Era::Immortal, + genesis_hash, genesis_hash, RUNTIME_SPEC_VERSION ); diff --git a/enclave/src/lib.rs b/enclave/src/lib.rs index f1b173c61f..2927c5e03f 100644 --- a/enclave/src/lib.rs +++ b/enclave/src/lib.rs @@ -174,6 +174,8 @@ fn stf_post_actions( signer.clone(), call, nonce, + Era::Immortal, + validator.genesis_hash(validator.num_relays).unwrap(), validator.genesis_hash(validator.num_relays).unwrap(), RUNTIME_SPEC_VERSION ) diff --git a/stf/Cargo.toml b/stf/Cargo.toml index e00e4b74ed..31aac7c9d2 100644 --- a/stf/Cargo.toml +++ b/stf/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "substratee-stf" -version = "0.2.0" +version = "0.6.4-sub2.0.0-alpha.7" authors = ["Supercomputing Systems AG "] edition = "2018" @@ -85,7 +85,7 @@ features = ["disable_oom", "disable_panic_handler", "disable_allocator", "sgx"] [dependencies.sgx-runtime] default-features = false git = "https://github.com/scs/sgx-runtime" -#tag = "v2.0.0-alpha.6" +tag = "v2.0.0-alpha.7" optional = true [dependencies.sc-keystore] diff --git a/substratee-node-primitives/Cargo.toml b/substratee-node-primitives/Cargo.toml index e92614d5b7..735187ab5d 100644 --- a/substratee-node-primitives/Cargo.toml +++ b/substratee-node-primitives/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "substratee-node-primitives" -version = "0.6.3-sub2.0.0-alpha.7" +version = "0.6.4-sub2.0.0-alpha.7" authors = ["clangenbacher "] edition = "2018" @@ -16,9 +16,9 @@ features = ["untrusted_fs","net","backtrace"] rev = "v1.1.2" optional = true -[dependencies.my-node-runtime] +[dependencies.substratee-node-runtime] git = "https://github.com/scs/substraTEE-node" -tag = "v0.6.3-sub2.0.0-alpha.7" +tag = "v0.6.5-sub2.0.0-alpha.7" package = "substratee-node-runtime" optional = true default-features = false @@ -40,7 +40,7 @@ optional = true [features] default = ['std'] std = [ 'substrate-api-client', - 'my-node-runtime', + 'substratee-node-runtime', 'sp-core/std', 'sp-runtime', 'base58', diff --git a/substratee-node-primitives/src/lib.rs b/substratee-node-primitives/src/lib.rs index 112ab82058..c4aaf67335 100644 --- a/substratee-node-primitives/src/lib.rs +++ b/substratee-node-primitives/src/lib.rs @@ -23,12 +23,12 @@ pub type CallWorkerFn = ([u8; 2], Request); #[cfg(feature = "std")] pub mod calls { - pub use my_node_runtime::{ + use sp_core::crypto::Pair; + use sp_runtime::MultiSignature; + pub use substratee_node_runtime::{ substratee_registry::{Enclave, ShardIdentifier}, AccountId, }; - use sp_core::crypto::Pair; - use sp_runtime::MultiSignature; pub fn get_worker_info( api: &substrate_api_client::Api

, diff --git a/worker/Cargo.toml b/worker/Cargo.toml index 34ae2b7376..04b67d32e9 100644 --- a/worker/Cargo.toml +++ b/worker/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "substratee-worker" -version = "0.6.3-sub2.0.0-alpha.7" +version = "0.6.4-sub2.0.0-alpha.7" authors = ["Supercomputing Systems AG "] build = "build.rs" edition = "2018" @@ -46,7 +46,7 @@ path = "worker-api" [dependencies.substratee-node-runtime] git = "https://github.com/scs/substraTEE-node" -tag = "v0.6.3-sub2.0.0-alpha.7" +tag = "v0.6.5-sub2.0.0-alpha.7" package = "substratee-node-runtime" [dependencies.sp-finality-grandpa] diff --git a/worker/worker-api/Cargo.toml b/worker/worker-api/Cargo.toml index 057aadb598..80ad3c4386 100644 --- a/worker/worker-api/Cargo.toml +++ b/worker/worker-api/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "substratee-worker-api" -version = "0.6.3-sub2.0.0-alpha.7" +version = "0.6.4-sub2.0.0-alpha.7" authors = ["Supercomputing Systems AG "] edition = "2018" From cc77d379809fdba444fb0f4a97373e5599cc6016 Mon Sep 17 00:00:00 2001 From: Marcel Frei Date: Thu, 28 May 2020 07:47:56 +0200 Subject: [PATCH 05/29] Jenkinsfile: Archive binaries --- Jenkinsfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Jenkinsfile b/Jenkinsfile index cab5bdb251..4414344868 100755 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -80,6 +80,7 @@ pipeline { stage('Archive build output') { steps { archiveArtifacts artifacts: '*.log' + archiveArtifacts artifacts: 'bin/enclave.signed.so, bin/substratee-*, *.log', caseSensitive: false, fingerprint: true, onlyIfSuccessful: true } } } From 2448db9c7f5d277ccc1e1c1ea77dfaf5717b837c Mon Sep 17 00:00:00 2001 From: Marcel Frei Date: Thu, 28 May 2020 21:33:39 +0200 Subject: [PATCH 06/29] Jenkinsfile: Archive binary after build --- Jenkinsfile | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 4414344868..5b30a00555 100755 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -25,6 +25,11 @@ pipeline { sh 'make' } } + stage('Archive build output') { + steps { + archiveArtifacts artifacts: 'bin/enclave.signed.so, bin/substratee-*', caseSensitive: false, fingerprint: true, onlyIfSuccessful: true + } + } stage('Test') { steps { sh 'cd client && cargo test 2>&1 | tee ${WORKSPACE}/test_client.log' @@ -77,10 +82,9 @@ pipeline { } } } - stage('Archive build output') { + stage('Archive logs') { steps { archiveArtifacts artifacts: '*.log' - archiveArtifacts artifacts: 'bin/enclave.signed.so, bin/substratee-*, *.log', caseSensitive: false, fingerprint: true, onlyIfSuccessful: true } } } From 76be1ff0acc316873e5903df1d32fac776fdb525 Mon Sep 17 00:00:00 2001 From: clangenb <37865735+clangenb@users.noreply.github.com> Date: Fri, 29 May 2020 10:47:04 +0200 Subject: [PATCH 07/29] * bump node: v0.6.6-sub2.0.0-alpha.7 (#147) * include hash of trusted_call_signed in shield_funds extrinsic * change call_hash to H256 --- Cargo.lock | 10 +++++----- client/Cargo.toml | 2 +- client/src/main.rs | 12 +++++------- enclave/src/lib.rs | 23 +++++++++++------------ stf/src/sgx.rs | 20 +++++++++++--------- substratee-node-primitives/Cargo.toml | 2 +- substratee-node-primitives/src/lib.rs | 2 +- worker/Cargo.toml | 2 +- worker/src/main.rs | 7 +++++++ 9 files changed, 43 insertions(+), 37 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8f768a28ac..b618db11e8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1183,7 +1183,7 @@ dependencies = [ [[package]] name = "ias-verify" version = "0.1.0" -source = "git+https://github.com/scs/pallet-substratee-registry.git?tag=v0.6.7-sub2.0.0-alpha.7#c4bcb69975b96a52a68b95a852d3c4a02c84c241" +source = "git+https://github.com/scs/pallet-substratee-registry.git?tag=v0.6.8-sub2.0.0-alpha.7#9adb121943960f983e6261d64c74f7d4bba37918" dependencies = [ "base64", "chrono", @@ -1968,8 +1968,8 @@ dependencies = [ [[package]] name = "pallet-substratee-registry" -version = "0.6.7-sub2.0.0-alpha.7" -source = "git+https://github.com/scs/pallet-substratee-registry.git?tag=v0.6.7-sub2.0.0-alpha.7#c4bcb69975b96a52a68b95a852d3c4a02c84c241" +version = "0.6.8-sub2.0.0-alpha.7" +source = "git+https://github.com/scs/pallet-substratee-registry.git?tag=v0.6.8-sub2.0.0-alpha.7#9adb121943960f983e6261d64c74f7d4bba37918" dependencies = [ "frame-support", "frame-system", @@ -3818,8 +3818,8 @@ dependencies = [ [[package]] name = "substratee-node-runtime" -version = "0.6.5-sub2.0.0-alpha.7" -source = "git+https://github.com/scs/substraTEE-node?tag=v0.6.5-sub2.0.0-alpha.7#6b0ef0b840c34e0a9beb418125a6dc7904a7862c" +version = "0.6.6-sub2.0.0-alpha.7" +source = "git+https://github.com/scs/substraTEE-node?tag=v0.6.6-sub2.0.0-alpha.7#53c2c0330ebf55b869f2fcd106490cff9a466417" dependencies = [ "frame-executive", "frame-support", diff --git a/client/Cargo.toml b/client/Cargo.toml index f0abe477c5..0be8e5c130 100644 --- a/client/Cargo.toml +++ b/client/Cargo.toml @@ -53,7 +53,7 @@ default-features=false [dependencies.substratee-node-runtime] git = "https://github.com/scs/substraTEE-node" -tag = "v0.6.5-sub2.0.0-alpha.7" +tag = "v0.6.6-sub2.0.0-alpha.7" package = "substratee-node-runtime" [dependencies.substratee-stf] diff --git a/client/src/main.rs b/client/src/main.rs index 16da252939..a7a80b4a91 100644 --- a/client/src/main.rs +++ b/client/src/main.rs @@ -515,9 +515,7 @@ fn send_request(matches: &ArgMatches<'_>, call: TrustedCallSigned) -> Option("ShardIdentifier") .unwrap(); - decoder - .register_type_size::<(Hash, Vec)>("Request") - .unwrap(); + decoder.register_type_size::("H256").unwrap(); loop { let ret: CallConfirmedArgs = _chain_api @@ -529,7 +527,7 @@ fn send_request(matches: &ArgMatches<'_>, call: TrustedCallSigned) -> Option, call: TrustedCallSigned) -> Option, + payload: H256, } fn listen(matches: &ArgMatches<'_>) { @@ -619,7 +617,7 @@ fn listen(matches: &ArgMatches<'_>) { } // subscribes to he substratee_registry events of type CallConfirmed -pub fn subscribe_to_call_confirmed(api: Api

) -> Vec +pub fn subscribe_to_call_confirmed(api: Api

) -> H256 where MultiSignature: From, { @@ -649,7 +647,7 @@ where ) = &pe { println!("[+] Received confirm call from {}", sender); - return payload.to_vec(); + return payload.clone().to_owned(); } else { debug!( "received unknown event from SubstraTeeRegistry: {:?}", diff --git a/enclave/src/lib.rs b/enclave/src/lib.rs index 2927c5e03f..49874f373e 100644 --- a/enclave/src/lib.rs +++ b/enclave/src/lib.rs @@ -385,12 +385,16 @@ fn handle_shield_funds_xt( debug!("decrypt the call"); let rsa_keypair = rsa3072::unseal_pair()?; let account_vec = rsa3072::decrypt(&account_encrypted, &rsa_keypair)?; - let account = AccountId::decode(&mut account_vec.as_slice()).sgx_error()?; + let account = AccountId::decode(&mut account_vec.as_slice()) + .sgx_error_with_log("[ShieldFunds] Could not decode account")?; if let Err(e) = Stf::execute( &mut state, - TrustedCall::balance_shield(account, amount), - Default::default(), + TrustedCallSigned::new( + TrustedCall::balance_shield(account, amount), + 0, + Default::default(), + ), calls, ) { error!("Error performing Stf::execute. Error: {:?}", e); @@ -402,7 +406,7 @@ fn handle_shield_funds_xt( ( xt_call, shard, - blake2_256(&xt.encode()).to_vec(), + blake2_256(&xt.encode()), state_hash.encode(), ) .encode(), @@ -448,7 +452,7 @@ fn handle_call_worker_xt( let mut state = state::load(&shard)?; debug!("Update STF storage!"); - let requests = Stf::get_storage_hashes_to_update(&stf_call_signed.call) + let requests = Stf::get_storage_hashes_to_update(&stf_call_signed) .into_iter() .map(|key| WorkerRequest::ChainStorage(key, Some(header.hash()))) .collect(); @@ -486,12 +490,7 @@ fn handle_call_worker_xt( Stf::update_storage(&mut state, update_map); debug!("execute STF"); - if let Err(e) = Stf::execute( - &mut state, - stf_call_signed.call, - stf_call_signed.nonce, - calls, - ) { + if let Err(e) = Stf::execute(&mut state, stf_call_signed, calls) { error!("Error performing Stf::execute. Error: {:?}", e); return Ok(()); } @@ -503,7 +502,7 @@ fn handle_call_worker_xt( debug!("Call hash 0x{}", hex::encode_hex(&call_hash)); calls.push(OpaqueCall( - (xt_call, shard, call_hash.to_vec(), state_hash.encode()).encode(), + (xt_call, shard, call_hash, state_hash.encode()).encode(), )); Ok(()) diff --git a/stf/src/sgx.rs b/stf/src/sgx.rs index 145007fe66..1695b01af8 100644 --- a/stf/src/sgx.rs +++ b/stf/src/sgx.rs @@ -12,8 +12,10 @@ use sp_io::SgxExternalitiesTrait; use sp_runtime::traits::Dispatchable; use crate::{ - AccountId, State, Stf, TrustedCall, TrustedGetter, SUBSRATEE_REGISTRY_MODULE, UNSHIELD, + AccountId, State, Stf, TrustedCall, TrustedCallSigned, TrustedGetter, + SUBSRATEE_REGISTRY_MODULE, UNSHIELD, }; +use sp_core::blake2_256; /// Simple blob that holds a call in encoded format #[derive(Clone, Debug)] @@ -77,11 +79,10 @@ impl Stf { pub fn execute( ext: &mut State, - call: TrustedCall, - _nonce: u32, + call: TrustedCallSigned, calls: &mut Vec, ) -> Result<(), StfError> { - ext.execute_with(|| match call { + ext.execute_with(|| match call.call { TrustedCall::balance_set_balance(root, who, free_balance, reserved_balance) => { Self::ensure_root(root)?; sgx_runtime::BalancesCall::::set_balance( @@ -108,6 +109,7 @@ impl Stf { beneficiary, value, shard, + blake2_256(&call.encode()), ) .encode(), )); @@ -185,17 +187,17 @@ impl Stf { } } - pub fn get_storage_hashes_to_update(call: &TrustedCall) -> Vec> { + pub fn get_storage_hashes_to_update(call: &TrustedCallSigned) -> Vec> { let mut key_hashes = Vec::new(); - match call { + match call.call { TrustedCall::balance_set_balance(account, _, _, _) => { - key_hashes.push(nonce_key_hash(account)) // dummy, actually not necessary + key_hashes.push(nonce_key_hash(&account)) // dummy, actually not necessary } TrustedCall::balance_transfer(account, _, _) => { - key_hashes.push(nonce_key_hash(account)) // dummy, actually not necessary + key_hashes.push(nonce_key_hash(&account)) // dummy, actually not necessary } TrustedCall::balance_unshield(account, _, _, _) => { - key_hashes.push(nonce_key_hash(account)) + key_hashes.push(nonce_key_hash(&account)) } TrustedCall::balance_shield(_, _) => debug!("No storage updates needed..."), }; diff --git a/substratee-node-primitives/Cargo.toml b/substratee-node-primitives/Cargo.toml index 735187ab5d..77839e51fc 100644 --- a/substratee-node-primitives/Cargo.toml +++ b/substratee-node-primitives/Cargo.toml @@ -18,7 +18,7 @@ optional = true [dependencies.substratee-node-runtime] git = "https://github.com/scs/substraTEE-node" -tag = "v0.6.5-sub2.0.0-alpha.7" +tag = "v0.6.6-sub2.0.0-alpha.7" package = "substratee-node-runtime" optional = true default-features = false diff --git a/substratee-node-primitives/src/lib.rs b/substratee-node-primitives/src/lib.rs index c4aaf67335..ba3584b72f 100644 --- a/substratee-node-primitives/src/lib.rs +++ b/substratee-node-primitives/src/lib.rs @@ -17,7 +17,7 @@ pub struct Request { pub cyphertext: Vec, } -pub type SubstrateeConfirmCallFn = ([u8; 2], ShardIdentifier, Vec, Vec); +pub type SubstrateeConfirmCallFn = ([u8; 2], ShardIdentifier, H256, Vec); pub type ShieldFundsFn = ([u8; 2], Vec, u128, ShardIdentifier); pub type CallWorkerFn = ([u8; 2], Request); diff --git a/worker/Cargo.toml b/worker/Cargo.toml index 04b67d32e9..546dea79c9 100644 --- a/worker/Cargo.toml +++ b/worker/Cargo.toml @@ -46,7 +46,7 @@ path = "worker-api" [dependencies.substratee-node-runtime] git = "https://github.com/scs/substraTEE-node" -tag = "v0.6.5-sub2.0.0-alpha.7" +tag = "v0.6.6-sub2.0.0-alpha.7" package = "substratee-node-runtime" [dependencies.sp-finality-grandpa] diff --git a/worker/src/main.rs b/worker/src/main.rs index 8e18d01cc1..3f6bf7529c 100644 --- a/worker/src/main.rs +++ b/worker/src/main.rs @@ -398,6 +398,13 @@ fn print_events(events: Events, _sender: Sender) { debug!(" For: {:?}", incognito_account); println!(); } + substratee_node_runtime::substratee_registry::RawEvent::UnshieldedFunds( + incognito_account, + ) => { + println!("[+] Received UnshieldedFunds event"); + debug!(" For: {:?}", incognito_account); + println!(); + } _ => { info!("Ignoring unsupported substratee_registry event"); } From ca3ef97854665b9991534b7b11b9ba861d503456 Mon Sep 17 00:00:00 2001 From: clangenb <37865735+clangenb@users.noreply.github.com> Date: Fri, 29 May 2020 11:50:04 +0200 Subject: [PATCH 08/29] fix running multiple workers (#149) * [worker] initialize chain after keys have been provisioned * [worker] fix cli for key_provisioning tests * [worker/mu-ra] pass shard that should be exchanged is passed to request_key_provisioning * [enclave/cert] fix mr_enclave fetch and comparison * [enclave/tls_ra] remove state exchange from ra as every new worker fetches calculates the state from 0. * [worker] change get_most_recent_worker -> get_first_worker that is not equal to self * [worker] ensure_shard_initialized now in any case as we do not fetch a state while provisioning secrets. And put it at the very beginning of `fn worker` * [enclave/tls_ra] remove unsafe from request_key_provisioning * bump version: 0.6.5-sub2.0.0-alpha.7 --- Cargo.lock | 10 +-- client/Cargo.toml | 2 +- enclave/Cargo.lock | 14 ++-- enclave/Cargo.toml | 2 +- enclave/Enclave.edl | 2 +- enclave/chain_relay/Cargo.toml | 2 +- enclave/src/cert.rs | 10 +-- enclave/src/tls_ra.rs | 97 +++------------------------ stf/Cargo.toml | 2 +- substratee-node-primitives/Cargo.toml | 2 +- substratee-node-primitives/src/lib.rs | 19 +++++- worker/Cargo.toml | 2 +- worker/src/cli.yml | 4 ++ worker/src/enclave/tls_ra.rs | 1 + worker/src/main.rs | 50 ++++++-------- worker/worker-api/Cargo.toml | 2 +- 16 files changed, 79 insertions(+), 142 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b618db11e8..bd2b391846 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3771,7 +3771,7 @@ checksum = "d2a965994514ab35d3893e9260245f2947fd1981cdd4fffd2c6e6d1a9ce02e6a" [[package]] name = "substratee-client" -version = "0.6.4-sub2.0.0-alpha.7" +version = "0.6.5-sub2.0.0-alpha.7" dependencies = [ "base58", "blake2-rfc", @@ -3803,7 +3803,7 @@ dependencies = [ [[package]] name = "substratee-node-primitives" -version = "0.6.4-sub2.0.0-alpha.7" +version = "0.6.5-sub2.0.0-alpha.7" dependencies = [ "base58", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3851,7 +3851,7 @@ dependencies = [ [[package]] name = "substratee-stf" -version = "0.6.4-sub2.0.0-alpha.7" +version = "0.6.5-sub2.0.0-alpha.7" dependencies = [ "base58", "clap", @@ -3876,7 +3876,7 @@ dependencies = [ [[package]] name = "substratee-worker" -version = "0.6.4-sub2.0.0-alpha.7" +version = "0.6.5-sub2.0.0-alpha.7" dependencies = [ "base58", "cid", @@ -3915,7 +3915,7 @@ dependencies = [ [[package]] name = "substratee-worker-api" -version = "0.6.4-sub2.0.0-alpha.7" +version = "0.6.5-sub2.0.0-alpha.7" dependencies = [ "hex 0.4.2", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/client/Cargo.toml b/client/Cargo.toml index 0be8e5c130..9ead5b19e2 100644 --- a/client/Cargo.toml +++ b/client/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "substratee-client" -version = "0.6.4-sub2.0.0-alpha.7" +version = "0.6.5-sub2.0.0-alpha.7" authors = ["Supercomputing Systems AG "] edition = "2018" diff --git a/enclave/Cargo.lock b/enclave/Cargo.lock index 3fe0998449..abb58e4452 100644 --- a/enclave/Cargo.lock +++ b/enclave/Cargo.lock @@ -172,7 +172,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "chain-relay" -version = "0.6.4-sub2.0.0-alpha.7" +version = "0.6.5-sub2.0.0-alpha.7" dependencies = [ "derive_more 0.99.5 (registry+https://github.com/rust-lang/crates.io-index)", "finality-grandpa 0.11.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2068,7 +2068,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "substratee-node-primitives" -version = "0.6.4-sub2.0.0-alpha.7" +version = "0.6.5-sub2.0.0-alpha.7" dependencies = [ "parity-scale-codec 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "primitive-types 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2078,7 +2078,7 @@ dependencies = [ [[package]] name = "substratee-stf" -version = "0.6.4-sub2.0.0-alpha.7" +version = "0.6.5-sub2.0.0-alpha.7" dependencies = [ "derive_more 0.99.5 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.7.1 (git+https://github.com/mesalock-linux/env_logger-sgx)", @@ -2097,12 +2097,12 @@ dependencies = [ [[package]] name = "substratee-worker-enclave" -version = "0.6.4-sub2.0.0-alpha.7" +version = "0.6.5-sub2.0.0-alpha.7" dependencies = [ "aes 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "base64 0.10.1 (git+https://github.com/mesalock-linux/rust-base64-sgx)", "bit-vec 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", - "chain-relay 0.6.4-sub2.0.0-alpha.7", + "chain-relay 0.6.5-sub2.0.0-alpha.7", "chrono 0.4.11 (git+https://github.com/mesalock-linux/chrono-sgx)", "env_logger 0.7.1 (git+https://github.com/mesalock-linux/env_logger-sgx)", "httparse 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2136,8 +2136,8 @@ dependencies = [ "sp-runtime 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "sp-std 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "substrate-api-client 0.4.6-sub2.0.0-alpha.7 (git+https://github.com/scs/substrate-api-client?tag=v0.4.6-sub2.0.0-alpha.7)", - "substratee-node-primitives 0.6.4-sub2.0.0-alpha.7", - "substratee-stf 0.6.4-sub2.0.0-alpha.7", + "substratee-node-primitives 0.6.5-sub2.0.0-alpha.7", + "substratee-stf 0.6.5-sub2.0.0-alpha.7", "webpki 0.21.2 (git+https://github.com/mesalock-linux/webpki?branch=mesalock_sgx)", "webpki-roots 0.19.0 (git+https://github.com/mesalock-linux/webpki-roots?branch=mesalock_sgx)", "yasna 0.3.1 (git+https://github.com/mesalock-linux/yasna.rs-sgx?rev=sgx_1.1.2)", diff --git a/enclave/Cargo.toml b/enclave/Cargo.toml index bfd1b308a4..b97af1ccc1 100644 --- a/enclave/Cargo.toml +++ b/enclave/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "substratee-worker-enclave" -version = "0.6.4-sub2.0.0-alpha.7" +version = "0.6.5-sub2.0.0-alpha.7" authors = ["Supercomputing Systems AG "] edition = "2018" diff --git a/enclave/Enclave.edl b/enclave/Enclave.edl index d793f194ef..e907602247 100644 --- a/enclave/Enclave.edl +++ b/enclave/Enclave.edl @@ -71,7 +71,7 @@ enclave { public sgx_status_t dump_ra_to_disk(); public sgx_status_t run_key_provisioning_server(int fd,sgx_quote_sign_type_t quote_type); - public sgx_status_t request_key_provisioning(int fd,sgx_quote_sign_type_t quote_type); + public sgx_status_t request_key_provisioning(int fd, sgx_quote_sign_type_t quote_type); public size_t test_main_entrance(); }; diff --git a/enclave/chain_relay/Cargo.toml b/enclave/chain_relay/Cargo.toml index 0a961e4984..33b3a5edb3 100644 --- a/enclave/chain_relay/Cargo.toml +++ b/enclave/chain_relay/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "chain-relay" -version = "0.6.4-sub2.0.0-alpha.7" +version = "0.6.5-sub2.0.0-alpha.7" authors = ["Supercomputing Systems AG "] edition = "2018" diff --git a/enclave/src/cert.rs b/enclave/src/cert.rs index afedf7c450..9cccbe7fb5 100644 --- a/enclave/src/cert.rs +++ b/enclave/src/cert.rs @@ -402,10 +402,12 @@ fn verify_attn_report(report_raw: &[u8], pub_k: Vec) -> Result<(), sgx_statu // TODO: lack security check here let sgx_quote: sgx_quote_t = unsafe { ptr::read(quote.as_ptr() as *const _) }; - let ti: sgx_target_info_t = sgx_target_info_t::default(); - - if sgx_quote.report_body.mr_enclave.m != ti.mr_enclave.m { - error!("mr_enclave is not equal to self"); + let ti = crate::attestation::get_mrenclave_of_self().sgx_error()?; + if sgx_quote.report_body.mr_enclave.m != ti.m { + error!( + "mr_enclave is not equal to self {:?} != {:?}", + sgx_quote.report_body.mr_enclave.m, ti.m + ); return Err(sgx_status_t::SGX_ERROR_UNEXPECTED); } diff --git a/enclave/src/tls_ra.rs b/enclave/src/tls_ra.rs index 4019658a2f..f0b9b0799c 100644 --- a/enclave/src/tls_ra.rs +++ b/enclave/src/tls_ra.rs @@ -12,11 +12,8 @@ use rustls::{ClientConfig, ClientSession, ServerConfig, ServerSession, Stream}; use crate::aes; use crate::attestation::{create_ra_report_and_signature, DEV_HOSTNAME}; use crate::cert; -use crate::constants::ENCRYPTED_STATE_FILE; -use crate::io; use crate::rsa3072; use crate::utils::UnwrapOrSgxErrorUnexpected; -use crate::{ocall_read_ipfs, ocall_write_ipfs}; struct ClientAuth { outdated_ok: bool, @@ -37,7 +34,7 @@ impl rustls::ClientCertVerifier for ClientAuth { &self, _certs: &[rustls::Certificate], ) -> Result { - info!("client cert: {:?}", _certs); + debug!("client cert: {:?}", _certs); // This call will automatically verify cert is properly signed match cert::verify_mra_cert(&_certs[0].0) { Ok(()) => Ok(rustls::ClientCertVerified::assertion()), @@ -76,7 +73,7 @@ impl rustls::ServerCertVerifier for ServerAuth { _hostname: webpki::DNSNameRef, _ocsp: &[u8], ) -> Result { - info!("server cert: {:?}", _certs); + debug!("server cert: {:?}", _certs); // This call will automatically verify cert is properly signed match cert::verify_mra_cert(&_certs[0].0) { Ok(()) => Ok(rustls::ServerCertVerified::assertion()), @@ -117,13 +114,13 @@ pub unsafe extern "C" fn run_key_provisioning_server( let mut tls = rustls::Stream::new(&mut sess, &mut conn); println!(" [Enclave] (MU-RA-Server) MU-RA successful sending keys"); - let (rsa_pair, aes, enc_state) = match read_files_to_send() { - Ok((r, a, s)) => (r, a, s), + let (rsa_pair, aes) = match read_files_to_send() { + Ok((r, a)) => (r, a), Err(e) => return e, }; - match send_files(&mut tls, &rsa_pair, &aes, &enc_state) { - Ok(_) => println!(" [Enclave] (MU-RA-Server) Registration procedure successful!\n"), + match send_files(&mut tls, &rsa_pair, &aes) { + Ok(_) => println!(" [Enclave] (MU-RA-Server) Successfully provisioned keys!\n"), Err(e) => return e, } @@ -151,61 +148,27 @@ fn tls_server_config(sign_type: sgx_quote_sign_type_t) -> SgxResult SgxResult<(Vec, aes::Aes, Vec)> { +fn read_files_to_send() -> SgxResult<(Vec, aes::Aes)> { let shielding_key = rsa3072::unseal_pair().sgx_error()?; let aes = aes::read_sealed().sgx_error()?; let rsa_pair = serde_json::to_string(&shielding_key).sgx_error()?; - let enc_state = io::read(ENCRYPTED_STATE_FILE).sgx_error()?; let rsa_len = rsa_pair.as_bytes().len(); info!(" [Enclave] Read Shielding Key: {:?}", rsa_len); info!(" [Enclave] Read AES key {:?}\nIV: {:?}\n", aes.0, aes.1); - Ok((rsa_pair.as_bytes().to_vec(), aes, enc_state)) + Ok((rsa_pair.as_bytes().to_vec(), aes)) } fn send_files( tls: &mut Stream, rsa_pair: &[u8], aes: &(Vec, Vec), - enc_state: &[u8], ) -> SgxResult<()> { tls.write(&rsa_pair.len().to_le_bytes()).sgx_error()?; tls.write(&rsa_pair).sgx_error()?; tls.write(&aes.0[..]).sgx_error()?; tls.write(&aes.1[..]).sgx_error()?; - - println!( - " [Enclave] (MU-RA-Server) Keys sent, writing state to IPFS (= file hosting service)" - ); - info!(" [Enclave] (MU-RA-Server) Sending encrypted state length"); - - tls.write(&enc_state.len().to_le_bytes()).sgx_error()?; - if enc_state.is_empty() { - println!( - " [Enclave] (MU-RA-Server) No state has been written yet. Nothing to write to ipfs." - ); - println!(" [Enclave] (MU-RA-Server) Registration procedure successful!\n"); - return Ok(()); - } - let mut rt: sgx_status_t = sgx_status_t::SGX_ERROR_UNEXPECTED; - let mut cid_buf: [u8; 46] = [0; 46]; - let res = unsafe { - ocall_write_ipfs( - &mut rt as *mut sgx_status_t, - enc_state.as_ptr() as *const u8, - enc_state.len() as u32, - cid_buf.as_mut_ptr() as *mut u8, - cid_buf.len() as u32, - ) - }; - - if res == sgx_status_t::SGX_ERROR_UNEXPECTED || rt == sgx_status_t::SGX_ERROR_UNEXPECTED { - return Err(sgx_status_t::SGX_ERROR_UNEXPECTED); - } - - println!(" [Enclave] (MU-RA-Server) Write to IPFS successful, sending storage hash"); - tls.write(&cid_buf).sgx_error()?; Ok(()) } @@ -276,49 +239,7 @@ fn receive_files(tls: &mut Stream) -> SgxResult<()> { aes::seal(aes_key, aes_iv)?; - println!(" [Enclave] (MU-RA-Client) Received and stored keys, waiting for storage hash..."); - - let mut state_len_arr = [0u8; 8]; - let state_len = tls - .read(&mut state_len_arr) - .map(|_| usize::from_le_bytes(state_len_arr)) - .sgx_error_with_log("Error receiving state length")?; - - if state_len == 0 { - println!(" [Enclave] (MU-RA-Client) No state has been written yet, nothing to fetch from IPFS"); - println!(" [Enclave] (MU-RA-Client) Registration Procedure successful!\n"); - return Ok(()); - } - - let mut cid = [0u8; 46]; - tls.read(&mut cid) - .map(|_| { - info!( - " [Enclave] (MU-RA-Client) Received ipfs CID: {:?}", - &cid[..] - ) - }) - .sgx_error_with_log(" [Enclave] (MU-RA-Client) Error receiving ipfs CID")?; - - println!(" [Enclave] (MU-RA-Client) Received IPFS storage hash, reading from IPFS..."); - - let mut enc_state = vec![0u8; state_len]; - let mut rt: sgx_status_t = sgx_status_t::SGX_ERROR_UNEXPECTED; - let _res = unsafe { - ocall_read_ipfs( - &mut rt as *mut sgx_status_t, - enc_state.as_mut_ptr(), - enc_state.len() as u32, - cid.as_ptr(), - cid.len() as u32, - ) - }; - println!( - " [Enclave] (MU-RA-Client) Got encrypted state from ipfs: {:?}\n", - enc_state - ); - io::write(&enc_state, ENCRYPTED_STATE_FILE)?; - println!(" [Enclave] (MU-RA-Client) Successfully read state from IPFS"); + println!(" [Enclave] (MU-RA-Client) Successfully received keys."); Ok(()) } diff --git a/stf/Cargo.toml b/stf/Cargo.toml index 31aac7c9d2..9c64711c29 100644 --- a/stf/Cargo.toml +++ b/stf/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "substratee-stf" -version = "0.6.4-sub2.0.0-alpha.7" +version = "0.6.5-sub2.0.0-alpha.7" authors = ["Supercomputing Systems AG "] edition = "2018" diff --git a/substratee-node-primitives/Cargo.toml b/substratee-node-primitives/Cargo.toml index 77839e51fc..046f5601cb 100644 --- a/substratee-node-primitives/Cargo.toml +++ b/substratee-node-primitives/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "substratee-node-primitives" -version = "0.6.4-sub2.0.0-alpha.7" +version = "0.6.5-sub2.0.0-alpha.7" authors = ["clangenbacher "] edition = "2018" diff --git a/substratee-node-primitives/src/lib.rs b/substratee-node-primitives/src/lib.rs index ba3584b72f..59a294be47 100644 --- a/substratee-node-primitives/src/lib.rs +++ b/substratee-node-primitives/src/lib.rs @@ -43,11 +43,12 @@ pub mod calls { pub fn get_worker_for_shard( api: &substrate_api_client::Api

, shard: &ShardIdentifier, - ) -> Option + ) -> Option>> where MultiSignature: From, { api.get_storage_map("SubstrateeRegistry", "WorkerForShard", shard, None) + .and_then(|w| get_worker_info(&api, w)) } pub fn get_worker_amount(api: &substrate_api_client::Api

) -> Option @@ -57,6 +58,22 @@ pub mod calls { api.get_storage_value("SubstrateeRegistry", "EnclaveCount", None) } + pub fn get_first_worker_that_is_not_equal_to_self( + api: &substrate_api_client::Api

, + self_account: &AccountId, + ) -> Option>> + where + MultiSignature: From, + { + for n in 0..api.get_storage_value("SubstrateeRegistry", "EnclaveCount", None)? { + let worker = get_worker_info(api, n)?; + if &worker.pubkey != self_account { + return Some(worker); + } + } + None + } + pub fn get_latest_state( api: &substrate_api_client::Api

, shard: &ShardIdentifier, diff --git a/worker/Cargo.toml b/worker/Cargo.toml index 546dea79c9..70ef8295ba 100644 --- a/worker/Cargo.toml +++ b/worker/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "substratee-worker" -version = "0.6.4-sub2.0.0-alpha.7" +version = "0.6.5-sub2.0.0-alpha.7" authors = ["Supercomputing Systems AG "] build = "build.rs" edition = "2018" diff --git a/worker/src/cli.yml b/worker/src/cli.yml index c9f23be39e..5bd8940507 100644 --- a/worker/src/cli.yml +++ b/worker/src/cli.yml @@ -90,6 +90,10 @@ subcommands: help: Run integration tests takes_value: false - provisioning-server: + long: provisioning-server help: Run TEE server for MU-RA key provisioning + takes_value: false - provisioning-client: + long: provisioning-client help: Run TEE client for MU-RA key provisioning + takes_value: false diff --git a/worker/src/enclave/tls_ra.rs b/worker/src/enclave/tls_ra.rs index 0fecf1b6bd..181042e5f3 100644 --- a/worker/src/enclave/tls_ra.rs +++ b/worker/src/enclave/tls_ra.rs @@ -76,6 +76,7 @@ pub fn enclave_request_key_provisioning( info!("[MU-RA-Client] Requesting key provisioning from {}", addr); let socket = TcpStream::connect(addr).unwrap(); let mut status = sgx_status_t::SGX_SUCCESS; + let result = unsafe { request_key_provisioning(eid, &mut status, socket.as_raw_fd(), sign_type) }; if status != sgx_status_t::SGX_SUCCESS { diff --git a/worker/src/main.rs b/worker/src/main.rs index 3f6bf7529c..cdd5336568 100644 --- a/worker/src/main.rs +++ b/worker/src/main.rs @@ -18,6 +18,7 @@ use std::fs::{self, File}; use std::io::stdin; use std::io::Write; use std::path::Path; +use std::slice; use std::str; use std::sync::mpsc::{channel, Sender}; use std::thread; @@ -47,8 +48,7 @@ use enclave::api::{ }; use enclave::tls_ra::{enclave_request_key_provisioning, enclave_run_key_provisioning_server}; use sp_finality_grandpa::{AuthorityList, VersionedAuthorityList, GRANDPA_AUTHORITIES_KEY}; -use std::slice; -use substratee_node_primitives::calls::{get_worker_for_shard, get_worker_info}; +use substratee_node_primitives::calls::get_first_worker_that_is_not_equal_to_self; use substratee_worker_api::Api as WorkerApi; use ws_server::start_ws_server; @@ -186,7 +186,7 @@ fn main() { println!("[+] Done!"); enclave.destroy(); } else if _matches.is_present("provisioning-client") { - println!("*** Running Enclave MU-RA TLS server\n"); + println!("*** Running Enclave MU-RA TLS client\n"); let enclave = enclave_init().unwrap(); enclave_request_key_provisioning( enclave.geteid(), @@ -209,6 +209,7 @@ fn worker(node_url: &str, w_ip: &str, w_port: &str, mu_ra_port: &str, shard: &Sh // ------------------------------------------------------------------------ // check for required files check_files(); + ensure_shard_initialized(shard); // ------------------------------------------------------------------------ // initialize the enclave #[cfg(feature = "production")] @@ -251,7 +252,6 @@ fn worker(node_url: &str, w_ip: &str, w_port: &str, mu_ra_port: &str, shard: &Sh info!("Enclave nonce = {:?}", nonce); let uxt = enclave_perform_ra(eid, genesis_hash, nonce, w_url.as_bytes().to_vec()).unwrap(); - let mut latest_head = init_chain_relay(eid, &api); let ue = UncheckedExtrinsic::decode(&mut uxt.as_slice()).unwrap(); let mut _xthex = hex::encode(ue.encode()); @@ -263,37 +263,29 @@ fn worker(node_url: &str, w_ip: &str, w_port: &str, mu_ra_port: &str, shard: &Sh println!("[<] Extrinsic got finalized. Hash: {:?}\n", tx_hash); // browse enclave registry - match get_worker_for_shard(&api, shard) { + match get_first_worker_that_is_not_equal_to_self(&api, &tee_accountid) { Some(w) => { - let master_worker = get_worker_info(&api, w).unwrap(); - if master_worker.pubkey == tee_accountid { - info!("the most recently active worker is myself"); - ensure_shard_initialized(shard); - } else { - let _url = String::from_utf8_lossy(&master_worker.url[..]).to_string(); - let _w_api = WorkerApi::new(_url.clone()); - let _url_split: Vec<_> = _url.split(':').collect(); - let mura_url = format!("{}:{}", _url_split[0], _w_api.get_mu_ra_port().unwrap()); - - info!("Requesting key provisioning from worker at {}", mura_url); - enclave_request_key_provisioning( - eid, - sgx_quote_sign_type_t::SGX_UNLINKABLE_SIGNATURE, - &mura_url, - ) - .unwrap(); - debug!("key provisioning successfully performed"); - } + let _url = String::from_utf8_lossy(&w.url[..]).to_string(); + let _w_api = WorkerApi::new(_url.clone()); + let _url_split: Vec<_> = _url.split(':').collect(); + let mura_url = format!("{}:{}", _url_split[0], _w_api.get_mu_ra_port().unwrap()); + + info!("Requesting key provisioning from worker at {}", mura_url); + enclave_request_key_provisioning( + eid, + sgx_quote_sign_type_t::SGX_UNLINKABLE_SIGNATURE, + &mura_url, + ) + .unwrap(); + debug!("key provisioning successfully performed"); } None => { - info!( - "no worker has ever published a state update for shard {}", - shard.encode().to_base58() - ); - ensure_shard_initialized(shard); + info!("there are no other workers"); } } + let mut latest_head = init_chain_relay(eid, &api); + // ------------------------------------------------------------------------ // subscribe to events and react on firing println!("*** Subscribing to events"); diff --git a/worker/worker-api/Cargo.toml b/worker/worker-api/Cargo.toml index 80ad3c4386..48195f0041 100644 --- a/worker/worker-api/Cargo.toml +++ b/worker/worker-api/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "substratee-worker-api" -version = "0.6.4-sub2.0.0-alpha.7" +version = "0.6.5-sub2.0.0-alpha.7" authors = ["Supercomputing Systems AG "] edition = "2018" From 4a3841796c2f82066f5ede07e86abe92a98fb668 Mon Sep 17 00:00:00 2001 From: clangenb <37865735+clangenb@users.noreply.github.com> Date: Sat, 30 May 2020 08:07:29 +0200 Subject: [PATCH 09/29] ! fix: indexing in get_first_worker_that_is_not_equal_to_self (#150) --- substratee-node-primitives/src/lib.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/substratee-node-primitives/src/lib.rs b/substratee-node-primitives/src/lib.rs index 59a294be47..63bafd74b8 100644 --- a/substratee-node-primitives/src/lib.rs +++ b/substratee-node-primitives/src/lib.rs @@ -65,8 +65,9 @@ pub mod calls { where MultiSignature: From, { - for n in 0..api.get_storage_value("SubstrateeRegistry", "EnclaveCount", None)? { - let worker = get_worker_info(api, n)?; + // the registry starts indexing its map at one + for n in 1..=api.get_storage_value("SubstrateeRegistry", "EnclaveCount", None)? { + let worker = get_worker_info(api, n).unwrap(); if &worker.pubkey != self_account { return Some(worker); } From 24ef5b3051e579e80c9ecd51eb4307f73f634617 Mon Sep 17 00:00:00 2001 From: clangenb <37865735+clangenb@users.noreply.github.com> Date: Wed, 3 Jun 2020 11:40:10 +0200 Subject: [PATCH 10/29] on block storage updates for every shard (#155) * [enclave] extracted verify worker response. * [STF/enclave] whip update storages upon block import * [enclave] perform state updates on all shards upon block import * [enclave] Create shard if it does not exist. Currently, the workers follow an auto-join policy for new shards. * clippy * [enclave] do not return an error if could not execute relevant extrinsic in stf. Only log the error. --- enclave/src/lib.rs | 142 +++++++++++++++++++++++++++---------------- enclave/src/state.rs | 33 +++++++++- stf/src/sgx.rs | 9 ++- worker/src/main.rs | 16 ----- 4 files changed, 128 insertions(+), 72 deletions(-) diff --git a/enclave/src/lib.rs b/enclave/src/lib.rs index 49874f373e..73204e509a 100644 --- a/enclave/src/lib.rs +++ b/enclave/src/lib.rs @@ -309,7 +309,8 @@ pub unsafe extern "C" fn sync_chain_relay( Err(e) => return e, }; - for signed_block in blocks.iter() { + let mut calls = Vec::new(); + for signed_block in blocks.into_iter() { validator .check_xt_inclusion(validator.num_relays, &signed_block.block) .unwrap(); // panic can only happen if relay_id is does not exist @@ -321,12 +322,16 @@ pub unsafe extern "C" fn sync_chain_relay( error!("Block verification failed. Error : {:?}", e); return sgx_status_t::SGX_ERROR_UNEXPECTED; } - } - let calls = match scan_blocks_for_relevant_xt(blocks, node_url) { - Ok(c) => c, - Err(e) => return e, - }; + match scan_block_for_relevant_xt(&signed_block.block, node_url) { + Ok(c) => calls.extend(c.into_iter()), + Err(_) => error!("Error executing relevant extrinsics"), + }; + + if update_states(signed_block.block.header, node_url).is_err() { + error!("Error performing state updates upon block import") + } + } if let Err(_e) = stf_post_actions(validator, calls, xt_slice, *nonce) { return sgx_status_t::SGX_ERROR_UNEXPECTED; @@ -335,35 +340,50 @@ pub unsafe extern "C" fn sync_chain_relay( sgx_status_t::SGX_SUCCESS } +pub fn update_states(header: Header, node_url: &[u8]) -> SgxResult<()> { + debug!("Update STF storage upon block import!"); + let requests = Stf::storage_hashes_to_update_on_block() + .into_iter() + .map(|key| WorkerRequest::ChainStorage(key, Some(header.hash()))) + .collect(); + + let responses: Vec>> = worker_request(requests, node_url)?; + let update_map = verify_worker_responses(responses, header)?; + + let shards = state::list_shards()?; + debug!("found shards: {:?}", shards); + for s in shards { + let mut state = state::load(&s)?; + Stf::update_storage(&mut state, &update_map); + state::write(state, &s)?; + } + Ok(()) +} + /// Scans blocks for extrinsics that ask the enclave to execute some actions. -pub fn scan_blocks_for_relevant_xt( - blocks: Vec>, - node_url: &[u8], -) -> SgxResult> { +pub fn scan_block_for_relevant_xt(block: &Block, node_url: &[u8]) -> SgxResult> { debug!("Scanning blocks for relevant xt"); let mut calls = Vec::::new(); - for block in blocks.iter() { - for xt_opaque in block.block.extrinsics.iter() { - if let Ok(xt) = - UncheckedExtrinsicV4::::decode(&mut xt_opaque.0.encode().as_slice()) - { - // confirm call decodes successfully as well - if xt.function.0 == [SUBSRATEE_REGISTRY_MODULE, SHIELD_FUNDS] { - if let Err(e) = handle_shield_funds_xt(&mut calls, xt) { - error!("Error performing shieldfunds. Error: {:?}", e); - } + for xt_opaque in block.extrinsics.iter() { + if let Ok(xt) = + UncheckedExtrinsicV4::::decode(&mut xt_opaque.0.encode().as_slice()) + { + // confirm call decodes successfully as well + if xt.function.0 == [SUBSRATEE_REGISTRY_MODULE, SHIELD_FUNDS] { + if let Err(e) = handle_shield_funds_xt(&mut calls, xt) { + error!("Error performing shieldfunds. Error: {:?}", e); } - }; - - if let Ok(xt) = - UncheckedExtrinsicV4::::decode(&mut xt_opaque.0.encode().as_slice()) - { - if xt.function.0 == [SUBSRATEE_REGISTRY_MODULE, CALL_WORKER] { - if let Err(e) = - handle_call_worker_xt(&mut calls, xt, block.block.header.clone(), node_url) - { - error!("Error performing worker call: Error: {:?}", e); - } + } + }; + + if let Ok(xt) = + UncheckedExtrinsicV4::::decode(&mut xt_opaque.0.encode().as_slice()) + { + if xt.function.0 == [SUBSRATEE_REGISTRY_MODULE, CALL_WORKER] { + if let Err(e) = + handle_call_worker_xt(&mut calls, xt, block.header.clone(), node_url) + { + error!("Error performing worker call: Error: {:?}", e); } } } @@ -380,7 +400,11 @@ fn handle_shield_funds_xt( call, account_encrypted, amount, shard ); - let mut state = state::load(&shard)?; + let mut state = if state::exists(&shard) { + state::load(&shard)? + } else { + Stf::init_state() + }; debug!("decrypt the call"); let rsa_keypair = rsa3072::unseal_pair()?; @@ -449,7 +473,11 @@ fn handle_call_worker_xt( return Ok(()); } - let mut state = state::load(&shard)?; + let mut state = if state::exists(&shard) { + state::load(&shard)? + } else { + Stf::init_state() + }; debug!("Update STF storage!"); let requests = Stf::get_storage_hashes_to_update(&stf_call_signed) @@ -459,6 +487,33 @@ fn handle_call_worker_xt( let responses: Vec>> = worker_request(requests, node_url)?; + let update_map = verify_worker_responses(responses, header)?; + + Stf::update_storage(&mut state, &update_map); + + debug!("execute STF"); + if let Err(e) = Stf::execute(&mut state, stf_call_signed, calls) { + error!("Error performing Stf::execute. Error: {:?}", e); + return Ok(()); + } + + let state_hash = state::write(state, &shard)?; + + let xt_call = [SUBSRATEE_REGISTRY_MODULE, CALL_CONFIRMED]; + let call_hash = blake2_256(&request_vec); + debug!("Call hash 0x{}", hex::encode_hex(&call_hash)); + + calls.push(OpaqueCall( + (xt_call, shard, call_hash, state_hash.encode()).encode(), + )); + + Ok(()) +} + +fn verify_worker_responses( + responses: Vec>>, + header: Header, +) -> SgxResult, Vec>> { let mut update_map = HashMap::new(); for response in responses.iter() { match response { @@ -486,26 +541,7 @@ fn handle_call_worker_xt( } } } - - Stf::update_storage(&mut state, update_map); - - debug!("execute STF"); - if let Err(e) = Stf::execute(&mut state, stf_call_signed, calls) { - error!("Error performing Stf::execute. Error: {:?}", e); - return Ok(()); - } - - let state_hash = state::write(state, &shard)?; - - let xt_call = [SUBSRATEE_REGISTRY_MODULE, CALL_CONFIRMED]; - let call_hash = blake2_256(&request_vec); - debug!("Call hash 0x{}", hex::encode_hex(&call_hash)); - - calls.push(OpaqueCall( - (xt_call, shard, call_hash, state_hash.encode()).encode(), - )); - - Ok(()) + Ok(update_map) } extern "C" { diff --git a/enclave/src/state.rs b/enclave/src/state.rs index c3fd9a4839..3bd82e5286 100644 --- a/enclave/src/state.rs +++ b/enclave/src/state.rs @@ -15,6 +15,7 @@ */ +use std::fs; use std::vec::Vec; use log::*; @@ -25,10 +26,12 @@ use crate::aes; use crate::constants::{ENCRYPTED_STATE_FILE, SHARDS_PATH}; use crate::hex; use crate::io; -use base58::ToBase58; -use codec::Encode; +use crate::utils::UnwrapOrSgxErrorUnexpected; +use base58::{FromBase58, ToBase58}; +use codec::{Decode, Encode}; use sgx_externalities::SgxExternalitiesTrait; use sp_core::H256; +use std::path::Path; use substratee_stf::{ShardIdentifier, State as StfState, Stf}; pub fn load(shard: &ShardIdentifier) -> SgxResult { @@ -79,6 +82,16 @@ pub fn write(state: StfState, shard: &ShardIdentifier) -> SgxResult { Ok(state_hash.into()) } +pub fn exists(shard: &ShardIdentifier) -> bool { + Path::new(&format!( + "{}/{}/{}", + SHARDS_PATH, + shard.encode().to_base58(), + ENCRYPTED_STATE_FILE + )) + .exists() +} + fn read(path: &str) -> SgxResult> { let mut bytes = match io::read(path) { Ok(vec) => match vec.len() { @@ -108,6 +121,22 @@ fn encrypt(mut state: Vec) -> SgxResult> { Ok(state) } +pub fn list_shards() -> SgxResult> { + let files = fs::read_dir(SHARDS_PATH).sgx_error()?; + let mut shards = Vec::new(); + for file in files { + let s = file + .sgx_error()? + .file_name() + .into_string() + .sgx_error()? + .from_base58() + .sgx_error()?; + shards.push(ShardIdentifier::decode(&mut s.as_slice()).sgx_error()?); + } + Ok(shards) +} + pub fn test_encrypted_state_io_works() { let path = "test_state_file.bin"; let plaintext = b"The quick brown fox jumps over the lazy dog."; diff --git a/stf/src/sgx.rs b/stf/src/sgx.rs index 1695b01af8..e645d003b7 100644 --- a/stf/src/sgx.rs +++ b/stf/src/sgx.rs @@ -69,7 +69,7 @@ impl Stf { ext } - pub fn update_storage(ext: &mut State, map_update: HashMap, Vec>) { + pub fn update_storage(ext: &mut State, map_update: &HashMap, Vec>) { ext.execute_with(|| { map_update .iter() @@ -203,6 +203,13 @@ impl Stf { }; key_hashes } + + pub fn storage_hashes_to_update_on_block() -> Vec> { + // let key_hashes = Vec::new(); + // key_hashes.push(storage_value_key("dummy", "dummy")); + // key_hashes + Vec::new() + } } // get the AccountInfo key where the nonce is stored diff --git a/worker/src/main.rs b/worker/src/main.rs index cdd5336568..6380240d86 100644 --- a/worker/src/main.rs +++ b/worker/src/main.rs @@ -209,7 +209,6 @@ fn worker(node_url: &str, w_ip: &str, w_port: &str, mu_ra_port: &str, shard: &Sh // ------------------------------------------------------------------------ // check for required files check_files(); - ensure_shard_initialized(shard); // ------------------------------------------------------------------------ // initialize the enclave #[cfg(feature = "production")] @@ -583,21 +582,6 @@ fn get_balance(api: &Api, who: &AccountId32) -> u128 { } } -fn ensure_shard_initialized(shard: &ShardIdentifier) { - let shardenc = shard.encode().to_base58(); - if !Path::new(&format!( - "{}/{}/{}", - constants::SHARDS_PATH, - &shardenc, - constants::ENCRYPTED_STATE_FILE - )) - .exists() - { - panic!("shard {} hasn't been initialized", shardenc); - } - debug!("state file is present for shard {}", shardenc); -} - pub fn check_files() { debug!("*** Check files"); let files = vec![ From c68084b764252e0bba3773c5c05bb3d8eaaea80a Mon Sep 17 00:00:00 2001 From: clangenb <37865735+clangenb@users.noreply.github.com> Date: Wed, 3 Jun 2020 16:18:28 +0200 Subject: [PATCH 11/29] allow on chain read in get state (#156) * [enclave] return preemptively if there are no worker_requests to be performed in state_update upon block import * [worker] use lazy_static to create a global static reference to the node_url. No longer passing the node_url to the enclave needed. * [enclave/stf] support on-chain storage access in get_state * perform_ra: rename url -> w_url to prevent confusion with node_url * clippy * [enclave] ! fix: init-shard if it does not exist --- Cargo.lock | 1 + enclave/Enclave.edl | 4 +-- enclave/src/attestation.rs | 6 ++-- enclave/src/lib.rs | 64 +++++++++++++++++++++++++------------- enclave/src/state.rs | 4 +++ stf/src/lib.rs | 2 +- stf/src/sgx.rs | 8 ++++- worker/Cargo.toml | 1 + worker/src/enclave/api.rs | 15 +++------ worker/src/main.rs | 26 ++++++++++------ 10 files changed, 83 insertions(+), 48 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index bd2b391846..a20734ea87 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3888,6 +3888,7 @@ dependencies = [ "hex 0.3.2", "hyper", "ipfs-api", + "lazy_static", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "multihash", "pallet-balances", diff --git a/enclave/Enclave.edl b/enclave/Enclave.edl index e907602247..cf6a0b227e 100644 --- a/enclave/Enclave.edl +++ b/enclave/Enclave.edl @@ -48,7 +48,6 @@ enclave { public sgx_status_t sync_chain_relay( [in, size=blocks_size] uint8_t* blocks, size_t blocks_size, [in] uint32_t* nonce, - [in, size=node_url_size] uint8_t* node_url, size_t node_url_size, [out, size=unchecked_extrinsic_size] uint8_t* unchecked_extrinsic, size_t unchecked_extrinsic_size ); @@ -64,7 +63,7 @@ enclave { public sgx_status_t perform_ra( [in, size=genesis_hash_size] uint8_t* genesis_hash, uint32_t genesis_hash_size, [in] uint32_t* nonce, - [in, size=url_size] uint8_t* url, uint32_t url_size, + [in, size=w_url_size] uint8_t* w_url, uint32_t w_url_size, [out, size=unchecked_extrinsic_size] uint8_t* unchecked_extrinsic, uint32_t unchecked_extrinsic_size ); @@ -110,7 +109,6 @@ enclave { sgx_status_t ocall_worker_request( [in, size = req_size] uint8_t * request, uint32_t req_size, - [in, size = node_url_size] uint8_t * node_url, uint32_t node_url_size, [out, size = resp_size] uint8_t * response, uint32_t resp_size ); }; diff --git a/enclave/src/attestation.rs b/enclave/src/attestation.rs index 32c6f7131b..955a6b4a86 100644 --- a/enclave/src/attestation.rs +++ b/enclave/src/attestation.rs @@ -609,8 +609,8 @@ pub unsafe extern "C" fn perform_ra( genesis_hash: *const u8, genesis_hash_size: u32, nonce: *const u32, - url: *const u8, - url_size: u32, + w_url: *const u8, + w_url_size: u32, unchecked_extrinsic: *mut u8, unchecked_extrinsic_size: u32, ) -> sgx_status_t { @@ -625,7 +625,7 @@ pub unsafe extern "C" fn perform_ra( info!(" [Enclave] Compose extrinsic"); let genesis_hash_slice = slice::from_raw_parts(genesis_hash, genesis_hash_size as usize); //let mut nonce_slice = slice::from_raw_parts(nonce, nonce_size as usize); - let url_slice = slice::from_raw_parts(url, url_size as usize); + let url_slice = slice::from_raw_parts(w_url, w_url_size as usize); let extrinsic_slice = slice::from_raw_parts_mut(unchecked_extrinsic, unchecked_extrinsic_size as usize); let signer = match ed25519::unseal_pair() { diff --git a/enclave/src/lib.rs b/enclave/src/lib.rs index 73204e509a..7c96ff00a9 100644 --- a/enclave/src/lib.rs +++ b/enclave/src/lib.rs @@ -223,6 +223,34 @@ pub unsafe extern "C" fn get_state( Err(status) => return status, }; + let validator = match io::light_validation::unseal() { + Ok(val) => val, + Err(e) => return e, + }; + + let latest_header = validator.latest_header(validator.num_relays).unwrap(); + + debug!("Update STF storage!"); + let requests: Vec = + Stf::get_storage_hashes_to_update_for_getter(&tusted_getter_signed) + .into_iter() + .map(|key| WorkerRequest::ChainStorage(key, Some(latest_header.hash()))) + .collect(); + + if !requests.is_empty() { + let responses: Vec>> = match worker_request(requests) { + Ok(resp) => resp, + Err(e) => return e, + }; + + let update_map = match verify_worker_responses(responses, latest_header) { + Ok(map) => map, + Err(e) => return e, + }; + + Stf::update_storage(&mut state, &update_map); + } + debug!("calling into STF to get state"); let value_opt = Stf::get_state(&mut state, tusted_getter_signed.getter); @@ -286,13 +314,10 @@ pub unsafe extern "C" fn sync_chain_relay( blocks: *const u8, blocks_size: usize, nonce: *const u32, - node_url: *const u8, - node_url_size: usize, unchecked_extrinsic: *mut u8, unchecked_extrinsic_size: usize, ) -> sgx_status_t { info!("Syncing chain relay!"); - let node_url = slice::from_raw_parts(node_url, node_url_size as usize); let mut blocks_slice = slice::from_raw_parts(blocks, blocks_size); let xt_slice = slice::from_raw_parts_mut(unchecked_extrinsic, unchecked_extrinsic_size); @@ -323,12 +348,12 @@ pub unsafe extern "C" fn sync_chain_relay( return sgx_status_t::SGX_ERROR_UNEXPECTED; } - match scan_block_for_relevant_xt(&signed_block.block, node_url) { + match scan_block_for_relevant_xt(&signed_block.block) { Ok(c) => calls.extend(c.into_iter()), Err(_) => error!("Error executing relevant extrinsics"), }; - if update_states(signed_block.block.header, node_url).is_err() { + if update_states(signed_block.block.header).is_err() { error!("Error performing state updates upon block import") } } @@ -340,14 +365,18 @@ pub unsafe extern "C" fn sync_chain_relay( sgx_status_t::SGX_SUCCESS } -pub fn update_states(header: Header, node_url: &[u8]) -> SgxResult<()> { +pub fn update_states(header: Header) -> SgxResult<()> { debug!("Update STF storage upon block import!"); - let requests = Stf::storage_hashes_to_update_on_block() + let requests: Vec = Stf::storage_hashes_to_update_on_block() .into_iter() .map(|key| WorkerRequest::ChainStorage(key, Some(header.hash()))) .collect(); - let responses: Vec>> = worker_request(requests, node_url)?; + if requests.is_empty() { + return Ok(()); + } + + let responses: Vec>> = worker_request(requests)?; let update_map = verify_worker_responses(responses, header)?; let shards = state::list_shards()?; @@ -361,7 +390,7 @@ pub fn update_states(header: Header, node_url: &[u8]) -> SgxResult<()> { } /// Scans blocks for extrinsics that ask the enclave to execute some actions. -pub fn scan_block_for_relevant_xt(block: &Block, node_url: &[u8]) -> SgxResult> { +pub fn scan_block_for_relevant_xt(block: &Block) -> SgxResult> { debug!("Scanning blocks for relevant xt"); let mut calls = Vec::::new(); for xt_opaque in block.extrinsics.iter() { @@ -380,9 +409,7 @@ pub fn scan_block_for_relevant_xt(block: &Block, node_url: &[u8]) -> SgxResult::decode(&mut xt_opaque.0.encode().as_slice()) { if xt.function.0 == [SUBSRATEE_REGISTRY_MODULE, CALL_WORKER] { - if let Err(e) = - handle_call_worker_xt(&mut calls, xt, block.header.clone(), node_url) - { + if let Err(e) = handle_call_worker_xt(&mut calls, xt, block.header.clone()) { error!("Error performing worker call: Error: {:?}", e); } } @@ -403,6 +430,7 @@ fn handle_shield_funds_xt( let mut state = if state::exists(&shard) { state::load(&shard)? } else { + state::init_shard(&shard)?; Stf::init_state() }; @@ -442,7 +470,6 @@ fn handle_call_worker_xt( calls: &mut Vec, xt: UncheckedExtrinsicV4, header: Header, - node_url: &[u8], ) -> SgxResult<()> { let (call, request) = xt.function; let (shard, cyphertext) = (request.shard, request.cyphertext); @@ -476,6 +503,7 @@ fn handle_call_worker_xt( let mut state = if state::exists(&shard) { state::load(&shard)? } else { + state::init_shard(&shard)?; Stf::init_state() }; @@ -485,7 +513,7 @@ fn handle_call_worker_xt( .map(|key| WorkerRequest::ChainStorage(key, Some(header.hash()))) .collect(); - let responses: Vec>> = worker_request(requests, node_url)?; + let responses: Vec>> = worker_request(requests)?; let update_map = verify_worker_responses(responses, header)?; @@ -565,8 +593,6 @@ extern "C" { ret_val: *mut sgx_status_t, request: *const u8, req_size: u32, - node_url: *const u8, - node_url_size: u32, response: *mut u8, resp_size: u32, ) -> sgx_status_t; @@ -630,7 +656,6 @@ pub enum WorkerResponse { fn worker_request( req: Vec, - node_url: &[u8], ) -> SgxResult>> { let mut rt: sgx_status_t = sgx_status_t::SGX_ERROR_UNEXPECTED; let mut resp: Vec = vec![0; 4196]; @@ -640,8 +665,6 @@ fn worker_request( &mut rt as *mut sgx_status_t, req.encode().as_ptr(), req.encode().len() as u32, - node_url.as_ptr(), - node_url.len() as u32, resp.as_mut_ptr(), resp.len() as u32, ) @@ -660,14 +683,13 @@ fn worker_request( fn test_ocall_worker_request() { info!("testing ocall_worker_request. Hopefully substraTEE-node is running..."); let mut requests = Vec::new(); - let node_url = format!("ws://{}:{}", "127.0.0.1", "9991").into_bytes(); requests.push(WorkerRequest::ChainStorage( storage_key("Balances", "TotalIssuance").0, None, )); - let mut resp: Vec>> = match worker_request(requests, node_url.as_ref()) { + let mut resp: Vec>> = match worker_request(requests) { Ok(response) => response, Err(e) => panic!("Worker response decode failed. Error: {:?}", e), }; diff --git a/enclave/src/state.rs b/enclave/src/state.rs index 3bd82e5286..e7b0bbbe5c 100644 --- a/enclave/src/state.rs +++ b/enclave/src/state.rs @@ -92,6 +92,10 @@ pub fn exists(shard: &ShardIdentifier) -> bool { .exists() } +pub fn init_shard(shard: &ShardIdentifier) -> SgxResult<()> { + fs::create_dir_all(format!("{}/{}", SHARDS_PATH, shard.encode().to_base58())).sgx_error() +} + fn read(path: &str) -> SgxResult> { let mut bytes = match io::read(path) { Ok(vec) => match vec.len() { diff --git a/stf/src/lib.rs b/stf/src/lib.rs index e29e515ac8..e20116e459 100644 --- a/stf/src/lib.rs +++ b/stf/src/lib.rs @@ -102,7 +102,7 @@ impl TrustedCall { } } -#[derive(Encode, Decode, Clone)] +#[derive(Encode, Decode, Clone, Debug)] #[allow(non_camel_case_types)] pub enum TrustedGetter { free_balance(AccountId), diff --git a/stf/src/sgx.rs b/stf/src/sgx.rs index e645d003b7..7c68a4519c 100644 --- a/stf/src/sgx.rs +++ b/stf/src/sgx.rs @@ -12,7 +12,7 @@ use sp_io::SgxExternalitiesTrait; use sp_runtime::traits::Dispatchable; use crate::{ - AccountId, State, Stf, TrustedCall, TrustedCallSigned, TrustedGetter, + AccountId, State, Stf, TrustedCall, TrustedCallSigned, TrustedGetter, TrustedGetterSigned, SUBSRATEE_REGISTRY_MODULE, UNSHIELD, }; use sp_core::blake2_256; @@ -204,6 +204,12 @@ impl Stf { key_hashes } + pub fn get_storage_hashes_to_update_for_getter(getter: &TrustedGetterSigned) -> Vec> { + let key_hashes = Vec::new(); + info!("No storage updates needed for getter: {:?}", getter.getter); // dummy. Is currently not needed + key_hashes + } + pub fn storage_hashes_to_update_on_block() -> Vec> { // let key_hashes = Vec::new(); // key_hashes.push(storage_value_key("dummy", "dummy")); diff --git a/worker/Cargo.toml b/worker/Cargo.toml index 70ef8295ba..0247494bcf 100644 --- a/worker/Cargo.toml +++ b/worker/Cargo.toml @@ -13,6 +13,7 @@ env_logger = "0.7" base58 = "0.1" rust-crypto = "0.2" clap = { version = "2.33", features = [ "yaml" ] } +lazy_static = "1.4.0" dirs = "1.0.2" serde = "1.0" diff --git a/worker/src/enclave/api.rs b/worker/src/enclave/api.rs index f9a7adde1b..a50cea771b 100644 --- a/worker/src/enclave/api.rs +++ b/worker/src/enclave/api.rs @@ -63,8 +63,6 @@ extern "C" { blocks: *const u8, blocks_size: usize, nonce: *const u32, - node_url: *const u8, - url_size: usize, unchecked_extrinsic: *mut u8, unchecked_extrinsic_size: usize, ) -> sgx_status_t; @@ -96,8 +94,8 @@ extern "C" { genesis_hash: *const u8, genesis_hash_size: u32, nonce: *const u32, - url: *const u8, - url_size: u32, + w_url: *const u8, + w_url_size: u32, unchecked_extrinsic: *mut u8, unchecked_extrinsic_size: u32, ) -> sgx_status_t; @@ -237,7 +235,6 @@ pub fn enclave_sync_chain_relay( eid: sgx_enclave_id_t, blocks: Vec, tee_nonce: u32, - node_url: &str, ) -> SgxResult> { let mut status = sgx_status_t::SGX_SUCCESS; @@ -251,8 +248,6 @@ pub fn enclave_sync_chain_relay( b.as_ptr(), b.len(), &tee_nonce, - node_url.as_ptr(), - node_url.len(), unchecked_extrinsics.as_mut_ptr(), EXTRINSIC_MAX_SIZE, ) @@ -366,7 +361,7 @@ pub fn enclave_perform_ra( eid: sgx_enclave_id_t, genesis_hash: Vec, nonce: u32, - url: Vec, + w_url: Vec, ) -> SgxResult> { let unchecked_extrinsic_size = EXTRINSIC_MAX_SIZE; let mut unchecked_extrinsic: Vec = vec![0u8; unchecked_extrinsic_size as usize]; @@ -378,8 +373,8 @@ pub fn enclave_perform_ra( genesis_hash.as_ptr(), genesis_hash.len() as u32, &nonce, - url.as_ptr(), - url.len() as u32, + w_url.as_ptr(), + w_url.len() as u32, unchecked_extrinsic.as_mut_ptr(), unchecked_extrinsic_size as u32, ) diff --git a/worker/src/main.rs b/worker/src/main.rs index 6380240d86..057e5b1037 100644 --- a/worker/src/main.rs +++ b/worker/src/main.rs @@ -20,7 +20,10 @@ use std::io::Write; use std::path::Path; use std::slice; use std::str; -use std::sync::mpsc::{channel, Sender}; +use std::sync::{ + mpsc::{channel, Sender}, + Mutex, +}; use std::thread; use sgx_types::*; @@ -28,6 +31,7 @@ use sgx_types::*; use base58::{FromBase58, ToBase58}; use clap::{load_yaml, App}; use codec::{Decode, Encode}; +use lazy_static::lazy_static; use log::*; use sp_core::{ crypto::{AccountId32, Ss58Codec}, @@ -69,6 +73,7 @@ fn main() { let node_port = matches.value_of("node-port").unwrap_or("9944"); let n_url = format!("{}:{}", node_ip, node_port); info!("Interacting with node on {}", n_url); + *NODE_URL.lock().unwrap() = n_url; let w_ip = matches.value_of("w-server").unwrap_or("127.0.0.1"); let w_port = matches.value_of("w-port").unwrap_or("2000"); @@ -96,7 +101,7 @@ fn main() { ShardIdentifier::from_slice(&mrenclave[..]) } }; - worker(&n_url, w_ip, w_port, mu_ra_port, &shard); + worker(w_ip, w_port, mu_ra_port, &shard); } else if matches.is_present("shielding-key") { info!("*** Get the public key from the TEE\n"); let enclave = enclave_init().unwrap(); @@ -204,7 +209,7 @@ fn main() { } } -fn worker(node_url: &str, w_ip: &str, w_port: &str, mu_ra_port: &str, shard: &ShardIdentifier) { +fn worker(w_ip: &str, w_port: &str, mu_ra_port: &str, shard: &ShardIdentifier) { info!("starting worker on shard {}", shard.encode().to_base58()); // ------------------------------------------------------------------------ // check for required files @@ -237,7 +242,8 @@ fn worker(node_url: &str, w_ip: &str, w_port: &str, mu_ra_port: &str, shard: &Sh // ------------------------------------------------------------------------ // start the substrate-api-client to communicate with the node - let mut api = Api::new(node_url.to_string()).set_signer(AccountKeyring::Alice.pair()); + let mut api = + Api::new(NODE_URL.lock().unwrap().clone()).set_signer(AccountKeyring::Alice.pair()); let genesis_hash = api.genesis_hash.as_bytes().to_vec(); let tee_accountid = enclave_account(eid); @@ -480,7 +486,7 @@ pub fn sync_chain_relay( let tee_accountid = enclave_account(eid); let tee_nonce = get_nonce(&api, &tee_accountid); - let xts = enclave_sync_chain_relay(eid, blocks_to_sync, tee_nonce, &api.url).unwrap(); + let xts = enclave_sync_chain_relay(eid, blocks_to_sync, tee_nonce).unwrap(); let extrinsics: Vec> = Decode::decode(&mut xts.as_slice()).unwrap(); info!( @@ -598,6 +604,11 @@ pub fn check_files() { } } +lazy_static! { + // todo: replace with &str, but use &str in api-client first + static ref NODE_URL: Mutex = Mutex::new("".to_string()); +} + /// # Safety /// /// FFI are always unsafe @@ -605,17 +616,14 @@ pub fn check_files() { pub unsafe extern "C" fn ocall_worker_request( request: *const u8, req_size: u32, - node_url: *const u8, - node_url_size: u32, response: *mut u8, resp_size: u32, ) -> sgx_status_t { debug!(" Entering ocall_worker_request"); let mut req_slice = slice::from_raw_parts(request, req_size as usize); let resp_slice = slice::from_raw_parts_mut(response, resp_size as usize); - let url_slice = slice::from_raw_parts(node_url, node_url_size as usize); - let api = Api::::new(String::from_utf8(url_slice.to_vec()).unwrap()); + let api = Api::::new(NODE_URL.lock().unwrap().clone()); let requests: Vec = Decode::decode(&mut req_slice).unwrap(); From f2e67e60cf099be9b7cc8a10fee05a9c7342d32e Mon Sep 17 00:00:00 2001 From: Alain Brenzikofer Date: Sun, 21 Jun 2020 09:26:32 +0200 Subject: [PATCH 12/29] back up chain relay db before update in case of file corruption clean up chain relay sync logging --- enclave/src/io.rs | 13 +++++++++---- enclave/src/lib.rs | 2 +- enclave/src/state.rs | 14 +++++++------- worker/src/main.rs | 32 ++++++++++++++++++++++++-------- 4 files changed, 41 insertions(+), 20 deletions(-) diff --git a/enclave/src/io.rs b/enclave/src/io.rs index 4ebafbd9fc..2662e08273 100644 --- a/enclave/src/io.rs +++ b/enclave/src/io.rs @@ -14,7 +14,7 @@ limitations under the License. */ -use std::fs::File; +use std::fs; use std::io::{Read, Write}; use std::sgxfs::SgxFile; use std::string::String; @@ -31,7 +31,7 @@ pub fn unseal(filepath: &str) -> SgxResult> { } pub fn read(filepath: &str) -> SgxResult> { - File::open(filepath) + fs::File::open(filepath) .map(_read) .sgx_error_with_log(&format!("[Enclave] File '{}' not found!", filepath))? } @@ -46,7 +46,7 @@ fn _read(mut file: F) -> SgxResult> { pub fn read_to_string(filepath: &str) -> SgxResult { let mut contents = String::new(); - File::open(filepath) + fs::File::open(filepath) .map(|mut f| f.read_to_string(&mut contents)) .sgx_error_with_log(&format!("[Enclave] Could not read '{}'", filepath))? .sgx_error_with_log(&format!("[Enclave] File '{}' not found!", filepath))?; @@ -61,7 +61,7 @@ pub fn seal(bytes: &[u8], filepath: &str) -> SgxResult { } pub fn write(bytes: &[u8], filepath: &str) -> SgxResult { - File::create(filepath) + fs::File::create(filepath) .map(|f| _write(bytes, f)) .sgx_error_with_log(&format!("[Enclave] Creating '{}' failed", filepath))? } @@ -83,6 +83,7 @@ pub mod light_validation { use sgx_types::{sgx_status_t, SgxResult}; use sp_finality_grandpa::VersionedAuthorityList; use std::sgxfs::SgxFile; + use std::fs; pub fn unseal() -> SgxResult { let vec = super::unseal(CHAIN_RELAY_DB)?; @@ -90,6 +91,10 @@ pub mod light_validation { } pub fn seal(validator: LightValidation) -> SgxResult { + debug!("backup chain relay state"); + if fs::copy(CHAIN_RELAY_DB, format!("{}.1", CHAIN_RELAY_DB)).is_err() { + warn!("could not backup previous chain relay state"); + }; debug!("Seal Chain Relay State. Current state: {:?}", validator); super::seal(validator.encode().as_slice(), CHAIN_RELAY_DB) } diff --git a/enclave/src/lib.rs b/enclave/src/lib.rs index 7c96ff00a9..ec3a27feb8 100644 --- a/enclave/src/lib.rs +++ b/enclave/src/lib.rs @@ -391,7 +391,7 @@ pub fn update_states(header: Header) -> SgxResult<()> { /// Scans blocks for extrinsics that ask the enclave to execute some actions. pub fn scan_block_for_relevant_xt(block: &Block) -> SgxResult> { - debug!("Scanning blocks for relevant xt"); + debug!("Scanning block {} for relevant xt", block.header.number()); let mut calls = Vec::::new(); for xt_opaque in block.extrinsics.iter() { if let Ok(xt) = diff --git a/enclave/src/state.rs b/enclave/src/state.rs index e7b0bbbe5c..1d07b85b23 100644 --- a/enclave/src/state.rs +++ b/enclave/src/state.rs @@ -42,21 +42,21 @@ pub fn load(shard: &ShardIdentifier) -> SgxResult { shard.encode().to_base58(), ENCRYPTED_STATE_FILE ); - debug!("loading state from: {}", state_path); + trace!("loading state from: {}", state_path); let state_vec = read(&state_path)?; // state is now decrypted! let state: StfState = match state_vec.len() { 0 => { - debug!("state is empty. will initialize it."); + debug!("state at {} is empty. will initialize it.", state_path); Stf::init_state() } n => { - debug!("State loaded with size {}B, deserializing...", n); + debug!("State loaded from {} with size {}B, deserializing...", state_path, n); StfState::decode(state_vec) } }; - debug!("state decoded successfully"); + trace!("state decoded successfully"); Ok(state) } @@ -67,7 +67,7 @@ pub fn write(state: StfState, shard: &ShardIdentifier) -> SgxResult { shard.encode().to_base58(), ENCRYPTED_STATE_FILE ); - debug!("writing state to: {}", state_path); + trace!("writing state to: {}", state_path); let cyphertext = encrypt(state.encode())?; @@ -76,7 +76,7 @@ pub fn write(state: StfState, shard: &ShardIdentifier) -> SgxResult { Err(status) => return Err(status), }; - debug!("new state hash=0x{}", hex::encode_hex(&state_hash)); + debug!("new state with hash=0x{} written to {}", hex::encode_hex(&state_hash), state_path); io::write(&cyphertext, &state_path)?; Ok(state_hash.into()) @@ -106,7 +106,7 @@ fn read(path: &str) -> SgxResult> { }; aes::de_or_encrypt(&mut bytes)?; - debug!("buffer decrypted = {:?}", bytes); + trace!("buffer decrypted = {:?}", bytes); Ok(bytes) } diff --git a/worker/src/main.rs b/worker/src/main.rs index 057e5b1037..3825fe459e 100644 --- a/worker/src/main.rs +++ b/worker/src/main.rs @@ -62,6 +62,9 @@ mod ipfs; mod tests; mod ws_server; +/// how many blocks will be synced before storing the chain db to disk +const BLOCK_SYNC_BATCH_SIZE: u32 = 1000; + fn main() { // Setup logging env_logger::init(); @@ -475,7 +478,10 @@ pub fn sync_chain_relay( .get_signed_block(Some(head.block.header.parent_hash)) .unwrap(); blocks_to_sync.push(head.clone()); - debug!("Syncing Block: {:?}", head.block) + + if head.block.header.number % BLOCK_SYNC_BATCH_SIZE == 0 { + println!("Remaining blocks to fetch until last synced header: {:?}", head.block.header.number - last_synced_head.number) + } } blocks_to_sync.reverse(); debug!( @@ -486,13 +492,23 @@ pub fn sync_chain_relay( let tee_accountid = enclave_account(eid); let tee_nonce = get_nonce(&api, &tee_accountid); - let xts = enclave_sync_chain_relay(eid, blocks_to_sync, tee_nonce).unwrap(); - - let extrinsics: Vec> = Decode::decode(&mut xts.as_slice()).unwrap(); - info!( - "Sync chain relay: Enclave wants to send {} extrinsics", - extrinsics.len() - ); + // only feed BLOCK_SYNC_BATCH_SIZE blocks at a time into the enclave to save enclave state regularly + let mut i = blocks_to_sync[0].block.header.number as usize; + for chunk in blocks_to_sync.chunks(BLOCK_SYNC_BATCH_SIZE as usize) { + let tee_nonce = get_nonce(&api, &tee_accountid); + let xts = enclave_sync_chain_relay(eid, chunk.to_vec(), tee_nonce).unwrap(); + let extrinsics: Vec> = Decode::decode(&mut xts.as_slice()).unwrap(); + + if !extrinsics.is_empty() { + println!( + "Sync chain relay: Enclave wants to send {} extrinsics", + extrinsics.len() + ); + } + for xt in extrinsics.into_iter() { + api.send_extrinsic(hex_encode(xt), XtStatus::InBlock) + .unwrap(); + } for xt in extrinsics.into_iter() { api.send_extrinsic(hex_encode(xt), XtStatus::InBlock) From ca9622d47114d7218bb976bba4067ad93d18b941 Mon Sep 17 00:00:00 2001 From: clangenb <37865735+clangenb@users.noreply.github.com> Date: Tue, 23 Jun 2020 12:54:25 +0200 Subject: [PATCH 13/29] Ws server refactor (#13) * changed ws_server completely. Requests from client are now handled in the worker main event loop to prevent race conditions with on state/chain_relay access. * [ws_server] remove unwrap and send instead "invalid_client_request" to client --- stf/src/lib.rs | 4 +- worker/src/main.rs | 24 +++++---- worker/src/ws_server.rs | 84 ++++++++++++++++++++----------- worker/worker-api/src/client.rs | 9 ++-- worker/worker-api/src/lib.rs | 25 ++++----- worker/worker-api/src/requests.rs | 12 +++-- 6 files changed, 97 insertions(+), 61 deletions(-) diff --git a/stf/src/lib.rs b/stf/src/lib.rs index e20116e459..639a8b6485 100644 --- a/stf/src/lib.rs +++ b/stf/src/lib.rs @@ -126,7 +126,7 @@ impl TrustedGetter { } } -#[derive(Encode, Decode, Clone)] +#[derive(Encode, Decode, Clone, Debug)] pub struct TrustedGetterSigned { pub getter: TrustedGetter, pub signature: AnySignature, @@ -143,7 +143,7 @@ impl TrustedGetterSigned { } } -#[derive(Encode, Decode, Clone)] +#[derive(Encode, Decode, Clone, Debug)] pub struct TrustedCallSigned { pub call: TrustedCall, pub nonce: u32, diff --git a/worker/src/main.rs b/worker/src/main.rs index 3825fe459e..d9ca78cf61 100644 --- a/worker/src/main.rs +++ b/worker/src/main.rs @@ -55,6 +55,8 @@ use sp_finality_grandpa::{AuthorityList, VersionedAuthorityList, GRANDPA_AUTHORI use substratee_node_primitives::calls::get_first_worker_that_is_not_equal_to_self; use substratee_worker_api::Api as WorkerApi; use ws_server::start_ws_server; +use substratee_worker_api::requests::ClientRequest; +use std::time::Duration; mod constants; mod enclave; @@ -78,7 +80,7 @@ fn main() { info!("Interacting with node on {}", n_url); *NODE_URL.lock().unwrap() = n_url; - let w_ip = matches.value_of("w-server").unwrap_or("127.0.0.1"); + let w_ip = matches.value_of("w-server").unwrap_or("ws://127.0.0.1"); let w_port = matches.value_of("w-port").unwrap_or("2000"); info!("Worker listening on {}:{}", w_ip, w_port); @@ -228,8 +230,9 @@ fn worker(w_ip: &str, w_port: &str, mu_ra_port: &str, shard: &ShardIdentifier) { let eid = enclave.geteid(); // ------------------------------------------------------------------------ // start the ws server to listen for worker requests + let (ws_sender, ws_receiver) = channel(); let w_url = format!("{}:{}", w_ip, w_port); - start_ws_server(eid, w_url.clone(), mu_ra_port.to_string()); + start_ws_server(w_url.clone(),ws_sender.clone()); // ------------------------------------------------------------------------ // let new workers call us for key provisioning @@ -316,14 +319,17 @@ fn worker(w_ip: &str, w_port: &str, mu_ra_port: &str, shard: &ShardIdentifier) { println!("[+] Subscribed to events. waiting..."); + let timeout = Duration::from_millis(10); loop { - let msg = receiver.recv().unwrap(); - if let Ok(events) = parse_events(msg.clone()) { - print_events(events, sender.clone()) - } else if let Ok(_header) = parse_header(msg.clone()) { - latest_head = sync_chain_relay(eid, &api, latest_head) - } else { - println!("[-] Unable to parse received message!") + if let Ok(msg) = receiver.recv_timeout(timeout) { + if let Ok(events) = parse_events(msg.clone()) { + print_events(events, sender.clone()) + } else if let Ok(_header) = parse_header(msg.clone()) { + latest_head = sync_chain_relay(eid, &api, latest_head) + } + } + if let Ok(req) = ws_receiver.recv_timeout(timeout) { + ws_server::handle_request(req, eid, mu_ra_port.to_string()).unwrap() } } } diff --git a/worker/src/ws_server.rs b/worker/src/ws_server.rs index c2516ed569..fdc5fb7662 100644 --- a/worker/src/ws_server.rs +++ b/worker/src/ws_server.rs @@ -20,37 +20,50 @@ use std::thread; use sgx_types::*; -use codec::Encode; +use codec::{Decode, Encode}; use log::*; -use substratee_stf::ShardIdentifier; +use std::sync::mpsc::Sender as MpscSender; +use substratee_stf::{ShardIdentifier, TrustedGetter, TrustedGetterSigned}; use substratee_worker_api::requests::*; use ws::{listen, CloseCode, Handler, Message, Result, Sender}; use crate::enclave::api::{enclave_query_state, enclave_shielding_key}; -pub fn start_ws_server(eid: sgx_enclave_id_t, addr: String, mu_ra_port: String) { +#[derive(Clone, Debug)] +pub struct WsServerRequest { + client: Sender, + request: ClientRequest, +} + +impl WsServerRequest { + pub fn new(client: Sender, request: ClientRequest) -> Self { + Self { client, request } + } +} + +pub fn start_ws_server(addr: String, worker: MpscSender) { // Server WebSocket handler struct Server { - out: Sender, - eid: sgx_enclave_id_t, - mu_ra_port: String, + client: Sender, + worker: MpscSender, } impl Handler for Server { fn on_message(&mut self, msg: Message) -> Result<()> { - info!(" [WS Server] Got message '{}'. ", msg); - - let msg_txt = msg.into_text().unwrap(); - let args: Vec<&str> = msg_txt.split("::").collect(); - - let answer = match args[0] { - MSG_GET_PUB_KEY_WORKER => get_worker_pub_key(self.eid), - MSG_GET_MU_RA_PORT => Message::text(self.mu_ra_port.clone()), - MSG_GET_STF_STATE => handle_get_stf_state_msg(self.eid, args[1], args[2]), - _ => Message::text("[WS Server]: unrecognized msg pattern"), - }; - - self.out.send(answer) + info!( + "[WS Server] Forwarding message to worker event loop: {:?}", + msg + ); + + match ClientRequest::decode(&mut msg.into_data().as_slice()) { + Ok(req) => { + self.worker + .send(WsServerRequest::new(self.client.clone(), req)) + .unwrap(); + } + Err(e) => self.client.send("Could not decode request").unwrap() + } + Ok(()) } fn on_close(&mut self, code: CloseCode, reason: &str) { @@ -61,20 +74,35 @@ pub fn start_ws_server(eid: sgx_enclave_id_t, addr: String, mu_ra_port: String) info!("Starting WebSocket server on {}", addr); thread::spawn(move || { listen(addr, |out| Server { - out, - eid, - mu_ra_port: mu_ra_port.clone(), + client: out, + worker: worker.clone(), }) .unwrap() }); } -fn handle_get_stf_state_msg(eid: sgx_enclave_id_t, getter_str: &str, shard_str: &str) -> Message { - info!(" [WS Server] Query state"); - let getter_vec = hex::decode(getter_str).unwrap(); - let shard = ShardIdentifier::from_slice(&hex::decode(shard_str).unwrap()); +pub fn handle_request( + req: WsServerRequest, + eid: sgx_enclave_id_t, + mu_ra_port: String, +) -> Result<()> { + info!(" [WS Server] Got message '{:?}'. ", req); + let answer = match req.request { + ClientRequest::PubKeyWorker => get_pubkey(eid), + ClientRequest::MuRaPortWorker => Message::text(mu_ra_port), + ClientRequest::StfState(getter, shard) => get_stf_state(eid, getter, shard), + }; - let value = match enclave_query_state(eid, getter_vec, shard.encode()) { + req.client.send(answer) +} + +fn get_stf_state( + eid: sgx_enclave_id_t, + getter: TrustedGetterSigned, + shard: ShardIdentifier, +) -> Message { + info!(" [WS Server] Query state"); + let value = match enclave_query_state(eid, getter.encode(), shard.encode()) { Ok(val) => Some(val), Err(_) => { error!("query state failed"); @@ -86,7 +114,7 @@ fn handle_get_stf_state_msg(eid: sgx_enclave_id_t, getter_str: &str, shard_str: Message::text(hex::encode(value.encode())) } -fn get_worker_pub_key(eid: sgx_enclave_id_t) -> Message { +fn get_pubkey(eid: sgx_enclave_id_t) -> Message { let rsa_pubkey = enclave_shielding_key(eid).unwrap(); debug!(" [WS Server] RSA pubkey {:?}\n", rsa_pubkey); diff --git a/worker/worker-api/src/client.rs b/worker/worker-api/src/client.rs index be42f101ea..1b01c74ba3 100644 --- a/worker/worker-api/src/client.rs +++ b/worker/worker-api/src/client.rs @@ -17,20 +17,21 @@ use std::sync::mpsc::Sender as ThreadOut; +use crate::requests::ClientRequest; +use codec::Encode; use log::*; use ws::{CloseCode, Handler, Handshake, Message, Result, Sender}; pub struct WsClient { pub out: Sender, - pub request: String, + pub request: ClientRequest, pub result: ThreadOut, } impl Handler for WsClient { fn on_open(&mut self, _: Handshake) -> Result<()> { - info!("sending request: {}", self.request); - - match self.out.send(self.request.clone()) { + debug!("sending request: {:?}", self.request); + match self.out.send(Message::Binary(self.request.encode())) { Ok(_) => Ok(()), Err(e) => Err(e), } diff --git a/worker/worker-api/src/lib.rs b/worker/worker-api/src/lib.rs index b636f533c0..acfb9db98e 100644 --- a/worker/worker-api/src/lib.rs +++ b/worker/worker-api/src/lib.rs @@ -20,7 +20,7 @@ use std::thread; use sgx_crypto_helper::rsa3072::Rsa3072PubKey; -use codec::{Decode, Encode}; +use codec::{Decode}; use log::*; use ws::connect; @@ -37,18 +37,16 @@ pub struct Api { } impl Api { - pub fn new(url: String) -> Api { - Api { - url: format!("ws://{}", url), - } + pub fn new(url: String) -> Self { + Self { url } } pub fn get_mu_ra_port(&self) -> Result { - Self::get(&self, MSG_GET_MU_RA_PORT) + Self::get(&self, ClientRequest::MuRaPortWorker) } pub fn get_rsa_pubkey(&self) -> Result { - let keystr = Self::get(&self, MSG_GET_PUB_KEY_WORKER)?; + let keystr = Self::get(&self, ClientRequest::PubKeyWorker)?; let rsa_pubkey: Rsa3072PubKey = serde_json::from_str(&keystr).unwrap(); info!("[+] Got RSA public key of enclave"); @@ -61,10 +59,8 @@ impl Api { getter: TrustedGetterSigned, shard: &ShardIdentifier, ) -> Result, ()> { - let getter_str = hex::encode(getter.encode()); - let shard_str = hex::encode(shard.encode()); - let request = format!("{}::{}::{}", MSG_GET_STF_STATE, getter_str, shard_str); - match Self::get(&self, &request) { + let req = ClientRequest::StfState(getter, shard.to_owned()); + match Self::get(&self, req) { Ok(res) => { let value_slice = hex::decode(&res).unwrap(); let value: Option> = Decode::decode(&mut &value_slice[..]).unwrap(); @@ -77,16 +73,15 @@ impl Api { } } - fn get(&self, request: &str) -> Result { + fn get(&self, request: ClientRequest) -> Result { let url = self.url.clone(); - let req = request.to_string(); let (port_in, port_out) = channel(); - info!("[Worker Api]: Sending request: {}", req); + info!("[Worker Api]: Sending request: {:?}", request); let client = thread::spawn(move || { match connect(url, |out| WsClient { out, - request: req.clone(), + request: request.clone(), result: port_in.clone(), }) { Ok(c) => c, diff --git a/worker/worker-api/src/requests.rs b/worker/worker-api/src/requests.rs index b9e6479bf2..8dbbfd1149 100644 --- a/worker/worker-api/src/requests.rs +++ b/worker/worker-api/src/requests.rs @@ -15,6 +15,12 @@ */ -pub const MSG_GET_PUB_KEY_WORKER: &str = "get_pub_key_worker"; -pub const MSG_GET_MU_RA_PORT: &str = "get_mu_ra_port"; -pub const MSG_GET_STF_STATE: &str = "get_stf_state"; +use codec::{Encode, Decode}; +use substratee_stf::{TrustedGetterSigned, ShardIdentifier}; + +#[derive(Encode, Decode, Clone, Debug)] +pub enum ClientRequest { + PubKeyWorker, + MuRaPortWorker, + StfState(TrustedGetterSigned, ShardIdentifier), // (trusted_getter_encrypted, shard) +} \ No newline at end of file From d185559c02dafcb9a9683c50c1df02e3a6b805ba Mon Sep 17 00:00:00 2001 From: Alain Brenzikofer Date: Tue, 23 Jun 2020 20:54:31 +0200 Subject: [PATCH 14/29] worker should panic if it can't write to shard --- enclave/src/lib.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/enclave/src/lib.rs b/enclave/src/lib.rs index ec3a27feb8..fec01819b5 100644 --- a/enclave/src/lib.rs +++ b/enclave/src/lib.rs @@ -348,6 +348,11 @@ pub unsafe extern "C" fn sync_chain_relay( return sgx_status_t::SGX_ERROR_UNEXPECTED; } + if update_states(signed_block.block.header.clone()).is_err() { + error!("Error performing state updates upon block import") + return sgx_status_t::SGX_ERROR_UNEXPECTED; + } + match scan_block_for_relevant_xt(&signed_block.block) { Ok(c) => calls.extend(c.into_iter()), Err(_) => error!("Error executing relevant extrinsics"), From f815fcd8a9a0254451f2c170f632076d75edaf14 Mon Sep 17 00:00:00 2001 From: brenzi Date: Tue, 23 Jun 2020 23:06:58 +0200 Subject: [PATCH 15/29] add public getters for unpermissioned statistics (#16) * fixes #7 * add total-issuance to client CLI * bump version to 0.6.7 * document new function in script --- Cargo.lock | 428 +++++++++++++++++++------- client/bootstrap_demo_currency.sh | 131 ++++++++ client/src/main.rs | 12 +- enclave/chain_relay/Cargo.toml | 2 +- enclave/src/lib.rs | 24 +- stf/Cargo.toml | 2 +- stf/src/cli.rs | 237 ++++++++++---- stf/src/lib.rs | 55 +++- stf/src/sgx.rs | 11 +- substratee-node-primitives/Cargo.toml | 2 +- worker/src/ws_server.rs | 4 +- worker/worker-api/Cargo.toml | 2 +- worker/worker-api/src/lib.rs | 4 +- worker/worker-api/src/requests.rs | 4 +- 14 files changed, 706 insertions(+), 212 deletions(-) create mode 100755 client/bootstrap_demo_currency.sh diff --git a/Cargo.lock b/Cargo.lock index a20734ea87..6841262296 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -561,6 +561,123 @@ version = "1.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bb1f6b1ce1c140482ea30ddd3335fc0024ac7ee112895426e0a629a6c20adfe3" +[[package]] +name = "encointer-client-teeproxy" +version = "0.6.7-sub2.0.0-alpha.7" +dependencies = [ + "base58", + "blake2-rfc", + "chrono", + "clap", + "clap-nested", + "encointer-node-teeproxy-runtime", + "env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "frame-system", + "geojson", + "hex 0.4.2", + "json", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "pallet-balances", + "pallet-encointer-balances 0.3.0 (git+https://github.com/encointer/pallets?tag=v0.3.1)", + "pallet-encointer-ceremonies 0.3.0 (git+https://github.com/encointer/pallets?tag=v0.3.1)", + "pallet-encointer-currencies 0.3.0 (git+https://github.com/encointer/pallets?tag=v0.3.1)", + "pallet-encointer-scheduler 0.3.1", + "parity-scale-codec", + "primitive-types 0.6.2", + "sc-keystore", + "serde", + "serde_json", + "sp-application-crypto", + "sp-core", + "sp-keyring", + "sp-runtime", + "substrate-api-client", + "substrate-bip39 0.3.1", + "substratee-stf", + "substratee-worker-api", + "tiny-bip39 0.6.2", +] + +[[package]] +name = "encointer-node-teeproxy-runtime" +version = "0.3.2" +source = "git+https://github.com/encointer/encointer-node?branch=sgx-master#59ef144fa0b5d44c9c0ef003086facd848ad9b17" +dependencies = [ + "frame-executive", + "frame-support", + "frame-system", + "frame-system-rpc-runtime-api", + "pallet-aura", + "pallet-balances", + "pallet-encointer-balances 0.3.0 (git+https://github.com/encointer/pallets?tag=v0.3.1)", + "pallet-encointer-ceremonies 0.3.0 (git+https://github.com/encointer/pallets?tag=v0.3.1)", + "pallet-encointer-currencies 0.3.0 (git+https://github.com/encointer/pallets?tag=v0.3.1)", + "pallet-encointer-scheduler 0.3.1", + "pallet-grandpa", + "pallet-randomness-collective-flip", + "pallet-substratee-registry", + "pallet-sudo", + "pallet-timestamp", + "pallet-transaction-payment", + "pallet-transaction-payment-rpc-runtime-api", + "parity-scale-codec", + "serde", + "sp-api", + "sp-block-builder", + "sp-consensus-aura", + "sp-core", + "sp-inherents", + "sp-io 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-offchain", + "sp-runtime", + "sp-session", + "sp-std", + "sp-transaction-pool", + "sp-version", + "substrate-fixed", + "substrate-wasm-builder-runner", +] + +[[package]] +name = "encointer-worker" +version = "0.6.7-sub2.0.0-alpha.7" +dependencies = [ + "base58", + "cid", + "clap", + "dirs", + "encointer-node-teeproxy-runtime", + "env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "frame-system", + "futures 0.1.29", + "hex 0.3.2", + "hyper", + "ipfs-api", + "lazy_static", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "multihash", + "pallet-balances", + "parity-scale-codec", + "primitive-types 0.6.2", + "rust-crypto", + "serde", + "serde_derive", + "serde_json", + "sgx_crypto_helper", + "sgx_types", + "sgx_urts", + "sha2 0.7.1", + "sp-core", + "sp-finality-grandpa", + "sp-keyring", + "sp-runtime", + "substrate-api-client", + "substratee-node-primitives", + "substratee-stf", + "substratee-worker-api", + "ws", +] + [[package]] name = "env_logger" version = "0.7.1" @@ -789,6 +906,16 @@ dependencies = [ "sp-version", ] +[[package]] +name = "frame-system-rpc-runtime-api" +version = "2.0.0-alpha.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd46f144dd3e1a29dc7bac5f5d3cce95b43dcaf9f352880d95e94a5019fd2191" +dependencies = [ + "parity-scale-codec", + "sp-api", +] + [[package]] name = "fuchsia-cprng" version = "0.1.1" @@ -948,6 +1075,17 @@ dependencies = [ "typenum", ] +[[package]] +name = "geojson" +version = "0.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4ac03428b3276fc7f1756eba0c76c7c0c91ef77e1c43fbdd47a460238419cb9" +dependencies = [ + "num-traits", + "serde", + "serde_json", +] + [[package]] name = "getrandom" version = "0.1.14" @@ -1897,6 +2035,152 @@ dependencies = [ "sp-std", ] +[[package]] +name = "pallet-encointer-balances" +version = "0.3.0" +source = "git+https://github.com/encointer/pallets?tag=v0.3.0#f60169a908675bb90ae54cfa8b9000fc08ca45e7" +dependencies = [ + "frame-support", + "frame-system", + "impl-trait-for-tuples", + "num-traits", + "pallet-encointer-currencies 0.3.0 (git+https://github.com/encointer/pallets?tag=v0.3.0)", + "parity-scale-codec", + "safe-mix", + "serde", + "sp-io 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-runtime", + "sp-std", + "substrate-fixed", +] + +[[package]] +name = "pallet-encointer-balances" +version = "0.3.0" +source = "git+https://github.com/encointer/pallets?tag=v0.3.1#21f1fba74f66052564764d93c119a712d27d0aa3" +dependencies = [ + "frame-support", + "frame-system", + "impl-trait-for-tuples", + "num-traits", + "pallet-encointer-currencies 0.3.0 (git+https://github.com/encointer/pallets?tag=v0.3.1)", + "parity-scale-codec", + "safe-mix", + "serde", + "sp-io 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-runtime", + "sp-std", + "substrate-fixed", +] + +[[package]] +name = "pallet-encointer-ceremonies" +version = "0.3.0" +source = "git+https://github.com/encointer/pallets?tag=v0.3.0#f60169a908675bb90ae54cfa8b9000fc08ca45e7" +dependencies = [ + "frame-support", + "frame-system", + "pallet-balances", + "pallet-encointer-balances 0.3.0 (git+https://github.com/encointer/pallets?tag=v0.3.0)", + "pallet-encointer-currencies 0.3.0 (git+https://github.com/encointer/pallets?tag=v0.3.0)", + "pallet-encointer-scheduler 0.3.0", + "pallet-timestamp", + "parity-scale-codec", + "serde", + "sp-core", + "sp-io 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "pallet-encointer-ceremonies" +version = "0.3.0" +source = "git+https://github.com/encointer/pallets?tag=v0.3.1#21f1fba74f66052564764d93c119a712d27d0aa3" +dependencies = [ + "frame-support", + "frame-system", + "pallet-balances", + "pallet-encointer-balances 0.3.0 (git+https://github.com/encointer/pallets?tag=v0.3.1)", + "pallet-encointer-currencies 0.3.0 (git+https://github.com/encointer/pallets?tag=v0.3.1)", + "pallet-encointer-scheduler 0.3.1", + "pallet-timestamp", + "parity-scale-codec", + "serde", + "sp-core", + "sp-io 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "pallet-encointer-currencies" +version = "0.3.0" +source = "git+https://github.com/encointer/pallets?tag=v0.3.0#f60169a908675bb90ae54cfa8b9000fc08ca45e7" +dependencies = [ + "frame-support", + "frame-system", + "pallet-balances", + "parity-scale-codec", + "serde", + "sp-core", + "sp-io 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-runtime", + "sp-std", + "substrate-fixed", +] + +[[package]] +name = "pallet-encointer-currencies" +version = "0.3.0" +source = "git+https://github.com/encointer/pallets?tag=v0.3.1#21f1fba74f66052564764d93c119a712d27d0aa3" +dependencies = [ + "frame-support", + "frame-system", + "pallet-balances", + "parity-scale-codec", + "serde", + "sp-core", + "sp-io 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-runtime", + "sp-std", + "substrate-fixed", +] + +[[package]] +name = "pallet-encointer-scheduler" +version = "0.3.0" +source = "git+https://github.com/encointer/pallets?tag=v0.3.0#f60169a908675bb90ae54cfa8b9000fc08ca45e7" +dependencies = [ + "frame-support", + "frame-system", + "pallet-timestamp", + "parity-scale-codec", + "serde", + "sp-core", + "sp-io 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-runtime", + "sp-std", + "sp-timestamp", +] + +[[package]] +name = "pallet-encointer-scheduler" +version = "0.3.1" +source = "git+https://github.com/encointer/pallets?tag=v0.3.1#21f1fba74f66052564764d93c119a712d27d0aa3" +dependencies = [ + "frame-support", + "frame-system", + "pallet-timestamp", + "parity-scale-codec", + "serde", + "sp-core", + "sp-io 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-runtime", + "sp-std", + "sp-timestamp", +] + [[package]] name = "pallet-finality-tracker" version = "2.0.0-alpha.7" @@ -2000,7 +2284,7 @@ dependencies = [ [[package]] name = "pallet-template" version = "2.0.0-alpha.7" -source = "git+https://github.com/scs/sgx-runtime?tag=v2.0.0-alpha.7#32f212bbefffc095bb5ef470b86fd7f776338dbb" +source = "git+https://github.com/encointer/sgx-runtime#e206ce2f185fb22c513c0e52f591576418a817d6" dependencies = [ "frame-support", "frame-system", @@ -2950,7 +3234,7 @@ dependencies = [ [[package]] name = "sgx-externalities" version = "0.2.0" -source = "git+https://github.com/scs/sgx-runtime#32f212bbefffc095bb5ef470b86fd7f776338dbb" +source = "git+https://github.com/encointer/sgx-runtime#e206ce2f185fb22c513c0e52f591576418a817d6" dependencies = [ "environmental", "log 0.4.8 (git+https://github.com/mesalock-linux/log-sgx)", @@ -2962,13 +3246,17 @@ dependencies = [ [[package]] name = "sgx-runtime" version = "2.0.0-alpha.7" -source = "git+https://github.com/scs/sgx-runtime?tag=v2.0.0-alpha.7#32f212bbefffc095bb5ef470b86fd7f776338dbb" +source = "git+https://github.com/encointer/sgx-runtime#e206ce2f185fb22c513c0e52f591576418a817d6" dependencies = [ "frame-executive", "frame-support", "frame-system", "pallet-aura", "pallet-balances", + "pallet-encointer-balances 0.3.0 (git+https://github.com/encointer/pallets?tag=v0.3.0)", + "pallet-encointer-ceremonies 0.3.0 (git+https://github.com/encointer/pallets?tag=v0.3.0)", + "pallet-encointer-currencies 0.3.0 (git+https://github.com/encointer/pallets?tag=v0.3.0)", + "pallet-encointer-scheduler 0.3.0", "pallet-grandpa", "pallet-randomness-collective-flip", "pallet-sudo", @@ -3372,7 +3660,7 @@ dependencies = [ [[package]] name = "sp-io" version = "2.0.0-alpha.7" -source = "git+https://github.com/scs/sgx-runtime#32f212bbefffc095bb5ef470b86fd7f776338dbb" +source = "git+https://github.com/encointer/sgx-runtime#e206ce2f185fb22c513c0e52f591576418a817d6" dependencies = [ "environmental", "hash-db", @@ -3764,48 +4052,27 @@ dependencies = [ ] [[package]] -name = "substrate-wasm-builder-runner" -version = "1.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2a965994514ab35d3893e9260245f2947fd1981cdd4fffd2c6e6d1a9ce02e6a" - -[[package]] -name = "substratee-client" -version = "0.6.5-sub2.0.0-alpha.7" +name = "substrate-fixed" +version = "0.5.4" +source = "git+https://github.com/encointer/substrate-fixed?tag=v0.5.4+sub_v0.1#2c52170fa02507dc5b52c516061302670860869a" dependencies = [ - "base58", - "blake2-rfc", - "chrono", - "clap", - "clap-nested", - "env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", - "frame-system", - "hex 0.4.2", - "json", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "pallet-balances", "parity-scale-codec", - "primitive-types 0.6.2", - "sc-keystore", "serde", - "serde_json", - "sp-application-crypto", - "sp-core", - "sp-keyring", - "sp-runtime", - "substrate-api-client", - "substrate-bip39 0.3.1", - "substratee-node-runtime", - "substratee-stf", - "substratee-worker-api", - "tiny-bip39 0.6.2", + "typenum", ] +[[package]] +name = "substrate-wasm-builder-runner" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2a965994514ab35d3893e9260245f2947fd1981cdd4fffd2c6e6d1a9ce02e6a" + [[package]] name = "substratee-node-primitives" -version = "0.6.5-sub2.0.0-alpha.7" +version = "0.6.7-sub2.0.0-alpha.7" dependencies = [ "base58", + "encointer-node-teeproxy-runtime", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec", "primitive-types 0.6.2", @@ -3813,45 +4080,11 @@ dependencies = [ "sp-core", "sp-runtime", "substrate-api-client", - "substratee-node-runtime", -] - -[[package]] -name = "substratee-node-runtime" -version = "0.6.6-sub2.0.0-alpha.7" -source = "git+https://github.com/scs/substraTEE-node?tag=v0.6.6-sub2.0.0-alpha.7#53c2c0330ebf55b869f2fcd106490cff9a466417" -dependencies = [ - "frame-executive", - "frame-support", - "frame-system", - "pallet-aura", - "pallet-balances", - "pallet-grandpa", - "pallet-randomness-collective-flip", - "pallet-substratee-registry", - "pallet-sudo", - "pallet-timestamp", - "pallet-transaction-payment", - "parity-scale-codec", - "serde", - "sp-api", - "sp-block-builder", - "sp-consensus-aura", - "sp-core", - "sp-inherents", - "sp-io 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", - "sp-offchain", - "sp-runtime", - "sp-session", - "sp-std", - "sp-transaction-pool", - "sp-version", - "substrate-wasm-builder-runner", ] [[package]] name = "substratee-stf" -version = "0.6.5-sub2.0.0-alpha.7" +version = "0.6.7-sub2.0.0-alpha.7" dependencies = [ "base58", "clap", @@ -3860,63 +4093,28 @@ dependencies = [ "env_logger 0.7.1 (git+https://github.com/mesalock-linux/env_logger-sgx)", "frame-metadata", "frame-system", + "hex 0.3.2", "log 0.4.8 (git+https://github.com/mesalock-linux/log-sgx)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "pallet-balances", + "pallet-encointer-balances 0.3.0 (git+https://github.com/encointer/pallets?tag=v0.3.0)", + "pallet-encointer-ceremonies 0.3.0 (git+https://github.com/encointer/pallets?tag=v0.3.0)", + "pallet-encointer-currencies 0.3.0 (git+https://github.com/encointer/pallets?tag=v0.3.0)", + "pallet-encointer-scheduler 0.3.0", "parity-scale-codec", "sc-keystore", "sgx-runtime", "sgx_tstd", "sp-application-crypto", "sp-core", - "sp-io 2.0.0-alpha.7 (git+https://github.com/scs/sgx-runtime)", - "sp-keyring", - "sp-runtime", -] - -[[package]] -name = "substratee-worker" -version = "0.6.5-sub2.0.0-alpha.7" -dependencies = [ - "base58", - "cid", - "clap", - "dirs", - "env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", - "frame-system", - "futures 0.1.29", - "hex 0.3.2", - "hyper", - "ipfs-api", - "lazy_static", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "multihash", - "pallet-balances", - "parity-scale-codec", - "primitive-types 0.6.2", - "rust-crypto", - "serde", - "serde_derive", - "serde_json", - "sgx_crypto_helper", - "sgx_types", - "sgx_urts", - "sha2 0.7.1", - "sp-core", - "sp-finality-grandpa", + "sp-io 2.0.0-alpha.7 (git+https://github.com/encointer/sgx-runtime)", "sp-keyring", "sp-runtime", "substrate-api-client", - "substratee-node-primitives", - "substratee-node-runtime", - "substratee-stf", - "substratee-worker-api", - "ws", ] [[package]] name = "substratee-worker-api" -version = "0.6.5-sub2.0.0-alpha.7" +version = "0.6.7-sub2.0.0-alpha.7" dependencies = [ "hex 0.4.2", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4367,7 +4565,7 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3bfd5b7557925ce778ff9b9ef90e3ade34c524b5ff10e239c69a42d546d2af56" dependencies = [ - "rand 0.3.23", + "rand 0.7.3", ] [[package]] diff --git a/client/bootstrap_demo_currency.sh b/client/bootstrap_demo_currency.sh new file mode 100755 index 0000000000..42f129f1a7 --- /dev/null +++ b/client/bootstrap_demo_currency.sh @@ -0,0 +1,131 @@ +#!/bin/bash + +# M1 Demo +# +# bootstrap a bot currency on Encointer Cantillon Testnet + +## Cantillon node endpoint +#NURL=wss://cantillon.encointer.org +#NPORT=443 +## Cantillon worker endpoint +#WURL=wss://substratee03.scs.ch +#WPORT=443 + +# locals +NURL=ws://127.0.0.1 +NPORT=9979 +WURL=ws://127.0.0.1 +WPORT=2000 + +CLIENT="./../bin/encointer-client-teeproxy -u $NURL -p $NPORT -U $WURL -P $WPORT" + +wait_for_phase() { + current_phase=$($CLIENT get-phase) + + echo "waiting for phase: $1 ..." + + while [ "$current_phase" != "$1" ]; do + echo "current phase: $current_phase ... waiting for phase $1" + sleep 10 + current_phase=$($CLIENT get-phase) + done + + echo "current_phase is $1, progress script" +} + +echo "Using node address: $NURL:$NPORT" +echo "Using worker address: $WURL:$WPORT" +echo "" + + +#WORKERADDR="--worker-url ${WURL} --worker-port ${WPORT}" + +# register new currency (with any funded on-chain account) +cid=$($CLIENT new-currency test-locations-sea-of-crete.json //Alice) +echo $cid + +# list currenies +$CLIENT list-currencies + +wait_for_phase REGISTERING + +#read MRENCLAVE <<< $($CLIENT list-workers | awk '/ MRENCLAVE: / { print $2 }') +#cid=7eLSZLSMShw4ju9GvuMmoVgeZxZimtvsGTSvLEdvcRqQ +MRENCLAVE=6AkpQeSLGSwESvKMiygJzDTLHXvnwBG9c8Q8FV9LiDuN + +echo " MRENCLAVE = ${MRENCLAVE}" + +# new account with +# $CLIENT trusted new-account --mrenclave $MRENCLAVE --shard $cid + +# these must be registered bootstrappers +account1=//AliceIncognito +account2=//BobIncognito +account3=//CharlieIncognito + +$CLIENT trusted get-registration $account1 --mrenclave $MRENCLAVE --shard $cid +# should be zero + +$CLIENT trusted register-participant $account1 --mrenclave $MRENCLAVE --shard $cid +$CLIENT trusted register-participant $account2 --mrenclave $MRENCLAVE --shard $cid +$CLIENT trusted register-participant $account3 --mrenclave $MRENCLAVE --shard $cid + +echo "*** registered participants" +sleep 10 # the above returns before TrustedCalls have been executed + +# should be 1,2 and 3 +$CLIENT trusted get-registration $account1 --mrenclave $MRENCLAVE --shard $cid +$CLIENT trusted get-registration $account2 --mrenclave $MRENCLAVE --shard $cid +$CLIENT trusted get-registration $account3 --mrenclave $MRENCLAVE --shard $cid + +wait_for_phase ASSIGNING + +# nothing to do here until we can have debug getters + +wait_for_phase ATTESTING + +echo "* Waiting 5 seconds such that phase change happened in enclave" +sleep 5 +echo "" + +echo "*** start meetup" +claim1=$($CLIENT trusted new-claim $account1 3 --mrenclave $MRENCLAVE --shard $cid ) +claim2=$($CLIENT trusted new-claim $account2 3 --mrenclave $MRENCLAVE --shard $cid ) +claim3=$($CLIENT trusted new-claim $account3 3 --mrenclave $MRENCLAVE --shard $cid ) + +echo "Claim1 = ${claim1}" +echo "Claim2 = ${claim2}" +echo "Claim3 = ${claim3}" + +echo "*** sign each others claims" +witness1_2=$($CLIENT sign-claim $account1 $claim2) +witness1_3=$($CLIENT sign-claim $account1 $claim3) + +witness2_1=$($CLIENT sign-claim $account2 $claim1) +witness2_3=$($CLIENT sign-claim $account2 $claim3) + +witness3_1=$($CLIENT sign-claim $account3 $claim1) +witness3_2=$($CLIENT sign-claim $account3 $claim2) + +echo "*** send witnesses to chain" +$CLIENT trusted register-attestations $account1 $witness2_1 $witness3_1 --mrenclave $MRENCLAVE --shard $cid +$CLIENT trusted register-attestations $account2 $witness1_2 $witness3_2 --mrenclave $MRENCLAVE --shard $cid +$CLIENT trusted register-attestations $account3 $witness1_3 $witness2_3 --mrenclave $MRENCLAVE --shard $cid + + +$CLIENT trusted get-attestations $account1 --mrenclave $MRENCLAVE --shard $cid +$CLIENT trusted get-attestations $account2 --mrenclave $MRENCLAVE --shard $cid +$CLIENT trusted get-attestations $account3 --mrenclave $MRENCLAVE --shard $cid + +wait_for_phase REGISTERING + +echo "* Waiting 5 seconds such that phase change happened in enclave" +sleep 5 +echo "" + +echo "account balances for new currency with cid $cid" +$CLIENT trusted balance $account1 --mrenclave $MRENCLAVE --shard $cid +$CLIENT trusted balance $account2 --mrenclave $MRENCLAVE --shard $cid +$CLIENT trusted balance $account3 --mrenclave $MRENCLAVE --shard $cid +echo "total issuance (publicly readable)" +$CLIENT trusted total-issuance --mrenclave $MRENCLAVE --shard $cid \ No newline at end of file diff --git a/client/src/main.rs b/client/src/main.rs index a7a80b4a91..43d98aef2c 100644 --- a/client/src/main.rs +++ b/client/src/main.rs @@ -58,7 +58,7 @@ use substratee_node_runtime::{ }; use substratee_stf::{ cli::get_identifiers, ShardIdentifier, TrustedCallSigned, TrustedGetterSigned, - TrustedOperationSigned, + TrustedOperation, Getter }; use substratee_worker_api::Api as WorkerApi; @@ -437,18 +437,18 @@ fn get_worker_api(matches: &ArgMatches<'_>) -> WorkerApi { fn perform_trusted_operation( matches: &ArgMatches<'_>, - top: &TrustedOperationSigned, + top: &TrustedOperation, ) -> Option> { match top { - TrustedOperationSigned::call(call) => send_request(matches, call.clone()), - TrustedOperationSigned::get(getter) => get_state(matches, getter.clone()), + TrustedOperation::call(call) => send_request(matches, call.clone()), + TrustedOperation::get(getter) => get_state(matches, getter.clone()), } } -fn get_state(matches: &ArgMatches<'_>, getter: TrustedGetterSigned) -> Option> { +fn get_state(matches: &ArgMatches<'_>, getter: Getter) -> Option> { let worker_api = get_worker_api(matches); let (_mrenclave, shard) = get_identifiers(matches); - debug!("calling workerapi to get state value"); + debug!("calling workerapi to get state value, {:?}", getter); let ret = worker_api .get_stf_state(getter, &shard) .expect("getting value failed"); diff --git a/enclave/chain_relay/Cargo.toml b/enclave/chain_relay/Cargo.toml index 33b3a5edb3..10ba37ad85 100644 --- a/enclave/chain_relay/Cargo.toml +++ b/enclave/chain_relay/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "chain-relay" -version = "0.6.5-sub2.0.0-alpha.7" +version = "0.6.7-sub2.0.0-alpha.7" authors = ["Supercomputing Systems AG "] edition = "2018" diff --git a/enclave/src/lib.rs b/enclave/src/lib.rs index fec01819b5..462f0cbdbb 100644 --- a/enclave/src/lib.rs +++ b/enclave/src/lib.rs @@ -38,7 +38,7 @@ use sgx_types::{sgx_epid_group_id_t, sgx_status_t, sgx_target_info_t, size_t, Sg use substrate_api_client::{compose_extrinsic_offline, utils::storage_key}; use substratee_node_primitives::{CallWorkerFn, ShieldFundsFn}; use substratee_stf::{ - AccountId, ShardIdentifier, Stf, TrustedCall, TrustedCallSigned, TrustedGetterSigned, + ShardIdentifier, Stf, TrustedCallSigned, Getter, }; use codec::{Decode, Encode}; @@ -210,12 +210,14 @@ pub unsafe extern "C" fn get_state( let shard = ShardIdentifier::from_slice(slice::from_raw_parts(shard, shard_size as usize)); let mut trusted_op_slice = slice::from_raw_parts(trusted_op, trusted_op_size as usize); let value_slice = slice::from_raw_parts_mut(value, value_size as usize); - let tusted_getter_signed = TrustedGetterSigned::decode(&mut trusted_op_slice).unwrap(); - - debug!("verifying signature of TrustedCallSigned"); - if let false = tusted_getter_signed.verify_signature() { - error!("bad signature"); - return sgx_status_t::SGX_ERROR_UNEXPECTED; + let getter = Getter::decode(&mut trusted_op_slice).unwrap(); + + if let Getter::trusted(trusted_getter_signed) = getter.clone() { + debug!("verifying signature of TrustedGetterSigned"); + if let false = trusted_getter_signed.verify_signature() { + error!("bad signature"); + return sgx_status_t::SGX_ERROR_UNEXPECTED; + } } let mut state = match state::load(&shard) { @@ -230,9 +232,11 @@ pub unsafe extern "C" fn get_state( let latest_header = validator.latest_header(validator.num_relays).unwrap(); + // FIXME: not sure we will ever need this as we are querying trusted state, not onchain state + // i.e. demurrage could be correctly applied with this, but the client could do that too. debug!("Update STF storage!"); let requests: Vec = - Stf::get_storage_hashes_to_update_for_getter(&tusted_getter_signed) + Stf::get_storage_hashes_to_update_for_getter(&getter) .into_iter() .map(|key| WorkerRequest::ChainStorage(key, Some(latest_header.hash()))) .collect(); @@ -252,7 +256,7 @@ pub unsafe extern "C" fn get_state( } debug!("calling into STF to get state"); - let value_opt = Stf::get_state(&mut state, tusted_getter_signed.getter); + let value_opt = Stf::get_state(&mut state, getter); debug!("returning getter result"); write_slice_and_whitespace_pad(value_slice, value_opt.encode()); @@ -349,7 +353,7 @@ pub unsafe extern "C" fn sync_chain_relay( } if update_states(signed_block.block.header.clone()).is_err() { - error!("Error performing state updates upon block import") + error!("Error performing state updates upon block import"); return sgx_status_t::SGX_ERROR_UNEXPECTED; } diff --git a/stf/Cargo.toml b/stf/Cargo.toml index 9c64711c29..553a0f58f9 100644 --- a/stf/Cargo.toml +++ b/stf/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "substratee-stf" -version = "0.6.5-sub2.0.0-alpha.7" +version = "0.6.7-sub2.0.0-alpha.7" authors = ["Supercomputing Systems AG "] edition = "2018" diff --git a/stf/src/cli.rs b/stf/src/cli.rs index 90358fbea0..60843dbad6 100644 --- a/stf/src/cli.rs +++ b/stf/src/cli.rs @@ -15,7 +15,7 @@ */ -use crate::{AccountId, ShardIdentifier, TrustedCall, TrustedGetter, TrustedOperationSigned}; +use crate::{AccountId, ShardIdentifier, TrustedCall, TrustedGetter, PublicGetter, TrustedOperation, Attestation}; use base58::{FromBase58, ToBase58}; use clap::{Arg, ArgMatches}; use clap_nested::{Command, Commander, MultiCommand}; @@ -30,7 +30,7 @@ use std::path::PathBuf; const KEYSTORE_PATH: &str = "my_trusted_keystore"; pub fn cmd<'a>( - perform_operation: &'a dyn Fn(&ArgMatches<'_>, &TrustedOperationSigned) -> Option>, + perform_operation: &'a dyn Fn(&ArgMatches<'_>, &TrustedOperation) -> Option>, ) -> MultiCommand<'a, str, str> { Commander::new() .options(|app| { @@ -138,23 +138,22 @@ pub fn cmd<'a>( info!("from ss58 is {}", from.public().to_ss58check()); info!("to ss58 is {}", to.to_ss58check()); - let (mrenclave, shard) = get_identifiers(matches); - - let tcall = TrustedCall::balance_transfer( - sr25519_core::Public::from(from.public()), - to, - amount, - ); - let nonce = 0; // FIXME: hard coded for now - let tscall = - tcall.sign(&sr25519_core::Pair::from(from), nonce, &mrenclave, &shard); println!( "send trusted call transfer from {} to {}: {}", - tscall.call.account(), + from.public(), to, amount ); - let _ = perform_operation(matches, &TrustedOperationSigned::call(tscall)); + let (mrenclave, shard) = get_identifiers(matches); + let nonce = 0; // FIXME: hard coded for now + let top: TrustedOperation = TrustedCall::balance_transfer( + sr25519_core::Public::from(from.public()), + to, + shard, // for encointer we assume that every currency has its own shard. so shard == cid + BalanceType::from_num(amount)) + .sign(&sr25519_core::Pair::from(from), nonce, &mrenclave, &shard) + .into(); + let _ = perform_operation(matches, &top); Ok(()) }), ) @@ -169,8 +168,58 @@ pub fn cmd<'a>( .value_name("SS58") .help("sender's AccountId in ss58check format"), ) - .arg( - Arg::with_name("amount") + }) + .runner(move |_args: &str, matches: &ArgMatches<'_>| { + let arg_who = matches.value_of("accountid").unwrap(); + println!("arg_who = {:?}", arg_who); + let who = get_pair_from_str(matches, arg_who); + let (_mrenclave, shard) = get_identifiers(matches); + let top: TrustedOperation = TrustedGetter::balance(sr25519_core::Public::from(who.public()), shard) + .sign(&sr25519_core::Pair::from(who)) + .into(); + let res = perform_operation(matches, &top); + let bal = if let Some(v) = res { + if let Ok(vd) = ::decode(&mut v.as_slice()) { + vd + } else { + info!("could not decode value. maybe hasn't been set? {:x?}", v); + BalanceType::from_num(0) + } + } else { + BalanceType::from_num(0) + }; + println!("{}", bal); + Ok(()) + }), + ) + .add_cmd( + Command::new("total-issuance") + .description("query total issuance for currency (public information)") + .runner(move |_args: &str, matches: &ArgMatches<'_>| { + let (_mrenclave, shard) = get_identifiers(matches); + let top: TrustedOperation = PublicGetter::total_issuance(shard) + .into(); + let res = perform_operation(matches, &top); + let bal = if let Some(v) = res { + if let Ok(vd) = ::decode(&mut v.as_slice()) { + vd + } else { + info!("could not decode value. maybe hasn't been set? {:x?}", v); + BalanceType::from_num(0) + } + } else { + BalanceType::from_num(0) + }; + println!("{}", bal); + Ok(()) + }), + ) + .add_cmd( + Command::new("register-participant") + .description("register participant for next encointer ceremony") + .options(|app| { + app.arg( + Arg::with_name("accountid") .takes_value(true) .required(true) .value_name("U128") @@ -186,22 +235,18 @@ pub fn cmd<'a>( info!("account ss58 is {}", who.public().to_ss58check()); let (mrenclave, shard) = get_identifiers(matches); - - let tcall = TrustedCall::balance_set_balance( - sr25519_core::Public::from(signer.public()), - sr25519_core::Public::from(who.public()), - amount, - amount, - ); let nonce = 0; // FIXME: hard coded for now - let tscall = - tcall.sign(&sr25519_core::Pair::from(signer), nonce, &mrenclave, &shard); println!( - "send trusted call set-balance({}, {})", - tscall.call.account(), - amount + "send TrustedCall::register_participant for {}", + who.public(), ); - let _ = perform_operation(matches, &TrustedOperationSigned::call(tscall)); + let top: TrustedOperation = TrustedCall::ceremonies_register_participant( + sr25519_core::Public::from(who.public()), + shard, // for encointer we assume that every currency has its own shard. so shard == cid + None) + .sign(&sr25519_core::Pair::from(who), nonce, &mrenclave, &shard) + .into(); + perform_operation(matches, &top); Ok(()) }), ) @@ -221,21 +266,20 @@ pub fn cmd<'a>( let arg_who = matches.value_of("accountid").unwrap(); println!("arg_who = {:?}", arg_who); let who = get_pair_from_str(matches, arg_who); - let tgetter = - TrustedGetter::free_balance(sr25519_core::Public::from(who.public())); - let tsgetter = tgetter.sign(&sr25519_core::Pair::from(who)); - let res = perform_operation(matches, &TrustedOperationSigned::get(tsgetter)); - let bal = if let Some(v) = res { - if let Ok(vd) = crate::Balance::decode(&mut v.as_slice()) { - vd - } else { - info!("could not decode value. maybe hasn't been set? {:x?}", v); - 0 - } - } else { - 0 - }; - println!("{}", bal); + let (_mrenclave, shard) = get_identifiers(matches); + println!( + "send TrustedGetter::get_registration for {}", + who.public() + ); + let top: TrustedOperation = TrustedGetter::registration( + sr25519_core::Public::from(who.public()), + shard, // for encointer we assume that every currency has its own shard. so shard == cid + ) + .sign(&sr25519_core::Pair::from(who)) + .into(); + let part = perform_operation(matches, &top).unwrap(); + let participant: ParticipantIndexType = Decode::decode(&mut part.as_slice()).unwrap(); + println!("Participant index: {:?}", participant); Ok(()) }), ) @@ -250,15 +294,76 @@ pub fn cmd<'a>( .value_name("SS58") .help("Sender's incognito AccountId in ss58check format"), ) - .arg( - Arg::with_name("to") + .arg( + Arg::with_name("attestations") + .takes_value(true) + .required(true) + .multiple(true) + .min_values(2) + ) + }) + .runner(move |_args: &str, matches: &ArgMatches<'_>| { + let arg_who = matches.value_of("accountid").unwrap(); + let who = get_pair_from_str(matches, arg_who); + let (mrenclave, shard) = get_identifiers(matches); + let nonce = 0; // FIXME: hard coded for now + let attestation_args: Vec<_> = matches.values_of("attestations").unwrap().collect(); + let mut attestations: Vec> = vec![]; + for arg in attestation_args.iter() { + let w = Attestation::decode(&mut &hex::decode(arg).unwrap()[..]).unwrap(); + attestations.push(w); + } + println!( + "send TrustedCall::register_attestations for {}", + who.public() + ); + let top: TrustedOperation = TrustedCall::ceremonies_register_attestations( + sr25519_core::Public::from(who.public()), + attestations + ) + .sign(&sr25519_core::Pair::from(who), nonce, &mrenclave, &shard) + .into(); + perform_operation(matches, &top); + Ok(()) + }), + ) + .add_cmd( + Command::new("get-attestations") + .description("get attestations registration index for this encointer ceremony") + .options(|app| { + app.arg( + Arg::with_name("accountid") .takes_value(true) .required(true) .value_name("SS58") .help("Recipient's on-chain AccountId in ss58check format"), ) - .arg( - Arg::with_name("amount") + }) + .runner(move |_args: &str, matches: &ArgMatches<'_>| { + let arg_who = matches.value_of("accountid").unwrap(); + let who = get_pair_from_str(matches, arg_who); + let (_mrenclave, shard) = get_identifiers(matches); + println!( + "send TrustedGetter::get_attestations for {}", + who.public(), + ); + let top: TrustedOperation = TrustedGetter::attestations( + sr25519_core::Public::from(who.public()), + shard, // for encointer we assume that every currency has its own shard. so shard == cid + ) + .sign(&sr25519_core::Pair::from(who)) + .into(); + let attestations = perform_operation(matches, &top).unwrap(); + println!("Attestations: {:?}", hex::encode(attestations)); + Ok(()) + }), + ) + .add_cmd( + Command::new("new-claim") + .description("read current ceremony phase from chain") + .options(|app| { + app.arg( + Arg::with_name("accountid") .takes_value(true) .required(true) .value_name("U128") @@ -273,23 +378,29 @@ pub fn cmd<'a>( ) }) .runner(move |_args: &str, matches: &ArgMatches<'_>| { - let arg_from = matches.value_of("from").unwrap(); - let arg_to = matches.value_of("to").unwrap(); - let amount = u128::from_str_radix(matches.value_of("amount").unwrap(), 10) - .expect("amount can be converted to u128"); - let from = get_pair_from_str(matches, arg_from); - let to = get_accountid_from_str(arg_to); - println!("from ss58 is {}", from.public().to_ss58check()); - println!("to ss58 is {}", to.to_ss58check()); + let arg_who = matches.value_of("accountid").unwrap(); + // println!("arg_who = {:?}", arg_who); + let who = get_pair_from_str(matches, arg_who); - let (mrenclave, shard) = get_identifiers(matches); + let n_participants = matches + .value_of("n-participants") + .unwrap() + .parse::() + .unwrap(); - println!( - "send trusted call unshield_funds from {} to {}: {}", - from.public(), - to, - amount - ); + let (_mrenclave, shard) = get_identifiers(matches); + let top: TrustedOperation = TrustedGetter::meetup_index_time_and_location(who.public().into(), shard) + .sign(&sr25519_core::Pair::from(who.clone())) + .into(); + + let res = perform_operation(matches, &top).unwrap(); + let (mindex, mlocation, mtime): (MeetupIndexType, Option, Option) = Decode::decode(&mut res.as_slice()).unwrap(); + info!("got mindex: {:?}", mindex); + info!("got time: {:?}", mtime); + info!("got location: {:?}", mlocation); + let api = get_chain_api(matches); + let cindex = api.get_storage_value("EncointerScheduler", "CurrentCeremonyIndex", None) + .unwrap(); let tcall = TrustedCall::balance_unshield( sr25519_core::Public::from(from.public()), diff --git a/stf/src/lib.rs b/stf/src/lib.rs index 639a8b6485..38f89720d2 100644 --- a/stf/src/lib.rs +++ b/stf/src/lib.rs @@ -58,9 +58,60 @@ pub type State = sp_io::SgxExternalities; #[derive(Encode, Decode, Clone)] #[allow(non_camel_case_types)] -pub enum TrustedOperationSigned { +pub enum TrustedOperation { call(TrustedCallSigned), - get(TrustedGetterSigned), + get(Getter), +} + +impl From for TrustedOperation { + fn from(item: TrustedCallSigned) -> Self { + TrustedOperation::call(item) + } +} + +impl From for TrustedOperation { + fn from(item: Getter) -> Self { + TrustedOperation::get(item) + } +} + +impl From for TrustedOperation { + fn from(item: TrustedGetterSigned) -> Self { + TrustedOperation::get(item.into()) + } +} + +impl From for TrustedOperation { + fn from(item: PublicGetter) -> Self { + TrustedOperation::get(item.into()) + } +} + + + +#[derive(Encode, Decode, Clone, Debug)] +#[allow(non_camel_case_types)] +pub enum Getter { + public(PublicGetter), + trusted(TrustedGetterSigned) +} + +impl From for Getter { + fn from(item: PublicGetter) -> Self { + Getter::public(item) + } +} + +impl From for Getter { + fn from(item: TrustedGetterSigned) -> Self { + Getter::trusted(item) + } +} + +#[derive(Encode, Decode, Clone, Debug)] +#[allow(non_camel_case_types)] +pub enum PublicGetter { + total_issuance(CurrencyIdentifier), } #[derive(Encode, Decode, Clone)] diff --git a/stf/src/sgx.rs b/stf/src/sgx.rs index 7c68a4519c..21492744fc 100644 --- a/stf/src/sgx.rs +++ b/stf/src/sgx.rs @@ -12,7 +12,7 @@ use sp_io::SgxExternalitiesTrait; use sp_runtime::traits::Dispatchable; use crate::{ - AccountId, State, Stf, TrustedCall, TrustedCallSigned, TrustedGetter, TrustedGetterSigned, + AccountId, State, Stf, TrustedCall, TrustedCallSigned, Getter, PublicGetter, TrustedGetter, TrustedGetterSigned, ShardIdentifier, SUBSRATEE_REGISTRY_MODULE, UNSHIELD, }; use sp_core::blake2_256; @@ -140,7 +140,7 @@ impl Stf { None } } - }) + ) } fn ensure_root(account: AccountId) -> Result<(), StfError> { @@ -204,10 +204,9 @@ impl Stf { key_hashes } - pub fn get_storage_hashes_to_update_for_getter(getter: &TrustedGetterSigned) -> Vec> { - let key_hashes = Vec::new(); - info!("No storage updates needed for getter: {:?}", getter.getter); // dummy. Is currently not needed - key_hashes + pub fn get_storage_hashes_to_update_for_getter(getter: &Getter) -> Vec> { + info!("No specific storage updates needed for getter. Returning those for on block: {:?}", getter); + Self::storage_hashes_to_update_on_block() } pub fn storage_hashes_to_update_on_block() -> Vec> { diff --git a/substratee-node-primitives/Cargo.toml b/substratee-node-primitives/Cargo.toml index 046f5601cb..d0cf9f722c 100644 --- a/substratee-node-primitives/Cargo.toml +++ b/substratee-node-primitives/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "substratee-node-primitives" -version = "0.6.5-sub2.0.0-alpha.7" +version = "0.6.7-sub2.0.0-alpha.7" authors = ["clangenbacher "] edition = "2018" diff --git a/worker/src/ws_server.rs b/worker/src/ws_server.rs index fdc5fb7662..24354221e7 100644 --- a/worker/src/ws_server.rs +++ b/worker/src/ws_server.rs @@ -23,7 +23,7 @@ use sgx_types::*; use codec::{Decode, Encode}; use log::*; use std::sync::mpsc::Sender as MpscSender; -use substratee_stf::{ShardIdentifier, TrustedGetter, TrustedGetterSigned}; +use substratee_stf::{ShardIdentifier, Getter}; use substratee_worker_api::requests::*; use ws::{listen, CloseCode, Handler, Message, Result, Sender}; @@ -98,7 +98,7 @@ pub fn handle_request( fn get_stf_state( eid: sgx_enclave_id_t, - getter: TrustedGetterSigned, + getter: Getter, shard: ShardIdentifier, ) -> Message { info!(" [WS Server] Query state"); diff --git a/worker/worker-api/Cargo.toml b/worker/worker-api/Cargo.toml index 48195f0041..cd964c460f 100644 --- a/worker/worker-api/Cargo.toml +++ b/worker/worker-api/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "substratee-worker-api" -version = "0.6.5-sub2.0.0-alpha.7" +version = "0.6.7-sub2.0.0-alpha.7" authors = ["Supercomputing Systems AG "] edition = "2018" diff --git a/worker/worker-api/src/lib.rs b/worker/worker-api/src/lib.rs index acfb9db98e..1d549f9824 100644 --- a/worker/worker-api/src/lib.rs +++ b/worker/worker-api/src/lib.rs @@ -26,7 +26,7 @@ use ws::connect; use client::WsClient; use requests::*; -use substratee_stf::{ShardIdentifier, TrustedGetterSigned}; +use substratee_stf::{ShardIdentifier, Getter}; pub mod client; pub mod requests; @@ -56,7 +56,7 @@ impl Api { pub fn get_stf_state( &self, - getter: TrustedGetterSigned, + getter: Getter, shard: &ShardIdentifier, ) -> Result, ()> { let req = ClientRequest::StfState(getter, shard.to_owned()); diff --git a/worker/worker-api/src/requests.rs b/worker/worker-api/src/requests.rs index 8dbbfd1149..f49caccb9e 100644 --- a/worker/worker-api/src/requests.rs +++ b/worker/worker-api/src/requests.rs @@ -16,11 +16,11 @@ */ use codec::{Encode, Decode}; -use substratee_stf::{TrustedGetterSigned, ShardIdentifier}; +use substratee_stf::{Getter, ShardIdentifier}; #[derive(Encode, Decode, Clone, Debug)] pub enum ClientRequest { PubKeyWorker, MuRaPortWorker, - StfState(TrustedGetterSigned, ShardIdentifier), // (trusted_getter_encrypted, shard) + StfState(Getter, ShardIdentifier), // (trusted_getter_encrypted, shard) } \ No newline at end of file From c2af7380a9ca91e5af578eb5ce5d78dbb18092d1 Mon Sep 17 00:00:00 2001 From: brenzi Date: Wed, 24 Jun 2020 14:26:09 +0200 Subject: [PATCH 16/29] update Block number in state and apply demurrage in client (#17) * updating block number in stf state * fix #9. apply demurrage in client * bump version to 0.6.8 --- Cargo.lock | 171 ++++++++------------------ client/bootstrap_demo_currency.sh | 6 +- enclave/chain_relay/Cargo.toml | 2 +- enclave/src/lib.rs | 42 +++++-- stf/Cargo.toml | 14 ++- stf/src/cli.rs | 68 ++++------ stf/src/sgx.rs | 8 ++ substratee-node-primitives/Cargo.toml | 2 +- worker/Cargo.toml | 5 + worker/worker-api/Cargo.toml | 2 +- 10 files changed, 142 insertions(+), 178 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6841262296..a094cb1bdb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -563,7 +563,7 @@ checksum = "bb1f6b1ce1c140482ea30ddd3335fc0024ac7ee112895426e0a629a6c20adfe3" [[package]] name = "encointer-client-teeproxy" -version = "0.6.7-sub2.0.0-alpha.7" +version = "0.6.8-sub2.0.0-alpha.7" dependencies = [ "base58", "blake2-rfc", @@ -578,10 +578,10 @@ dependencies = [ "json", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "pallet-balances", - "pallet-encointer-balances 0.3.0 (git+https://github.com/encointer/pallets?tag=v0.3.1)", - "pallet-encointer-ceremonies 0.3.0 (git+https://github.com/encointer/pallets?tag=v0.3.1)", - "pallet-encointer-currencies 0.3.0 (git+https://github.com/encointer/pallets?tag=v0.3.1)", - "pallet-encointer-scheduler 0.3.1", + "pallet-encointer-balances", + "pallet-encointer-ceremonies", + "pallet-encointer-currencies", + "pallet-encointer-scheduler", "parity-scale-codec", "primitive-types 0.6.2", "sc-keystore", @@ -600,8 +600,8 @@ dependencies = [ [[package]] name = "encointer-node-teeproxy-runtime" -version = "0.3.2" -source = "git+https://github.com/encointer/encointer-node?branch=sgx-master#59ef144fa0b5d44c9c0ef003086facd848ad9b17" +version = "0.3.3" +source = "git+https://github.com/encointer/encointer-node?branch=sgx-master#156b90a0fc5e8b8af46ea48dc3b9c611688b94ab" dependencies = [ "frame-executive", "frame-support", @@ -609,10 +609,10 @@ dependencies = [ "frame-system-rpc-runtime-api", "pallet-aura", "pallet-balances", - "pallet-encointer-balances 0.3.0 (git+https://github.com/encointer/pallets?tag=v0.3.1)", - "pallet-encointer-ceremonies 0.3.0 (git+https://github.com/encointer/pallets?tag=v0.3.1)", - "pallet-encointer-currencies 0.3.0 (git+https://github.com/encointer/pallets?tag=v0.3.1)", - "pallet-encointer-scheduler 0.3.1", + "pallet-encointer-balances", + "pallet-encointer-ceremonies", + "pallet-encointer-currencies", + "pallet-encointer-scheduler", "pallet-grandpa", "pallet-randomness-collective-flip", "pallet-substratee-registry", @@ -640,7 +640,7 @@ dependencies = [ [[package]] name = "encointer-worker" -version = "0.6.7-sub2.0.0-alpha.7" +version = "0.6.8-sub2.0.0-alpha.7" dependencies = [ "base58", "cid", @@ -1159,7 +1159,7 @@ dependencies = [ [[package]] name = "hashbrown_tstd" version = "0.7.1" -source = "git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2#253b3ac982b2d09d32f5fa5a2011e3c36bcbed1e" +source = "git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2#fdc2ea93caecaa7f69a3edc9cf840607d0628ff3" dependencies = [ "autocfg 1.0.0", ] @@ -2037,33 +2037,14 @@ dependencies = [ [[package]] name = "pallet-encointer-balances" -version = "0.3.0" -source = "git+https://github.com/encointer/pallets?tag=v0.3.0#f60169a908675bb90ae54cfa8b9000fc08ca45e7" -dependencies = [ - "frame-support", - "frame-system", - "impl-trait-for-tuples", - "num-traits", - "pallet-encointer-currencies 0.3.0 (git+https://github.com/encointer/pallets?tag=v0.3.0)", - "parity-scale-codec", - "safe-mix", - "serde", - "sp-io 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", - "sp-runtime", - "sp-std", - "substrate-fixed", -] - -[[package]] -name = "pallet-encointer-balances" -version = "0.3.0" -source = "git+https://github.com/encointer/pallets?tag=v0.3.1#21f1fba74f66052564764d93c119a712d27d0aa3" +version = "0.3.2" +source = "git+https://github.com/encointer/pallets?tag=v0.3.2#9765159a7fa55dd69f1bc164d0b8d560d0413f0d" dependencies = [ "frame-support", "frame-system", "impl-trait-for-tuples", "num-traits", - "pallet-encointer-currencies 0.3.0 (git+https://github.com/encointer/pallets?tag=v0.3.1)", + "pallet-encointer-currencies", "parity-scale-codec", "safe-mix", "serde", @@ -2076,34 +2057,14 @@ dependencies = [ [[package]] name = "pallet-encointer-ceremonies" version = "0.3.0" -source = "git+https://github.com/encointer/pallets?tag=v0.3.0#f60169a908675bb90ae54cfa8b9000fc08ca45e7" -dependencies = [ - "frame-support", - "frame-system", - "pallet-balances", - "pallet-encointer-balances 0.3.0 (git+https://github.com/encointer/pallets?tag=v0.3.0)", - "pallet-encointer-currencies 0.3.0 (git+https://github.com/encointer/pallets?tag=v0.3.0)", - "pallet-encointer-scheduler 0.3.0", - "pallet-timestamp", - "parity-scale-codec", - "serde", - "sp-core", - "sp-io 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", - "sp-runtime", - "sp-std", -] - -[[package]] -name = "pallet-encointer-ceremonies" -version = "0.3.0" -source = "git+https://github.com/encointer/pallets?tag=v0.3.1#21f1fba74f66052564764d93c119a712d27d0aa3" +source = "git+https://github.com/encointer/pallets?tag=v0.3.2#9765159a7fa55dd69f1bc164d0b8d560d0413f0d" dependencies = [ "frame-support", "frame-system", "pallet-balances", - "pallet-encointer-balances 0.3.0 (git+https://github.com/encointer/pallets?tag=v0.3.1)", - "pallet-encointer-currencies 0.3.0 (git+https://github.com/encointer/pallets?tag=v0.3.1)", - "pallet-encointer-scheduler 0.3.1", + "pallet-encointer-balances", + "pallet-encointer-currencies", + "pallet-encointer-scheduler", "pallet-timestamp", "parity-scale-codec", "serde", @@ -2116,24 +2077,7 @@ dependencies = [ [[package]] name = "pallet-encointer-currencies" version = "0.3.0" -source = "git+https://github.com/encointer/pallets?tag=v0.3.0#f60169a908675bb90ae54cfa8b9000fc08ca45e7" -dependencies = [ - "frame-support", - "frame-system", - "pallet-balances", - "parity-scale-codec", - "serde", - "sp-core", - "sp-io 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", - "sp-runtime", - "sp-std", - "substrate-fixed", -] - -[[package]] -name = "pallet-encointer-currencies" -version = "0.3.0" -source = "git+https://github.com/encointer/pallets?tag=v0.3.1#21f1fba74f66052564764d93c119a712d27d0aa3" +source = "git+https://github.com/encointer/pallets?tag=v0.3.2#9765159a7fa55dd69f1bc164d0b8d560d0413f0d" dependencies = [ "frame-support", "frame-system", @@ -2147,27 +2091,10 @@ dependencies = [ "substrate-fixed", ] -[[package]] -name = "pallet-encointer-scheduler" -version = "0.3.0" -source = "git+https://github.com/encointer/pallets?tag=v0.3.0#f60169a908675bb90ae54cfa8b9000fc08ca45e7" -dependencies = [ - "frame-support", - "frame-system", - "pallet-timestamp", - "parity-scale-codec", - "serde", - "sp-core", - "sp-io 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", - "sp-runtime", - "sp-std", - "sp-timestamp", -] - [[package]] name = "pallet-encointer-scheduler" version = "0.3.1" -source = "git+https://github.com/encointer/pallets?tag=v0.3.1#21f1fba74f66052564764d93c119a712d27d0aa3" +source = "git+https://github.com/encointer/pallets?tag=v0.3.2#9765159a7fa55dd69f1bc164d0b8d560d0413f0d" dependencies = [ "frame-support", "frame-system", @@ -2284,7 +2211,7 @@ dependencies = [ [[package]] name = "pallet-template" version = "2.0.0-alpha.7" -source = "git+https://github.com/encointer/sgx-runtime#e206ce2f185fb22c513c0e52f591576418a817d6" +source = "git+https://github.com/encointer/sgx-runtime#d28c480652130b65084b1bd0e0204f87026f1c24" dependencies = [ "frame-support", "frame-system", @@ -3234,7 +3161,7 @@ dependencies = [ [[package]] name = "sgx-externalities" version = "0.2.0" -source = "git+https://github.com/encointer/sgx-runtime#e206ce2f185fb22c513c0e52f591576418a817d6" +source = "git+https://github.com/encointer/sgx-runtime#d28c480652130b65084b1bd0e0204f87026f1c24" dependencies = [ "environmental", "log 0.4.8 (git+https://github.com/mesalock-linux/log-sgx)", @@ -3246,17 +3173,17 @@ dependencies = [ [[package]] name = "sgx-runtime" version = "2.0.0-alpha.7" -source = "git+https://github.com/encointer/sgx-runtime#e206ce2f185fb22c513c0e52f591576418a817d6" +source = "git+https://github.com/encointer/sgx-runtime#d28c480652130b65084b1bd0e0204f87026f1c24" dependencies = [ "frame-executive", "frame-support", "frame-system", "pallet-aura", "pallet-balances", - "pallet-encointer-balances 0.3.0 (git+https://github.com/encointer/pallets?tag=v0.3.0)", - "pallet-encointer-ceremonies 0.3.0 (git+https://github.com/encointer/pallets?tag=v0.3.0)", - "pallet-encointer-currencies 0.3.0 (git+https://github.com/encointer/pallets?tag=v0.3.0)", - "pallet-encointer-scheduler 0.3.0", + "pallet-encointer-balances", + "pallet-encointer-ceremonies", + "pallet-encointer-currencies", + "pallet-encointer-scheduler", "pallet-grandpa", "pallet-randomness-collective-flip", "pallet-sudo", @@ -3283,12 +3210,12 @@ dependencies = [ [[package]] name = "sgx_alloc" version = "1.1.2" -source = "git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2#253b3ac982b2d09d32f5fa5a2011e3c36bcbed1e" +source = "git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2#fdc2ea93caecaa7f69a3edc9cf840607d0628ff3" [[package]] name = "sgx_backtrace_sys" version = "1.1.2" -source = "git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2#253b3ac982b2d09d32f5fa5a2011e3c36bcbed1e" +source = "git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2#fdc2ea93caecaa7f69a3edc9cf840607d0628ff3" dependencies = [ "cc", "sgx_build_helper", @@ -3298,7 +3225,7 @@ dependencies = [ [[package]] name = "sgx_build_helper" version = "0.1.3" -source = "git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2#253b3ac982b2d09d32f5fa5a2011e3c36bcbed1e" +source = "git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2#fdc2ea93caecaa7f69a3edc9cf840607d0628ff3" [[package]] name = "sgx_crypto_helper" @@ -3317,12 +3244,12 @@ dependencies = [ [[package]] name = "sgx_demangle" version = "1.1.2" -source = "git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2#253b3ac982b2d09d32f5fa5a2011e3c36bcbed1e" +source = "git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2#fdc2ea93caecaa7f69a3edc9cf840607d0628ff3" [[package]] name = "sgx_libc" version = "1.1.2" -source = "git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2#253b3ac982b2d09d32f5fa5a2011e3c36bcbed1e" +source = "git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2#fdc2ea93caecaa7f69a3edc9cf840607d0628ff3" dependencies = [ "sgx_types", ] @@ -3330,7 +3257,7 @@ dependencies = [ [[package]] name = "sgx_serialize" version = "1.1.2" -source = "git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2#253b3ac982b2d09d32f5fa5a2011e3c36bcbed1e" +source = "git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2#fdc2ea93caecaa7f69a3edc9cf840607d0628ff3" dependencies = [ "sgx_tstd", ] @@ -3338,7 +3265,7 @@ dependencies = [ [[package]] name = "sgx_tprotected_fs" version = "1.1.2" -source = "git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2#253b3ac982b2d09d32f5fa5a2011e3c36bcbed1e" +source = "git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2#fdc2ea93caecaa7f69a3edc9cf840607d0628ff3" dependencies = [ "sgx_trts", "sgx_types", @@ -3347,7 +3274,7 @@ dependencies = [ [[package]] name = "sgx_trts" version = "1.1.2" -source = "git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2#253b3ac982b2d09d32f5fa5a2011e3c36bcbed1e" +source = "git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2#fdc2ea93caecaa7f69a3edc9cf840607d0628ff3" dependencies = [ "sgx_libc", "sgx_types", @@ -3356,7 +3283,7 @@ dependencies = [ [[package]] name = "sgx_tstd" version = "1.1.2" -source = "git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2#253b3ac982b2d09d32f5fa5a2011e3c36bcbed1e" +source = "git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2#fdc2ea93caecaa7f69a3edc9cf840607d0628ff3" dependencies = [ "hashbrown_tstd", "sgx_alloc", @@ -3372,7 +3299,7 @@ dependencies = [ [[package]] name = "sgx_types" version = "1.1.2" -source = "git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2#253b3ac982b2d09d32f5fa5a2011e3c36bcbed1e" +source = "git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2#fdc2ea93caecaa7f69a3edc9cf840607d0628ff3" [[package]] name = "sgx_ucrypto" @@ -3388,7 +3315,7 @@ dependencies = [ [[package]] name = "sgx_unwind" version = "0.1.1" -source = "git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2#253b3ac982b2d09d32f5fa5a2011e3c36bcbed1e" +source = "git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2#fdc2ea93caecaa7f69a3edc9cf840607d0628ff3" dependencies = [ "sgx_build_helper", ] @@ -3660,7 +3587,7 @@ dependencies = [ [[package]] name = "sp-io" version = "2.0.0-alpha.7" -source = "git+https://github.com/encointer/sgx-runtime#e206ce2f185fb22c513c0e52f591576418a817d6" +source = "git+https://github.com/encointer/sgx-runtime#d28c480652130b65084b1bd0e0204f87026f1c24" dependencies = [ "environmental", "hash-db", @@ -4069,7 +3996,7 @@ checksum = "d2a965994514ab35d3893e9260245f2947fd1981cdd4fffd2c6e6d1a9ce02e6a" [[package]] name = "substratee-node-primitives" -version = "0.6.7-sub2.0.0-alpha.7" +version = "0.6.8-sub2.0.0-alpha.7" dependencies = [ "base58", "encointer-node-teeproxy-runtime", @@ -4084,22 +4011,23 @@ dependencies = [ [[package]] name = "substratee-stf" -version = "0.6.7-sub2.0.0-alpha.7" +version = "0.6.8-sub2.0.0-alpha.7" dependencies = [ "base58", "clap", "clap-nested", "derive_more", + "encointer-node-teeproxy-runtime", "env_logger 0.7.1 (git+https://github.com/mesalock-linux/env_logger-sgx)", "frame-metadata", "frame-system", "hex 0.3.2", "log 0.4.8 (git+https://github.com/mesalock-linux/log-sgx)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "pallet-encointer-balances 0.3.0 (git+https://github.com/encointer/pallets?tag=v0.3.0)", - "pallet-encointer-ceremonies 0.3.0 (git+https://github.com/encointer/pallets?tag=v0.3.0)", - "pallet-encointer-currencies 0.3.0 (git+https://github.com/encointer/pallets?tag=v0.3.0)", - "pallet-encointer-scheduler 0.3.0", + "pallet-encointer-balances", + "pallet-encointer-ceremonies", + "pallet-encointer-currencies", + "pallet-encointer-scheduler", "parity-scale-codec", "sc-keystore", "sgx-runtime", @@ -4110,11 +4038,12 @@ dependencies = [ "sp-keyring", "sp-runtime", "substrate-api-client", + "substrate-fixed", ] [[package]] name = "substratee-worker-api" -version = "0.6.7-sub2.0.0-alpha.7" +version = "0.6.8-sub2.0.0-alpha.7" dependencies = [ "hex 0.4.2", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/client/bootstrap_demo_currency.sh b/client/bootstrap_demo_currency.sh index 42f129f1a7..3e5d31924e 100755 --- a/client/bootstrap_demo_currency.sh +++ b/client/bootstrap_demo_currency.sh @@ -49,9 +49,9 @@ $CLIENT list-currencies wait_for_phase REGISTERING -#read MRENCLAVE <<< $($CLIENT list-workers | awk '/ MRENCLAVE: / { print $2 }') +read MRENCLAVE <<< $($CLIENT list-workers | awk '/ MRENCLAVE: / { print $2 }') #cid=7eLSZLSMShw4ju9GvuMmoVgeZxZimtvsGTSvLEdvcRqQ -MRENCLAVE=6AkpQeSLGSwESvKMiygJzDTLHXvnwBG9c8Q8FV9LiDuN +#MRENCLAVE=6AkpQeSLGSwESvKMiygJzDTLHXvnwBG9c8Q8FV9LiDuN echo " MRENCLAVE = ${MRENCLAVE}" @@ -128,4 +128,4 @@ $CLIENT trusted balance $account1 --mrenclave $MRENCLAVE --shard $cid $CLIENT trusted balance $account2 --mrenclave $MRENCLAVE --shard $cid $CLIENT trusted balance $account3 --mrenclave $MRENCLAVE --shard $cid echo "total issuance (publicly readable)" -$CLIENT trusted total-issuance --mrenclave $MRENCLAVE --shard $cid \ No newline at end of file +$CLIENT trusted total-issuance --mrenclave $MRENCLAVE --shard $cid diff --git a/enclave/chain_relay/Cargo.toml b/enclave/chain_relay/Cargo.toml index 10ba37ad85..bbc38e4824 100644 --- a/enclave/chain_relay/Cargo.toml +++ b/enclave/chain_relay/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "chain-relay" -version = "0.6.7-sub2.0.0-alpha.7" +version = "0.6.8-sub2.0.0-alpha.7" authors = ["Supercomputing Systems AG "] edition = "2018" diff --git a/enclave/src/lib.rs b/enclave/src/lib.rs index 462f0cbdbb..fedb81932a 100644 --- a/enclave/src/lib.rs +++ b/enclave/src/lib.rs @@ -386,15 +386,39 @@ pub fn update_states(header: Header) -> SgxResult<()> { } let responses: Vec>> = worker_request(requests)?; - let update_map = verify_worker_responses(responses, header)?; - - let shards = state::list_shards()?; - debug!("found shards: {:?}", shards); - for s in shards { - let mut state = state::load(&s)?; - Stf::update_storage(&mut state, &update_map); - state::write(state, &s)?; - } + let update_map = verify_worker_responses(responses, header.clone())?; + // look for new shards an initialize them + if let Some(maybe_shards) = update_map.get(&shards_key_hash()) { + match maybe_shards { + Some(shards) => { + let shards: Vec = Decode::decode(&mut shards.as_slice()).sgx_error_with_log("error decoding shards")?; + for s in shards { + if !state::exists(&s) { + info!("Initialized new shard that was found on chain: {:?}", s); + state::init_shard(&s)?; + } + // per shard (cid) requests + let per_shard_request = storage_hashes_to_update_per_shard(&s) + .into_iter() + .map(|key| WorkerRequest::ChainStorage(key, Some(header.hash()))) + .collect(); + + let responses: Vec>> = worker_request(per_shard_request)?; + let per_shard_update_map = verify_worker_responses(responses, header.clone())?; + + let mut state = state::load(&s)?; + Stf::update_storage(&mut state, &per_shard_update_map); + Stf::update_storage(&mut state, &update_map); + + // block number is purged from the substrate state so it can't be read like other storage values + Stf::update_block_number(&mut state, header.number); + + state::write(state, &s)?; + } + } + None => info!("No shards are on the chain yet") + }; + }; Ok(()) } diff --git a/stf/Cargo.toml b/stf/Cargo.toml index 553a0f58f9..6b7ae1581f 100644 --- a/stf/Cargo.toml +++ b/stf/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "substratee-stf" -version = "0.6.7-sub2.0.0-alpha.7" +version = "0.6.8-sub2.0.0-alpha.7" authors = ["Supercomputing Systems AG "] edition = "2018" @@ -51,6 +51,18 @@ default-features = false package = 'pallet-balances' version = '2.0.0-alpha.7' +[dependencies.fixed] +default-features = false +git = "https://github.com/encointer/substrate-fixed" +tag = "v0.5.4+sub_v0.1" +package = "substrate-fixed" + +[dependencies.my-node-runtime] +git = "https://github.com/encointer/encointer-node" +branch = "sgx-master" +package = "encointer-node-teeproxy-runtime" +optional = true + [dependencies.system] default-features = false package = 'frame-system' diff --git a/stf/src/cli.rs b/stf/src/cli.rs index 60843dbad6..598a9368e9 100644 --- a/stf/src/cli.rs +++ b/stf/src/cli.rs @@ -179,8 +179,12 @@ pub fn cmd<'a>( .into(); let res = perform_operation(matches, &top); let bal = if let Some(v) = res { - if let Ok(vd) = ::decode(&mut v.as_slice()) { - vd + if let Ok(vd) = >::decode(&mut v.as_slice()) { + let api = get_chain_api(matches); + let bn = get_block_number(&api); + let dr = get_demurrage_per_block(&api, shard); + debug!("will apply demurrage to {:?}. blocknumber {}, demurrage rate {}", vd, bn, dr); + apply_demurrage(vd, bn, dr) } else { info!("could not decode value. maybe hasn't been set? {:x?}", v); BalanceType::from_num(0) @@ -201,8 +205,12 @@ pub fn cmd<'a>( .into(); let res = perform_operation(matches, &top); let bal = if let Some(v) = res { - if let Ok(vd) = ::decode(&mut v.as_slice()) { - vd + if let Ok(vd) = >::decode(&mut v.as_slice()) { + let api = get_chain_api(matches); + let bn = get_block_number(&api); + let dr = get_demurrage_per_block(&api, shard); + debug!("will apply demurrage to {:?}. blocknumber {}, demurrage rate {}", vd, bn, dr); + apply_demurrage(vd, bn, dr) } else { info!("could not decode value. maybe hasn't been set? {:x?}", v); BalanceType::from_num(0) @@ -502,43 +510,21 @@ pub fn call_trusted_stf( let xt = compose_extrinsic!(api.clone(), "SubstraTEERegistry", "call_worker", request); - // send and watch extrinsic until finalized - let tx_hash = api.send_extrinsic(xt.hex_encode()).unwrap(); - info!("stf call extrinsic got finalized. Hash: {:?}", tx_hash); - info!("waiting for confirmation of stf call"); - let act_hash = subscribe_to_call_confirmed(api.clone()); - info!("callConfirmed event received"); - debug!( - "Expected stf call Hash: {:?}", - blake2s(32, &[0; 32], &call_encrypted).as_bytes() - ); - debug!("confirmation stf call Hash: {:?}", act_hash); +fn get_demurrage_per_block(api: &Api, cid: CurrencyIdentifier) -> BalanceType { + let cp: CurrencyPropertiesType = api + .get_storage_map("EncointerCurrencies", "CurrencyProperties", cid, None) + .unwrap(); + debug!("CurrencyProperties are {:?}", cp); + cp.demurrage_per_block } -pub fn get_trusted_stf_state( - workerapi: &WorkerApi, - getter: TrustedGetterSigned, - shard: &ShardIdentifier, -) { - //TODO: #91 - // encrypt getter - // decrypt response and verify signature - debug!("calling workerapi to get value"); - let ret = workerapi - .get_stf_state(getter, shard) - .expect("getting value failed"); - let ret_cropped = &ret[..9 * 2]; - debug!( - "got getter response from worker: {:?}\ncropping to {:?}", - ret, ret_cropped - ); - let valopt: Option> = Decode::decode(&mut &ret_cropped[..]).unwrap(); - match valopt { - Some(v) => { - let value = U256::from_little_endian(&v); - println!(" value = {}", value); - } - _ => error!("error getting value"), - }; +fn apply_demurrage(entry: BalanceEntry, current_block: BlockNumber, demurrage_per_block: BalanceType) -> BalanceType { + let elapsed_time_block_number = current_block.checked_sub(entry.last_update).unwrap(); + let elapsed_time_u32: u32 = elapsed_time_block_number.into(); + let elapsed_time = BalanceType::from_num(elapsed_time_u32); + let exponent : BalanceType = -demurrage_per_block * elapsed_time; + debug!("demurrage per block {}, current_block {}, last {}, elapsed_blocks {}", demurrage_per_block, current_block, entry.last_update, elapsed_time); + let exp_result : BalanceType = exp(exponent).unwrap(); + entry.principal.checked_mul(exp_result).unwrap() } -*/ + diff --git a/stf/src/sgx.rs b/stf/src/sgx.rs index 21492744fc..b903caf4d0 100644 --- a/stf/src/sgx.rs +++ b/stf/src/sgx.rs @@ -77,6 +77,14 @@ impl Stf { }); } + pub fn update_block_number(ext: &mut State, number: BlockNumber) { + ext.execute_with(|| { + let key = storage_value_key("System", "Number"); + sp_io::storage::set(&key, &number.encode()); + }); + } + + pub fn execute( ext: &mut State, call: TrustedCallSigned, diff --git a/substratee-node-primitives/Cargo.toml b/substratee-node-primitives/Cargo.toml index d0cf9f722c..73ff439c31 100644 --- a/substratee-node-primitives/Cargo.toml +++ b/substratee-node-primitives/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "substratee-node-primitives" -version = "0.6.7-sub2.0.0-alpha.7" +version = "0.6.8-sub2.0.0-alpha.7" authors = ["clangenbacher "] edition = "2018" diff --git a/worker/Cargo.toml b/worker/Cargo.toml index 0247494bcf..df8c097462 100644 --- a/worker/Cargo.toml +++ b/worker/Cargo.toml @@ -1,6 +1,11 @@ [package] +<<<<<<< HEAD name = "substratee-worker" version = "0.6.5-sub2.0.0-alpha.7" +======= +name = "encointer-worker" +version = "0.6.8-sub2.0.0-alpha.7" +>>>>>>> a8772b6... update Block number in state and apply demurrage in client (#17) authors = ["Supercomputing Systems AG "] build = "build.rs" edition = "2018" diff --git a/worker/worker-api/Cargo.toml b/worker/worker-api/Cargo.toml index cd964c460f..f65cfe8c00 100644 --- a/worker/worker-api/Cargo.toml +++ b/worker/worker-api/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "substratee-worker-api" -version = "0.6.7-sub2.0.0-alpha.7" +version = "0.6.8-sub2.0.0-alpha.7" authors = ["Supercomputing Systems AG "] edition = "2018" From 8a0511522589e9b03afa027c02d4993703e120c0 Mon Sep 17 00:00:00 2001 From: Christian Langenbacher Date: Thu, 20 Aug 2020 17:15:52 +0200 Subject: [PATCH 17/29] [enclave/chain_relay] store only hashes of the headers instead of the headers themselves --- enclave/chain_relay/src/lib.rs | 8 ++++---- enclave/chain_relay/src/state.rs | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/enclave/chain_relay/src/lib.rs b/enclave/chain_relay/src/lib.rs index 50a0c6a51e..20442ed32d 100644 --- a/enclave/chain_relay/src/lib.rs +++ b/enclave/chain_relay/src/lib.rs @@ -116,7 +116,7 @@ impl LightValidation { if grandpa_proof.is_none() { relay.last_finalized_block_header = header.clone(); - relay.unjustified_headers.push(header); + relay.unjustified_headers.push(header.hash()); info!( "Syncing finalized block without grandpa proof. Amount of unjustified headers: {}", relay.unjustified_headers.len() @@ -142,8 +142,8 @@ impl LightValidation { Self::schedule_validator_set_change(&mut relay, &header); // a valid grandpa proof proofs finalization of all previous unjustified blocks - relay.headers.append(&mut relay.unjustified_headers); - relay.headers.push(header); + relay.header_hashes.append(&mut relay.unjustified_headers); + relay.header_hashes.push(header.hash()); if validator_set_id > relay.current_validator_set_id { relay.current_validator_set = validator_set; @@ -241,7 +241,7 @@ impl LightValidation { .tracked_relays .get(&relay_id) .ok_or(Error::NoSuchRelayExists)?; - Ok(relay.headers[0].hash()) + Ok(relay.header_hashes[0]) } pub fn latest_header(&self, relay_id: RelayId) -> Result { diff --git a/enclave/chain_relay/src/state.rs b/enclave/chain_relay/src/state.rs index 229170f030..1b1d0530f0 100644 --- a/enclave/chain_relay/src/state.rs +++ b/enclave/chain_relay/src/state.rs @@ -10,8 +10,8 @@ pub struct RelayState { pub last_finalized_block_header: Block::Header, pub current_validator_set: AuthorityList, pub current_validator_set_id: SetId, - pub headers: Vec, - pub unjustified_headers: Vec, // Finalized headers without grandpa proof + pub header_hashes: Vec, + pub unjustified_headers: Vec, // Finalized headers without grandpa proof pub verify_tx_inclusion: Vec, // Transactions sent by the relay pub scheduled_change: Option>, // Scheduled Authorities change as indicated in the header's digest. } @@ -28,7 +28,7 @@ impl RelayState { last_finalized_block_header: block_header.clone(), current_validator_set: validator_set, current_validator_set_id: 0, - headers: vec![block_header], + header_hashes: vec![block_header.hash()], unjustified_headers: Vec::new(), verify_tx_inclusion: Vec::new(), scheduled_change: None, From 39771040cea3092882db7e5f96e1eac532de83fa Mon Sep 17 00:00:00 2001 From: Alain Brenzikofer Date: Sun, 30 Aug 2020 11:11:44 +0200 Subject: [PATCH 18/29] enclave: patch log and env_logger to mesalock --- enclave/Cargo.lock | 230 +++++++++++++++++++++++++++------------------ enclave/Cargo.toml | 2 + 2 files changed, 142 insertions(+), 90 deletions(-) diff --git a/enclave/Cargo.lock b/enclave/Cargo.lock index abb58e4452..e9927dd4ce 100644 --- a/enclave/Cargo.lock +++ b/enclave/Cargo.lock @@ -172,7 +172,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "chain-relay" -version = "0.6.5-sub2.0.0-alpha.7" +version = "0.6.10-sub2.0.0-alpha.7" dependencies = [ "derive_more 0.99.5 (registry+https://github.com/rust-lang/crates.io-index)", "finality-grandpa 0.11.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -186,7 +186,7 @@ dependencies = [ "sp-application-crypto 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "sp-core 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "sp-finality-grandpa 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", - "sp-io 2.0.0-alpha.7 (git+https://github.com/scs/sgx-runtime)", + "sp-io 2.0.0-alpha.7 (git+https://github.com/encointer/sgx-runtime?tag=v0.6.10-sub2.0.0-alpha.7)", "sp-runtime 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "sp-runtime-interface 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "sp-trie 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -354,7 +354,7 @@ dependencies = [ "frame-support 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "frame-system 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "sp-io 2.0.0-alpha.7 (git+https://github.com/scs/sgx-runtime)", + "sp-io 2.0.0-alpha.7 (git+https://github.com/encointer/sgx-runtime?tag=v0.6.10-sub2.0.0-alpha.7)", "sp-runtime 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "sp-std 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "sp-tracing 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -379,13 +379,13 @@ dependencies = [ "frame-metadata 11.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "frame-support-procedural 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "impl-trait-for-tuples 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (git+https://github.com/mesalock-linux/log-sgx)", "parity-scale-codec 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "paste 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "sp-arithmetic 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "sp-core 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "sp-inherents 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", - "sp-io 2.0.0-alpha.7 (git+https://github.com/scs/sgx-runtime)", + "sp-io 2.0.0-alpha.7 (git+https://github.com/encointer/sgx-runtime?tag=v0.6.10-sub2.0.0-alpha.7)", "sp-runtime 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "sp-std 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "sp-tracing 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -433,7 +433,7 @@ dependencies = [ "impl-trait-for-tuples 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "sp-core 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", - "sp-io 2.0.0-alpha.7 (git+https://github.com/scs/sgx-runtime)", + "sp-io 2.0.0-alpha.7 (git+https://github.com/encointer/sgx-runtime?tag=v0.6.10-sub2.0.0-alpha.7)", "sp-runtime 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "sp-std 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "sp-version 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -568,7 +568,7 @@ dependencies = [ [[package]] name = "hashbrown_tstd" version = "0.7.1" -source = "git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2#253b3ac982b2d09d32f5fa5a2011e3c36bcbed1e" +source = "git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2#fdc2ea93caecaa7f69a3edc9cf840607d0628ff3" dependencies = [ "autocfg 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -700,14 +700,6 @@ dependencies = [ "sgx_tstd 1.1.2 (git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2)", ] -[[package]] -name = "log" -version = "0.4.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "memchr" version = "2.2.1" @@ -866,7 +858,7 @@ dependencies = [ "sp-consensus-aura 0.8.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "sp-core 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "sp-inherents 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", - "sp-io 2.0.0-alpha.7 (git+https://github.com/scs/sgx-runtime)", + "sp-io 2.0.0-alpha.7 (git+https://github.com/encointer/sgx-runtime?tag=v0.6.10-sub2.0.0-alpha.7)", "sp-runtime 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "sp-std 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "sp-timestamp 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -880,11 +872,80 @@ dependencies = [ "frame-support 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "frame-system 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "sp-io 2.0.0-alpha.7 (git+https://github.com/scs/sgx-runtime)", + "sp-io 2.0.0-alpha.7 (git+https://github.com/encointer/sgx-runtime?tag=v0.6.10-sub2.0.0-alpha.7)", + "sp-runtime 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-std 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "pallet-encointer-balances" +version = "0.3.2" +source = "git+https://github.com/encointer/pallets?tag=v0.3.3#750d323892f007142ae49267da768e44d733f0c0" +dependencies = [ + "frame-support 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", + "frame-system 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", + "impl-trait-for-tuples 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", + "pallet-encointer-currencies 0.3.0 (git+https://github.com/encointer/pallets?tag=v0.3.3)", + "parity-scale-codec 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "safe-mix 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-io 2.0.0-alpha.7 (git+https://github.com/encointer/sgx-runtime?tag=v0.6.10-sub2.0.0-alpha.7)", + "sp-runtime 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-std 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", + "substrate-fixed 0.5.4 (git+https://github.com/encointer/substrate-fixed?tag=v0.5.4+sub_v0.1)", +] + +[[package]] +name = "pallet-encointer-ceremonies" +version = "0.3.3" +source = "git+https://github.com/encointer/pallets?tag=v0.3.3#750d323892f007142ae49267da768e44d733f0c0" +dependencies = [ + "frame-support 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", + "frame-system 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", + "pallet-balances 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", + "pallet-encointer-balances 0.3.2 (git+https://github.com/encointer/pallets?tag=v0.3.3)", + "pallet-encointer-currencies 0.3.0 (git+https://github.com/encointer/pallets?tag=v0.3.3)", + "pallet-encointer-scheduler 0.3.1 (git+https://github.com/encointer/pallets?tag=v0.3.3)", + "pallet-timestamp 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-core 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-io 2.0.0-alpha.7 (git+https://github.com/encointer/sgx-runtime?tag=v0.6.10-sub2.0.0-alpha.7)", "sp-runtime 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "sp-std 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "pallet-encointer-currencies" +version = "0.3.0" +source = "git+https://github.com/encointer/pallets?tag=v0.3.3#750d323892f007142ae49267da768e44d733f0c0" +dependencies = [ + "frame-support 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", + "frame-system 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", + "pallet-balances 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-core 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-io 2.0.0-alpha.7 (git+https://github.com/encointer/sgx-runtime?tag=v0.6.10-sub2.0.0-alpha.7)", + "sp-runtime 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-std 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", + "substrate-fixed 0.5.4 (git+https://github.com/encointer/substrate-fixed?tag=v0.5.4+sub_v0.1)", +] + +[[package]] +name = "pallet-encointer-scheduler" +version = "0.3.1" +source = "git+https://github.com/encointer/pallets?tag=v0.3.3#750d323892f007142ae49267da768e44d733f0c0" +dependencies = [ + "frame-support 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", + "frame-system 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", + "pallet-timestamp 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-core 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-io 2.0.0-alpha.7 (git+https://github.com/encointer/sgx-runtime?tag=v0.6.10-sub2.0.0-alpha.7)", + "sp-runtime 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-std 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-timestamp 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "pallet-finality-tracker" version = "2.0.0-alpha.7" @@ -941,7 +1002,7 @@ dependencies = [ "impl-trait-for-tuples 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "pallet-timestamp 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "sp-io 2.0.0-alpha.7 (git+https://github.com/scs/sgx-runtime)", + "sp-io 2.0.0-alpha.7 (git+https://github.com/encointer/sgx-runtime?tag=v0.6.10-sub2.0.0-alpha.7)", "sp-runtime 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "sp-staking 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "sp-std 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -955,7 +1016,7 @@ dependencies = [ "frame-support 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "frame-system 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "sp-io 2.0.0-alpha.7 (git+https://github.com/scs/sgx-runtime)", + "sp-io 2.0.0-alpha.7 (git+https://github.com/encointer/sgx-runtime?tag=v0.6.10-sub2.0.0-alpha.7)", "sp-runtime 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "sp-std 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -963,7 +1024,7 @@ dependencies = [ [[package]] name = "pallet-template" version = "2.0.0-alpha.7" -source = "git+https://github.com/scs/sgx-runtime?tag=v2.0.0-alpha.7#32f212bbefffc095bb5ef470b86fd7f776338dbb" +source = "git+https://github.com/encointer/sgx-runtime?tag=v0.6.10-sub2.0.0-alpha.7#931bc07ce7331cf00aba14db08f5220ca5f4533e" dependencies = [ "frame-support 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "frame-system 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1433,19 +1494,7 @@ dependencies = [ [[package]] name = "sgx-externalities" version = "0.2.0" -source = "git+https://github.com/scs/sgx-runtime?tag=v2.0.0-alpha.7#32f212bbefffc095bb5ef470b86fd7f776338dbb" -dependencies = [ - "environmental 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (git+https://github.com/mesalock-linux/log-sgx)", - "sgx_serialize 1.1.2 (git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2)", - "sgx_tstd 1.1.2 (git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2)", - "sgx_types 1.1.2 (git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2)", -] - -[[package]] -name = "sgx-externalities" -version = "0.2.0" -source = "git+https://github.com/scs/sgx-runtime#32f212bbefffc095bb5ef470b86fd7f776338dbb" +source = "git+https://github.com/encointer/sgx-runtime?tag=v0.6.10-sub2.0.0-alpha.7#931bc07ce7331cf00aba14db08f5220ca5f4533e" dependencies = [ "environmental 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (git+https://github.com/mesalock-linux/log-sgx)", @@ -1457,17 +1506,21 @@ dependencies = [ [[package]] name = "sgx-runtime" version = "2.0.0-alpha.7" -source = "git+https://github.com/scs/sgx-runtime?tag=v2.0.0-alpha.7#32f212bbefffc095bb5ef470b86fd7f776338dbb" +source = "git+https://github.com/encointer/sgx-runtime?tag=v0.6.10-sub2.0.0-alpha.7#931bc07ce7331cf00aba14db08f5220ca5f4533e" dependencies = [ "frame-executive 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "frame-support 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "frame-system 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "pallet-aura 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "pallet-balances 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", + "pallet-encointer-balances 0.3.2 (git+https://github.com/encointer/pallets?tag=v0.3.3)", + "pallet-encointer-ceremonies 0.3.3 (git+https://github.com/encointer/pallets?tag=v0.3.3)", + "pallet-encointer-currencies 0.3.0 (git+https://github.com/encointer/pallets?tag=v0.3.3)", + "pallet-encointer-scheduler 0.3.1 (git+https://github.com/encointer/pallets?tag=v0.3.3)", "pallet-grandpa 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "pallet-randomness-collective-flip 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "pallet-sudo 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", - "pallet-template 2.0.0-alpha.7 (git+https://github.com/scs/sgx-runtime?tag=v2.0.0-alpha.7)", + "pallet-template 2.0.0-alpha.7 (git+https://github.com/encointer/sgx-runtime?tag=v0.6.10-sub2.0.0-alpha.7)", "pallet-timestamp 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "pallet-transaction-payment 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1477,7 +1530,7 @@ dependencies = [ "sp-consensus-aura 0.8.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "sp-core 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "sp-inherents 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", - "sp-io 2.0.0-alpha.7 (git+https://github.com/scs/sgx-runtime)", + "sp-io 2.0.0-alpha.7 (git+https://github.com/encointer/sgx-runtime?tag=v0.6.10-sub2.0.0-alpha.7)", "sp-offchain 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "sp-runtime 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "sp-session 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1490,12 +1543,12 @@ dependencies = [ [[package]] name = "sgx_alloc" version = "1.1.2" -source = "git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2#253b3ac982b2d09d32f5fa5a2011e3c36bcbed1e" +source = "git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2#fdc2ea93caecaa7f69a3edc9cf840607d0628ff3" [[package]] name = "sgx_backtrace_sys" version = "1.1.2" -source = "git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2#253b3ac982b2d09d32f5fa5a2011e3c36bcbed1e" +source = "git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2#fdc2ea93caecaa7f69a3edc9cf840607d0628ff3" dependencies = [ "cc 1.0.52 (registry+https://github.com/rust-lang/crates.io-index)", "sgx_build_helper 0.1.3 (git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2)", @@ -1505,7 +1558,7 @@ dependencies = [ [[package]] name = "sgx_build_helper" version = "0.1.3" -source = "git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2#253b3ac982b2d09d32f5fa5a2011e3c36bcbed1e" +source = "git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2#fdc2ea93caecaa7f69a3edc9cf840607d0628ff3" [[package]] name = "sgx_crypto_helper" @@ -1524,12 +1577,12 @@ dependencies = [ [[package]] name = "sgx_demangle" version = "1.1.2" -source = "git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2#253b3ac982b2d09d32f5fa5a2011e3c36bcbed1e" +source = "git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2#fdc2ea93caecaa7f69a3edc9cf840607d0628ff3" [[package]] name = "sgx_libc" version = "1.1.2" -source = "git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2#253b3ac982b2d09d32f5fa5a2011e3c36bcbed1e" +source = "git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2#fdc2ea93caecaa7f69a3edc9cf840607d0628ff3" dependencies = [ "sgx_types 1.1.2 (git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2)", ] @@ -1547,7 +1600,7 @@ dependencies = [ [[package]] name = "sgx_serialize" version = "1.1.2" -source = "git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2#253b3ac982b2d09d32f5fa5a2011e3c36bcbed1e" +source = "git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2#fdc2ea93caecaa7f69a3edc9cf840607d0628ff3" dependencies = [ "sgx_tstd 1.1.2 (git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2)", ] @@ -1589,7 +1642,7 @@ dependencies = [ [[package]] name = "sgx_tprotected_fs" version = "1.1.2" -source = "git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2#253b3ac982b2d09d32f5fa5a2011e3c36bcbed1e" +source = "git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2#fdc2ea93caecaa7f69a3edc9cf840607d0628ff3" dependencies = [ "sgx_trts 1.1.2 (git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2)", "sgx_types 1.1.2 (git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2)", @@ -1598,7 +1651,7 @@ dependencies = [ [[package]] name = "sgx_trts" version = "1.1.2" -source = "git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2#253b3ac982b2d09d32f5fa5a2011e3c36bcbed1e" +source = "git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2#fdc2ea93caecaa7f69a3edc9cf840607d0628ff3" dependencies = [ "sgx_libc 1.1.2 (git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2)", "sgx_types 1.1.2 (git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2)", @@ -1626,7 +1679,7 @@ dependencies = [ [[package]] name = "sgx_tstd" version = "1.1.2" -source = "git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2#253b3ac982b2d09d32f5fa5a2011e3c36bcbed1e" +source = "git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2#fdc2ea93caecaa7f69a3edc9cf840607d0628ff3" dependencies = [ "hashbrown_tstd 0.7.1 (git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2)", "sgx_alloc 1.1.2 (git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2)", @@ -1650,12 +1703,12 @@ dependencies = [ [[package]] name = "sgx_types" version = "1.1.2" -source = "git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2#253b3ac982b2d09d32f5fa5a2011e3c36bcbed1e" +source = "git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2#fdc2ea93caecaa7f69a3edc9cf840607d0628ff3" [[package]] name = "sgx_unwind" version = "0.1.1" -source = "git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2#253b3ac982b2d09d32f5fa5a2011e3c36bcbed1e" +source = "git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2#fdc2ea93caecaa7f69a3edc9cf840607d0628ff3" dependencies = [ "sgx_build_helper 0.1.3 (git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2)", ] @@ -1713,7 +1766,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "parity-scale-codec 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "sp-core 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", - "sp-io 2.0.0-alpha.7 (git+https://github.com/scs/sgx-runtime)", + "sp-io 2.0.0-alpha.7 (git+https://github.com/encointer/sgx-runtime?tag=v0.6.10-sub2.0.0-alpha.7)", "sp-std 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1768,7 +1821,7 @@ dependencies = [ "hash256-std-hasher 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", "hex 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "libsecp256k1 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (git+https://github.com/mesalock-linux/log-sgx)", "merlin 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1830,31 +1883,13 @@ dependencies = [ [[package]] name = "sp-io" version = "2.0.0-alpha.7" -source = "git+https://github.com/scs/sgx-runtime?tag=v2.0.0-alpha.7#32f212bbefffc095bb5ef470b86fd7f776338dbb" -dependencies = [ - "environmental 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "hash-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (git+https://github.com/mesalock-linux/log-sgx)", - "parity-scale-codec 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "sgx-externalities 0.2.0 (git+https://github.com/scs/sgx-runtime?tag=v2.0.0-alpha.7)", - "sgx_tstd 1.1.2 (git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2)", - "sgx_types 1.1.2 (git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2)", - "sp-core 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", - "sp-runtime-interface 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", - "sp-std 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", - "sp-wasm-interface 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "sp-io" -version = "2.0.0-alpha.7" -source = "git+https://github.com/scs/sgx-runtime#32f212bbefffc095bb5ef470b86fd7f776338dbb" +source = "git+https://github.com/encointer/sgx-runtime?tag=v0.6.10-sub2.0.0-alpha.7#931bc07ce7331cf00aba14db08f5220ca5f4533e" dependencies = [ "environmental 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "hash-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (git+https://github.com/mesalock-linux/log-sgx)", "parity-scale-codec 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "sgx-externalities 0.2.0 (git+https://github.com/scs/sgx-runtime)", + "sgx-externalities 0.2.0 (git+https://github.com/encointer/sgx-runtime?tag=v0.6.10-sub2.0.0-alpha.7)", "sgx_tstd 1.1.2 (git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2)", "sgx_types 1.1.2 (git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2)", "sp-core 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1887,7 +1922,7 @@ dependencies = [ "sp-arithmetic 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "sp-core 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "sp-inherents 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", - "sp-io 2.0.0-alpha.7 (git+https://github.com/scs/sgx-runtime)", + "sp-io 2.0.0-alpha.7 (git+https://github.com/encointer/sgx-runtime?tag=v0.6.10-sub2.0.0-alpha.7)", "sp-std 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2055,12 +2090,21 @@ dependencies = [ "pallet-balances 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "sp-core 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", - "sp-io 2.0.0-alpha.7 (git+https://github.com/scs/sgx-runtime)", + "sp-io 2.0.0-alpha.7 (git+https://github.com/encointer/sgx-runtime?tag=v0.6.10-sub2.0.0-alpha.7)", "sp-runtime 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "sp-std 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "sp-version 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "substrate-fixed" +version = "0.5.4" +source = "git+https://github.com/encointer/substrate-fixed?tag=v0.5.4+sub_v0.1#2c52170fa02507dc5b52c516061302670860869a" +dependencies = [ + "parity-scale-codec 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "typenum 1.12.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "substrate-wasm-builder-runner" version = "1.0.6" @@ -2068,7 +2112,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "substratee-node-primitives" -version = "0.6.5-sub2.0.0-alpha.7" +version = "0.6.10-sub2.0.0-alpha.7" dependencies = [ "parity-scale-codec 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "primitive-types 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2078,31 +2122,35 @@ dependencies = [ [[package]] name = "substratee-stf" -version = "0.6.5-sub2.0.0-alpha.7" +version = "0.6.10-sub2.0.0-alpha.7" dependencies = [ "derive_more 0.99.5 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.7.1 (git+https://github.com/mesalock-linux/env_logger-sgx)", "frame-metadata 11.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "frame-system 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (git+https://github.com/mesalock-linux/log-sgx)", - "pallet-balances 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", + "pallet-encointer-balances 0.3.2 (git+https://github.com/encointer/pallets?tag=v0.3.3)", + "pallet-encointer-ceremonies 0.3.3 (git+https://github.com/encointer/pallets?tag=v0.3.3)", + "pallet-encointer-currencies 0.3.0 (git+https://github.com/encointer/pallets?tag=v0.3.3)", + "pallet-encointer-scheduler 0.3.1 (git+https://github.com/encointer/pallets?tag=v0.3.3)", "parity-scale-codec 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "sgx-runtime 2.0.0-alpha.7 (git+https://github.com/scs/sgx-runtime?tag=v2.0.0-alpha.7)", + "sgx-runtime 2.0.0-alpha.7 (git+https://github.com/encointer/sgx-runtime?tag=v0.6.10-sub2.0.0-alpha.7)", "sgx_tstd 1.1.2 (git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2)", "sp-application-crypto 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "sp-core 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", - "sp-io 2.0.0-alpha.7 (git+https://github.com/scs/sgx-runtime)", + "sp-io 2.0.0-alpha.7 (git+https://github.com/encointer/sgx-runtime?tag=v0.6.10-sub2.0.0-alpha.7)", "sp-runtime 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", + "substrate-fixed 0.5.4 (git+https://github.com/encointer/substrate-fixed?tag=v0.5.4+sub_v0.1)", ] [[package]] name = "substratee-worker-enclave" -version = "0.6.5-sub2.0.0-alpha.7" +version = "0.6.10-sub2.0.0-alpha.7" dependencies = [ "aes 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "base64 0.10.1 (git+https://github.com/mesalock-linux/rust-base64-sgx)", "bit-vec 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", - "chain-relay 0.6.5-sub2.0.0-alpha.7", + "chain-relay 0.6.10-sub2.0.0-alpha.7", "chrono 0.4.11 (git+https://github.com/mesalock-linux/chrono-sgx)", "env_logger 0.7.1 (git+https://github.com/mesalock-linux/env_logger-sgx)", "httparse 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2118,7 +2166,7 @@ dependencies = [ "serde 1.0.106 (git+https://github.com/mesalock-linux/serde-sgx?rev=sgx_1.1.2)", "serde_derive 1.0.106 (git+https://github.com/mesalock-linux/serde-sgx)", "serde_json 1.0.51 (git+https://github.com/mesalock-linux/serde-json-sgx?rev=sgx_1.1.2)", - "sgx-externalities 0.2.0 (git+https://github.com/scs/sgx-runtime)", + "sgx-externalities 0.2.0 (git+https://github.com/encointer/sgx-runtime?tag=v0.6.10-sub2.0.0-alpha.7)", "sgx_rand 1.1.2 (git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2)", "sgx_serialize 1.1.2 (git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2)", "sgx_serialize_derive 1.1.2 (git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2)", @@ -2132,12 +2180,12 @@ dependencies = [ "sgx_types 1.1.2 (git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2)", "sp-core 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "sp-finality-grandpa 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", - "sp-io 2.0.0-alpha.7 (git+https://github.com/scs/sgx-runtime?tag=v2.0.0-alpha.7)", + "sp-io 2.0.0-alpha.7 (git+https://github.com/encointer/sgx-runtime?tag=v0.6.10-sub2.0.0-alpha.7)", "sp-runtime 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "sp-std 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "substrate-api-client 0.4.6-sub2.0.0-alpha.7 (git+https://github.com/scs/substrate-api-client?tag=v0.4.6-sub2.0.0-alpha.7)", - "substratee-node-primitives 0.6.5-sub2.0.0-alpha.7", - "substratee-stf 0.6.5-sub2.0.0-alpha.7", + "substratee-node-primitives 0.6.10-sub2.0.0-alpha.7", + "substratee-stf 0.6.10-sub2.0.0-alpha.7", "webpki 0.21.2 (git+https://github.com/mesalock-linux/webpki?branch=mesalock_sgx)", "webpki-roots 0.19.0 (git+https://github.com/mesalock-linux/webpki-roots?branch=mesalock_sgx)", "yasna 0.3.1 (git+https://github.com/mesalock-linux/yasna.rs-sgx?rev=sgx_1.1.2)", @@ -2258,7 +2306,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "hash-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", "hashbrown 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (git+https://github.com/mesalock-linux/log-sgx)", "smallvec 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2461,7 +2509,6 @@ dependencies = [ "checksum libc 0.2.70 (registry+https://github.com/rust-lang/crates.io-index)" = "3baa92041a6fec78c687fa0cc2b3fae8884f743d672cf551bed1d6dac6988d0f" "checksum libsecp256k1 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "1fc1e2c808481a63dc6da2074752fdd4336a3c8fcc68b83db6f1fd5224ae7962" "checksum log 0.4.8 (git+https://github.com/mesalock-linux/log-sgx)" = "" -"checksum log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" "checksum memchr 2.2.1 (git+https://github.com/mesalock-linux/rust-memchr-sgx)" = "" "checksum memchr 2.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3728d817d99e5ac407411fa471ff9800a778d88a24685968b36824eaf4bee400" "checksum memory-db 0.20.1 (registry+https://github.com/rust-lang/crates.io-index)" = "be512cb2ccb4ecbdca937fdd4a62ea5f09f8e7195466a85e4632b3d5bcce82e6" @@ -2480,12 +2527,16 @@ dependencies = [ "checksum opaque-debug 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" "checksum pallet-aura 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)" = "84bfe377cb99f04a51ef30521bd3236acdf57ae76187d6ae8f0b1896fae1ba1d" "checksum pallet-balances 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)" = "5933eed290294f48ae9c6ca9b83c48f73c0e50eb2d86532a388d2076806f9d37" +"checksum pallet-encointer-balances 0.3.2 (git+https://github.com/encointer/pallets?tag=v0.3.3)" = "" +"checksum pallet-encointer-ceremonies 0.3.3 (git+https://github.com/encointer/pallets?tag=v0.3.3)" = "" +"checksum pallet-encointer-currencies 0.3.0 (git+https://github.com/encointer/pallets?tag=v0.3.3)" = "" +"checksum pallet-encointer-scheduler 0.3.1 (git+https://github.com/encointer/pallets?tag=v0.3.3)" = "" "checksum pallet-finality-tracker 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)" = "99b6aaf467788f82d9f18c940f57b6773e6114988120c63630ec1a30ef6af73d" "checksum pallet-grandpa 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)" = "0be9854b7b21a8ab2d14bc323d08b18b6d57d1bbdba1657f37169a02ac198162" "checksum pallet-randomness-collective-flip 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)" = "e6f06234e000e7b7554d75d62280e953f902981196d6dcde0d084ad5c7df4809" "checksum pallet-session 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)" = "6aace05f197abe3905182ec817e6fadc3c985b3c2ec41bfc74bb9918d1585e9e" "checksum pallet-sudo 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)" = "246c9c0b5c29baff01d925ebadee6c0c642fa4c56ba8de1957f1ecc1438cc7dc" -"checksum pallet-template 2.0.0-alpha.7 (git+https://github.com/scs/sgx-runtime?tag=v2.0.0-alpha.7)" = "" +"checksum pallet-template 2.0.0-alpha.7 (git+https://github.com/encointer/sgx-runtime?tag=v0.6.10-sub2.0.0-alpha.7)" = "" "checksum pallet-timestamp 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)" = "4c90b652dfb8796d657a2df5fa6200ada33b9784554b81a32efd73de2fe00575" "checksum pallet-transaction-payment 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)" = "52333b8598b2bcb3af5e158c61cb2d30821220a5034e92a74c6a4ef116d82a7f" "checksum pallet-transaction-payment-rpc-runtime-api 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)" = "40f6cc2ebdaff949b9f38cc03f19e541bd22773ce32e84532ac1d85a481cb112" @@ -2538,9 +2589,8 @@ dependencies = [ "checksum serde_derive 1.0.106 (git+https://github.com/mesalock-linux/serde-sgx)" = "" "checksum serde_derive 1.0.110 (registry+https://github.com/rust-lang/crates.io-index)" = "818fbf6bfa9a42d3bfcaca148547aa00c7b915bec71d1757aa2d44ca68771984" "checksum serde_json 1.0.51 (git+https://github.com/mesalock-linux/serde-json-sgx?rev=sgx_1.1.2)" = "" -"checksum sgx-externalities 0.2.0 (git+https://github.com/scs/sgx-runtime)" = "" -"checksum sgx-externalities 0.2.0 (git+https://github.com/scs/sgx-runtime?tag=v2.0.0-alpha.7)" = "" -"checksum sgx-runtime 2.0.0-alpha.7 (git+https://github.com/scs/sgx-runtime?tag=v2.0.0-alpha.7)" = "" +"checksum sgx-externalities 0.2.0 (git+https://github.com/encointer/sgx-runtime?tag=v0.6.10-sub2.0.0-alpha.7)" = "" +"checksum sgx-runtime 2.0.0-alpha.7 (git+https://github.com/encointer/sgx-runtime?tag=v0.6.10-sub2.0.0-alpha.7)" = "" "checksum sgx_alloc 1.1.2 (git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2)" = "" "checksum sgx_backtrace_sys 1.1.2 (git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2)" = "" "checksum sgx_build_helper 0.1.3 (git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2)" = "" @@ -2575,8 +2625,7 @@ dependencies = [ "checksum sp-finality-grandpa 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)" = "c91cc8d9e62f28d3dd90c3e4291f26147c5094f6f2587aeea4301bf3731d4a3c" "checksum sp-finality-tracker 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)" = "8f050f19f1e07b63f61a872552fecf7239c75e77dc133a5f5ae00dac0e7b348d" "checksum sp-inherents 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)" = "8367b0e285f8c3ab00400a5f5b53ff0dba263005d2458fdc3e9652f824205f0b" -"checksum sp-io 2.0.0-alpha.7 (git+https://github.com/scs/sgx-runtime)" = "" -"checksum sp-io 2.0.0-alpha.7 (git+https://github.com/scs/sgx-runtime?tag=v2.0.0-alpha.7)" = "" +"checksum sp-io 2.0.0-alpha.7 (git+https://github.com/encointer/sgx-runtime?tag=v0.6.10-sub2.0.0-alpha.7)" = "" "checksum sp-offchain 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)" = "e63092c0ecd8fc90971a14a169f62337b78d885873e55dee87f33fe5f76d6591" "checksum sp-runtime 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)" = "0d37f6a2e111dd82dd194fa9ef77ba49b17e70162afc237f99e7c5dc6f95834f" "checksum sp-runtime-interface 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)" = "bc743ea280556cbaf82203ec63ade39f4167402cb571aaf012c6c43f092ccf33" @@ -2596,6 +2645,7 @@ dependencies = [ "checksum static_assertions 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" "checksum stream-cipher 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8131256a5896cabcf5eb04f4d6dacbe1aefda854b0d9896e09cb58829ec5638c" "checksum substrate-api-client 0.4.6-sub2.0.0-alpha.7 (git+https://github.com/scs/substrate-api-client?tag=v0.4.6-sub2.0.0-alpha.7)" = "" +"checksum substrate-fixed 0.5.4 (git+https://github.com/encointer/substrate-fixed?tag=v0.5.4+sub_v0.1)" = "" "checksum substrate-wasm-builder-runner 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "d2a965994514ab35d3893e9260245f2947fd1981cdd4fffd2c6e6d1a9ce02e6a" "checksum subtle 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2d67a5a62ba6e01cb2192ff309324cb4875d0c451d55fe2319433abe7a05a8ee" "checksum subtle 2.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7c65d530b10ccaeac294f349038a597e435b18fb456aadd0840a623f83b9e941" diff --git a/enclave/Cargo.toml b/enclave/Cargo.toml index b97af1ccc1..8ecada9dba 100644 --- a/enclave/Cargo.toml +++ b/enclave/Cargo.toml @@ -125,3 +125,5 @@ features = ["sgx"] [patch.crates-io] sp-io = { git = "https://github.com/scs/sgx-runtime", default-features = false, features = ["disable_oom", "disable_panic_handler", "disable_allocator", "sgx"]} +log = { git = "https://github.com/mesalock-linux/log-sgx", version = "0.4" } +env_logger = { git = "https://github.com/mesalock-linux/env_logger-sgx", version = "0.7" } From 23b84851fc272528bceff6e9beacd5fb11a32b05 Mon Sep 17 00:00:00 2001 From: Alain Brenzikofer Date: Tue, 8 Sep 2020 23:05:49 +0200 Subject: [PATCH 19/29] manual fixes to remove encointer-specifics. bump version to 0.6.11 like encointer reference release --- Cargo.lock | 980 +++++++++++--------------- client/bootstrap_demo_currency.sh | 131 ---- enclave/Cargo.lock | 230 +++--- enclave/Cargo.toml | 2 +- enclave/chain_relay/Cargo.toml | 2 +- stf/Cargo.toml | 2 +- substratee-node-primitives/Cargo.toml | 2 +- worker/Cargo.toml | 7 +- worker/worker-api/Cargo.toml | 2 +- 9 files changed, 511 insertions(+), 847 deletions(-) delete mode 100755 client/bootstrap_demo_currency.sh diff --git a/Cargo.lock b/Cargo.lock index a094cb1bdb..c71164f539 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -183,6 +183,18 @@ dependencies = [ "radium", ] +[[package]] +name = "blake2" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94cb07b0da6a73955f8fb85d24c466778e70cda767a568229b104f0264089330" +dependencies = [ + "byte-tools 0.3.1", + "crypto-mac", + "digest 0.8.1", + "opaque-debug", +] + [[package]] name = "blake2-rfc" version = "0.2.18" @@ -235,6 +247,12 @@ dependencies = [ "byte-tools 0.3.1", ] +[[package]] +name = "bs58" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "476e9cd489f9e121e02ffa6014a8ef220ecb15c05ed23fc34cca13925dc283fb" + [[package]] name = "bumpalo" version = "3.2.1" @@ -272,10 +290,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "206fdffcfa2df7cbe15601ef46c813fce0965eb3286db6b56c583b814b51c81c" dependencies = [ "byteorder", - "either", "iovec", ] +[[package]] +name = "bytes" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "118cf036fbb97d0816e3c34b2d7a1e8cfc60f68fcf63d550ddbe9bd5f59c213b" +dependencies = [ + "loom", +] + [[package]] name = "cc" version = "1.0.52" @@ -355,12 +381,12 @@ dependencies = [ [[package]] name = "common-multipart-rfc7578" -version = "0.1.2" +version = "0.2.0-rc" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "268218373e3e8e71822a01d34ad9d638c3d0e4895054497c5b8a44859df7fedd" +checksum = "7471b7b1588b2cda44e0cdf3fd3da5706c1b46224dbf486c3daceb6655ec191c" dependencies = [ - "bytes", - "futures 0.1.29", + "bytes 0.5.5", + "futures 0.3.5", "http", "mime", "rand 0.5.6", @@ -408,42 +434,6 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b3a71ab494c0b5b860bdc8407ae08978052417070c2ced38573a9157ad75b8ac" -[[package]] -name = "crossbeam-deque" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f02af974daeee82218205558e51ec8768b48cf524bd01d550abe5573a608285" -dependencies = [ - "crossbeam-epoch", - "crossbeam-utils", - "maybe-uninit", -] - -[[package]] -name = "crossbeam-epoch" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "058ed274caafc1f60c4997b5fc07bf7dc7cca454af7c6e81edffe5f33f70dace" -dependencies = [ - "autocfg 1.0.0", - "cfg-if", - "crossbeam-utils", - "lazy_static", - "maybe-uninit", - "memoffset", - "scopeguard 1.1.0", -] - -[[package]] -name = "crossbeam-queue" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c695eeca1e7173472a32221542ae469b3e9aac3a4fc81f7696bcad82029493db" -dependencies = [ - "cfg-if", - "crossbeam-utils", -] - [[package]] name = "crossbeam-utils" version = "0.7.2" @@ -497,6 +487,12 @@ dependencies = [ "zeroize 1.1.0", ] +[[package]] +name = "data-encoding" +version = "2.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72aa14c04dfae8dd7d8a2b1cb7ca2152618cd01336dbfe704b8dcbf8d41dbd69" + [[package]] name = "derive_more" version = "0.99.5" @@ -537,6 +533,27 @@ dependencies = [ "winapi 0.3.8", ] +[[package]] +name = "dirs" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13aea89a5c93364a98e9b37b2fa237effbb694d5cfe01c5b70941f7eb087d5e3" +dependencies = [ + "cfg-if", + "dirs-sys", +] + +[[package]] +name = "dirs-sys" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e93d7f5705de3e49895a2b5e0b8855a1c27f080192ae9c32a6432d50741a57a" +dependencies = [ + "libc", + "redox_users", + "winapi 0.3.8", +] + [[package]] name = "dtoa" version = "0.4.5" @@ -561,123 +578,6 @@ version = "1.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bb1f6b1ce1c140482ea30ddd3335fc0024ac7ee112895426e0a629a6c20adfe3" -[[package]] -name = "encointer-client-teeproxy" -version = "0.6.8-sub2.0.0-alpha.7" -dependencies = [ - "base58", - "blake2-rfc", - "chrono", - "clap", - "clap-nested", - "encointer-node-teeproxy-runtime", - "env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", - "frame-system", - "geojson", - "hex 0.4.2", - "json", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "pallet-balances", - "pallet-encointer-balances", - "pallet-encointer-ceremonies", - "pallet-encointer-currencies", - "pallet-encointer-scheduler", - "parity-scale-codec", - "primitive-types 0.6.2", - "sc-keystore", - "serde", - "serde_json", - "sp-application-crypto", - "sp-core", - "sp-keyring", - "sp-runtime", - "substrate-api-client", - "substrate-bip39 0.3.1", - "substratee-stf", - "substratee-worker-api", - "tiny-bip39 0.6.2", -] - -[[package]] -name = "encointer-node-teeproxy-runtime" -version = "0.3.3" -source = "git+https://github.com/encointer/encointer-node?branch=sgx-master#156b90a0fc5e8b8af46ea48dc3b9c611688b94ab" -dependencies = [ - "frame-executive", - "frame-support", - "frame-system", - "frame-system-rpc-runtime-api", - "pallet-aura", - "pallet-balances", - "pallet-encointer-balances", - "pallet-encointer-ceremonies", - "pallet-encointer-currencies", - "pallet-encointer-scheduler", - "pallet-grandpa", - "pallet-randomness-collective-flip", - "pallet-substratee-registry", - "pallet-sudo", - "pallet-timestamp", - "pallet-transaction-payment", - "pallet-transaction-payment-rpc-runtime-api", - "parity-scale-codec", - "serde", - "sp-api", - "sp-block-builder", - "sp-consensus-aura", - "sp-core", - "sp-inherents", - "sp-io 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", - "sp-offchain", - "sp-runtime", - "sp-session", - "sp-std", - "sp-transaction-pool", - "sp-version", - "substrate-fixed", - "substrate-wasm-builder-runner", -] - -[[package]] -name = "encointer-worker" -version = "0.6.8-sub2.0.0-alpha.7" -dependencies = [ - "base58", - "cid", - "clap", - "dirs", - "encointer-node-teeproxy-runtime", - "env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", - "frame-system", - "futures 0.1.29", - "hex 0.3.2", - "hyper", - "ipfs-api", - "lazy_static", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "multihash", - "pallet-balances", - "parity-scale-codec", - "primitive-types 0.6.2", - "rust-crypto", - "serde", - "serde_derive", - "serde_json", - "sgx_crypto_helper", - "sgx_types", - "sgx_urts", - "sha2 0.7.1", - "sp-core", - "sp-finality-grandpa", - "sp-keyring", - "sp-runtime", - "substrate-api-client", - "substratee-node-primitives", - "substratee-stf", - "substratee-worker-api", - "ws", -] - [[package]] name = "env_logger" version = "0.7.1" @@ -906,16 +806,6 @@ dependencies = [ "sp-version", ] -[[package]] -name = "frame-system-rpc-runtime-api" -version = "2.0.0-alpha.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd46f144dd3e1a29dc7bac5f5d3cce95b43dcaf9f352880d95e94a5019fd2191" -dependencies = [ - "parity-scale-codec", - "sp-api", -] - [[package]] name = "fuchsia-cprng" version = "0.1.1" @@ -975,16 +865,6 @@ version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "59f5fff90fd5d971f936ad674802482ba441b6f09ba5e15fd8b39145582ca399" -[[package]] -name = "futures-cpupool" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab90cde24b3319636588d0c35fe03b1333857621051837ed769faefb4c2162e4" -dependencies = [ - "futures 0.1.29", - "num_cpus", -] - [[package]] name = "futures-executor" version = "0.3.5" @@ -1057,6 +937,19 @@ version = "0.3.55" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" +[[package]] +name = "generator" +version = "0.6.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "add72f17bb81521258fcc8a7a3245b1e184e916bfbe34f0ea89558f440df5c68" +dependencies = [ + "cc", + "libc", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc_version", + "winapi 0.3.8", +] + [[package]] name = "generic-array" version = "0.9.0" @@ -1075,17 +968,6 @@ dependencies = [ "typenum", ] -[[package]] -name = "geojson" -version = "0.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4ac03428b3276fc7f1756eba0c76c7c0c91ef77e1c43fbdd47a460238419cb9" -dependencies = [ - "num-traits", - "serde", - "serde_json", -] - [[package]] name = "getrandom" version = "0.1.14" @@ -1105,20 +987,21 @@ checksum = "bcc8e0c9bce37868955864dbecd2b1ab2bdf967e6f28066d65aaac620444b65c" [[package]] name = "h2" -version = "0.1.26" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5b34c246847f938a410a03c5458c7fee2274436675e76d8b903c08efc29c462" +checksum = "79b7246d7e4b979c03fa093da39cfb3617a96bbeee6310af63991668d7e843ff" dependencies = [ - "byteorder", - "bytes", + "bytes 0.5.5", "fnv", - "futures 0.1.29", + "futures-core", + "futures-sink", + "futures-util", "http", "indexmap", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "slab", - "string", - "tokio-io", + "tokio", + "tokio-util 0.3.1", ] [[package]] @@ -1159,7 +1042,7 @@ dependencies = [ [[package]] name = "hashbrown_tstd" version = "0.7.1" -source = "git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2#fdc2ea93caecaa7f69a3edc9cf840607d0628ff3" +source = "git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2#253b3ac982b2d09d32f5fa5a2011e3c36bcbed1e" dependencies = [ "autocfg 1.0.0", ] @@ -1217,25 +1100,23 @@ dependencies = [ [[package]] name = "http" -version = "0.1.21" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6ccf5ede3a895d8856620237b2f02972c1bbc78d2965ad7fe8838d4a0ed41f0" +checksum = "28d569972648b2c512421b5f2a405ad6ac9666547189d0c5477a3f200f3e02f9" dependencies = [ - "bytes", + "bytes 0.5.5", "fnv", "itoa", ] [[package]] name = "http-body" -version = "0.1.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6741c859c1b2463a423a1dbce98d418e6c3c3fc720fb0d45528657320920292d" +checksum = "13d5ff830006f7646652e057693569bfe0d51760c0085a071769d142a205111b" dependencies = [ - "bytes", - "futures 0.1.29", + "bytes 0.5.5", "http", - "tokio-buf", ] [[package]] @@ -1264,58 +1145,52 @@ dependencies = [ [[package]] name = "hyper" -version = "0.12.35" +version = "0.13.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9dbe6ed1438e1f8ad955a4701e9a944938e9519f6888d12d8558b645e247d5f6" +checksum = "a6e7655b9594024ad0ee439f3b5a7299369dc2a3f459b47c696f9ff676f9aa1f" dependencies = [ - "bytes", - "futures 0.1.29", - "futures-cpupool", + "bytes 0.5.5", + "futures-channel", + "futures-core", + "futures-util", "h2", "http", "http-body", "httparse", - "iovec", "itoa", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "net2", - "rustc_version", + "pin-project", + "socket2", "time", "tokio", - "tokio-buf", - "tokio-executor", - "tokio-io", - "tokio-reactor", - "tokio-tcp", - "tokio-threadpool", - "tokio-timer", + "tower-service", "want", ] [[package]] name = "hyper-multipart-rfc7578" -version = "0.3.1" +version = "0.4.0-rc" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9dd6db1305d3da7f9a2d876d6e897a076e49d5253c7d33722311d2ce86c35075" +checksum = "3a71feb0ce26d0e28969633c06521716b07607f58f55dff84f30214b6c6d256a" dependencies = [ - "bytes", + "bytes 0.5.5", "common-multipart-rfc7578", - "futures 0.1.29", + "futures 0.3.5", "http", "hyper", ] [[package]] name = "hyper-tls" -version = "0.3.2" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a800d6aa50af4b5850b2b0f659625ce9504df908e9733b635720483be26174f" +checksum = "d979acc56dcb5b8dddba3917601745e877576475aa046df3226eabdecef78eed" dependencies = [ - "bytes", - "futures 0.1.29", + "bytes 0.5.5", "hyper", "native-tls", - "tokio-io", + "tokio", + "tokio-tls", ] [[package]] @@ -1345,6 +1220,17 @@ dependencies = [ "unicode-normalization", ] +[[package]] +name = "idna" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02e2673c30ee86b5b96a9cb52ad15718aa1f966f5ab9ad54a8b95d5ca33120a9" +dependencies = [ + "matches", + "unicode-bidi", + "unicode-normalization", +] + [[package]] name = "impl-codec" version = "0.4.2" @@ -1419,26 +1305,24 @@ dependencies = [ [[package]] name = "ipfs-api" -version = "0.5.2" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fdaf4ca6ebd12e362bef43fbab53b577c2d8c9e9f4b4336f6cc727e5a33ffa1f" +checksum = "f9e7fbfe5c8cb04c27fe20bf2624354f4d102652fd465a297a924c24e60aba4a" dependencies = [ - "bytes", - "dirs", + "bytes 0.5.5", + "dirs 2.0.2", "failure", - "futures 0.1.29", + "futures 0.3.5", "http", "hyper", "hyper-multipart-rfc7578", "hyper-tls", - "multiaddr", + "parity-multiaddr", "serde", - "serde_derive", "serde_json", "serde_urlencoded", "tokio", - "tokio-codec", - "tokio-io", + "tokio-util 0.2.0", "walkdir", ] @@ -1485,7 +1369,7 @@ dependencies = [ "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "serde", "serde_json", - "url", + "url 1.7.2", ] [[package]] @@ -1640,6 +1524,17 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "loom" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ecc775857611e1df29abba5c41355cdf540e7e9d4acfdf0f355eefee82330b7" +dependencies = [ + "cfg-if", + "generator", + "scoped-tls", +] + [[package]] name = "matches" version = "0.1.8" @@ -1677,15 +1572,6 @@ version = "2.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3728d817d99e5ac407411fa471ff9800a778d88a24685968b36824eaf4bee400" -[[package]] -name = "memoffset" -version = "0.5.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4fc2c02a7e374099d4ee95a193111f72d2110197fe200272371758f6c3643d8" -dependencies = [ - "autocfg 1.0.0", -] - [[package]] name = "memory-db" version = "0.20.1" @@ -1765,17 +1651,6 @@ dependencies = [ "slab", ] -[[package]] -name = "mio-uds" -version = "0.6.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afcb699eb26d4332647cc848492bbc15eafb26f08d0304550d5aa1f612e066f0" -dependencies = [ - "iovec", - "libc", - "mio", -] - [[package]] name = "miow" version = "0.2.1" @@ -1788,17 +1663,6 @@ dependencies = [ "ws2_32-sys", ] -[[package]] -name = "multiaddr" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46c47add5e6a96020ca53393aebf77193fd5f578a4e7a73ab505f41e4be06e8c" -dependencies = [ - "byteorder", - "cid", - "integer-encoding", -] - [[package]] name = "multibase" version = "0.6.0" @@ -2035,79 +1899,6 @@ dependencies = [ "sp-std", ] -[[package]] -name = "pallet-encointer-balances" -version = "0.3.2" -source = "git+https://github.com/encointer/pallets?tag=v0.3.2#9765159a7fa55dd69f1bc164d0b8d560d0413f0d" -dependencies = [ - "frame-support", - "frame-system", - "impl-trait-for-tuples", - "num-traits", - "pallet-encointer-currencies", - "parity-scale-codec", - "safe-mix", - "serde", - "sp-io 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", - "sp-runtime", - "sp-std", - "substrate-fixed", -] - -[[package]] -name = "pallet-encointer-ceremonies" -version = "0.3.0" -source = "git+https://github.com/encointer/pallets?tag=v0.3.2#9765159a7fa55dd69f1bc164d0b8d560d0413f0d" -dependencies = [ - "frame-support", - "frame-system", - "pallet-balances", - "pallet-encointer-balances", - "pallet-encointer-currencies", - "pallet-encointer-scheduler", - "pallet-timestamp", - "parity-scale-codec", - "serde", - "sp-core", - "sp-io 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", - "sp-runtime", - "sp-std", -] - -[[package]] -name = "pallet-encointer-currencies" -version = "0.3.0" -source = "git+https://github.com/encointer/pallets?tag=v0.3.2#9765159a7fa55dd69f1bc164d0b8d560d0413f0d" -dependencies = [ - "frame-support", - "frame-system", - "pallet-balances", - "parity-scale-codec", - "serde", - "sp-core", - "sp-io 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", - "sp-runtime", - "sp-std", - "substrate-fixed", -] - -[[package]] -name = "pallet-encointer-scheduler" -version = "0.3.1" -source = "git+https://github.com/encointer/pallets?tag=v0.3.2#9765159a7fa55dd69f1bc164d0b8d560d0413f0d" -dependencies = [ - "frame-support", - "frame-system", - "pallet-timestamp", - "parity-scale-codec", - "serde", - "sp-core", - "sp-io 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", - "sp-runtime", - "sp-std", - "sp-timestamp", -] - [[package]] name = "pallet-finality-tracker" version = "2.0.0-alpha.7" @@ -2211,7 +2002,7 @@ dependencies = [ [[package]] name = "pallet-template" version = "2.0.0-alpha.7" -source = "git+https://github.com/encointer/sgx-runtime#d28c480652130b65084b1bd0e0204f87026f1c24" +source = "git+https://github.com/scs/sgx-runtime?tag=v2.0.0-alpha.7#32f212bbefffc095bb5ef470b86fd7f776338dbb" dependencies = [ "frame-support", "frame-system", @@ -2264,6 +2055,39 @@ dependencies = [ "sp-std", ] +[[package]] +name = "parity-multiaddr" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f77055f9e81921a8cc7bebeb6cded3d128931d51f1e3dd6251f0770a6d431477" +dependencies = [ + "arrayref", + "bs58", + "byteorder", + "data-encoding", + "parity-multihash", + "percent-encoding 2.1.0", + "serde", + "static_assertions", + "unsigned-varint", + "url 2.1.1", +] + +[[package]] +name = "parity-multihash" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a1cd2ba02391b81367bec529fb209019d718684fdc8ad6a712c2b536e46f775" +dependencies = [ + "blake2", + "bytes 0.5.5", + "rand 0.7.3", + "sha-1", + "sha2 0.8.1", + "sha3", + "unsigned-varint", +] + [[package]] name = "parity-scale-codec" version = "1.3.0" @@ -2431,6 +2255,12 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "31010dd2e1ac33d5b46a5b413495239882813e0369f8ed8a5e266f173602f831" +[[package]] +name = "percent-encoding" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" + [[package]] name = "pin-project" version = "0.4.16" @@ -2451,6 +2281,12 @@ dependencies = [ "syn", ] +[[package]] +name = "pin-project-lite" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282adbf10f2698a7a77f8e983a74b2d18176c19a7fd32a45446139ae7b02b715" + [[package]] name = "pin-utils" version = "0.1.0" @@ -3049,6 +2885,12 @@ dependencies = [ "zeroize 1.1.0", ] +[[package]] +name = "scoped-tls" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "332ffa32bf586782a3efaeb58f127980944bbc8c4d6913a86107ac2a5ab24b28" + [[package]] name = "scopeguard" version = "0.3.3" @@ -3148,20 +2990,20 @@ dependencies = [ [[package]] name = "serde_urlencoded" -version = "0.5.5" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "642dd69105886af2efd227f75a520ec9b44a820d65bc133a9131f7d229fd165a" +checksum = "9ec5d77e2d4c73717816afac02670d5c4f534ea95ed430442cad02e7a6e32c97" dependencies = [ "dtoa", "itoa", "serde", - "url", + "url 2.1.1", ] [[package]] name = "sgx-externalities" version = "0.2.0" -source = "git+https://github.com/encointer/sgx-runtime#d28c480652130b65084b1bd0e0204f87026f1c24" +source = "git+https://github.com/scs/sgx-runtime#32f212bbefffc095bb5ef470b86fd7f776338dbb" dependencies = [ "environmental", "log 0.4.8 (git+https://github.com/mesalock-linux/log-sgx)", @@ -3173,17 +3015,13 @@ dependencies = [ [[package]] name = "sgx-runtime" version = "2.0.0-alpha.7" -source = "git+https://github.com/encointer/sgx-runtime#d28c480652130b65084b1bd0e0204f87026f1c24" +source = "git+https://github.com/scs/sgx-runtime?tag=v2.0.0-alpha.7#32f212bbefffc095bb5ef470b86fd7f776338dbb" dependencies = [ "frame-executive", "frame-support", "frame-system", "pallet-aura", "pallet-balances", - "pallet-encointer-balances", - "pallet-encointer-ceremonies", - "pallet-encointer-currencies", - "pallet-encointer-scheduler", "pallet-grandpa", "pallet-randomness-collective-flip", "pallet-sudo", @@ -3210,12 +3048,12 @@ dependencies = [ [[package]] name = "sgx_alloc" version = "1.1.2" -source = "git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2#fdc2ea93caecaa7f69a3edc9cf840607d0628ff3" +source = "git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2#253b3ac982b2d09d32f5fa5a2011e3c36bcbed1e" [[package]] name = "sgx_backtrace_sys" version = "1.1.2" -source = "git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2#fdc2ea93caecaa7f69a3edc9cf840607d0628ff3" +source = "git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2#253b3ac982b2d09d32f5fa5a2011e3c36bcbed1e" dependencies = [ "cc", "sgx_build_helper", @@ -3225,7 +3063,7 @@ dependencies = [ [[package]] name = "sgx_build_helper" version = "0.1.3" -source = "git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2#fdc2ea93caecaa7f69a3edc9cf840607d0628ff3" +source = "git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2#253b3ac982b2d09d32f5fa5a2011e3c36bcbed1e" [[package]] name = "sgx_crypto_helper" @@ -3244,12 +3082,12 @@ dependencies = [ [[package]] name = "sgx_demangle" version = "1.1.2" -source = "git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2#fdc2ea93caecaa7f69a3edc9cf840607d0628ff3" +source = "git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2#253b3ac982b2d09d32f5fa5a2011e3c36bcbed1e" [[package]] name = "sgx_libc" version = "1.1.2" -source = "git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2#fdc2ea93caecaa7f69a3edc9cf840607d0628ff3" +source = "git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2#253b3ac982b2d09d32f5fa5a2011e3c36bcbed1e" dependencies = [ "sgx_types", ] @@ -3257,7 +3095,7 @@ dependencies = [ [[package]] name = "sgx_serialize" version = "1.1.2" -source = "git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2#fdc2ea93caecaa7f69a3edc9cf840607d0628ff3" +source = "git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2#253b3ac982b2d09d32f5fa5a2011e3c36bcbed1e" dependencies = [ "sgx_tstd", ] @@ -3265,7 +3103,7 @@ dependencies = [ [[package]] name = "sgx_tprotected_fs" version = "1.1.2" -source = "git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2#fdc2ea93caecaa7f69a3edc9cf840607d0628ff3" +source = "git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2#253b3ac982b2d09d32f5fa5a2011e3c36bcbed1e" dependencies = [ "sgx_trts", "sgx_types", @@ -3274,7 +3112,7 @@ dependencies = [ [[package]] name = "sgx_trts" version = "1.1.2" -source = "git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2#fdc2ea93caecaa7f69a3edc9cf840607d0628ff3" +source = "git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2#253b3ac982b2d09d32f5fa5a2011e3c36bcbed1e" dependencies = [ "sgx_libc", "sgx_types", @@ -3283,7 +3121,7 @@ dependencies = [ [[package]] name = "sgx_tstd" version = "1.1.2" -source = "git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2#fdc2ea93caecaa7f69a3edc9cf840607d0628ff3" +source = "git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2#253b3ac982b2d09d32f5fa5a2011e3c36bcbed1e" dependencies = [ "hashbrown_tstd", "sgx_alloc", @@ -3299,7 +3137,7 @@ dependencies = [ [[package]] name = "sgx_types" version = "1.1.2" -source = "git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2#fdc2ea93caecaa7f69a3edc9cf840607d0628ff3" +source = "git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2#253b3ac982b2d09d32f5fa5a2011e3c36bcbed1e" [[package]] name = "sgx_ucrypto" @@ -3315,7 +3153,7 @@ dependencies = [ [[package]] name = "sgx_unwind" version = "0.1.1" -source = "git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2#fdc2ea93caecaa7f69a3edc9cf840607d0628ff3" +source = "git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2#253b3ac982b2d09d32f5fa5a2011e3c36bcbed1e" dependencies = [ "sgx_build_helper", ] @@ -3329,6 +3167,18 @@ dependencies = [ "sgx_types", ] +[[package]] +name = "sha-1" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7d94d0bede923b3cea61f3f1ff57ff8cdfd77b400fb8f9998949e0cf04163df" +dependencies = [ + "block-buffer 0.7.3", + "digest 0.8.1", + "fake-simd", + "opaque-debug", +] + [[package]] name = "sha1" version = "0.5.0" @@ -3365,6 +3215,19 @@ dependencies = [ "opaque-debug", ] +[[package]] +name = "sha3" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd26bc0e7a2e3a7c959bc494caf58b72ee0c71d67704e9520f736ca7e4853ecf" +dependencies = [ + "block-buffer 0.7.3", + "byte-tools 0.3.1", + "digest 0.8.1", + "keccak", + "opaque-debug", +] + [[package]] name = "slab" version = "0.4.2" @@ -3386,6 +3249,18 @@ version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c7cb5678e1615754284ec264d9bb5b4c27d2018577fd90ac0ceb578591ed5ee4" +[[package]] +name = "socket2" +version = "0.3.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03088793f677dce356f3ccc2edb1b314ad191ab702a5de3faf49304f7e104918" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "winapi 0.3.8", +] + [[package]] name = "sp-api" version = "2.0.0-alpha.7" @@ -3587,7 +3462,7 @@ dependencies = [ [[package]] name = "sp-io" version = "2.0.0-alpha.7" -source = "git+https://github.com/encointer/sgx-runtime#d28c480652130b65084b1bd0e0204f87026f1c24" +source = "git+https://github.com/scs/sgx-runtime#32f212bbefffc095bb5ef470b86fd7f776338dbb" dependencies = [ "environmental", "hash-db", @@ -3892,15 +3767,6 @@ dependencies = [ "rand 0.5.6", ] -[[package]] -name = "string" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d24114bfcceb867ca7f71a0d3fe45d45619ec47a6fbfa98cb14e14250bfa5d6d" -dependencies = [ - "bytes", -] - [[package]] name = "strsim" version = "0.8.0" @@ -3978,28 +3844,49 @@ dependencies = [ "sha2 0.8.1", ] -[[package]] -name = "substrate-fixed" -version = "0.5.4" -source = "git+https://github.com/encointer/substrate-fixed?tag=v0.5.4+sub_v0.1#2c52170fa02507dc5b52c516061302670860869a" -dependencies = [ - "parity-scale-codec", - "serde", - "typenum", -] - [[package]] name = "substrate-wasm-builder-runner" version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d2a965994514ab35d3893e9260245f2947fd1981cdd4fffd2c6e6d1a9ce02e6a" +[[package]] +name = "substratee-client" +version = "0.6.5-sub2.0.0-alpha.7" +dependencies = [ + "base58", + "blake2-rfc", + "chrono", + "clap", + "clap-nested", + "env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "frame-system", + "hex 0.4.2", + "json", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "pallet-balances", + "parity-scale-codec", + "primitive-types 0.6.2", + "sc-keystore", + "serde", + "serde_json", + "sp-application-crypto", + "sp-core", + "sp-keyring", + "sp-runtime", + "substrate-api-client", + "substrate-bip39 0.3.1", + "substratee-node-runtime", + "substratee-stf", + "substratee-worker-api", + "tiny-bip39 0.6.2", +] + [[package]] name = "substratee-node-primitives" -version = "0.6.8-sub2.0.0-alpha.7" +version = "0.6.5-sub2.0.0-alpha.7" dependencies = [ "base58", - "encointer-node-teeproxy-runtime", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec", "primitive-types 0.6.2", @@ -4007,43 +3894,110 @@ dependencies = [ "sp-core", "sp-runtime", "substrate-api-client", + "substratee-node-runtime", +] + +[[package]] +name = "substratee-node-runtime" +version = "0.6.6-sub2.0.0-alpha.7" +source = "git+https://github.com/scs/substraTEE-node?tag=v0.6.6-sub2.0.0-alpha.7#53c2c0330ebf55b869f2fcd106490cff9a466417" +dependencies = [ + "frame-executive", + "frame-support", + "frame-system", + "pallet-aura", + "pallet-balances", + "pallet-grandpa", + "pallet-randomness-collective-flip", + "pallet-substratee-registry", + "pallet-sudo", + "pallet-timestamp", + "pallet-transaction-payment", + "parity-scale-codec", + "serde", + "sp-api", + "sp-block-builder", + "sp-consensus-aura", + "sp-core", + "sp-inherents", + "sp-io 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-offchain", + "sp-runtime", + "sp-session", + "sp-std", + "sp-transaction-pool", + "sp-version", + "substrate-wasm-builder-runner", ] [[package]] name = "substratee-stf" -version = "0.6.8-sub2.0.0-alpha.7" +version = "0.6.5-sub2.0.0-alpha.7" dependencies = [ "base58", "clap", "clap-nested", "derive_more", - "encointer-node-teeproxy-runtime", "env_logger 0.7.1 (git+https://github.com/mesalock-linux/env_logger-sgx)", "frame-metadata", "frame-system", - "hex 0.3.2", "log 0.4.8 (git+https://github.com/mesalock-linux/log-sgx)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "pallet-encointer-balances", - "pallet-encointer-ceremonies", - "pallet-encointer-currencies", - "pallet-encointer-scheduler", + "pallet-balances", "parity-scale-codec", "sc-keystore", "sgx-runtime", "sgx_tstd", "sp-application-crypto", "sp-core", - "sp-io 2.0.0-alpha.7 (git+https://github.com/encointer/sgx-runtime)", + "sp-io 2.0.0-alpha.7 (git+https://github.com/scs/sgx-runtime)", + "sp-keyring", + "sp-runtime", +] + +[[package]] +name = "substratee-worker" +version = "0.6.5-sub2.0.0-alpha.7" +dependencies = [ + "base58", + "cid", + "clap", + "dirs 1.0.5", + "env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "frame-system", + "futures 0.3.5", + "hex 0.3.2", + "ipfs-api", + "lazy_static", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "multihash", + "pallet-balances", + "parity-scale-codec", + "primitive-types 0.6.2", + "rust-crypto", + "serde", + "serde_derive", + "serde_json", + "sgx_crypto_helper", + "sgx_types", + "sgx_urts", + "sha2 0.7.1", + "sp-core", + "sp-finality-grandpa", "sp-keyring", "sp-runtime", "substrate-api-client", - "substrate-fixed", + "substratee-node-primitives", + "substratee-node-runtime", + "substratee-stf", + "substratee-worker-api", + "tokio", + "ws", ] [[package]] name = "substratee-worker-api" -version = "0.6.8-sub2.0.0-alpha.7" +version = "0.6.5-sub2.0.0-alpha.7" dependencies = [ "hex 0.4.2", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4230,195 +4184,69 @@ dependencies = [ [[package]] name = "tokio" -version = "0.1.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a09c0b5bb588872ab2f09afa13ee6e9dac11e10a0ec9e8e3ba39a5a5d530af6" -dependencies = [ - "bytes", - "futures 0.1.29", - "mio", - "num_cpus", - "tokio-codec", - "tokio-current-thread", - "tokio-executor", - "tokio-fs", - "tokio-io", - "tokio-reactor", - "tokio-sync", - "tokio-tcp", - "tokio-threadpool", - "tokio-timer", - "tokio-udp", - "tokio-uds", -] - -[[package]] -name = "tokio-buf" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fb220f46c53859a4b7ec083e41dec9778ff0b1851c0942b211edb89e0ccdc46" -dependencies = [ - "bytes", - "either", - "futures 0.1.29", -] - -[[package]] -name = "tokio-codec" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25b2998660ba0e70d18684de5d06b70b70a3a747469af9dea7618cc59e75976b" -dependencies = [ - "bytes", - "futures 0.1.29", - "tokio-io", -] - -[[package]] -name = "tokio-current-thread" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1de0e32a83f131e002238d7ccde18211c0a5397f60cbfffcb112868c2e0e20e" -dependencies = [ - "futures 0.1.29", - "tokio-executor", -] - -[[package]] -name = "tokio-executor" -version = "0.1.10" +version = "0.2.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb2d1b8f4548dbf5e1f7818512e9c406860678f29c300cdf0ebac72d1a3a1671" -dependencies = [ - "crossbeam-utils", - "futures 0.1.29", -] - -[[package]] -name = "tokio-fs" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "297a1206e0ca6302a0eed35b700d292b275256f596e2f3fea7729d5e629b6ff4" -dependencies = [ - "futures 0.1.29", - "tokio-io", - "tokio-threadpool", -] - -[[package]] -name = "tokio-io" -version = "0.1.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57fc868aae093479e3131e3d165c93b1c7474109d13c90ec0dda2a1bbfff0674" -dependencies = [ - "bytes", - "futures 0.1.29", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "tokio-reactor" -version = "0.1.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09bc590ec4ba8ba87652da2068d150dcada2cfa2e07faae270a5e0409aa51351" -dependencies = [ - "crossbeam-utils", - "futures 0.1.29", - "lazy_static", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "mio", - "num_cpus", - "parking_lot 0.9.0", - "slab", - "tokio-executor", - "tokio-io", - "tokio-sync", -] - -[[package]] -name = "tokio-sync" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "edfe50152bc8164fcc456dab7891fa9bf8beaf01c5ee7e1dd43a397c3cf87dee" +checksum = "d099fa27b9702bed751524694adbe393e18b36b204da91eb1cbbbbb4a5ee2d58" dependencies = [ + "bytes 0.5.5", "fnv", - "futures 0.1.29", -] - -[[package]] -name = "tokio-tcp" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98df18ed66e3b72e742f185882a9e201892407957e45fbff8da17ae7a7c51f72" -dependencies = [ - "bytes", - "futures 0.1.29", + "futures-core", "iovec", + "lazy_static", + "memchr 2.3.3", "mio", - "tokio-io", - "tokio-reactor", + "pin-project-lite", + "slab", + "tokio-macros", ] [[package]] -name = "tokio-threadpool" -version = "0.1.18" +name = "tokio-macros" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df720b6581784c118f0eb4310796b12b1d242a7eb95f716a8367855325c25f89" +checksum = "f0c3acc6aa564495a0f2e1d59fab677cd7f81a19994cfc7f3ad0e64301560389" dependencies = [ - "crossbeam-deque", - "crossbeam-queue", - "crossbeam-utils", - "futures 0.1.29", - "lazy_static", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "num_cpus", - "slab", - "tokio-executor", + "proc-macro2", + "quote", + "syn", ] [[package]] -name = "tokio-timer" -version = "0.2.13" +name = "tokio-tls" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93044f2d313c95ff1cb7809ce9a7a05735b012288a888b62d4434fd58c94f296" +checksum = "9a70f4fcd7b3b24fb194f837560168208f669ca8cb70d0c4b862944452396343" dependencies = [ - "crossbeam-utils", - "futures 0.1.29", - "slab", - "tokio-executor", + "native-tls", + "tokio", ] [[package]] -name = "tokio-udp" -version = "0.1.6" +name = "tokio-util" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2a0b10e610b39c38b031a2fcab08e4b82f16ece36504988dcbd81dbba650d82" +checksum = "571da51182ec208780505a32528fc5512a8fe1443ab960b3f2f3ef093cd16930" dependencies = [ - "bytes", - "futures 0.1.29", + "bytes 0.5.5", + "futures-core", + "futures-sink", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "mio", - "tokio-codec", - "tokio-io", - "tokio-reactor", + "pin-project-lite", + "tokio", ] [[package]] -name = "tokio-uds" -version = "0.2.6" +name = "tokio-util" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5076db410d6fdc6523df7595447629099a1fdc47b3d9f896220780fa48faf798" +checksum = "be8242891f2b6cbef26a2d7e8605133c2c554cd35b3e4948ea892d6d68436499" dependencies = [ - "bytes", - "futures 0.1.29", - "iovec", - "libc", + "bytes 0.5.5", + "futures-core", + "futures-sink", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "mio", - "mio-uds", - "tokio-codec", - "tokio-io", - "tokio-reactor", + "pin-project-lite", + "tokio", ] [[package]] @@ -4430,6 +4258,12 @@ dependencies = [ "serde", ] +[[package]] +name = "tower-service" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e987b6bf443f4b5b3b6f38704195592cca41c5bb7aedd3c3693c7081f8289860" + [[package]] name = "tracing" version = "0.1.13" @@ -4551,6 +4385,12 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c" +[[package]] +name = "unsigned-varint" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f67332660eb59a6f1eb24ff1220c9e8d01738a8503c6002e30bcfe4bd9f2b4a9" + [[package]] name = "untrusted" version = "0.7.1" @@ -4563,9 +4403,20 @@ version = "1.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd4e7c0d531266369519a4aa4f399d748bd37043b00bde1e4ff1f60a120b355a" dependencies = [ - "idna", + "idna 0.1.5", + "matches", + "percent-encoding 1.0.1", +] + +[[package]] +name = "url" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "829d4a8476c35c9bf0bbce5a3b23f4106f79728039b726d292bb93bc106787cb" +dependencies = [ + "idna 0.2.0", "matches", - "percent-encoding", + "percent-encoding 2.1.0", ] [[package]] @@ -4593,11 +4444,10 @@ dependencies = [ [[package]] name = "want" -version = "0.2.0" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6395efa4784b027708f7451087e647ec73cc74f5d9bc2e418404248d679a230" +checksum = "1ce8a968cb1cd110d136ff8b819a556d6fb6d919363c61534f6860c7eb172ba0" dependencies = [ - "futures 0.1.29", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "try-lock", ] @@ -4782,7 +4632,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "329d3e6dd450a9c5c73024e1047f0be7e24121a68484eb0b5368977bee3cf8c3" dependencies = [ "byteorder", - "bytes", + "bytes 0.4.12", "httparse", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "mio", @@ -4791,7 +4641,7 @@ dependencies = [ "rand 0.4.6", "sha1 0.6.0", "slab", - "url", + "url 1.7.2", ] [[package]] diff --git a/client/bootstrap_demo_currency.sh b/client/bootstrap_demo_currency.sh deleted file mode 100755 index 3e5d31924e..0000000000 --- a/client/bootstrap_demo_currency.sh +++ /dev/null @@ -1,131 +0,0 @@ -#!/bin/bash - -# M1 Demo -# -# bootstrap a bot currency on Encointer Cantillon Testnet - -## Cantillon node endpoint -#NURL=wss://cantillon.encointer.org -#NPORT=443 -## Cantillon worker endpoint -#WURL=wss://substratee03.scs.ch -#WPORT=443 - -# locals -NURL=ws://127.0.0.1 -NPORT=9979 -WURL=ws://127.0.0.1 -WPORT=2000 - -CLIENT="./../bin/encointer-client-teeproxy -u $NURL -p $NPORT -U $WURL -P $WPORT" - -wait_for_phase() { - current_phase=$($CLIENT get-phase) - - echo "waiting for phase: $1 ..." - - while [ "$current_phase" != "$1" ]; do - echo "current phase: $current_phase ... waiting for phase $1" - sleep 10 - current_phase=$($CLIENT get-phase) - done - - echo "current_phase is $1, progress script" -} - -echo "Using node address: $NURL:$NPORT" -echo "Using worker address: $WURL:$WPORT" -echo "" - - -#WORKERADDR="--worker-url ${WURL} --worker-port ${WPORT}" - -# register new currency (with any funded on-chain account) -cid=$($CLIENT new-currency test-locations-sea-of-crete.json //Alice) -echo $cid - -# list currenies -$CLIENT list-currencies - -wait_for_phase REGISTERING - -read MRENCLAVE <<< $($CLIENT list-workers | awk '/ MRENCLAVE: / { print $2 }') -#cid=7eLSZLSMShw4ju9GvuMmoVgeZxZimtvsGTSvLEdvcRqQ -#MRENCLAVE=6AkpQeSLGSwESvKMiygJzDTLHXvnwBG9c8Q8FV9LiDuN - -echo " MRENCLAVE = ${MRENCLAVE}" - -# new account with -# $CLIENT trusted new-account --mrenclave $MRENCLAVE --shard $cid - -# these must be registered bootstrappers -account1=//AliceIncognito -account2=//BobIncognito -account3=//CharlieIncognito - -$CLIENT trusted get-registration $account1 --mrenclave $MRENCLAVE --shard $cid -# should be zero - -$CLIENT trusted register-participant $account1 --mrenclave $MRENCLAVE --shard $cid -$CLIENT trusted register-participant $account2 --mrenclave $MRENCLAVE --shard $cid -$CLIENT trusted register-participant $account3 --mrenclave $MRENCLAVE --shard $cid - -echo "*** registered participants" -sleep 10 # the above returns before TrustedCalls have been executed - -# should be 1,2 and 3 -$CLIENT trusted get-registration $account1 --mrenclave $MRENCLAVE --shard $cid -$CLIENT trusted get-registration $account2 --mrenclave $MRENCLAVE --shard $cid -$CLIENT trusted get-registration $account3 --mrenclave $MRENCLAVE --shard $cid - -wait_for_phase ASSIGNING - -# nothing to do here until we can have debug getters - -wait_for_phase ATTESTING - -echo "* Waiting 5 seconds such that phase change happened in enclave" -sleep 5 -echo "" - -echo "*** start meetup" -claim1=$($CLIENT trusted new-claim $account1 3 --mrenclave $MRENCLAVE --shard $cid ) -claim2=$($CLIENT trusted new-claim $account2 3 --mrenclave $MRENCLAVE --shard $cid ) -claim3=$($CLIENT trusted new-claim $account3 3 --mrenclave $MRENCLAVE --shard $cid ) - -echo "Claim1 = ${claim1}" -echo "Claim2 = ${claim2}" -echo "Claim3 = ${claim3}" - -echo "*** sign each others claims" -witness1_2=$($CLIENT sign-claim $account1 $claim2) -witness1_3=$($CLIENT sign-claim $account1 $claim3) - -witness2_1=$($CLIENT sign-claim $account2 $claim1) -witness2_3=$($CLIENT sign-claim $account2 $claim3) - -witness3_1=$($CLIENT sign-claim $account3 $claim1) -witness3_2=$($CLIENT sign-claim $account3 $claim2) - -echo "*** send witnesses to chain" -$CLIENT trusted register-attestations $account1 $witness2_1 $witness3_1 --mrenclave $MRENCLAVE --shard $cid -$CLIENT trusted register-attestations $account2 $witness1_2 $witness3_2 --mrenclave $MRENCLAVE --shard $cid -$CLIENT trusted register-attestations $account3 $witness1_3 $witness2_3 --mrenclave $MRENCLAVE --shard $cid - - -$CLIENT trusted get-attestations $account1 --mrenclave $MRENCLAVE --shard $cid -$CLIENT trusted get-attestations $account2 --mrenclave $MRENCLAVE --shard $cid -$CLIENT trusted get-attestations $account3 --mrenclave $MRENCLAVE --shard $cid - -wait_for_phase REGISTERING - -echo "* Waiting 5 seconds such that phase change happened in enclave" -sleep 5 -echo "" - -echo "account balances for new currency with cid $cid" -$CLIENT trusted balance $account1 --mrenclave $MRENCLAVE --shard $cid -$CLIENT trusted balance $account2 --mrenclave $MRENCLAVE --shard $cid -$CLIENT trusted balance $account3 --mrenclave $MRENCLAVE --shard $cid -echo "total issuance (publicly readable)" -$CLIENT trusted total-issuance --mrenclave $MRENCLAVE --shard $cid diff --git a/enclave/Cargo.lock b/enclave/Cargo.lock index e9927dd4ce..abb58e4452 100644 --- a/enclave/Cargo.lock +++ b/enclave/Cargo.lock @@ -172,7 +172,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "chain-relay" -version = "0.6.10-sub2.0.0-alpha.7" +version = "0.6.5-sub2.0.0-alpha.7" dependencies = [ "derive_more 0.99.5 (registry+https://github.com/rust-lang/crates.io-index)", "finality-grandpa 0.11.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -186,7 +186,7 @@ dependencies = [ "sp-application-crypto 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "sp-core 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "sp-finality-grandpa 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", - "sp-io 2.0.0-alpha.7 (git+https://github.com/encointer/sgx-runtime?tag=v0.6.10-sub2.0.0-alpha.7)", + "sp-io 2.0.0-alpha.7 (git+https://github.com/scs/sgx-runtime)", "sp-runtime 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "sp-runtime-interface 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "sp-trie 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -354,7 +354,7 @@ dependencies = [ "frame-support 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "frame-system 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "sp-io 2.0.0-alpha.7 (git+https://github.com/encointer/sgx-runtime?tag=v0.6.10-sub2.0.0-alpha.7)", + "sp-io 2.0.0-alpha.7 (git+https://github.com/scs/sgx-runtime)", "sp-runtime 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "sp-std 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "sp-tracing 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -379,13 +379,13 @@ dependencies = [ "frame-metadata 11.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "frame-support-procedural 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "impl-trait-for-tuples 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (git+https://github.com/mesalock-linux/log-sgx)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "paste 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "sp-arithmetic 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "sp-core 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "sp-inherents 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", - "sp-io 2.0.0-alpha.7 (git+https://github.com/encointer/sgx-runtime?tag=v0.6.10-sub2.0.0-alpha.7)", + "sp-io 2.0.0-alpha.7 (git+https://github.com/scs/sgx-runtime)", "sp-runtime 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "sp-std 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "sp-tracing 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -433,7 +433,7 @@ dependencies = [ "impl-trait-for-tuples 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "sp-core 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", - "sp-io 2.0.0-alpha.7 (git+https://github.com/encointer/sgx-runtime?tag=v0.6.10-sub2.0.0-alpha.7)", + "sp-io 2.0.0-alpha.7 (git+https://github.com/scs/sgx-runtime)", "sp-runtime 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "sp-std 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "sp-version 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -568,7 +568,7 @@ dependencies = [ [[package]] name = "hashbrown_tstd" version = "0.7.1" -source = "git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2#fdc2ea93caecaa7f69a3edc9cf840607d0628ff3" +source = "git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2#253b3ac982b2d09d32f5fa5a2011e3c36bcbed1e" dependencies = [ "autocfg 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -700,6 +700,14 @@ dependencies = [ "sgx_tstd 1.1.2 (git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2)", ] +[[package]] +name = "log" +version = "0.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "memchr" version = "2.2.1" @@ -858,7 +866,7 @@ dependencies = [ "sp-consensus-aura 0.8.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "sp-core 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "sp-inherents 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", - "sp-io 2.0.0-alpha.7 (git+https://github.com/encointer/sgx-runtime?tag=v0.6.10-sub2.0.0-alpha.7)", + "sp-io 2.0.0-alpha.7 (git+https://github.com/scs/sgx-runtime)", "sp-runtime 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "sp-std 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "sp-timestamp 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -872,80 +880,11 @@ dependencies = [ "frame-support 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "frame-system 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "sp-io 2.0.0-alpha.7 (git+https://github.com/encointer/sgx-runtime?tag=v0.6.10-sub2.0.0-alpha.7)", - "sp-runtime 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", - "sp-std 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "pallet-encointer-balances" -version = "0.3.2" -source = "git+https://github.com/encointer/pallets?tag=v0.3.3#750d323892f007142ae49267da768e44d733f0c0" -dependencies = [ - "frame-support 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", - "frame-system 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", - "impl-trait-for-tuples 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "num-traits 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", - "pallet-encointer-currencies 0.3.0 (git+https://github.com/encointer/pallets?tag=v0.3.3)", - "parity-scale-codec 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "safe-mix 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "sp-io 2.0.0-alpha.7 (git+https://github.com/encointer/sgx-runtime?tag=v0.6.10-sub2.0.0-alpha.7)", - "sp-runtime 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", - "sp-std 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", - "substrate-fixed 0.5.4 (git+https://github.com/encointer/substrate-fixed?tag=v0.5.4+sub_v0.1)", -] - -[[package]] -name = "pallet-encointer-ceremonies" -version = "0.3.3" -source = "git+https://github.com/encointer/pallets?tag=v0.3.3#750d323892f007142ae49267da768e44d733f0c0" -dependencies = [ - "frame-support 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", - "frame-system 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", - "pallet-balances 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", - "pallet-encointer-balances 0.3.2 (git+https://github.com/encointer/pallets?tag=v0.3.3)", - "pallet-encointer-currencies 0.3.0 (git+https://github.com/encointer/pallets?tag=v0.3.3)", - "pallet-encointer-scheduler 0.3.1 (git+https://github.com/encointer/pallets?tag=v0.3.3)", - "pallet-timestamp 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-scale-codec 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "sp-core 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", - "sp-io 2.0.0-alpha.7 (git+https://github.com/encointer/sgx-runtime?tag=v0.6.10-sub2.0.0-alpha.7)", + "sp-io 2.0.0-alpha.7 (git+https://github.com/scs/sgx-runtime)", "sp-runtime 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "sp-std 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "pallet-encointer-currencies" -version = "0.3.0" -source = "git+https://github.com/encointer/pallets?tag=v0.3.3#750d323892f007142ae49267da768e44d733f0c0" -dependencies = [ - "frame-support 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", - "frame-system 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", - "pallet-balances 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-scale-codec 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "sp-core 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", - "sp-io 2.0.0-alpha.7 (git+https://github.com/encointer/sgx-runtime?tag=v0.6.10-sub2.0.0-alpha.7)", - "sp-runtime 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", - "sp-std 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", - "substrate-fixed 0.5.4 (git+https://github.com/encointer/substrate-fixed?tag=v0.5.4+sub_v0.1)", -] - -[[package]] -name = "pallet-encointer-scheduler" -version = "0.3.1" -source = "git+https://github.com/encointer/pallets?tag=v0.3.3#750d323892f007142ae49267da768e44d733f0c0" -dependencies = [ - "frame-support 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", - "frame-system 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", - "pallet-timestamp 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-scale-codec 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "sp-core 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", - "sp-io 2.0.0-alpha.7 (git+https://github.com/encointer/sgx-runtime?tag=v0.6.10-sub2.0.0-alpha.7)", - "sp-runtime 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", - "sp-std 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", - "sp-timestamp 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "pallet-finality-tracker" version = "2.0.0-alpha.7" @@ -1002,7 +941,7 @@ dependencies = [ "impl-trait-for-tuples 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "pallet-timestamp 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "sp-io 2.0.0-alpha.7 (git+https://github.com/encointer/sgx-runtime?tag=v0.6.10-sub2.0.0-alpha.7)", + "sp-io 2.0.0-alpha.7 (git+https://github.com/scs/sgx-runtime)", "sp-runtime 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "sp-staking 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "sp-std 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1016,7 +955,7 @@ dependencies = [ "frame-support 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "frame-system 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "sp-io 2.0.0-alpha.7 (git+https://github.com/encointer/sgx-runtime?tag=v0.6.10-sub2.0.0-alpha.7)", + "sp-io 2.0.0-alpha.7 (git+https://github.com/scs/sgx-runtime)", "sp-runtime 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "sp-std 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1024,7 +963,7 @@ dependencies = [ [[package]] name = "pallet-template" version = "2.0.0-alpha.7" -source = "git+https://github.com/encointer/sgx-runtime?tag=v0.6.10-sub2.0.0-alpha.7#931bc07ce7331cf00aba14db08f5220ca5f4533e" +source = "git+https://github.com/scs/sgx-runtime?tag=v2.0.0-alpha.7#32f212bbefffc095bb5ef470b86fd7f776338dbb" dependencies = [ "frame-support 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "frame-system 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1494,7 +1433,19 @@ dependencies = [ [[package]] name = "sgx-externalities" version = "0.2.0" -source = "git+https://github.com/encointer/sgx-runtime?tag=v0.6.10-sub2.0.0-alpha.7#931bc07ce7331cf00aba14db08f5220ca5f4533e" +source = "git+https://github.com/scs/sgx-runtime?tag=v2.0.0-alpha.7#32f212bbefffc095bb5ef470b86fd7f776338dbb" +dependencies = [ + "environmental 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (git+https://github.com/mesalock-linux/log-sgx)", + "sgx_serialize 1.1.2 (git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2)", + "sgx_tstd 1.1.2 (git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2)", + "sgx_types 1.1.2 (git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2)", +] + +[[package]] +name = "sgx-externalities" +version = "0.2.0" +source = "git+https://github.com/scs/sgx-runtime#32f212bbefffc095bb5ef470b86fd7f776338dbb" dependencies = [ "environmental 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (git+https://github.com/mesalock-linux/log-sgx)", @@ -1506,21 +1457,17 @@ dependencies = [ [[package]] name = "sgx-runtime" version = "2.0.0-alpha.7" -source = "git+https://github.com/encointer/sgx-runtime?tag=v0.6.10-sub2.0.0-alpha.7#931bc07ce7331cf00aba14db08f5220ca5f4533e" +source = "git+https://github.com/scs/sgx-runtime?tag=v2.0.0-alpha.7#32f212bbefffc095bb5ef470b86fd7f776338dbb" dependencies = [ "frame-executive 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "frame-support 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "frame-system 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "pallet-aura 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "pallet-balances 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", - "pallet-encointer-balances 0.3.2 (git+https://github.com/encointer/pallets?tag=v0.3.3)", - "pallet-encointer-ceremonies 0.3.3 (git+https://github.com/encointer/pallets?tag=v0.3.3)", - "pallet-encointer-currencies 0.3.0 (git+https://github.com/encointer/pallets?tag=v0.3.3)", - "pallet-encointer-scheduler 0.3.1 (git+https://github.com/encointer/pallets?tag=v0.3.3)", "pallet-grandpa 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "pallet-randomness-collective-flip 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "pallet-sudo 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", - "pallet-template 2.0.0-alpha.7 (git+https://github.com/encointer/sgx-runtime?tag=v0.6.10-sub2.0.0-alpha.7)", + "pallet-template 2.0.0-alpha.7 (git+https://github.com/scs/sgx-runtime?tag=v2.0.0-alpha.7)", "pallet-timestamp 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "pallet-transaction-payment 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1530,7 +1477,7 @@ dependencies = [ "sp-consensus-aura 0.8.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "sp-core 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "sp-inherents 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", - "sp-io 2.0.0-alpha.7 (git+https://github.com/encointer/sgx-runtime?tag=v0.6.10-sub2.0.0-alpha.7)", + "sp-io 2.0.0-alpha.7 (git+https://github.com/scs/sgx-runtime)", "sp-offchain 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "sp-runtime 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "sp-session 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1543,12 +1490,12 @@ dependencies = [ [[package]] name = "sgx_alloc" version = "1.1.2" -source = "git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2#fdc2ea93caecaa7f69a3edc9cf840607d0628ff3" +source = "git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2#253b3ac982b2d09d32f5fa5a2011e3c36bcbed1e" [[package]] name = "sgx_backtrace_sys" version = "1.1.2" -source = "git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2#fdc2ea93caecaa7f69a3edc9cf840607d0628ff3" +source = "git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2#253b3ac982b2d09d32f5fa5a2011e3c36bcbed1e" dependencies = [ "cc 1.0.52 (registry+https://github.com/rust-lang/crates.io-index)", "sgx_build_helper 0.1.3 (git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2)", @@ -1558,7 +1505,7 @@ dependencies = [ [[package]] name = "sgx_build_helper" version = "0.1.3" -source = "git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2#fdc2ea93caecaa7f69a3edc9cf840607d0628ff3" +source = "git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2#253b3ac982b2d09d32f5fa5a2011e3c36bcbed1e" [[package]] name = "sgx_crypto_helper" @@ -1577,12 +1524,12 @@ dependencies = [ [[package]] name = "sgx_demangle" version = "1.1.2" -source = "git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2#fdc2ea93caecaa7f69a3edc9cf840607d0628ff3" +source = "git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2#253b3ac982b2d09d32f5fa5a2011e3c36bcbed1e" [[package]] name = "sgx_libc" version = "1.1.2" -source = "git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2#fdc2ea93caecaa7f69a3edc9cf840607d0628ff3" +source = "git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2#253b3ac982b2d09d32f5fa5a2011e3c36bcbed1e" dependencies = [ "sgx_types 1.1.2 (git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2)", ] @@ -1600,7 +1547,7 @@ dependencies = [ [[package]] name = "sgx_serialize" version = "1.1.2" -source = "git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2#fdc2ea93caecaa7f69a3edc9cf840607d0628ff3" +source = "git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2#253b3ac982b2d09d32f5fa5a2011e3c36bcbed1e" dependencies = [ "sgx_tstd 1.1.2 (git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2)", ] @@ -1642,7 +1589,7 @@ dependencies = [ [[package]] name = "sgx_tprotected_fs" version = "1.1.2" -source = "git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2#fdc2ea93caecaa7f69a3edc9cf840607d0628ff3" +source = "git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2#253b3ac982b2d09d32f5fa5a2011e3c36bcbed1e" dependencies = [ "sgx_trts 1.1.2 (git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2)", "sgx_types 1.1.2 (git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2)", @@ -1651,7 +1598,7 @@ dependencies = [ [[package]] name = "sgx_trts" version = "1.1.2" -source = "git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2#fdc2ea93caecaa7f69a3edc9cf840607d0628ff3" +source = "git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2#253b3ac982b2d09d32f5fa5a2011e3c36bcbed1e" dependencies = [ "sgx_libc 1.1.2 (git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2)", "sgx_types 1.1.2 (git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2)", @@ -1679,7 +1626,7 @@ dependencies = [ [[package]] name = "sgx_tstd" version = "1.1.2" -source = "git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2#fdc2ea93caecaa7f69a3edc9cf840607d0628ff3" +source = "git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2#253b3ac982b2d09d32f5fa5a2011e3c36bcbed1e" dependencies = [ "hashbrown_tstd 0.7.1 (git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2)", "sgx_alloc 1.1.2 (git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2)", @@ -1703,12 +1650,12 @@ dependencies = [ [[package]] name = "sgx_types" version = "1.1.2" -source = "git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2#fdc2ea93caecaa7f69a3edc9cf840607d0628ff3" +source = "git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2#253b3ac982b2d09d32f5fa5a2011e3c36bcbed1e" [[package]] name = "sgx_unwind" version = "0.1.1" -source = "git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2#fdc2ea93caecaa7f69a3edc9cf840607d0628ff3" +source = "git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2#253b3ac982b2d09d32f5fa5a2011e3c36bcbed1e" dependencies = [ "sgx_build_helper 0.1.3 (git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2)", ] @@ -1766,7 +1713,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "parity-scale-codec 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "sp-core 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", - "sp-io 2.0.0-alpha.7 (git+https://github.com/encointer/sgx-runtime?tag=v0.6.10-sub2.0.0-alpha.7)", + "sp-io 2.0.0-alpha.7 (git+https://github.com/scs/sgx-runtime)", "sp-std 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1821,7 +1768,7 @@ dependencies = [ "hash256-std-hasher 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", "hex 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "libsecp256k1 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (git+https://github.com/mesalock-linux/log-sgx)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "merlin 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1883,13 +1830,31 @@ dependencies = [ [[package]] name = "sp-io" version = "2.0.0-alpha.7" -source = "git+https://github.com/encointer/sgx-runtime?tag=v0.6.10-sub2.0.0-alpha.7#931bc07ce7331cf00aba14db08f5220ca5f4533e" +source = "git+https://github.com/scs/sgx-runtime?tag=v2.0.0-alpha.7#32f212bbefffc095bb5ef470b86fd7f776338dbb" +dependencies = [ + "environmental 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "hash-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (git+https://github.com/mesalock-linux/log-sgx)", + "parity-scale-codec 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sgx-externalities 0.2.0 (git+https://github.com/scs/sgx-runtime?tag=v2.0.0-alpha.7)", + "sgx_tstd 1.1.2 (git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2)", + "sgx_types 1.1.2 (git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2)", + "sp-core 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-runtime-interface 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-std 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-wasm-interface 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "sp-io" +version = "2.0.0-alpha.7" +source = "git+https://github.com/scs/sgx-runtime#32f212bbefffc095bb5ef470b86fd7f776338dbb" dependencies = [ "environmental 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "hash-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (git+https://github.com/mesalock-linux/log-sgx)", "parity-scale-codec 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "sgx-externalities 0.2.0 (git+https://github.com/encointer/sgx-runtime?tag=v0.6.10-sub2.0.0-alpha.7)", + "sgx-externalities 0.2.0 (git+https://github.com/scs/sgx-runtime)", "sgx_tstd 1.1.2 (git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2)", "sgx_types 1.1.2 (git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2)", "sp-core 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1922,7 +1887,7 @@ dependencies = [ "sp-arithmetic 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "sp-core 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "sp-inherents 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", - "sp-io 2.0.0-alpha.7 (git+https://github.com/encointer/sgx-runtime?tag=v0.6.10-sub2.0.0-alpha.7)", + "sp-io 2.0.0-alpha.7 (git+https://github.com/scs/sgx-runtime)", "sp-std 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2090,21 +2055,12 @@ dependencies = [ "pallet-balances 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "sp-core 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", - "sp-io 2.0.0-alpha.7 (git+https://github.com/encointer/sgx-runtime?tag=v0.6.10-sub2.0.0-alpha.7)", + "sp-io 2.0.0-alpha.7 (git+https://github.com/scs/sgx-runtime)", "sp-runtime 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "sp-std 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "sp-version 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "substrate-fixed" -version = "0.5.4" -source = "git+https://github.com/encointer/substrate-fixed?tag=v0.5.4+sub_v0.1#2c52170fa02507dc5b52c516061302670860869a" -dependencies = [ - "parity-scale-codec 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "typenum 1.12.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "substrate-wasm-builder-runner" version = "1.0.6" @@ -2112,7 +2068,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "substratee-node-primitives" -version = "0.6.10-sub2.0.0-alpha.7" +version = "0.6.5-sub2.0.0-alpha.7" dependencies = [ "parity-scale-codec 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "primitive-types 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2122,35 +2078,31 @@ dependencies = [ [[package]] name = "substratee-stf" -version = "0.6.10-sub2.0.0-alpha.7" +version = "0.6.5-sub2.0.0-alpha.7" dependencies = [ "derive_more 0.99.5 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.7.1 (git+https://github.com/mesalock-linux/env_logger-sgx)", "frame-metadata 11.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "frame-system 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (git+https://github.com/mesalock-linux/log-sgx)", - "pallet-encointer-balances 0.3.2 (git+https://github.com/encointer/pallets?tag=v0.3.3)", - "pallet-encointer-ceremonies 0.3.3 (git+https://github.com/encointer/pallets?tag=v0.3.3)", - "pallet-encointer-currencies 0.3.0 (git+https://github.com/encointer/pallets?tag=v0.3.3)", - "pallet-encointer-scheduler 0.3.1 (git+https://github.com/encointer/pallets?tag=v0.3.3)", + "pallet-balances 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "sgx-runtime 2.0.0-alpha.7 (git+https://github.com/encointer/sgx-runtime?tag=v0.6.10-sub2.0.0-alpha.7)", + "sgx-runtime 2.0.0-alpha.7 (git+https://github.com/scs/sgx-runtime?tag=v2.0.0-alpha.7)", "sgx_tstd 1.1.2 (git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2)", "sp-application-crypto 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "sp-core 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", - "sp-io 2.0.0-alpha.7 (git+https://github.com/encointer/sgx-runtime?tag=v0.6.10-sub2.0.0-alpha.7)", + "sp-io 2.0.0-alpha.7 (git+https://github.com/scs/sgx-runtime)", "sp-runtime 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", - "substrate-fixed 0.5.4 (git+https://github.com/encointer/substrate-fixed?tag=v0.5.4+sub_v0.1)", ] [[package]] name = "substratee-worker-enclave" -version = "0.6.10-sub2.0.0-alpha.7" +version = "0.6.5-sub2.0.0-alpha.7" dependencies = [ "aes 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "base64 0.10.1 (git+https://github.com/mesalock-linux/rust-base64-sgx)", "bit-vec 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", - "chain-relay 0.6.10-sub2.0.0-alpha.7", + "chain-relay 0.6.5-sub2.0.0-alpha.7", "chrono 0.4.11 (git+https://github.com/mesalock-linux/chrono-sgx)", "env_logger 0.7.1 (git+https://github.com/mesalock-linux/env_logger-sgx)", "httparse 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2166,7 +2118,7 @@ dependencies = [ "serde 1.0.106 (git+https://github.com/mesalock-linux/serde-sgx?rev=sgx_1.1.2)", "serde_derive 1.0.106 (git+https://github.com/mesalock-linux/serde-sgx)", "serde_json 1.0.51 (git+https://github.com/mesalock-linux/serde-json-sgx?rev=sgx_1.1.2)", - "sgx-externalities 0.2.0 (git+https://github.com/encointer/sgx-runtime?tag=v0.6.10-sub2.0.0-alpha.7)", + "sgx-externalities 0.2.0 (git+https://github.com/scs/sgx-runtime)", "sgx_rand 1.1.2 (git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2)", "sgx_serialize 1.1.2 (git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2)", "sgx_serialize_derive 1.1.2 (git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2)", @@ -2180,12 +2132,12 @@ dependencies = [ "sgx_types 1.1.2 (git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2)", "sp-core 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "sp-finality-grandpa 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", - "sp-io 2.0.0-alpha.7 (git+https://github.com/encointer/sgx-runtime?tag=v0.6.10-sub2.0.0-alpha.7)", + "sp-io 2.0.0-alpha.7 (git+https://github.com/scs/sgx-runtime?tag=v2.0.0-alpha.7)", "sp-runtime 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "sp-std 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "substrate-api-client 0.4.6-sub2.0.0-alpha.7 (git+https://github.com/scs/substrate-api-client?tag=v0.4.6-sub2.0.0-alpha.7)", - "substratee-node-primitives 0.6.10-sub2.0.0-alpha.7", - "substratee-stf 0.6.10-sub2.0.0-alpha.7", + "substratee-node-primitives 0.6.5-sub2.0.0-alpha.7", + "substratee-stf 0.6.5-sub2.0.0-alpha.7", "webpki 0.21.2 (git+https://github.com/mesalock-linux/webpki?branch=mesalock_sgx)", "webpki-roots 0.19.0 (git+https://github.com/mesalock-linux/webpki-roots?branch=mesalock_sgx)", "yasna 0.3.1 (git+https://github.com/mesalock-linux/yasna.rs-sgx?rev=sgx_1.1.2)", @@ -2306,7 +2258,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "hash-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", "hashbrown 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (git+https://github.com/mesalock-linux/log-sgx)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2509,6 +2461,7 @@ dependencies = [ "checksum libc 0.2.70 (registry+https://github.com/rust-lang/crates.io-index)" = "3baa92041a6fec78c687fa0cc2b3fae8884f743d672cf551bed1d6dac6988d0f" "checksum libsecp256k1 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "1fc1e2c808481a63dc6da2074752fdd4336a3c8fcc68b83db6f1fd5224ae7962" "checksum log 0.4.8 (git+https://github.com/mesalock-linux/log-sgx)" = "" +"checksum log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" "checksum memchr 2.2.1 (git+https://github.com/mesalock-linux/rust-memchr-sgx)" = "" "checksum memchr 2.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3728d817d99e5ac407411fa471ff9800a778d88a24685968b36824eaf4bee400" "checksum memory-db 0.20.1 (registry+https://github.com/rust-lang/crates.io-index)" = "be512cb2ccb4ecbdca937fdd4a62ea5f09f8e7195466a85e4632b3d5bcce82e6" @@ -2527,16 +2480,12 @@ dependencies = [ "checksum opaque-debug 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" "checksum pallet-aura 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)" = "84bfe377cb99f04a51ef30521bd3236acdf57ae76187d6ae8f0b1896fae1ba1d" "checksum pallet-balances 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)" = "5933eed290294f48ae9c6ca9b83c48f73c0e50eb2d86532a388d2076806f9d37" -"checksum pallet-encointer-balances 0.3.2 (git+https://github.com/encointer/pallets?tag=v0.3.3)" = "" -"checksum pallet-encointer-ceremonies 0.3.3 (git+https://github.com/encointer/pallets?tag=v0.3.3)" = "" -"checksum pallet-encointer-currencies 0.3.0 (git+https://github.com/encointer/pallets?tag=v0.3.3)" = "" -"checksum pallet-encointer-scheduler 0.3.1 (git+https://github.com/encointer/pallets?tag=v0.3.3)" = "" "checksum pallet-finality-tracker 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)" = "99b6aaf467788f82d9f18c940f57b6773e6114988120c63630ec1a30ef6af73d" "checksum pallet-grandpa 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)" = "0be9854b7b21a8ab2d14bc323d08b18b6d57d1bbdba1657f37169a02ac198162" "checksum pallet-randomness-collective-flip 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)" = "e6f06234e000e7b7554d75d62280e953f902981196d6dcde0d084ad5c7df4809" "checksum pallet-session 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)" = "6aace05f197abe3905182ec817e6fadc3c985b3c2ec41bfc74bb9918d1585e9e" "checksum pallet-sudo 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)" = "246c9c0b5c29baff01d925ebadee6c0c642fa4c56ba8de1957f1ecc1438cc7dc" -"checksum pallet-template 2.0.0-alpha.7 (git+https://github.com/encointer/sgx-runtime?tag=v0.6.10-sub2.0.0-alpha.7)" = "" +"checksum pallet-template 2.0.0-alpha.7 (git+https://github.com/scs/sgx-runtime?tag=v2.0.0-alpha.7)" = "" "checksum pallet-timestamp 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)" = "4c90b652dfb8796d657a2df5fa6200ada33b9784554b81a32efd73de2fe00575" "checksum pallet-transaction-payment 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)" = "52333b8598b2bcb3af5e158c61cb2d30821220a5034e92a74c6a4ef116d82a7f" "checksum pallet-transaction-payment-rpc-runtime-api 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)" = "40f6cc2ebdaff949b9f38cc03f19e541bd22773ce32e84532ac1d85a481cb112" @@ -2589,8 +2538,9 @@ dependencies = [ "checksum serde_derive 1.0.106 (git+https://github.com/mesalock-linux/serde-sgx)" = "" "checksum serde_derive 1.0.110 (registry+https://github.com/rust-lang/crates.io-index)" = "818fbf6bfa9a42d3bfcaca148547aa00c7b915bec71d1757aa2d44ca68771984" "checksum serde_json 1.0.51 (git+https://github.com/mesalock-linux/serde-json-sgx?rev=sgx_1.1.2)" = "" -"checksum sgx-externalities 0.2.0 (git+https://github.com/encointer/sgx-runtime?tag=v0.6.10-sub2.0.0-alpha.7)" = "" -"checksum sgx-runtime 2.0.0-alpha.7 (git+https://github.com/encointer/sgx-runtime?tag=v0.6.10-sub2.0.0-alpha.7)" = "" +"checksum sgx-externalities 0.2.0 (git+https://github.com/scs/sgx-runtime)" = "" +"checksum sgx-externalities 0.2.0 (git+https://github.com/scs/sgx-runtime?tag=v2.0.0-alpha.7)" = "" +"checksum sgx-runtime 2.0.0-alpha.7 (git+https://github.com/scs/sgx-runtime?tag=v2.0.0-alpha.7)" = "" "checksum sgx_alloc 1.1.2 (git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2)" = "" "checksum sgx_backtrace_sys 1.1.2 (git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2)" = "" "checksum sgx_build_helper 0.1.3 (git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2)" = "" @@ -2625,7 +2575,8 @@ dependencies = [ "checksum sp-finality-grandpa 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)" = "c91cc8d9e62f28d3dd90c3e4291f26147c5094f6f2587aeea4301bf3731d4a3c" "checksum sp-finality-tracker 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)" = "8f050f19f1e07b63f61a872552fecf7239c75e77dc133a5f5ae00dac0e7b348d" "checksum sp-inherents 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)" = "8367b0e285f8c3ab00400a5f5b53ff0dba263005d2458fdc3e9652f824205f0b" -"checksum sp-io 2.0.0-alpha.7 (git+https://github.com/encointer/sgx-runtime?tag=v0.6.10-sub2.0.0-alpha.7)" = "" +"checksum sp-io 2.0.0-alpha.7 (git+https://github.com/scs/sgx-runtime)" = "" +"checksum sp-io 2.0.0-alpha.7 (git+https://github.com/scs/sgx-runtime?tag=v2.0.0-alpha.7)" = "" "checksum sp-offchain 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)" = "e63092c0ecd8fc90971a14a169f62337b78d885873e55dee87f33fe5f76d6591" "checksum sp-runtime 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)" = "0d37f6a2e111dd82dd194fa9ef77ba49b17e70162afc237f99e7c5dc6f95834f" "checksum sp-runtime-interface 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)" = "bc743ea280556cbaf82203ec63ade39f4167402cb571aaf012c6c43f092ccf33" @@ -2645,7 +2596,6 @@ dependencies = [ "checksum static_assertions 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" "checksum stream-cipher 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8131256a5896cabcf5eb04f4d6dacbe1aefda854b0d9896e09cb58829ec5638c" "checksum substrate-api-client 0.4.6-sub2.0.0-alpha.7 (git+https://github.com/scs/substrate-api-client?tag=v0.4.6-sub2.0.0-alpha.7)" = "" -"checksum substrate-fixed 0.5.4 (git+https://github.com/encointer/substrate-fixed?tag=v0.5.4+sub_v0.1)" = "" "checksum substrate-wasm-builder-runner 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "d2a965994514ab35d3893e9260245f2947fd1981cdd4fffd2c6e6d1a9ce02e6a" "checksum subtle 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2d67a5a62ba6e01cb2192ff309324cb4875d0c451d55fe2319433abe7a05a8ee" "checksum subtle 2.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7c65d530b10ccaeac294f349038a597e435b18fb456aadd0840a623f83b9e941" diff --git a/enclave/Cargo.toml b/enclave/Cargo.toml index 8ecada9dba..0f5868270d 100644 --- a/enclave/Cargo.toml +++ b/enclave/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "substratee-worker-enclave" -version = "0.6.5-sub2.0.0-alpha.7" +version = "0.6.11-sub2.0.0-alpha.7" authors = ["Supercomputing Systems AG "] edition = "2018" diff --git a/enclave/chain_relay/Cargo.toml b/enclave/chain_relay/Cargo.toml index bbc38e4824..a66d2008a8 100644 --- a/enclave/chain_relay/Cargo.toml +++ b/enclave/chain_relay/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "chain-relay" -version = "0.6.8-sub2.0.0-alpha.7" +version = "0.6.11-sub2.0.0-alpha.7" authors = ["Supercomputing Systems AG "] edition = "2018" diff --git a/stf/Cargo.toml b/stf/Cargo.toml index 6b7ae1581f..46387e453c 100644 --- a/stf/Cargo.toml +++ b/stf/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "substratee-stf" -version = "0.6.8-sub2.0.0-alpha.7" +version = "0.6.11-sub2.0.0-alpha.7" authors = ["Supercomputing Systems AG "] edition = "2018" diff --git a/substratee-node-primitives/Cargo.toml b/substratee-node-primitives/Cargo.toml index 73ff439c31..d0cc9fc590 100644 --- a/substratee-node-primitives/Cargo.toml +++ b/substratee-node-primitives/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "substratee-node-primitives" -version = "0.6.8-sub2.0.0-alpha.7" +version = "0.6.11-sub2.0.0-alpha.7" authors = ["clangenbacher "] edition = "2018" diff --git a/worker/Cargo.toml b/worker/Cargo.toml index df8c097462..0a50c3b900 100644 --- a/worker/Cargo.toml +++ b/worker/Cargo.toml @@ -1,11 +1,6 @@ [package] -<<<<<<< HEAD name = "substratee-worker" -version = "0.6.5-sub2.0.0-alpha.7" -======= -name = "encointer-worker" -version = "0.6.8-sub2.0.0-alpha.7" ->>>>>>> a8772b6... update Block number in state and apply demurrage in client (#17) +version = "0.6.11-sub2.0.0-alpha.7" authors = ["Supercomputing Systems AG "] build = "build.rs" edition = "2018" diff --git a/worker/worker-api/Cargo.toml b/worker/worker-api/Cargo.toml index f65cfe8c00..6a02d22d23 100644 --- a/worker/worker-api/Cargo.toml +++ b/worker/worker-api/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "substratee-worker-api" -version = "0.6.8-sub2.0.0-alpha.7" +version = "0.6.11-sub2.0.0-alpha.7" authors = ["Supercomputing Systems AG "] edition = "2018" From e13c5d935f7b2080b2cd9c9c7132d909c44d8de0 Mon Sep 17 00:00:00 2001 From: Alain Brenzikofer Date: Tue, 8 Sep 2020 23:48:36 +0200 Subject: [PATCH 20/29] fixed stf cli. client and worker build successfully --- Cargo.lock | 8 +- enclave/Cargo.lock | 29 ++--- stf/Cargo.toml | 12 -- stf/src/cli.rs | 284 +++++++++++++++------------------------------ stf/src/lib.rs | 2 +- stf/src/sgx.rs | 38 +++--- 6 files changed, 131 insertions(+), 242 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c71164f539..4523bfca33 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3884,7 +3884,7 @@ dependencies = [ [[package]] name = "substratee-node-primitives" -version = "0.6.5-sub2.0.0-alpha.7" +version = "0.6.11-sub2.0.0-alpha.7" dependencies = [ "base58", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3932,7 +3932,7 @@ dependencies = [ [[package]] name = "substratee-stf" -version = "0.6.5-sub2.0.0-alpha.7" +version = "0.6.11-sub2.0.0-alpha.7" dependencies = [ "base58", "clap", @@ -3957,7 +3957,7 @@ dependencies = [ [[package]] name = "substratee-worker" -version = "0.6.5-sub2.0.0-alpha.7" +version = "0.6.11-sub2.0.0-alpha.7" dependencies = [ "base58", "cid", @@ -3997,7 +3997,7 @@ dependencies = [ [[package]] name = "substratee-worker-api" -version = "0.6.5-sub2.0.0-alpha.7" +version = "0.6.11-sub2.0.0-alpha.7" dependencies = [ "hex 0.4.2", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/enclave/Cargo.lock b/enclave/Cargo.lock index 46f09c191a..78327d03ba 100644 --- a/enclave/Cargo.lock +++ b/enclave/Cargo.lock @@ -225,7 +225,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "chain-relay" -version = "0.6.5-sub2.0.0-alpha.7" +version = "0.6.11-sub2.0.0-alpha.7" dependencies = [ "derive_more 0.99.5 (registry+https://github.com/rust-lang/crates.io-index)", "finality-grandpa 0.11.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -469,7 +469,7 @@ dependencies = [ "frame-metadata 11.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "frame-support-procedural 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "impl-trait-for-tuples 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (git+https://github.com/mesalock-linux/log-sgx)", "parity-scale-codec 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "paste 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "sp-arithmetic 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -811,14 +811,6 @@ dependencies = [ "sgx_tstd 1.1.2 (git+https://github.com/apache/teaclave-sgx-sdk.git?rev=v1.1.2)", ] -[[package]] -name = "log" -version = "0.4.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "memchr" version = "2.2.1" @@ -1952,7 +1944,7 @@ dependencies = [ "hash256-std-hasher 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", "hex 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "libsecp256k1 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (git+https://github.com/mesalock-linux/log-sgx)", "merlin 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2252,7 +2244,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "substratee-node-primitives" -version = "0.6.5-sub2.0.0-alpha.7" +version = "0.6.11-sub2.0.0-alpha.7" dependencies = [ "parity-scale-codec 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "primitive-types 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2262,7 +2254,7 @@ dependencies = [ [[package]] name = "substratee-stf" -version = "0.6.5-sub2.0.0-alpha.7" +version = "0.6.11-sub2.0.0-alpha.7" dependencies = [ "derive_more 0.99.5 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.7.1 (git+https://github.com/mesalock-linux/env_logger-sgx)", @@ -2281,12 +2273,12 @@ dependencies = [ [[package]] name = "substratee-worker-enclave" -version = "0.6.5-sub2.0.0-alpha.7" +version = "0.6.11-sub2.0.0-alpha.7" dependencies = [ "aes 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "base64 0.10.1 (git+https://github.com/mesalock-linux/rust-base64-sgx)", "bit-vec 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", - "chain-relay 0.6.5-sub2.0.0-alpha.7", + "chain-relay 0.6.11-sub2.0.0-alpha.7", "chrono 0.4.11 (git+https://github.com/mesalock-linux/chrono-sgx)", "cid 0.5.1 (git+https://github.com/whalelephant/rust-cid?branch=nstd)", "env_logger 0.7.1 (git+https://github.com/mesalock-linux/env_logger-sgx)", @@ -2323,8 +2315,8 @@ dependencies = [ "sp-runtime 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "sp-std 2.0.0-alpha.7 (registry+https://github.com/rust-lang/crates.io-index)", "substrate-api-client 0.4.6-sub2.0.0-alpha.7 (git+https://github.com/scs/substrate-api-client?tag=v0.4.6-sub2.0.0-alpha.7)", - "substratee-node-primitives 0.6.5-sub2.0.0-alpha.7", - "substratee-stf 0.6.5-sub2.0.0-alpha.7", + "substratee-node-primitives 0.6.11-sub2.0.0-alpha.7", + "substratee-stf 0.6.11-sub2.0.0-alpha.7", "webpki 0.21.2 (git+https://github.com/mesalock-linux/webpki?branch=mesalock_sgx)", "webpki-roots 0.19.0 (git+https://github.com/mesalock-linux/webpki-roots?branch=mesalock_sgx)", "yasna 0.3.1 (git+https://github.com/mesalock-linux/yasna.rs-sgx?rev=sgx_1.1.2)", @@ -2445,7 +2437,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "hash-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", "hashbrown 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (git+https://github.com/mesalock-linux/log-sgx)", "smallvec 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2671,7 +2663,6 @@ dependencies = [ "checksum libc 0.2.70 (registry+https://github.com/rust-lang/crates.io-index)" = "3baa92041a6fec78c687fa0cc2b3fae8884f743d672cf551bed1d6dac6988d0f" "checksum libsecp256k1 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "1fc1e2c808481a63dc6da2074752fdd4336a3c8fcc68b83db6f1fd5224ae7962" "checksum log 0.4.8 (git+https://github.com/mesalock-linux/log-sgx)" = "" -"checksum log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" "checksum memchr 2.2.1 (git+https://github.com/mesalock-linux/rust-memchr-sgx)" = "" "checksum memchr 2.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3728d817d99e5ac407411fa471ff9800a778d88a24685968b36824eaf4bee400" "checksum memory-db 0.20.1 (registry+https://github.com/rust-lang/crates.io-index)" = "be512cb2ccb4ecbdca937fdd4a62ea5f09f8e7195466a85e4632b3d5bcce82e6" diff --git a/stf/Cargo.toml b/stf/Cargo.toml index 46387e453c..f422ee444c 100644 --- a/stf/Cargo.toml +++ b/stf/Cargo.toml @@ -51,18 +51,6 @@ default-features = false package = 'pallet-balances' version = '2.0.0-alpha.7' -[dependencies.fixed] -default-features = false -git = "https://github.com/encointer/substrate-fixed" -tag = "v0.5.4+sub_v0.1" -package = "substrate-fixed" - -[dependencies.my-node-runtime] -git = "https://github.com/encointer/encointer-node" -branch = "sgx-master" -package = "encointer-node-teeproxy-runtime" -optional = true - [dependencies.system] default-features = false package = 'frame-system' diff --git a/stf/src/cli.rs b/stf/src/cli.rs index 598a9368e9..acffb95e1e 100644 --- a/stf/src/cli.rs +++ b/stf/src/cli.rs @@ -15,7 +15,7 @@ */ -use crate::{AccountId, ShardIdentifier, TrustedCall, TrustedGetter, PublicGetter, TrustedOperation, Attestation}; +use crate::{AccountId, ShardIdentifier, TrustedCall, TrustedGetter, TrustedOperation}; use base58::{FromBase58, ToBase58}; use clap::{Arg, ArgMatches}; use clap_nested::{Command, Commander, MultiCommand}; @@ -149,8 +149,7 @@ pub fn cmd<'a>( let top: TrustedOperation = TrustedCall::balance_transfer( sr25519_core::Public::from(from.public()), to, - shard, // for encointer we assume that every currency has its own shard. so shard == cid - BalanceType::from_num(amount)) + amount) .sign(&sr25519_core::Pair::from(from), nonce, &mrenclave, &shard) .into(); let _ = perform_operation(matches, &top); @@ -168,66 +167,8 @@ pub fn cmd<'a>( .value_name("SS58") .help("sender's AccountId in ss58check format"), ) - }) - .runner(move |_args: &str, matches: &ArgMatches<'_>| { - let arg_who = matches.value_of("accountid").unwrap(); - println!("arg_who = {:?}", arg_who); - let who = get_pair_from_str(matches, arg_who); - let (_mrenclave, shard) = get_identifiers(matches); - let top: TrustedOperation = TrustedGetter::balance(sr25519_core::Public::from(who.public()), shard) - .sign(&sr25519_core::Pair::from(who)) - .into(); - let res = perform_operation(matches, &top); - let bal = if let Some(v) = res { - if let Ok(vd) = >::decode(&mut v.as_slice()) { - let api = get_chain_api(matches); - let bn = get_block_number(&api); - let dr = get_demurrage_per_block(&api, shard); - debug!("will apply demurrage to {:?}. blocknumber {}, demurrage rate {}", vd, bn, dr); - apply_demurrage(vd, bn, dr) - } else { - info!("could not decode value. maybe hasn't been set? {:x?}", v); - BalanceType::from_num(0) - } - } else { - BalanceType::from_num(0) - }; - println!("{}", bal); - Ok(()) - }), - ) - .add_cmd( - Command::new("total-issuance") - .description("query total issuance for currency (public information)") - .runner(move |_args: &str, matches: &ArgMatches<'_>| { - let (_mrenclave, shard) = get_identifiers(matches); - let top: TrustedOperation = PublicGetter::total_issuance(shard) - .into(); - let res = perform_operation(matches, &top); - let bal = if let Some(v) = res { - if let Ok(vd) = >::decode(&mut v.as_slice()) { - let api = get_chain_api(matches); - let bn = get_block_number(&api); - let dr = get_demurrage_per_block(&api, shard); - debug!("will apply demurrage to {:?}. blocknumber {}, demurrage rate {}", vd, bn, dr); - apply_demurrage(vd, bn, dr) - } else { - info!("could not decode value. maybe hasn't been set? {:x?}", v); - BalanceType::from_num(0) - } - } else { - BalanceType::from_num(0) - }; - println!("{}", bal); - Ok(()) - }), - ) - .add_cmd( - Command::new("register-participant") - .description("register participant for next encointer ceremony") - .options(|app| { - app.arg( - Arg::with_name("accountid") + .arg( + Arg::with_name("amount") .takes_value(true) .required(true) .value_name("U128") @@ -241,20 +182,25 @@ pub fn cmd<'a>( let who = get_pair_from_str(matches, arg_who); let signer = get_pair_from_str(matches, "//AliceIncognito"); info!("account ss58 is {}", who.public().to_ss58check()); - - let (mrenclave, shard) = get_identifiers(matches); - let nonce = 0; // FIXME: hard coded for now + println!( - "send TrustedCall::register_participant for {}", + "send trusted call set-balance({}, {})", who.public(), + amount ); - let top: TrustedOperation = TrustedCall::ceremonies_register_participant( + + let (mrenclave, shard) = get_identifiers(matches); + + let nonce = 0; // FIXME: hard coded for now + + let top: TrustedOperation = TrustedCall::balance_set_balance( + sr25519_core::Public::from(signer.public()), sr25519_core::Public::from(who.public()), - shard, // for encointer we assume that every currency has its own shard. so shard == cid - None) - .sign(&sr25519_core::Pair::from(who), nonce, &mrenclave, &shard) + amount, + amount,) + .sign(&sr25519_core::Pair::from(signer), nonce, &mrenclave, &shard) .into(); - perform_operation(matches, &top); + let _ = perform_operation(matches, &top); Ok(()) }), ) @@ -275,19 +221,21 @@ pub fn cmd<'a>( println!("arg_who = {:?}", arg_who); let who = get_pair_from_str(matches, arg_who); let (_mrenclave, shard) = get_identifiers(matches); - println!( - "send TrustedGetter::get_registration for {}", - who.public() - ); - let top: TrustedOperation = TrustedGetter::registration( - sr25519_core::Public::from(who.public()), - shard, // for encointer we assume that every currency has its own shard. so shard == cid - ) + let top: TrustedOperation = TrustedGetter::free_balance(sr25519_core::Public::from(who.public())) .sign(&sr25519_core::Pair::from(who)) .into(); - let part = perform_operation(matches, &top).unwrap(); - let participant: ParticipantIndexType = Decode::decode(&mut part.as_slice()).unwrap(); - println!("Participant index: {:?}", participant); + let res = perform_operation(matches, &top); + let bal = if let Some(v) = res { + if let Ok(vd) = crate::Balance::decode(&mut v.as_slice()) { + vd + } else { + info!("could not decode value. maybe hasn't been set? {:x?}", v); + 0 + } + } else { + 0 + }; + println!("{}", bal); Ok(()) }), ) @@ -302,76 +250,15 @@ pub fn cmd<'a>( .value_name("SS58") .help("Sender's incognito AccountId in ss58check format"), ) - .arg( - Arg::with_name("attestations") - .takes_value(true) - .required(true) - .multiple(true) - .min_values(2) - ) - }) - .runner(move |_args: &str, matches: &ArgMatches<'_>| { - let arg_who = matches.value_of("accountid").unwrap(); - let who = get_pair_from_str(matches, arg_who); - let (mrenclave, shard) = get_identifiers(matches); - let nonce = 0; // FIXME: hard coded for now - let attestation_args: Vec<_> = matches.values_of("attestations").unwrap().collect(); - let mut attestations: Vec> = vec![]; - for arg in attestation_args.iter() { - let w = Attestation::decode(&mut &hex::decode(arg).unwrap()[..]).unwrap(); - attestations.push(w); - } - println!( - "send TrustedCall::register_attestations for {}", - who.public() - ); - let top: TrustedOperation = TrustedCall::ceremonies_register_attestations( - sr25519_core::Public::from(who.public()), - attestations - ) - .sign(&sr25519_core::Pair::from(who), nonce, &mrenclave, &shard) - .into(); - perform_operation(matches, &top); - Ok(()) - }), - ) - .add_cmd( - Command::new("get-attestations") - .description("get attestations registration index for this encointer ceremony") - .options(|app| { - app.arg( - Arg::with_name("accountid") + .arg( + Arg::with_name("to") .takes_value(true) .required(true) .value_name("SS58") .help("Recipient's on-chain AccountId in ss58check format"), ) - }) - .runner(move |_args: &str, matches: &ArgMatches<'_>| { - let arg_who = matches.value_of("accountid").unwrap(); - let who = get_pair_from_str(matches, arg_who); - let (_mrenclave, shard) = get_identifiers(matches); - println!( - "send TrustedGetter::get_attestations for {}", - who.public(), - ); - let top: TrustedOperation = TrustedGetter::attestations( - sr25519_core::Public::from(who.public()), - shard, // for encointer we assume that every currency has its own shard. so shard == cid - ) - .sign(&sr25519_core::Pair::from(who)) - .into(); - let attestations = perform_operation(matches, &top).unwrap(); - println!("Attestations: {:?}", hex::encode(attestations)); - Ok(()) - }), - ) - .add_cmd( - Command::new("new-claim") - .description("read current ceremony phase from chain") - .options(|app| { - app.arg( - Arg::with_name("accountid") + .arg( + Arg::with_name("amount") .takes_value(true) .required(true) .value_name("U128") @@ -386,40 +273,33 @@ pub fn cmd<'a>( ) }) .runner(move |_args: &str, matches: &ArgMatches<'_>| { - let arg_who = matches.value_of("accountid").unwrap(); - // println!("arg_who = {:?}", arg_who); - let who = get_pair_from_str(matches, arg_who); - - let n_participants = matches - .value_of("n-participants") - .unwrap() - .parse::() - .unwrap(); + let arg_from = matches.value_of("from").unwrap(); + let arg_to = matches.value_of("to").unwrap(); + let amount = u128::from_str_radix(matches.value_of("amount").unwrap(), 10) + .expect("amount can be converted to u128"); + let from = get_pair_from_str(matches, arg_from); + let to = get_accountid_from_str(arg_to); + println!("from ss58 is {}", from.public().to_ss58check()); + println!("to ss58 is {}", to.to_ss58check()); - let (_mrenclave, shard) = get_identifiers(matches); - let top: TrustedOperation = TrustedGetter::meetup_index_time_and_location(who.public().into(), shard) - .sign(&sr25519_core::Pair::from(who.clone())) - .into(); + println!( + "send trusted call unshield_funds from {} to {}: {}", + from.public(), + to, + amount + ); - let res = perform_operation(matches, &top).unwrap(); - let (mindex, mlocation, mtime): (MeetupIndexType, Option, Option) = Decode::decode(&mut res.as_slice()).unwrap(); - info!("got mindex: {:?}", mindex); - info!("got time: {:?}", mtime); - info!("got location: {:?}", mlocation); - let api = get_chain_api(matches); - let cindex = api.get_storage_value("EncointerScheduler", "CurrentCeremonyIndex", None) - .unwrap(); + let (mrenclave, shard) = get_identifiers(matches); + let nonce = 0; // FIXME: hard coded for now - let tcall = TrustedCall::balance_unshield( + let top: TrustedOperation = TrustedCall::balance_unshield( sr25519_core::Public::from(from.public()), to, amount, - shard, - ); - let nonce = 0; // FIXME: hard coded for now - let tscall = - tcall.sign(&sr25519_core::Pair::from(from), nonce, &mrenclave, &shard); - perform_operation(matches, &TrustedOperationSigned::call(tscall)); + shard) + .sign(&sr25519_core::Pair::from(from), nonce, &mrenclave, &shard) + .into(); + let _ = perform_operation(matches, &top); Ok(()) }), ) @@ -510,21 +390,43 @@ pub fn call_trusted_stf( let xt = compose_extrinsic!(api.clone(), "SubstraTEERegistry", "call_worker", request); -fn get_demurrage_per_block(api: &Api, cid: CurrencyIdentifier) -> BalanceType { - let cp: CurrencyPropertiesType = api - .get_storage_map("EncointerCurrencies", "CurrencyProperties", cid, None) - .unwrap(); - debug!("CurrencyProperties are {:?}", cp); - cp.demurrage_per_block + // send and watch extrinsic until finalized + let tx_hash = api.send_extrinsic(xt.hex_encode()).unwrap(); + info!("stf call extrinsic got finalized. Hash: {:?}", tx_hash); + info!("waiting for confirmation of stf call"); + let act_hash = subscribe_to_call_confirmed(api.clone()); + info!("callConfirmed event received"); + debug!( + "Expected stf call Hash: {:?}", + blake2s(32, &[0; 32], &call_encrypted).as_bytes() + ); + debug!("confirmation stf call Hash: {:?}", act_hash); } -fn apply_demurrage(entry: BalanceEntry, current_block: BlockNumber, demurrage_per_block: BalanceType) -> BalanceType { - let elapsed_time_block_number = current_block.checked_sub(entry.last_update).unwrap(); - let elapsed_time_u32: u32 = elapsed_time_block_number.into(); - let elapsed_time = BalanceType::from_num(elapsed_time_u32); - let exponent : BalanceType = -demurrage_per_block * elapsed_time; - debug!("demurrage per block {}, current_block {}, last {}, elapsed_blocks {}", demurrage_per_block, current_block, entry.last_update, elapsed_time); - let exp_result : BalanceType = exp(exponent).unwrap(); - entry.principal.checked_mul(exp_result).unwrap() +pub fn get_trusted_stf_state( + workerapi: &WorkerApi, + getter: TrustedGetterSigned, + shard: &ShardIdentifier, +) { + //TODO: #91 + // encrypt getter + // decrypt response and verify signature + debug!("calling workerapi to get value"); + let ret = workerapi + .get_stf_state(getter, shard) + .expect("getting value failed"); + let ret_cropped = &ret[..9 * 2]; + debug!( + "got getter response from worker: {:?}\ncropping to {:?}", + ret, ret_cropped + ); + let valopt: Option> = Decode::decode(&mut &ret_cropped[..]).unwrap(); + match valopt { + Some(v) => { + let value = U256::from_little_endian(&v); + println!(" value = {}", value); + } + _ => error!("error getting value"), + }; } - +*/ diff --git a/stf/src/lib.rs b/stf/src/lib.rs index 61dd00a684..b8d590c1db 100644 --- a/stf/src/lib.rs +++ b/stf/src/lib.rs @@ -111,7 +111,7 @@ impl From for Getter { #[derive(Encode, Decode, Clone, Debug)] #[allow(non_camel_case_types)] pub enum PublicGetter { - total_issuance(CurrencyIdentifier), + some_value, } #[derive(Encode, Decode, Clone, Debug)] diff --git a/stf/src/sgx.rs b/stf/src/sgx.rs index 149972141d..a6a92049d7 100644 --- a/stf/src/sgx.rs +++ b/stf/src/sgx.rs @@ -134,22 +134,30 @@ impl Stf { } pub fn get_state(ext: &mut State, getter: TrustedGetter) -> Option> { - ext.execute_with(|| match getter { - TrustedGetter::free_balance(who) => { - if let Some(info) = get_account_info(&who) { - debug!("AccountInfo for {:?} is {:?}", who, info); - Some(info.data.free.encode()) - } else { - None - } - } - TrustedGetter::reserved_balance(who) => { - if let Some(info) = get_account_info(&who) { - debug!("AccountInfo for {:?} is {:?}", who, info); - Some(info.data.reserved.encode()) - } else { - None + ext.execute_with(|| + match getter { + Getter::trusted(g) => match g.getter { + TrustedGetter::free_balance(who) => { + if let Some(info) = get_account_info(&who) { + debug!("AccountInfo for {:?} is {:?}", who, info); + Some(info.data.free.encode()) + } else { + None + } } + TrustedGetter::reserved_balance(who) => { + if let Some(info) = get_account_info(&who) { + debug!("AccountInfo for {:?} is {:?}", who, info); + Some(info.data.reserved.encode()) + } else { + None + } + }, + }, + Getter::public(g) => match g { + PublicGetter::some_value => { + Some(42u32.encode()) + }, } ) } From daa30b95487510831281b4a9231b44034da001ea Mon Sep 17 00:00:00 2001 From: Alain Brenzikofer Date: Wed, 9 Sep 2020 00:10:51 +0200 Subject: [PATCH 21/29] some worker fixes --- client/Cargo.toml | 2 +- stf/src/sgx.rs | 29 ++++++++++++----------------- 2 files changed, 13 insertions(+), 18 deletions(-) diff --git a/client/Cargo.toml b/client/Cargo.toml index 9ead5b19e2..a7dd77d2a2 100644 --- a/client/Cargo.toml +++ b/client/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "substratee-client" -version = "0.6.5-sub2.0.0-alpha.7" +version = "0.6.11-sub2.0.0-alpha.7" authors = ["Supercomputing Systems AG "] edition = "2018" diff --git a/stf/src/sgx.rs b/stf/src/sgx.rs index a6a92049d7..a8a82bfbd4 100644 --- a/stf/src/sgx.rs +++ b/stf/src/sgx.rs @@ -6,7 +6,7 @@ use codec::{Decode, Encode}; use derive_more::Display; use log_sgx::*; use metadata::StorageHasher; -use sgx_runtime::{Balance, Runtime}; +use sgx_runtime::{Balance, Runtime, BlockNumber}; use sp_core::crypto::AccountId32; use sp_io::SgxExternalitiesTrait; use sp_runtime::traits::Dispatchable; @@ -69,14 +69,16 @@ impl Stf { ext } - pub fn update_storage(ext: &mut State, map_update: &HashMap, Vec>) { + pub fn update_storage(ext: &mut State, map_update: &HashMap, Option>>) { ext.execute_with(|| { - map_update.iter().for_each(|(k, v)| { - match v { - Some(value) => sp_io::storage::set(k, value), - None => sp_io::storage::clear(k), - }; - }); + map_update + .iter() + .for_each(|(k, v)| { + match v { + Some(value) => sp_io::storage::set(k, value), + None => sp_io::storage::clear(k) + }; + }); }); } @@ -133,7 +135,7 @@ impl Stf { }) } - pub fn get_state(ext: &mut State, getter: TrustedGetter) -> Option> { + pub fn get_state(ext: &mut State, getter: Getter) -> Option> { ext.execute_with(|| match getter { Getter::trusted(g) => match g.getter { @@ -159,6 +161,7 @@ impl Stf { Some(42u32.encode()) }, } + } ) } @@ -170,14 +173,6 @@ impl Stf { } } - fn ensure_root(account: AccountId) -> Result<(), StfError> { - if sp_io::storage::get(&storage_value_key("Sudo", "Key")).unwrap() == account.encode() { - Ok(()) - } else { - Err(StfError::MissingPrivileges(account)) - } - } - fn shield_funds(account: AccountId, amount: u128) -> Result<(), StfError> { match get_account_info(&account) { Some(account_info) => sgx_runtime::BalancesCall::::set_balance( From a0da29c30cf0ed2d8bd8289ec6238d1f734aca98 Mon Sep 17 00:00:00 2001 From: Alain Brenzikofer Date: Wed, 9 Sep 2020 08:47:38 +0200 Subject: [PATCH 22/29] building works --- Cargo.lock | 2 +- enclave/src/lib.rs | 8 ++++---- stf/src/sgx.rs | 12 +++++++++++- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4523bfca33..7fa67858c8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3852,7 +3852,7 @@ checksum = "d2a965994514ab35d3893e9260245f2947fd1981cdd4fffd2c6e6d1a9ce02e6a" [[package]] name = "substratee-client" -version = "0.6.5-sub2.0.0-alpha.7" +version = "0.6.11-sub2.0.0-alpha.7" dependencies = [ "base58", "blake2-rfc", diff --git a/enclave/src/lib.rs b/enclave/src/lib.rs index 0a78c11557..2abc6170cc 100644 --- a/enclave/src/lib.rs +++ b/enclave/src/lib.rs @@ -37,9 +37,6 @@ use sgx_types::{sgx_epid_group_id_t, sgx_status_t, sgx_target_info_t, size_t, Sg use substrate_api_client::{compose_extrinsic_offline, utils::storage_key}; use substratee_node_primitives::{CallWorkerFn, ShieldFundsFn}; -use substratee_stf::{ - ShardIdentifier, Stf, TrustedCallSigned, Getter, -}; use codec::{Decode, Encode}; use sp_core::{crypto::Pair, hashing::blake2_256}; @@ -65,6 +62,9 @@ use chain_relay::{ use sp_runtime::OpaqueExtrinsic; use sp_runtime::{generic::SignedBlock, traits::Header as HeaderT}; use substrate_api_client::extrinsic::xt_primitives::UncheckedExtrinsicV4; +use substratee_stf::{ + AccountId, ShardIdentifier, Stf, TrustedCall, TrustedCallSigned, Getter, +}; use substratee_stf::sgx::{shards_key_hash, storage_hashes_to_update_per_shard, OpaqueCall}; mod aes; @@ -586,7 +586,7 @@ fn handle_call_worker_xt( fn verify_worker_responses( responses: Vec>>, header: Header, -) -> SgxResult, Vec>> { +) -> SgxResult, Option>>> { let mut update_map = HashMap::new(); for response in responses.iter() { match response { diff --git a/stf/src/sgx.rs b/stf/src/sgx.rs index a8a82bfbd4..cbd5ef793a 100644 --- a/stf/src/sgx.rs +++ b/stf/src/sgx.rs @@ -12,7 +12,7 @@ use sp_io::SgxExternalitiesTrait; use sp_runtime::traits::Dispatchable; use crate::{ - AccountId, State, Stf, TrustedCall, TrustedCallSigned, Getter, PublicGetter, TrustedGetter, TrustedGetterSigned, ShardIdentifier, + AccountId, State, Stf, TrustedCall, TrustedCallSigned, Getter, PublicGetter, TrustedGetter, ShardIdentifier, SUBSRATEE_REGISTRY_MODULE, UNSHIELD, }; use sp_core::blake2_256; @@ -240,6 +240,16 @@ impl Stf { } } +pub fn storage_hashes_to_update_per_shard(_shard: &ShardIdentifier) -> Vec> { + Vec::new() +} + +pub fn shards_key_hash() -> Vec { + // here you have to point to a storage value containing a Vec of ShardIdentifiers + // the enclave uses this to autosubscribe to no shards + storage_value_key("EncointerCurrencies", "CurrencyIdentifiers") +} + // get the AccountInfo key where the nonce is stored pub fn nonce_key_hash(account: &AccountId) -> Vec { storage_map_key( From 15fc7cda48bf0379d1e0423aaef9df2181dc4723 Mon Sep 17 00:00:00 2001 From: Alain Brenzikofer Date: Wed, 9 Sep 2020 09:13:49 +0200 Subject: [PATCH 23/29] don't request key provisioning form other worker --- worker/src/main.rs | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/worker/src/main.rs b/worker/src/main.rs index da1e65d46e..37375a5dc2 100644 --- a/worker/src/main.rs +++ b/worker/src/main.rs @@ -273,27 +273,27 @@ fn worker(w_ip: &str, w_port: &str, mu_ra_port: &str, shard: &ShardIdentifier) { let tx_hash = api.send_extrinsic(_xthex, XtStatus::InBlock).unwrap(); println!("[<] Extrinsic got finalized. Hash: {:?}\n", tx_hash); - // browse enclave registry - match get_first_worker_that_is_not_equal_to_self(&api, &tee_accountid) { - Some(w) => { - let _url = String::from_utf8_lossy(&w.url[..]).to_string(); - let _w_api = WorkerApi::new(_url.clone()); - let _url_split: Vec<_> = _url.split(':').collect(); - let mura_url = format!("{}:{}", _url_split[0], _w_api.get_mu_ra_port().unwrap()); - - info!("Requesting key provisioning from worker at {}", mura_url); - enclave_request_key_provisioning( - eid, - sgx_quote_sign_type_t::SGX_UNLINKABLE_SIGNATURE, - &mura_url, - ) - .unwrap(); - debug!("key provisioning successfully performed"); - } - None => { - info!("there are no other workers"); - } - } + // // browse enclave registry + // match get_first_worker_that_is_not_equal_to_self(&api, &tee_accountid) { + // Some(w) => { + // let _url = String::from_utf8_lossy(&w.url[..]).to_string(); + // let _w_api = WorkerApi::new(_url.clone()); + // let _url_split: Vec<_> = _url.split(':').collect(); + // let mura_url = format!("{}:{}", _url_split[0], _w_api.get_mu_ra_port().unwrap()); + + // info!("Requesting key provisioning from worker at {}", mura_url); + // enclave_request_key_provisioning( + // eid, + // sgx_quote_sign_type_t::SGX_UNLINKABLE_SIGNATURE, + // &mura_url, + // ) + // .unwrap(); + // debug!("key provisioning successfully performed"); + // } + // None => { + // info!("there are no other workers"); + // } + // } let mut latest_head = init_chain_relay(eid, &api); From e9efdc4fda0c56baaefaba1cecfc015f1b36e389 Mon Sep 17 00:00:00 2001 From: Alain Brenzikofer Date: Wed, 9 Sep 2020 09:55:27 +0200 Subject: [PATCH 24/29] fix --- enclave/src/lib.rs | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/enclave/src/lib.rs b/enclave/src/lib.rs index 2abc6170cc..1b5d139b69 100644 --- a/enclave/src/lib.rs +++ b/enclave/src/lib.rs @@ -372,10 +372,6 @@ pub unsafe extern "C" fn sync_chain_relay( Ok(c) => calls.extend(c.into_iter()), Err(_) => error!("Error executing relevant extrinsics"), }; - - if update_states(signed_block.block.header).is_err() { - error!("Error performing state updates upon block import") - } } if let Err(_e) = stf_post_actions(validator, calls, xt_slice, *nonce) { @@ -497,17 +493,17 @@ fn handle_shield_funds_xt( error!("Error performing Stf::execute. Error: {:?}", e); return Ok(()); } - let xt_call = [SUBSRATEE_REGISTRY_MODULE, CALL_CONFIRMED]; + let state_hash = state::write(state, &shard)?; + + let xt_call = [SUBSRATEE_REGISTRY_MODULE, CALL_CONFIRMED]; + let call_hash = blake2_256(&xt.encode()); + debug!("Call hash 0x{}", hex::encode_hex(&call_hash)); + calls.push(OpaqueCall( - ( - xt_call, - shard, - blake2_256(&xt.encode()), - state_hash.encode(), - ) - .encode(), + (xt_call, shard, call_hash, state_hash.encode()).encode(), )); + Ok(()) } From e4b9bc5aa81d9558d37d27c33d87d23a37b94272 Mon Sep 17 00:00:00 2001 From: Alain Brenzikofer Date: Wed, 9 Sep 2020 10:48:41 +0200 Subject: [PATCH 25/29] more stf debug output --- stf/src/sgx.rs | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/stf/src/sgx.rs b/stf/src/sgx.rs index cbd5ef793a..13230f2eb7 100644 --- a/stf/src/sgx.rs +++ b/stf/src/sgx.rs @@ -98,23 +98,31 @@ impl Stf { ext.execute_with(|| match call.call { TrustedCall::balance_set_balance(root, who, free_balance, reserved_balance) => { Self::ensure_root(root)?; + debug!("balance_set_balance({:?}, {}, {})", who, free_balance, reserved_balance); sgx_runtime::BalancesCall::::set_balance( AccountId32::from(who), free_balance, reserved_balance, ) .dispatch(sgx_runtime::Origin::ROOT) - .map_err(|_| StfError::Dispatch)?; + .map_err(|_| StfError::Dispatch("balance_set_balance".to_string()))?; Ok(()) } TrustedCall::balance_transfer(from, to, value) => { let origin = sgx_runtime::Origin::signed(AccountId32::from(from)); + debug!("balance_transfer({:?}, {:?}, {})", from, to, value); + if let Some(info) = get_account_info(&from) { + debug!("sender balance is {}", info.data.free); + } else { + debug!("sender balance is zero"); + } sgx_runtime::BalancesCall::::transfer(AccountId32::from(to), value) .dispatch(origin) - .map_err(|_| StfError::Dispatch)?; + .map_err(|_| StfError::Dispatch("balance_transfer".to_string()))?; Ok(()) } TrustedCall::balance_unshield(account_incognito, beneficiary, value, shard) => { + debug!("balance_unshield({:?}, {:?}, {}, {})", account_incognito, beneficiary, value, shard); Self::unshield_funds(account_incognito, value)?; calls.push(OpaqueCall( ( @@ -129,6 +137,7 @@ impl Stf { Ok(()) } TrustedCall::balance_shield(who, value) => { + debug!("balance_shield({:?}, {})", who, value); Self::shield_funds(who, value)?; Ok(()) } @@ -181,10 +190,10 @@ impl Stf { account_info.data.reserved, ) .dispatch(sgx_runtime::Origin::ROOT) - .map_err(|_| StfError::Dispatch)?, + .map_err(|_| StfError::Dispatch("shield_funds".to_string()))?, None => sgx_runtime::BalancesCall::::set_balance(account.into(), amount, 0) .dispatch(sgx_runtime::Origin::ROOT) - .map_err(|_| StfError::Dispatch)?, + .map_err(|_| StfError::Dispatch("shield_funds::set_balance".to_string()))?, }; Ok(()) } @@ -202,7 +211,7 @@ impl Stf { account_info.data.reserved, ) .dispatch(sgx_runtime::Origin::ROOT) - .map_err(|_| StfError::Dispatch)?; + .map_err(|_| StfError::Dispatch("unshield_funds::set_balance".to_string()))?; Ok(()) } None => Err(StfError::InexistentAccount(account)), @@ -337,7 +346,7 @@ pub enum StfError { #[display(fmt = "Insufficient privileges {:?}, are you sure you are root?", _0)] MissingPrivileges(AccountId), #[display(fmt = "Error dispatching runtime call")] - Dispatch, + Dispatch(String), #[display(fmt = "Not enough funds to perform operation")] MissingFunds, #[display(fmt = "Account does not exist {:?}", _0)] From 68d66799f770fc6a863da966107abca185a50203 Mon Sep 17 00:00:00 2001 From: Alain Brenzikofer Date: Wed, 9 Sep 2020 17:14:37 +0200 Subject: [PATCH 26/29] fix demo shielding example --- enclave/src/lib.rs | 8 ++++---- enclave/src/state.rs | 7 ++++++- stf/src/sgx.rs | 20 +++++++++++--------- 3 files changed, 21 insertions(+), 14 deletions(-) diff --git a/enclave/src/lib.rs b/enclave/src/lib.rs index 1b5d139b69..e78b19ce7c 100644 --- a/enclave/src/lib.rs +++ b/enclave/src/lib.rs @@ -464,8 +464,8 @@ fn handle_shield_funds_xt( xt: UncheckedExtrinsicV4, ) -> SgxResult<()> { let (call, account_encrypted, amount, shard) = xt.function.clone(); - info!("Found ShieldFunds extrinsic in block: \nCall: {:?} \nAccount Encrypted {:?} \nAmount: {} \nShard: {:?}", - call, account_encrypted, amount, shard + info!("Found ShieldFunds extrinsic in block: \nCall: {:?} \nAccount Encrypted {:?} \nAmount: {} \nShard: {}", + call, account_encrypted, amount, shard.encode().to_base58(), ); let mut state = if state::exists(&shard) { @@ -485,8 +485,8 @@ fn handle_shield_funds_xt( &mut state, TrustedCallSigned::new( TrustedCall::balance_shield(account, amount), - 0, - Default::default(), + 0, //nonce + Default::default(), //don't care about signature here ), calls, ) { diff --git a/enclave/src/state.rs b/enclave/src/state.rs index 3fdb89812f..77fcbd57d8 100644 --- a/enclave/src/state.rs +++ b/enclave/src/state.rs @@ -77,7 +77,7 @@ pub fn write(state: StfState, shard: &ShardIdentifier) -> SgxResult { Err(status) => return Err(status), }; - debug!("new state with hash=0x{} written to {}", hex::encode_hex(&state_hash), state_path); + debug!("new encrypted state with hash=0x{} written to {}", hex::encode_hex(&state_hash), state_path); io::write(&cyphertext, &state_path)?; Ok(state_hash.into()) @@ -105,6 +105,11 @@ fn read(path: &str) -> SgxResult> { }, Err(e) => return Err(e), }; + let state_hash = match rsgx_sha256_slice(&bytes) { + Ok(h) => h, + Err(status) => return Err(status), + }; + debug!("read encrypted state with hash 0x{} from {}", hex::encode_hex(&state_hash), path); aes::de_or_encrypt(&mut bytes)?; trace!("buffer decrypted = {:?}", bytes); diff --git a/stf/src/sgx.rs b/stf/src/sgx.rs index 13230f2eb7..06fbfa0605 100644 --- a/stf/src/sgx.rs +++ b/stf/src/sgx.rs @@ -98,7 +98,7 @@ impl Stf { ext.execute_with(|| match call.call { TrustedCall::balance_set_balance(root, who, free_balance, reserved_balance) => { Self::ensure_root(root)?; - debug!("balance_set_balance({:?}, {}, {})", who, free_balance, reserved_balance); + debug!("balance_set_balance({:x?}, {}, {})", who.encode(), free_balance, reserved_balance); sgx_runtime::BalancesCall::::set_balance( AccountId32::from(who), free_balance, @@ -110,7 +110,7 @@ impl Stf { } TrustedCall::balance_transfer(from, to, value) => { let origin = sgx_runtime::Origin::signed(AccountId32::from(from)); - debug!("balance_transfer({:?}, {:?}, {})", from, to, value); + debug!("balance_transfer({:x?}, {:x?}, {})", from.encode(), to.encode(), value); if let Some(info) = get_account_info(&from) { debug!("sender balance is {}", info.data.free); } else { @@ -122,7 +122,7 @@ impl Stf { Ok(()) } TrustedCall::balance_unshield(account_incognito, beneficiary, value, shard) => { - debug!("balance_unshield({:?}, {:?}, {}, {})", account_incognito, beneficiary, value, shard); + debug!("balance_unshield({:x?}, {:x?}, {}, {})", account_incognito.encode(), beneficiary.encode(), value, shard); Self::unshield_funds(account_incognito, value)?; calls.push(OpaqueCall( ( @@ -137,7 +137,7 @@ impl Stf { Ok(()) } TrustedCall::balance_shield(who, value) => { - debug!("balance_shield({:?}, {})", who, value); + debug!("balance_shield({:x?}, {})", who.encode(), value); Self::shield_funds(who, value)?; Ok(()) } @@ -150,7 +150,8 @@ impl Stf { Getter::trusted(g) => match g.getter { TrustedGetter::free_balance(who) => { if let Some(info) = get_account_info(&who) { - debug!("AccountInfo for {:?} is {:?}", who, info); + debug!("AccountInfo for {:x?} is {:?}", who.encode(), info); + debug!("Account free balance is {}", info.data.free); Some(info.data.free.encode()) } else { None @@ -158,7 +159,8 @@ impl Stf { } TrustedGetter::reserved_balance(who) => { if let Some(info) = get_account_info(&who) { - debug!("AccountInfo for {:?} is {:?}", who, info); + debug!("AccountInfo for {:x?} is {:?}", who.encode(), info); + debug!("Account reserved balance is {}", info.data.reserved); Some(info.data.reserved.encode()) } else { None @@ -222,13 +224,13 @@ impl Stf { let mut key_hashes = Vec::new(); match call.call { TrustedCall::balance_set_balance(account, _, _, _) => { - key_hashes.push(nonce_key_hash(&account)) // dummy, actually not necessary + debug!("No storage updates needed...") } TrustedCall::balance_transfer(account, _, _) => { - key_hashes.push(nonce_key_hash(&account)) // dummy, actually not necessary + debug!("No storage updates needed...") } TrustedCall::balance_unshield(account, _, _, _) => { - key_hashes.push(nonce_key_hash(&account)) + debug!("No storage updates needed...") } TrustedCall::balance_shield(_, _) => debug!("No storage updates needed..."), }; From 01e437cff8e0d41d4c9383128243c2d98f8ea561 Mon Sep 17 00:00:00 2001 From: Alain Brenzikofer Date: Wed, 9 Sep 2020 17:27:13 +0200 Subject: [PATCH 27/29] fmt --- client/src/main.rs | 9 ++--- stf/src/cli.rs | 30 ++++++++------ stf/src/lib.rs | 8 ++-- stf/src/sgx.rs | 67 ++++++++++++++++++------------- worker/src/main.rs | 11 +++-- worker/src/ws_server.rs | 10 ++--- worker/worker-api/src/lib.rs | 10 ++--- worker/worker-api/src/requests.rs | 4 +- 8 files changed, 76 insertions(+), 73 deletions(-) diff --git a/client/src/main.rs b/client/src/main.rs index 8352550366..896fb81d61 100644 --- a/client/src/main.rs +++ b/client/src/main.rs @@ -57,8 +57,8 @@ use substratee_node_runtime::{ AccountId, Event, Hash, Signature, }; use substratee_stf::{ - cli::get_identifiers, ShardIdentifier, TrustedCallSigned, TrustedGetterSigned, - TrustedOperation, Getter + cli::get_identifiers, Getter, ShardIdentifier, TrustedCallSigned, TrustedGetterSigned, + TrustedOperation, }; use substratee_worker_api::Api as WorkerApi; @@ -435,10 +435,7 @@ fn get_worker_api(matches: &ArgMatches<'_>) -> WorkerApi { WorkerApi::new(url) } -fn perform_trusted_operation( - matches: &ArgMatches<'_>, - top: &TrustedOperation, -) -> Option> { +fn perform_trusted_operation(matches: &ArgMatches<'_>, top: &TrustedOperation) -> Option> { match top { TrustedOperation::call(call) => send_request(matches, call.clone()), TrustedOperation::get(getter) => get_state(matches, getter.clone()), diff --git a/stf/src/cli.rs b/stf/src/cli.rs index acffb95e1e..76056ded89 100644 --- a/stf/src/cli.rs +++ b/stf/src/cli.rs @@ -149,9 +149,10 @@ pub fn cmd<'a>( let top: TrustedOperation = TrustedCall::balance_transfer( sr25519_core::Public::from(from.public()), to, - amount) - .sign(&sr25519_core::Pair::from(from), nonce, &mrenclave, &shard) - .into(); + amount, + ) + .sign(&sr25519_core::Pair::from(from), nonce, &mrenclave, &shard) + .into(); let _ = perform_operation(matches, &top); Ok(()) }), @@ -182,7 +183,7 @@ pub fn cmd<'a>( let who = get_pair_from_str(matches, arg_who); let signer = get_pair_from_str(matches, "//AliceIncognito"); info!("account ss58 is {}", who.public().to_ss58check()); - + println!( "send trusted call set-balance({}, {})", who.public(), @@ -197,9 +198,10 @@ pub fn cmd<'a>( sr25519_core::Public::from(signer.public()), sr25519_core::Public::from(who.public()), amount, - amount,) - .sign(&sr25519_core::Pair::from(signer), nonce, &mrenclave, &shard) - .into(); + amount, + ) + .sign(&sr25519_core::Pair::from(signer), nonce, &mrenclave, &shard) + .into(); let _ = perform_operation(matches, &top); Ok(()) }), @@ -221,9 +223,10 @@ pub fn cmd<'a>( println!("arg_who = {:?}", arg_who); let who = get_pair_from_str(matches, arg_who); let (_mrenclave, shard) = get_identifiers(matches); - let top: TrustedOperation = TrustedGetter::free_balance(sr25519_core::Public::from(who.public())) - .sign(&sr25519_core::Pair::from(who)) - .into(); + let top: TrustedOperation = + TrustedGetter::free_balance(sr25519_core::Public::from(who.public())) + .sign(&sr25519_core::Pair::from(who)) + .into(); let res = perform_operation(matches, &top); let bal = if let Some(v) = res { if let Ok(vd) = crate::Balance::decode(&mut v.as_slice()) { @@ -296,9 +299,10 @@ pub fn cmd<'a>( sr25519_core::Public::from(from.public()), to, amount, - shard) - .sign(&sr25519_core::Pair::from(from), nonce, &mrenclave, &shard) - .into(); + shard, + ) + .sign(&sr25519_core::Pair::from(from), nonce, &mrenclave, &shard) + .into(); let _ = perform_operation(matches, &top); Ok(()) }), diff --git a/stf/src/lib.rs b/stf/src/lib.rs index b8d590c1db..bea3fa5be6 100644 --- a/stf/src/lib.rs +++ b/stf/src/lib.rs @@ -87,13 +87,11 @@ impl From for TrustedOperation { } } - - #[derive(Encode, Decode, Clone, Debug)] #[allow(non_camel_case_types)] pub enum Getter { - public(PublicGetter), - trusted(TrustedGetterSigned) + public(PublicGetter), + trusted(TrustedGetterSigned), } impl From for Getter { @@ -111,7 +109,7 @@ impl From for Getter { #[derive(Encode, Decode, Clone, Debug)] #[allow(non_camel_case_types)] pub enum PublicGetter { - some_value, + some_value, } #[derive(Encode, Decode, Clone, Debug)] diff --git a/stf/src/sgx.rs b/stf/src/sgx.rs index 06fbfa0605..47789a2e91 100644 --- a/stf/src/sgx.rs +++ b/stf/src/sgx.rs @@ -6,14 +6,14 @@ use codec::{Decode, Encode}; use derive_more::Display; use log_sgx::*; use metadata::StorageHasher; -use sgx_runtime::{Balance, Runtime, BlockNumber}; +use sgx_runtime::{Balance, BlockNumber, Runtime}; use sp_core::crypto::AccountId32; use sp_io::SgxExternalitiesTrait; use sp_runtime::traits::Dispatchable; use crate::{ - AccountId, State, Stf, TrustedCall, TrustedCallSigned, Getter, PublicGetter, TrustedGetter, ShardIdentifier, - SUBSRATEE_REGISTRY_MODULE, UNSHIELD, + AccountId, Getter, PublicGetter, ShardIdentifier, State, Stf, TrustedCall, TrustedCallSigned, + TrustedGetter, SUBSRATEE_REGISTRY_MODULE, UNSHIELD, }; use sp_core::blake2_256; @@ -71,14 +71,12 @@ impl Stf { pub fn update_storage(ext: &mut State, map_update: &HashMap, Option>>) { ext.execute_with(|| { - map_update - .iter() - .for_each(|(k, v)| { - match v { - Some(value) => sp_io::storage::set(k, value), - None => sp_io::storage::clear(k) - }; - }); + map_update.iter().for_each(|(k, v)| { + match v { + Some(value) => sp_io::storage::set(k, value), + None => sp_io::storage::clear(k), + }; + }); }); } @@ -89,7 +87,6 @@ impl Stf { }); } - pub fn execute( ext: &mut State, call: TrustedCallSigned, @@ -98,7 +95,12 @@ impl Stf { ext.execute_with(|| match call.call { TrustedCall::balance_set_balance(root, who, free_balance, reserved_balance) => { Self::ensure_root(root)?; - debug!("balance_set_balance({:x?}, {}, {})", who.encode(), free_balance, reserved_balance); + debug!( + "balance_set_balance({:x?}, {}, {})", + who.encode(), + free_balance, + reserved_balance + ); sgx_runtime::BalancesCall::::set_balance( AccountId32::from(who), free_balance, @@ -110,7 +112,12 @@ impl Stf { } TrustedCall::balance_transfer(from, to, value) => { let origin = sgx_runtime::Origin::signed(AccountId32::from(from)); - debug!("balance_transfer({:x?}, {:x?}, {})", from.encode(), to.encode(), value); + debug!( + "balance_transfer({:x?}, {:x?}, {})", + from.encode(), + to.encode(), + value + ); if let Some(info) = get_account_info(&from) { debug!("sender balance is {}", info.data.free); } else { @@ -122,7 +129,13 @@ impl Stf { Ok(()) } TrustedCall::balance_unshield(account_incognito, beneficiary, value, shard) => { - debug!("balance_unshield({:x?}, {:x?}, {}, {})", account_incognito.encode(), beneficiary.encode(), value, shard); + debug!( + "balance_unshield({:x?}, {:x?}, {}, {})", + account_incognito.encode(), + beneficiary.encode(), + value, + shard + ); Self::unshield_funds(account_incognito, value)?; calls.push(OpaqueCall( ( @@ -145,8 +158,7 @@ impl Stf { } pub fn get_state(ext: &mut State, getter: Getter) -> Option> { - ext.execute_with(|| - match getter { + ext.execute_with(|| match getter { Getter::trusted(g) => match g.getter { TrustedGetter::free_balance(who) => { if let Some(info) = get_account_info(&who) { @@ -165,15 +177,12 @@ impl Stf { } else { None } - }, + } }, Getter::public(g) => match g { - PublicGetter::some_value => { - Some(42u32.encode()) - }, - } - } - ) + PublicGetter::some_value => Some(42u32.encode()), + }, + }) } fn ensure_root(account: AccountId) -> Result<(), StfError> { @@ -226,9 +235,7 @@ impl Stf { TrustedCall::balance_set_balance(account, _, _, _) => { debug!("No storage updates needed...") } - TrustedCall::balance_transfer(account, _, _) => { - debug!("No storage updates needed...") - } + TrustedCall::balance_transfer(account, _, _) => debug!("No storage updates needed..."), TrustedCall::balance_unshield(account, _, _, _) => { debug!("No storage updates needed...") } @@ -237,9 +244,11 @@ impl Stf { key_hashes } - pub fn get_storage_hashes_to_update_for_getter(getter: &Getter) -> Vec> { - info!("No specific storage updates needed for getter. Returning those for on block: {:?}", getter); + info!( + "No specific storage updates needed for getter. Returning those for on block: {:?}", + getter + ); Self::storage_hashes_to_update_on_block() } diff --git a/worker/src/main.rs b/worker/src/main.rs index 37375a5dc2..27ef901db3 100644 --- a/worker/src/main.rs +++ b/worker/src/main.rs @@ -52,11 +52,11 @@ use enclave::api::{ }; use enclave::tls_ra::{enclave_request_key_provisioning, enclave_run_key_provisioning_server}; use sp_finality_grandpa::{AuthorityList, VersionedAuthorityList, GRANDPA_AUTHORITIES_KEY}; +use std::time::Duration; use substratee_node_primitives::calls::get_first_worker_that_is_not_equal_to_self; +use substratee_worker_api::requests::ClientRequest; use substratee_worker_api::Api as WorkerApi; use ws_server::start_ws_server; -use substratee_worker_api::requests::ClientRequest; -use std::time::Duration; mod constants; mod enclave; @@ -232,7 +232,7 @@ fn worker(w_ip: &str, w_port: &str, mu_ra_port: &str, shard: &ShardIdentifier) { // start the ws server to listen for worker requests let (ws_sender, ws_receiver) = channel(); let w_url = format!("{}:{}", w_ip, w_port); - start_ws_server(w_url.clone(),ws_sender.clone()); + start_ws_server(w_url.clone(), ws_sender.clone()); // ------------------------------------------------------------------------ // let new workers call us for key provisioning @@ -499,7 +499,10 @@ pub fn sync_chain_relay( blocks_to_sync.push(head.clone()); if head.block.header.number % BLOCK_SYNC_BATCH_SIZE == 0 { - println!("Remaining blocks to fetch until last synced header: {:?}", head.block.header.number - last_synced_head.number) + println!( + "Remaining blocks to fetch until last synced header: {:?}", + head.block.header.number - last_synced_head.number + ) } } blocks_to_sync.reverse(); diff --git a/worker/src/ws_server.rs b/worker/src/ws_server.rs index 24354221e7..d92c2b1321 100644 --- a/worker/src/ws_server.rs +++ b/worker/src/ws_server.rs @@ -23,7 +23,7 @@ use sgx_types::*; use codec::{Decode, Encode}; use log::*; use std::sync::mpsc::Sender as MpscSender; -use substratee_stf::{ShardIdentifier, Getter}; +use substratee_stf::{Getter, ShardIdentifier}; use substratee_worker_api::requests::*; use ws::{listen, CloseCode, Handler, Message, Result, Sender}; @@ -61,7 +61,7 @@ pub fn start_ws_server(addr: String, worker: MpscSender) { .send(WsServerRequest::new(self.client.clone(), req)) .unwrap(); } - Err(e) => self.client.send("Could not decode request").unwrap() + Err(e) => self.client.send("Could not decode request").unwrap(), } Ok(()) } @@ -96,11 +96,7 @@ pub fn handle_request( req.client.send(answer) } -fn get_stf_state( - eid: sgx_enclave_id_t, - getter: Getter, - shard: ShardIdentifier, -) -> Message { +fn get_stf_state(eid: sgx_enclave_id_t, getter: Getter, shard: ShardIdentifier) -> Message { info!(" [WS Server] Query state"); let value = match enclave_query_state(eid, getter.encode(), shard.encode()) { Ok(val) => Some(val), diff --git a/worker/worker-api/src/lib.rs b/worker/worker-api/src/lib.rs index 1d549f9824..08dc4f70e8 100644 --- a/worker/worker-api/src/lib.rs +++ b/worker/worker-api/src/lib.rs @@ -20,13 +20,13 @@ use std::thread; use sgx_crypto_helper::rsa3072::Rsa3072PubKey; -use codec::{Decode}; +use codec::Decode; use log::*; use ws::connect; use client::WsClient; use requests::*; -use substratee_stf::{ShardIdentifier, Getter}; +use substratee_stf::{Getter, ShardIdentifier}; pub mod client; pub mod requests; @@ -54,11 +54,7 @@ impl Api { Ok(rsa_pubkey) } - pub fn get_stf_state( - &self, - getter: Getter, - shard: &ShardIdentifier, - ) -> Result, ()> { + pub fn get_stf_state(&self, getter: Getter, shard: &ShardIdentifier) -> Result, ()> { let req = ClientRequest::StfState(getter, shard.to_owned()); match Self::get(&self, req) { Ok(res) => { diff --git a/worker/worker-api/src/requests.rs b/worker/worker-api/src/requests.rs index f49caccb9e..437cbc91bc 100644 --- a/worker/worker-api/src/requests.rs +++ b/worker/worker-api/src/requests.rs @@ -15,7 +15,7 @@ */ -use codec::{Encode, Decode}; +use codec::{Decode, Encode}; use substratee_stf::{Getter, ShardIdentifier}; #[derive(Encode, Decode, Clone, Debug)] @@ -23,4 +23,4 @@ pub enum ClientRequest { PubKeyWorker, MuRaPortWorker, StfState(Getter, ShardIdentifier), // (trusted_getter_encrypted, shard) -} \ No newline at end of file +} From 506e844c9b23f177698e6f5e045e0af1804c00cb Mon Sep 17 00:00:00 2001 From: Alain Brenzikofer Date: Wed, 9 Sep 2020 19:13:02 +0200 Subject: [PATCH 28/29] fmt - also enclave --- enclave/src/io.rs | 2 +- enclave/src/ipfs.rs | 18 ++++++++---------- enclave/src/lib.rs | 27 +++++++++++++-------------- enclave/src/state.rs | 17 ++++++++++++++--- 4 files changed, 36 insertions(+), 28 deletions(-) diff --git a/enclave/src/io.rs b/enclave/src/io.rs index 2662e08273..ee59d25507 100644 --- a/enclave/src/io.rs +++ b/enclave/src/io.rs @@ -82,8 +82,8 @@ pub mod light_validation { use log::*; use sgx_types::{sgx_status_t, SgxResult}; use sp_finality_grandpa::VersionedAuthorityList; - use std::sgxfs::SgxFile; use std::fs; + use std::sgxfs::SgxFile; pub fn unseal() -> SgxResult { let vec = super::unseal(CHAIN_RELAY_DB)?; diff --git a/enclave/src/ipfs.rs b/enclave/src/ipfs.rs index 0df5758f0b..b217218557 100644 --- a/enclave/src/ipfs.rs +++ b/enclave/src/ipfs.rs @@ -44,16 +44,14 @@ impl IpfsContent { cid_str, self.stats.blocks, self.stats.block_bytes ); match self.cid.as_ref() { - Ok(initial_cid) => { - if last_cid.hash().eq(&initial_cid.hash()) { - Ok(()) - } else { - Err(IpfsError::Verification) - } - }, - Err(_) => { - Err(IpfsError::InputCidInvalid) - } + Ok(initial_cid) => { + if last_cid.hash().eq(&initial_cid.hash()) { + Ok(()) + } else { + Err(IpfsError::Verification) + } + } + Err(_) => Err(IpfsError::InputCidInvalid), } } else { Err(IpfsError::FinalCidMissing) diff --git a/enclave/src/lib.rs b/enclave/src/lib.rs index e78b19ce7c..48787dc856 100644 --- a/enclave/src/lib.rs +++ b/enclave/src/lib.rs @@ -62,10 +62,8 @@ use chain_relay::{ use sp_runtime::OpaqueExtrinsic; use sp_runtime::{generic::SignedBlock, traits::Header as HeaderT}; use substrate_api_client::extrinsic::xt_primitives::UncheckedExtrinsicV4; -use substratee_stf::{ - AccountId, ShardIdentifier, Stf, TrustedCall, TrustedCallSigned, Getter, -}; use substratee_stf::sgx::{shards_key_hash, storage_hashes_to_update_per_shard, OpaqueCall}; +use substratee_stf::{AccountId, Getter, ShardIdentifier, Stf, TrustedCall, TrustedCallSigned}; mod aes; mod attestation; @@ -215,7 +213,7 @@ pub unsafe extern "C" fn get_state( let mut trusted_op_slice = slice::from_raw_parts(trusted_op, trusted_op_size as usize); let value_slice = slice::from_raw_parts_mut(value, value_size as usize); let getter = Getter::decode(&mut trusted_op_slice).unwrap(); - + if let Getter::trusted(trusted_getter_signed) = getter.clone() { debug!("verifying signature of TrustedGetterSigned"); if let false = trusted_getter_signed.verify_signature() { @@ -246,11 +244,10 @@ pub unsafe extern "C" fn get_state( // FIXME: not sure we will ever need this as we are querying trusted state, not onchain state // i.e. demurrage could be correctly applied with this, but the client could do that too. debug!("Update STF storage!"); - let requests: Vec = - Stf::get_storage_hashes_to_update_for_getter(&getter) - .into_iter() - .map(|key| WorkerRequest::ChainStorage(key, Some(latest_header.hash()))) - .collect(); + let requests: Vec = Stf::get_storage_hashes_to_update_for_getter(&getter) + .into_iter() + .map(|key| WorkerRequest::ChainStorage(key, Some(latest_header.hash()))) + .collect(); if !requests.is_empty() { let responses: Vec>> = match worker_request(requests) { @@ -398,7 +395,8 @@ pub fn update_states(header: Header) -> SgxResult<()> { if let Some(maybe_shards) = update_map.get(&shards_key_hash()) { match maybe_shards { Some(shards) => { - let shards: Vec = Decode::decode(&mut shards.as_slice()).sgx_error_with_log("error decoding shards")?; + let shards: Vec = Decode::decode(&mut shards.as_slice()) + .sgx_error_with_log("error decoding shards")?; for s in shards { if !state::exists(&s) { @@ -411,7 +409,8 @@ pub fn update_states(header: Header) -> SgxResult<()> { .map(|key| WorkerRequest::ChainStorage(key, Some(header.hash()))) .collect(); - let responses: Vec>> = worker_request(per_shard_request)?; + let responses: Vec>> = + worker_request(per_shard_request)?; let per_shard_update_map = verify_worker_responses(responses, header.clone())?; let mut state = state::load(&s)?; @@ -424,7 +423,7 @@ pub fn update_states(header: Header) -> SgxResult<()> { state::write(state, &s)?; } } - None => info!("No shards are on the chain yet") + None => info!("No shards are on the chain yet"), }; }; Ok(()) @@ -485,7 +484,7 @@ fn handle_shield_funds_xt( &mut state, TrustedCallSigned::new( TrustedCall::balance_shield(account, amount), - 0, //nonce + 0, //nonce Default::default(), //don't care about signature here ), calls, @@ -493,7 +492,7 @@ fn handle_shield_funds_xt( error!("Error performing Stf::execute. Error: {:?}", e); return Ok(()); } - + let state_hash = state::write(state, &shard)?; let xt_call = [SUBSRATEE_REGISTRY_MODULE, CALL_CONFIRMED]; diff --git a/enclave/src/state.rs b/enclave/src/state.rs index 77fcbd57d8..c5ed0cf433 100644 --- a/enclave/src/state.rs +++ b/enclave/src/state.rs @@ -53,7 +53,10 @@ pub fn load(shard: &ShardIdentifier) -> SgxResult { Stf::init_state() } n => { - debug!("State loaded from {} with size {}B, deserializing...", state_path, n); + debug!( + "State loaded from {} with size {}B, deserializing...", + state_path, n + ); StfState::decode(state_vec) } }; @@ -77,7 +80,11 @@ pub fn write(state: StfState, shard: &ShardIdentifier) -> SgxResult { Err(status) => return Err(status), }; - debug!("new encrypted state with hash=0x{} written to {}", hex::encode_hex(&state_hash), state_path); + debug!( + "new encrypted state with hash=0x{} written to {}", + hex::encode_hex(&state_hash), + state_path + ); io::write(&cyphertext, &state_path)?; Ok(state_hash.into()) @@ -109,7 +116,11 @@ fn read(path: &str) -> SgxResult> { Ok(h) => h, Err(status) => return Err(status), }; - debug!("read encrypted state with hash 0x{} from {}", hex::encode_hex(&state_hash), path); + debug!( + "read encrypted state with hash 0x{} from {}", + hex::encode_hex(&state_hash), + path + ); aes::de_or_encrypt(&mut bytes)?; trace!("buffer decrypted = {:?}", bytes); From 8a16eaed2b0098168d52fd820c2cda2efffc0e63 Mon Sep 17 00:00:00 2001 From: Alain Brenzikofer Date: Wed, 9 Sep 2020 19:42:13 +0200 Subject: [PATCH 29/29] fix clippy. fmt --- client/src/main.rs | 3 +-- enclave/src/lib.rs | 8 ++++++++ stf/src/cli.rs | 1 - stf/src/sgx.rs | 12 ++++-------- worker/src/main.rs | 9 +++------ worker/src/ws_server.rs | 2 +- 6 files changed, 17 insertions(+), 18 deletions(-) diff --git a/client/src/main.rs b/client/src/main.rs index 896fb81d61..bcc26238c6 100644 --- a/client/src/main.rs +++ b/client/src/main.rs @@ -57,8 +57,7 @@ use substratee_node_runtime::{ AccountId, Event, Hash, Signature, }; use substratee_stf::{ - cli::get_identifiers, Getter, ShardIdentifier, TrustedCallSigned, TrustedGetterSigned, - TrustedOperation, + cli::get_identifiers, Getter, ShardIdentifier, TrustedCallSigned, TrustedOperation, }; use substratee_worker_api::Api as WorkerApi; diff --git a/enclave/src/lib.rs b/enclave/src/lib.rs index 48787dc856..9e4b7ac47e 100644 --- a/enclave/src/lib.rs +++ b/enclave/src/lib.rs @@ -111,6 +111,14 @@ pub unsafe extern "C" fn init() -> sgx_status_t { return status; } + // for debug purposes, list shards. no problem to panic if fails + let shards = state::list_shards().unwrap(); + debug!("found the following {} shards on disk:", shards.len()); + for s in shards { + debug!("{}", s.encode().to_base58()) + } + //shards.into_iter().map(|s| debug!("{}", s.encode().to_base58())); + sgx_status_t::SGX_SUCCESS } diff --git a/stf/src/cli.rs b/stf/src/cli.rs index 76056ded89..cfa0de6537 100644 --- a/stf/src/cli.rs +++ b/stf/src/cli.rs @@ -222,7 +222,6 @@ pub fn cmd<'a>( let arg_who = matches.value_of("accountid").unwrap(); println!("arg_who = {:?}", arg_who); let who = get_pair_from_str(matches, arg_who); - let (_mrenclave, shard) = get_identifiers(matches); let top: TrustedOperation = TrustedGetter::free_balance(sr25519_core::Public::from(who.public())) .sign(&sr25519_core::Pair::from(who)) diff --git a/stf/src/sgx.rs b/stf/src/sgx.rs index 47789a2e91..f2c7390e4c 100644 --- a/stf/src/sgx.rs +++ b/stf/src/sgx.rs @@ -230,15 +230,11 @@ impl Stf { } pub fn get_storage_hashes_to_update(call: &TrustedCallSigned) -> Vec> { - let mut key_hashes = Vec::new(); + let key_hashes = Vec::new(); match call.call { - TrustedCall::balance_set_balance(account, _, _, _) => { - debug!("No storage updates needed...") - } - TrustedCall::balance_transfer(account, _, _) => debug!("No storage updates needed..."), - TrustedCall::balance_unshield(account, _, _, _) => { - debug!("No storage updates needed...") - } + TrustedCall::balance_set_balance(_, _, _, _) => debug!("No storage updates needed..."), + TrustedCall::balance_transfer(_, _, _) => debug!("No storage updates needed..."), + TrustedCall::balance_unshield(_, _, _, _) => debug!("No storage updates needed..."), TrustedCall::balance_shield(_, _) => debug!("No storage updates needed..."), }; key_hashes diff --git a/worker/src/main.rs b/worker/src/main.rs index 27ef901db3..1265f2bb34 100644 --- a/worker/src/main.rs +++ b/worker/src/main.rs @@ -53,9 +53,8 @@ use enclave::api::{ use enclave::tls_ra::{enclave_request_key_provisioning, enclave_run_key_provisioning_server}; use sp_finality_grandpa::{AuthorityList, VersionedAuthorityList, GRANDPA_AUTHORITIES_KEY}; use std::time::Duration; -use substratee_node_primitives::calls::get_first_worker_that_is_not_equal_to_self; -use substratee_worker_api::requests::ClientRequest; -use substratee_worker_api::Api as WorkerApi; +//use substratee_worker_api::requests::ClientRequest; +//use substratee_worker_api::Api as WorkerApi; use ws_server::start_ws_server; mod constants; @@ -232,11 +231,10 @@ fn worker(w_ip: &str, w_port: &str, mu_ra_port: &str, shard: &ShardIdentifier) { // start the ws server to listen for worker requests let (ws_sender, ws_receiver) = channel(); let w_url = format!("{}:{}", w_ip, w_port); - start_ws_server(w_url.clone(), ws_sender.clone()); + start_ws_server(w_url.clone(), ws_sender); // ------------------------------------------------------------------------ // let new workers call us for key provisioning - let eid = enclave.geteid(); let ra_url = format!("{}:{}", w_ip, mu_ra_port); thread::spawn(move || { enclave_run_key_provisioning_server( @@ -508,7 +506,6 @@ pub fn sync_chain_relay( blocks_to_sync.reverse(); let tee_accountid = enclave_account(eid); - let tee_nonce = get_nonce(&api, &tee_accountid); // only feed BLOCK_SYNC_BATCH_SIZE blocks at a time into the enclave to save enclave state regularly let mut i = blocks_to_sync[0].block.header.number as usize; diff --git a/worker/src/ws_server.rs b/worker/src/ws_server.rs index d92c2b1321..879f6d7ca6 100644 --- a/worker/src/ws_server.rs +++ b/worker/src/ws_server.rs @@ -61,7 +61,7 @@ pub fn start_ws_server(addr: String, worker: MpscSender) { .send(WsServerRequest::new(self.client.clone(), req)) .unwrap(); } - Err(e) => self.client.send("Could not decode request").unwrap(), + Err(_) => self.client.send("Could not decode request").unwrap(), } Ok(()) }