helium / blockchain-http

An http API for the helium blockchain database
https://helium.com
Apache License 2.0
47 stars 18 forks source link

Wonky cursor when retrieving roles #439

Open WubbleWobble opened 2 years ago

WubbleWobble commented 2 years ago

Summary

When I ask the API to show me add_gateway_v1 transactions on my account via the /accounts/<acct>/roles endpoint, the min_block that gets encoded in the cursor is a block that happened after the add_gateway_v1 transaction for my miner, and hence the data is never returned.

Details

  1. I could see via the roles/count endpoint that there was an "add_gateway_v1" transaction for my address. https://api.helium.io/v1/accounts/13odoQc9cEgFogTeuP7PKFzyg9HPoc6s258TUowUSEKnwW1WM6X/roles/count

  2. I tried to retrieve it, but after following the cursor for many hops, I ended up being given precisely zero data results. https://api.helium.io/v1/accounts/13odoQc9cEgFogTeuP7PKFzyg9HPoc6s258TUowUSEKnwW1WM6X/roles?min_time=1970-01-01T00:00&filter_types=add_gateway_v1

  3. I eventually tried decoding the cursor as it looked very base64y, and got shown this:

    {
    "types": ["add_gateway_v1"],
    "min_block": 1319093,
    "max_block": 1334881,
    "block": 1334800,
    "anchor_block": 1334800
    }
  4. Looking the min_block up on the explorer, I could see that this block corresponds to a date/time of 20th April 2022 2:55am: https://explorer.helium.com/blocks/1319093

  5. Looking at the miner on hotspotty, I could see that it was added to the blockchain on 19th April 2022: https://app.hotspotty.net/hotspots/112113XKkUqMEMaLLfrjkdLpXSsSvWZJR4eiC2DdNx9h9tihiGxK/info

  6. Manually manipulating the cursor to set min_block to an earlier block then allowed me to retrieve the transaction information from the API (I set it to 1315093 which is a few days earlier):

    {
    "type": "add_gateway_v1"
    "time": 1650371887
    "role": "owner"
    "height": 1318324
    "hash": "RhN_98AYf-bpoK8MZFnTPt-83Nr9ajrk6zxveYM0kDI"
    }

So essentially, the problem seems to be that the min_block in the cursor doesn't seem to be set low enough to allow me to retrieve all of the transactions (without manual intervention, that is :)