diff --git a/Cargo.lock b/Cargo.lock index 2da3e366..c4bbc0da 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6275,6 +6275,7 @@ dependencies = [ "serde", "serde_json", "sha3", + "thiserror", "tokio", ] diff --git a/pipeline/src/builder.rs b/pipeline/src/builder.rs index a27c0b71..e5a42991 100644 --- a/pipeline/src/builder.rs +++ b/pipeline/src/builder.rs @@ -222,9 +222,9 @@ impl CommandBuilder { // ├── build/ // ├── main --> this is the output (same) // └── bin2 --> this is the output (same) - pub fn build_command(&self, profile: &str, bins: &Vec) -> Executor { + pub fn build_command(&self, profile: &str, bins: &[String]) -> Executor { let args = vec!["build".to_string()]; - let cmd = self.inner_command(args, profile, bins.clone()); + let cmd = self.inner_command(args, profile, bins.to_owned()); let target_path: PathBuf = self .meta .target_directory @@ -362,7 +362,7 @@ fn to_strings(strs: &[&str]) -> Vec { strs.iter().map(|s| s.to_string()).collect() } -pub fn format_flags(flag: &str, items: &Vec) -> Vec { +pub fn format_flags(flag: &str, items: &[String]) -> Vec { let res = items.iter().fold(Vec::new(), |mut res, i| { res.extend([flag.to_owned(), i.to_owned()]); res diff --git a/pipeline/src/executor.rs b/pipeline/src/executor.rs index b1a0b7ed..a7bca210 100644 --- a/pipeline/src/executor.rs +++ b/pipeline/src/executor.rs @@ -2,7 +2,6 @@ use anyhow::Result; use crate::ROOT_DIR; use regex::Regex; -use std::fs::File; use std::io::BufRead; use std::{ fs, @@ -11,6 +10,7 @@ use std::{ process::{Command, Stdio}, thread, }; +use std::{fs::File, path::Path}; #[derive(Debug)] pub struct Executor { @@ -107,7 +107,7 @@ impl Executor { } } -fn file_name(path: &PathBuf) -> String { +fn file_name(path: &Path) -> String { String::from(path.file_name().unwrap().to_str().unwrap()) } diff --git a/pipeline/src/risc0_util.rs b/pipeline/src/risc0_util.rs index e9e68d26..01b56c1a 100644 --- a/pipeline/src/risc0_util.rs +++ b/pipeline/src/risc0_util.rs @@ -7,6 +7,7 @@ use std::{ pub const DIGEST_WORDS: usize = 8; +#[allow(dead_code)] pub fn risc0_data() -> Result { let dir = if let Ok(dir) = std::env::var("RISC0_DATA_DIR") { dir.into() @@ -27,6 +28,7 @@ pub struct GuestListEntry { /// The name of the guest binary pub name: Cow<'static, str>, /// The compiled ELF guest binary + #[allow(dead_code)] pub elf: Cow<'static, [u8]>, /// The image id of the guest pub image_id: [u32; DIGEST_WORDS], diff --git a/provers/sgx/guest/Cargo.toml b/provers/sgx/guest/Cargo.toml index 883b0c89..cec84822 100644 --- a/provers/sgx/guest/Cargo.toml +++ b/provers/sgx/guest/Cargo.toml @@ -10,6 +10,7 @@ raiko-lib = { workspace = true, features = ["sgx"] } raiko-primitives = { workspace = true } tokio = { workspace = true } anyhow = { workspace = true } +thiserror = { workspace = true } secp256k1 = { workspace = true } serde = { workspace = true } rand = { workspace = true } diff --git a/provers/sgx/guest/src/one_shot.rs b/provers/sgx/guest/src/one_shot.rs index 74ae7d60..4bdd12df 100644 --- a/provers/sgx/guest/src/one_shot.rs +++ b/provers/sgx/guest/src/one_shot.rs @@ -1,6 +1,6 @@ use std::{ fs::{self, File, OpenOptions}, - io::prelude::*, + io::{prelude::*, Write}, os::unix::fs::PermissionsExt, path::{Path, PathBuf}, }; @@ -78,12 +78,16 @@ fn save_bootstrap_details( Ok(()) } +#[derive(Debug, thiserror::Error)] pub enum BootStrapError { // file does not exist + #[error("File does not exist")] NotExist, // file exists but has wrong permissions + #[error("File exists but has wrong permissions")] WithWrongPermissions, // file exists but could not be read normally due to mrenclave change + #[error("File exists but could not be read normally due to mrenclave change: {0}")] DecryptionError(String), } diff --git a/provers/sgx/prover/src/sgx_register_utils.rs b/provers/sgx/prover/src/sgx_register_utils.rs index 1ce06f10..27a3f1b9 100644 --- a/provers/sgx/prover/src/sgx_register_utils.rs +++ b/provers/sgx/prover/src/sgx_register_utils.rs @@ -75,6 +75,7 @@ sol! { } #[sol(rpc)] + #[allow(dead_code)] contract SgxVerifier { event InstanceAdded( uint256 indexed id, address indexed instance, address replaced, uint256 validSince