Skip to content

Commit 1e79097

Browse files
authored
fix: chunk task input serialization issue (#59)
1 parent b57526e commit 1e79097

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

src/prover/mod.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,13 +295,15 @@ impl Prover {
295295
}
296296
CircuitType::Chunk => {
297297
let chunk_task_detail: ChunkTaskDetail = serde_json::from_str(&task.task_data)?;
298-
let traces = self
298+
let serialized_traces = self
299299
.l2geth_client
300300
.as_ref()
301301
.unwrap()
302302
.get_sorted_traces_by_hashes(&chunk_task_detail.block_hashes)
303303
.await?;
304-
let input = serde_json::to_string(&traces)?;
304+
// Note: Manually join pre-serialized traces since they are already in JSON format.
305+
// Using serde_json::to_string would escape the JSON strings, creating invalid nested JSON.
306+
let input = format!("[{}]", serialized_traces.join(","));
305307

306308
Ok(ProveRequest {
307309
circuit_type: task.task_type,

src/tracing_handler.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@ use ethers_core::types::BlockNumber;
33
use ethers_core::types::H256;
44
use ethers_providers::{Http, Provider};
55
use prover_darwin_v2::BlockTrace;
6-
use serde::{de::DeserializeOwned, Serialize};
76
use std::cmp::Ordering;
8-
use std::fmt::Debug;
97

108
pub type CommonHash = H256;
119

@@ -19,10 +17,7 @@ impl L2gethClient {
1917
Ok(Self { provider })
2018
}
2119

22-
pub async fn get_block_trace_by_hash<T>(&self, hash: &CommonHash) -> anyhow::Result<T>
23-
where
24-
T: Serialize + DeserializeOwned + Debug + Send,
25-
{
20+
pub async fn get_block_trace_by_hash(&self, hash: &CommonHash) -> anyhow::Result<String> {
2621
log::info!(
2722
"l2geth_client calling get_block_trace_by_hash, hash: {:#?}",
2823
hash
@@ -45,7 +40,7 @@ impl L2gethClient {
4540
pub async fn get_sorted_traces_by_hashes(
4641
&self,
4742
block_hashes: &[CommonHash],
48-
) -> anyhow::Result<Vec<BlockTrace>> {
43+
) -> anyhow::Result<Vec<String>> {
4944
if block_hashes.is_empty() {
5045
log::error!("failed to get sorted traces: block_hashes are empty");
5146
anyhow::bail!("block_hashes are empty")
@@ -94,6 +89,7 @@ impl L2gethClient {
9489
}
9590
}
9691

97-
fn get_block_number_from_trace(block_trace: &BlockTrace) -> Option<u64> {
92+
fn get_block_number_from_trace(block_trace: &String) -> Option<u64> {
93+
let block_trace: BlockTrace = serde_json::from_str(block_trace).unwrap();
9894
block_trace.header.number.map(|n| n.as_u64())
9995
}

0 commit comments

Comments
 (0)