Skip to content

Conversation

@darosior
Copy link
Member

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.

@darosior
Copy link
Member Author

Added a trivial commit which de-duplicates some duplicated for-loops.

@darosior darosior changed the title Refactor fee estimation code Cleanup fee estimation code Aug 1, 2020
@laanwj
Copy link
Member

laanwj commented Aug 6, 2020

Code review ACK besides some minor nits

@darosior darosior force-pushed the 20/07/refactor_feeest_code branch from 7f61299 to 8bb546a Compare August 6, 2020 17:12
@darosior
Copy link
Member Author

darosior commented Aug 6, 2020

Amended after review (the unnecessary variables declaration move and the pre-decrement).

@laanwj
Copy link
Member

laanwj commented Aug 6, 2020

FYI it looks the last usage of requireGreater=false went away in b2322e0

@darosior darosior force-pushed the 20/07/refactor_feeest_code branch from 8bb546a to 6963cec Compare August 6, 2020 17:24
Copy link
Contributor

@theStack theStack left a 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.

@darosior darosior force-pushed the 20/07/refactor_feeest_code branch from 6963cec to d211ea7 Compare August 7, 2020 10:55
@darosior
Copy link
Member Author

darosior commented Aug 7, 2020

@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!

@darosior darosior force-pushed the 20/07/refactor_feeest_code branch 2 times, most recently from a8f42fd to dd7f81d Compare August 8, 2020 10:00
@darosior
Copy link
Member Author

darosior commented Aug 8, 2020

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..

@darosior darosior closed this Aug 10, 2020
@darosior darosior reopened this Aug 10, 2020
Copy link
Contributor

@practicalswift practicalswift left a comment

Choose a reason for hiding this comment

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

Concept ACK

Copy link
Contributor

@jnewbery jnewbery left a comment

Choose a reason for hiding this comment

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

Concept ACK

Copy link
Contributor

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"

Suggested change
/** 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.

Copy link
Member Author

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.

Copy link
Contributor

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.

Copy link
Member Author

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]>
Reported-by: practicalswift <[email protected]>
Signed-off-by: Antoine Poinsot <[email protected]>
@darosior darosior force-pushed the 20/07/refactor_feeest_code branch 2 times, most recently from 0a1eddb to a3abeec Compare September 14, 2020 14:23
@darosior
Copy link
Member Author

Thanks for the review. Cleaned up the logprint, used the m_ prefix, and made some variables const.

@jnewbery
Copy link
Contributor

utACK a3abeec

Copy link

@ariard ariard left a 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)
Copy link

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;
Copy link

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.

Copy link
Member

@maflcko maflcko left a 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
Copy link
Member

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

@fanquake fanquake merged commit ec9b449 into bitcoin:master Sep 29, 2020
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Sep 29, 2020
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
@darosior darosior deleted the 20/07/refactor_feeest_code branch January 12, 2021 21:35
deadalnix pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Dec 23, 2021
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
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Aug 16, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants