Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: closes issue #1071 - fetch a poi from the latestBlock if it's behind chainhead #1085

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 32 additions & 5 deletions packages/indexer-common/src/indexer-management/monitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
resolveChainAlias,
TransferredSubgraphDeployment,
sequentialTimerReduce,
IndexingStatus,
} from '@graphprotocol/indexer-common'
import {
Address,
Expand Down Expand Up @@ -956,16 +957,42 @@ Please submit an issue at https://github.com/graphprotocol/block-oracle/issues/n
switch (poi == generatedPOI) {
case true:
if (poi == undefined) {
const deploymentStatus = await this.graphNode.indexingStatus([
allocation.subgraphDeployment.id,
])
const deploymentStatuses: IndexingStatus[] =
await this.graphNode.indexingStatus([allocation.subgraphDeployment.id])

const thisDeploymentStatus = deploymentStatuses.find(
(status) =>
status.subgraphDeployment.ipfsHash ==
allocation.subgraphDeployment.id.ipfsHash,
)
if (thisDeploymentStatus) {
const chain = thisDeploymentStatus.chains.find(
(chain) => chain.network == supportedNetworkAlias,
)
if (
chain &&
chain.latestBlock &&
chain.chainHeadBlock &&
chain.latestBlock.number <= chain.chainHeadBlock.number
) {
const generatedPOI = await this.graphNode.proofOfIndexing(
allocation.subgraphDeployment.id,
chain.latestBlock,
allocation.indexer,
)
if (generatedPOI !== undefined) {
return generatedPOI
}
}
}

throw indexerError(
IndexerErrorCode.IE067,
`POI not available for deployment at current epoch start block.
currentEpochStartBlock: ${epochStartBlock.number}
deploymentStatus: ${
deploymentStatus.length > 0
? JSON.stringify(deploymentStatus)
deploymentStatuses.length > 0
? JSON.stringify(deploymentStatuses)
: 'not deployed'
}`,
)
Expand Down
Loading