maticnetwork / heimdall

Validator node for Polygon PoS
https://polygon.technology/
GNU General Public License v3.0
272 stars 181 forks source link

Return checkpoint IDs in `checkpoints/list` #1183

Closed shohamc1 closed 1 month ago

shohamc1 commented 2 months ago

Description

Return checkpoint IDs in checkpoints/list similar to checkpoint/{number}. In Erigon at the moment, we have to infer the checkpoint ID by checking its index in a sorted list of checkpoints. Returning the checkpoint ID will let us rely on Heimdall's IDs and reduce the chance of any discrepancies.

Changes

Checklist

Cross repository changes

Testing

Manual tests

curl -s http://localhost:1317/checkpoints/list\?page\=1\&limit\=5 | jq
{
  "height": "4449411",
  "result": [
    {
      "id": 1,
      "proposer": "0x6ab3d36c46ecfb9b9c0bd51cb1c3da5a2c81cea6",
      "start_block": 0,
      "end_block": 114,
      "root_hash": "0x767b9ed2c10b2aaf7d39df9a1142b9de3a4e246db5c28fe2697ed2e92cf4a061",
      "bor_chain_id": "80002",
      "timestamp": 1700396194
    },
    {
      "id": 10,
      "proposer": "0x6ab3d36c46ecfb9b9c0bd51cb1c3da5a2c81cea6",
      "start_block": 4979,
      "end_block": 5746,
      "root_hash": "0x3d1715ce689ac4d27683efd775198b8369d0f625e051562b8727e6056c6c33cb",
      "bor_chain_id": "80002",
      "timestamp": 1700408441
    },
    {
      "id": 100,
      "proposer": "0x6ab3d36c46ecfb9b9c0bd51cb1c3da5a2c81cea6",
      "start_block": 94579,
      "end_block": 95346,
      "root_hash": "0x7c85b133d23ef1f504c154dd0e1b5940829bf2b4070dc99c54037c0d84e87b3a",
      "bor_chain_id": "80002",
      "timestamp": 1700598942
    },
    {
      "id": 1000,
      "proposer": "0x6ab3d36c46ecfb9b9c0bd51cb1c3da5a2c81cea6",
      "start_block": 988531,
      "end_block": 989554,
      "root_hash": "0x272b4e4593d5fb4f4784b19ae010d930470b26db5b2907f15af53c7463236fe3",
      "bor_chain_id": "80002",
      "timestamp": 1704308393
    },
    {
      "id": 1001,
      "proposer": "0x6ab3d36c46ecfb9b9c0bd51cb1c3da5a2c81cea6",
      "start_block": 989555,
      "end_block": 990578,
      "root_hash": "0x3d2c446fd7cd45ed941738d62f45d006c5b10674ba784e471e38974e28e49885",
      "bor_chain_id": "80002",
      "timestamp": 1704309293
    }
  ]
}

The checkpoints were matched to the ones returned by checkpoint/{number}.

for i in 1 10 100 1000 1001; do
  curl -s http://localhost:1317/checkpoints/$i | jq
done
{
  "height": "4449440",
  "result": {
    "id": 1,
    "proposer": "0x6ab3d36c46ecfb9b9c0bd51cb1c3da5a2c81cea6",
    "start_block": 0,
    "end_block": 114,
    "root_hash": "0x767b9ed2c10b2aaf7d39df9a1142b9de3a4e246db5c28fe2697ed2e92cf4a061",
    "bor_chain_id": "80002",
    "timestamp": 1700396194
  }
}
{
  "height": "4449440",
  "result": {
    "id": 10,
    "proposer": "0x6ab3d36c46ecfb9b9c0bd51cb1c3da5a2c81cea6",
    "start_block": 4979,
    "end_block": 5746,
    "root_hash": "0x3d1715ce689ac4d27683efd775198b8369d0f625e051562b8727e6056c6c33cb",
    "bor_chain_id": "80002",
    "timestamp": 1700408441
  }
}
{
  "height": "4449440",
  "result": {
    "id": 100,
    "proposer": "0x6ab3d36c46ecfb9b9c0bd51cb1c3da5a2c81cea6",
    "start_block": 94579,
    "end_block": 95346,
    "root_hash": "0x7c85b133d23ef1f504c154dd0e1b5940829bf2b4070dc99c54037c0d84e87b3a",
    "bor_chain_id": "80002",
    "timestamp": 1700598942
  }
}
{
  "height": "4449440",
  "result": {
    "id": 1000,
    "proposer": "0x6ab3d36c46ecfb9b9c0bd51cb1c3da5a2c81cea6",
    "start_block": 988531,
    "end_block": 989554,
    "root_hash": "0x272b4e4593d5fb4f4784b19ae010d930470b26db5b2907f15af53c7463236fe3",
    "bor_chain_id": "80002",
    "timestamp": 1704308393
  }
}
{
  "height": "4449440",
  "result": {
    "id": 1001,
    "proposer": "0x6ab3d36c46ecfb9b9c0bd51cb1c3da5a2c81cea6",
    "start_block": 989555,
    "end_block": 990578,
    "root_hash": "0x3d2c446fd7cd45ed941738d62f45d006c5b10674ba784e471e38974e28e49885",
    "bor_chain_id": "80002",
    "timestamp": 1704309293
  }
}