-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Attesteer RPC additions #1201
Merged
OverOrion
merged 22 commits into
integritee-network:master
from
OverOrion:szp/attesteer-rpc
Apr 3, 2023
Merged
Attesteer RPC additions #1201
Changes from 7 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
378652e
rpc: add attesteer_forward_dcap_quote call
OverOrion 5862ee0
rpc: add attesteer_forward_ias_attestation_report
OverOrion 3865f59
remove unused variables
OverOrion 296ce9c
enclave-runtime/attestation: remove duplicate code
OverOrion ad76638
enclave-runtime/attestation: extract extrinsic sending
OverOrion 3b21f0a
enclave-runtime/attestaion: refactor generate_dcap_ra_extrinsic_inter…
OverOrion 5f1c56f
attesteer: add attesteer RPC calls to the CLI
OverOrion 6e4a5c1
compiling
OverOrion 9a11f6b
cli: attesteer dcap quote verification takes a filename (to a hex enc…
OverOrion 3c184f4
cli: attesteer ias attestation report takes a filename (to a hex enco…
OverOrion 74c7597
clippy: fix needless borrow
OverOrion 376dc0b
rename: match substrate convention for RPC method names
OverOrion ac5fcc5
rename: SendDCAPQuoteCmd -> SendDcapQuoteCmd
OverOrion 43aa983
rename: SendIASAttestationReportCmd -> SendIasAttestationReportCmd
OverOrion 554eea9
rename: attesteer_callForwardIASAttestationReport -> attesteer_Forwar…
OverOrion a7e5f80
rename: attesteer_callForwardDCAPQuote -> attesteer_ForwardDcapQuote
OverOrion e6cdacc
cli: refactor attesteer comamnds to use a neat match expressions
OverOrion 6875baa
cli: attesteer commands use let-else pattern
OverOrion c920561
cli: attesteer commands send to chain
OverOrion 5b94a6c
rename: attesteer_Forward -> attesteer_forward
OverOrion 2cb4162
Merge branch 'master' into szp/attesteer-rpc
OverOrion 8d75580
Merge branch 'master' into szp/attesteer-rpc
OverOrion File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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 |
---|---|---|
|
@@ -19,43 +19,42 @@ use itc_rpc_client::direct_client::DirectApi; | |
use itp_rpc::{RpcRequest, RpcResponse, RpcReturnValue}; | ||
use itp_types::DirectRequestStatus; | ||
use itp_utils::FromHexPrefixed; | ||
use log::error; | ||
use log::*; | ||
use std::fs::read_to_string; | ||
|
||
use crate::{command_utils::get_worker_api_direct, Cli}; | ||
|
||
/// Forward IAS attestation report for verification. | ||
#[derive(Debug, Clone, Parser)] | ||
pub struct SendIASAttestationReportCmd { | ||
pub struct SendIasAttestationReportCmd { | ||
/// Hex encoded IAS attestation report filename. | ||
report: String, | ||
} | ||
|
||
impl SendIASAttestationReportCmd { | ||
impl SendIasAttestationReportCmd { | ||
pub fn run(&self, cli: &Cli) { | ||
let direct_api = get_worker_api_direct(cli); | ||
let hex_encoded_report = read_to_string(&self.report) | ||
.map_err(|e| error!("Opening hex encoded IAS attestation report file failed: {:#?}", e)) | ||
.unwrap(); | ||
let hex_encoded_report = match read_to_string(&self.report) { | ||
Ok(hex_encoded_report) => hex_encoded_report, | ||
Err(e) => panic!("Opening hex encoded IAS attestation report file failed: {:#?}", e), | ||
}; | ||
|
||
//let request = Request { shard, cyphertext: hex_encoded_quote.to_vec() }; | ||
|
||
let rpc_method = "attesteer_callForwardIASAttestationReport".to_owned(); | ||
let rpc_method = "attesteer_ForwardIasAttestationReport".to_owned(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same, small 'f' please :) |
||
let jsonrpc_call: String = | ||
RpcRequest::compose_jsonrpc_call(rpc_method, vec![hex_encoded_report]).unwrap(); | ||
|
||
let rpc_response_str = direct_api.get(&jsonrpc_call).unwrap(); | ||
|
||
// Decode RPC response. | ||
let rpc_response: RpcResponse = serde_json::from_str(&rpc_response_str).ok().unwrap(); | ||
let rpc_return_value = RpcReturnValue::from_hex(&rpc_response.result) | ||
// Replace with `inspect_err` once it's stable. | ||
.map_err(|e| { | ||
error!("Failed to decode RpcReturnValue: {:?}", e); | ||
e | ||
}) | ||
.ok() | ||
.unwrap(); | ||
let Ok(rpc_response) = serde_json::from_str::<RpcResponse>(&rpc_response_str) else { | ||
panic!("Can't parse RPC response: '{rpc_response_str}'"); | ||
}; | ||
let rpc_return_value = match RpcReturnValue::from_hex(&rpc_response.result) { | ||
Ok(rpc_return_value) => rpc_return_value, | ||
Err(e) => panic!("Failed to decode RpcReturnValue: {:?}", e), | ||
}; | ||
|
||
match rpc_return_value.status { | ||
DirectRequestStatus::Ok => println!("IAS attestation report verification succeded."), | ||
|
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
small 'f' please :)