Skip to content

backport: Merge bitcoin/bitcoin#29031#7388

Draft
vijaydasmp wants to merge 1 commit into
dashpay:developfrom
vijaydasmp:July_2026_3
Draft

backport: Merge bitcoin/bitcoin#29031#7388
vijaydasmp wants to merge 1 commit into
dashpay:developfrom
vijaydasmp:July_2026_3

Conversation

@vijaydasmp

Copy link
Copy Markdown

bitcoin back ports

…ness

15f5a0d fuzz: Improve fuzzing stability for txorphan harness (dergoegge)

Pull request description:

  The `txorphan` harness has low stability as eviction of orphan txs is entirely random at the moment.

  Fix this by passing the rng to `LimitOrphans`, which can be deterministic in tests.

  Also see bitcoin#29018.

ACKs for top commit:
  maflcko:
    lgtm ACK 15f5a0d
  brunoerg:
    utACK 15f5a0d

Tree-SHA512: 854ec34b3a0f16f26db6dc419096c6e7a380e8400119534aa278d6b1d54c253b572aa2fad13c383c796c431d8ff4263956e6f60326e99f8bf6abd16d9a280e97
@github-actions

Copy link
Copy Markdown

✅ No Merge Conflicts Detected

This PR currently has no conflicts with other open PRs.

@vijaydasmp vijaydasmp marked this pull request as ready for review June 28, 2026 09:15
@vijaydasmp vijaydasmp marked this pull request as draft June 28, 2026 09:17

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7deb6fb067

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/net_processing.cpp
// DoS prevention: do not allow m_orphans to grow unbounded (see CVE-2012-3789)
unsigned int nMaxOrphanTxSize = (unsigned int)std::max((int64_t)0, gArgs.GetIntArg("-maxorphantxsize", DEFAULT_MAX_ORPHAN_TRANSACTIONS_SIZE)) * 1000000;
m_orphanage.LimitOrphans(nMaxOrphanTxSize);
m_orphanage.LimitOrphans(nMaxOrphanTxSize, m_rng);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Add the missing RNG member before using it

This call now passes m_rng, but PeerManagerImpl does not declare any m_rng member or otherwise define that name (repo-wide search only finds this new use). As soon as net_processing.cpp is compiled, this path fails to build with an undeclared identifier; add the intended FastRandomContext member or pass an existing RNG.

Useful? React with 👍 / 👎.

Comment thread src/txorphanage.cpp
}

void TxOrphanage::LimitOrphans(unsigned int max_orphans_size)
void TxOrphanage::LimitOrphans(unsigned int max_orphans_size, FastRandomContext& rng)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Remove the shadowing RNG declaration

Adding the rng parameter here leaves the existing FastRandomContext rng; declaration later in the same function body, so txorphanage.cpp redeclares the parameter name and fails to compile. Remove the local declaration and use the injected RNG for the eviction loop.

Useful? React with 👍 / 👎.

@coderabbitai

coderabbitai Bot commented Jun 28, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

TxOrphanage::LimitOrphans is updated to accept an explicit FastRandomContext& parameter instead of constructing its own RNG internally. The header declaration and .cpp definition are both changed. All three call sites are updated: PeerManagerImpl::ProcessMessage passes m_rng, the fuzz target introduces a local deterministic FastRandomContext and passes it, and the DoS_mapOrphans unit test constructs a deterministic FastRandomContext for its three LimitOrphans calls.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Suggested reviewers

  • knst
  • PastaPastaPasta
  • UdjinM6
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately identifies this as a backport merge of bitcoin#29031, which matches the PR's main purpose.
Description check ✅ Passed The description is brief, but it is still related to the changeset as a Bitcoin backport.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/txorphanage.cpp (1)

119-149: 🎯 Functional Correctness | 🔴 Critical | ⚡ Quick win

Remove the stale local RNG declaration.

FastRandomContext rng; redeclares the rng parameter in the same scope, so this won’t compile. It also drops the caller-supplied RNG needed by this path.

Suggested fix
 void TxOrphanage::LimitOrphans(unsigned int max_orphans_size, FastRandomContext& rng)
 {
     LOCK(m_mutex);
@@
-    FastRandomContext rng;
     while (!m_orphans.empty() && m_orphan_tx_size > max_orphans_size)
     {
         // Evict a random orphan:
         size_t randompos = rng.randrange(m_orphan_list.size());
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/txorphanage.cpp` around lines 119 - 149, In TxOrphanage::LimitOrphans,
remove the stale local FastRandomContext declaration that shadows the rng
parameter and prevents compilation. Keep using the caller-supplied rng argument
for the random eviction path, and make sure the call to randrange in the orphan
eviction loop uses that existing parameter rather than a new local variable.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@src/txorphanage.cpp`:
- Around line 119-149: In TxOrphanage::LimitOrphans, remove the stale local
FastRandomContext declaration that shadows the rng parameter and prevents
compilation. Keep using the caller-supplied rng argument for the random eviction
path, and make sure the call to randrange in the orphan eviction loop uses that
existing parameter rather than a new local variable.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 7f9f4f53-6c87-41fa-92f4-66bf335723a1

📥 Commits

Reviewing files that changed from the base of the PR and between ebfdb8b and 7deb6fb.

📒 Files selected for processing (5)
  • src/net_processing.cpp
  • src/test/fuzz/txorphan.cpp
  • src/test/orphanage_tests.cpp
  • src/txorphanage.cpp
  • src/txorphanage.h

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