Conversation
fcf443c to
49f5815
Compare
ee6aaa2 to
73ba5f6
Compare
|
This has been updated with the newest discussion we had, and some other improvements:
This was tested and worked (still need to validate the POI of a subgraph synced straight with RPC and when switching from RPC to Firehose and the like):
Ready for review and merge. |
|
I have fully tested that resuming from RPC subgraph block then falling back to Firehose on a forked block produces the same POI for a few blocks after the forked block in question. I've fixed also an edge case where I was allowing to revert back behind manifest's defined start block. This is ready for a final review and merge. |
| let mut backoff = ExponentialBackoff::new(30 * SECOND, *SUBGRAPH_ERROR_RETRY_CEIL_SECS); | ||
|
|
||
| loop { | ||
| match store.delete_block_cursor() { |
There was a problem hiding this comment.
DB operations are blocking and need to be asyncified so they can be used in an async context, you need to use with_conn within delete_block_cursor to asyncify it.
There was a problem hiding this comment.
This is a copy of other existing methods in the trait like block_ptr, block_cursor and many others. Is the new paradigm to always use async from now on?
I would like to perform that in another PR mainly because this is blocking the integration test workflow and it would be nice to unlock it.
|
|
||
| async fn delete_subgraph_firehose_cursor(logger: &Logger, store: &dyn WritableStore) { | ||
| debug!(logger, "Deleting any existing Firehose cursor"); | ||
| let mut backoff = ExponentialBackoff::new(30 * SECOND, *SUBGRAPH_ERROR_RETRY_CEIL_SECS); |
There was a problem hiding this comment.
This retry looks a lot like
graph-node/store/postgres/src/writable.rs
Line 108 in ebc6f65
There was a problem hiding this comment.
I agree, in the FirehoseBlockIngestor there is a bunch of those also so it would be a good thing to have a re-usable method. Again, would like to postpone that to another PR.
| .map_err(|e| e.into()) | ||
| } | ||
|
|
||
| pub fn get_subgraph_firehose_cursor( |
There was a problem hiding this comment.
It looks like this also needs to be asyncified.
There was a problem hiding this comment.
This is not part of this PR, but I would include that in an upcoming PR that would asyncinfy the various methods found in the WritableStore trait.
b4540a4 to
6d1b8ba
Compare
…k ptr and no firehose cursor Firehose is now using the subgraph ptr if no cursor is found. To ensure we do not create inconsistency in the data due to how Firehose resolves current block number, a sanity check has now been added. This check ensure that the first received block's parent from firehose is the same as the subgraph pointer block. If it's not the case, we revert to the last know final block so we are sure to start from a correct chain segment. What final block to pick is decided by the chain itself. On Ethereum, we use `block.number - reorg_threshold` (guarded) while on NEAR, we use the last final block height defined by the block itself.
6d1b8ba to
5d8c4f1
Compare
|
@otaviopace I just rebased, then double-checked this PR and the behavior is as-expected. Would you kindly go ahead and merge this into master ? |
Firehose is now using the subgraph ptr if no cursor is found. To ensure we do not create inconsistency in the data due to how Firehose resolves current block number, a sanity check has now been added. This check ensure that the first received block's parent from firehose is the same as the subgraph pointer block. If it's not the case, we revert to the last know final block so we are sure to start from a correct chain segment.
What final block to pick is decided by the chain itself. On Ethereum, we use
block.number - reorg_threshold(guarded) while on NEAR, we use the last final block height defined by the block itself.Missing/To Change
I pushed the PR to get an overall feeling of the idea and get early inputs.
Right now I'm using
revert_block_operationsbut this is wrong as it's able to only revert a single block. I need in fact probably torewindthe subgraph but I would like to get advise here on how to do that properly and if there is any risks or stuff I missed with the approach.Ping @lutter to get your input about the
rewindthing above.Draft
This is based on #3133 for now, so I would like to get the other merged first and rebased + finish this one after.