Skip to content

Conversation

ismaelsadeeq
Copy link
Member

@ismaelsadeeq ismaelsadeeq commented May 10, 2024

Another attempt at #25380 with an alternate approach

This PR updates CBlockPolicyEstimator to ignore all transactions that are CPFP'd by some child when a new block is received.
This fixes the assumption that all transactions are confirmed solely because of their fee rate.
As some transactions are confirmed due to a CPFP by some child.

This approach linearize all transactions removed from the mempool because of the new block, and only ignore transactions whose mining score is not the same with their the fee rate.

All transaction with in-mempool parent are already not tracked for fee estimation, so the child that CPFP'd the parent is also ignored.

Upon implementing the cluster mempool, we will just track chunks and make the fee estimator package aware.

@DrahtBot
Copy link
Contributor

DrahtBot commented May 10, 2024

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Code Coverage & Benchmarks

For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/30079.

Reviews

See the guideline for information on the review process.

Type Reviewers
Concept ACK instagibbs, josibake
Stale ACK rkrux

If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #33216 (mini miner: enable Linearize return package feerates by ismaelsadeeq)

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

LLM Linter (✨ experimental)

Possible typos and grammar issues:

  • In fees.h comment: “all transaction parents was added into the vector first” -> “all transaction parents were added into the vector first” [plural verb agreement]
  • In feature_fee_estimation.py log message: “ignore all transaction with in block child” -> “ignore all transactions with an in-block child” [plural noun and hyphenation]

drahtbot_id_4_m

@glozow
Copy link
Member

glozow commented May 10, 2024

cc @josibake @instagibbs @naumenkogs @darosior @murchandamus since you reviewed the last time

@instagibbs
Copy link
Member

concept ACK

strikes me as the right idea, keep it simple for now, focusing on correctness. Do we have charts anywhere tracking % of transactions that are in a cluster size of 1?

@ismaelsadeeq
Copy link
Member Author

Do we have charts anywhere tracking % of transactions that are in a cluster size of 1?

I will analyze the percentage of cluster size 1 transactions mined in previous blocks.

@josibake
Copy link
Member

Concept ACK

Copy link
Contributor

@rkrux rkrux left a comment

Choose a reason for hiding this comment

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

tACK c12a677

Make successful, all functional tests successful.
Mentioned few nits and asked few questions for my clarity.

The downside of this approach is that transactions that are not CPFP’d will aslo be ignored.

Related to this^, one specific case I can think of that will be affected is of layered transactions that are meant to be confirmed together, example: fanout transactions to increase the utxo count in the wallet and make the utxo value distribution more even, but Idk how frequently these transactions happen.

@DrahtBot DrahtBot requested review from instagibbs and josibake May 14, 2024 08:38
@ismaelsadeeq ismaelsadeeq force-pushed the 05-2023-ignore-transactions-with-parents branch from c12a677 to 2563305 Compare May 14, 2024 17:03
@ismaelsadeeq
Copy link
Member Author

Do we have charts anywhere tracking % of transactions that are in a cluster size of 1?

I will analyze the percentage of cluster size 1 transactions mined in previous blocks.

I tracked recent 1000 blocks from block 842457 to 843457

~61% of transactions in the last 1000 blocks were confirmed in a cluster size > 1.
~38% of transactions in the last 1000 blocks were confirmed in a cluster size 1

Transactions: 3974143
Cluster size 1 transactions: 1516505
Approximate percentage of Cluster size 1 transactions: ~38
Transactions in a cluster size > 1 transactions: 2457638
Approximate percentage of transactions in a cluster size > 1: ~61

The data is available here here https://docs.google.com/spreadsheets/d/1QTE2EQeQlamA123pIn0SY4F-9jtnzS7e7CV1etT6ytM/edit?usp=sharing

I used this script to collect the data https://gist.github.com/ismaelsadeeq/e2767040b720f65986976b3f8c6b7b20

@ismaelsadeeq
Copy link
Member Author

Thanks for review @rkrux

Copy link
Contributor

@rkrux rkrux left a comment

Choose a reason for hiding this comment

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

reACK 2563305

Thanks for the quick turnaround on this @ismaelsadeeq!

Copy link
Member

@josibake josibake left a comment

Choose a reason for hiding this comment

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

Looks good, although unclear to me why we don't also remove the child transaction from fee estimation to avoid overestimating. Would recommend also removing the children, or at least documenting why it doesn't matter in a comment.

@DrahtBot DrahtBot requested a review from josibake May 16, 2024 10:02
@laanwj laanwj added the Mempool label May 16, 2024
@bitcoin bitcoin deleted a comment from laib200 Jun 3, 2024
@ismaelsadeeq ismaelsadeeq force-pushed the 05-2023-ignore-transactions-with-parents branch from 2563305 to 57556e5 Compare June 3, 2024 12:55
@ismaelsadeeq ismaelsadeeq changed the title Fee Estimation: Ignore all transactions with an in-block child Fee Estimation: Ignore all transactions that are CPFP'd Jun 3, 2024
@ismaelsadeeq
Copy link
Member Author

ismaelsadeeq commented Jun 3, 2024

Do we have charts anywhere tracking % of transactions that are in a cluster size of 1?

I will analyze the percentage of cluster size 1 transactions mined in previous blocks.

I tracked recent 1000 blocks from block 842457 to 843457

~61% of transactions in the last 1000 blocks were confirmed in a cluster size > 1. ~38% of transactions in the last 1000 blocks were confirmed in a cluster size 1

Transactions: 3974143 Cluster size 1 transactions: 1516505 Approximate percentage of Cluster size 1 transactions: ~38 Transactions in a cluster size > 1 transactions: 2457638 Approximate percentage of transactions in a cluster size > 1: ~61

The data is available here here https://docs.google.com/spreadsheets/d/1QTE2EQeQlamA123pIn0SY4F-9jtnzS7e7CV1etT6ytM/edit?usp=sharing

I used this script to collect the data https://gist.github.com/ismaelsadeeq/e2767040b720f65986976b3f8c6b7b20

This data shows that most transactions are in cluster size > 1.

So I switched to ignoring transaction that are CPFP'd only.

Thanks for your reviews @rkrux @josibake

@ismaelsadeeq ismaelsadeeq force-pushed the 05-2023-ignore-transactions-with-parents branch from 57556e5 to 55d615c Compare June 3, 2024 14:57
@DrahtBot
Copy link
Contributor

DrahtBot commented Jun 3, 2024

🚧 At least one of the CI tasks failed. Make sure to run all tests locally, according to the
documentation.

Possibly this is due to a silent merge conflict (the changes in this pull request being
incompatible with the current code in the target branch). If so, make sure to rebase on the latest
commit of the target branch.

Leave a comment here, if you need help tracking down a confusing failure.

Debug: https://github.com/bitcoin/bitcoin/runs/25734218532

@ismaelsadeeq ismaelsadeeq force-pushed the 05-2023-ignore-transactions-with-parents branch from 55d615c to 055d9e6 Compare June 3, 2024 15:08
@josibake
Copy link
Member

I didn't look too closely into the CI failure reason, but seems like a relatively simple fix, i.e. fixing an signed int overflow:

SUMMARY: UndefinedBehaviorSanitizer: signed-integer-overflow node/mini_miner.cpp:196:33 
MS: 0 ; base unit: 0000000000000000000000000000000000000000
artifact_prefix='./'; Test unit written to ./crash-2315c89458602360eb93362328da5c0ef21f9864

Traceback (most recent call last):
  File "/ci_container_base/ci/scratch/build/bitcoin-x86_64-pc-linux-gnu/test/fuzz/test_runner.py", line 411, in <module>
    main()
  File "/ci_container_base/ci/scratch/build/bitcoin-x86_64-pc-linux-gnu/test/fuzz/test_runner.py", line 199, in main
    run_once(
  File "/ci_container_base/ci/scratch/build/bitcoin-x86_64-pc-linux-gnu/test/fuzz/test_runner.py", line 376, in run_once
    assert len(done_stat) == 1
           ^^^^^^^^^^^^^^^^^^^
AssertionError

@ismaelsadeeq ismaelsadeeq marked this pull request as draft June 10, 2024 10:12
@ismaelsadeeq
Copy link
Member Author

Marking as draft, as I attempt to fix the fuzzing overflow error.

@ismaelsadeeq ismaelsadeeq force-pushed the 05-2023-ignore-transactions-with-parents branch 2 times, most recently from 3f05950 to ba565be Compare June 13, 2024 19:03
@maflcko maflcko closed this Mar 18, 2025
@maflcko

This comment was marked as resolved.

@ismaelsadeeq

This comment was marked as resolved.

@DrahtBot DrahtBot reopened this Mar 18, 2025
@ismaelsadeeq ismaelsadeeq force-pushed the 05-2023-ignore-transactions-with-parents branch from 22726d4 to a02dd61 Compare March 20, 2025 08:01
@ismaelsadeeq
Copy link
Member Author

Rebased and fix comment by @yancyribbens

@josibake
Copy link
Member

Feel free to ignore me if this PR is close to merge, but it does feel like there are two PRs here. The first 3 commits seem more about updates to miniminer, and then the 4th commit does what the title of this PR indicates.

It may help to attract more review by breaking out the first 3 commits into their own PR, using this PR as a motivating use case. Either way, I plan to dig in more next week and review, but wanted to mention this.

@ismaelsadeeq ismaelsadeeq force-pushed the 05-2023-ignore-transactions-with-parents branch from 43d13e0 to bf2a05b Compare August 19, 2025 13:52
@ismaelsadeeq ismaelsadeeq force-pushed the 05-2023-ignore-transactions-with-parents branch from bf2a05b to 1aa6583 Compare August 19, 2025 15:14
ismaelsadeeq and others added 5 commits August 19, 2025 18:09
- GetTxAncestorsAndDescendants takes the vector of transactions removed from the mempool
  after a block is connected. The function assumed that the order the transactions were
  included in the block was maintained; that is, all transaction parents was be added
  into the vector first before descendants.

- GetTxAncestorsAndDescendants computes all the ancestors and descendants of the transactions.
  The transaction is also included as a descendant and ancestor of itself.

Co-authored-by: willcl-ark <will@256k1.dev>
- This method takes removed mempool transaction and generates
  an output that can be linearized by mini miner.

Co-authored-by: willcl-ark <will@256k1.dev>
Co-authored-by: Antoine Poinsot <darosior@protonmail.com>
@ismaelsadeeq
Copy link
Member Author

ismaelsadeeq commented Aug 19, 2025

Feel free to ignore me if this PR is close to merge, but it does feel like there are two PRs here. The first 3 commits seem more about updates to miniminer, and then the 4th commit does what the title of this PR indicates.

It may help to attract more review by breaking out the first 3 commits into their own PR, using this PR as a motivating use case. Either way, I plan to dig in more next week and review, but wanted to mention this.

Not close to merge I think, so far this PR received a couple of concept ACK and some initial review last year.

On the contrary the mini miner changes are tiny, but thats the first step, I opened #33216 for that.

The next two commits are preparing the removed mempool transactions for linearization by the mini miner.
by going over the transactions sequentially and appending their ancestors and descendant, the bulk of the diff is from the test in 80cb8d2

The subsequent three commits are the main feature and test.

Hence I think they can be bundled together.

In the latest pushes I moved the helper functions to fees for simplicity and make some improvement to the code.

@ismaelsadeeq ismaelsadeeq marked this pull request as draft August 19, 2025 17:23
@ismaelsadeeq
Copy link
Member Author

Putting in draft because of a dependent PR.

@josibake
Copy link
Member

Thanks for taking the suggestion of splitting this up! I think it would be nice to add a blurb to the description that this PR depends on #33216 and is in draft pending review on the parent PR. You mention this in the comments, but having it in the description ensures reviewers dont miss it / get confused on the status of the PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.