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

Add sanity check for round destroyer threshold #12585

Merged
merged 1 commit into from Mar 1, 2024

Conversation

turbolay
Copy link
Collaborator

@turbolay turbolay commented Mar 1, 2024

Round destroyer is broken since deployment of #12524 because roundDestroyerInputCount = 440, which is higher than MaxInputCountByRound (400). However, it must always be lower.

This clearly shows how unintuitive is this code, those multipliers etc etc... We should remove all that and refactor more simply.

Something else, we had extremely good rounds while having this bug. Maybe we should reconsider how this round destroyer is working.

@molnard
Copy link
Collaborator

molnard commented Mar 1, 2024

Can you add a static config parameter instead of calculations? Like RoundDestroyerInputCount.

Nevermind. A lot of things can be done. Let's restore the original behavior first.

@molnard
Copy link
Collaborator

molnard commented Mar 1, 2024

RoundDestroyer is solving a very complex problem of ensuring all the clients can register ALL their inputs into the round.

Before the client registers, it sets up a plan. According to the wallet privacy status, number of coins, etc. it selects the best combination of coins. The best for the client the plan can be executed. However if the number of inputs in the round goes up and reaches the maximum, it is not guaranteed that all the inputs can be registered. RoundDestroyer solving this issue by splitting the round and making an optimal distribution by using maxSuggestedAmount parameter. The result is smaller rounds which from blockpsace point of view is less effective, but it will guarantee optimal coin selection for the clients.

I am sure it can be improved or there can be other solutions but the other solution must address the requirement to ensure the clients can register all of their inputs to the round.

Copy link
Collaborator

@molnard molnard left a comment

Choose a reason for hiding this comment

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

ACK

@molnard molnard merged commit 3f656ae into zkSNACKs:master Mar 1, 2024
7 checks passed
@molnard molnard added the affiliate Could affect affiliates compatibility label Mar 1, 2024
@@ -497,7 +497,7 @@ private async Task CreateRoundsAsync(CancellationToken cancellationToken)
x.Phase == Phase.InputRegistration
&& x is not BlameRound
&& !x.IsInputRegistrationEnded(x.Parameters.MaxInputCountByRound)
&& x.InputCount >= roundDestroyerInputCount).ToArray())
&& x.InputCount >= Math.Min(0.9 * x.Parameters.MaxInputCountByRound, roundDestroyerInputCount)).ToArray())
Copy link
Collaborator

@adamPetho adamPetho Mar 1, 2024

Choose a reason for hiding this comment

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

roundDestroyerInputCount has no use after this change and at LOC540 we will log false data.

How about this?

var roundDestroyerInputCount = 0.9 * Config.MaxInputCountByRound

Then, we don't complicate further this Where predicate.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Where does the x come from? :D

Copy link
Collaborator

Choose a reason for hiding this comment

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

hehe, Config.MaxInputCountByRound is better.

Edited my prev message.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

For the logging, we could create a function instead, I was tired, didn't see we where using it again for logging purposes

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

hehe, Config.MaxInputCountByRound is better.

No, it has to be tested against the Round Parameter, not the Config.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I tried to fix this while respecting that we want use the Round Parameter and not the Config
#12591

@molnard
Copy link
Collaborator

molnard commented Mar 1, 2024

Deployed to TestNet and MainNet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affiliate Could affect affiliates compatibility size/XS
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants