#![feature(test)]
#![feature(arbitrary_self_types)]
#![feature(const_option)]
use lazy_static::lazy_static;
#[cfg(target_env = "sgx")]
use sgx_isa::{AttributesFlags, Report};
#[cfg_attr(test, macro_use)]
extern crate base64_serde;
#[macro_use]
pub mod common;
mod attestation;
pub mod cache;
pub mod config;
pub mod consensus;
pub mod dispatcher;
pub mod enclave_rpc;
pub mod future;
pub mod host;
pub mod identity;
pub mod init;
pub mod policy;
pub mod protocol;
pub mod rofl;
pub mod storage;
pub mod transaction;
pub mod types;
use crate::common::version::{Version, PROTOCOL_VERSION};
#[cfg(target_env = "sgx")]
use self::common::sgx::{EnclaveIdentity, MrSigner};
#[cfg(all(target_env = "sgx", feature = "debug-mock-sgx"))]
compile_error!("the debug-mock-sgx feature can only be enabled on non-sgx targets");
lazy_static! {
pub static ref BUILD_INFO: BuildInfo = {
#[cfg(not(target_env = "sgx"))]
let is_secure = false;
#[cfg(target_env = "sgx")]
let is_secure = {
let maybe_secure = true;
let maybe_secure = maybe_secure && option_env!("OASIS_UNSAFE_SKIP_AVR_VERIFY").is_none();
let maybe_secure = maybe_secure && option_env!("OASIS_UNSAFE_ALLOW_DEBUG_ENCLAVES").is_none();
let maybe_secure = maybe_secure && option_env!("OASIS_UNSAFE_LAX_AVR_VERIFY").is_none();
let maybe_secure = maybe_secure && !Report::for_self().attributes.flags.contains(AttributesFlags::DEBUG);
let enclave_identity = EnclaveIdentity::current().unwrap();
let fortanix_mrsigner = MrSigner::from("9affcfae47b848ec2caf1c49b4b283531e1cc425f93582b36806e52a43d78d1a");
let maybe_secure = maybe_secure && (enclave_identity.mr_signer != fortanix_mrsigner);
maybe_secure
};
BuildInfo {
protocol_version: PROTOCOL_VERSION,
is_secure,
}
};
}
pub struct BuildInfo {
pub protocol_version: Version,
pub is_secure: bool,
}
pub use self::{
enclave_rpc::{demux::Demux as RpcDemux, dispatcher::Dispatcher as RpcDispatcher},
init::start_runtime,
protocol::Protocol,
transaction::dispatcher::Dispatcher as TxnDispatcher,
};
pub use cbor;