From 0b5bb49d944c27131a7fef1e69d2223dfdf3316b Mon Sep 17 00:00:00 2001 From: orion Date: Mon, 6 Feb 2023 10:45:56 +0100 Subject: [PATCH] add feature flags for dcap, use pallets fork --- Cargo.lock | 31 ++++++++++++++++++++++++++---- app-libs/sgx-runtime/Cargo.toml | 2 +- app-libs/stf/Cargo.toml | 2 +- enclave-runtime/Cargo.lock | 2 +- enclave-runtime/src/attestation.rs | 2 +- service/Cargo.toml | 5 +++-- service/src/main.rs | 3 +++ service/src/prometheus_metrics.rs | 5 +++++ 8 files changed, 42 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5c80bef2d1..cd6b4a1f4e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2668,7 +2668,7 @@ dependencies = [ "serde 1.0.152", "serde_derive 1.0.152", "serde_json 1.0.93", - "sgx-verify", + "sgx-verify 0.1.4 (git+https://github.com/OverOrion/pallets.git?branch=szp/extract-tcb-info)", "sgx_crypto_helper", "sgx_types", "sgx_urts", @@ -2678,7 +2678,7 @@ dependencies = [ "sp-keyring", "sp-runtime", "substrate-api-client", - "teerex-primitives 0.1.0 (git+https://github.com/integritee-network/pallets.git?branch=polkadot-v0.9.37)", + "teerex-primitives 0.1.0 (git+https://github.com/OverOrion/pallets.git?branch=szp/extract-tcb-info)", "thiserror 1.0.38", "tokio", "warp", @@ -5206,7 +5206,7 @@ dependencies = [ [[package]] name = "pallet-parentchain" version = "0.9.0" -source = "git+https://github.com/integritee-network/pallets.git?branch=polkadot-v0.9.37#50cac490de02a6484751c193da9f8080477b885c" +source = "git+https://github.com/OverOrion/pallets.git?branch=szp/extract-tcb-info#fb57261d1d6e4b2da12e90f563a5a3f5e6a50b88" dependencies = [ "frame-support", "frame-system", @@ -5368,7 +5368,7 @@ dependencies = [ "parity-scale-codec", "scale-info", "serde 1.0.152", - "sgx-verify", + "sgx-verify 0.1.4 (git+https://github.com/integritee-network/pallets.git?branch=polkadot-v0.9.37)", "sp-core", "sp-io 7.0.0 (git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.37)", "sp-runtime", @@ -6835,6 +6835,29 @@ dependencies = [ "x509-cert", ] +[[package]] +name = "sgx-verify" +version = "0.1.4" +source = "git+https://github.com/OverOrion/pallets.git?branch=szp/extract-tcb-info#fb57261d1d6e4b2da12e90f563a5a3f5e6a50b88" +dependencies = [ + "base64 0.13.1", + "chrono 0.4.23", + "der", + "frame-support", + "hex", + "parity-scale-codec", + "ring 0.16.20 (git+https://github.com/Niederb/ring-xous.git?branch=0.16.20-cleanup)", + "scale-info", + "serde 1.0.152", + "serde_json 1.0.93", + "sp-core", + "sp-io 7.0.0 (git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.37)", + "sp-std", + "teerex-primitives 0.1.0 (git+https://github.com/OverOrion/pallets.git?branch=szp/extract-tcb-info)", + "webpki 0.21.0", + "x509-cert", +] + [[package]] name = "sgx_alloc" version = "1.1.6" diff --git a/app-libs/sgx-runtime/Cargo.toml b/app-libs/sgx-runtime/Cargo.toml index 80a6c8199f..ce0e0eec3e 100644 --- a/app-libs/sgx-runtime/Cargo.toml +++ b/app-libs/sgx-runtime/Cargo.toml @@ -46,7 +46,7 @@ sp-version = { default-features = false, git = "https://github.com/paritytech/su # Integritee dependencies pallet-evm = { default-features = false, optional = true, git = "https://github.com/integritee-network/frontier.git", branch = "polkadot-v0.9.37" } -pallet-parentchain = { default-features = false, git = "https://github.com/integritee-network/pallets.git", branch = "polkadot-v0.9.37" } +pallet-parentchain = { default-features = false, git = "https://github.com/OverOrion/pallets.git", branch = "szp/extract-tcb-info" } [features] default = ["std"] diff --git a/app-libs/stf/Cargo.toml b/app-libs/stf/Cargo.toml index fd505bc160..71dbf6ff09 100644 --- a/app-libs/stf/Cargo.toml +++ b/app-libs/stf/Cargo.toml @@ -50,7 +50,7 @@ sp-runtime = { default-features = false, git = "https://github.com/paritytech/su # scs / integritee my-node-runtime = { package = "integritee-node-runtime", optional = true, git = "https://github.com/integritee-network/integritee-node.git", branch = "polkadot-v0.9.37" } -pallet-parentchain = { default-features = false, git = "https://github.com/integritee-network/pallets.git", branch = "polkadot-v0.9.37" } +pallet-parentchain = { default-features = false, git = "https://github.com/OverOrion/pallets.git", branch = "szp/extract-tcb-info" } [dev-dependencies] diff --git a/enclave-runtime/Cargo.lock b/enclave-runtime/Cargo.lock index b7c91fde19..9ee37913b3 100644 --- a/enclave-runtime/Cargo.lock +++ b/enclave-runtime/Cargo.lock @@ -2822,7 +2822,7 @@ dependencies = [ [[package]] name = "pallet-parentchain" version = "0.9.0" -source = "git+https://github.com/integritee-network/pallets.git?branch=polkadot-v0.9.37#50cac490de02a6484751c193da9f8080477b885c" +source = "git+https://github.com/OverOrion/pallets.git?branch=szp/extract-tcb-info#fb57261d1d6e4b2da12e90f563a5a3f5e6a50b88" dependencies = [ "frame-support", "frame-system", diff --git a/enclave-runtime/src/attestation.rs b/enclave-runtime/src/attestation.rs index 614831607a..729a19457f 100644 --- a/enclave-runtime/src/attestation.rs +++ b/enclave-runtime/src/attestation.rs @@ -211,7 +211,7 @@ pub unsafe extern "C" fn generate_dcap_ra_quote( Err(e) => return e.into(), }; - let mut dcap_quote_slice = slice::from_raw_parts_mut(dcap_quote_p, dcap_quote_size as usize); + let dcap_quote_slice = slice::from_raw_parts_mut(dcap_quote_p, dcap_quote_size as usize); if let Err(e) = write_slice_and_whitespace_pad(dcap_quote_slice, dcap_quote) { return EnclaveError::Other(Box::new(e)).into() diff --git a/service/Cargo.toml b/service/Cargo.toml index b6a9964448..646eda668c 100644 --- a/service/Cargo.toml +++ b/service/Cargo.toml @@ -56,10 +56,11 @@ its-rpc-handler = { path = "../sidechain/rpc-handler" } its-storage = { path = "../sidechain/storage" } # scs / integritee + my-node-runtime = { package = "integritee-node-runtime", git = "https://github.com/integritee-network/integritee-node.git", branch = "polkadot-v0.9.37" } substrate-api-client = { git = "https://github.com/scs/substrate-api-client.git", branch = "polkadot-v0.9.37-tag-v0.7.0" } -teerex-primitives = { git = "https://github.com/integritee-network/pallets.git", branch = "polkadot-v0.9.37" } -sgx-verify = { git = "https://github.com/integritee-network/pallets.git", branch = "polkadot-v0.9.37" } +teerex-primitives = { git = "https://github.com/OverOrion/pallets.git", branch = "szp/extract-tcb-info" } +sgx-verify = { git = "https://github.com/OverOrion/pallets.git", branch = "szp/extract-tcb-info" } # Substrate dependencies frame-support = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.37" } diff --git a/service/src/main.rs b/service/src/main.rs index bcba9a00b1..8eafd46d05 100644 --- a/service/src/main.rs +++ b/service/src/main.rs @@ -75,6 +75,8 @@ use its_storage::{interface::FetchBlocks, BlockPruner, SidechainStorageLock}; use log::*; use my_node_runtime::{Hash, Header, RuntimeEvent}; use sgx_types::*; + +#[cfg(feature = "dcap")] use sgx_verify::extract_tcb_info_from_raw_dcap_quote; use sp_core::crypto::{AccountId32, Ss58Codec}; @@ -432,6 +434,7 @@ fn start_worker( register_collateral(&node_api, &*enclave, &tee_accountid, is_development_mode, skip_ra); let trusted_url = config.trusted_worker_url_external(); + #[cfg(feature = "dcap")] let marblerun_base_url = run_config.marblerun_base_url.unwrap_or("http://localhost:9944".to_owned()); diff --git a/service/src/prometheus_metrics.rs b/service/src/prometheus_metrics.rs index 40f8d19c0c..42f183dc5f 100644 --- a/service/src/prometheus_metrics.rs +++ b/service/src/prometheus_metrics.rs @@ -25,7 +25,9 @@ use crate::{ error::{Error, ServiceResult}, }; use async_trait::async_trait; +#[cfg(feature = "dcap")] use core::time::Duration; +#[cfg(feature = "dcap")] use itc_rest_client::{ http_client::{DefaultSend, HttpClient}, rest_client::{RestClient, Url as URL}, @@ -183,12 +185,14 @@ impl ReceiveEnclaveMetrics for EnclaveMetricsReceiver { #[derive(Serialize, Deserialize, Debug)] struct PrometheusMarblerunEvents(pub Vec); +#[cfg(feature = "dcap")] impl RestPath<&str> for PrometheusMarblerunEvents { fn get_path(path: &str) -> Result { Ok(format!("{}", path)) } } +#[cfg(feature = "dcap")] pub fn fetch_marblerun_events(base_url: &str) -> Result, Error> { let base_url = URL::parse(&base_url).map_err(|e| { Error::Custom( @@ -216,6 +220,7 @@ pub struct PrometheusMarblerunEvent { pub activation: PrometheusMarblerunEventActivation, } +#[cfg(feature = "dcap")] impl PrometheusMarblerunEvent { pub fn get_quote_without_prepended_bytes(&self) -> &[u8] { let marblerun_magic_prepended_header_size = 16usize;