-
Notifications
You must be signed in to change notification settings - Fork 216
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use rounded derived height sync param #2364
Conversation
Great! Thanks for the quick resolution @smk762 |
@smk762 I did installation from 0 (with removing old app data). But for some reason Asset list is not displaying: Logs file contains only one exception:
|
@smk762 Problem releated to issue in this PR: KomodoPlatform/coins#821 |
@@ -28,7 +28,7 @@ namespace atomic_dex::mm2 | |||
{ | |||
j["params"]["ticker"] = request.coin_name; | |||
j["params"]["activation_params"]["mode"]["rpc"] = "Light"; | |||
j["params"]["activation_params"]["mode"]["rpc_data"]["sync_params"]["date"] = request.sync_date; | |||
j["params"]["activation_params"]["mode"]["rpc_data"]["sync_params"]["height"] = request.sync_height; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
afaik, as soon as sync params are present, mm2 will start syncing from scratch from the specified date/height, mo matter what it's in the DB
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
only if height != db_height
see https://github.com/KomodoPlatform/komodo-defi-framework/pull/1922/files#diff-878c719c6e82f1f4290cc74719c8a7de8e3ef2d5927ebbee5925e3dd54655cfcR381-R382 and https://github.com/KomodoPlatform/komodo-defi-framework/pull/1922/files#diff-878c719c6e82f1f4290cc74719c8a7de8e3ef2d5927ebbee5925e3dd54655cfcR487
@borngraced can you please confirm?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes only if derived starting_height != to the minimum height in db
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can't follow the links to the code, it's not jumping to the specified line, so i will just trust you :-)
ok, so we rely now on some height calculation based on a 60s blocktime which can vary a lot on ARRR
does it mean there is still a chance that my app will start syncing from scratch if the calc is off eg because blocktime was 120s in the last 2 weeks? is there a way to avoid this 100%? it takes 2 days to sync from scratch and i want to avoid this at all costs, so i rather prefer to remove sync_params completely from my repo then to risk syncing from scratch
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, guess if i have the date set at 2 days and the DB is 2 years old, it should never happen... just need to think to reset the date back to 2 days ago after a complete resync from 2 years ago
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes right
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://github.com/KomodoPlatform/komodo-wallet-desktop/pull/2367 has been prepared for the next release (0.6.2) after current API dev branch is merged.
so we rely now on some height calculation based on a 60s blocktime
The calculated avg block time between the checkpoint block (19000000) and the current height was a little over 63 seconds. In the GUI side date to height calc, I've assumed a 65 sec avg blocktime (to avoid recent dates potentially returning a block_height > tip) calculated as an offset from the checkpoint block (middle out reduces the cumulative overage compared to edges in).
This calc will generally return a height for a date which errors on the side of being earlier than actual, which is better than later than actual, for example if user knows the date of a tx and syncs from there but the calc sets it ahead a day, the sync excludes the tx. If set earlier, it is sure to be included.
The real problem though that this PR aims to fix is the potential for the date to height calc to return a different value when run again later, due to the rate of block production between the first and second runs. This changed block height may force a rescan even if selected date remains unchanged, and the odds this will happen increases as the time between first and second run increases. By rounding the result to the nearest 1000, it is much less likely for this to occur, and in a large majority of cases, the returned height will be the same so that no resync is triggered and the sync will continue from the prior cache height.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we get reports that rounding to 1000 still results in cases of forced resync, we can change the rounding factor to a higher value, though a value of 1000 should be enough to overcome most periods of excessively high or low block production unless they are uncharacteristically extended before reverting back to the mean.
Test 1: Activation ARRR coin with default Activation date - 2 days in the past
UpdatingBlocksCache stage:
BuildingWalletDb stage:
RequestingWalletBalance stage:
After app restart ARRR coin activation takes about 1 minute. Activation started from RequestingWalletBalance stage:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved.
ARRR coin activation works. On app restart ARRR activation takes less 1 minute.
Percentage displayed correctly. 95% is max value that displayed.
This PR is a further improvement on Z coin activation. Previously we used the "date" sync param, which would be effectively changed in the API to a derived height based on the average block time.
As blocktime varies, this potentially resulted in the derived height not being a constant value, and in cases where it did not return the same height as calculated during a prior sync, could force a long resync.
The simplest mitigation for this was to use the height param in the RPC instead, derived by the GUI and rounding the height to the nearest 1000 so that the same date selection would be much more likely to return the same value as in the past.
To Test:
"requested":2448000
value in logs on lines like below:[14:55:02] [info] [mm2.service.cpp:1495] [2605136]: ARRR Activation Status: {"id":null,"mmrpc":"2.0","result":{"details":{"UpdatingBlocksCache":{"current_scanned_block":2521275,"first_sync_block":{"actual":2448000,"is_pre_sapling":false,"requested":2448000},"latest_block":2575728}},"status":"InProgress"}}
the
requested
value should be divisible by 1000.requested
.Note: This relies on updated data in
coins_config.json
, so please delete your local%appdata%/0.6.1
folder and the coins file used for your wallet before launch