As a Wasabi Wallet user, you want your bitcoin activity to be private. Coinjoins are great for that, but they’re not the complete solution. To do bitcoin privacy right, you need to solve both blockchain privacy, which coinjoins do, and network privacy. How does Wasabi Wallet handle the latter? We implement block filters (BIP 157-158) as a solution to download bitcoin transaction data without compromising network privacy.
One of the biggest challenges with this implementation is that users have to download a lot of data compared to other light client solutions. This results in longer load times when restoring or initializing a wallet on Wasabi. Fortunately, the hard work of the contributors has resulted in an optimization.
Turbosync has now been introduced in the 2.0.4 release of the Wasabi Wallet and reduces load times by up to 90%. We did this with accessibility in mind so that even slow internet users can use Wasabi with less friction.
What is Turbosync and How Does it Reduce Wasabi Wallet’s Load Time by Up to 90%?
This release optimizes the filter-checking process to reduce wallet loading times by 90% thanks to code cleanup and a clever key prioritization process dubbed “Turbosync”. With Turbosync, internal addresses that have already been used are not checked for coins in new blocks until after unused addresses have been checked first. Filter performance has been further improved by storing them in a SQLite database instead of a plain text file, reducing disk space requirements by about 1 GB and increasing resilience to file corruption.
To better communicate this topic, we first need to take a quick look at the challenges of network privacy in bitcoin, block filters as an abstract solution, Wasabi’s specific block filter implementation, and the details of Turbosync along with the fixes in the 2.0.4 release.
The Challenges of Network Privacy in Bitcoin
Network privacy in Bitcoin is an essential piece of the puzzle to solve. The goal is to connect to the Bitcoin network privately in order to track your wallet’s addresses and broadcast transactions. As you may know, running and using a Bitcoin node is the best thing you can do because you’re part of the network and you don’t need any intermediaries. Read this article to learn more about the benefits of running a bitcoin node.
While this is easy to say, it is harder to accomplish since running a bitcoin node requires a lot of bandwidth and disk space. It also takes a long time to set up, from a few hours to a few weeks (usually 12-36 hours). Light wallets are inevitably the standard for their ease of use, which is something even Satoshi acknowledged on the Bitcoin White Paper, as SPV (Simple Payment Verification).
The Privacy Problem of Light Wallets
There are two main approaches to network connectivity for light wallets, SPV and API (Application Specific Interface). Both have inherent privacy flaws that this section will explore.
SPV was a terrible design because it couldn’t validate transactions, it wasn’t private, and it wasn’t fast. Bloom Filters were added to SPV wallets in BIP37, as an effort to increase privacy. However, this was debunked in the following years because bloom filters download specific transactions, which makes it straightforward to deduct which coins belong to the user’s IP address.
API wallets were introduced as a way to make network connectivity fast. They work by connecting to a central server via an API. Examples include BitPay’s wallet, Mycelium, and the Electrum server framework. This centralized approach means that users’ transaction data can be logged and linked to their IP address. Again, there are privacy limitations with Bitcoin network connectivity.
Doesn’t Tor Solve This?
It partially solves this. Yes, Tor (The Onion Network) is software that allows for anonymous communication by encrypting and routing internet traffic through a network of servers, making it difficult to trace the origin or destination of data. This means that it hides your IP address from the SPV network peers or the API server. However, all your transactions and coins are still linked to each other, which remains a big privacy problem.
Tor is bundled with Wasabi Wallet and is enabled by default. The remaining part of the network privacy problem is solved by Block Filters.
Block Filters as a Solution for Bitcoin Network Privacy
Block Filters were introduced in BIP 157 and BIP 158 as a privacy improvement over Bloom Filters. Block filters compress block data to help wallets like Wasabi receive transactions from peers without compromising privacy by downloading specific blocks instead of looking up single transactions.
With block filters, full nodes create filters for each block, and light clients fetch these filters. With bloom filters, the light client creates and sends the filter to the full nodes. There’s a key difference in the direction of filter creation.
Although filters consume bandwidth and storage, keep in mind that this additional consumption of network and hardware resources is nowhere near those of a full bitcoin node. Only ≈3GB of filters and blocks are required to sync a wallet instead of 500GB of block history.
How does this work in Wasabi’s specific context?
Wasabi Wallet’s Block Filter Implementation
Wasabi’s coinjoin and privacy features would not be complete without a block filter implementation. There’s three steps for wallet synchronization: Filter Download, Filter Scanning and Block Download.
Implemented differently in Wasabi Wallet than on the BIPs because they’re downloaded from the Wasabi backend coordinator server, through Tor. This takes a while the first time, but it’s much faster on the next occasions since it only has to catch up to the newest blockchain state.
When you load a wallet, it checks if the generated addresses within the gap limit hit against a block filter. If a transaction of yours is in a block, then the corresponding filter will always be hit, and the wallet will know this is a relevant block for you. There’s a small chance of a false positive where the filter matches, but the block actually does not contain a transaction.
When a block filter hits, either a true match or a false positive, the wallet will download it. If you have a Bitcoin full node connected, then it will fetch the verified block locally. If not, then Wasabi will connect to a random Bitcoin P2P node with a new Tor identity, and request only this block for download. In this step, your Wasabi behaves like any other full node, and cannot be differentiated. Once every block wanted is downloaded, the wallet load has finished and your wallet dashboard appears.
It can be annoying for users to be presented with the wallet load screen and having to wait for this to complete before using their wallet. To speed things up, our software contributors noticed that some improvements could be brought to this implementation and Turbosync was born.
Turbosync and 2.0.4 Release Improvements
Turbosync is a feature introduced in Wasabi Wallet’s 2.0.4 release that changes how filter scanning is done in order to present the user’s dashboard as fast as possible. It operates with the heuristic that internal keys (coinjoin outputs or change addresses) should only be used to receive coins once and to spend. As soon as an address (part of the internal keys) hits a block filter twice, it has received coins and then spent them, we skip checking this address and we move on to the next one.
Once all addresses have been checked and the required blocks are downloaded, the wallet load screen will change to present the user’s dashboard. However, filter scanning will continue in the background and the skipped addresses will be checked. In the case that some additional funds have been received on those addresses. Users in that edge case would see their balance update automatically after some time. Once done, the message “Wallet is fully synchronized.” will be written to the logs file to indicate that the verification process has finished.
Wallets that coinjoin frequently will benefit the most from this feature, as the vast majority of their addresses will be skipped. It’s important to remember that false-positives happen and they lead to unnecessary additional load time. Turbosync reduces the amount of false-positive blocks downloaded before the user’s dashboard appears.
TurboSync feature shouldn’t cause any issues, but you might want to disable it to debug potential issues with the synchronization of your wallet. In that case, go to your wallet file (search for `Wallet Folder` using Wasabi’s search bar then open the file corresponding to your wallet) and set `UseTurboSync` to `false`.
What other improvements were made to the Block Filter implementation?
Filter performance improved even more by storing them in an SQLite database instead of a plaintext file, reducing disk space requirements by about 1 GB and increasing resilience against file corruption. This is a standard software development practice that is applied to the block filter implementation, but is not related to the steps for wallet synchronization.
In this article, we explained the network privacy problem of bitcoin light wallets and how both SPV and API wallets fail at solving this. We explain how Tor is part of the solution, but how Block Filters are the remaining piece of the puzzle to solve this problem. We then break down how block filters work in an abstract format, but also how Wasabi Wallet implements it. Finally, Turbosync is introduced in the 2.0.4 release with some other improvements such as the introduction of an SQLite database for block filter storage. Together, both of these changes can reduce Wasabi Wallet’s load time by up to 90%.