Skip to content
This repository has been archived by the owner on Nov 4, 2021. It is now read-only.

Commit

Permalink
bump to 0.6.1. better logging, more consistent starage prefix naming
Browse files Browse the repository at this point in the history
  • Loading branch information
Alain Brenzikofer committed Apr 30, 2020
1 parent 72d1355 commit 8cb8b28
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "pallet-substratee-registry"
version = "0.6.0"
version = "0.6.1"
authors = ["Supercomputing Systems AG <[email protected]>"]
edition = "2018"

Expand Down
4 changes: 4 additions & 0 deletions ias-verify/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 3 additions & 4 deletions ias-verify/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down Expand Up @@ -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,
Expand All @@ -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],
Expand Down
12 changes: 6 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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<PubKey, Url> {
pub pubkey: PubKey, // FIXME: this is redundant information
pub mr_enclave: [u8; 32],
Expand All @@ -43,8 +43,7 @@ pub struct Enclave<PubKey, Url> {

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<u8>,
Expand All @@ -64,7 +63,7 @@ decl_event!(
);

decl_storage! {
trait Store for Module<T: Trait> as substraTEERegistry {
trait Store for Module<T: Trait> 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.
Expand Down Expand Up @@ -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(<Error<T>>::EnclaveSignerDecodeError.into())
Expand Down Expand Up @@ -147,7 +147,7 @@ decl_module! {
let sender_index = Self::enclave_index(&sender);
<LatestIpfsHash>::insert(shard, ipfs_hash.clone());
<WorkerForShard>::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(())
Expand Down

0 comments on commit 8cb8b28

Please sign in to comment.