@@ -15,7 +15,11 @@ use anyhow::{bail, Context, Result};
15
15
use clap:: { Args , Parser , Subcommand } ;
16
16
use guest_util:: ECHO_ELF ;
17
17
use hex:: FromHex ;
18
- use risc0_zkvm:: sha:: Digest ;
18
+ use risc0_ethereum_contracts:: IRiscZeroVerifier ;
19
+ use risc0_zkvm:: {
20
+ sha:: { Digest , Digestible } ,
21
+ Journal ,
22
+ } ;
19
23
use url:: Url ;
20
24
21
25
use boundless_market:: {
@@ -72,6 +76,14 @@ enum Command {
72
76
#[ clap( short, long, default_value = "false" ) ]
73
77
wait : bool ,
74
78
} ,
79
+ /// Verify the proof of the given request against
80
+ /// the SetVerifier contract.
81
+ VerifyProof {
82
+ /// The proof request identifier
83
+ request_id : U256 ,
84
+ /// The image id of the original request
85
+ image_id : B256 ,
86
+ } ,
75
87
/// Get the status of a given request
76
88
Status {
77
89
/// The proof request identifier
@@ -138,6 +150,8 @@ struct MainArgs {
138
150
wallet_private_key : PrivateKeySigner ,
139
151
#[ clap( short, long, env) ]
140
152
proof_market_address : Address ,
153
+ #[ clap( short, long, env) ]
154
+ set_verifier_address : Address ,
141
155
#[ command( subcommand) ]
142
156
command : Command ,
143
157
}
@@ -156,7 +170,7 @@ async fn main() -> Result<()> {
156
170
let provider =
157
171
ProviderBuilder :: new ( ) . with_recommended_fillers ( ) . wallet ( wallet) . on_http ( args. rpc_url ) ;
158
172
let market = ProofMarketService :: new ( args. proof_market_address , provider. clone ( ) , caller) ;
159
-
173
+ let set_verifier = IRiscZeroVerifier :: new ( args . set_verifier_address , provider . clone ( ) ) ;
160
174
let command = args. command . clone ( ) ;
161
175
match command {
162
176
Command :: Deposit { amount } => {
@@ -182,7 +196,7 @@ async fn main() -> Result<()> {
182
196
}
183
197
Command :: Slash { request_id } => {
184
198
market. slash ( request_id) . await ?;
185
- tracing:: info!( "Request slashed: {request_id:x}" ) ;
199
+ tracing:: info!( "Request slashed: 0x {request_id:x}" ) ;
186
200
}
187
201
Command :: GetProof { request_id, wait } => {
188
202
let ( journal, seal) = if wait {
@@ -198,6 +212,19 @@ async fn main() -> Result<()> {
198
212
serde_json:: to_string_pretty( & seal) ?
199
213
) ;
200
214
}
215
+ Command :: VerifyProof { request_id, image_id } => {
216
+ let ( journal, seal) = market
217
+ . wait_for_request_fulfillment ( request_id, Duration :: from_secs ( 5 ) , None )
218
+ . await ?;
219
+
220
+ let journal_digest = <[ u8 ; 32 ] >:: from ( Journal :: new ( journal. to_vec ( ) ) . digest ( ) ) . into ( ) ;
221
+ set_verifier
222
+ . verify ( seal, image_id, journal_digest)
223
+ . call ( )
224
+ . await
225
+ . map_err ( |_| anyhow:: anyhow!( "Verification failed" ) ) ?;
226
+ tracing:: info!( "Proof for request id 0x{request_id:x} verified successfully." ) ;
227
+ }
201
228
Command :: Status { request_id } => {
202
229
let status = market. get_status ( request_id) . await ?;
203
230
tracing:: info!( "Status: {:?}" , status) ;
@@ -298,7 +325,7 @@ where
298
325
299
326
let request_id = market. submit_request ( & request, & signer) . await ?;
300
327
tracing:: info!(
301
- "Submitted request ID {request_id:x}, bidding start at block number {}" ,
328
+ "Submitted request ID 0x {request_id:x}, bidding start at block number {}" ,
302
329
offer. biddingStart
303
330
) ;
304
331
@@ -360,7 +387,7 @@ where
360
387
361
388
let request_id = market. submit_request ( & request, & signer) . await ?;
362
389
tracing:: info!(
363
- "Proving request ID {request_id:x}, bidding start at block number {}" ,
390
+ "Proving request ID 0x {request_id:x}, bidding start at block number {}" ,
364
391
request. offer. biddingStart
365
392
) ;
366
393
0 commit comments