bob-wallet
bob-wallet copied to clipboard
Network synchronization stalled after adding the same Ledger wallet twice
Expected Behavior
Wallet should maintain synchronization with the network.
Current Behavior
Wallet goes out of sync. Upon restart, Bob will resynchronize up to the point where txns were issued after duplicate wallet was removed.
Steps to Reproduce
- In a fresh Bob instance, create new Ledger-backed wallet
- Issue txns on that wallet
- Create another wallet using the same Ledger key (a duplicate wallet)
- Rescan the new wallet so now both wallets are equivalent
- Delete the new wallet
- Create new txns on your existing wallet
- Wait a period of time (took me overnight)
- The new txns will remain in pending status, restart Bob wallet
- Synchronization progress will now stall
Logs
For each pending txn, I see the following error message:
[I:2022-09-14T17:56:46Z] (wallet) Incoming transaction for 2 wallets in WalletDB (9617...).
[E:2022-09-14T17:56:46Z] (node) Assertion failed.
at WalletDB._addTX (C:\Users\account\AppData\Local\Programs\bob-wallet\resources\app.asar\node_modules\hsd\lib\wallet\walletdb.js:2432:7)
at async WalletDB._addBlock (C:\Users\account\AppData\Local\Programs\bob-wallet\resources\app.asar\node_modules\hsd\lib\wallet\walletdb.js:2267:13)
at async WalletDB.rescanBlock (C:\Users\account\AppData\Local\Programs\bob-wallet\resources\app.asar\node_modules\hsd\lib\wallet\walletdb.js:2378:7)
at async C:\Users\account\AppData\Local\Programs\bob-wallet\resources\app.asar\node_modules\hsd\lib\wallet\walletdb.js:154:9
at async NodeClient._emitAsync (C:\Users\account\AppData\Local\Programs\bob-wallet\resources\app.asar\node_modules\bevent\lib\asyncemitter.js:377:11)
at async NodeClient.emitAsync (C:\Users\account\AppData\Local\Programs\bob-wallet\resources\app.asar\node_modules\bevent\lib\asyncemitter.js:318:7)
at async ChainDB.scan (C:\Users\account\AppData\Local\Programs\bob-wallet\resources\app.asar\node_modules\hsd\lib\blockchain\chaindb.js:1610:7)
at async Chain.scan (C:\Users\account\AppData\Local\Programs\bob-wallet\resources\app.asar\node_modules\hsd\lib\blockchain\chain.js:2228:14)
at async WalletDB.scan (C:\Users\account\AppData\Local\Programs\bob-wallet\resources\app.asar\node_modules\hsd\lib\wallet\walletdb.js:509:7)
at async WalletDB.syncNode (C:\Users\account\AppData\Local\Programs\bob-wallet\resources\app.asar\node_modules\hsd\lib\wallet\walletdb.js:408:7)
[E:2022-09-14T17:56:46Z] (node) Assertion failed.
at WalletDB._addTX (C:\Users\account\AppData\Local\Programs\bob-wallet\resources\app.asar\node_modules\hsd\lib\wallet\walletdb.js:2432:7)
at async WalletDB._addBlock (C:\Users\account\AppData\Local\Programs\bob-wallet\resources\app.asar\node_modules\hsd\lib\wallet\walletdb.js:2267:13)
at async WalletDB.rescanBlock (C:\Users\account\AppData\Local\Programs\bob-wallet\resources\app.asar\node_modules\hsd\lib\wallet\walletdb.js:2378:7)
at async C:\Users\account\AppData\Local\Programs\bob-wallet\resources\app.asar\node_modules\hsd\lib\wallet\walletdb.js:154:9
at async NodeClient._emitAsync (C:\Users\account\AppData\Local\Programs\bob-wallet\resources\app.asar\node_modules\bevent\lib\asyncemitter.js:377:11)
at async NodeClient.emitAsync (C:\Users\account\AppData\Local\Programs\bob-wallet\resources\app.asar\node_modules\bevent\lib\asyncemitter.js:318:7)
at async ChainDB.scan (C:\Users\account\AppData\Local\Programs\bob-wallet\resources\app.asar\node_modules\hsd\lib\blockchain\chaindb.js:1610:7)
at async Chain.scan (C:\Users\account\AppData\Local\Programs\bob-wallet\resources\app.asar\node_modules\hsd\lib\blockchain\chain.js:2228:14)
at async WalletDB.scan (C:\Users\account\AppData\Local\Programs\bob-wallet\resources\app.asar\node_modules\hsd\lib\wallet\walletdb.js:509:7)
at async WalletDB.syncNode (C:\Users\account\AppData\Local\Programs\bob-wallet\resources\app.asar\node_modules\hsd\lib\wallet\walletdb.js:408:7)
Fix
Moved existing wallet directory to wallet_old, re-imported wallet from Ledger, rescanned wallet. No more pending txns, everything synchronizing fine.
Delete the new wallet
I didn't realize this is something Bob users can do, it's not normally exposed in the hsd API so I wouldn't be surprised that there's an edge case like this. I'm looking at walletdb.getWalletsByTX()
and it retrieves WIDs based on outpointMap, pathMap, and nameMap -- all three of which seem to be cleared appropriately in walletdb.remove()
.
this log line is maybe a clue:
[I:2022-09-14T17:56:46Z] (wallet) Incoming transaction for 2 wallets in WalletDB (9617...).
It says 2 wallets -- but only one of the matching wallets was actually retrievable. Maybe we should ensure that removing a wallet doesn't have any race conditions?