Skip to content
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

multi: refactor sync status #2895

Merged
merged 3 commits into from
Aug 5, 2024
Merged

multi: refactor sync status #2895

merged 3 commits into from
Aug 5, 2024

Conversation

buck54321
Copy link
Member

@buck54321 buck54321 commented Jul 30, 2024

Use a more detailed structure for sync status. Add a sync 
notification to replace wallet state notifications where only 
the sync status has changed. Lower default account and 
address gap limits for Decred and make address gap limit 
configurable. Add information about address and tx syncing, 
for after headers and filters have synced.

Our synchronization display has always been a little funky, and it still will be after this PR, but less so. For full-node RPC wallets, we show block synchronization, which is fine. For SPV wallets, we show header synchronization, but SPV wallets also have to synchronize filters and then scan for addresses and then scan again for transactions. We've always handled this by just showing 99.9% if we have our headers synced but haven't finished all the other stuff. The other stuff took substantial amounts of time though, so users were just staring at the 99.9% and probably thinking something is wrong. I've heard lots of feedback about the ux around this.

For Decred, part of the reason that post-header synchronization was taking so long is because we always start with a seed so we always get a full scan. We set our account gap limit to 10, same as dcrwallet default, but our address gap limit is 100 where dcrwallet's default is 20. I think we set this high because of concerns about the way we generate redemption addresses, but we have a wrapping gap-policy, so as long as we can set the address gap limit for initialization and rescan, we can restore wallets properly. We also only use 3 accounts max in our SPV wallets, so an account gap limit of 10 is not needed. I've lowered the account gap limit to 3 and the address gap limit to 20, and added a configuration option for the address gap limit. This reduces the time spent scanning for addresses by at least 80%.

I don't think there's currently a way to track the actual filter synchronization, but luckily it is done in parallel with headers so there is really very little lag there. I also can't track the address scan. But I can track the transaction scan portion using the RescanPoint method provided by dcrwallet. So I've updated the UI to show the header download progress separately from the transaction scan progress, and for the address scan that preceeds the transaction scan, I just show a spinner and a message. On my system, that message is only displayed for about 1 minute now.

Initial header sync
image

Address discovery
image

Transaction sync
image

Use a more details structure for sync status. Add a sync
notification to replace wallet state notifications where only
the sync status has changed. Lower default account and address
gap limits for Decred and make address gap limit configurable.
Add information about address and tx syncing, for after headers
and filters have synced.
@buck54321
Copy link
Member Author

"Tx sync" may be confusing. Maybe something like "wallet scan" or "wallet sync"? I don't know.

@davecgh
Copy link
Member

davecgh commented Jul 31, 2024

"Tx sync" may be confusing. Maybe something like "wallet scan" or "wallet sync"? I don't know.

Balance Discovery?

Copy link
Contributor

@martonp martonp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DCR syncing super fast. LTC and BTC did not finish after almost 2 hours, then when I try to shut down, it's stuck unloading for a long time. Also, there are these "Reporting a block found in polling that the wallet apparently never reported" warnings:

2024-08-01 16:14:37.064 [WRN] CORE[btc]: Reporting a block found in polling that the wallet apparently never reported: 697711 00000000000000000009aa8f7a2f3e0eac287a82b73d422bdb919723e9cd8ce3. If you see this message repeatedly, it may indicate an issue with the wallet.
2024-08-01 16:14:39.742 [DBG] CORE[dcr]: Retrieving fee rate from external fee oracle for 2 target blocks
2024-08-01 16:17:43.072 [WRN] CORE[btc]: Reporting a block found in polling that the wallet apparently never reported: 699711 00000000000000000005c8c220d1c756cf3b9386475a954056d4b583aeedd90f. If you see this message repeatedly, it may indicate an issue with the wallet.
2024-08-01 16:19:41.022 [DBG] CORE[dcr]: Retrieving fee rate from external fee oracle for 2 target blocks
2024-08-01 16:20:40.067 [WRN] CORE[btc]: Reporting a block found in polling that the wallet apparently never reported: 701711 00000000000000000009b927aa5645b637a875e46d1352421de3eb72caa358b9. If you see this message repeatedly, it may indicate an issue with the wallet.
2024-08-01 16:24:10.069 [WRN] CORE[btc]: Reporting a block found in polling that the wallet apparently never reported: 703711 00000000000000000004fed3943274f18ac3a101e81e04620764c57495b7666a. If you see this message repeatedly, it may indicate an issue with the wallet.
2024-08-01 16:24:42.391 [DBG] CORE[dcr]: Retrieving fee rate from external fee oracle for 2 target blocks
2024-08-01 16:27:50.071 [WRN] CORE[btc]: Reporting a block found in polling that the wallet apparently never reported: 705711 0000000000000000000d0873424e7b39e1859da9612ee474ccd1ccbf7fc0e55f. If you see this message repeatedly, it may indicate an issue with the wallet.
2024-08-01 16:29:43.705 [DBG] CORE[dcr]: Retrieving fee rate from external fee oracle for 2 target blocks
2024-08-01 16:31:15.073 [WRN] CORE[btc]: Reporting a block found in polling that the wallet apparently never reported: 707711 000000000000000000026b16849fc863b1dcee1628e09b71124311ad7d3a070e. If you see this message repeatedly, it may indicate an issue with the wallet.
2024-08-01 16:34:44.957 [DBG] CORE[dcr]: Retrieving fee rate from external fee oracle for 2 target blocks
2024-08-01 16:34:49.075 [WRN] CORE[btc]: Reporting a block found in polling that the wallet apparently never reported: 709711 0000000000000000000964042210e7408a6f62d529d7d0cde90b73da7e77014b. If you see this message repeatedly, it may indicate an issue with the wallet.
2024-08-01 16:37:53.074 [WRN] CORE[btc]: Reporting a block found in polling that the wallet apparently never reported: 711711 00000000000000000000621805c695b16324c5136e47aa7ef4b940eda397354e. If you see this message repeatedly, it may indicate an issue with the wallet.
2024-08-01 16:39:46.076 [DBG] CORE[dcr]: Retrieving fee rate from external fee oracle for 2 target blocks
2024-08-01 16:40:59.076 [WRN] CORE[btc]: Reporting a block found in polling that the wallet apparently never reported: 713711 0000000000000000000630129dabf79db93e6174856ac6499aae05f3a57acba2. If you see this message repeatedly, it may indicate an issue with the wallet.
2024-08-01 16:44:12.077 [WRN] CORE[btc]: Reporting a block found in polling that the wallet apparently never reported: 715711 0000000000000000000630c9336d4d19d9b4fe3e4a23cffd8e4236ca0621af8a. If you see this message repeatedly, it may indicate an issue with the wallet.
2024-08-01 16:44:47.406 [DBG] CORE[dcr]: Retrieving fee rate from external fee oracle for 2 target blocks
2024-08-01 16:47:14.909 [WRN] CORE[ltc]: Query(3713) from peer 204.195.168.116:9333 failed, rescheduling: did not get response before timeout
2024-08-01 16:47:30.933 [WRN] CORE[ltc]: Query(3728) from peer 5.181.165.147:9333 failed, rescheduling: did not get response before timeout
2024-08-01 16:47:44.080 [WRN] CORE[btc]: Reporting a block found in polling that the wallet apparently never reported: 717711 00000000000000000007e72a9979faadc01e12b4f9627b600a607a07c4f0a59e. If you see this message repeatedly, it may indicate an issue with the wallet.
2024-08-01 16:49:48.688 [DBG] CORE[dcr]: Retrieving fee rate from external fee oracle for 2 target blocks
2024-08-01 16:51:30.081 [WRN] CORE[btc]: Reporting a block found in polling that the wallet apparently never reported: 719711 00000000000000000002d5d3caf5cd22bd5cc211e4fb7e283c1713dabaa96df6. If you see this message repeatedly, it may indicate an issue with the wallet.
2024-08-01 16:54:36.935 [WRN] CORE[ltc]: Query(4513) from peer 45.153.35.147:9333 failed, rescheduling: did not get response before timeout
2024-08-01 16:54:49.883 [DBG] CORE[dcr]: Retrieving fee rate from external fee oracle for 2 target blocks
2024-08-01 16:55:07.142 [WRN] CORE[ltc]: Query(4581) from peer 44.226.159.216:9333 failed, rescheduling: did not get response before timeout
2024-08-01 16:55:52.083 [WRN] CORE[btc]: Reporting a block found in polling that the wallet apparently never reported: 721711 000000000000000000085c9890c7ff241bf0b9ccba6175a9e30200b189c9ace4. If you see this message repeatedly, it may indicate an issue with the wallet.
2024-08-01 16:59:50.277 [DBG] CORE[dcr]: Retrieving fee rate from external fee oracle for 2 target blocks
2024-08-01 17:00:33.085 [WRN] CORE[btc]: Reporting a block found in polling that the wallet apparently never reported: 723711 000000000000000000014a0d29af25f5886ea949fb01c61608e5e6fc26e4f4bf. If you see this message repeatedly, it may indicate an issue with the wallet.
2024-08-01 17:00:53.995 [WRN] CORE[ltc]: Reporting a block found in polling that the wallet apparently never reported: 2730541 fe0554830f40d148059da5014d4f285015f1e3cf3d51a658f2642194603a4546. If you see this message repeatedly, it may indicate an issue with the wallet.
2024-08-01 17:02:27.114 [ERR] CORE[ltc][PEER]: Can't read message from 67.40.102.33:9333 (outbound): read tcp 192.168.8.107:51937->67.40.102.33:9333: read: operation timed out
2024-08-01 17:04:51.086 [WRN] CORE[btc]: Reporting a block found in polling that the wallet apparently never reported: 725711 000000000000000000012312efc19acdcf3a0d518edc6d966b45aa5e6f247f1b. If you see this message repeatedly, it may indicate an issue with the wallet.
2024-08-01 17:04:52.474 [DBG] CORE[dcr]: Retrieving fee rate from external fee oracle for 2 target blocks
2024-08-01 17:09:00.089 [WRN] CORE[btc]: Reporting a block found in polling that the wallet apparently never reported: 727711 00000000000000000006a5a7d64d5b6ec509f5e5cbe66e7acce834d99b131843. If you see this message repeatedly, it may indicate an issue with the wallet.
2024-08-01 17:09:53.535 [DBG] CORE[dcr]: Retrieving fee rate from external fee oracle for 2 target blocks
2024-08-01 17:13:23.092 [WRN] CORE[btc]: Reporting a block found in polling that the wallet apparently never reported: 729711 00000000000000000005b15ed87d2c8a20796050d7fd5a0d54147c37a15d8204. If you see this message repeatedly, it may indicate an issue with the wallet.
2024-08-01 17:14:54.914 [DBG] CORE[dcr]: Retrieving fee rate from external fee oracle for 2 target blocks
2024-08-01 17:17:55.093 [WRN] CORE[btc]: Reporting a block found in polling that the wallet apparently never reported: 731711 00000000000000000002bcb26df2961f65e1b019b35831f24c8eb7b1bc6efaeb. If you see this message repeatedly, it may indicate an issue with the wallet.
2024-08-01 17:19:56.481 [DBG] CORE[dcr]: Retrieving fee rate from external fee oracle for 2 target blocks
2024-08-01 17:20:19.765 [DBG] WEB[WS]: New websocket client 127.0.0.1:53790
2024-08-01 17:23:35.095 [WRN] CORE[btc]: Reporting a block found in polling that the wallet apparently never reported: 733711 00000000000000000007ad2ecdc017590698eaedda39d9cfeba13a24c93cca31. If you see this message repeatedly, it may indicate an issue with the wallet.
2024-08-01 17:24:58.082 [DBG] CORE[dcr]: Retrieving fee rate from external fee oracle for 2 target blocks
^C2024-08-01 17:26:59.241 [INF] BW: Attempting to logout...
2024-08-01 17:26:59.242 [INF] CORE: Locking BTC wallet
2024-08-01 17:26:59.242 [INF] CORE: Locking LTC wallet
2024-08-01 17:26:59.243 [INF] CORE: Locking DCR wallet
2024-08-01 17:26:59.245 [INF] BW: Shutting down...
2024-08-01 17:26:59.245 [INF] RPC: RPC server off
2024-08-01 17:26:59.245 [ERR] WEB[WS][127.0.0.1:51869]: Websocket receive error from peer 127.0.0.1:51869: read tcp 127.0.0.1:5758->127.0.0.1:51869: use of closed network connection (*websocket.netError)
2024-08-01 17:26:59.246 [ERR] WEB[WS][127.0.0.1:51864]: Websocket receive error from peer 127.0.0.1:51864: read tcp 127.0.0.1:5758->127.0.0.1:51864: use of closed network connection (*websocket.netError)
2024-08-01 17:26:59.246 [ERR] WEB[WS][127.0.0.1:53790]: Websocket receive error from peer 127.0.0.1:53790: read tcp 127.0.0.1:5758->127.0.0.1:53790: use of closed network connection (*websocket.netError)
2024-08-01 17:26:59.265 [INF] WEB: Web server off
2024-08-01 17:26:59.285 [INF] CORE[DB]: Backing up database...
2024-08-01 17:26:59.325 [DBG] CORE[DB]: Total DB size 32768 bytes, 12328 bytes unused (37.62%)
2024-08-01 17:26:59.325 [INF] CORE[btc][SPV]: Unloading wallet
2024-08-01 17:27:35.002 [INF] CORE[btc][SPV]: SPV wallet closed
2024-08-01 17:27:35.002 [INF] CORE[ltc][SPV]: Unloading wallet

if ss.Transactions == nil { // If the asset doesn't support tx sync status, max unsynced is 0.999
return utils.Min(prog, 0.999)
}
return float32(ss.Blocks-ss.StartingBlocks) / float32(ss.TargetHeight-ss.StartingBlocks)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return float32(ss.Blocks-ss.StartingBlocks) / float32(ss.TargetHeight-ss.StartingBlocks)
return prog

Comment on lines 135 to 145
<td class="grey text-nowrap">Block Sync</td>
<td id="syncProgress" class="demi"></td>
</tr>
<tr id="txSyncBox">
<td class="grey text-nowrap">Tx Sync</td>
<td id="txProgress" class="demi text-end"></td>
<td id="txFindingAddrs" class="demi">
<div class="d-flex align-items-center justify-content-end">
<div class="fs10 ico-spinner spinner me-1"></div>
<span>Finding Addresses</span>
</div>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing translations.

@martonp
Copy link
Contributor

martonp commented Aug 1, 2024

After killing the process and restarting, LTC jumped to 100% (was 99%), and BTC (was ~85%) seems to be continuing.

@buck54321
Copy link
Member Author

The Reporting a block found in polling that the wallet apparently never reported is just a message that needs to be surpressed during initial sync. Not sure about other stuff. The only asset that should really be affected by this change is Decred.

@buck54321 buck54321 merged commit 12aeb7c into decred:master Aug 5, 2024
5 checks passed
buck54321 added a commit that referenced this pull request Aug 5, 2024
* refactor sync status

Use a more details structure for sync status. Add a sync
notification to replace wallet state notifications where only
the sync status has changed. Lower default account and address
gap limits for Decred and make address gap limit configurable.
Add information about address and tx syncing, for after headers
and filters have synced.

* supress unreported block warning during initial sync

* translations
@buck54321 buck54321 mentioned this pull request Aug 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants