@@ -2963,11 +2963,12 @@ async fn fetch_receipts_with_retry(
2963
2963
if supports_block_receipts {
2964
2964
return fetch_block_receipts_with_retry ( alloy, web3, hashes, block_hash, logger) . await ;
2965
2965
}
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
2967
2967
}
2968
2968
2969
2969
// Fetches receipts for each transaction in the block individually.
2970
2970
async fn fetch_individual_receipts_with_retry (
2971
+ alloy : Arc < dyn Provider + ' static > ,
2971
2972
web3 : Arc < Web3 < Transport > > ,
2972
2973
hashes : Vec < H256 > ,
2973
2974
block_hash : H256 ,
@@ -2983,6 +2984,7 @@ async fn fetch_individual_receipts_with_retry(
2983
2984
let receipt_stream = hash_stream
2984
2985
. map ( move |tx_hash| {
2985
2986
fetch_transaction_receipt_with_retry (
2987
+ alloy. clone ( ) ,
2986
2988
web3. cheap_clone ( ) ,
2987
2989
tx_hash,
2988
2990
block_hash,
@@ -3077,18 +3079,20 @@ async fn fetch_block_receipts_with_retry(
3077
3079
3078
3080
/// Retries fetching a single transaction receipt.
3079
3081
async fn fetch_transaction_receipt_with_retry (
3082
+ alloy : Arc < dyn Provider + ' static > ,
3080
3083
web3 : Arc < Web3 < Transport > > ,
3081
3084
transaction_hash : H256 ,
3082
3085
block_hash : H256 ,
3083
3086
logger : Logger ,
3084
3087
) -> Result < Arc < TransactionReceipt > , IngestorError > {
3085
- info ! ( logger, "!!!! fetch_transaction_receipt_with_retry" ) ;
3086
3088
let logger = logger. cheap_clone ( ) ;
3087
3089
let retry_log_message = format ! (
3088
3090
"eth_getTransactionReceipt RPC call for transaction {:?}" ,
3089
3091
transaction_hash
3090
3092
) ;
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)
3092
3096
. redact_log_urls ( true )
3093
3097
. limit ( ENV_VARS . request_retries )
3094
3098
. timeout_secs ( ENV_VARS . json_rpc_timeout . as_secs ( ) )
@@ -3098,7 +3102,40 @@ async fn fetch_transaction_receipt_with_retry(
3098
3102
. and_then ( move |some_receipt| {
3099
3103
resolve_transaction_receipt ( some_receipt, transaction_hash, block_hash, logger)
3100
3104
} )
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
3102
3139
}
3103
3140
3104
3141
fn resolve_transaction_receipt (
@@ -3243,10 +3280,6 @@ async fn get_transaction_receipts_for_transaction_hashes(
3243
3280
if transaction_hashes_by_block. is_empty ( ) {
3244
3281
return Ok ( receipts_by_hash) ;
3245
3282
}
3246
- info ! (
3247
- logger,
3248
- "!!!! get_transaction_receipts_for_transaction_hashes"
3249
- ) ;
3250
3283
// Keep a record of all unique transaction hashes for which we'll request receipts. We will
3251
3284
// later use this to check if we have collected the receipts from all required transactions.
3252
3285
let mut unique_transaction_hashes: HashSet < & H256 > = HashSet :: new ( ) ;
@@ -3255,10 +3288,12 @@ async fn get_transaction_receipts_for_transaction_hashes(
3255
3288
let receipt_futures = FuturesUnordered :: new ( ) ;
3256
3289
3257
3290
let web3 = Arc :: clone ( & adapter. web3 ) ;
3291
+ let alloy = adapter. alloy . clone ( ) ;
3258
3292
for ( block_hash, transaction_hashes) in transaction_hashes_by_block {
3259
3293
for transaction_hash in transaction_hashes {
3260
3294
unique_transaction_hashes. insert ( transaction_hash) ;
3261
3295
let receipt_future = fetch_transaction_receipt_with_retry (
3296
+ alloy. clone ( ) ,
3262
3297
web3. cheap_clone ( ) ,
3263
3298
* transaction_hash,
3264
3299
* block_hash,
@@ -3307,7 +3342,6 @@ async fn get_transaction_receipts_for_transaction_hashes(
3307
3342
unique_transaction_hashes. is_empty( ) ,
3308
3343
"Didn't receive all necessary transaction receipts"
3309
3344
) ;
3310
- info ! ( logger, "RCP: {:?}" , receipts_by_hash) ;
3311
3345
3312
3346
Ok ( receipts_by_hash)
3313
3347
}
@@ -3409,46 +3443,43 @@ fn convert_log(alloy_logs: &[alloy_rpc_types::Log<alloy::primitives::LogData>])
3409
3443
fn convert_receipts (
3410
3444
receipts_option : Option < Vec < alloy_rpc_types:: TransactionReceipt > > ,
3411
3445
) -> 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
+ }
3452
3483
}
3453
3484
3454
3485
fn tx_to_tx (
0 commit comments