blocknet icon indicating copy to clipboard operation
blocknet copied to clipboard

xrGetBlockCount returns inconsistent results

Open shrnkld opened this issue 4 years ago • 3 comments

Scenario: requesting xrGetBlockCount via core console or cli returns unreliable results.

Issue: There seems to be an upper limit on the queryCount parameter - possibly if the count is higher than the amount of nodes registered on the network, the query fails. Eg:

xrgetblockcount BLOCK 10
{
  “reply”: 2244915,
  “uuid”: “08ae7d53-49b7-498a-8d3d-9b3ece4d8a03”
}

xrgetblockcount BLOCK 100
{
  “code”: 1032,
  “error”: “Failed to find 100 service node(s) supporting BLOCK::xrGetBlockCount with config limits, found 0”,
  “uuid”: “1933a5d2-f023-42d1-b154-8ed469d1a407”
}

To do:

  • [x] investigate and document how the XRouter max queryCount is calculated
  • [x] #608

shrnkld avatar Nov 19 '21 14:11 shrnkld

queryCount has a limit of 50 hard coded. See #608 for follow up info

shrnkld avatar Nov 22 '21 14:11 shrnkld

This has the potential to put anyone off using XRouter to get answers to "Oracle" questions like this. Following the advice not to use XLite to trade SYS after the v4.3.0 nEVM activation I checked if the servicenode network was faring any better than the CC network. And the answer was a resounding "not really". Depending on how many/which node(s) your query goes to you might or might not get a correct answer, eg:

mark@x230:~/Dropbox/backups$ xrbc SYS
{
  "reply": 1317678,
  "uuid": "48e3b63d-a343-44ae-97ae-c9277462dd8a"
}
mark@x230:~/Dropbox/backups$ xrbc SYS 10
{
  "reply": 1318075,
  "uuid": "9f54bf30-7d00-42e1-adeb-14856590a210"
}
mark@x230:~/Dropbox/backups$ xrbc SYS 17
{
  "code": 1032,
  "error": "Failed to find 17 service node(s) supporting SYS::xrGetBlockCount with config limits, found 12",
  "uuid": "4115e45b-ddb3-4f66-839f-4ab1bdd42995"
}
mark@x230:~/Dropbox/backups$ xrbc SYS 12
{
  "reply": 1318076,
  "uuid": "a8dd09ea-60d2-488e-87d7-327e3f24249e"
}
mark@x230:~/Dropbox/backups$ xrep a8dd09ea-60d2-488e-87d7-327e3f24249e
{
  "allreplies": [
    {
      "reply": 1318076,
      "nodepubkey": "032a353e120f08c5e11ac0b5f2ffcd1947e35be35bc6c6bd7609264cbdb22c24df",
      "score": 288,
      "address": "BjLe5KiJbWyb57iGK7BcZ1XDktz5JgVSR3",
      "exr": false
    },
    {
      "reply": 1317678,
      "nodepubkey": "03ff2093e844e17b4bdb1b4d2840cac7dbb89bb4379fcb8e989ad33903faca348f",
      "score": 276,
      "address": "BrHGuUQcGaJrKGsyG3fVkDWWiTghK6ty7b",
      "exr": true
    },
    {
      "reply": 1317678,
      "nodepubkey": "033da080ee0cc8e8419afd82cf88674a7bae38fbdc9f0d584ba6a12d4d5d2c3e65",
      "score": 262,
      "address": "BYsnKNKPHGgFZqtta6HHZoD4xexNNV19sR",
      "exr": false
    },
    {
      "reply": 1318076,
      "nodepubkey": "03b59ac37046833efca76a1bbc687825660704a5936a4048e52084fdbe2f283c8f",
      "score": 19,
      "address": "BZjYp4p4qZqVqLiFouqBfUTB8vHJGJoWR4",
      "exr": true
    },
    {
      "reply": 1318076,
      "nodepubkey": "0276f5e0319b8446b99e82c5d6884cf3eede54aed76bbe3f6dabe065d83bff9037",
      "score": 261,
      "address": "BakFLuSW9g48FpQH3fmS7Vu2zJJUN7XwHG",
      "exr": false
    },
    {
      "reply": 1318076,
      "nodepubkey": "02f606694cc9f90683a00609233b205d0e97b5cd451e8583ef02f402b406b0365b",
      "score": 310,
      "address": "BbS8jHdrk6DwXnuj4BaHqocgeXT1Q9e9ix",
      "exr": true
    },
    {
      "reply": 1318076,
      "nodepubkey": "026073b884640b0bb956a690f6f891840317d2c6edf8e8f9439aa0cc81ffefb318",
      "score": 273,
      "address": "Brze9rNAJohXDWTvCHBHaDGQKHY3Fx3ubX",
      "exr": false
    },
    {
      "reply": 1318076,
      "nodepubkey": "02a5d0279e484a3df81acd611e1052d2e0797e796564ecbc25c7fe19f36e9985e5",
      "score": 297,
      "address": "BqNaZmLJe9wEGBHDNid9FvsgrG2x7Hbfex",
      "exr": true
    },
    {
      "reply": 1317678,
      "nodepubkey": "02dc8b82ecaa043e69cf8631c52607e93faeb4df9b68a3f1056d20a6291587bafa",
      "score": 276,
      "address": "BYvnGv3m8JCG5Fo4V3znSGt4xhjSoxExyM",
      "exr": true
    },
    {
      "reply": 1317678,
      "nodepubkey": "025ed0a51bd2e1550d872b23ce5e406c1326d0850a8dae2cd1cc0dc66ab43396d7",
      "score": 263,
      "address": "BfmFscc2726USK5EH6DW7iTsa6DvkGJzca",
      "exr": true
    },
    {
      "reply": 1318076,
      "nodepubkey": "03f3d063bcec800977dc2703d6c0593c6cb72ce5bcf87e1309a7b689265331b65e",
      "score": 265,
      "address": "BqdqETsCRbvpeuVhfN7S2JiC7NTk9gRWA6",
      "exr": false
    },
    {
      "reply": {
        "error": "Unable to verify if the service node is valid. Received bad signature on this request.",
        "code": 1036,
        "reply": "<html>\r\n<head><title>400 The plain HTTP request was sent to HTTPS port</title></head>\r\n<body>\r\n<center><h1>400 Bad Request</h1></center>\r\n<center>The plain HTTP request was sent to HTTPS port</center>\r\n<hr><center>cloudflare</center>\r\n</body>\r\n</html>\r\n"
      },
      "nodepubkey": "039d80ac813a7fc95a5b9dd285df99fbb9ceceb5aae25af7252b8f5ef78da97fe8",
      "score": -80,
      "address": "Bqw6bQg5tHW6QuiwvNM3xrnb4EHV8BdyCW",
      "exr": true
    }
  ],
  "mostcommon": 1318076,
  "mostcommoncount": 7,
  "uuid": "a8dd09ea-60d2-488e-87d7-327e3f24249e"
}
mark@x230:~/Dropbox/backups$ xrbc SYS 16
{
  "reply": 1318077,
  "uuid": "2614d52c-c507-496f-a181-f30a019e0fab"
}
mark@x230:~/Dropbox/backups$ xrep 2614d52c-c507-496f-a181-f30a019e0fab
{
  "allreplies": [
    {
      "reply": 1318077,
      "nodepubkey": "032a353e120f08c5e11ac0b5f2ffcd1947e35be35bc6c6bd7609264cbdb22c24df",
      "score": 304,
      "address": "BjLe5KiJbWyb57iGK7BcZ1XDktz5JgVSR3",
      "exr": false
    },
    {
      "reply": 1317678,
      "nodepubkey": "03845e9ab8f0fb77b92086ac3e9b97ce01c7c986d9d8fa26e843c78db5134e5d3e",
      "score": 17,
      "address": "BfQvWYgoQZpkgrKzSMWFxQN2Rh1Rv2XDQ9",
      "exr": false
    },
    {
      "reply": 1318077,
      "nodepubkey": "03f79d629c5c501aa87c71f885da8edfdbdaddf2cb502dc13be4519918101954c2",
      "score": 25,
      "address": "BdTremosuH7wHhJCiLF5TS7Envzw3nanKX",
      "exr": false
    },
    {
      "reply": 1317678,
      "nodepubkey": "03ff2093e844e17b4bdb1b4d2840cac7dbb89bb4379fcb8e989ad33903faca348f",
      "score": 271,
      "address": "BrHGuUQcGaJrKGsyG3fVkDWWiTghK6ty7b",
      "exr": true
    },
    {
      "reply": 1317678,
      "nodepubkey": "033da080ee0cc8e8419afd82cf88674a7bae38fbdc9f0d584ba6a12d4d5d2c3e65",
      "score": 257,
      "address": "BYsnKNKPHGgFZqtta6HHZoD4xexNNV19sR",
      "exr": false
    },
    {
      "reply": 1318077,
      "nodepubkey": "03b59ac37046833efca76a1bbc687825660704a5936a4048e52084fdbe2f283c8f",
      "score": 35,
      "address": "BZjYp4p4qZqVqLiFouqBfUTB8vHJGJoWR4",
      "exr": true
    },
    {
      "reply": 1318077,
      "nodepubkey": "0276f5e0319b8446b99e82c5d6884cf3eede54aed76bbe3f6dabe065d83bff9037",
      "score": 277,
      "address": "BakFLuSW9g48FpQH3fmS7Vu2zJJUN7XwHG",
      "exr": false
    },
    {
      "reply": 1318077,
      "nodepubkey": "02f606694cc9f90683a00609233b205d0e97b5cd451e8583ef02f402b406b0365b",
      "score": 326,
      "address": "BbS8jHdrk6DwXnuj4BaHqocgeXT1Q9e9ix",
      "exr": true
    },
    {
      "reply": 1004445,
      "nodepubkey": "023101ed69f01e4982111d7f4ad9424ffa55aef31ce89de5248698362984cf4469",
      "score": -10,
      "address": "BgRyxG2D1fxqYivgWQ76isPDnBCu4rvUJJ",
      "exr": false
    },
    {
      "reply": 1318077,
      "nodepubkey": "026073b884640b0bb956a690f6f891840317d2c6edf8e8f9439aa0cc81ffefb318",
      "score": 289,
      "address": "Brze9rNAJohXDWTvCHBHaDGQKHY3Fx3ubX",
      "exr": false
    },
    {
      "reply": 1318077,
      "nodepubkey": "02a5d0279e484a3df81acd611e1052d2e0797e796564ecbc25c7fe19f36e9985e5",
      "score": 313,
      "address": "BqNaZmLJe9wEGBHDNid9FvsgrG2x7Hbfex",
      "exr": true
    },
    {
      "reply": 1317678,
      "nodepubkey": "03ec8723f06bdee1220dec2a077b686caa56ae4ed2837354138a8eed90780b20e5",
      "score": -5,
      "address": "BfbjZhUCpiKSzrzgixfVbiSb3jx5JBgQDA",
      "exr": false
    },
    {
      "reply": 1317678,
      "nodepubkey": "02dc8b82ecaa043e69cf8631c52607e93faeb4df9b68a3f1056d20a6291587bafa",
      "score": 271,
      "address": "BYvnGv3m8JCG5Fo4V3znSGt4xhjSoxExyM",
      "exr": true
    },
    {
      "reply": 1317678,
      "nodepubkey": "025ed0a51bd2e1550d872b23ce5e406c1326d0850a8dae2cd1cc0dc66ab43396d7",
      "score": 258,
      "address": "BfmFscc2726USK5EH6DW7iTsa6DvkGJzca",
      "exr": true
    },
    {
      "reply": 1318077,
      "nodepubkey": "03f3d063bcec800977dc2703d6c0593c6cb72ce5bcf87e1309a7b689265331b65e",
      "score": 281,
      "address": "BqdqETsCRbvpeuVhfN7S2JiC7NTk9gRWA6",
      "exr": false
    },
    {
      "reply": {
        "error": "Unable to verify if the service node is valid. Received bad signature on this request.",
        "code": 1036,
        "reply": "<html>\r\n<head><title>400 The plain HTTP request was sent to HTTPS port</title></head>\r\n<body>\r\n<center><h1>400 Bad Request</h1></center>\r\n<center>The plain HTTP request was sent to HTTPS port</center>\r\n<hr><center>cloudflare</center>\r\n</body>\r\n</html>\r\n"
      },
      "nodepubkey": "039d80ac813a7fc95a5b9dd285df99fbb9ceceb5aae25af7252b8f5ef78da97fe8",
      "score": -85,
      "address": "Bqw6bQg5tHW6QuiwvNM3xrnb4EHV8BdyCW",
      "exr": true
    }
  ],
  "mostcommon": 1318077,
  "mostcommoncount": 8,
  "uuid": "2614d52c-c507-496f-a181-f30a019e0fab"
}

walkjivefly avatar Dec 07 '21 15:12 walkjivefly

At the time of the first query above the SYS explorer was reporting block height 1318075.

Takeaways from the above test:

  1. Asking for an answer from a single node may or may not get you the "right" answer.
  2. Asking for an answer from multiple nodes may or may not get you the "right" answer.
  3. Asking from a bigger set of nodes is no guarantee you're more likely to get the "right" answer.
  4. Servicenode operators need to do a much better job of keeping their wallets synced, and removing them from XBridge/XRouter configs when they're not synced.

walkjivefly avatar Dec 07 '21 16:12 walkjivefly