Skip to content

Conversation

@SNeedlewoods
Copy link
Contributor

Issue short description

restore_height can be set higher than actual block height on wallet creation, due to inaccurate approximation

Related issues:


Changes made:

  • Use latest hard fork block (src) for get_approximate_blockchain_height() (src).
  • Update approximate_rolled_back_blocks (src) and also apply it for MAINNET.

Some more info

Note: negative values for deviation mean the estimated height is higher than actual height.

Current estimates (starting from v2 height, offset by approximate_rolled_back_blocks, one month safety margin):

nettype estimated actual deviation
mainnet 3498067 3517127 19060 (~ 26 days)
stagenet 1942002 1964485 22483 (~ 31 days)
testnet 2857971 2850082 -7889 (~-10 days)

Note: I included the following table just to show how bad the estimates would be without applying approximate_rolled_back_blocks. I'd argue it makes sense to apply it for MAINNET and to keep an eye on it when the hard forks get updated in the future. For the actual difference that this PR makes see Historical deviations below.

Updated estimates (starting from latest height in hardforks.cpp, without approximate_rolled_back_blocks, one month safety margin):

nettype estimated actual deviation
mainnet 3532426 3520682 -11744 (~-16 days)
stagenet 1994540 1967959 -26581 (~-36 days)
testnet 2858138 2853760 -4378 (~ -6 days)

Historical deviations

With help of a python script (search for NOTE to find adjustable parameters) I compared the historical deviations between actual - expected block height, starting from fork_block src until today in one month increments

With old rules (starting from v2 height, offset by approximate_rolled_back_blocks, one month safety margin):

nettype      min blocks days  max blocks days  avg blocks days
    mainnet      49152  ~ 68      52224  ~ 72      50530  ~ 70
   stagenet      21504  ~ 29      79456  ~110      47401  ~ 65
    testnet      -7268  ~-11     363520  ~504      89514  ~124

With new rules (starting from latest height in hardforks.cpp, with adjusted approximate_rolled_back_blocks, one month safety margin):

nettype      min blocks days  max blocks days  avg blocks days
   mainnet       22016  ~ 30      23040  ~ 32      22440  ~ 31
  stagenet       22272  ~ 30      44032  ~ 61      33261  ~ 46
   testnet       22528  ~ 31      48128  ~ 66      37644  ~ 52

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants