diff --git a/cli/src/base_cli/commands/transfer.rs b/cli/src/base_cli/commands/transfer.rs index 3ea285cb40..d5894f80c1 100644 --- a/cli/src/base_cli/commands/transfer.rs +++ b/cli/src/base_cli/commands/transfer.rs @@ -24,7 +24,7 @@ use log::*; use my_node_runtime::Balance; use sp_core::{crypto::Ss58Codec, sr25519 as sr25519_core, Pair}; use substrate_api_client::{ - extrinsic::BalancesExtrinsics, GetAccountInformation, SubmitAndWatch, XtStatus, + extrinsic::BalancesExtrinsics, GetAccountInformation, SubmitAndWatchUntilSuccess, }; #[derive(Parser)] @@ -48,11 +48,11 @@ impl TransferCommand { let mut api = get_chain_api(cli); api.set_signer(ParentchainExtrinsicSigner::new(sr25519_core::Pair::from(from_account))); let xt = api.balance_transfer_allow_death(Address::Id(to_account.clone()), self.amount); - let tx_hash = api - .submit_and_watch_extrinsic_until(xt, XtStatus::InBlock) - .unwrap() - .extrinsic_hash; - println!("[+] TrustedOperation got finalized. Hash: {:?}\n", tx_hash); + let tx_report = api.submit_and_watch_extrinsic_until_success(xt, false).unwrap(); + println!( + "[+] L1 extrinsic success. extrinsic hash: {:?} / status: {:?}", + tx_report.extrinsic_hash, tx_report.status + ); let result = api.get_account_data(&to_account).unwrap().unwrap(); let balance = result.free; println!("balance for {} is now {}", to_account, balance); diff --git a/core-primitives/attestation-handler/src/attestation_handler.rs b/core-primitives/attestation-handler/src/attestation_handler.rs index fa2058d563..91bfc77f3a 100644 --- a/core-primitives/attestation-handler/src/attestation_handler.rs +++ b/core-primitives/attestation-handler/src/attestation_handler.rs @@ -48,7 +48,7 @@ use sgx_tcrypto::{rsgx_sha256_slice, SgxEccHandle}; use sgx_tse::{rsgx_create_report, rsgx_verify_report}; use sgx_types::{ c_int, sgx_epid_group_id_t, sgx_quote_nonce_t, sgx_quote_sign_type_t, sgx_report_data_t, - sgx_spid_t, sgx_status_t, sgx_status_t::SGX_ERROR_UNEXPECTED, sgx_target_info_t, SgxResult, *, + sgx_spid_t, sgx_status_t, sgx_target_info_t, SgxResult, *, }; use sp_core::{ed25519, Pair}; use std::{ @@ -678,7 +678,7 @@ where .map_err(|e| EnclaveError::Other(e.into())) } - /// Returns Ok if the verification of the quote by the quote verification enclave (QVE) was successful + /// Returns Ok if the verification of the quote by the quote verification enclave (QVE) was successful pub fn ecdsa_quote_verification(&self, quote: Vec) -> SgxResult<()> { let mut app_enclave_target_info: sgx_target_info_t = unsafe { std::mem::zeroed() }; let quote_collateral: sgx_ql_qve_collateral_t = unsafe { std::mem::zeroed() }; diff --git a/core-primitives/attestation-handler/src/cert.rs b/core-primitives/attestation-handler/src/cert.rs index ae158f661b..99c0d8529b 100644 --- a/core-primitives/attestation-handler/src/cert.rs +++ b/core-primitives/attestation-handler/src/cert.rs @@ -283,11 +283,11 @@ where // Obtain Netscape Comment offset += 1; let mut payload = cert_der[offset..offset + len].to_vec(); - println!("payload in mra cert verifier is: {:#?}", &payload); + trace!("payload in mra cert verifier is: {:?}", &payload); if is_payload_base64_encoded { payload = base64::decode(&payload[..]).or(Err(sgx_status_t::SGX_ERROR_UNEXPECTED))?; } - println!("payload in mra cert verifier is: {:#?}", &payload); + trace!("payload in mra cert verifier is: {:?}", &payload); if !is_dcap { // Extract each field let mut iter = payload.split(|x| *x == b'|'); diff --git a/service/src/account_funding.rs b/service/src/account_funding.rs index 68c2585019..15c5038bf0 100644 --- a/service/src/account_funding.rs +++ b/service/src/account_funding.rs @@ -30,7 +30,7 @@ use sp_core::{ use sp_keyring::AccountKeyring; use sp_runtime::MultiAddress; use substrate_api_client::{ - extrinsic::BalancesExtrinsics, GetBalance, GetTransactionPayment, SubmitAndWatch, XtStatus, + extrinsic::BalancesExtrinsics, GetBalance, GetTransactionPayment, SubmitAndWatchUntilSuccess, }; /// Information about the enclave on-chain account. @@ -155,15 +155,14 @@ fn bootstrap_funds_from_alice( let mut alice_signer_api = api.clone(); alice_signer_api.set_signer(ParentchainExtrinsicSigner::new(alice)); - println!("[+] bootstrap funding Enclave from Alice's funds"); + println!("[+] send extrinsic: bootstrap funding Enclave from Alice's funds"); let xt = alice_signer_api .balance_transfer_allow_death(MultiAddress::Id(accountid.clone()), funding_amount); - let xt_report = alice_signer_api.submit_and_watch_extrinsic_until(xt, XtStatus::InBlock)?; + let xt_report = alice_signer_api.submit_and_watch_extrinsic_until_success(xt, false)?; info!( - "[<] Extrinsic got included in a block. Extrinsic Hash: {:?}\n", - xt_report.extrinsic_hash + "[<] L1 extrinsic success. extrinsic hash: {:?} / status: {:?}", + xt_report.extrinsic_hash, xt_report.status ); - // Verify funds have arrived. let free_balance = alice_signer_api.get_free_balance(accountid); info!("TEE's NEW free balance = {:?}", free_balance); diff --git a/service/src/main.rs b/service/src/main.rs index 62cdff3a35..bdda6d0b2b 100644 --- a/service/src/main.rs +++ b/service/src/main.rs @@ -480,6 +480,7 @@ fn start_worker( let register_xt = move || enclave2.generate_dcap_ra_extrinsic(&trusted_url, skip_ra).unwrap(); let send_register_xt = move || { + println!("[+] Send register enclave extrinsic"); send_extrinsic(register_xt(), &node_api2, &tee_accountid.clone(), is_development_mode) }; @@ -814,20 +815,23 @@ fn send_extrinsic( accountid: &AccountId32, is_development_mode: bool, ) -> Option { - // Account funds + // ensure account funds if let Err(x) = setup_account_funding(api, accountid, extrinsic.clone(), is_development_mode) { - error!("Starting worker failed: {:?}", x); + error!("Ensure enclave funding failed: {:?}", x); // Return without registering the enclave. This will fail and the transaction will be banned for 30min. return None } - println!("[>] send extrinsic"); + info!("[>] send extrinsic"); + trace!(" encoded extrinsic: 0x{:}", hex::encode(extrinsic.clone())); match api.submit_and_watch_opaque_extrinsic_until_success(extrinsic.into(), true) { Ok(xt_report) => { - let register_qe_block_hash = xt_report.block_hash; - println!("[<] Extrinsic got finalized. Block hash: {:?}\n", register_qe_block_hash); - register_qe_block_hash + info!( + "[+] L1 extrinsic success. extrinsic hash: {:?} / status: {:?}", + xt_report.extrinsic_hash, xt_report.status + ); + xt_report.block_hash }, Err(e) => { error!("ExtrinsicFailed {:?}", e); @@ -878,5 +882,10 @@ fn we_are_primary_validateer( ) -> Result { let enclave_count_of_previous_block = node_api.enclave_count(Some(*register_enclave_xt_header.parent_hash()))?; + println!( + "enclave count is {} for previous block 0x{:?}", + enclave_count_of_previous_block, + register_enclave_xt_header.parent_hash() + ); Ok(enclave_count_of_previous_block == 0) }