Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Bug] Going back from firehose ingestor to rpc-based ingestor is broken #4670

@sduchesneau

Description

@sduchesneau

Bug report

Steps to reproduce:

  1. launch graph-node with a subgraph, without any rpc provider, so that firehose is used as the blockIngestor
  2. restart graph-node without firehose, using rpc provider as the blockingestor and stream source for the subgraph
  3. observe the following debug logs: DEBG Block stream produced a non-fatal error, error: missing field parentHash,

Workaround

  • Flushing the block cache fixes the issue

Explanation

The "firehose block ingestor" is implemented differently that the "rpc block ingestor". It only saves the block hash and number to the database:

update(n::table.filter(n::name.eq(&self.chain)))
.set((
n::head_block_hash.eq(&hash),
n::head_block_number.eq(number),
n::head_block_cursor.eq(cursor),
))

(called from
https://github.com/graphprotocol/graph-node/blob/master/graph/src/blockchain/firehose_block_ingestor.rs#L153)

The "rpc block ingestor" saves more data in the database:

// We should always have the parent block available to us at this point.
if let Some(parent_hash) = block.parent_hash() {
self.recent_blocks_cache
.insert_block(block.ptr(), block.data().ok(), parent_hash);
}

(called from ingest_block() in https://github.com/graphprotocol/graph-node/blob/master/chain/ethereum/src/ingestor.rs#L181)

Proposed solution

either:

  1. fix the firehose-based ingestor so that it adds all the required fields (namely, parent_hash)
  2. add a check on graph-node start: if the subgraphs are being served from RPC for a given chain, validate that the blocks are complete in the database or flush the cache)

Relevant log output

No response

IPFS hash

No response

Subgraph name or link to explorer

No response

Some information to help us out

  • Tick this box if this bug is caused by a regression found in the latest release.
  • Tick this box if this bug is specific to the hosted service.
  • I have searched the issue tracker to make sure this issue is not a duplicate.

OS information

None

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions