1
1
use std:: fmt:: Display ;
2
- use std:: sync:: Arc ;
3
- use std:: time:: Duration ;
4
2
5
3
use alloy_primitives:: B256 ;
6
4
use serde:: { Deserialize , Serialize } ;
7
5
use sp1_sdk:: SP1ProofWithPublicValues ;
8
6
9
7
pub use crate :: error:: Error ;
10
- use crate :: network_prover:: AggSpanProver ;
11
- use crate :: rpc:: { AggSpanProofProposer , AggSpanProofProposerRequest , AggSpanProofProposerResponse } ;
8
+ use crate :: rpc:: { AggregationProofProposerRequest , AggregationProofProposerResponse } ;
12
9
pub mod config;
13
10
pub mod error;
14
11
pub mod network_prover;
15
12
pub mod rpc;
16
13
14
+ pub mod client;
17
15
#[ cfg( test) ]
18
16
mod tests;
19
17
@@ -22,66 +20,13 @@ mod tests;
22
20
pub trait ProposerClient {
23
21
async fn request_agg_proof (
24
22
& self ,
25
- request : AggSpanProofProposerRequest ,
26
- ) -> Result < AggSpanProofProposerResponse , Error > ;
23
+ request : AggregationProofProposerRequest ,
24
+ ) -> Result < AggregationProofProposerResponse , Error > ;
27
25
28
- async fn wait_for_proof ( & self , proof_id : ProofId ) -> Result < SP1ProofWithPublicValues , Error > ;
29
- }
30
-
31
- /// The Proposer client is responsible for retrieval of the AggSpanProof.
32
- /// AggSpanProof is the aggregated proof of the multiple
33
- /// block span full execution proofs.
34
- ///
35
- /// The proposer client communicates with the proposer API to
36
- /// request creation of the AggSpanProof (getting the proof ID in return),
37
- /// and directly communicates with the SP1 cluster using NetworkProver
38
- /// to retrieve the generated proof.
39
- #[ derive( Clone ) ]
40
- pub struct Client < Proposer , Prover > {
41
- proposer_rpc : Arc < Proposer > ,
42
- prover_rpc : Arc < Prover > ,
43
- proving_timeout : Option < Duration > ,
44
- }
45
-
46
- impl < Proposer , Prover > Client < Proposer , Prover >
47
- where
48
- Proposer : AggSpanProofProposer ,
49
- Prover : AggSpanProver ,
50
- {
51
- pub fn new (
52
- proposer : Proposer ,
53
- prover : Prover ,
54
- timeout : Option < Duration > ,
55
- ) -> Result < Self , error:: Error > {
56
- Ok ( Self {
57
- proposer_rpc : Arc :: new ( proposer) ,
58
- prover_rpc : Arc :: new ( prover) ,
59
- proving_timeout : timeout,
60
- } )
61
- }
62
- }
63
-
64
- #[ async_trait:: async_trait]
65
- impl < Proposer , Prover > ProposerClient for Client < Proposer , Prover >
66
- where
67
- Proposer : AggSpanProofProposer + Sync + Send ,
68
- Prover : AggSpanProver + Sync + Send ,
69
- {
70
- async fn request_agg_proof (
26
+ async fn wait_for_proof (
71
27
& self ,
72
- request : AggSpanProofProposerRequest ,
73
- ) -> Result < AggSpanProofProposerResponse , Error > {
74
- self . proposer_rpc . request_agg_proof ( request) . await
75
- }
76
-
77
- async fn wait_for_proof ( & self , proof_id : ProofId ) -> Result < SP1ProofWithPublicValues , Error > {
78
- let request_id = proof_id. 0 ;
79
-
80
- self . prover_rpc
81
- . wait_for_proof ( request_id, self . proving_timeout )
82
- . await
83
- . map_err ( |e| Error :: Proving ( proof_id, e. to_string ( ) ) )
84
- }
28
+ request_id : RequestId ,
29
+ ) -> Result < SP1ProofWithPublicValues , Error > ;
85
30
}
86
31
87
32
#[ derive( Debug , Clone , Serialize , Deserialize , PartialEq ) ]
@@ -99,9 +44,9 @@ pub struct FepProposerResponse {
99
44
}
100
45
101
46
#[ derive( Debug , Clone , Serialize , Deserialize , PartialEq ) ]
102
- pub struct ProofId ( pub B256 ) ;
47
+ pub struct RequestId ( pub B256 ) ;
103
48
104
- impl Display for ProofId {
49
+ impl Display for RequestId {
105
50
fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
106
51
write ! ( f, "{}" , hex:: encode( self . 0 ) )
107
52
}
0 commit comments