Skip to content

Commit 4821929

Browse files
feat: add pre-compute module (#3)
1 parent 0ce3d2c commit 4821929

File tree

23 files changed

+3225
-34
lines changed

23 files changed

+3225
-34
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
[workspace]
22
resolver = "3"
33
members = [
4-
"post-compute"
4+
"post-compute",
5+
"pre-compute"
56
]

post-compute/src/api/worker_api.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use serde::Serialize;
2323
///
2424
/// # Example
2525
///
26-
/// ```
26+
/// ```rust
2727
/// use tee_worker_post_compute::{
2828
/// api::worker_api::ExitMessage,
2929
/// compute::errors::ReplicateStatusCause,
@@ -49,7 +49,7 @@ impl<'a> From<&'a ReplicateStatusCause> for ExitMessage<'a> {
4949
///
5050
/// # Example
5151
///
52-
/// ```
52+
/// ```rust
5353
/// use tee_worker_post_compute::api::worker_api::WorkerApiClient;
5454
///
5555
/// let client = WorkerApiClient::new("http://worker:13100");
@@ -80,7 +80,7 @@ impl WorkerApiClient {
8080
///
8181
/// # Example
8282
///
83-
/// ```
83+
/// ```rust
8484
/// use tee_worker_post_compute::api::worker_api::WorkerApiClient;
8585
///
8686
/// let client = WorkerApiClient::from_env();
@@ -119,7 +119,7 @@ impl WorkerApiClient {
119119
///
120120
/// # Example
121121
///
122-
/// ```
122+
/// ```rust
123123
/// use tee_worker_post_compute::{
124124
/// api::worker_api::{ExitMessage, WorkerApiClient},
125125
/// compute::errors::ReplicateStatusCause,
@@ -189,7 +189,7 @@ impl WorkerApiClient {
189189
///
190190
/// # Example
191191
///
192-
/// ```
192+
/// ```rust
193193
/// use tee_worker_post_compute::{
194194
/// api::worker_api::WorkerApiClient,
195195
/// compute::computed_file::ComputedFile,

post-compute/src/compute/computed_file.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ pub struct ComputedFile {
6868
///
6969
/// # Example
7070
///
71-
/// ```
71+
/// ```rust
7272
/// use tee_worker_post_compute::compute::computed_file::read_computed_file;
7373
///
7474
/// match read_computed_file("0x123456789abcdef", "/iexec_out") {
@@ -153,7 +153,7 @@ pub fn read_computed_file(
153153
///
154154
/// # Example
155155
///
156-
/// ```
156+
/// ```rust
157157
/// use tee_worker_post_compute::compute::computed_file::{
158158
/// build_result_digest_in_computed_file,
159159
/// ComputedFile
@@ -235,7 +235,7 @@ pub fn build_result_digest_in_computed_file(
235235
///
236236
/// # Example
237237
///
238-
/// ```
238+
/// ```rust
239239
/// use tee_worker_post_compute::compute::computed_file::{
240240
/// sign_computed_file,
241241
/// ComputedFile

post-compute/src/compute/utils/hash_utils.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ use sha256::{Sha256Digest, digest};
44
pub fn concatenate_and_hash(hexa_strings: &[&str]) -> String {
55
let mut hasher = Keccak256::default();
66
for hexa_string in hexa_strings {
7-
println!("value {hexa_string}");
87
hasher.update(hex_string_to_byte_array(hexa_string));
98
}
109
format!("0x{:x}", hasher.finalize())
@@ -19,15 +18,19 @@ pub fn hex_string_to_byte_array(input: &str) -> Vec<u8> {
1918

2019
let mut data: Vec<u8> = vec![];
2120
let start_idx = if len % 2 != 0 {
22-
let byte = u8::from_str_radix(&clean_input[0..1], 16).expect("");
21+
let byte =
22+
u8::from_str_radix(&clean_input[0..1], 16).expect("Invalid hex digit in input string");
2323
data.push(byte);
2424
1
2525
} else {
2626
0
2727
};
2828

2929
for i in (start_idx..len).step_by(2) {
30-
data.push(u8::from_str_radix(&clean_input[i..i + 2], 16).expect(""));
30+
data.push(
31+
u8::from_str_radix(&clean_input[i..i + 2], 16)
32+
.expect("Invalid hex digit in input string"),
33+
);
3134
}
3235

3336
data

post-compute/src/compute/utils/result_utils.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ use std::{
3030
///
3131
/// # Example
3232
///
33-
/// ```
33+
/// ```rust
3434
/// use tee_worker_post_compute::compute::{computed_file::ComputedFile, utils::result_utils::compute_web3_result_digest};
3535
///
3636
/// let computed_file = ComputedFile {
@@ -93,7 +93,7 @@ pub fn compute_web3_result_digest(computed_file: &ComputedFile) -> String {
9393
///
9494
/// # Example
9595
///
96-
/// ```
96+
/// ```rust
9797
/// use tee_worker_post_compute::compute::{computed_file::ComputedFile, utils::result_utils::compute_web2_result_digest};
9898
///
9999
/// let computed_file = ComputedFile {
@@ -225,7 +225,7 @@ pub fn sha256_file(file_path: &Path) -> String {
225225
///
226226
/// # Example
227227
///
228-
/// ```
228+
/// ```rust
229229
/// use std::path::Path;
230230
/// use tee_worker_post_compute::compute::utils::result_utils::get_file_tree_sha256;
231231
///

pre-compute/Cargo.toml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
[package]
2+
name = "tee-worker-pre-compute"
3+
version = "0.1.0"
4+
edition = "2024"
5+
6+
[dependencies]
7+
aes = "0.8.4"
8+
alloy-signer = "0.15.9"
9+
alloy-signer-local = "0.15.9"
10+
base64 = "0.22.1"
11+
cbc = { version = "0.1.2", features = ["alloc"] }
12+
env_logger = "0.11.8"
13+
log = "0.4.27"
14+
multiaddr = "0.18.2"
15+
reqwest = { version = "0.12.15", features = ["blocking", "json"] }
16+
serde = "1.0.219"
17+
sha256 = "1.6.0"
18+
sha3 = "0.10.8"
19+
thiserror = "2.0.12"
20+
21+
[dev-dependencies]
22+
mockall = "0.13.1"
23+
serde_json = "1.0.140"
24+
temp-env = "0.3.6"
25+
tempfile = "3.20.0"
26+
testcontainers = { version = "0.25.0", features = ["blocking"] }
27+
testing_logger = "0.1.1"
28+
tokio = { version = "1.45.0", features = ["macros", "rt-multi-thread"] }
29+
wiremock = "0.6.3"

pre-compute/src/api.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pub mod worker_api;

0 commit comments

Comments
 (0)