@@ -8,6 +8,10 @@ use ethers::{
88} ;
99use sha3:: { Digest , Keccak256 } ;
1010
11+ /// How much to go back from current block if from_block is not provided
12+ /// 7500 blocks = 25hr
13+ const FROM_BLOCKS_AGO_DEFAULT : u64 = 7500 ;
14+
1115#[ derive( Debug ) ]
1216pub enum ProofVerificationAggModeError {
1317 ProvingSystemNotSupportedInAggMode ,
@@ -26,6 +30,7 @@ pub enum ProofVerificationAggModeError {
2630///
2731/// ⚠️ The `from` block used in the verification process must not be older than 18 days,
2832/// as blobs expire after that period and will no longer be retrievable.
33+ /// If not provided, it defaults to fetch logs from the past 25hs
2934///
3035/// The step-by-step verification process includes:
3136/// 1. Querying the blob versioned hash from the latest event emitted by the aligned proof aggregation service contract
@@ -40,12 +45,23 @@ pub async fn is_proof_verified_in_aggregation_mode(
4045 network : Network ,
4146 eth_rpc_url : String ,
4247 beacon_client_url : String ,
43- from_block : u64 ,
48+ from_block : Option < u64 > ,
4449) -> Result < [ u8 ; 32 ] , ProofVerificationAggModeError > {
4550 let eth_rpc_provider = Provider :: < Http > :: try_from ( eth_rpc_url)
4651 . map_err ( |e| ProofVerificationAggModeError :: EthereumProviderError ( e. to_string ( ) ) ) ?;
4752 let beacon_client = BeaconClient :: new ( beacon_client_url) ;
4853
54+ let from_block = match from_block {
55+ Some ( from_block) => from_block,
56+ None => {
57+ let block_number = eth_rpc_provider
58+ . get_block_number ( )
59+ . await
60+ . map_err ( |e| ProofVerificationAggModeError :: EthereumProviderError ( e. to_string ( ) ) ) ?;
61+ block_number. as_u64 ( ) - FROM_BLOCKS_AGO_DEFAULT
62+ }
63+ } ;
64+
4965 let filter = Filter :: new ( )
5066 . address ( network. get_aligned_proof_agg_service_address ( ) )
5167 . event ( "AggregatedProofVerified(bytes32,bytes32)" )
@@ -111,7 +127,7 @@ pub async fn is_proof_verified_in_aggregation_mode(
111127 }
112128 }
113129
114- return Err ( ProofVerificationAggModeError :: ProofNotFoundInLogs ) ;
130+ Err ( ProofVerificationAggModeError :: ProofNotFoundInLogs )
115131}
116132
117133fn decoded_blob ( blob_data : Vec < u8 > ) -> Vec < [ u8 ; 32 ] > {
0 commit comments