-
Notifications
You must be signed in to change notification settings - Fork 38.8k
Cleanup fee estimation code #19630
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
Cleanup fee estimation code #19630
Conversation
|
Added a trivial commit which de-duplicates some duplicated |
|
Code review ACK besides some minor nits |
7f61299 to
8bb546a
Compare
|
Amended after review (the unnecessary variables declaration move and the pre-decrement). |
|
FYI it looks the last usage of requireGreater=false went away in b2322e0 |
8bb546a to
6963cec
Compare
theStack
left a comment
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.
LGTM, very nice unused code finding and cleanup!
I think the last two commits could be squashed, but no strong objective.
6963cec to
d211ea7
Compare
|
@theStack i think the for loops unification are not "small readability improvements", and that the readability improvements are not "unify some duplicated for loops". Also, fixed the string format, thanks! |
a8f42fd to
dd7f81d
Compare
|
Tests pass but the s390X Travis build is always stuck and eventually results in a failure after one day (i've tried to force-push above but it won't trigger it). edit: reopened to kick it back.. |
practicalswift
left a comment
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.
Concept ACK
jnewbery
left a comment
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.
Concept ACK
src/policy/fees.h
Outdated
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.
Remove the number entirely from the comment. No need for a comment that says "x is x"
| /** Decay of .9952 is a half-life of 144 blocks or about 1 day */ | |
| /** This decay gives a half-life of 144 blocks or about 1 day */ |
Same for other comments here.
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 don't think it's a trivial "x is x" comment: it's not trivial to me that a decay of say .99931 is equivalent to a half-life of 1008 blocks.
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 agree! That's why I'm saying remove the literal value that's in the code and leave the rest.
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.
Ah, ok: will remove if i have to retouch
This was confusing: which one is the good one ? After testing the value is right but not the comment, so fix it. Signed-off-by: Antoine Poinsot <[email protected]>
It was always passed as true, and complicates the (already complex) logic of the function. Signed-off-by: Antoine Poinsot <[email protected]>
Signed-off-by: Antoine Poinsot <[email protected]>
Signed-off-by: Antoine Poinsot <[email protected]>
Reported-by: practicalswift <[email protected]> Signed-off-by: Antoine Poinsot <[email protected]>
0a1eddb to
a3abeec
Compare
|
Thanks for the review. Cleaned up the logprint, used the |
|
utACK a3abeec |
ariard
left a comment
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.
Code Review ACK a3abeec.
| const std::map<double, unsigned int>& defaultBucketMap, | ||
| unsigned int maxPeriods, double _decay, unsigned int _scale) | ||
| : buckets(defaultBuckets), bucketMap(defaultBucketMap) | ||
| : buckets(defaultBuckets), bucketMap(defaultBucketMap), decay(_decay), scale(_scale) |
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.
If you feel it you can comment scale parameter usage at function declaration.
| // feerate such that all lower values fail, and we go in the opposite direction. | ||
| unsigned int startbucket = requireGreater ? maxbucketindex : 0; | ||
| int step = requireGreater ? -1 : 1; | ||
| const int periodTarget = (confTarget + scale - 1) / scale; |
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.
Maybe you can keep comment first halve and precise what the highers values reference is about. I believe it means higher buckets of transactions.
maflcko
left a comment
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.
ACK a3abeec 💹
Show signature and timestamp
Signature:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512
ACK a3abeec33a6ae903e514c7a7b6f587b7c17288a0 💹
-----BEGIN PGP SIGNATURE-----
iQGzBAEBCgAdFiEE+rVPoUahrI9sLGYTzit1aX5ppUgFAlwqrYAACgkQzit1aX5p
pUiPSQv9GVM34Ovhf/IZuz4KOiBBJw2Awl49W5aP6XSMN25yuTR2sFX57bUaIMeD
jYCcLC/+Px1xXIre0l8/afNtlHxw4gz/H+iRjWj6I4wA/MF58JiskX2X6TnS5RCi
67pKDN8IiYnWdPVWacahqY9qjLPYC88RiqV65Qce6DTiTJCBh3Kh/mErp0RWjioN
Hrd7UmHgV6bzD4hhqd+qrOTY6RrDkesSC9IAZDVNNHSMl9cOiQI2zQu8lYngIFnW
uwZlDz6s79fWvJWQwnCGOJ+BkniWjii2/20ol+rZM8oOQrEkmu+vZq/aFzs8fdHo
hjk8omKNBWvhPYovGHy4PY3CWRFC7OyyQB2kcCeFkXo9iloGpmVGE0JkCm7NDOfO
gJFohrWE0al6Dl6KVAWUDZ/F8FK64oGiOE4PEI1TLK00JMMU6HL/J+MfvlhKuDD/
M334hu1c0TS0K6NSKHDCH6X5cnNrNo3IimaFAl/JdzRXyOKc7cXCt6VLsnrqZk+Q
2UZJvsAT
=0se/
-----END PGP SIGNATURE-----
Timestamp of file with hash d9cd36b4e6a9b525b00d5cee9eb8107f4bc33c22ac73950c8b6164e5c2d50eda -
| int maxbucketindex = buckets.size() - 1; | ||
|
|
||
| // requireGreater means we are looking for the lowest feerate such that all higher | ||
| // values pass, so we start at maxbucketindex (highest feerate) and look at successively |
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.
nit in commit 5b8cb35:
I think this line in the comment can be kept
a3abeec policy/fees: remove a floating-point division by zero (Antoine Poinsot) c36869b policy/fees: unify some duplicated for loops (Antoine Poinsot) 569d92a policy/fees: small readability improvements (Antoine Poinsot) 5b8cb35 policy/fee: remove requireGreater parameter in EstimateMedianVal() (Antoine Poinsot) dba8196 policy/fees: correct decay explanation comments (Antoine Poinsot) Pull request description: This (*does not* change behaviour and) cleans up a bit of unused code in `CBlockPolicyEstimator` and friends, and slightly improves readability of the rest (comment correction etc.). The last commit is a small reformatting one which I could not resist but am happy to remove at will. ACKs for top commit: jnewbery: utACK a3abeec MarcoFalke: ACK a3abeec 💹 ariard: Code Review ACK a3abeec. Tree-SHA512: b7620bcd23a2ffa8f7ed859467868fc0f6488279e3ee634f6d408872cb866ad086a037e8ace76599a05b7e9c07768adf5016b0ae782d153196b9c030db4c34a5
Summary: [[bitcoin/bitcoin#20379 | core#20379]] > Remove no longer needed UBSan suppression. > The float divide-by-zero in validation.cpp was fixed by instagibbs in D8857. The other suppression was removed by [[bitcoin/bitcoin#19630 | core#19630]] after fixing fee estimation code that does not exist in Bitcoin ABC. We can assume that we do not need this suppression, and add it back if needed. This is a backport of [[bitcoin/bitcoin#20379 | core#20379]] Test Plan: With UBSAN: `ninja && ninja check check-functional` Reviewers: #bitcoin_abc, Fabien Reviewed By: #bitcoin_abc, Fabien Subscribers: Fabien Differential Revision: https://reviews.bitcoinabc.org/D10728
This (does not change behaviour and) cleans up a bit of unused code in
CBlockPolicyEstimatorand friends, and slightly improves readability of the rest (comment correction etc.). The last commit is a small reformatting one which I could not resist but am happy to remove at will.