Skip to content

Commit 257c436

Browse files
committed
fix some issues while debugging
1 parent feb9646 commit 257c436

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

coordinator/internal/logic/provertask/bundle_prover_task.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -243,9 +243,14 @@ func (bp *BundleProverTask) formatProverTask(ctx context.Context, task *orm.Prov
243243
return nil, fmt.Errorf("failed to get batch proofs for bundle task id:%s, no batch found", task.TaskID)
244244
}
245245

246-
parentBatch, err := bp.batchOrm.GetBatchByHash(ctx, batches[0].ParentBatchHash)
247-
if err != nil {
248-
return nil, fmt.Errorf("failed to get parent batch for batch task id:%s err:%w", task.TaskID, err)
246+
var prevStateRoot common.Hash
247+
// this would be common in test cases: the first batch has empty parent
248+
if batches[0].Index > 1 {
249+
parentBatch, err := bp.batchOrm.GetBatchByHash(ctx, batches[0].ParentBatchHash)
250+
if err != nil {
251+
return nil, fmt.Errorf("failed to get parent batch for batch task id:%s err:%w", task.TaskID, err)
252+
}
253+
prevStateRoot = common.HexToHash(parentBatch.StateRoot)
249254
}
250255

251256
var batchProofs []*message.OpenVMBatchProof
@@ -264,7 +269,7 @@ func (bp *BundleProverTask) formatProverTask(ctx context.Context, task *orm.Prov
264269

265270
taskDetail.BundleInfo = &message.OpenVMBundleInfo{
266271
ChainID: bp.cfg.L2.ChainID,
267-
PrevStateRoot: common.HexToHash(parentBatch.StateRoot),
272+
PrevStateRoot: prevStateRoot,
268273
PostStateRoot: common.HexToHash(batches[len(batches)-1].StateRoot),
269274
WithdrawRoot: common.HexToHash(batches[len(batches)-1].WithdrawRoot),
270275
NumBatches: uint32(len(batches)),

crates/l2geth/src/rpc_client.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ impl ChunkInterpreter for RpcClient<'_> {
108108
.get_block_by_hash(block_hash)
109109
.full()
110110
.await?
111-
.ok_or_else(|| eyre::eyre!("Block not found"))?;
111+
.ok_or_else(|| eyre::eyre!("Block {block_hash} not found"))?;
112112

113113
let number = block.header.number;
114114
if number == 0 {

crates/libzkp_c/src/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,7 @@ pub unsafe extern "C" fn gen_universal_task(
204204
.as_secs();
205205
let c_str = unsafe { std::ffi::CStr::from_ptr(fork_name) };
206206
let filename = format!("/tmp/task_{}_{}.json", c_str.to_str().unwrap(), timestamp);
207-
let c_str = unsafe { std::ffi::CStr::from_ptr(task) };
208-
if let Err(e) = std::fs::write(&filename, c_str.to_bytes()) {
207+
if let Err(e) = std::fs::write(&filename, task_json.as_bytes()) {
209208
eprintln!("Failed to write task to file {}: {}", filename, e);
210209
} else {
211210
println!("Dumped failed task to {}", filename);

0 commit comments

Comments
 (0)