decred / dcrwallet

A secure Decred wallet daemon written in Go (golang).
https://decred.org
ISC License
212 stars 153 forks source link

syncstatus.Synced does not reflect discovery progress in RPC mode #2317

Closed matheusd closed 5 months ago

matheusd commented 6 months ago

In SPV mode, the SyncStatusResult.Synced only toggles to true when the entire initial sync process, including account and address discovery and rescan process completes here.

However, in RPC mode the same value toggles to true as soon as the headers and cfilters are synced, due to the handler not taking into account the syncer status and only the mainchain tip (here).

This can lead to problems to clients verifying the wallet's sync status through the JSON RPC interface, as the client cannot be sure rescan has completed (and thus may start client operations before the wallet is in a consistent state).

This should be fixed so that the sync status in RPC syncing mode reflects a similar status to the SPV syncing mode.

One solution to this is to ensure the RPC syncer establishes itself as the wallet's backend network instead of the dcrd JSONRPC interface (here). This will involve ensuring the chain.Syncer also fulfills the appropriate interface.

jrick commented 6 months ago

Makes sense to pass in the syncer as the network backend, and type assert for it as is done with spv mode. Then we can query the syncer itself whether it has fully synced the wallet or not. That existing check where it is doing another dcrd rpc call looks like a total hack, and the results will be racy too.