diff --git a/tee-worker/Cargo.lock b/tee-worker/Cargo.lock index 3598a69365..db04271794 100644 --- a/tee-worker/Cargo.lock +++ b/tee-worker/Cargo.lock @@ -5368,6 +5368,7 @@ dependencies = [ "id-itp-stf-executor", "id-itp-top-pool-author", "itp-enclave-metrics", + "itp-extrinsics-factory", "itp-node-api", "itp-ocall-api", "itp-sgx-crypto", @@ -5378,7 +5379,6 @@ dependencies = [ "itp-types", "lc-dynamic-assertion", "lc-evm-dynamic-assertions", - "lc-parachain-extrinsic-task-sender", "lc-stf-task-receiver", "lc-stf-task-sender", "lc-vc-task-sender", diff --git a/tee-worker/identity/enclave-runtime/Cargo.lock b/tee-worker/identity/enclave-runtime/Cargo.lock index 34b8f1631d..de7a5089bf 100644 --- a/tee-worker/identity/enclave-runtime/Cargo.lock +++ b/tee-worker/identity/enclave-runtime/Cargo.lock @@ -3277,6 +3277,7 @@ dependencies = [ "id-itp-stf-executor", "id-itp-top-pool-author", "itp-enclave-metrics", + "itp-extrinsics-factory", "itp-node-api", "itp-ocall-api", "itp-sgx-crypto", @@ -3287,7 +3288,6 @@ dependencies = [ "itp-types", "lc-dynamic-assertion", "lc-evm-dynamic-assertions", - "lc-parachain-extrinsic-task-sender", "lc-stf-task-receiver", "lc-stf-task-sender", "lc-vc-task-sender", diff --git a/tee-worker/identity/enclave-runtime/src/initialization/mod.rs b/tee-worker/identity/enclave-runtime/src/initialization/mod.rs index dabe50920b..d6cde31bc2 100644 --- a/tee-worker/identity/enclave-runtime/src/initialization/mod.rs +++ b/tee-worker/identity/enclave-runtime/src/initialization/mod.rs @@ -324,9 +324,10 @@ fn run_vc_issuance() -> Result<(), Error> { data_provider_config, evm_assertion_repository, ); + let extrinsic_factory = get_extrinsic_factory_from_integritee_solo_or_parachain()?; let node_metadata_repo = get_node_metadata_repository_from_integritee_solo_or_parachain()?; - run_vc_handler_runner(Arc::new(stf_task_context), node_metadata_repo); + run_vc_handler_runner(Arc::new(stf_task_context), extrinsic_factory, node_metadata_repo); Ok(()) } diff --git a/tee-worker/identity/litentry/core/vc-task/receiver/Cargo.toml b/tee-worker/identity/litentry/core/vc-task/receiver/Cargo.toml index e581fb153c..cafe82d635 100644 --- a/tee-worker/identity/litentry/core/vc-task/receiver/Cargo.toml +++ b/tee-worker/identity/litentry/core/vc-task/receiver/Cargo.toml @@ -15,6 +15,7 @@ sp-core = { workspace = true, features = ["full_crypto"] } ita-sgx-runtime = { package = "id-ita-sgx-runtime", path = "../../../../app-libs/sgx-runtime", default-features = false } ita-stf = { package = "id-ita-stf", path = "../../../../app-libs/stf", default-features = false } itp-enclave-metrics = { workspace = true } +itp-extrinsics-factory = { workspace = true } itp-node-api = { workspace = true } itp-ocall-api = { workspace = true } itp-sgx-crypto = { workspace = true } @@ -29,7 +30,6 @@ itp-types = { workspace = true } frame-support = { workspace = true } lc-dynamic-assertion = { workspace = true } lc-evm-dynamic-assertions = { workspace = true } -lc-parachain-extrinsic-task-sender = { workspace = true } lc-stf-task-receiver = { workspace = true } lc-stf-task-sender = { workspace = true } lc-vc-task-sender = { workspace = true } @@ -53,6 +53,7 @@ sgx = [ "lc-stf-task-sender/sgx", "itp-node-api/sgx", "itp-storage/sgx", + "itp-extrinsics-factory/sgx", "lc-vc-task-sender/sgx", "lc-dynamic-assertion/sgx", "lc-evm-dynamic-assertions/sgx", @@ -66,6 +67,7 @@ std = [ "itp-stf-executor/std", "itp-stf-state-handler/std", "itp-stf-primitives/std", + "itp-extrinsics-factory/std", "sp-core/std", "litentry-primitives/std", "ita-sgx-runtime/std", diff --git a/tee-worker/identity/litentry/core/vc-task/receiver/src/lib.rs b/tee-worker/identity/litentry/core/vc-task/receiver/src/lib.rs index 727258f173..d8cce8567f 100644 --- a/tee-worker/identity/litentry/core/vc-task/receiver/src/lib.rs +++ b/tee-worker/identity/litentry/core/vc-task/receiver/src/lib.rs @@ -37,6 +37,7 @@ use ita_stf::{ Getter, TrustedCall, TrustedCallSigned, }; use itp_enclave_metrics::EnclaveMetric; +use itp_extrinsics_factory::CreateExtrinsics; use itp_node_api::metadata::{ pallet_system::SystemConstants, pallet_vcmp::VCMPCallIndexes, provider::AccessNodeMetadata, NodeMetadataTrait, @@ -50,11 +51,11 @@ use itp_stf_state_handler::handle_state::HandleState; use itp_storage::{storage_map_key, storage_value_key, StorageHasher}; use itp_top_pool_author::traits::AuthorApi; use itp_types::{ - AccountId, BlockNumber as SidechainBlockNumber, OpaqueCall, ShardIdentifier, H256, + parentchain::ParentchainId, AccountId, BlockNumber as SidechainBlockNumber, OpaqueCall, + ShardIdentifier, H256, }; use lc_dynamic_assertion::AssertionLogicRepository; use lc_evm_dynamic_assertions::AssertionRepositoryItem; -use lc_parachain_extrinsic_task_sender::{ParachainExtrinsicSender, SendParachainExtrinsic}; use lc_stf_task_receiver::{handler::assertion::create_credential_str, StfTaskContext}; use lc_vc_task_sender::init_vc_task_sender; use litentry_macros::if_development_or; @@ -78,8 +79,9 @@ use std::{ vec::Vec, }; -pub fn run_vc_handler_runner( +pub fn run_vc_handler_runner( context: Arc>, + extrinsic_factory: Arc, node_metadata_repo: Arc, ) where ShieldingKeyRepository: AccessKey + Send + Sync + 'static, @@ -90,6 +92,7 @@ pub fn run_vc_handler_runner( H: HandleState + Send + Sync + 'static, H::StateT: SgxExternalitiesTrait, O: EnclaveOnChainOCallApi + EnclaveMetricsOCallApi + EnclaveAttestationOCallApi + 'static, + Z: CreateExtrinsics + Send + Sync + 'static, N: AccessNodeMetadata + Send + Sync + 'static, N::MetadataType: NodeMetadataTrait, AR: AssertionLogicRepository + Send + Sync + 'static, @@ -185,6 +188,7 @@ pub fn run_vc_handler_runner( let shard_pool = request.shard; let context_pool = context.clone(); + let extrinsic_factory_pool = extrinsic_factory.clone(); let node_metadata_repo_pool = node_metadata_repo.clone(); let tc_sender_pool = tc_sender.clone(); let req_registry_pool = req_registry.clone(); @@ -192,6 +196,7 @@ pub fn run_vc_handler_runner( let response = process_single_request( shard_pool, context_pool.clone(), + extrinsic_factory_pool, node_metadata_repo_pool, tc_sender_pool, tcs.call.clone(), @@ -249,6 +254,7 @@ pub fn run_vc_handler_runner( let shard_pool = request.shard; let context_pool = context.clone(); + let extrinsic_factory_pool = extrinsic_factory.clone(); let node_metadata_repo_pool = node_metadata_repo.clone(); let tc_sender_pool = tc_sender.clone(); let req_registry_pool = req_registry.clone(); @@ -257,6 +263,7 @@ pub fn run_vc_handler_runner( let response = process_single_request( shard_pool, context_pool.clone(), + extrinsic_factory_pool, node_metadata_repo_pool, tc_sender_pool, new_call, @@ -405,9 +412,10 @@ fn send_vc_response( } } -fn process_single_request( +fn process_single_request( shard: H256, context: Arc>, + extrinsic_factory: Arc, node_metadata_repo: Arc, tc_sender: Sender<(ShardIdentifier, TrustedCall)>, call: TrustedCall, @@ -421,6 +429,7 @@ where H: HandleState + Send + Sync + 'static, H::StateT: SgxExternalitiesTrait, O: EnclaveOnChainOCallApi + EnclaveMetricsOCallApi + EnclaveAttestationOCallApi + 'static, + Z: CreateExtrinsics + Send + Sync + 'static, N: AccessNodeMetadata + Send + Sync + 'static, N::MetadataType: NodeMetadataTrait, AR: AssertionLogicRepository, @@ -599,8 +608,15 @@ where .send((shard, c)) .map_err(|e| RequestVcErrorDetail::TrustedCallSendingFailed(e.to_string()))?; - let extrinsic_sender = ParachainExtrinsicSender::new(); - extrinsic_sender.send(call).map_err(RequestVcErrorDetail::CallSendingFailed)?; + // this internally fetches nonce from a mutex and then updates it thereby ensuring ordering + let xt = extrinsic_factory + .create_extrinsics(&[call], None) + .map_err(|e| RequestVcErrorDetail::ExtrinsicConstructionFailed(e.to_string()))?; + + context + .ocall_api + .send_to_parentchain(xt, &ParentchainId::Litentry, false) + .map_err(|e| RequestVcErrorDetail::ExtrinsicSendingFailed(e.to_string()))?; if let Err(e) = context .ocall_api