Skip to content

Commit

Permalink
Fixes of fixes of fixes of fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
pbeza committed Sep 5, 2024
1 parent ae10700 commit 65740b7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
15 changes: 15 additions & 0 deletions core/lib/basic_types/src/tee_types.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::fmt;

use serde::{Deserialize, Serialize};

#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)]
Expand All @@ -7,6 +9,14 @@ pub enum TeeType {
Sgx,
}

impl fmt::Display for TeeType {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
TeeType::Sgx => write!(f, "sgx"),
}
}
}

#[cfg(test)]
mod tests {
use serde_json;
Expand All @@ -31,4 +41,9 @@ mod tests {
let json_str = serde_json::to_string(&tee_type).unwrap();
assert_eq!(json_str, "\"sgx\"");
}

#[test]
fn test_display_teetype() {
assert_eq!(TeeType::Sgx.to_string(), "sgx");
}
}
11 changes: 5 additions & 6 deletions core/lib/dal/src/tee_proof_generation_dal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ impl TeeProofGenerationDal<'_, '_> {
tee_proof_generation_details.l1_batch_number
"#,
TeeProofGenerationJobStatus::PickedByProver.to_string(),
serde_json::to_string(&tee_type).unwrap(),
tee_type.to_string(),
TeeVerifierInputProducerJobStatus::Successful as TeeVerifierInputProducerJobStatus,
TeeProofGenerationJobStatus::Unpicked.to_string(),
processing_timeout,
Expand Down Expand Up @@ -112,7 +112,7 @@ impl TeeProofGenerationDal<'_, '_> {
"#,
TeeProofGenerationJobStatus::Unpicked.to_string(),
batch_number,
serde_json::to_string(&tee_type).unwrap()
tee_type.to_string()
)
.instrument("unlock_batch")
.with_arg("l1_batch_number", &batch_number)
Expand Down Expand Up @@ -145,7 +145,7 @@ impl TeeProofGenerationDal<'_, '_> {
WHERE
l1_batch_number = $6
"#,
serde_json::to_string(&tee_type).unwrap(),
tee_type.to_string(),
TeeProofGenerationJobStatus::Generated.to_string(),
pubkey,
signature,
Expand Down Expand Up @@ -189,7 +189,7 @@ impl TeeProofGenerationDal<'_, '_> {
ON CONFLICT (l1_batch_number, tee_type) DO NOTHING
"#,
batch_number,
serde_json::to_string(&tee_type).unwrap(),
tee_type.to_string(),
TeeProofGenerationJobStatus::Unpicked.to_string(),
);
let instrumentation = Instrumented::new("insert_tee_proof_generation_job")
Expand Down Expand Up @@ -259,8 +259,7 @@ impl TeeProofGenerationDal<'_, '_> {
.bind(TeeProofGenerationJobStatus::Generated.to_string());

if let Some(tee_type) = tee_type {
let tee_type = serde_json::to_string(&tee_type).unwrap();
query = query.bind(tee_type);
query = query.bind(tee_type.to_string());
}

let proofs: Vec<StorageTeeProof> = query.fetch_all(self.storage.conn()).await.unwrap();
Expand Down

0 comments on commit 65740b7

Please sign in to comment.