@@ -4,7 +4,7 @@ use crate::{
4
4
api:: v3:: { ProofResponse , Status } ,
5
5
handler:: prove_many,
6
6
prove_aggregation,
7
- utils:: { is_zk_any_request, to_v3_status} ,
7
+ utils:: { draw_for_zk_any_request , fulfill_sp1_params , is_zk_any_request, to_v3_status} ,
8
8
} ,
9
9
} ;
10
10
use axum:: { extract:: State , routing:: post, Json , Router } ;
@@ -39,22 +39,33 @@ use utoipa::OpenApi;
39
39
/// - risc0 - uses the risc0 prover
40
40
async fn batch_handler (
41
41
State ( actor) : State < Actor > ,
42
- Json ( batch_request_opt) : Json < Value > ,
42
+ Json ( mut batch_request_opt) : Json < Value > ,
43
43
) -> HostResult < Status > {
44
44
if is_zk_any_request ( & batch_request_opt) {
45
- return Ok ( Status :: Ok {
46
- proof_type : ProofType :: Native ,
47
- data : ProofResponse :: Status {
48
- status : TaskStatus :: ZKAnyNotDrawn ,
49
- } ,
50
- } ) ;
45
+ fulfill_sp1_params ( & mut batch_request_opt) ;
51
46
}
52
47
53
48
let batch_request = {
54
49
// Override the existing proof request config from the config file and command line
55
50
// options with the request from the client, and convert to a BatchProofRequest.
56
51
let mut opts = serde_json:: to_value ( actor. default_request_config ( ) ) ?;
57
52
merge ( & mut opts, & batch_request_opt) ;
53
+
54
+ // For zk_any request, draw zk proof type based on the block hash.
55
+ if is_zk_any_request ( & opts) {
56
+ match draw_for_zk_any_request ( & actor, & opts) . await ? {
57
+ Some ( proof_type) => opts[ "proof_type" ] = serde_json:: to_value ( proof_type) . unwrap ( ) ,
58
+ None => {
59
+ return Ok ( Status :: Ok {
60
+ proof_type : ProofType :: Native ,
61
+ data : ProofResponse :: Status {
62
+ status : TaskStatus :: ZKAnyNotDrawn ,
63
+ } ,
64
+ } ) ;
65
+ }
66
+ }
67
+ }
68
+
58
69
let batch_request_opt: BatchProofRequestOpt = serde_json:: from_value ( opts) ?;
59
70
let batch_request: BatchProofRequest = batch_request_opt. try_into ( ) ?;
60
71
0 commit comments