-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding integration tests for the omni-executor (#3255)
- Loading branch information
Showing
32 changed files
with
6,313 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
tee-worker/omni-executor/parentchain/attestation/Cargo.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
[package] | ||
name = "parentchain-attestation" | ||
version = "0.1.0" | ||
authors = ['Trust Computing GmbH <[email protected]>'] | ||
edition.workspace = true | ||
|
||
[dependencies] | ||
log = { workspace = true } | ||
subxt-core = { workspace = true } | ||
subxt-signer = { workspace = true } | ||
|
||
# Local dependencies | ||
parentchain-api-interface = { workspace = true } | ||
parentchain-rpc-client = { workspace = true } | ||
parentchain-signer = { workspace = true } | ||
|
||
[dev-dependencies] | ||
env_logger = { workspace = true } | ||
|
||
[lints] | ||
workspace = true | ||
|
||
[features] | ||
gramine-quote = [] |
66 changes: 66 additions & 0 deletions
66
tee-worker/omni-executor/parentchain/attestation/src/lib.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
use parentchain_api_interface::{ | ||
runtime_types::core_primitives::teebag::types::DcapProvider, | ||
teebag::calls::types::register_enclave::{AttestationType, WorkerMode, WorkerType}, | ||
}; | ||
use parentchain_rpc_client::{ | ||
metadata::SubxtMetadataProvider, CustomConfig, SubstrateRpcClient, SubxtClient, | ||
SubxtClientFactory, | ||
}; | ||
use parentchain_signer::{key_store::SubstrateKeyStore, TransactionSigner}; | ||
use std::sync::Arc; | ||
use subxt_core::Metadata; | ||
use subxt_signer::sr25519::Keypair; | ||
|
||
type TxSigner = TransactionSigner< | ||
SubstrateKeyStore, | ||
SubxtClient<CustomConfig>, | ||
SubxtClientFactory<CustomConfig>, | ||
CustomConfig, | ||
Metadata, | ||
SubxtMetadataProvider<CustomConfig>, | ||
>; | ||
|
||
#[allow(unused_assignments, unused_mut, unused_variables)] | ||
pub async fn perform_attestation( | ||
client_factory: Arc<SubxtClientFactory<CustomConfig>>, | ||
signer: Keypair, | ||
transaction_signer: Arc<TxSigner>, | ||
) -> Result<(), ()> { | ||
let mut quote = vec![]; | ||
let mut attestation_type = AttestationType::Dcap(DcapProvider::Intel); | ||
|
||
#[cfg(feature = "gramine-quote")] | ||
{ | ||
use log::info; | ||
use std::fs; | ||
use std::fs::File; | ||
use std::io::Write; | ||
let mut f = File::create("/dev/attestation/user_report_data").unwrap(); | ||
let content = signer.public_key().0; | ||
f.write_all(&content).unwrap(); | ||
|
||
quote = fs::read("/dev/attestation/quote").unwrap(); | ||
info!("Attestation quote {:?}", quote); | ||
} | ||
#[cfg(not(feature = "gramine-quote"))] | ||
{ | ||
attestation_type = AttestationType::Ignore; | ||
} | ||
|
||
let registration_call = parentchain_api_interface::tx().teebag().register_enclave( | ||
WorkerType::OmniExecutor, | ||
WorkerMode::OffChainWorker, | ||
quote, | ||
vec![], | ||
None, | ||
None, | ||
attestation_type, | ||
); | ||
|
||
let mut client = client_factory.new_client_until_connected().await; | ||
let signed_call = transaction_signer.sign(registration_call).await; | ||
client.submit_tx(&signed_call).await.map_err(|e| { | ||
log::error!("Error while submitting tx: {:?}", e); | ||
})?; | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,6 +29,3 @@ env_logger = { workspace = true } | |
|
||
[lints] | ||
workspace = true | ||
|
||
[features] | ||
gramine-quote = [] |
Oops, something went wrong.