Skip to content

validation: fix verification progress during IBD.

Description

Motivation: Currently verificationprogress attribute of getblockchaininfo returns incorrect value(1.92338932716318e-06) during the headers synchronization phase of IBD. This PR fixes this by returning 0 instead of ...e-0x.

getblockchaininfo on master
$ ./src/bitcoin-cli -signet getblockchaininfo                                                                                                                                                               
{
  "chain": "signet",
  "blocks": 0,
  "headers": 32410,
  "bestblockhash": "00000008819873e925422c1ff0f99f7cc9bbb232af63a077a480a3633bee1ef6",
  "difficulty": 0.001126515290698186,
  "time": 1598918400,
  "mediantime": 1598918400,
  "verificationprogress": 1.921578597095376e-06,
  "initialblockdownload": true,
  "chainwork": "000000000000000000000000000000000000000000000000000000000049d414",
  "size_on_disk": 17095548,
  "pruned": false,
  "softforks": {
    "bip34": {
      "type": "buried",
      "active": true,
      "height": 1
    },
    "bip66": {
      "type": "buried",
      "active": true,
      "height": 1
    },
    "bip65": {
      "type": "buried",
      "active": true,
      "height": 1
    },
    "csv": {
      "type": "buried",
      "active": true,
      "height": 1
    },
    "segwit": {
      "type": "buried",
      "active": true,
      "height": 1
    },
    "taproot": {
      "type": "bip9",
      "bip9": {
        "status": "active",
        "start_time": -1,
        "timeout": 9223372036854775807,
        "since": 0,
        "min_activation_height": 0
      },
      "height": 0,
      "active": true
    }
  },
  "warnings": "This is a pre-release test build - use at your own risk - do not use for mining or merchant applications"
}
getblockchaininfo in this PR
$ ./src/bitcoin-cli -signet getblockchaininfo                                                                                                                                                               
{
  "chain": "signet",
  "blocks": 0,
  "headers": 21940,
  "bestblockhash": "00000008819873e925422c1ff0f99f7cc9bbb232af63a077a480a3633bee1ef6",
  "difficulty": 0.001126515290698186,
  "time": 1598918400,
  "mediantime": 1598918400,
  "verificationprogress": 0,
  "initialblockdownload": true,
  "chainwork": "000000000000000000000000000000000000000000000000000000000049d414",
  "size_on_disk": 8546460,
  "pruned": false,
  "softforks": {
    "bip34": {
      "type": "buried",
      "active": true,
      "height": 1
    },
    "bip66": {
      "type": "buried",
      "active": true,
      "height": 1
    },
    "bip65": {
      "type": "buried",
      "active": true,
      "height": 1
    },
    "csv": {
      "type": "buried",
      "active": true,
      "height": 1
    },
    "segwit": {
      "type": "buried",
      "active": true,
      "height": 1
    },
    "taproot": {
      "type": "bip9",
      "bip9": {
        "status": "active",
        "start_time": -1,
        "timeout": 9223372036854775807,
        "since": 0,
        "min_activation_height": 0
      },
      "height": 0,
      "active": true
    }
  },
  "warnings": "This is a pre-release test build - use at your own risk - do not use for mining or merchant applications"
}

Conext:

Changes:

  • This PR fixes the issue by returning 0.0 in GuessVerificationProgress option when nHeight == 0

Reviewing

Testing:

You can test this by running bitconid with -reindex option and immediately running getblockchainfo afterward.

$ ./src/bitcoind --daemon -signet -reindex
$ ./src/bitcoin-cli -signet getblockchaininfo

Merge request reports

Loading