Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix bitacross indirect-calls-executor tests #2827

Merged
merged 1 commit into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,6 @@ mod test {
TestStfEnclaveSigner,
TestTopPoolAuthor,
TestNodeMetadataRepository,
MockExtrinsicFilter<MockParentchainExtrinsicParser>,
TestEventCreator,
MockParentchainEventHandler,
TrustedCallSignedMock,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::{
error::{Error, Result as ICResult},
filter_metadata::{EventsFromMetadata, FilterIntoDataFrom},
filter_metadata::EventsFromMetadata,
IndirectDispatch,
};
use bc_relayer_registry::RelayerRegistry;
Expand All @@ -10,10 +10,7 @@ use core::marker::PhantomData;
use litentry_primitives::DecryptableRequest;

use bc_enclave_registry::EnclaveRegistry;
use itp_node_api::{
api_client::{CallIndex, PairSignature, UncheckedExtrinsicV4},
metadata::NodeMetadataTrait,
};
use itp_node_api::api_client::{CallIndex, PairSignature, UncheckedExtrinsicV4};
use itp_sgx_runtime_primitives::types::{AccountId, Balance};
use itp_stf_primitives::{traits::IndirectExecutor, types::Signature};
use itp_test::mock::stf_mock::{GetterMock, TrustedCallMock, TrustedCallSignedMock};
Expand All @@ -27,52 +24,6 @@ use itp_types::{
use log::*;
use std::vec::Vec;

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

impl<ExtrinsicParser, NodeMetadata: NodeMetadataTrait> FilterIntoDataFrom<NodeMetadata>
for MockExtrinsicFilter<ExtrinsicParser>
where
ExtrinsicParser: ParseExtrinsic,
{
type Output = IndirectCall;
type ParseParentchainMetadata = ExtrinsicParser;

fn filter_into_from_metadata(
encoded_data: &[u8],
metadata: &NodeMetadata,
) -> Option<Self::Output> {
let call_mut = &mut &encoded_data[..];

// Todo: the filter should not need to parse, only filter. This should directly be configured
// in the indirect executor.
let xt = match Self::ParseParentchainMetadata::parse(call_mut) {
Ok(xt) => xt,
Err(e) => {
log::error!(
"[ShieldFundsAndInvokeFilter] Could not parse parentchain extrinsic: {:?}",
e
);
return None
},
};
let index = xt.call_index;
let call_args = &mut &xt.call_args[..];
log::trace!(
"[ShieldFundsAndInvokeFilter] attempting to execute indirect call with index {:?}",
index
);
if index == metadata.post_opaque_task_call_indexes().ok()? {
log::debug!("executing invoke call");
let args = InvokeArgs::decode(call_args).unwrap();
Some(IndirectCall::Invoke(args))
} else {
None
}
}
}
pub struct ExtrinsicParser<SignedExtra> {
_phantom: PhantomData<SignedExtra>,
}
Expand Down