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

Make some DI responses synchronous #1920

Merged
merged 19 commits into from
Jul 25, 2023
Merged
Show file tree
Hide file tree
Changes from 17 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
378 changes: 190 additions & 188 deletions Cargo.lock

Large diffs are not rendered by default.

763 changes: 375 additions & 388 deletions tee-worker/Cargo.lock

Large diffs are not rendered by default.

23 changes: 23 additions & 0 deletions tee-worker/app-libs/stf/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ pub mod stf_sgx_tests;
pub mod test_genesis;
pub mod trusted_call;
pub mod trusted_call_litentry;
pub mod trusted_call_rpc_response;

pub(crate) const ENCLAVE_ACCOUNT_KEY: &str = "Enclave_Account_Key";

Expand Down Expand Up @@ -93,6 +94,7 @@ pub enum StfError {
#[display(fmt = "SetIdentityNetworksFailed: {:?}", _0)]
SetIdentityNetworksFailed(ErrorDetail),
InvalidAccount,
UnclassifiedError,
}

impl From<MetadataError> for StfError {
Expand All @@ -107,6 +109,27 @@ impl From<MetadataProviderError> for StfError {
}
}

impl From<IMPError> for StfError {
fn from(e: IMPError) -> Self {
match e {
IMPError::SetUserShieldingKeyFailed(d) => StfError::SetIdentityNetworksFailed(d),
IMPError::LinkIdentityFailed(d) => StfError::LinkIdentityFailed(d),
IMPError::DeactivateIdentityFailed(d) => StfError::DeactivateIdentityFailed(d),
IMPError::ActivateIdentityFailed(d) => StfError::ActivateIdentityFailed(d),
_ => StfError::UnclassifiedError,
}
}
}

impl From<VCMPError> for StfError {
fn from(e: VCMPError) -> Self {
match e {
VCMPError::RequestVCFailed(a, d) => StfError::RequestVCFailed(a, d),
_ => StfError::UnclassifiedError,
}
}
}

impl StfError {
// Convert StfError to IMPError that would be sent to parentchain
pub fn to_imp_error(&self) -> IMPError {
Expand Down
7 changes: 4 additions & 3 deletions tee-worker/app-libs/stf/src/stf_sgx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ use itp_stf_interface::{
};
use itp_stf_primitives::types::ShardIdentifier;
use itp_storage::storage_value_key;
use itp_types::OpaqueCall;
use itp_types::{OpaqueCall, H256};
use itp_utils::stringify::account_id_to_string;
use log::*;
use sp_runtime::traits::StaticLookup;
Expand Down Expand Up @@ -136,10 +136,11 @@ where
state: &mut State,
shard: &ShardIdentifier,
call: Call,
top_hash: H256,
calls: &mut Vec<OpaqueCall>,
node_metadata_repo: Arc<NodeMetadataRepository>,
) -> Result<(), Self::Error> {
state.execute_with(|| call.execute(shard, calls, node_metadata_repo))
) -> Result<Vec<u8>, Self::Error> {
state.execute_with(|| call.execute(shard, top_hash, calls, node_metadata_repo))
}
}

Expand Down
10 changes: 9 additions & 1 deletion tee-worker/app-libs/stf/src/stf_sgx_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,15 @@ pub fn shield_funds_increments_signer_account_nonce() {

let repo = Arc::new(NodeMetadataRepository::new(NodeMetadataMock::new()));
let shard = ShardIdentifier::default();
StfState::execute_call(&mut state, &shard, shield_funds_call, &mut Vec::new(), repo).unwrap();
StfState::execute_call(
&mut state,
&shard,
shield_funds_call,
Default::default(),
&mut Vec::new(),
repo,
)
.unwrap();
assert_eq!(1, StfState::get_account_nonce(&mut state, &enclave_signer_account_id));
}

Expand Down
Loading
Loading