From 666290ad96e8753b606d3778ca30bc3166c7c8d6 Mon Sep 17 00:00:00 2001 From: Ratan Kaliani Date: Mon, 30 Dec 2024 18:39:03 -0500 Subject: [PATCH] feat: assorted fixes --- proposer/op/proposer/prove.go | 28 +++++++++++++++++++++++++++- proposer/succinct/bin/server.rs | 31 ++++++++++++++++++++++++------- utils/host/src/fetcher.rs | 2 +- 3 files changed, 52 insertions(+), 9 deletions(-) diff --git a/proposer/op/proposer/prove.go b/proposer/op/proposer/prove.go index ce2a88a7..178a3f78 100644 --- a/proposer/op/proposer/prove.go +++ b/proposer/op/proposer/prove.go @@ -340,7 +340,19 @@ func (l *L2OutputSubmitter) makeProofRequest(proofType proofrequest.Type, jsonBo defer resp.Body.Close() if resp.StatusCode != http.StatusOK { - l.Log.Error("Witness generation request failed", "status", resp.StatusCode, "body", resp.Body) + body, _ := io.ReadAll(resp.Body) + var errResp struct { + Error string `json:"error"` + } + if err := json.Unmarshal(body, &errResp); err == nil { + l.Log.Error("Witness generation request failed", + "status", resp.StatusCode, + "error", errResp.Error) + } else { + l.Log.Error("Witness generation request failed", + "status", resp.StatusCode, + "body", string(body)) + } l.Metr.RecordWitnessGenFailure("Failed") return nil, fmt.Errorf("received non-200 status code: %d", resp.StatusCode) } @@ -382,6 +394,20 @@ func (l *L2OutputSubmitter) GetProofStatus(proofId string) (ProofStatusResponse, // If the response status code is not 200, return an error. if resp.StatusCode != http.StatusOK { + body, _ := io.ReadAll(resp.Body) + var errResp struct { + Error string `json:"error"` + } + if err := json.Unmarshal(body, &errResp); err == nil { + l.Log.Error("Get proof status request failed", + "status", resp.StatusCode, + "error", errResp.Error) + } else { + l.Log.Error("Get proof status request failed", + "status", resp.StatusCode, + "body", string(body)) + } + l.Metr.RecordWitnessGenFailure("Failed") return ProofStatusResponse{}, fmt.Errorf("received non-200 status code: %d", resp.StatusCode) } diff --git a/proposer/succinct/bin/server.rs b/proposer/succinct/bin/server.rs index 466abab2..3ff0178d 100644 --- a/proposer/succinct/bin/server.rs +++ b/proposer/succinct/bin/server.rs @@ -259,13 +259,30 @@ async fn request_agg_proof( .map(|proof| proof.proof.clone()) .collect(); - let l1_head_bytes = hex::decode( - payload - .head - .strip_prefix("0x") - .expect("Invalid L1 head, no 0x prefix."), - )?; - let l1_head: [u8; 32] = l1_head_bytes.try_into().unwrap(); + let l1_head_bytes = match payload.head.strip_prefix("0x") { + Some(hex_str) => match hex::decode(hex_str) { + Ok(bytes) => bytes, + Err(e) => { + error!("Failed to decode L1 head hex string: {}", e); + return Err(AppError(anyhow::anyhow!("Failed to decode L1 head hex string: {}", e))); + } + }, + None => { + error!("Invalid L1 head format: missing 0x prefix"); + return Err(AppError(anyhow::anyhow!("Invalid L1 head format: missing 0x prefix"))); + } + }; + + let l1_head: [u8; 32] = match l1_head_bytes.try_into() { + Ok(array) => array, + Err(_) => { + error!("Invalid L1 head length: expected 32 bytes, got {}", l1_head_bytes.len()); + return Err(AppError(anyhow::anyhow!( + "Invalid L1 head length: expected 32 bytes, got {}", + l1_head_bytes.len() + ))); + } + }; let fetcher = match OPSuccinctDataFetcher::new_with_rollup_config(RunContext::Docker).await { Ok(f) => f, diff --git a/utils/host/src/fetcher.rs b/utils/host/src/fetcher.rs index 9a5cf461..5382ce39 100644 --- a/utils/host/src/fetcher.rs +++ b/utils/host/src/fetcher.rs @@ -606,7 +606,7 @@ impl OPSuccinctDataFetcher { pub async fn fetch_headers_in_range(&self, start: u64, end: u64) -> Result> { let headers = stream::iter(start..=end) .map(|block_number| async move { self.get_l1_header(block_number.into()).await }) - .buffered(100) + .buffered(10) .collect::>>() .await .into_iter()