From 4a0a4f6e5ec8eca62bf19fb5b164553d3f3f9ea5 Mon Sep 17 00:00:00 2001 From: Harald Hoyer Date: Thu, 28 Nov 2024 15:48:05 +0100 Subject: [PATCH] fix(proof-validation): handle optional proof status Ensure proof status is treated as optional, preventing crashes when status is absent. - Modify status field to `Option` in `Proof` struct. - Update validation logic to handle `None` values safely. - Adjust main logic to check for "permanently_ignored" safely. --- bin/verify-era-proof-attestation/src/main.rs | 5 ++++- bin/verify-era-proof-attestation/src/proof.rs | 7 ++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/bin/verify-era-proof-attestation/src/main.rs b/bin/verify-era-proof-attestation/src/main.rs index 9ee0b1b..137db06 100644 --- a/bin/verify-era-proof-attestation/src/main.rs +++ b/bin/verify-era-proof-attestation/src/main.rs @@ -155,7 +155,10 @@ async fn verify_batch_proofs( total_proofs_count += 1; let tee_type = proof.tee_type.to_uppercase(); - if proof.status.eq_ignore_ascii_case("permanently_ignored") { + if proof + .status + .map_or(false, |s| s.eq_ignore_ascii_case("permanently_ignored")) + { trace!( batch_no, tee_type, diff --git a/bin/verify-era-proof-attestation/src/proof.rs b/bin/verify-era-proof-attestation/src/proof.rs index 9da43ea..3ee9990 100644 --- a/bin/verify-era-proof-attestation/src/proof.rs +++ b/bin/verify-era-proof-attestation/src/proof.rs @@ -39,8 +39,9 @@ pub async fn get_proofs( if !proofs.is_empty() && proofs.iter().all(|proof| { - !proof.status.eq_ignore_ascii_case("failed") - && !proof.status.eq_ignore_ascii_case("picked_by_prover") + !proof.status.as_ref().map_or(false, |s| { + s.eq_ignore_ascii_case("failed") | s.eq_ignore_ascii_case("picked_by_prover") + }) }) { return Ok(proofs); @@ -165,7 +166,7 @@ pub struct Proof { #[serde_as(as = "Option")] pub proof: Option>, pub proved_at: String, - pub status: String, + pub status: Option, #[serde_as(as = "Option")] pub attestation: Option>, }