Skip to content

Commit

Permalink
feat(raiko): Sgx output print for better debug experience (#182)
Browse files Browse the repository at this point in the history
* update blob data format as some nodes return differently

* code refine, print sgx guest output

Signed-off-by: smtmfft <smtm@taiko.xyz>

---------

Signed-off-by: smtmfft <smtm@taiko.xyz>
  • Loading branch information
smtmfft committed May 13, 2024
1 parent 6a8421d commit f0a602e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
2 changes: 1 addition & 1 deletion provers/sgx/config/sgx-guest.docker.manifest.template
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ sgx.trusted_files = [
"file:/usr/lib/ssl/certs/",
"file:sgx-guest",
]
sgx.max_threads = 16
sgx.max_threads = 32
sgx.remote_attestation = "dcap"
sys.enable_extra_runtime_domain_names_conf = true
sys.insecure__allow_eventfd = true
Expand Down
2 changes: 1 addition & 1 deletion provers/sgx/config/sgx-guest.local.manifest.template
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ sgx.trusted_files = [
"file:/usr/lib/ssl/certs/",
"file:sgx-guest",
]
sgx.max_threads = 16
sgx.max_threads = 32
sgx.remote_attestation = "dcap"
sys.enable_extra_runtime_domain_names_conf = true
sys.insecure__allow_eventfd = true
Expand Down
21 changes: 15 additions & 6 deletions provers/sgx/prover/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,13 +283,22 @@ async fn prove(
.spawn()
.map_err(|e| format!("Could not spawn gramine cmd: {e}"))?;
let stdin = child.stdin.as_mut().expect("Failed to open stdin");
bincode::serialize_into(stdin, &input).expect("Unable to serialize input");
let input_success = bincode::serialize_into(stdin, &input);
let output_success = child.wait_with_output();

let output = child
.wait_with_output()
.map_err(|e| handle_gramine_error("Could not run SGX guest prover", e))?;
handle_output(&output, "SGX prove")?;
Ok(parse_sgx_result(output.stdout)?)
match (input_success, output_success) {
(Ok(_), Ok(output)) => {
handle_output(&output, "SGX prove")?;
Ok(parse_sgx_result(output.stdout)?)
}
(Err(i), output_success) => Err(ProverError::GuestError(format!(
"Can not serialize input for SGX {}, output is {:?}",
i, output_success
))),
(Ok(_), Err(output_err)) => Err(ProverError::GuestError(
handle_gramine_error("Could not run SGX guest prover", output_err).to_string(),
)),
}
})
.await
.map_err(|e| ProverError::GuestError(e.to_string()))?
Expand Down

0 comments on commit f0a602e

Please sign in to comment.