pokt-foundation / portal-api

The Portal API Gateway is a single endpoint that offers access to the full range of supported blockchains through one URL.
https://pokt.network
MIT License
11 stars 8 forks source link

Add "archival check" for chains that must be served by archival nodes #74

Open nymd opened 3 years ago

nymd commented 3 years ago

Currently any node can join an "archival" chain ID and serve bad data due to their database being pruned.

Some calls, such as eth_getStorageAt, will return properly formatted results that do not register as errors when the node has pruning turned on. This results in bad data getting out to the end-user if a node-runner is not serving an archival chain ID with an archival node.

In addition to the sync check, the portal API should perform an "archival check" for chain IDs that are marked as such.

For EVM-based chains, the method of calling eth_getBalance at block height 0x0 will show the pruning state of the node.

Querying OpenEthereum with pruning turned on for archival data:

curl -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0", "method": "eth_getBalance", "params": ["0x0000000000000000000000000000000000000000", "0x2710"], "id": 1}' http://localhost:8555
{"jsonrpc":"2.0","error":{"code":-32000,"message":"This request is not supported because your node is running with state pruning. Run with --pruning=archive."},"id":1}

Querying BSC with pruning turned on:

curl -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0", "method": "eth_getBalance", "params": ["0x0000000000000000000000000000000000000000", "0x2710"], "id": 1}' localhost:8545
{"jsonrpc":"2.0","id":1,"error":{"code":-32000,"message":"missing trie node dafa7081c603c29487e3a64a0da0a569485cdef17fe13867d53be92f26ef192e (path )"}}

Implementation should follow the same method as services/sync-check but the record that a node is improperly configured should last 24 hours. After 24 hours that record should expire and a node can be re-checked.

DragonDmoney commented 2 years ago

Any progress? This issue is greatly affecting the quality of service.