@@ -2963,11 +2963,12 @@ async fn fetch_receipts_with_retry(
29632963 if supports_block_receipts {
29642964 return fetch_block_receipts_with_retry ( alloy, web3, hashes, block_hash, logger) . await ;
29652965 }
2966- fetch_individual_receipts_with_retry ( web3, hashes, block_hash, logger) . await
2966+ fetch_individual_receipts_with_retry ( alloy , web3, hashes, block_hash, logger) . await
29672967}
29682968
29692969// Fetches receipts for each transaction in the block individually.
29702970async fn fetch_individual_receipts_with_retry (
2971+ alloy : Arc < dyn Provider + ' static > ,
29712972 web3 : Arc < Web3 < Transport > > ,
29722973 hashes : Vec < H256 > ,
29732974 block_hash : H256 ,
@@ -2983,6 +2984,7 @@ async fn fetch_individual_receipts_with_retry(
29832984 let receipt_stream = hash_stream
29842985 . map ( move |tx_hash| {
29852986 fetch_transaction_receipt_with_retry (
2987+ alloy. clone ( ) ,
29862988 web3. cheap_clone ( ) ,
29872989 tx_hash,
29882990 block_hash,
@@ -3077,18 +3079,20 @@ async fn fetch_block_receipts_with_retry(
30773079
30783080/// Retries fetching a single transaction receipt.
30793081async fn fetch_transaction_receipt_with_retry (
3082+ alloy : Arc < dyn Provider + ' static > ,
30803083 web3 : Arc < Web3 < Transport > > ,
30813084 transaction_hash : H256 ,
30823085 block_hash : H256 ,
30833086 logger : Logger ,
30843087) -> Result < Arc < TransactionReceipt > , IngestorError > {
3085- info ! ( logger, "!!!! fetch_transaction_receipt_with_retry" ) ;
30863088 let logger = logger. cheap_clone ( ) ;
30873089 let retry_log_message = format ! (
30883090 "eth_getTransactionReceipt RPC call for transaction {:?}" ,
30893091 transaction_hash
30903092 ) ;
3091- retry ( retry_log_message, & logger)
3093+ let logger2 = logger. cheap_clone ( ) ;
3094+ let retry_log_message2 = retry_log_message. clone ( ) ;
3095+ let rcp1 = retry ( retry_log_message, & logger)
30923096 . redact_log_urls ( true )
30933097 . limit ( ENV_VARS . request_retries )
30943098 . timeout_secs ( ENV_VARS . json_rpc_timeout . as_secs ( ) )
@@ -3098,7 +3102,40 @@ async fn fetch_transaction_receipt_with_retry(
30983102 . and_then ( move |some_receipt| {
30993103 resolve_transaction_receipt ( some_receipt, transaction_hash, block_hash, logger)
31003104 } )
3101- . map ( Arc :: new)
3105+ . map ( Arc :: new) ;
3106+
3107+ let mut rcp2: Result < Arc < TransactionReceipt > , IngestorError > =
3108+ retry ( retry_log_message2, & logger2)
3109+ . redact_log_urls ( true )
3110+ . limit ( ENV_VARS . request_retries )
3111+ . timeout_secs ( ENV_VARS . json_rpc_timeout . as_secs ( ) )
3112+ . run ( move || {
3113+ alloy
3114+ . get_transaction_receipt ( h256_to_b256 ( & transaction_hash) )
3115+ . boxed ( )
3116+ } )
3117+ . await
3118+ . map_err ( |_timeout| anyhow ! ( block_hash) . into ( ) )
3119+ . and_then ( move |some_receipt| {
3120+ let rcp = some_receipt. map ( convert_receipt) ;
3121+ resolve_transaction_receipt ( rcp, transaction_hash, block_hash, logger2)
3122+ } )
3123+ . map ( Arc :: new) ;
3124+ match ( & rcp1, & mut rcp2) {
3125+ ( Ok ( r1) , Ok ( r2) ) => {
3126+ let r2 = std:: sync:: Arc :: < graph:: prelude:: web3:: types:: TransactionReceipt > :: get_mut ( r2)
3127+ . unwrap ( ) ;
3128+ r2. cumulative_gas_used = r1. cumulative_gas_used ;
3129+ r2. root = r1. root ;
3130+ r2. transaction_type = r1. transaction_type ;
3131+ let r2 = r2. clone ( ) ;
3132+ let r2 = Arc :: new ( r2) ;
3133+ assert_eq ! ( r1, & r2) ;
3134+ }
3135+ ( _, _) => todo ! ( ) ,
3136+ } ;
3137+
3138+ rcp1
31023139}
31033140
31043141fn resolve_transaction_receipt (
@@ -3243,10 +3280,6 @@ async fn get_transaction_receipts_for_transaction_hashes(
32433280 if transaction_hashes_by_block. is_empty ( ) {
32443281 return Ok ( receipts_by_hash) ;
32453282 }
3246- info ! (
3247- logger,
3248- "!!!! get_transaction_receipts_for_transaction_hashes"
3249- ) ;
32503283 // Keep a record of all unique transaction hashes for which we'll request receipts. We will
32513284 // later use this to check if we have collected the receipts from all required transactions.
32523285 let mut unique_transaction_hashes: HashSet < & H256 > = HashSet :: new ( ) ;
@@ -3255,10 +3288,12 @@ async fn get_transaction_receipts_for_transaction_hashes(
32553288 let receipt_futures = FuturesUnordered :: new ( ) ;
32563289
32573290 let web3 = Arc :: clone ( & adapter. web3 ) ;
3291+ let alloy = adapter. alloy . clone ( ) ;
32583292 for ( block_hash, transaction_hashes) in transaction_hashes_by_block {
32593293 for transaction_hash in transaction_hashes {
32603294 unique_transaction_hashes. insert ( transaction_hash) ;
32613295 let receipt_future = fetch_transaction_receipt_with_retry (
3296+ alloy. clone ( ) ,
32623297 web3. cheap_clone ( ) ,
32633298 * transaction_hash,
32643299 * block_hash,
@@ -3307,7 +3342,6 @@ async fn get_transaction_receipts_for_transaction_hashes(
33073342 unique_transaction_hashes. is_empty( ) ,
33083343 "Didn't receive all necessary transaction receipts"
33093344 ) ;
3310- info ! ( logger, "RCP: {:?}" , receipts_by_hash) ;
33113345
33123346 Ok ( receipts_by_hash)
33133347}
@@ -3409,46 +3443,43 @@ fn convert_log(alloy_logs: &[alloy_rpc_types::Log<alloy::primitives::LogData>])
34093443fn convert_receipts (
34103444 receipts_option : Option < Vec < alloy_rpc_types:: TransactionReceipt > > ,
34113445) -> Option < Vec < TransactionReceipt > > {
3412- receipts_option. map ( |receipts| {
3413- receipts
3414- . into_iter ( )
3415- . map ( |receipt| {
3416- let transaction_hash = b256_to_h256 ( receipt. transaction_hash ) ;
3417- let transaction_index = u64_to_u64 ( receipt. transaction_index . unwrap ( ) ) ;
3418- let block_hash = receipt. block_hash . map ( b256_to_h256) ;
3419- let block_number = receipt. block_number . map ( u64_to_u64) ;
3420- let from = address_to_h160 ( receipt. from ) ;
3421- let to = receipt. to . map ( address_to_h160) ;
3422- let cumulative_gas_used = u64_to_u256 ( receipt. blob_gas_used . unwrap_or_default ( ) ) ; // TODO: fix
3423- let gas_used = Some ( u64_to_u256 ( receipt. gas_used ) ) ;
3424- let contract_address = receipt. contract_address . map ( address_to_h160) ;
3425- let logs = convert_log ( receipt. logs ( ) ) ;
3426- let status = Some ( bool_to_u64 ( receipt. status ( ) ) ) ;
3427- let root = None ; // TODO: fix it
3428- let logs_bloom = convert_bloom ( receipt. inner . logs_bloom ( ) ) ;
3429- let transaction_type = Some ( u64_to_u64 ( 0 ) ) ; // TODO fix it
3430- let effective_gas_price = Some ( u128_to_u256 ( receipt. effective_gas_price ) ) ;
3431-
3432- TransactionReceipt {
3433- transaction_hash,
3434- transaction_index,
3435- block_hash,
3436- block_number,
3437- from,
3438- to,
3439- cumulative_gas_used,
3440- gas_used,
3441- contract_address,
3442- logs,
3443- status,
3444- root,
3445- logs_bloom,
3446- transaction_type,
3447- effective_gas_price,
3448- }
3449- } )
3450- . collect ( )
3451- } )
3446+ receipts_option. map ( |receipts| receipts. into_iter ( ) . map ( convert_receipt) . collect ( ) )
3447+ }
3448+
3449+ fn convert_receipt ( receipt : alloy_rpc_types:: TransactionReceipt ) -> TransactionReceipt {
3450+ let transaction_hash = b256_to_h256 ( receipt. transaction_hash ) ;
3451+ let transaction_index = u64_to_u64 ( receipt. transaction_index . unwrap ( ) ) ;
3452+ let block_hash = receipt. block_hash . map ( b256_to_h256) ;
3453+ let block_number = receipt. block_number . map ( u64_to_u64) ;
3454+ let from = address_to_h160 ( receipt. from ) ;
3455+ let to = receipt. to . map ( address_to_h160) ;
3456+ let cumulative_gas_used = u64_to_u256 ( receipt. blob_gas_used . unwrap_or_default ( ) ) ; // TODO: fix
3457+ let gas_used = Some ( u64_to_u256 ( receipt. gas_used ) ) ;
3458+ let contract_address = receipt. contract_address . map ( address_to_h160) ;
3459+ let logs = convert_log ( receipt. logs ( ) ) ;
3460+ let status = Some ( bool_to_u64 ( receipt. status ( ) ) ) ;
3461+ let root = None ; // TODO: fix it
3462+ let logs_bloom = convert_bloom ( receipt. inner . logs_bloom ( ) ) ;
3463+ let transaction_type = Some ( u64_to_u64 ( 0 ) ) ; // TODO fix it
3464+ let effective_gas_price = Some ( u128_to_u256 ( receipt. effective_gas_price ) ) ;
3465+
3466+ TransactionReceipt {
3467+ transaction_hash,
3468+ transaction_index,
3469+ block_hash,
3470+ block_number,
3471+ from,
3472+ to,
3473+ cumulative_gas_used,
3474+ gas_used,
3475+ contract_address,
3476+ logs,
3477+ status,
3478+ root,
3479+ logs_bloom,
3480+ transaction_type,
3481+ effective_gas_price,
3482+ }
34523483}
34533484
34543485fn tx_to_tx (
0 commit comments