WalletWasabi / WalletWasabi

Open-source, non-custodial, privacy preserving Bitcoin wallet for Windows, Linux, and Mac.
https://wasabiwallet.io
MIT License
2.13k stars 497 forks source link

System.InvalidOperationException: Sequence contains no elements #3795

Closed mmahut closed 4 years ago

mmahut commented 4 years ago

General Description

I'm trying to run Wasabi Wallet againts my own backend, however when WasabiSynchronizer tries to download the filters for blocks, it fails with:

2020-06-19 15:54:23 ERROR   WasabiSynchronizer (306)    System.InvalidOperationException: Sequence contains no elements
   at System.Linq.ThrowHelper.ThrowNoElementsException()
   at System.Linq.Enumerable.Last[TSource](IEnumerable`1 source)
   at WalletWasabi.Stores.IndexStore.RemoveLastFilterAsync(CancellationToken cancel)
   at WalletWasabi.Services.WasabiSynchronizer.<>c__DisplayClass60_0.<<Start>b__0>d.MoveNext()

How To Reproduce?

  1. Download and run backend 1.1.11.1
  2. Point the wallet to it
  3. See error

Operating System

NixOS, both backend and wallet are 1.1.11.1

Logs


2020-06-19 15:54:22 INFO    IndexStore (45) InitializeAsync finished in 4 seconds.
2020-06-19 15:54:22 INFO    BitcoinStore (39)   InitializeAsync finished in 4 seconds.
2020-06-19 15:54:22 INFO    HostedServices (51) Started Software Update Checker.
2020-06-19 15:54:22 INFO    Global (290)    Start connecting to nodes...
2020-06-19 15:54:22 INFO    Global (314)    Start synchronizing filters...
2020-06-19 15:54:23 INFO    WasabiSynchronizer (270)    REORG Invalid Block: 0000000000000000000e228a078c22bbbff525b4ddebfec74f4cc7e3c6e7a8cd.
2020-06-19 15:54:23 INFO    WasabiSynchronizer (270)    REORG Invalid Block: 000000000000000000042d1a7ca80afb329e5b014df991b002183c7a3b847097.
2020-06-19 15:54:23 INFO    WasabiSynchronizer (270)    REORG Invalid Block: 000000000000000000093c60b9636fd42e082b29ca218eb42a01e9453df8646d.
2020-06-19 15:54:23 INFO    WasabiSynchronizer (270)    REORG Invalid Block: 0000000000000000000858632112aaa4b8e1d3c572bdd8fd96baa9d0ed2e9b98.
2020-06-19 15:54:23 INFO    WasabiSynchronizer (270)    REORG Invalid Block: 00000000000000000000ab01a48e30683fff1e4d8bf5ff9ae4474104ac40a104.
2020-06-19 15:54:23 INFO    WasabiSynchronizer (270)    REORG Invalid Block: 000000000000000000096c4a564f55b86fac9b4a78793cb31baeed3fd63e7db2.
2020-06-19 15:54:23 INFO    WasabiSynchronizer (270)    REORG Invalid Block: 0000000000000000000725d296d68691073f8b104e0be2f5a481b0e78cb4e69d.
2020-06-19 15:54:23 INFO    WasabiSynchronizer (270)    REORG Invalid Block: 000000000000000000000b4daee828769ed4911f278e882c53bb9d3ae9487fea.
2020-06-19 15:54:23 INFO    WasabiSynchronizer (270)    REORG Invalid Block: 000000000000000000053b5c9886044aac6d20e5004905270d1f88d45c28926c.
2020-06-19 15:54:23 INFO    WasabiSynchronizer (270)    REORG Invalid Block: 0000000000000000000b1a2fb6d6dcc0f9e268602a992da756aea04299ea3051.
2020-06-19 15:54:23 INFO    WasabiSynchronizer (270)    REORG Invalid Block: 0000000000000000000f8065e6e1a1df28c187724476316a0f8d1acb2d619891.
2020-06-19 15:54:23 INFO    WasabiSynchronizer (270)    REORG Invalid Block: 0000000000000000001132f719e160815139740e6f771c0b64a10f98c2985db2.
2020-06-19 15:54:23 INFO    WasabiSynchronizer (270)    REORG Invalid Block: 0000000000000000000bf718bd6b88bd2053ef6fa141c0239c6ec6894d14beda.
2020-06-19 15:54:23 INFO    WasabiSynchronizer (270)    REORG Invalid Block: 00000000000000000006a14b99867d2576d07c0670c8600eedd560c319b6e3c2.
2020-06-19 15:54:23 INFO    WasabiSynchronizer (270)    REORG Invalid Block: 00000000000000000004e409fe6d721cc7a4fd8e7f3c6b1486192972529a74ca.
2020-06-19 15:54:23 INFO    WasabiSynchronizer (270)    REORG Invalid Block: 0000000000000000000580a02c4a13ad38a83094dd7c23889c58b35672814f55.
2020-06-19 15:54:23 ERROR   WasabiSynchronizer (306)    System.InvalidOperationException: Sequence contains no elements
   at System.Linq.ThrowHelper.ThrowNoElementsException()
   at System.Linq.Enumerable.Last[TSource](IEnumerable`1 source)
   at WalletWasabi.Stores.IndexStore.RemoveLastFilterAsync(CancellationToken cancel)
   at WalletWasabi.Services.WasabiSynchronizer.<>c__DisplayClass60_0.<<Start>b__0>d.MoveNext()
2020-06-19 15:54:53 ERROR   WasabiSynchronizer (306)    System.InvalidOperationException: Sequence contains no elements
   at System.Linq.ThrowHelper.ThrowNoElementsException()
   at System.Linq.Enumerable.Last[TSource](IEnumerable`1 source)
   at WalletWasabi.Stores.IndexStore.RemoveLastFilterAsync(CancellationToken cancel)
   at WalletWasabi.Services.WasabiSynchronizer.<>c__DisplayClass60_0.<<Start>b__0>d.MoveNext()

Wasabi Version

Compile from Github, 1.1.11.1.

lontivero commented 4 years ago

This is a bug produced by a reorg detected during initial synchronization. The user has to be really lucky to find it. UPDATE: this comment is incorrect.

lontivero commented 4 years ago

Oh wait, no. It looks like a more than 16 blocks reorg and the blocks are okay (valid). Ohhhh you are running your OWN backend.... Your backend doesn't have all the filters or the filters are for the wrong network. Once your backend has all the filters you will be able to synchronize your wallet with your backend.

lontivero commented 4 years ago

In other words, the wallet is synchronized (Jun 18, 2020) and it can go back on time maximum 100 blocks, however it seems the backend server is in a time (block height) older than that.

mmahut commented 4 years ago

This has been caused by custom backend working with bitcoind (not knots). Upgrading to knots did solve the problem.