From 87f596aae605a139f29744152b21f26a97170ec2 Mon Sep 17 00:00:00 2001 From: Alain Brenzikofer Date: Mon, 11 Sep 2023 12:15:48 +0200 Subject: [PATCH] tune log levels for demo --- .../commands/issue_node_template_xt.rs | 2 +- enclave-runtime/src/rpc/encointer_utils.rs | 24 ++++++++----------- enclave-runtime/src/rpc/worker_api_direct.rs | 4 +--- local-setup/py/worker.py | 12 ++++++---- service/src/account_funding.rs | 13 +++++----- 5 files changed, 27 insertions(+), 28 deletions(-) diff --git a/cli/src/personhood_oracle/commands/issue_node_template_xt.rs b/cli/src/personhood_oracle/commands/issue_node_template_xt.rs index 8b6a2f50..5bcf7aed 100644 --- a/cli/src/personhood_oracle/commands/issue_node_template_xt.rs +++ b/cli/src/personhood_oracle/commands/issue_node_template_xt.rs @@ -74,7 +74,7 @@ impl IssueNodeTemplateXtCmd { match rpc_return_value.status { DirectRequestStatus::Ok => { - println!("NodeTemplate Idex has been issued successfully."); + println!("NodeTemplate Index has been issued successfully."); }, _ => { let error_msg = "Node Template Xt issuance failed"; diff --git a/enclave-runtime/src/rpc/encointer_utils.rs b/enclave-runtime/src/rpc/encointer_utils.rs index b810814d..2cb715cd 100644 --- a/enclave-runtime/src/rpc/encointer_utils.rs +++ b/enclave-runtime/src/rpc/encointer_utils.rs @@ -23,7 +23,7 @@ use itp_component_container::ComponentGetter; use itp_ocall_api::EnclaveOnChainOCallApi; use itp_stf_primitives::types::AccountId; use itp_storage::{storage_double_map_key, StorageHasher}; -use itp_types::{WorkerRequest, WorkerResponse, parentchain::ParentchainId}; +use itp_types::{parentchain::ParentchainId, WorkerRequest, WorkerResponse}; use log::*; use std::cmp::min; @@ -52,12 +52,7 @@ fn get_reputation_ocall_api( cid: CommunityIdentifier, cindex: CeremonyIndexType, ) -> Reputation { - println!( - "requesting reputation for {:?}: cid is :{}, cindex is: {}", - prover, - cid, - cindex.clone() - ); + info!("requesting reputation for {:?}: cid is :{}, cindex is: {}", prover, cid, cindex.clone()); let unverified_reputation = Reputation::Unverified; let ocall_api = GLOBAL_OCALL_API_COMPONENT.get(); @@ -77,13 +72,14 @@ fn get_reputation_ocall_api( trace!("storage_hash is : {}", hex::encode(storage_hash.clone())); let requests = vec![WorkerRequest::ChainStorage(storage_hash, None)]; - let mut resp: Vec>> = match ocall_api.worker_request(requests, &ParentchainId::TargetA) { - Ok(response) => response, - Err(e) => { - error!("Worker response decode failed. Error: {:?}", e); - return unverified_reputation - }, - }; + let mut resp: Vec>> = + match ocall_api.worker_request(requests, &ParentchainId::TargetA) { + Ok(response) => response, + Err(e) => { + error!("Worker response decode failed. Error: {:?}", e); + return unverified_reputation + }, + }; let first = match resp.pop() { None => { diff --git a/enclave-runtime/src/rpc/worker_api_direct.rs b/enclave-runtime/src/rpc/worker_api_direct.rs index b052fba3..6ad1228d 100644 --- a/enclave-runtime/src/rpc/worker_api_direct.rs +++ b/enclave-runtime/src/rpc/worker_api_direct.rs @@ -543,14 +543,12 @@ fn issue_node_template_xt_inner(params: Params) -> Result<(), String> { let subject_template_idx: u32 = Decode::decode(&mut subject_template_idx_bytes.as_slice()) .map_err(|e| format!("{:?}", e))?; - println!("subject index on template is {}", subject_template_idx); + println!("subject index on node-template is {}", subject_template_idx); let call = OpaqueCall::from_tuple(&((7u8, 0u8), subject_template_idx)); - println!("encoded call: 0x{}", hex::encode(call.encode())); let extrinsics_factory = get_extrinsic_factory_from_target_b_solo_or_parachain().unwrap(); let extrinsics: Vec = extrinsics_factory.create_extrinsics(&[call], None).unwrap(); - println!("sending {} extrinsics: {:?}", extrinsics.len(), extrinsics); let validator_access = get_validator_accessor_from_target_b_solo_or_parachain().unwrap(); validator_access .execute_mut_on_validator(|v| v.send_extrinsics(extrinsics)) diff --git a/local-setup/py/worker.py b/local-setup/py/worker.py index abb1de76..0997141e 100644 --- a/local-setup/py/worker.py +++ b/local-setup/py/worker.py @@ -154,20 +154,24 @@ def run_in_background(self, log_file: TextIO, flags: [str] = None, subcommand_fl # Todo: make this configurable env = dict(os.environ, RUST_LOG='warn,ws=warn,sp_io=error,' - 'substrate_api_client=warn,' + 'substrate_api_client=error,' 'jsonrpsee_ws_client=warn,' 'jsonrpsee_ws_server=warn,' 'enclave_runtime=info,' - 'integritee_service=warn,' + 'enclave_runtime::rpc::encointer_utils=info,' + 'enclave_runtime::rpc::worker_api_direct=trace,' 'itp_stf_state_handler=debug,' - 'itp_extrinsics_factory=trace,' + 'itp_extrinsics_factory=warn,' 'its_consensus_common=debug,' 'its_consensus_aura=trace,' 'itc_parentchain_indirect_calls_executor=info,' 'itc_parentchain_light_client=info,' 'itc_parentchain_block_importer=debug,' 'ita_stf=debug,' - 'integritee_service=trace') + 'integritee_service=debug,' + 'integritee_service::parentchain_handler=warn,' + 'integritee_service::ocall_bridge=warn,' + 'integritee_service::account_funding=warn') worker_cmd = self._assemble_cmd(flags=flags, subcommand_flags=subcommand_flags) print("worker command is "+ str(worker_cmd)) return Popen( diff --git a/service/src/account_funding.rs b/service/src/account_funding.rs index d4d6df01..403a475d 100644 --- a/service/src/account_funding.rs +++ b/service/src/account_funding.rs @@ -100,10 +100,10 @@ fn ensure_account_has_funds(api: &ParentchainApi, accountid: &AccountId32) -> Re ); // check account balance let free_balance = api.get_free_balance(accountid)?; - info!("TEE's free balance = {:?} (Account: {})", free_balance, accountid); + debug!("TEE's free balance = {:?} (Account: {})", free_balance, accountid); let existential_deposit = api.get_existential_deposit()?; - info!("Existential deposit is = {:?}", existential_deposit); + debug!("Existential deposit is = {:?}", existential_deposit); let balance_transfer_fee = api .get_fee_details( api.balance_transfer_allow_death( @@ -119,7 +119,7 @@ fn ensure_account_has_funds(api: &ParentchainApi, accountid: &AccountId32) -> Re .inclusion_fee .unwrap() .inclusion_fee(); - info!("Balance Transfer Fee is = {:?}", balance_transfer_fee); + debug!("Balance Transfer Fee is = {:?}", balance_transfer_fee); let min_required_funds = existential_deposit .saturating_mul(EXISTENTIAL_DEPOSIT_FACTOR_FOR_INIT_FUNDS) @@ -127,7 +127,7 @@ fn ensure_account_has_funds(api: &ParentchainApi, accountid: &AccountId32) -> Re let missing_funds = min_required_funds.saturating_sub(free_balance); if missing_funds > 0 { - info!("Transfer {:?} from Alice to {}", missing_funds, accountid); + debug!("Transfer {:?} from Alice to {}", missing_funds, accountid); bootstrap_funds_from_alice(api, accountid, missing_funds)?; } Ok(()) @@ -165,7 +165,7 @@ fn bootstrap_funds_from_alice( trace!(" Alice's Account Nonce is {}", nonce); if funding_amount > alice_free { - println!( + error!( "funding amount is too high: please change EXISTENTIAL_DEPOSIT_FACTOR_FOR_INIT_FUNDS ({:?})", funding_amount ); @@ -176,7 +176,8 @@ fn bootstrap_funds_from_alice( alice_signer_api.set_signer(ParentchainExtrinsicSigner::new(alice)); println!( - "[+] send extrinsic: bootstrap funding Enclave from Alice's funds (genesis hash {})", + "[+] send extrinsic: bootstrap funding Enclave from Alice's funds: {:?} (genesis hash {})", + funding_amount, api.genesis_hash() ); let xt = alice_signer_api