Skip to content

Commit

Permalink
check_hw: added migrate_op
Browse files Browse the repository at this point in the history
  • Loading branch information
vlad committed Nov 20, 2024
1 parent 4ecfa31 commit 6b9ba39
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 22 deletions.
2 changes: 2 additions & 0 deletions check-hw/src/enclave_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ extern "C" {
api_key: *const u8,
api_key_len: u32,
) -> sgx_status_t;

pub fn ecall_migration_op(opcode: u32) -> sgx_status_t;
}

// ocalls
Expand Down
62 changes: 40 additions & 22 deletions check-hw/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ use clap::App;
use lazy_static::lazy_static;
use sgx_types::sgx_status_t;

use crate::{enclave_api::ecall_check_patch_level, types::EnclaveDoorbell};
use crate::{
enclave_api::ecall_check_patch_level, enclave_api::ecall_migration_op, types::EnclaveDoorbell,
};

use enclave_ffi_types::NodeAuthResult;

Expand Down Expand Up @@ -35,6 +37,13 @@ fn main() {
.long("testnet")
.help("Run in testnet mode"),
)
.arg(
clap::Arg::with_name("migrate_op")
.long("migrate_op")
.value_name("NUMBER") // Describes the expected value
.help("Specify the migrate operation mode")
.takes_value(true), // Indicates this flag takes a value
)
.get_matches();

let is_testnet = matches.is_present("testnet");
Expand Down Expand Up @@ -68,29 +77,38 @@ fn main() {
};

let eid = enclave.unwrap().geteid();
let mut retval = NodeAuthResult::Success;
let status = unsafe {
ecall_check_patch_level(
eid,
&mut retval,
api_key_bytes.as_ptr(),
api_key_bytes.len() as u32,
)
};

if status != sgx_status_t::SGX_SUCCESS {
println!(
"Failed to run hardware verification test (is the correct enclave in the correct path?)"
);
return;
}
if let Some(migrate_op) = matches.value_of("migrate_op") {
let op = migrate_op.parse::<u32>().unwrap();

let status = unsafe { ecall_migration_op(op) };

if retval != NodeAuthResult::Success {
println!("Failed to verify platform. Please see errors above for more info on what needs to be fixed before you can run a mainnet node. \n\
If you require assistance or more information, please contact us on Discord or Telegram. In addition, you may use the documentation available at \
https://docs.scrt.network
");
println!("Migration op reval: {}", status);
} else {
println!("Platform verification successful! You are able to run a mainnet Secret node")
let mut retval = NodeAuthResult::Success;
let status = unsafe {
ecall_check_patch_level(
eid,
&mut retval,
api_key_bytes.as_ptr(),
api_key_bytes.len() as u32,
)
};

if status != sgx_status_t::SGX_SUCCESS {
println!(
"Failed to run hardware verification test (is the correct enclave in the correct path?)"
);
return;
}

if retval != NodeAuthResult::Success {
println!("Failed to verify platform. Please see errors above for more info on what needs to be fixed before you can run a mainnet node. \n\
If you require assistance or more information, please contact us on Discord or Telegram. In addition, you may use the documentation available at \
https://docs.scrt.network
");
} else {
println!("Platform verification successful! You are able to run a mainnet Secret node")
}
}
}

0 comments on commit 6b9ba39

Please sign in to comment.