DefiantLabs / cosmos-upgrades

a tool to search for scheduled cosmos upgrades
MIT License
4 stars 2 forks source link

Feat/plan info in response and semantic version GitHub tag checking #19

Closed pharr117 closed 1 year ago

pharr117 commented 1 year ago

Plan Info in Response

This PR adds the plan info object into the response.

When the "source" is current_upgrade_plan, we include the parsed upgrade plan pulled from the plan endpoint:

{
    "type": "mainnet",
    "network": "cosmoshub",
    "rpc_server": "https://cosmos-rpc.quickapi.com:443",
    "rest_server": "https://cosmoshub-api.lavenderfive.com:443",
    "latest_block_height": 16947875,
    "upgrade_found": true,
    "upgrade_name": "v12",
    "source": "current_upgrade_plan",
    "upgrade_block_height": 16985500,
    "estimated_upgrade_time": "2023-09-13T12:08:55.648530",
    "upgrade_plan": {
      "height": "16985500",
      "binaries": {
        "darwin/amd64": "https://github.com/cosmos/gaia/releases/download/v12.0.0/gaiad-v12.0.0-darwin-amd64?checksum=sha256:1b76a7b2ee9bd739cd28de6e380248f276c678d8f9cab1fc2fe17fce07389693",
        "darwin/arm64": "https://github.com/cosmos/gaia/releases/download/v12.0.0/gaiad-v12.0.0-darwin-arm64?checksum=sha256:20e81d813f942ed3114c6953016b9e24f0946b08e34f0da9c13bcb7276719130",
        "linux/amd64": "https://github.com/cosmos/gaia/releases/download/v12.0.0/gaiad-v12.0.0-linux-amd64?checksum=sha256:d67e91bda37c94f2efacba0f97bcbdb8931e9dbc457d1ce3f1e60a71d1b1b7dd",
        "linux/arm64": "https://github.com/cosmos/gaia/releases/download/v12.0.0/gaiad-v12.0.0-linux-arm64?checksum=sha256:aee279a6aedf8e83e59487c2006e72e496f73c36a882c44b3cc20969c3d237fb",
        "windows/amd64": "https://github.com/cosmos/gaia/releases/download/v12.0.0/gaiad-v12.0.0-windows-amd64.exe?checksum=sha256:7d970cd3f138b5ce8fe78a8209a5907fcfec6fb717434244010381cdd6b4cd32",
        "windows/arm64": "https://github.com/cosmos/gaia/releases/download/v12.0.0/gaiad-v12.0.0-windows-arm64.exe?checksum=sha256:b54c9c7e1c7bb36fc78cac294d86f8836e2dc02d747abc84d68062615a0512df"
      },
      "name": "v12",
      "upgraded_client_state": null
    },
    "version": "v12.0.0",
    "error": null
  }

Network Repo Tags Checking for Version

This PR adds the simple semantic-version Python package for parsing semantic versions.

This package is used in the following way:

  1. Use the codebase URL from the chain registry to pull down the current repo tags. These are cached per-repo url for 600 seconds to prevent external API throttling.
  2. Get the possible version strings from the endpoints
  3. Pass these to a semantic version checker that:
    • Finds possible semver matches between the parsed data and the network repo tags
    • Use the highest semver found in the matches

This fixes a known issue in the secret network where they are including other repo version tags in the plan description that was making the version be incorrect.

Secret now looks like this:

{
    "type": "mainnet",
    "network": "secretnetwork",
    "rpc_server": "https://secretnetwork-rpc.lavenderfive.com:443",
    "rest_server": "https://secretnetwork-api.highstakes.ch:1317/",
    "latest_block_height": 10589028,
    "upgrade_found": true,
    "upgrade_name": "v1.11",
    "source": "active_upgrade_proposals",
    "upgrade_block_height": 10615300,
    "estimated_upgrade_time": "2023-09-12T14:05:53.051747",
    "upgrade_plan": null,
    "version": "v1.11.0",
    "error": null
  }

Closes #18