KomodoPlatform / komodo

Komodo
https://komodoplatform.com/en/
Other
118 stars 99 forks source link

valuePools (sprout, sapling) monitoring / calculation works incorrectly #604

Open DeckerSU opened 1 year ago

DeckerSU commented 1 year ago

Ever since we started using our own versioning system, which is similar to 0.7.x.y, instead of the default ZCash versioning 1.x.y.z (meaning our release has lower versions than the initial), it appears that we have encountered issues with monitoring the valuepools.

define(_CLIENT_VERSION_MAJOR, 0)
define(_CLIENT_VERSION_MINOR, 8)
define(_CLIENT_VERSION_REVISION, 1)
define(_CLIENT_VERSION_BUILD, 1)
...
static const int CLIENT_VERSION =
                           1000000 * CLIENT_VERSION_MAJOR
                         +   10000 * CLIENT_VERSION_MINOR
                         +     100 * CLIENT_VERSION_REVISION
                         +       1 * CLIENT_VERSION_BUILD;

For example, version 0.8.1.1 resulting in nVersion == 80101. And here: https://github.com/KomodoPlatform/komodo/blob/d9144d0f44f3a4b6d103aaff3c13264387de7702/src/chain.h#L446-L456 We lost read/write of nSproutValue and nSaplingValue for the CDiskBlockIndex, as the values of SPROUT_VALUE_VERSION and SAPLING_VALUE_VERSION is higher than current actual version: https://github.com/KomodoPlatform/komodo/blob/d9144d0f44f3a4b6d103aaff3c13264387de7702/src/chain.h#L40-L41 As a result this code for updating nChainSproutValue and nChainSaplingValue don't work, because pindex->nSproutValue and pindex->nSaplingValue are boost::none (no read from index): https://github.com/KomodoPlatform/komodo/blob/d9144d0f44f3a4b6d103aaff3c13264387de7702/src/main.cpp#L6041-L6094 As a result getblockchaininfo RPC output looks like this:

  "valuePools": [
    {
      "id": "sprout",
      "monitored": false
    },
    {
      "id": "sapling",
      "monitored": true,
      "chainValue": 0.00000000,
      "chainValueZat": 0
    }
  ],

The offer is to change SPROUT_VALUE_VERSION and SAPLING_VALUE_VERSION to 80102 (0.8.1-beta3) in KomodoOcean and komodod simultaneously, otherwise the bootstraps between original komodod and KomodoOcean will be incompatible (of course, it assumes publishing releases 80102, 0.8.1-beta3)

Since monitoring value pools is not a critical issue, we can delay addressing it. However, if we decide to make changes now, both daemons in KomodoOcean and this repository should have the same version and the same read/write activation constants.

DeckerSU commented 1 year ago

Btw, jfyi, currently the value of pools in KMD chain are following:

[
  {
    "id": "sprout",
    "monitored": true,
    "chainValue": 84948.93692198,
    "chainValueZat": 8494893692198
  },
  {
    "id": "sapling",
    "monitored": true,
    "chainValue": 3.07618319,
    "chainValueZat": 307618319
  }
]

Since the KOMODO_SAPLING_DEADLINE on February 15, 2019, we have disabled the ability to create new sprout addresses and perform transfers to or from them. Additionally, all shielded transactions have been disabled on the public chain, as KMD itself is a public chain. These values should remain constant, allowing us to use them for verification purposes and more.