Skip to content

Commit

Permalink
invalid witness error
Browse files Browse the repository at this point in the history
  • Loading branch information
MdTeach committed Dec 31, 2024
1 parent 473d073 commit 0d77fc2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
4 changes: 4 additions & 0 deletions bin/prover-client/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ pub enum ProvingTaskError {
#[error("Witness not found")]
WitnessNotFound,

/// Occurs when the witness data provided is invalid.
#[error("{0}")]
InvalidWitness(String),

/// Represents a generic database error.
#[error("Database error: {0:?}")]
DatabaseError(DbError),
Expand Down
16 changes: 12 additions & 4 deletions bin/prover-client/src/operators/checkpoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,21 @@ impl CheckpointOperator {
.inspect_err(|_| error!(%block_num, "Failed to fetch l2_headers"))
.map_err(|e| ProvingTaskError::RpcError(e.to_string()))?;

let cl_stf_id_buf: Buf32 = l2_headers
.expect("invalid height")
let headers = l2_headers.ok_or_else(|| {
error!(%block_num, "No L2 headers found at block height");
ProvingTaskError::WitnessNotFound
})?;

let first_header: Buf32 = headers
.first()
.expect("at least one l2 blockid")
.ok_or_else(|| {
error!(%block_num, "Empty L2 headers response");
ProvingTaskError::InvalidWitness("Invalid block height".to_string())
})?
.block_id
.into();
Ok(cl_stf_id_buf.into())

Ok(first_header.into())
}

/// Retrieves the latest checkpoint index
Expand Down

0 comments on commit 0d77fc2

Please sign in to comment.