graph-node icon indicating copy to clipboard operation
graph-node copied to clipboard

POI is generated for invalid block number and hash

Open hopeyen opened this issue 1 year ago • 1 comments

Do you want to request a feature or report a bug? bug

What is the current behavior? Currently when querying proofOfIndexing in the admin API with incorrect block hash or invalid block number will each return different POIs. Since invalid POIs can be generated this way, would it make sense for graph-node to error out saying that the block number or hash is invalid for the subgraph (and network that the subgraph is indexing)?

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem. Example query for a goerli subgraph with combination of POI queries on the same subgraph:

{
  indexingStatuses(subgraphs: ["QmfDSEUwk2Wp1cVEQ8FcJLVJLbPRfLpG75gLTEHkrSEFRC"]) {
    subgraph
    synced
    health
    fatalError {
      handler
      message
    }
    chains {
      network
      ... on EthereumIndexingStatus {
        latestBlock {
          number
          hash
        }
        chainHeadBlock {
          number
          hash
        }
      }
    }
  }
  blockHashFromNumber(network:"goerli", blockNumber:8491464)
  right_hash: proofOfIndexing(subgraph:"QmfDSEUwk2Wp1cVEQ8FcJLVJLbPRfLpG75gLTEHkrSEFRC",
  	blockNumber:8491464,
    blockHash: "5d80892e197d636d669af71f06e3fb23ffe5b16b0f3165ac866bdb34ec417488"
  )
  wrong_hash: proofOfIndexing(subgraph:"QmfDSEUwk2Wp1cVEQ8FcJLVJLbPRfLpG75gLTEHkrSEFRC",
  	blockNumber:8491464,
    blockHash: "3d80892e197d636d669af71f06e3fb23ffe5b16b0f3165ac866bdb34ec417488"
  )
  very_wrong_hash: proofOfIndexing(subgraph:"QmfDSEUwk2Wp1cVEQ8FcJLVJLbPRfLpG75gLTEHkrSEFRC",
  	blockNumber:8491464,
    blockHash: "636d669af71f06e3fb23ffe5b16b0f3165ac866bdb34ec417488"
  )
  wrong_number: proofOfIndexing(subgraph:"QmfDSEUwk2Wp1cVEQ8FcJLVJLbPRfLpG75gLTEHkrSEFRC",
  	blockNumber:7491464,
    blockHash: "3d80892e197d636d669af71f06e3fb23ffe5b16b0f3165ac866bdb34ec417488"
  )
  very_wrong_number: proofOfIndexing(subgraph:"QmfDSEUwk2Wp1cVEQ8FcJLVJLbPRfLpG75gLTEHkrSEFRC",
  	blockNumber:1464,
    blockHash: "3d80892e197d636d669af71f06e3fb23ffe5b16b0f3165ac866bdb34ec417488"
  )
}

Corresponding output

{
  "data": {
    "indexingStatuses": [
      {
        "subgraph": "QmfDSEUwk2Wp1cVEQ8FcJLVJLbPRfLpG75gLTEHkrSEFRC",
        "synced": true,
        "health": "healthy",
        "fatalError": null,
        "chains": [
          {
            "network": "goerli",
            "latestBlock": {
              "number": "8491464",
              "hash": "5d80892e197d636d669af71f06e3fb23ffe5b16b0f3165ac866bdb34ec417488"
            },
            "chainHeadBlock": {
              "number": "8491464",
              "hash": "5d80892e197d636d669af71f06e3fb23ffe5b16b0f3165ac866bdb34ec417488"
            }
          }
        ]
      }
    ],
    "blockHashFromNumber": "5d80892e197d636d669af71f06e3fb23ffe5b16b0f3165ac866bdb34ec417488",   // correct hash from the block number
    "right_hash": "0xb632fc83cb304ce0dfc3697901b848b97dabcdeac0229bd097c94296a2f5ff66",                   // with valid hash and number
    "wrong_hash": "0xd8fc7f59e4f010a070f5b0096841db437085fdfab8e2c5c9575b24e0c1dbd24a",                  // expected error of invalid hash corresponding to the number
    "very_wrong_hash": "0x11a87231123516f68b93a13860a63e5c6773824be33299b7e2339a27dff7a4a4",        // expected error from invalid hash string length
    "wrong_number": "0x2a39bcf82d41759c16e669483969bea5a15ed2de4941dc6bc3b25eb78cf8b464",         // invalid block number
    "very_wrong_number": "0x2a39bcf82d41759c16e669483969bea5a15ed2de4941dc6bc3b25eb78cf8b464" // same answer when invalid block number
  }
}

What is the expected behavior? It would be great if Graph node would validate the block inputs during a proof of indexing query, as it should prevent manual/accidental input errors

hopeyen avatar Feb 14 '23 18:02 hopeyen