Skip to content

test: Add functional tests for blockreconstructionextratxn and extra pool (compactblocks) - #33023

Closed
bigshiny90 wants to merge 1 commit into
bitcoin:masterfrom
bigshiny90:compactblocks-extratxs-tests-core
Closed

test: Add functional tests for blockreconstructionextratxn and extra pool (compactblocks)#33023
bigshiny90 wants to merge 1 commit into
bitcoin:masterfrom
bigshiny90:compactblocks-extratxs-tests-core

Conversation

@bigshiny90

@bigshiny90 bigshiny90 commented Jul 20, 2025

Copy link
Copy Markdown

This tests the -blockreconstructionextratxn parameter and extra pool memory (ring buffer) behavior used specifically for compact block reconstruction. The "extra transaction pool" stores transactions that were rejected from the mempool for policy reasons (dust, low fees, non-standard scripts), txs replaced via rbf, etc…

There is no test coverage for this. (no unit tests either as the code being tested - in PeerManagerImpl - isn't publicly accessible in the net_processing.h file)

The code being tested is in src/net_processing.cpp - look for vExtraTxnForCompact, AddToCompactExtraTransactions and -blockreconstructionextratxn start arg.

This tests

Policy-rejected transactions are stored in the extra pool: Transactions rejected for being dust, having low fees, or using non-standard scripts are kept in the extra pool
Pool capacity limits work correctly: Tests various pool sizes. Default is 100.
Eviction behavior: When the extra pool is full, the oldest transactions are evicted (FIFO)
Wraparound behavior: The extra pool correctly wraps around when adding new transactions
Compact block reconstruction: These extra transactions are actually used during block reconstruction

Uses policy rejected transactions to populate the extra pool for tests.

(Updated 08/29/25: rebased to currrent master and fixed tests to accommodate new low-fee rate policy)

@DrahtBot DrahtBot added the Tests label Jul 20, 2025
@DrahtBot

DrahtBot commented Jul 20, 2025

Copy link
Copy Markdown
Contributor

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

Reviews

See the guideline for information on the review process.

Type Reviewers
ACK bensig

If your review is incorrectly listed, please copy-paste <!--meta-tag:bot-skip--> into the comment that the bot should ignore.

LLM Linter (✨ experimental)

Possible typos and grammar issues:

  • so we can eg wait until a particular block is announced. -> # so we can e.g. wait until a particular block is announced. [Uses standard abbreviation punctuation for "for example", improving clarity]

drahtbot_id_5_m

@DrahtBot

Copy link
Copy Markdown
Contributor

🚧 At least one of the CI tasks failed.
Task lint: https://github.com/bitcoin/bitcoin/runs/46342861746
LLM reason (✨ experimental): The CI failure is primarily caused by lint errors detected by ruff, including issues with trailing whitespace and possible spelling errors.

Hints

Try to run the tests locally, according to the documentation. However, a CI failure may still
happen due to a number of reasons, for example:

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

  • A sanitizer issue, which can only be found by compiling with the sanitizer and running the
    affected test.

  • An intermittent issue.

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

@bigshiny90
bigshiny90 force-pushed the compactblocks-extratxs-tests-core branch from 76f1896 to 3e93378 Compare July 23, 2025 11:51
@fanquake
fanquake marked this pull request as draft July 24, 2025 10:06
@bigshiny90
bigshiny90 force-pushed the compactblocks-extratxs-tests-core branch 3 times, most recently from 90f0f1d to a01547c Compare July 24, 2025 11:30
@bigshiny90

bigshiny90 commented Jul 24, 2025

Copy link
Copy Markdown
Author

updated to fix CI Lint errors

(also had to remove an unused param)

@fanquake
fanquake marked this pull request as ready for review July 24, 2025 11:47
@bigshiny90
bigshiny90 force-pushed the compactblocks-extratxs-tests-core branch from a01547c to 4985235 Compare July 24, 2025 12:16

@brunoerg brunoerg left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think the description is not clear about what you're trying to cover/achieve with the test. Can you explain it better? Also, corecheck doesn't show any related new coverage.

@bigshiny90

bigshiny90 commented Jul 24, 2025

Copy link
Copy Markdown
Author

I think the description is not clear about what you're trying to cover/achieve with the test. Can you explain it better? Also, corecheck doesn't show any related new coverage.

Added better description (hopefully) to PR

I'm not sure about corecheck, but i'll hazard a guess:

There are other tests that cover the p2p_compactblocks - so these tests seem to cover the same ground, though in reality they are testing something new. (also, the fact that most of what is being tested is not publicly exposed). Just a guess, as I don’t know how corecheck determines things

Hopefully answers the questions?

@bigshiny90 bigshiny90 changed the title test: Add functional tests for blockreconstructionextratxn parameter test: Add functional tests for blockreconstructionextratxn and extra pool (compactblocks) Jul 25, 2025
Comment thread test/functional/p2p_compactblocks_extratxs.py Outdated
@bigshiny90
bigshiny90 force-pushed the compactblocks-extratxs-tests-core branch from 4985235 to b4f34aa Compare July 29, 2025 22:02
@bigshiny90
bigshiny90 requested review from brunoerg and luke-jr July 29, 2025 22:05
@bigshiny90
bigshiny90 force-pushed the compactblocks-extratxs-tests-core branch from b4f34aa to bd1c6b4 Compare July 30, 2025 20:13
luke-jr pushed a commit to bitcoinknots/bitcoin that referenced this pull request Aug 4, 2025
This adds comprehensive functional tests for the extra transaction pool
used in compact block reconstruction, controlled by the
-blockreconstructionextratxn parameter.

Github-Pull: bitcoin#33023
Rebased-From: bd1c6b4ea9b94ab4b2604f2a4b8a7fd1fe55c92a

@kevkevinpal kevkevinpal left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I get the idea of testing the extra pool. I think some of the tests can be consolidated.

I did run the test locally, and it passes for me. I haven't checked code coverage either to see if it covers anything extra,

but grep -nri "blockreconstructionextratxn" ./test/functional/ does not have any matches

Comment on lines 383 to 390

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This seems misplaced for this test test_extratxn_invalid_parameters

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

removed. now just tests for invalid capacity -1

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

instead of 8 can you make this num_txs - count, it makes sense to not have magic numbers

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

done

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

what is the point of testing with 2 when you have another test, testing with 1?

@bigshiny90 bigshiny90 Aug 25, 2025

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

yes, removed redundant test - test_extratxn_minimal_capacity_eviction

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If you could why not set buffersize to 400, and then after checking the capacity test the wrap around?

Then you can drop test_extratxn_large_capacity and test_extratxn_buffer_wraparound seems redundant to do the setup multiple times when they can be done in the same test.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I combined the 3 separate tests - test_extratxnpool_capacity, test_extratxn_large_capacity, test_extratxn_buffer_wraparound - and created one test test_extratxnpool_capacity_and_wraparound, which tests capacity 400 and wraparound behavior

@bigshiny90
bigshiny90 force-pushed the compactblocks-extratxs-tests-core branch from bd1c6b4 to f9c6331 Compare August 25, 2025 23:40
@bigshiny90
bigshiny90 requested a review from kevkevinpal August 25, 2025 23:46
luke-jr pushed a commit to bitcoinknots/bitcoin that referenced this pull request Aug 28, 2025
This adds comprehensive functional tests for the extra transaction pool
used in compact block reconstruction, controlled by the
-blockreconstructionextratxn parameter.

Github-Pull: bitcoin#33023
Rebased-From: f9c6331cb26f3bafc3dba7f5a72622a9ff4f190d
@DrahtBot

Copy link
Copy Markdown
Contributor

Could turn into draft while CI is red?

@bigshiny90

bigshiny90 commented Aug 29, 2025

Copy link
Copy Markdown
Author

investigating why tests fail on github CI... but runs fine on a local build

This adds comprehensive functional tests for the extra transaction pool
used in compact block reconstruction, controlled by the
-blockreconstructionextratxn parameter.
@bigshiny90
bigshiny90 force-pushed the compactblocks-extratxs-tests-core branch from f9c6331 to 841b3c2 Compare August 29, 2025 13:59
@bigshiny90

Copy link
Copy Markdown
Author

needed to rebase to current master and fix tests for the new lower fee-rate policy.

@bensig

bensig commented Jan 2, 2026

Copy link
Copy Markdown
Contributor

ACK 841b3c2

Tested locally on macOS - all test cases pass.

Good coverage for the extra transaction pool used in compact block reconstruction. Tests policy-rejected txs (dust, low_fee, nonstandard), pool capacity limits, FIFO eviction, and edge cases.

nit: The ✓ emojis in log messages are a bit unconventional compared to other functional tests, but doesn't affect functionality

result = self.send_compact_block(tx_list, indices)

assert_equal(result["missing_indices"], [])
self.log.info("✓ All rejected transactions are available in extra pool")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All these info messages on completion should be removed in my opinion.

# Check original transactions again - first one should be evicted
result2 = self.send_compact_block(rejected_txs, indices)
assert_equal(result2["missing_indices"], [0])
self.log.info("✓ Transaction 0 was evicted as expected (wraparound)")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All these info messages on test completion should be removed imo.

@sedited

sedited commented Apr 19, 2026

Copy link
Copy Markdown
Contributor

Are you still working on this? There are unaddressed review comments.

@fanquake
fanquake marked this pull request as draft May 7, 2026 10:08
@fanquake

fanquake commented Jun 1, 2026

Copy link
Copy Markdown
Member

Closing for now. Let us know if you're coming back to this.

@fanquake fanquake closed this Jun 1, 2026
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.

8 participants