Skip to content

Commit

Permalink
updae to substrate v4.0.0-dev (#347)
Browse files Browse the repository at this point in the history
Updates the following:
- update to subtrate v4.0.0-dev paritytech/substrate@f651d45
- Changes to match newest substrate-api-client (especially scs/substrate-api-client#131)
- updates [aes.rs](https://github.com/integritee-network/worker/blob/master/enclave/src/aes.rs) to reenable cargo update in enclave (old version of [ofb and aes](https://github.com/integritee-network/worker/blob/master/enclave/Cargo.toml#L34-L35) not available in crates.io anymore)
- renaming from substratee-registry to pallet teerex (some were enforced by newer version of node & pallet)
- adds `make update` command to makefile, because cargo update alone is not sufficient

* [Client] update cargo.toml

* [chain relay] update cargo.toml

* [Enlcave] update cargo.toml

* [Primitives] update cargo.tomls

* [stf] update cargo.toml

* [worker] update cargo.toml

* some clean up

* fix typos

* revert some cargo updates

* cargo update

* rename susbtratee_registry to pallet_teerex

* revert version of aes - ofd

* remove obsolete patch

* update Cargo.toml of enclave (+cargo update)

* adapt aes.rs to new version

* adapt to new susbtrate-api-client api structure

* rename substrateeapi to pallet teerex

* move sgx-runtime dep to git branhc

* remove obsolete control fnction and change to substrate-api-client branch

* change substate-api-client back to master

* cargo fmt

* remove obselete wrapper-debugging functions

* make clippy happy

* add getrandom-sgx patch

* rebase adaptions

* change sgx-runtime dep to master

* add makefile make update command
  • Loading branch information
haerdib authored Aug 13, 2021
1 parent 99c4b3a commit e1e86cd
Show file tree
Hide file tree
Showing 33 changed files with 1,286 additions and 2,157 deletions.
1,816 changes: 643 additions & 1,173 deletions Cargo.lock

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,9 @@ members = [

#[patch."https://github.com/scs/substrate-api-client"]
#substrate-api-client = { path = "../substrate-api-client" }
#substrate-client-keystore = { path = "../substrate-api-client/client-keystore" }
#substrate-client-keystore = { path = "../substrate-api-client/client-keystore" }

#[patch."https://github.com/integritee-network/sgx-runtime"]
#sgx-runtime = { path = "../sgx-runtime/runtime", default-features = false}
#sp-io = { path = "../sgx-runtime/substrate-sgx/sp-io", default-features = false, features = ["disable_oom", "disable_panic_handler", "disable_allocator", "sgx"]}
#sgx-externalities = { path = "../sgx-runtime/substrate-sgx/externalities", default-features = false}
10 changes: 10 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,16 @@ clean:
@echo "cargo clean in root directory"
@cargo clean

.PHONY: update
update:
@echo "Running cargo update.."
@cd enclave && cargo update
@cd enclave && cargo update -p sp-std --precise f651d45ce5742bc60fe8ae518c035d1638ae83d2
@cd enclave && cargo update -p sgx_tstd --precise 7c07ce0bfbacd3f4f2af53a2cdef9539018be73c
@cargo update
@cargo update -p sp-std --precise f651d45ce5742bc60fe8ae518c035d1638ae83d2
@cargo update -p sgx_tstd --precise 7c07ce0bfbacd3f4f2af53a2cdef9539018be73c

mrenclave:
@$(SGX_ENCLAVE_SIGNER) dump -enclave ./bin/enclave.signed.so -dumpfile df.out && ./extract_identity < df.out && rm df.out

Expand Down
101 changes: 23 additions & 78 deletions client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,88 +14,33 @@ tiny-bip39 = "0.6.2"
serde_json = "1.0"
clap = "2.33"
clap-nested = "0.3.1"
primitive-types = { version = "0.6.1", default-features = false, features = ["codec"] }
primitive-types = { version = "0.10.1", default-features = false, features = ["codec"] }
base58 = "0.1"
chrono = "*"
blake2-rfc = { version = "0.2.18", default-features = false}
geojson = "0.17"
ws = { version = "0.7", features = ["ssl"] }
serde = { version = "1.0", features = ["derive"] }
codec = { version = "2.0.0", package = "parity-scale-codec", features = ["derive"] }
sgx_crypto_helper = { rev = "v1.1.3", git = "https://github.com/apache/teaclave-sgx-sdk.git" }

[dependencies.substrate-api-client]
git = "https://github.com/scs/substrate-api-client"
branch = "master"

[dependencies.substrate-client-keystore]
git = "https://github.com/scs/substrate-api-client"
branch = "master"

[dependencies.serde]
features = ["derive"]
version = "1.0"

[dependencies.codec]
default-features = false
package = "parity-scale-codec"
features = ["derive"]
version = "2.0.0"

[dependencies.sp-runtime]
git = "https://github.com/paritytech/substrate.git"
branch = "master"
version = "3.0.0"

[dependencies.sc-keystore]
git = "https://github.com/paritytech/substrate.git"
branch = "master"
version = "3.0.0"

[dependencies.pallet-balances]
git = "https://github.com/paritytech/substrate.git"
branch = "master"
version = "3.0.0"
default-features=false

[dependencies.frame-system]
git = "https://github.com/paritytech/substrate.git"
branch = "master"
version = "3.0.0"
default-features=false

[dependencies.my-node-runtime]
git = "https://github.com/scs/substraTEE-node"
branch = "master"
package = "substratee-node-runtime"

[dependencies.substratee-worker-primitives]
path = "../primitives/worker"

[dependencies.substratee-node-primitives]
path = "../primitives/node"

[dependencies.substratee-api-client-extensions]
path = "../primitives/api-client-extensions"

[dependencies.substratee-stf]
path = "../stf"

[dependencies.substratee-worker-api]
path = "../worker/rpc/client"

[dependencies.sp-keyring]
git = "https://github.com/paritytech/substrate.git"
branch = "master"
version = "3.0.0"

[dependencies.sp-application-crypto]
git = "https://github.com/paritytech/substrate.git"
branch = "master"
version = "3.0.0"

[dependencies.sp-core]
git = "https://github.com/paritytech/substrate.git"
branch = "master"
version = "3.0.0"

#[patch.crates-io]
#ed25519-dalek = { git = "https://github.com/scs/ed25519-dalek.git", branch = "no_std_sgx"}
# scs / integritee
substrate-api-client = { features = ["ws-client"], git = "https://github.com/scs/substrate-api-client", branch = "master" }
substrate-client-keystore = { git = "https://github.com/scs/substrate-api-client", branch = "master" }
my-node-runtime = { git = "https://github.com/integritee-network/integritee-node", branch = "master", package = "integritee-node-runtime" }

# substrate dependencies
sp-runtime = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "master" }
sc-keystore = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "master" }
pallet-balances = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "master" }
frame-system = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "master" }
sp-keyring = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "master" }
sp-application-crypto = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "master" }
sp-core = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "master" }

#local dependencies
substratee-node-primitives = { path = "../primitives/node" }
substratee-worker-primitives = { path = "../primitives/worker" }
substratee-api-client-extensions = { path = "../primitives/api-client-extensions" }
substratee-stf = { path = "../stf" }
substratee-worker-api = { path = "../worker/rpc/client" }
47 changes: 24 additions & 23 deletions client/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ use clap_nested::{Command, Commander};
use codec::{Decode, Encode};
use log::*;
use my_node_runtime::{
substratee_registry::Request, AccountId, BalancesCall, Call, Event, Hash, Signature,
pallet_teerex::Request, AccountId, BalancesCall, Call, Event, Hash, Signature,
};

use sp_core::{crypto::Ss58Codec, sr25519 as sr25519_core, Pair, H256};
Expand All @@ -51,15 +51,17 @@ use sp_runtime::{
use std::{convert::TryFrom, result::Result as StdResult, sync::mpsc::channel, thread};
use substrate_api_client::{
compose_extrinsic, compose_extrinsic_offline,
events::EventsDecoder,
extrinsic::xt_primitives::{GenericAddress, UncheckedExtrinsicV4},
node_metadata::Metadata,
rpc::{
ws_client::{EventsDecoder, Subscriber},
WsRpcClient,
},
utils::FromHexString,
Api, XtStatus,
Api, Metadata, RpcClient, XtStatus,
};

use substrate_client_keystore::{KeystoreExt, LocalKeystore};
use substratee_api_client_extensions::{SubstrateeRegistryApi, TEEREX};
use substratee_api_client_extensions::{PalletTeerexApi, TEEREX};
use substratee_stf::{ShardIdentifier, TrustedCallSigned, TrustedOperation};
use substratee_worker_api::direct_client::{DirectApi, DirectClient as DirectWorkerApi};
use substratee_worker_primitives::{DirectRequestStatus, RpcRequest, RpcResponse, RpcReturnValue};
Expand Down Expand Up @@ -423,14 +425,14 @@ fn main() {
}
}

fn get_chain_api(matches: &ArgMatches<'_>) -> Api<sr25519::Pair> {
fn get_chain_api(matches: &ArgMatches<'_>) -> Api<sr25519::Pair, WsRpcClient> {
let url = format!(
"{}:{}",
matches.value_of("node-url").unwrap(),
matches.value_of("node-port").unwrap()
);
info!("connecting to {}", url);
Api::<sr25519::Pair>::new(url).unwrap()
Api::<sr25519::Pair, WsRpcClient>::new(WsRpcClient::new(&url)).unwrap()
}

fn perform_trusted_operation(matches: &ArgMatches<'_>, top: &TrustedOperation) -> Option<Vec<u8>> {
Expand Down Expand Up @@ -691,11 +693,11 @@ fn listen(matches: &ArgMatches<'_>) {
}
}
},*/
Event::SubstrateeRegistry(ee) => {
Event::Teerex(ee) => {
println!(">>>>>>>>>> substraTEE event: {:?}", ee);
count += 1;
match &ee {
my_node_runtime::substratee_registry::RawEvent::AddedEnclave(
my_node_runtime::pallet_teerex::RawEvent::AddedEnclave(
accountid,
url,
) => {
Expand All @@ -706,12 +708,12 @@ fn listen(matches: &ArgMatches<'_>) {
.unwrap_or_else(|_| "error".to_string())
);
},
my_node_runtime::substratee_registry::RawEvent::RemovedEnclave(
my_node_runtime::pallet_teerex::RawEvent::RemovedEnclave(
accountid,
) => {
println!("RemovedEnclave: {:?}", accountid);
},
my_node_runtime::substratee_registry::RawEvent::UpdatedIpfsHash(
my_node_runtime::pallet_teerex::RawEvent::UpdatedIpfsHash(
shard,
idx,
ipfs_hash,
Expand All @@ -723,15 +725,13 @@ fn listen(matches: &ArgMatches<'_>) {
ipfs_hash
);
},
my_node_runtime::substratee_registry::RawEvent::Forwarded(
shard,
) => {
my_node_runtime::pallet_teerex::RawEvent::Forwarded(shard) => {
println!(
"Forwarded request for shard {}",
shard.encode().to_base58()
);
},
my_node_runtime::substratee_registry::RawEvent::CallConfirmed(
my_node_runtime::pallet_teerex::RawEvent::CallConfirmed(
accountid,
call_hash,
) => {
Expand All @@ -740,7 +740,7 @@ fn listen(matches: &ArgMatches<'_>) {
accountid, call_hash
);
},
my_node_runtime::substratee_registry::RawEvent::BlockConfirmed(
my_node_runtime::pallet_teerex::RawEvent::BlockConfirmed(
accountid,
block_hash,
) => {
Expand All @@ -749,12 +749,12 @@ fn listen(matches: &ArgMatches<'_>) {
accountid, block_hash
);
},
my_node_runtime::substratee_registry::RawEvent::ShieldFunds(
my_node_runtime::pallet_teerex::RawEvent::ShieldFunds(
incognito_account,
) => {
println!("ShieldFunds for {:?}", incognito_account);
},
my_node_runtime::substratee_registry::RawEvent::UnshieldedFunds(
my_node_runtime::pallet_teerex::RawEvent::UnshieldedFunds(
public_account,
) => {
println!("UnshieldFunds for {:?}", public_account);
Expand All @@ -770,10 +770,11 @@ fn listen(matches: &ArgMatches<'_>) {
}
}

// subscribes to he substratee_registry events of type CallConfirmed
pub fn subscribe_to_call_confirmed<P: Pair>(api: Api<P>) -> H256
// subscribes to he pallet_teerex events of type CallConfirmed
pub fn subscribe_to_call_confirmed<P: Pair, Client: 'static>(api: Api<P, Client>) -> H256
where
MultiSignature: From<P::Signature>,
Client: RpcClient + Subscriber + Send,
{
let (events_in, events_out) = channel();

Expand All @@ -794,16 +795,16 @@ where
if let Ok(evts) = _events {
for evr in &evts {
info!("received event {:?}", evr.event);
if let Event::SubstrateeRegistry(pe) = &evr.event {
if let my_node_runtime::substratee_registry::RawEvent::CallConfirmed(
if let Event::Teerex(pe) = &evr.event {
if let my_node_runtime::pallet_teerex::RawEvent::CallConfirmed(
sender,
payload,
) = &pe
{
println!("[+] Received confirm call from {}", sender);
return payload.clone().to_owned()
} else {
debug!("received unknown event from SubstraTeeRegistry: {:?}", evr.event)
debug!("received unknown event from Teerex: {:?}", evr.event)
}
}
}
Expand Down
Loading

0 comments on commit e1e86cd

Please sign in to comment.