Skip to content

Commit

Permalink
fix(proof-validation): handle optional proof status
Browse files Browse the repository at this point in the history
Ensure proof status is treated as optional, preventing crashes when status is absent.
- Modify status field to `Option<String>` in `Proof` struct.
- Update validation logic to handle `None` values safely.
- Adjust main logic to check for "permanently_ignored" safely.
  • Loading branch information
haraldh committed Nov 28, 2024
1 parent 5b7f748 commit 4a0a4f6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
5 changes: 4 additions & 1 deletion bin/verify-era-proof-attestation/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
7 changes: 4 additions & 3 deletions bin/verify-era-proof-attestation/src/proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -165,7 +166,7 @@ pub struct Proof {
#[serde_as(as = "Option<Hex>")]
pub proof: Option<Vec<u8>>,
pub proved_at: String,
pub status: String,
pub status: Option<String>,
#[serde_as(as = "Option<Hex>")]
pub attestation: Option<Vec<u8>>,
}

0 comments on commit 4a0a4f6

Please sign in to comment.