Developers Forum for XinFin XDC Network

Paymahn Moghadasian
Paymahn Moghadasian

Posted on • Updated on

[WIP] Testnet RPC not reliable

I work at www.goldsky.com and we're trying to add XDC to our list of supported networks for subgraphs. We've successfully added mainnet. However, we're having trouble adding the XDC Testnet. It seems that the testnet RPC at https://earpc.apothem.network does not provide reliable RPC responses. Here's a log output that the Graph Node (the thing which powers subgraphs) spits out in a loop:

goldskyraw-indexer-0-graph-node-69c676fdc6-dg8k6 graph-node Oct 18 08:56:22.768 INFO receipt block mismatch, receipt_tx_hash: 0x03fe…bfd0, tx_hash: 0x03fe…bfd0, block_hash: 0xd5ed…d9a4, receipt_block_hash: 0x91e1…10d5, provider: xdc-testnet, component: EthereumPollingBlockIngestor
Enter fullscreen mode Exit fullscreen mode

Note that the receipt_block_hash and block_hash are not equivalent fetching fetching the listed transaction (whose receipt hash matches itself).

Discussion (8)

Collapse
gzliudan profile image
Daniel Liu • Edited on

Could you please share the below files?

  • docker-compose yaml file
  • more log messages
  • subgraph project

So I can reproduce your problem.

Collapse
paymahn_moghadasian_cf9d7 profile image
Paymahn Moghadasian Author

I don't have a docker compose setup to share since this is happening in production. This also isn't happening because of a specific subgraph but during initial network setup in the graph node.

Here are more logs: gist.github.com/paymog/33659ee46f0...

Here's how you can manually reproduce this:

  1. curl -X POST -H "Content-Type: application/json" -d '{"method": "eth_getBlockByHash", "params": ["0xd28bc799751815a0923d673d97dc8ca932e32c41e1d1f8ec08956106bd981018", false], "id": 1, "jsonrpc": "2.0"}' https://earpc.apothem.network which contains a single transaction: 0xc1b52110f52120b4faf9e8502d568fb6dc88e90b0acd9f48d0af443782b9f55b
  2. curl -X POST -H "Content-Type: application/json" -d '{"method": "eth_getTransactionReceipt", "params": ["0xc1b52110f52120b4faf9e8502d568fb6dc88e90b0acd9f48d0af443782b9f55b"], "id": 1, "jsonrpc": "2.0"}' https://earpc.apothem.network which apparently belongs to block 0x037d2d9f0e9e5c38ee9fb0c6721f5873cee7984bfe3bca2f91974daadcebbfd7

Note that the two block hashes, 0xd28bc799751815a0923d673d97dc8ca932e32c41e1d1f8ec08956106bd981018 and 0x037d2d9f0e9e5c38ee9fb0c6721f5873cee7984bfe3bca2f91974daadcebbfd7, differ and match the log statements which say

graph-node Oct 20 12:12:40.288 INFO receipt block mismatch, receipt_tx_hash: 0xc1b5…f55b, tx_hash: 0xc1b5…f55b, block_hash: 0xd28b…1018, receipt_block_hash: 0x037d…bfd7, provider: xdc-testnet, component: EthereumPollingBlockIngestor
Enter fullscreen mode Exit fullscreen mode
Collapse
gzliudan profile image
Daniel Liu • Edited on

In your case, both of blocks 0x354ce39 and 0x354ce45 contain the transaction hash 0xc1b52110f52120b4faf9e8502d568fb6dc88e90b0acd9f48d0af443782b9f55b. This is reported in github.com/XinFinOrg/XDPoSChain/pu.... Maybe this is a problem or bug. I will study your log messages later. Would you please share below files?

  • graph-node configuration
  • subgraph source codes
curl -s -X POST -H "Content-Type: application/json" https://earpc.apothem.network -d '
{
  "jsonrpc": "2.0",
  "id": 4003,
  "method": "eth_getBlockByNumber",
  "params": [
    "0x354ce39",
    true
  ]
}' | jq

curl -s -X POST -H "Content-Type: application/json" https://earpc.apothem.network -d '
{
  "jsonrpc": "2.0",
  "id": 4004,
  "method": "eth_getBlockByNumber",
  "params": [
    "0x354ce45",
    true
  ]
}' | jq
Enter fullscreen mode Exit fullscreen mode
Collapse
gzliudan profile image
Daniel Liu

Please set ETHEREUM_REORG_THRESHOLD to 1. You can refer to github.com/XinFinOrg/XDC-Graph-Nod....

Thread Thread
paymahn_moghadasian_cf9d7 profile image
Paymahn Moghadasian Author

That seems like a bandaid solution that will end up with incorrect data long term. From the graph node docs

ETHEREUM_REORG_THRESHOLD: Maximum expected reorg size, if a larger reorg happens, subgraphs might process inconsistent data. Defaults to 250.

Note that we're not seeing this against the XDC mainnet, only the testnet. Are the RPC calls I provided above expected and correct behavior?

Thread Thread
gzliudan profile image
Daniel Liu

I'm not sure whether the mainnet has this issue. This issue will affect some software. But It's a very big project to solve it.

Thread Thread
gzliudan profile image
Daniel Liu • Edited on

I'll write a script to check the duplicate transaction hashes on mainnet when I'm free.

Thread Thread
gzliudan profile image
Daniel Liu

The mainnet has same transaction hash bug also, such as both of blocks 39185599 and 39185611 has transaction hash 0x000f94c5677e68504bc8daabdb051d3f1e51fd626b59d9533f5fc55f656f6fd1. There is a fix already: github.com/XinFinOrg/XDPoSChain/pu.... Please wait for some time.