-
Notifications
You must be signed in to change notification settings - Fork 36.2k
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
test: reject float at satoshi_round #23225
Conversation
Using strings and integers will be more predictable than using float, which is less repeatable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if satoshi_round
can be removed if the call sites denote everything in integral satoshi values.
@@ -58,7 +58,7 @@ def small_txpuzzle_randfee(from_node, conflist, unconflist, amount, min_fee, fee | |||
# It's best to exponentially distribute our random fees | |||
# because the buckets are exponentially spaced. | |||
# Exponentially distributed from 1-128 * fee_increment | |||
rand_fee = float(fee_increment) * (1.1892 ** random.randint(0, 28)) | |||
rand_fee = fee_increment * Decimal(1.1892 ** random.randint(0, 28)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if rejecting a float
is the right thing to do when the caller just wraps the float
into a Decimal
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-
This is an exception: random fee generation. Rounding is not an
important issue. -
The corresponding rule: argument will be a well determined monetary
quantity, for repeatability purposes. Any other case, that is correctly
already not usingfloat
.
Conceptually I agree with this. It would be nice to go to Decimal/Integer only. Floating point numbers shouldn't be used for monetary amounts, not even in tests. |
If Bitcoin Core won't hard fork increased currency divisibility, If Bitcoin Core or other group is going to hard fork increased |
It is very safe to modify the test code assuming Bitcoin Core will not hard fork. |
If I had to do this, I'd take all the necessary time to make sure If possible, I would prefer configuring a "safe mode" at the Python interpreter Cheers! |
Are you still working on this? |
Using strings and integers will be more predictable than using float,
which is less repeatable.
satoshi_round was used with almost no floats already, I suppose
that because it rounds in a single direction and when floating
point rounding occurs it can go either up or downwards so it
is a risky thing to do. Forbid it explicitly.