Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip rounds randomly depending on network conditions #10910

Merged
merged 16 commits into from
Oct 11, 2023

Conversation

nopara73
Copy link
Contributor

@nopara73 nopara73 commented Jun 20, 2023

Closes #10586
Closes #10678
Closes #10906
Closes #8211

Less ambitious version of #10678

This pull request does not aim to replace the coinjoin prevention mechanism that happens during high fee environment, rather it introduces random round skipping depending on the profile and the network conditions, exactly as specified by #10678. The reason why I gave up on replacing the current cost saving mechanism is because I couldn't solve the Spread Problem, noted by @turbolay.

While the focus of this PR is randomization, it does it smartly as it considers the profile and daily, weekly and monthly fee environment in its randomization of round skipping.

  • add new properties
  • implement logic
  • reconsider concept
  • consider simplifying added keymanager properties somehow (create their own class?)
  • add unit tests
  • check if tests would randomly fail from this (make new properties 1, 1, 1)
  • discuss with trezor + btcpay about potential api break (CoinjoinClient)
  • implement UI customize (maybe)
  • test

@nopara73 nopara73 mentioned this pull request Jun 20, 2023
6 tasks
@nopara73 nopara73 marked this pull request as ready for review June 30, 2023 08:56
MaxHillebrand
MaxHillebrand previously approved these changes Jun 30, 2023
Copy link
Collaborator

@MaxHillebrand MaxHillebrand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cACK, it's nice to hit two birds with one stone, very elegant!

@nopara73 nopara73 requested a review from turbolay July 1, 2023 08:58
Copy link
Collaborator

@turbolay turbolay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The concept by itself is good, even tho it’s a bit misleading as one reading the code might think it’s helpful to save on fees while it’s in fact only useful for extra randomization, and we keep relying on the legacy implementation to save on fees.

I have at least a problem with the current implementation, related to the profiles. In fact, it’s a problem I already described here #10468 (comment) about retro compatibility, but it’s worse here and is inherent to how profiles equality work:

With your PR, ALL users would have the default values “CoinjoinSkipFactors”: “0.7_0.8_0.9”, and all users that previously had profiles Privacy and Economic would now see that they have profile Custom.

I believe an extra function must be added to check the current profile so that the default value for CoinjoinSkipFactors would be adequate for the current conjoin profile.

Additionally, isn’t it necessary to add a UI to change the values in Coinjoin Strategy Settings screen (Customize)? Otherwise, how would users with Custom profile already selected change their value? Or how would users disable the feature? This raises an extra problem: It’s really hard to understand what the values mean. For eg, 0.6 for the daily parameter of the constructor means 20% probability to skip the round if the current fee rate is lower than the daily median.... definitely not direct.

@@ -50,6 +53,13 @@ public WalletSettingsModel(KeyManager keyManager, bool isNewWallet = false)
.Skip(1)
.Do(_ => SetValues())
.Subscribe();

// This should go to the previous WhenAnyValue, it's just that it's not working for some reason.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't understand the problem either. There is an overload for 8 parameters, IDK why it's not working directly.

@nopara73
Copy link
Contributor Author

nopara73 commented Jul 9, 2023

Thanks @turbolay! I'll get back to this PR after the release.

@soosr
Copy link
Collaborator

soosr commented Aug 1, 2023

@Kruwed: Do you know what the music box text says while fees are high when a user sets their coinjoin time preference to "months" or "weeks"?

Investigate it here.

@molnard
Copy link
Collaborator

molnard commented Aug 29, 2023

I'll get back to this PR after the release.

Are we getting back to this?

@nopara73
Copy link
Contributor Author

I am working on this.

@Kruwed
Copy link
Collaborator

Kruwed commented Sep 3, 2023

@Kruwed: Do you know what the music box text says while fees are high when a user sets their coinjoin time preference to "months" or "weeks"?

Investigate it here.

After investigation, the answer is "Awaiting Coinjoin".

@nopara73
Copy link
Contributor Author

nopara73 commented Sep 4, 2023

@Kruwed, the investigation is to be done by the author of this PR, not you 🤣

@nopara73
Copy link
Contributor Author

The concept by itself is good, even tho it’s a bit misleading as one reading the code might think it’s helpful to save on fees while it’s in fact only useful for extra randomization, and we keep relying on the legacy implementation to save on fees.

My understanding is it is helpful to save on fees: this makes it less likely to participate in the middle of a mempool spike and more likely to do so down the hill.
image

@nopara73
Copy link
Contributor Author

With your PR, ALL users would have the default values “CoinjoinSkipFactors”: “0.7_0.8_0.9”, and all users that previously had profiles Privacy and Economic would now see that they have profile Custom.

That's a compromise. Correct. The reason why I don't mind it is because I did not touch existing features here like the FeeRateMedianTimeFrameHours, rather CoinjoinSkipFactors are merely an addition here, not a replacement. What this'll result in is:

  • old wallets will benefit from the default configuration of this feature: "CoinjoinSkipFactors": "0.7_0.8_0.9",
  • new wallets will benefit from the profile-specific configuration of this feature

I even wonder if there's an argument to be made for introducing the smallest possible change (default configuration of CoinjoinSkipFactors) to existing wallets?

In any case, even if not, that's a compromise I'm fine with.

@nopara73
Copy link
Contributor Author

Additionally, isn’t it necessary to add a UI to change the values in Coinjoin Strategy Settings screen (Customize)?

Necessary? No. Desirable? Maybe. I have no time for this, and your additional challenge makes it not even clear if there's a good way to do so, so this is something I skipped.

@nopara73
Copy link
Contributor Author

nopara73 commented Oct 11, 2023

I've reviewed this PR again and the only thing left here is a

  • coinjoinbox message in the case when we're skipping participation either because of FeeRateMedianTimeFrameHours or because of CoinjoinSkipFactors - @Kruwed, @soosr
  • Let user override behavior by clicking "Play"

@nopara73
Copy link
Contributor Author

After investigation, the answer is "Awaiting Coinjoin".

@Kruwed I misunderstood what you were investigating. This investigation is about what should it say and how to make it say that. Now that I've been investigation I realized your investigation isn't a normative prescription, but you're saying what it currently says.

@nopara73
Copy link
Contributor Author

nopara73 commented Oct 11, 2023

Let user override behavior by clicking "Play"

I didn't implement this. It was too hard for me. I opened an issue for that instead: #11673

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Load Balancing Coinjoins, Randomly Skipping Rounds Likelyhood to coinjoin
6 participants