Search code examples
nearprotocolnearprotocol-validator

Missing blocks in Near Mainnet


I see there are few blocks missing in Near when I try to query through the archival node. Even I am unable to find them in the explorer as well. Is there any particular reason that the blocks are missing.

curl --location 'https://archival-rpc.mainnet.near.org' \
--header 'Content-Type: application/json' \
--data '{
  "jsonrpc": "2.0",
  "id": "dontcare",
  "method": "block",
  "params": {
    "block_id": 9820234
  }
}'

Response:

{
    "jsonrpc": "2.0",
    "error": {
        "name": "HANDLER_ERROR",
        "cause": {
            "info": {},
            "name": "UNKNOWN_BLOCK"
        },
        "code": -32000,
        "message": "Server error",
        "data": "DB Not Found Error: BLOCK HEIGHT: 9820234 \n Cause: Unknown"
    },
    "id": "dontcare"
}

Solution

  • These blocks were skipped, which simply means the assigned block producer was unable to produce it in time. This is normal behavior of the chain, as described in the consenus chapter of the nomicon. https://nomicon.io/ChainSpec/Consensus

    Each block has an integer height h(B). It is guaranteed that block heights are monotonic (that is, for any block B≠G, h⁡(B)>h⁡(prev⁡(B))), but they need not be consecutive.

    You can verify that this particular block was skipped by querying blocks 9820233 and 9820235 and comparing hash of 9820233 with prev_hash of 9820235.

    curl --location 'https://archival-rpc.mainnet.near.org' --header 'Content-Type: application/json' --data '{
      "jsonrpc": "2.0",
      "id": "dontcare",
      "method": "block",
      "params": {
        "block_id": 9820233
      }
    }' | jq '.result.header | {hash, prev_hash}'
    

    gives

    {
      "hash": "6bJN8kR3KUgQ4NziFn5rZYzsQBRH7b7tFJFJKbSkHVK",
      "prev_hash": "HfAFAQWaHnViBZuTv7PmgWTkK44Xexm2a52RADt2vuUm"
    }
    

    and

    curl --location 'https://archival-rpc.mainnet.near.org' --header 'Content-Type: application/json' --data '{
      "jsonrpc": "2.0",
      "id": "dontcare",
      "method": "block",
      "params": {
        "block_id": 9820235
      }
    }' | jq '.result.header | {hash, prev_hash}'
    

    gives

    {
      "hash": "DThcwVCrCn5C54uA42jLKMffZbNK1bF3d56YVSFY1Tuv",
      "prev_hash": "6bJN8kR3KUgQ4NziFn5rZYzsQBRH7b7tFJFJKbSkHVK"
    }
    

    You can see that they are both "6bJN8kR3KUgQ4NziFn5rZYzsQBRH7b7tFJFJKbSkHVK", therefore no block exists between the two.