SiaFoundation / siad

The Sia daemon
https://sia.tech
MIT License
130 stars 28 forks source link

List unspent broken after rescan #163

Open mmbbee opened 1 year ago

mmbbee commented 1 year ago

After performing a wallet rescan on watched addresses, we can no longer call /wallet/unspent, getting the error

{"message":"error when calling /wallet/unspent: could not decode type wallet.v121ProcessedTransaction: EOF"}

This is on version v1.5.9

mmbbee commented 1 year ago

Just a guess, it might have something to do with the wallet db not being vacuumed after rescan ?

n8maninger commented 1 year ago

I’ll look into this. Do you have any steps to reproduce? How many addresses are you watching? What are you using the watch endpoints for?

mmbbee commented 1 year ago

We are watching about 50k addresses.

The steps where we hit this were

  1. Having running wallet watching lots of addresses
  2. kill -9 siad (unclean force kill)
  3. On restart, /wallet/watch [POST] a new address with unused = false ( kick off rescan)
  4. After rescan finishes, all wallet endpoints seem to still work except for /wallet/unspent which throws the above error. Wallet reports the correct balance, siad is up, and other endpoints are happy, just not get unspent

Similarly, i have seen this a few times in local testnet during integration tests. In our integration tests, the beforeAll() is to

  1. /wallet/watch [GET] - get all watched addresses
  2. /wallet/watch [POST] remove=true - remove all watched addresses
  3. /wallet/watch [POST] remove=false, unused=true - re-add all watched addresses but dont rescan
  4. /wallet/unspent throws error

In the local testnet case, it is happening with < 100 addresses

mmbbee commented 1 year ago

Should also clarify these wallets only watch addresses. We don't use the wallet for any funds management, just tx tracking