Skip to content

Commit bbdc3d8

Browse files
authored
chain/ethereum, docs: Default to fetching receipts concurrently
- Inverts the logic in `ethereum_adapter module` to make fetching receipts concurrently the default behaviour. - An environment variable `GRAPH_ETHEREUM_FETCH_TXN_RECEIPTS_IN_BATCHES` is provided for reverting to the previous, batching strategy.
1 parent e2b8b6d commit bbdc3d8

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

chain/ethereum/src/ethereum_adapter.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,8 @@ lazy_static! {
115115
.parse::<usize>()
116116
.expect("invalid GRAPH_ETHEREUM_BLOCK_INGESTOR_MAX_CONCURRENT_JSON_RPC_CALLS_FOR_TXN_RECEIPTS env var");
117117

118-
static ref FETCH_RECEIPTS_CONCURRENTLY: bool = std::env::var("GRAPH_EXPERIMENTAL_FETCH_TXN_RECEIPTS_CONCURRENTLY")
119-
.is_ok();
120-
121-
118+
static ref FETCH_RECEIPTS_IN_BATCHES: bool =
119+
matches!(std::env::var("GRAPH_ETHEREUM_FETCH_TXN_RECEIPTS_IN_BATCHES").as_deref(), Ok("true"));
122120
}
123121

124122
/// Gas limit for `eth_call`. The value of 50_000_000 is a protocol-wide parameter so this
@@ -1081,7 +1079,10 @@ impl EthereumAdapterTrait for EthereumAdapter {
10811079
})));
10821080
}
10831081
let hashes: Vec<_> = block.transactions.iter().map(|txn| txn.hash).collect();
1084-
let receipts_future = if *FETCH_RECEIPTS_CONCURRENTLY {
1082+
let receipts_future = if *FETCH_RECEIPTS_IN_BATCHES {
1083+
// Deprecated batching retrieval of transaction receipts.
1084+
fetch_transaction_receipts_in_batch_with_retry(web3, hashes, block_hash, logger).boxed()
1085+
} else {
10851086
let hash_stream = graph::tokio_stream::iter(hashes);
10861087
let receipt_stream = graph::tokio_stream::StreamExt::map(hash_stream, move |tx_hash| {
10871088
fetch_transaction_receipt_with_retry(
@@ -1095,9 +1096,6 @@ impl EthereumAdapterTrait for EthereumAdapter {
10951096
graph::tokio_stream::StreamExt::collect::<Result<Vec<TransactionReceipt>, IngestorError>>(
10961097
receipt_stream,
10971098
).boxed()
1098-
} else {
1099-
// Deprecated batching retrieval of transaction receipts.
1100-
fetch_transaction_receipts_in_batch_with_retry(web3, hashes, block_hash, logger).boxed()
11011099
};
11021100

11031101
let block_future =

docs/environment-variables.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ those.
3838
The maximum number of concurrent requests made against Ethereum for
3939
requesting transaction receipts during block ingestion.
4040
Defaults to 1,000.
41+
- `GRAPH_ETHEREUM_FETCH_TXN_RECEIPTS_IN_BATCHES`: Set to `true` to
42+
disable fetching receipts from the Ethereum node concurrently during
43+
block ingestion. This will use fewer, batched requests.
4144
- `GRAPH_ETHEREUM_CLEANUP_BLOCKS` : Set to `true` to clean up unneeded
4245
blocks from the cache in the database. When this is `false` or unset (the
4346
default), blocks will never be removed from the block cache. This setting

0 commit comments

Comments
 (0)