DataSourceBuilder - the Portal itself keeps track of which blocks are final.
Indexing unfinalized blocks
To index unfinalized (“hot”) blocks and stay correct across blockchain reorganizations, a squid must-
use a
Databasewith hot block support in itsrun()call. ForTypeormDatabasethat support is on unless explicitly disabled; state it explicitly with - not cap the block range of its data source below the chain head.
run() consumes the fork-aware stream of the data source. When a reorganization happens, the processor detects that the incoming blocks no longer extend the chain it has indexed, asks the Database to roll back the changes made for the orphaned blocks, then runs the batch handler on the new consensus blocks. The state of the Database reflects the current blockchain consensus at all times, and the batch handler code never has to deal with forks itself.
With a database that lacks hot block support (e.g. the file store or TypeormDatabase with {supportHotBlocks: false}), the processor consumes the finalized stream instead and simply stops short of the unfinalized chain head.
Networks without a Portal dataset, including local development chains, can be indexed in the same fork-aware way with the EVM RPC data source.