From 6b9ba39dfeea7e49666ab4f99ab2ba7aeadcd8fe Mon Sep 17 00:00:00 2001 From: vlad Date: Wed, 20 Nov 2024 09:57:58 +0000 Subject: [PATCH] check_hw: added migrate_op --- check-hw/src/enclave_api.rs | 2 ++ check-hw/src/main.rs | 62 ++++++++++++++++++++++++------------- 2 files changed, 42 insertions(+), 22 deletions(-) diff --git a/check-hw/src/enclave_api.rs b/check-hw/src/enclave_api.rs index ac3169fd6..69a44fe56 100644 --- a/check-hw/src/enclave_api.rs +++ b/check-hw/src/enclave_api.rs @@ -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 diff --git a/check-hw/src/main.rs b/check-hw/src/main.rs index b3abd4faf..570b2985e 100644 --- a/check-hw/src/main.rs +++ b/check-hw/src/main.rs @@ -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; @@ -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"); @@ -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::().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") + } } }