molnard / The-release-game-v2-0-4-1

0 stars 0 forks source link

Sort out the Coin Selectors #4

Open molnard opened 11 months ago

molnard commented 11 months ago

📜 Preamble:

Sort out the Coin Selectors by @molnard

📖 TL;DR - Too Long, Didn't Read:

When our user wants to send Bitcoin, wasabi needs to find the most optimal set of coins, according to the user's demand, privacy, cost, and speed. There are two problems here, first - sometimes these are against each other, where is the golden mean? Second - there are multiple logic in Wasabi and they barely work together. There are many cases where the selection could be better or what is worse harming privacy. The idea here is to unify these logics into one and write proper tests to clarify the behavior, which will also reduce issues in the future.

🌟 Specification, Scope, and Features:

⚔️ Motivation:

Issues about this are coming back again and again. The reason is that is so complex and scattered that when we fix something on one side, it breaks on the other side. Nobody at the company has a comprehensive detailed knowledge of how we are selecting coins. With a unified model and proper tests, this could be detected and avoided. Below you can see a few concrete issues and there were many user cases where the coin selection was clearly not optimal. However, the problem is not so visible for the users but it is there and will be noticed more when privacy warnings are more and more detailed.

📜 Rationale:

Basically, there are three main modules regarding coin selection. Pocket selector, Branch&Bound and SmartCoinSelector. My idea is to dismiss SmartCoinSelector and move all the relevant logic into another module. SmartCoinSelector is called by NBitcoin and we are not in 100% control there - we ran into mystical cases in the past - but currently, nobody dares to touch it significantly. After that Pocket selector should be melted into this new module as well. Tests are very important - so the implementation must focus on that as well. All cases have to be covered. The final part is to make B&B respect the same rules as we have in our new Module.

Many tests have to be added to ensure the best privacy we can reach with a given coin set.

🌌 Backward Compatibility:

I see no problems here. Everything will look the same for the user. Just the logic will be replaced under the hood.

📚 Reference Implementation (optional):

None but there are a couple of issues related.

👥 Team involvement

Lead: ? Code team Partially UI team

💪 Subtasks

We spent 2:30 hours figuring out a few actual steps in the right direction but we generally failed to provide a comprehensive plan. Coin selection happens on many levels and involves many other classes, like pockets, txbuilder, smartcoins, nbitcoin.

Primary direction: Simplify! - no improvements!

The quest seems to be too big to estimate - so the success rate and the time estimation are not determined at all => the risk is high. However, I do not see any other way to solve the problem any other way. So the question: is it the right time now to take the risk?

molnard commented 11 months ago

Noble Author,

Your Quest has been selected for further progress! The devil is in the details - so you need to elaborate and show your quest is not evil. We only embrace quests that are leading us to the light! To prove that you will need to add the following Sections to the Quest description above:

⚠️ Sections to add to the Quest descriptions

ℹ️ Tips

🕐 Please make this the utmost importance - we do not have much time left!