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