@@ -11,7 +11,7 @@ use crate::{
11
11
} ;
12
12
use axum:: { extract:: State , routing:: post, Json , Router } ;
13
13
use raiko_core:: {
14
- interfaces:: { BatchMetadata , BatchProofRequest , BatchProofRequestOpt } ,
14
+ interfaces:: { BatchMetadata , BatchProofRequest , BatchProofRequestOpt , RaikoError } ,
15
15
merge,
16
16
} ;
17
17
use raiko_lib:: { proof_type:: ProofType , prover:: Proof } ;
@@ -58,13 +58,27 @@ async fn batch_handler(
58
58
let mut opts = serde_json:: to_value ( actor. default_request_config ( ) ) ?;
59
59
merge ( & mut opts, & batch_request_opt) ;
60
60
61
+ let first_batch_id = {
62
+ let batches = opts[ "batches" ]
63
+ . as_array ( )
64
+ . ok_or ( RaikoError :: InvalidRequestConfig (
65
+ "Missing batches" . to_string ( ) ,
66
+ ) ) ?;
67
+ let first_batch = batches. first ( ) . ok_or ( RaikoError :: InvalidRequestConfig (
68
+ "batches is empty" . to_string ( ) ,
69
+ ) ) ?;
70
+ let first_batch_id = first_batch[ "batch_id" ] . as_u64 ( ) . expect ( "checked above" ) ;
71
+ first_batch_id
72
+ } ;
73
+
61
74
// For zk_any request, draw zk proof type based on the block hash.
62
75
if is_zk_any_request ( & opts) {
63
76
match draw_for_zk_any_batch_request ( & actor, & opts) . await ? {
64
77
Some ( proof_type) => opts[ "proof_type" ] = serde_json:: to_value ( proof_type) . unwrap ( ) ,
65
78
None => {
66
79
return Ok ( Status :: Ok {
67
80
proof_type : ProofType :: Native ,
81
+ batch_id : Some ( first_batch_id) ,
68
82
data : ProofResponse :: Status {
69
83
status : TaskStatus :: ZKAnyNotDrawn ,
70
84
} ,
@@ -207,7 +221,11 @@ async fn batch_handler(
207
221
}
208
222
} ;
209
223
tracing:: debug!( "Batch proof result: {}" , serde_json:: to_string( & result) ?) ;
210
- Ok ( to_v3_status ( batch_request. proof_type , result) )
224
+ Ok ( to_v3_status (
225
+ batch_request. proof_type ,
226
+ Some ( batch_request. batches . first ( ) . unwrap ( ) . batch_id ) ,
227
+ result,
228
+ ) )
211
229
}
212
230
213
231
#[ derive( OpenApi ) ]
0 commit comments