Skip to content

Commit

Permalink
feat: assorted fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ratankaliani committed Dec 30, 2024
1 parent 4569d35 commit 666290a
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 9 deletions.
28 changes: 27 additions & 1 deletion proposer/op/proposer/prove.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down Expand Up @@ -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)
}

Expand Down
31 changes: 24 additions & 7 deletions proposer/succinct/bin/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion utils/host/src/fetcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,7 @@ impl OPSuccinctDataFetcher {
pub async fn fetch_headers_in_range(&self, start: u64, end: u64) -> Result<Vec<Header>> {
let headers = stream::iter(start..=end)
.map(|block_number| async move { self.get_l1_header(block_number.into()).await })
.buffered(100)
.buffered(10)
.collect::<Vec<Result<Header>>>()
.await
.into_iter()
Expand Down

0 comments on commit 666290a

Please sign in to comment.