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

Prevent absurdly low minsizes in yg-pe #890

Merged
merged 1 commit into from
Jun 7, 2021
Merged

Prevent absurdly low minsizes in yg-pe #890

merged 1 commit into from
Jun 7, 2021

Conversation

AdamISZ
Copy link
Member

@AdamISZ AdamISZ commented Jun 2, 2021

Fixes #889.
Prior to this commit, it was possible for the
yg-privacyenhanced.py script to go into an infinite
loop of attempting to halve the txfee setting, in case
the user selected (a) reloffer, (b) an absurdly low
minsize like 1 sat, and (c) a txfee of zero.
This occurred partially due to the randomization of minsizes
included in the yg-pe algorithm, which could lead to a
pathological zero value for minsize.
After this commit the minsize is automatically bumped to
the DUST_THRESHOLD value if it falls below it, preventing
the possibility of a nonsensical value.
Additionally, the loop which halves the txfee is no longer
allowed to continue beyond 20 iterations, as an extra sanity
check.

@AdamISZ
Copy link
Member Author

AdamISZ commented Jun 2, 2021

Testing:

  1. Reproduced the behaviour described in YG stuck at "Warning: too high txfee to be profitable, halfing it to: 0" #889 on master, using this on regtest:
python yg-privacyenhanced.py --datadir=. 88c3ed2aee24f69697d94463d2b116c1 -o reloffer -s 1 -t 0

(warning : if you try to do this test, be ready to find and kill -9 the process quickly as it eats up disk space fairly fast).

  1. Confirmed that the behaviour is fixed by using this PR code and running the same command and seeing the expected message
2021-06-02 16:09:15,300 [WARNING]  Minsize was randomized to below dust; resetting to dust threshold.

followed by normal startup.

We could "gild the lily" by messing around with the exact value when it hits the limit, but using ridiculously low values around 10k sats is not something users should be doing anyway, since they don't actually want utxos that small.

@AdamISZ
Copy link
Member Author

AdamISZ commented Jun 2, 2021

Also, it is probably worth mentioning that the edit to the loop (from while to for i in range(20) ) isn't logically necessary, but: this is the second time we encountered an edge condition leading to an infinite loop there, and since it's so nasty, it makes zero sense to not just prevent it.

@kristapsk
Copy link
Member

ACK, tested before / after. Needs squash, of course. Note for other testers - you will not be able to reproduce this all the time, as it depends on randomization.

Fixes #889.
Prior to this commit, it was possible for the
yg-privacyenhanced.py script to go into an infinite
loop of attempting to halve the txfee setting, in case
the user selected (a) reloffer, (b) an absurdly low
minsize like 1 sat, and (c) a txfee of zero.
This occurred partially due to the randomization of minsizes
included in the yg-pe algorithm, which could lead to a
pathological zero value for minsize.
After this commit the minsize is automatically bumped to
the `DUST_THRESHOLD` value if it falls below it, preventing
the possibility of a nonsensical value.
Additionally, the loop which halves the txfee is no longer
allowed to continue beyond 20 iterations, as an extra sanity
check.
@AdamISZ AdamISZ merged commit 8b70836 into master Jun 7, 2021
@AdamISZ AdamISZ deleted the fix-minsize-loop branch July 27, 2021 15:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

YG stuck at "Warning: too high txfee to be profitable, halfing it to: 0"
2 participants