1
- use reqwest:: Client ;
1
+ use reqwest:: { Client , Response , StatusCode } ;
2
2
use secp256k1:: { ecdsa:: Signature , PublicKey } ;
3
- use serde:: { de :: DeserializeOwned , Serialize } ;
3
+ use serde:: Serialize ;
4
4
use url:: Url ;
5
5
use zksync_basic_types:: H256 ;
6
6
use zksync_prover_interface:: {
7
- api:: {
8
- RegisterTeeAttestationRequest , RegisterTeeAttestationResponse , SubmitTeeProofRequest ,
9
- SubmitTeeProofResponse , TeeProofGenerationDataRequest , TeeProofGenerationDataResponse ,
10
- } ,
7
+ api:: { RegisterTeeAttestationRequest , SubmitTeeProofRequest , TeeProofGenerationDataRequest } ,
11
8
inputs:: TeeVerifierInput ,
12
9
outputs:: L1BatchTeeProofForL1 ,
13
10
} ;
@@ -31,10 +28,9 @@ impl TeeApiClient {
31
28
}
32
29
}
33
30
34
- async fn post < Req , Resp , S > ( & self , endpoint : S , request : Req ) -> Result < Resp , reqwest:: Error >
31
+ async fn post < Req , S > ( & self , endpoint : S , request : Req ) -> Result < Response , reqwest:: Error >
35
32
where
36
33
Req : Serialize + std:: fmt:: Debug ,
37
- Resp : DeserializeOwned ,
38
34
S : AsRef < str > ,
39
35
{
40
36
let url = self . api_base_url . join ( endpoint. as_ref ( ) ) . unwrap ( ) ;
@@ -46,9 +42,7 @@ impl TeeApiClient {
46
42
. json ( & request)
47
43
. send ( )
48
44
. await ?
49
- . error_for_status ( ) ?
50
- . json :: < Resp > ( )
51
- . await
45
+ . error_for_status ( )
52
46
}
53
47
54
48
/// Registers the attestation quote with the TEE prover interface API, effectively proving that
@@ -63,8 +57,7 @@ impl TeeApiClient {
63
57
attestation : attestation_quote_bytes,
64
58
pubkey : public_key. serialize ( ) . to_vec ( ) ,
65
59
} ;
66
- self . post :: < _ , RegisterTeeAttestationResponse , _ > ( "/tee/register_attestation" , request)
67
- . await ?;
60
+ self . post ( "/tee/register_attestation" , request) . await ?;
68
61
tracing:: info!(
69
62
"Attestation quote was successfully registered for the public key {}" ,
70
63
public_key
@@ -77,12 +70,17 @@ impl TeeApiClient {
77
70
pub async fn get_job (
78
71
& self ,
79
72
tee_type : TeeType ,
80
- ) -> Result < Box < TeeVerifierInput > , TeeProverError > {
73
+ ) -> Result < Option < TeeVerifierInput > , TeeProverError > {
81
74
let request = TeeProofGenerationDataRequest { tee_type } ;
82
- let response = self
83
- . post :: < _ , TeeProofGenerationDataResponse , _ > ( "/tee/proof_inputs" , request)
84
- . await ?;
85
- Ok ( response. 0 )
75
+ let response = self . post ( "/tee/proof_inputs" , request) . await ?;
76
+ match response. status ( ) {
77
+ StatusCode :: OK => Ok ( Some ( response. json :: < TeeVerifierInput > ( ) . await ?) ) ,
78
+ StatusCode :: NO_CONTENT => Ok ( None ) ,
79
+ _ => response
80
+ . json :: < Option < TeeVerifierInput > > ( )
81
+ . await
82
+ . map_err ( TeeProverError :: Request ) ,
83
+ }
86
84
}
87
85
88
86
/// Submits the successfully verified proof to the TEE prover interface API.
@@ -101,7 +99,7 @@ impl TeeApiClient {
101
99
tee_type,
102
100
} ) ) ;
103
101
let observer = METRICS . proof_submitting_time . start ( ) ;
104
- self . post :: < _ , SubmitTeeProofResponse , _ > (
102
+ self . post (
105
103
format ! ( "/tee/submit_proofs/{batch_number}" ) . as_str ( ) ,
106
104
request,
107
105
)
0 commit comments