Skip to content

Commit

Permalink
pimp logs and try to get shard for confirm_processed_parentchain_block
Browse files Browse the repository at this point in the history
  • Loading branch information
brenzi committed Aug 2, 2023
1 parent bf06728 commit 84b3102
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 26 deletions.
22 changes: 15 additions & 7 deletions core/parentchain/indirect-calls-executor/src/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ impl<
let block_number = *block.header().number();
let block_hash = block.hash();

debug!("Scanning block {:?} for relevant xt", block_number);
trace!("Scanning block {:?} for relevant xt", block_number);
let mut executed_calls = Vec::<H256>::new();

let events = self
Expand All @@ -139,7 +139,7 @@ impl<
.ok_or_else(|| Error::Other("Could not create events from metadata".into()))?;

let xt_statuses = events.get_extrinsic_statuses()?;
debug!("xt_statuses:: {:?}", xt_statuses);
trace!("xt_statuses:: {:?}", xt_statuses);

// This would be catastrophic but should never happen
if xt_statuses.len() != block.extrinsics().len() {
Expand Down Expand Up @@ -169,7 +169,7 @@ impl<
executed_calls.push(hash_of(&call));
}
}

debug!("successfully processed {} indirect invocations", executed_calls.len());
// Include a processed parentchain block confirmation for each block.
self.create_processed_parentchain_block_call::<ParentchainBlock>(
block_hash,
Expand All @@ -190,9 +190,17 @@ impl<
let call = self.node_meta_data_provider.get_from_metadata(|meta_data| {
meta_data.confirm_processed_parentchain_block_call_indexes()
})??;

let root: H256 = merkle_root::<Keccak256, _>(extrinsics);
Ok(OpaqueCall::from_tuple(&(call, block_hash, block_number, root)))
let mrenclave = self.stf_enclave_signer.ocall_api.get_mr
let shard = self.top_pool_author.get_shards().get(0).unwrap_or(),
trace!("prepared confirm_processed_parentchain_block() call for block {:?} with index {:?} and merkle root {}", block_number, call, root);
Ok(OpaqueCall::from_tuple(&(
call,
shard,
block_hash,
block_number,
root,
)))
}
}

Expand Down Expand Up @@ -257,7 +265,7 @@ pub(crate) fn hash_of<T: Encode>(xt: &T) -> H256 {
mod test {
use super::*;
use crate::{
filter_metadata::{ShieldFundsAndCallWorkerFilter, TestEventCreator},
filter_metadata::{ShieldFundsAndInvokeFilter, TestEventCreator},
parentchain_parser::ParentchainExtrinsicParser,
};
use codec::{Decode, Encode};
Expand Down Expand Up @@ -291,7 +299,7 @@ mod test {
TestStfEnclaveSigner,
TestTopPoolAuthor,
TestNodeMetadataRepository,
ShieldFundsAndCallWorkerFilter<ParentchainExtrinsicParser>,
ShieldFundsAndInvokeFilter<ParentchainExtrinsicParser>,
TestEventCreator,
>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,12 @@ impl FilterIntoDataFrom<NodeMetadata> for DenyAll {
}

/// Default filter we use for the Integritee-Parachain.
pub struct ShieldFundsAndCallWorkerFilter<ExtrinsicParser> {
pub struct ShieldFundsAndInvokeFilter<ExtrinsicParser> {
_phantom: PhantomData<ExtrinsicParser>,
}

impl<ExtrinsicParser, NodeMetadata: NodeMetadataTrait> FilterIntoDataFrom<NodeMetadata>
for ShieldFundsAndCallWorkerFilter<ExtrinsicParser>
for ShieldFundsAndInvokeFilter<ExtrinsicParser>
where
ExtrinsicParser: ParseExtrinsic,
{
Expand All @@ -123,14 +123,15 @@ where
return None
},
};

let index = xt.call_index;
let call_args = &mut &xt.call_args[..];

log::trace!("attempting to execute indirect call with index {:?}", index);
if index == metadata.shield_funds_call_indexes().ok()? {
log::trace!("executing shield funds call");
let args = decode_and_log_error::<ShieldFundsArgs>(call_args)?;
Some(IndirectCall::ShieldFunds(args))
} else if index == metadata.invoke_call_indexes().ok()? {
log::trace!("executing invoke call");
let args = decode_and_log_error::<InvokeArgs>(call_args)?;
Some(IndirectCall::Invoke(args))
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
*/

mod call_worker;
mod invoke;
mod shield_funds;

pub use call_worker::InvokeArgs;
pub use invoke::InvokeArgs;
pub use shield_funds::ShieldFundsArgs;
4 changes: 2 additions & 2 deletions enclave-runtime/src/attestation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ pub fn generate_dcap_ra_extrinsic_internal(
skip_ra,
)?;

if skip_ra {
if !skip_ra {
generate_dcap_ra_extrinsic_from_quote_internal(url, &dcap_quote)
} else {
generate_dcap_skip_ra_extrinsic_from_quote_internal(url, &dcap_quote)
Expand Down Expand Up @@ -333,7 +333,7 @@ fn generate_ias_ra_extrinsic_internal(
let attestation_handler = GLOBAL_ATTESTATION_HANDLER_COMPONENT.get()?;
let cert_der = attestation_handler.generate_ias_ra_cert(skip_ra)?;

if skip_ra {
if !skip_ra {
generate_ias_ra_extrinsic_from_der_cert_internal(url, &cert_der)
} else {
generate_ias_skip_ra_extrinsic_from_der_cert_internal(url, &cert_der)
Expand Down
4 changes: 2 additions & 2 deletions enclave-runtime/src/initialization/global_components.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ use itc_parentchain::{
},
block_importer::ParentchainBlockImporter,
indirect_calls_executor::{
filter_metadata::{EventCreator, ShieldFundsAndCallWorkerFilter},
filter_metadata::{EventCreator, ShieldFundsAndInvokeFilter},
parentchain_parser::ParentchainExtrinsicParser,
IndirectCallsExecutor,
},
Expand Down Expand Up @@ -140,7 +140,7 @@ pub type EnclaveIndirectCallsExecutor = IndirectCallsExecutor<
EnclaveStfEnclaveSigner,
EnclaveTopPoolAuthor,
EnclaveNodeMetadataRepository,
ShieldFundsAndCallWorkerFilter<ParentchainExtrinsicParser>,
ShieldFundsAndInvokeFilter<ParentchainExtrinsicParser>,
EventCreator,
>;
pub type EnclaveValidatorAccessor = ValidatorAccessor<
Expand Down
4 changes: 2 additions & 2 deletions enclave-runtime/src/test/top_pool_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ use ita_stf::{
TrustedCall, TrustedOperation,
};
use itc_parentchain::indirect_calls_executor::{
filter_metadata::{ShieldFundsAndCallWorkerFilter, TestEventCreator},
filter_metadata::{ShieldFundsAndInvokeFilter, TestEventCreator},
parentchain_parser::ParentchainExtrinsicParser,
ExecuteIndirectCalls, IndirectCallsExecutor,
};
Expand Down Expand Up @@ -134,7 +134,7 @@ pub fn submit_shielding_call_to_top_pool() {
_,
_,
_,
ShieldFundsAndCallWorkerFilter<ParentchainExtrinsicParser>,
ShieldFundsAndInvokeFilter<ParentchainExtrinsicParser>,
TestEventCreator,
>::new(
shielding_key_repo, enclave_signer, top_pool_author.clone(), node_meta_data_repository
Expand Down
8 changes: 3 additions & 5 deletions service/src/account_funding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,14 +135,12 @@ fn bootstrap_funds_from_alice(
funding_amount: u128,
) -> Result<(), Error> {
let alice = AccountKeyring::Alice.pair();
info!("encoding Alice's public = {:?}", alice.public().0.encode());
let alice_acc = AccountId32::from(*alice.public().as_array_ref());
info!("encoding Alice's AccountId = {:?}", alice_acc.encode());

let alice_free = api.get_free_balance(&alice_acc)?;
info!(" Alice's free balance = {:?}", alice_free);
trace!(" Alice's free balance = {:?}", alice_free);
let nonce = api.get_nonce_of(&alice_acc)?;
info!(" Alice's Account Nonce is {}", nonce);
trace!(" Alice's Account Nonce is {}", nonce);

if funding_amount > alice_free {
println!(
Expand All @@ -165,7 +163,7 @@ fn bootstrap_funds_from_alice(
);
// Verify funds have arrived.
let free_balance = alice_signer_api.get_free_balance(accountid);
info!("TEE's NEW free balance = {:?}", free_balance);
trace!("TEE's NEW free balance = {:?}", free_balance);

Ok(())
}
4 changes: 2 additions & 2 deletions service/src/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ pub(crate) fn initialize_shard_and_keys(
pub(crate) fn init_shard(enclave: &Enclave, shard_identifier: &ShardIdentifier) {
match enclave.init_shard(shard_identifier.encode()) {
Err(e) => {
println!("Failed to initialize shard {:?}: {:?}", shard_identifier, e);
println!("Failed to initialize shard {:?}: {:?}", shard_identifier.to_base58(), e);
},
Ok(_) => {
println!("Successfully initialized shard {:?}", shard_identifier);
println!("Successfully initialized shard {:?}", shard_identifier.to_base58());
},
}
}
Expand Down

0 comments on commit 84b3102

Please sign in to comment.