11use super :: ProofType ;
22use async_trait:: async_trait;
3+ use std:: fmt;
34
45#[ async_trait]
56pub trait ProvingService {
@@ -9,27 +10,38 @@ pub trait ProvingService {
910 async fn query_task ( & mut self , req : QueryTaskRequest ) -> QueryTaskResponse ;
1011}
1112
12- #[ derive( Default ) ]
13+ #[ derive( Default , Debug , Clone , PartialEq , Eq , Hash ) ]
1314pub struct GetVkRequest {
1415 pub proof_types : Vec < ProofType > ,
1516 pub circuit_version : String ,
1617}
1718
18- #[ derive( Default ) ]
19+ #[ derive( Default , Debug , Clone , PartialEq , Eq , Hash ) ]
1920pub struct GetVkResponse {
2021 pub vks : Vec < String > ,
2122 pub error : Option < String > ,
2223}
2324
24- #[ derive( Default , Clone ) ]
25+ #[ derive( Default , Clone , PartialEq , Eq , Hash ) ]
2526pub struct ProveRequest {
2627 pub proof_type : ProofType ,
2728 pub circuit_version : String ,
2829 pub hard_fork_name : String ,
2930 pub input : String ,
3031}
3132
32- #[ derive( Default ) ]
33+ impl fmt:: Debug for ProveRequest {
34+ fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
35+ f. debug_struct ( "ProveRequest" )
36+ . field ( "proof_type" , & self . proof_type )
37+ . field ( "circuit_version" , & self . circuit_version )
38+ . field ( "hard_fork_name" , & self . hard_fork_name )
39+ . field ( "input" , & "..." )
40+ . finish ( )
41+ }
42+ }
43+
44+ #[ derive( Default , Clone , PartialEq ) ]
3345pub struct ProveResponse {
3446 pub task_id : String ,
3547 pub proof_type : ProofType ,
@@ -46,12 +58,46 @@ pub struct ProveResponse {
4658 pub error : Option < String > ,
4759}
4860
49- #[ derive( Default ) ]
61+ impl fmt:: Debug for ProveResponse {
62+ fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
63+ let mut fmt = f. debug_struct ( "ProveResponse" ) ;
64+ fmt. field ( "task_id" , & self . task_id )
65+ . field ( "proof_type" , & self . proof_type )
66+ . field ( "circuit_version" , & self . circuit_version )
67+ . field ( "hard_fork_name" , & self . hard_fork_name )
68+ . field ( "status" , & self . status )
69+ . field ( "created_at" , & self . created_at ) ;
70+ if let Some ( started_at) = & self . started_at {
71+ fmt. field ( "started_at" , started_at) ;
72+ }
73+ if let Some ( finished_at) = & self . finished_at {
74+ fmt. field ( "finished_at" , finished_at) ;
75+ }
76+ if let Some ( compute_time_sec) = & self . compute_time_sec {
77+ fmt. field ( "compute_time_sec" , compute_time_sec) ;
78+ }
79+ if self . input . is_some ( ) {
80+ fmt. field ( "input" , & "..." ) ; // Hide actual input for brevity
81+ }
82+ if self . proof . is_some ( ) {
83+ fmt. field ( "proof" , & "..." ) ; // Hide actual proof for brevity
84+ }
85+ if let Some ( vk) = & self . vk {
86+ fmt. field ( "vk" , vk) ;
87+ }
88+ if let Some ( error) = & self . error {
89+ fmt. field ( "error" , error) ;
90+ }
91+ fmt. finish ( )
92+ }
93+ }
94+
95+ #[ derive( Default , Debug , Clone , PartialEq , Eq , Hash ) ]
5096pub struct QueryTaskRequest {
5197 pub task_id : String ,
5298}
5399
54- #[ derive( Default ) ]
100+ #[ derive( Default , Clone , PartialEq ) ]
55101pub struct QueryTaskResponse {
56102 pub task_id : String ,
57103 pub proof_type : ProofType ,
@@ -68,7 +114,41 @@ pub struct QueryTaskResponse {
68114 pub error : Option < String > ,
69115}
70116
71- #[ derive( Debug , PartialEq , Default ) ]
117+ impl fmt:: Debug for QueryTaskResponse {
118+ fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
119+ let mut fmt = f. debug_struct ( "QueryTaskResponse" ) ;
120+ fmt. field ( "task_id" , & self . task_id )
121+ . field ( "proof_type" , & self . proof_type )
122+ . field ( "circuit_version" , & self . circuit_version )
123+ . field ( "hard_fork_name" , & self . hard_fork_name )
124+ . field ( "status" , & self . status )
125+ . field ( "created_at" , & self . created_at ) ;
126+ if let Some ( started_at) = & self . started_at {
127+ fmt. field ( "started_at" , started_at) ;
128+ }
129+ if let Some ( finished_at) = & self . finished_at {
130+ fmt. field ( "finished_at" , finished_at) ;
131+ }
132+ if let Some ( compute_time_sec) = & self . compute_time_sec {
133+ fmt. field ( "compute_time_sec" , compute_time_sec) ;
134+ }
135+ if self . input . is_some ( ) {
136+ fmt. field ( "input" , & "..." ) ; // Hide actual input for brevity
137+ }
138+ if self . proof . is_some ( ) {
139+ fmt. field ( "proof" , & "..." ) ; // Hide actual proof for brevity
140+ }
141+ if let Some ( vk) = & self . vk {
142+ fmt. field ( "vk" , vk) ;
143+ }
144+ if let Some ( error) = & self . error {
145+ fmt. field ( "error" , error) ;
146+ }
147+ fmt. finish ( )
148+ }
149+ }
150+
151+ #[ derive( Default , Debug , Copy , Clone , PartialEq , Eq , Hash ) ]
72152pub enum TaskStatus {
73153 #[ default]
74154 Queued ,
0 commit comments