graphprotocol / graph-node

Graph Node indexes data from blockchains such as Ethereum and serves it over GraphQL
https://thegraph.com
Apache License 2.0
2.92k stars 978 forks source link

[Bug] Subgraph `startBlock` not respected for substreams-based subgraphs #5615

Closed YaroShkvorets closed 2 months ago

YaroShkvorets commented 3 months ago

Bug report

Suppose I have a substreams-based subgraph that's consuming events from a substreams module that has initialBlock: 0.

In my subgraph manifest I'm setting startBlock: 1000000 for my substreams data source, so I want it to stream events starting from that block. But graph-node only looks at the substreams module initialBlock and starts streaming from block 0.

Relevant code: https://github.com/graphprotocol/graph-node/blob/e2e69250062f7cf5c8c38d1f6b4dcf9398140f72/chain/substreams/src/data_source.rs#L209-L211

I don't see why it shouldn't just take startBlock from subgraph manifest or use max(substreams_initialBlock, subgraph_startBlock) instead.

Use case: substreams-based subgraphs that use general-purpose foundational modules to stream only events emitted by a smart contract. They always have initialBlock: 0 but for each subgraph we would want to use start block when our smart contract was deployed.

Relevant log output

No response

IPFS hash

No response

Subgraph name or link to explorer

No response

Some information to help us out

OS information

None

YaroShkvorets commented 3 months ago

PR: https://github.com/graphprotocol/graph-node/pull/5617