Skip to content

Commit a50c615

Browse files
zhizming-zhongBillyWooo
andauthored
Remove caching challenge_code (#1326)
* remove `challenge_code` cache * fix unit tests * minor update --------- Co-authored-by: BillyWooo <thedreamofbilly@gmail.com>
1 parent 20041ac commit a50c615

File tree

23 files changed

+91
-268
lines changed

23 files changed

+91
-268
lines changed

tee-worker/Cargo.lock

Lines changed: 2 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tee-worker/app-libs/stf/Cargo.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ sp-core = { default-features = false, features = ["full_crypto"], git = "https:/
3939
sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.36" }
4040

4141
# litentry
42-
lc-challenge-code-cache = { path = "../../litentry/core/challenge-code-cache", default-features = false }
4342
lc-stf-task-sender = { path = "../../litentry/core/stf-task/sender", default-features = false }
4443
litentry-primitives = { path = "../../litentry/primitives", default-features = false }
4544
pallet-parentchain = { path = "../../../pallets/parentchain", default-features = false }
@@ -67,7 +66,6 @@ sgx = [
6766
"itp-node-api/sgx",
6867
"litentry-primitives/sgx",
6968
"lc-stf-task-sender/sgx",
70-
"lc-challenge-code-cache/sgx",
7169
"rand-sgx",
7270
]
7371
std = [
@@ -100,7 +98,6 @@ std = [
10098
"litentry-primitives/std",
10199
"parentchain-primitives/std",
102100
"lc-stf-task-sender/std",
103-
"lc-challenge-code-cache/std",
104101
"rand",
105102
]
106103
test = []

tee-worker/app-libs/stf/src/trusted_call_litentry.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ use crate::{
2525
use frame_support::dispatch::UnfilteredDispatchable;
2626
use itp_stf_primitives::types::ShardIdentifier;
2727
use itp_utils::stringify::account_id_to_string;
28-
use lc_challenge_code_cache::GLOBAL_CHALLENGE_CODE_CACHE;
2928
use lc_stf_task_sender::{
3029
stf_task_sender::{SendStfRequest, StfRequestSender},
3130
AssertionBuildRequest, MaxIdentityLength, RequestType, SetUserShieldingKeyRequest,
@@ -93,8 +92,6 @@ impl TrustedCallSigned {
9392

9493
// generate challenge code
9594
let code = generate_challenge_code();
96-
// only works if mockserver is enabled
97-
GLOBAL_CHALLENGE_CODE_CACHE.insert_challenge_code(identity.clone(), code);
9895

9996
ita_sgx_runtime::IdentityManagementCall::<Runtime>::set_challenge_code {
10097
who,

tee-worker/cli/src/trusted_base_cli/commands/get_storage.rs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ use itc_rpc_client::direct_client::{DirectApi, DirectClient};
66
use itp_rpc::{RpcRequest, RpcResponse, RpcReturnValue};
77
use itp_types::DirectRequestStatus;
88
use itp_utils::FromHexPrefixed;
9-
use log::{debug, error, warn};
9+
use log::{error, warn};
1010
use my_node_runtime::Hash;
1111
use scale_value::{scale::TypeId, Value};
1212
use sp_application_crypto::scale_info::TypeDef;
13-
use std::{format, sync::mpsc::channel};
13+
use std::format;
1414

1515
/// Usage:
1616
/// Plain Storage: ./integritee-cli trusted --mrenclave $mrenclave get-storage Parentchain Number
@@ -138,19 +138,13 @@ fn send_get_storage_request(
138138
mrenclave: String,
139139
storage_entry_key: &Vec<u8>,
140140
) -> Option<Vec<u8>> {
141-
let (sender, receiver) = channel();
142-
143141
let jsonrpc_call: String = RpcRequest::compose_jsonrpc_call(
144142
"state_getStorage".to_string(),
145143
vec![mrenclave, format!("0x{}", hex::encode(storage_entry_key))],
146144
)
147145
.unwrap();
148146

149-
direct_api.watch(jsonrpc_call, sender);
150-
151-
debug!("waiting for rpc response");
152-
153-
let value = match receiver.recv() {
147+
let value = match direct_api.get(jsonrpc_call.as_str()) {
154148
Ok(response) => {
155149
let response: RpcResponse = serde_json::from_str(&response).unwrap();
156150
if let Ok(return_value) = RpcReturnValue::from_hex(&response.result) {
@@ -176,7 +170,7 @@ fn send_get_storage_request(
176170
}
177171
},
178172
Err(e) => {
179-
error!("failed to receive rpc response: {:?}", e);
173+
error!("failed to send request: {:?}", e);
180174
None
181175
},
182176
};

tee-worker/core-primitives/enclave-api/ffi/src/lib.rs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -181,18 +181,4 @@ extern "C" {
181181
data_providers_static: *const u8,
182182
data_providers_static_size: usize,
183183
) -> sgx_status_t;
184-
185-
pub fn enable_challenge_code_cache(
186-
eid: sgx_enclave_id_t,
187-
retval: *mut sgx_status_t,
188-
) -> sgx_status_t;
189-
190-
pub fn get_challenge_code(
191-
eid: sgx_enclave_id_t,
192-
retval: *mut sgx_status_t,
193-
identity: *const u8,
194-
identity_size: u32,
195-
code: *mut u8,
196-
code_size: u32,
197-
) -> sgx_status_t;
198184
}

tee-worker/core-primitives/enclave-api/src/challenge_code_cache.rs

Lines changed: 0 additions & 63 deletions
This file was deleted.

tee-worker/core-primitives/enclave-api/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ use crate::error::Error;
1616
use sgx_types::*;
1717
use sgx_urts::SgxEnclave;
1818

19-
pub mod challenge_code_cache;
2019
pub mod direct_request;
2120
pub mod enclave_base;
2221
pub mod enclave_test;

tee-worker/enclave-runtime/Cargo.lock

Lines changed: 0 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tee-worker/enclave-runtime/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,6 @@ its-primitives = { path = "../sidechain/primitives", default-features = false }
128128
its-sidechain = { path = "../sidechain/sidechain-crate", default-features = false, features = ["sgx"] }
129129

130130
# litentry
131-
lc-challenge-code-cache = { path = "../litentry/core/challenge-code-cache", default-features = false, features = ["sgx"] }
132131
lc-data-providers = { path = "../litentry/core/data-providers", default-features = false, features = ["sgx"] }
133132
lc-stf-task-receiver = { path = "../litentry/core/stf-task/receiver", default-features = false, features = ["sgx"] }
134133
lc-stf-task-sender = { path = "../litentry/core/stf-task/sender", default-features = false, features = ["sgx"] }

tee-worker/enclave-runtime/Enclave.edl

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -131,14 +131,6 @@ enclave {
131131
public size_t run_stf_task_handler(
132132
[in, size=data_providers_static_len] uint8_t* data_providers_static, uint32_t data_providers_static_len
133133
);
134-
135-
public sgx_status_t enable_challenge_code_cache();
136-
137-
public sgx_status_t get_challenge_code(
138-
[in, size=identity_size] uint8_t* identity, uint32_t identity_size,
139-
[out, size=code_size] uint8_t* code, uint32_t code_size
140-
);
141-
142134
};
143135

144136
untrusted {

0 commit comments

Comments
 (0)