From 8cb8b286a2af7796cbd13c9ceb8306069b40fa80 Mon Sep 17 00:00:00 2001 From: Alain Brenzikofer Date: Thu, 30 Apr 2020 14:29:59 +0200 Subject: [PATCH] bump to 0.6.1. better logging, more consistent starage prefix naming --- Cargo.toml | 2 +- ias-verify/Cargo.toml | 4 ++++ ias-verify/src/lib.rs | 7 +++---- src/lib.rs | 12 ++++++------ 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index e935b4d..9a28a9b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pallet-substratee-registry" -version = "0.6.0" +version = "0.6.1" authors = ["Supercomputing Systems AG "] edition = "2018" diff --git a/ias-verify/Cargo.toml b/ias-verify/Cargo.toml index b349496..e9c4f27 100644 --- a/ias-verify/Cargo.toml +++ b/ias-verify/Cargo.toml @@ -28,6 +28,10 @@ default-features = false version = '2.0.0-alpha.6' features = ["disable_panic_handler", "disable_oom"] +[dependencies.sp-core] +default-features = false +version = '2.0.0-alpha.6' + [dependencies.webpki] git = 'https://github.com/Phala-Network/phala-blockchain.git' default_features = false diff --git a/ias-verify/src/lib.rs b/ias-verify/src/lib.rs index 6b2d536..ea2becf 100644 --- a/ias-verify/src/lib.rs +++ b/ias-verify/src/lib.rs @@ -28,6 +28,7 @@ use chrono::prelude::*; //use super::{SgxReport, SgxStatus}; use codec::{Encode, Decode}; use serde_json::Value; +use frame_support::debug::native; const SGX_REPORT_DATA_SIZE: usize = 64; #[derive(Encode, Decode, Copy, Clone)] @@ -76,8 +77,7 @@ pub struct SgxQuote { //signature: [u8; 64] /* 436 */ //must be hard-coded for SCALE codec } -#[derive(Encode, Decode, Copy, Clone, PartialEq)] -#[cfg_attr(feature = "std", derive(Debug))] +#[derive(Encode, Decode, Copy, Clone, PartialEq, sp_core::RuntimeDebug)] pub enum SgxStatus { Invalid, Ok, @@ -91,8 +91,7 @@ impl Default for SgxStatus { } } -#[derive(Encode, Decode, Default, Copy, Clone, PartialEq)] -#[cfg_attr(feature = "std", derive(Debug))] +#[derive(Encode, Decode, Default, Copy, Clone, PartialEq, sp_core::RuntimeDebug)] pub struct SgxReport { pub mr_enclave: [u8; 32], pub pubkey: [u8; 32], diff --git a/src/lib.rs b/src/lib.rs index 745843d..469a66f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -23,6 +23,7 @@ use sp_std::str; use sp_io::misc::print_utf8; use frame_support::{decl_event, decl_module, decl_storage, decl_error, dispatch::DispatchResult, ensure}; +use frame_support::debug::native; use frame_system::{self as system, ensure_signed}; use ias_verify::{SgxReport, verify_ias_report}; pub trait Trait: system::Trait { @@ -32,8 +33,7 @@ pub trait Trait: system::Trait { const MAX_RA_REPORT_LEN: usize = 4096; const MAX_URL_LEN: usize = 256; -#[derive(Encode, Decode, Default, Copy, Clone, PartialEq)] -#[cfg_attr(feature = "std", derive(Debug))] +#[derive(Encode, Decode, Default, Copy, Clone, PartialEq, sp_core::RuntimeDebug)] pub struct Enclave { pub pubkey: PubKey, // FIXME: this is redundant information pub mr_enclave: [u8; 32], @@ -43,8 +43,7 @@ pub struct Enclave { pub type ShardIdentifier = H256; -#[derive(Encode, Decode, Debug, Default, Clone, PartialEq, Eq)] -//#[cfg_attr(feature = "std", derive(Debug))] +#[derive(Encode, Decode, Default, Clone, PartialEq, Eq, sp_core::RuntimeDebug)] pub struct Request { pub shard: ShardIdentifier, pub cyphertext: Vec, @@ -64,7 +63,7 @@ decl_event!( ); decl_storage! { - trait Store for Module as substraTEERegistry { + trait Store for Module as SubstrateeRegistry { // Simple lists are not supported in runtime modules as theoretically O(n) // operations can be executed while only being charged O(1), see substrate // Kitties tutorial Chapter 2, Tracking all Kitties. @@ -97,6 +96,7 @@ decl_module! { print_utf8(b"substraTEE_registry: parameter lenght ok"); match verify_ias_report(&ra_report) { Ok(report) => { + native::info!("RA Report: {:?}", report); let enclave_signer = match T::AccountId::decode(&mut &report.pubkey[..]) { Ok(signer) => signer, Err(_) => return Err(>::EnclaveSignerDecodeError.into()) @@ -147,7 +147,7 @@ decl_module! { let sender_index = Self::enclave_index(&sender); ::insert(shard, ipfs_hash.clone()); ::insert(shard, sender_index); - + native::debug!("call confirmed with shard {:?}, call hash {:?}, ipfs_hash {:?}", shard, call_hash, ipfs_hash); Self::deposit_event(RawEvent::CallConfirmed(sender, call_hash)); Self::deposit_event(RawEvent::UpdatedIpfsHash(shard, sender_index, ipfs_hash)); Ok(())