graphprotocol / graphprotocol/graph-node
POI is generated for invalid block number and hash
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 3.2k
- Forks
- 1.1k
- Avg merge
- 4d 1h
- Merged PRs (30d)
- 1
Description
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the admin API's proofOfIndexing query and compare its block inputs with the blockHashFromNumber and indexingStatuses results shown in the report. Reproduce the valid and invalid hash and number combinations from the example. Done means invalid block inputs return an error instead of generating different POIs.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- graphql, rust
- Domain
- api, blockchain
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100