@@ -36,8 +36,10 @@ pub enum AggregatedProofSubmissionError {
3636 BuildingBlobCommitment ,
3737 BuildingBlobProof ,
3838 BuildingBlobVersionedHash ,
39+ BuildingCalldata ( String ) ,
40+ BuildingTx ( String ) ,
3941 Risc0EncodingSeal ( String ) ,
40- SendVerifyAggregatedProofTransaction ( alloy :: contract :: Error ) ,
42+ SendVerifyAggregatedProofTransaction ( String ) ,
4143 ReceiptError ( PendingTransactionError ) ,
4244 FetchingProofs ( ProofsFetcherError ) ,
4345 ZKVMAggregation ( ProofAggregationError ) ,
@@ -73,8 +75,10 @@ impl ProofAggregator {
7375 let engine =
7476 ZKVMEngine :: from_env ( ) . expect ( "AGGREGATOR env variable to be set to one of sp1|risc0" ) ;
7577 let fetcher = ProofsFetcher :: new ( & config) ;
76- let ethrex_eth_client = ethrex_rpc:: EthClient :: new ( & config. eth_rpc_url ) . unwrap ( ) ;
77- let secret_key = SecretKey :: from_str ( & config. ecdsa . private_key ) . unwrap ( ) ;
78+ let ethrex_eth_client =
79+ ethrex_rpc:: EthClient :: new ( & config. eth_rpc_url ) . expect ( "rpc url to be valid" ) ;
80+ let secret_key =
81+ SecretKey :: from_str ( & config. ecdsa . private_key ) . expect ( "private key to be valid" ) ;
7882 let ethrex_signer =
7983 ethrex_l2_rpc:: signer:: Signer :: Local ( EthrexLocalSigner :: new ( secret_key) ) ;
8084
@@ -184,7 +188,7 @@ impl ProofAggregator {
184188 ) ,
185189 ] ,
186190 )
187- . expect ( "Calldata to be valid" ) ;
191+ . map_err ( |e| AggregatedProofSubmissionError :: BuildingCalldata ( e . to_string ( ) ) ) ? ;
188192
189193 let tx = build_generic_tx (
190194 & self . ethrex_eth_client ,
@@ -198,12 +202,16 @@ impl ProofAggregator {
198202 } ,
199203 )
200204 . await
201- . expect ( "Tx to be built correctly" ) ;
205+ . map_err ( |e| AggregatedProofSubmissionError :: BuildingTx ( e . to_string ( ) ) ) ? ;
202206
203207 let tx_hash =
204208 send_generic_transaction ( & self . ethrex_eth_client , tx, & self . ethrex_signer )
205209 . await
206- . expect ( "Transaction to be sent" ) ;
210+ . map_err ( |e| {
211+ AggregatedProofSubmissionError :: SendVerifyAggregatedProofTransaction (
212+ e. to_string ( ) ,
213+ )
214+ } ) ?;
207215
208216 Ok ( tx_hash)
209217 }
@@ -224,7 +232,7 @@ impl ProofAggregator {
224232 ) ,
225233 ] ,
226234 )
227- . expect ( "Calldata to be valid" ) ;
235+ . map_err ( |e| AggregatedProofSubmissionError :: BuildingCalldata ( e . to_string ( ) ) ) ? ;
228236
229237 let tx = build_generic_tx (
230238 & self . ethrex_eth_client ,
@@ -238,12 +246,16 @@ impl ProofAggregator {
238246 } ,
239247 )
240248 . await
241- . expect ( "Tx to be built correctly" ) ;
249+ . map_err ( |e| AggregatedProofSubmissionError :: BuildingTx ( e . to_string ( ) ) ) ? ;
242250
243251 let tx_hash =
244252 send_generic_transaction ( & self . ethrex_eth_client , tx, & self . ethrex_signer )
245253 . await
246- . expect ( "Transaction to be sent" ) ;
254+ . map_err ( |e| {
255+ AggregatedProofSubmissionError :: SendVerifyAggregatedProofTransaction (
256+ e. to_string ( ) ,
257+ )
258+ } ) ?;
247259
248260 Ok ( tx_hash)
249261 }
@@ -295,7 +307,8 @@ impl ProofAggregator {
295307 blob_data[ start..end] . copy_from_slice ( chunk) ;
296308 offset += 32 ;
297309 }
298- let blobs_bundle = BlobsBundle :: create_from_blobs ( & vec ! [ blob_data] , Fork :: Osaka ) . unwrap ( ) ;
310+ let blobs_bundle = BlobsBundle :: create_from_blobs ( & vec ! [ blob_data] , Fork :: Osaka )
311+ . map_err ( |_| AggregatedProofSubmissionError :: BuildingBlobProof ) ?;
299312 let blob_versioned_hash = blobs_bundle. generate_versioned_hashes ( ) [ 0 ] ;
300313
301314 Ok ( ( blobs_bundle, blob_versioned_hash. 0 ) )
0 commit comments