wallet: more accurate blockchain height approximation #10165
+12
−6
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue short description
restore_heightcan be set higher than actual block height on wallet creation, due to inaccurate approximationRelated issues:
Changes made:
get_approximate_blockchain_height()(src).approximate_rolled_back_blocks(src) and also apply it forMAINNET.Some more info
Note: negative values for
deviationmean the estimated height is higher than actual height.Current estimates (starting from v2 height, offset by
approximate_rolled_back_blocks, one month safety margin):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 forMAINNETand 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, withoutapproximate_rolled_back_blocks, one month safety margin):Historical deviations
With help of a python script (search for
NOTEto find adjustable parameters) I compared the historical deviations betweenactual - expectedblock height, starting fromfork_blocksrc until today in one month incrementsWith old rules (starting from v2 height, offset by
approximate_rolled_back_blocks, one month safety margin):With new rules (starting from latest height in
hardforks.cpp, with adjustedapproximate_rolled_back_blocks, one month safety margin):