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

Refactor blockchaininterface: fee estimation code #1504

Merged
merged 1 commit into from
Jul 27, 2023

Conversation

kristapsk
Copy link
Member

Part of splitting #1462 into smaller PRs for easier reviewing and testing.

Copy link
Member

@PulpCattel PulpCattel left a comment

Choose a reason for hiding this comment

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

This PR refactors the estimate_fee_per_kb method. Mostly splitting it into multiple methods, adding the relevant abstract methods, and adding type hint.
Tests pass.

I think it should be possible to clean up the estimate_fee_per_kb method further. In particular, the difference between the two cases (block target and sat/vb) seems very small and maybe we could de-duplicate it further.

jmclient/jmclient/blockchaininterface.py Outdated Show resolved Hide resolved
jmclient/jmclient/blockchaininterface.py Outdated Show resolved Hide resolved
jmclient/jmclient/blockchaininterface.py Outdated Show resolved Hide resolved
jmclient/jmclient/blockchaininterface.py Outdated Show resolved Hide resolved
jmclient/jmclient/blockchaininterface.py Outdated Show resolved Hide resolved
jmclient/jmclient/blockchaininterface.py Outdated Show resolved Hide resolved
Comment on lines 470 to 478
# cannot be estimated in that case the 2nd highest priority
# should be used instead of falling back to hardcoded values
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 68352d0:

Since this is now a standalone method, we could remove the instead of falling back to hardcoded values, since it's not something this method should care/know about.

jmclient/jmclient/blockchaininterface.py Outdated Show resolved Hide resolved
jmclient/jmclient/blockchaininterface.py Outdated Show resolved Hide resolved
jmclient/test/commontest.py Outdated Show resolved Hide resolved
@kristapsk kristapsk force-pushed the refactor-fee-estimation branch from 20c3c5f to 936695a Compare July 26, 2023 07:51
@kristapsk
Copy link
Member Author

@PulpCattel I think I have addressed all the review comments, if this looks good, would like to squash and merge soon.

I think it should be possible to clean up the estimate_fee_per_kb method further. In particular, the difference between the two cases (block target and sat/vb) seems very small and maybe we could de-duplicate it further.

This could go as a follow up PR in future.

@kristapsk
Copy link
Member Author

@PulpCattel Looks ok now?

@PulpCattel
Copy link
Member

Yes, tested 36929c0. Tests pass, and I've done some basic manual testing on signet.

@kristapsk kristapsk force-pushed the refactor-fee-estimation branch from 36929c0 to 18a844b Compare July 27, 2023 11:31
mempoolminfee_in_sat, mempoolminfee_in_sat * float(1 + tx_fees_factor))

if self._fee_per_kb_has_been_manually_set(tx_fees):
N_res = random.uniform(tx_fees, tx_fees * float(1 - tx_fees_factor))
Copy link
Member Author

Choose a reason for hiding this comment

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

Here's typo bug (found by manual testing), should be + instead of -, will update soon.

Copy link
Member

Choose a reason for hiding this comment

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

Ah right, we randomize only upwards, so a lower value is a bug. Good catch.

This is one of the reasons we should eventually de-duplicate more out of this function.

Copy link
Member Author

Choose a reason for hiding this comment

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

Agree about de-duplication and also fee estimation code currently lacks any unit tests, that could have catched this.

@kristapsk kristapsk force-pushed the refactor-fee-estimation branch from 18a844b to d5c240b Compare July 27, 2023 12:01
@kristapsk
Copy link
Member Author

CI test failure is known unrelated issue that happens from time to time, merging.

@kristapsk kristapsk merged commit 54db582 into JoinMarket-Org:master Jul 27, 2023
@kristapsk kristapsk deleted the refactor-fee-estimation branch July 27, 2023 12:31
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.

2 participants