Skip to content

Commit 9a31c6d

Browse files
authored
chain: Do not use the block cache for is_on_main_chain (#6537)
Partially reverts #6491
1 parent 4ed1afe commit 9a31c6d

1 file changed

Lines changed: 6 additions & 12 deletions

File tree

chain/ethereum/src/chain.rs

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1075,6 +1075,12 @@ impl TriggersAdapterTrait<Chain> for TriggersAdapter {
10751075
}
10761076

10771077
async fn is_on_main_chain(&self, ptr: BlockPtr) -> Result<bool, Error> {
1078+
// It is tempting to use the block cache here; but that can go wrong
1079+
// when graph-node gets shut down and some of its nonfinal blocks
1080+
// then are reorged; when graph-node gets started again when those
1081+
// block numbers have become final, it might consider a reorged
1082+
// block as canonical; allowing the use of the block cache here
1083+
// would require us to also track the finality of blocks.
10781084
match &*self.chain_client {
10791085
ChainClient::Firehose(endpoints) => {
10801086
let endpoint = endpoints.endpoint().await?;
@@ -1088,18 +1094,6 @@ impl TriggersAdapterTrait<Chain> for TriggersAdapter {
10881094
Ok(block.hash() == ptr.hash)
10891095
}
10901096
ChainClient::Rpc(adapter) => {
1091-
let cached = self
1092-
.chain_store
1093-
.cheap_clone()
1094-
.block_ptrs_by_numbers(vec![ptr.number])
1095-
.await
1096-
.unwrap_or_default();
1097-
if let Some(ptrs) = cached.get(&ptr.number)
1098-
&& ptrs.len() == 1
1099-
{
1100-
return Ok(ptrs[0].hash == ptr.hash);
1101-
}
1102-
11031097
let adapter = adapter
11041098
.cheapest()
11051099
.await

0 commit comments

Comments
 (0)