Skip to content

Commit

Permalink
P 422 add a batched request vc method (#2532)
Browse files Browse the repository at this point in the history
* add batch_request_vc support. incoming TrustedCall could be one assertion or vector of assertions.

* fmt

* fix clippy

* add pnpm install

* one more fmt

* add filter to filt out duplicate assertions within vec; add assertion idx from vec to response; update type definition

* keep order aligned.

* clippy

* rename

* use same hash on both watcher and communicate_registry

* move return idx one layer up.

* example of multiple responses

* direct request vc doesn't need to go through watcher

* fix / add ts-tests for request-batch-vc

* fmt

* fix dr/di test input assertion data

---------

Co-authored-by: Yang <yang@litentry.com>
Co-authored-by: Igor Trofimov <igor@kawagarbo-tech.io>
  • Loading branch information
3 people committed Mar 12, 2024
1 parent eddcfd1 commit eeff000
Show file tree
Hide file tree
Showing 33 changed files with 1,345 additions and 148 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,8 @@ fmt-taplo:

.PHONY: fmt-ts ## ts fmt
fmt-ts:
@cd ts-tests && pnpm run format
@cd tee-worker/ts-tests && pnpm run format
@cd ts-tests && pnpm install && pnpm run format
@cd tee-worker/ts-tests && pnpm install && pnpm run format

.PHONY: githooks ## install the githooks
githooks:
Expand Down
27 changes: 19 additions & 8 deletions tee-worker/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 12 additions & 1 deletion tee-worker/app-libs/stf/src/trusted_call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,13 @@ use sp_core::{
ed25519,
};
use sp_io::hashing::blake2_256;
use sp_runtime::MultiAddress;
use sp_runtime::{traits::ConstU32, BoundedVec, MultiAddress};
use std::{format, prelude::v1::*, sync::Arc};

pub type IMTCall = ita_sgx_runtime::IdentityManagementCall<Runtime>;
pub type IMT = ita_sgx_runtime::pallet_imt::Pallet<Runtime>;
pub type MaxAssertionLength = ConstU32<32>;
pub type VecAssertion = BoundedVec<Assertion, MaxAssertionLength>;

#[derive(Encode, Decode, Clone, Debug, PartialEq, Eq)]
#[allow(non_camel_case_types)]
Expand Down Expand Up @@ -119,6 +121,8 @@ pub enum TrustedCall {
#[cfg(not(feature = "production"))]
#[codec(index = 5)]
remove_identity(Identity, Identity, Vec<Identity>),
#[codec(index = 6)]
request_batch_vc(Identity, Identity, VecAssertion, Option<RequestAesKey>, H256),
// the following trusted calls should not be requested directly from external
// they are guarded by the signature check (either root or enclave_signer_account)
// starting from index 20 to leave some room for future "normal" trusted calls
Expand Down Expand Up @@ -232,6 +236,7 @@ impl TrustedCall {
Self::maybe_create_id_graph(sender_identity, ..) => sender_identity,
#[cfg(not(feature = "production"))]
Self::remove_identity(sender_identity, ..) => sender_identity,
Self::request_batch_vc(sender_identity, ..) => sender_identity,
}
}

Expand Down Expand Up @@ -853,6 +858,12 @@ where
})?;
Ok(TrustedCallResult::Streamed)
},
TrustedCall::request_batch_vc(..) => {
error!(
"TrustedCall::request_batch_vc is not supported here. Will be removed later."
);
Ok(TrustedCallResult::Empty)
},
TrustedCall::request_vc_callback(
signer,
who,
Expand Down
8 changes: 8 additions & 0 deletions tee-worker/app-libs/stf/src/trusted_call_result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,11 @@ pub struct RequestVCResult {
pub pre_mutated_id_graph: AesOutput,
pub pre_id_graph_hash: H256,
}

#[derive(Debug, Encode, Decode, Clone)]
pub struct RequestVcResultOrError {
pub payload: Vec<u8>,
pub is_error: bool,
pub idx: u8,
pub len: u8,
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@ pub mod id_graph;
pub mod id_graph_stats;
pub mod link_identity;
pub mod remove_identity;
pub mod request_batch_vc;
pub mod request_vc;
pub mod send_erroneous_parentchain_call;

0 comments on commit eeff000

Please sign in to comment.