Skip to content

private broadcast: limit outstanding txs to count of 10,000 - #35406

Merged
fanquake merged 3 commits into
bitcoin:masterfrom
instagibbs:2026-05-private_cap
Jul 7, 2026
Merged

fanquake merged 3 commits into
bitcoin:masterfrom
instagibbs:2026-05-private_cap

Conversation

@instagibbs

@instagibbs instagibbs commented May 28, 2026 •

Copy link
Copy Markdown
Member

Add a belt-and-suspenders feature, limit the amount of memory and cpu possible when unlucky or simply misconfigured. The worst case limit is roughly 400kB * 10,000 = 4GB, regardless of usage pattern.

Before this change, sheer volume of broadcasts, mismatches in standardness rules, or simply fee mismatches may result in unbounded growth of memory usage. As the feature may be expanded in the future, explicit bounds helps reasoning going forward.

@DrahtBot

DrahtBot commented May 28, 2026 •

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

Reviews

See the guideline for information on the review process.

Type Reviewers
ACK vasild, andrewtoth, frankomosh, stickies-v
Stale ACK optout21

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

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #35315 (refactor: Use NodeClock::time_point in more places by maflcko)
  • #35252 (net: send decoy transactions via private broadcast by andrewtoth)
  • #35016 (net: deduplicate private broadcast state and snapshot types by kenji-yamam0to)
  • #34628 (p2p: Replace per-peer transaction rate-limiting with global rate limits by ajtowns)
  • #34271 (net_processing: make m_tx_for_private_broadcast optional by vasild)
  • #29700 (kernel, refactor: return error status on all fatal errors by ryanofsky)

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.

@fanquake

Copy link
Copy Markdown
Member

Is this for backport?

@instagibbs

Copy link
Copy Markdown
Member Author

@fanquake worthy of backport for safety and user expectations going forward imo

Comment thread src/private_broadcast.cpp Resolved
@instagibbs
instagibbs force-pushed the 2026-05-private_cap branch 2 times, most recently from 9a7c6b7 to 4014592 Compare May 28, 2026 20:05
Comment thread src/test/private_broadcast_tests.cpp Resolved
Comment thread src/rpc/mempool.cpp Resolved
def set_test_params(self):
self.num_nodes = 1
# -privatebroadcast is incompatible with the framework's default
# -connect=0; allow autoconnect (no actual peers will succeed though).

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.

We can use the -maxconnections=0 workaround for this if needed (not sure it's needed).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

leaving as is

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

ACK 401459243159e34fed93dc3ae1ec19c1c19075fc

Reviewed code, executed tests locally, LGTM.

This PR adds a safety-net max limit for the private broadcast queue.
While it can be argued that over-use is not very likely and not very catastrophic (usage through protected RPC interface, modest expected regular usage, reduced memory usage), it is good practice to have safety limits in place. It makes the risk explicit (however small), and introduces a "just in case" limit.
The limit of 1000 transaction is mostly arbitrary number, and not configurable. This is perfectly acceptable, having in mind the low-probability, low-harm nature of the queue being full.

Comment thread src/rpc/mempool.cpp Resolved
Comment thread src/private_broadcast.cpp Outdated
return inserted;
if (!m_transactions.try_emplace(tx).second) return false;

if (m_transactions.size() > MAX_TRANSACTIONS) {

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.

de1059f private broadcast: limit outstanding txs to count of 1000:

The implicit assumption here is that size exceeds max by exactly one. This is true, for as long as adding only happens only through Add, and never simultaneously. Changing the if to while would be more robust -- it's not really needed, but it's worth considering.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

We have the trailing Assume() that would catch this in debug builds, I think it's easiest to think about this way? Leaving as is.

@instagibbs
instagibbs force-pushed the 2026-05-private_cap branch from 4014592 to 9aeb4f8 Compare May 29, 2026 13:29

@stickies-v stickies-v 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.

Concept ACK for bounding resource usage.

Approach-wise, did you consider letting sendrawtransaction error instead of dropping the oldest tx? When it fails, user can use abortprivatebroadcast to drop what they want, rather than us doing it silently.

Comment thread src/private_broadcast.cpp Outdated
m_transactions, {},
[](const auto& el) { return el.second.time_added; })};
const CTransactionRef& tx_to_evict{oldest->first};
LogDebug(BCLog::PRIVBROADCAST,

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 this should be LogInfo at least?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Now that the caller is getting an error, going to leave it as debug

@andrewtoth

Copy link
Copy Markdown
Contributor

Approach-wise, did you consider letting sendrawtransaction error instead of dropping the oldest tx?

Might be easiest way, just do a length check in Add and return false if max or higher.

@instagibbs

instagibbs commented May 29, 2026 •

Copy link
Copy Markdown
Member Author

Approach-wise, did you consider letting sendrawtransaction error instead of dropping the oldest tx? When it fails, user can use abortprivatebroadcast to drop what they want, rather than us doing it silently.

In the misconfigured scenario, I think either strategy works just fine, we just don't want to crash and nothing is propagating for some reason.

In the high volume scenario, where we were simply wrong about how users intend to use it (now or going forward), they will have to know about and able to handle this explicitly (I have low confidence that people are doing sensible things with our weird error reporting fwiw).

One pro of explicit handling is that the caller will never be surprised that something ended up being dropped.

I'm slightly predisposed to handling it implicitly and allowing naive rebroadcasting to "fix" things, but I can see it both ways.

@andrewtoth

Copy link
Copy Markdown
Contributor

I think hitting this means something is misconfigured, so explicitly erroring will alert the user to the issue. I would be in favor of @stickies-v's approach.

@stickies-v

Copy link
Copy Markdown
Contributor

they will have to know about and able to handle this explicitly

Isn't that true regardless? When we silently drop, they'll need to (well, should) track / manage submitted txs and implement logic on how/when to retry the tx. Regardless, from an interface design pov, I think explicit is better than implicit.

Not familiar with wallet, so just my 2c, won't push back on it further.

@instagibbs

instagibbs commented May 29, 2026 •

Copy link
Copy Markdown
Member Author

so explicitly erroring will alert the user to the issue.

Just noting again to be clear: Outside of manual use I expect the error to simply be ignore/logged by many integrations, along with "already in mempool" kinda messages.

I suppose with good docs, the error-ignoring user can simply check the broadcast set, evict whatever the like, and it will self-heal next attempt at broadcasting.

I think hitting this means something is misconfigured

We shouldn't ignore usage patterns that plausibly exist. Question is what is best when our assumptions are violated.

Isn't that true regardless? When we silently drop, they'll need to (well, should) track / manage submitted txs and implement logic on how/when to retry the tx.

The caller knows a tx isn't being confirmed by looking at blocks and calls sendrawtransaction again. No need to even look at error messages in normal operation with or without private broadcast.

Regardless, from an interface design pov, I think explicit is better than implicit.

Agreed. I think with good docs it can be made idiot proof. Let me get that implemented.

@vasild

vasild commented May 29, 2026

Copy link
Copy Markdown
Contributor

A few thoughts:

  • Just 1000? The OP says 400kB * 1000 = 400MB, but where did that 400kB come from? A typical transaction is a few hundred bytes. Plus some storage overhead, I think we can reasonably assume one transaction takes 500-1000 bytes of RAM in the private broadcast queue. So, in 400MB one can store about 400'000 transactions, conservatively.

  • I think it would be better to return an immediate error from the sendrawtransaction RPC because then the user (or the user program driving this):

  1. knows which transaction couldn't be sent - the one it got error about
  2. is more likely to have the transaction at hand so it can retry after a short wait for the queue to empty
    otherwise "some of the transactions you scheduled some time ago was dropped but you do not know which one". That is harder to handle.
  • I guess Bitcoin Core runs on a variety of hardware. Maybe some machines have 100x more RAM than others. It is not reasonable to assume that one number will fit all. So consider making this manually configurable via config option (eh :/) or set it internally based on the amount of RAM available.

@instagibbs

Copy link
Copy Markdown
Member Author

Just 1000? The OP says 400kB * 1000 = 400MB, but where did that 400kB come from?

it's the currently maximum sized transaction we will accept into our mempool (or private broadcast set). I think the simplest alternative is to have the serialized sized accounting instead of pure tx accounting, so the average case would be much higher and unlikely to be hit. Just increases the required testing a bit, and users rectifying it would have to abandon a variable amount of stuck broadcasts to make room for new ones.

I think I'd rather bump this number a few X and keep the accounting / abandon flow as simple as possible.

I guess Bitcoin Core runs on a variety of hardware. Maybe some machines have 100x more RAM than others. It is not reasonable to assume that one number will fit all. So consider making this manually configurable via config option (eh :/) or set it internally based on the amount of RAM available.

eh same to me, would rather we keep things as simple as possible unless there is real demand for something other than a anti-footgun

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

ACK 4e29de7

Show Signature
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

ACK 4e29de719e6dc2a080f8a0c00cd137d3cd4dac96
-----BEGIN PGP SIGNATURE-----

iQRPBAEBCAA5FiEE5k2NRWFNsHVF2czBVN8G9ktVy78FAmpH62QbFIAAAAAABAAO
bWFudTIsMi41KzEuMTIsMiwzAAoJEFTfBvZLVcu/D9Af/jYQkC9sv7v1eb9AzExV
/9GmKlG+8wKAedBY3BgyoUzeykxq0FLSN3zRGHk9R5E0IJ5qiPveQhOApXqrNEQR
ajdUVCHAef+wX8pbcR2r+6IrqcrUF7AAsT3BC1XHMvsbG8ErMJ+WpiBuE1S9Ipw1
hM2i8nmX9g2Yp6Pd2sTaucEu4mgEl4fENm97SwJfo7SXKoMPM77JXtROrnjeiJO6
6gnm0Wtng0JkqQVCkjYSGgbcsVXAkgLB0+3P4IVYtrLE/zKbiZEJzK0f1wj9t1Og
gaMTGboNpznh6FqIv/CQMdeWAC9pLeSyiB5ukmoWAEsUgvdwtiLnO4k4n3TCoiQY
7awRa0+I5qUopdURewV+U9X9xn/CijZWjLuk2DKz38G8etSqMpzj/AY0ndop9n52
RXzQvRM6GkvrlBjzrDv24stpQR9Mk4abvymSynrTzs+kNSN0yJWbYvXiP4nhmXn0
P9dR0k109UY32y+QFCMMy7H1Tp3S+xg9yEPC98y/W2JV1KjdPJ7SFVLyatjLZAo8
XdGg00crmd3f5hyuHghFc62RvAG86jn+Y4BFNp3IhUYUhxeExoN6xFIM785QPINO
k9e226pa/mZ5sMnvjcfSWaZorwI+0S+jU3GjMxCu0z1iM2hNJHuQp57rks8OaJJh
sdekUst4HyMPwmOvLfgsHRq2+Cr6iX7mvYzjt0/W+jIg71r3xwNSRG7A80KCUWZ5
Ksp6w22242HppXeCfll3QnUh1a8J2gV2oF0WXBB6/e4/lE9adI/5VI5lECJoAGnm
pTRAigTyHbeFjfPRyNupRGr5oSkVMCvAoucWwgerEzsLC/R8TYRTUEKY+mEdPCB+
+mF/jFNmJPpfdrQ3PN0ucM8PyYD7ht5WVHY5VbPO2KMacfIvtxqOuUuVZQ2JdZpV
19NVwAvuXT7tLYozlQFVzfBLEmhWV61KGLD5NpZVw9deCwOJmUF9CHNvxsSNX3KE
YHOCw92DMEnYhwxIQ7tPAcJgXbAZhvp2IrETQHEcsQzVD6Bu/J8zm1zCXzp9Z2s5
jE1qpdpwWA6jisDcIi6DzCOfhoSAVHiN2MSD1KmqG303VewLxvUf0ck3Rc9snySo
L6OKh+/aptApkGOh4waOdCijV73KLkjpluPeDUK7TL+BgDF8mxVJRbxpnWrk0M14
Drc9fsUJAJb+GE4XfAdcIyP7pEJcxELh9Rz985jpLCrDvj7OV63rG3Tb27J2yNOU
/kXbg7Iz0JTLlVcwTUoP3E3lbD2VN6K8zMhIBm2DC0W9fUXvg8gdaB1DGK7b0XCH
rZCxcabN78VA3LicgkcwGAdZV+c/xZ/GcDjaOgOrBRxF543t/2dyaE2qJQcrTBs0
LRM=
=qeFE
-----END PGP SIGNATURE-----

vasild's public key is on openpgp.org

Comment on lines +207 to +209
// A previously-removed tx can be added again as a brand-new entry
BOOST_REQUIRE(pb.Remove(fresh).has_value());
BOOST_CHECK(pb.Add(txs[0]) == PrivateBroadcast::AddResult::Added);

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 is correct because txs[0] was removed earlier. But looking at this snippet in isolation I find it a bit confusing because it removes one transaction and adds another one. I would expect the snippet that checks "A previously-removed tx can be added again as a brand-new entry" to do "remove X, add X".

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

seems to be an old comment? resolving, please speak up if not


BOOST_CHECK(pb.Add(tx1));
BOOST_CHECK(!pb.Add(tx1));
BOOST_CHECK(pb.Add(tx1) == PrivateBroadcast::AddResult::Added);

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.

Suggested change
BOOST_CHECK(pb.Add(tx1) == PrivateBroadcast::AddResult::Added);
BOOST_CHECK_EQUAL(pb.Add(tx1), PrivateBroadcast::AddResult::Added);

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

will do if I touch commit again

BOOST_CHECK(pb.Add(tx1));
BOOST_CHECK(!pb.Add(tx1));
BOOST_CHECK(pb.Add(tx1) == PrivateBroadcast::AddResult::Added);
BOOST_CHECK(pb.Add(tx1) == PrivateBroadcast::AddResult::AlreadyPresent);

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.

Suggested change
BOOST_CHECK(pb.Add(tx1) == PrivateBroadcast::AddResult::AlreadyPresent);
BOOST_CHECK_EQUAL(pb.Add(tx1), PrivateBroadcast::AddResult::AlreadyPresent);

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

will do if I touch commit again


// Make another transaction with same txid, different wtxid and add it.
const auto tx2{MakeDummyTx(/*id=*/1, /*num_witness=*/1)};
BOOST_REQUIRE(tx1->GetHash() == tx2->GetHash());

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.

Suggested change
BOOST_REQUIRE(tx1->GetHash() == tx2->GetHash());
BOOST_REQUIRE_EQUAL(tx1->GetHash(), tx2->GetHash());

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

don't think this is me

txs.reserve(num_cap);
for (size_t i{0}; i < num_cap; ++i) {
auto tx{MakeDummyTx(/*id=*/static_cast<uint32_t>(i), /*num_witness=*/0)};
BOOST_REQUIRE(pb.Add(tx) == PrivateBroadcast::AddResult::Added);

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.

Suggested change
BOOST_REQUIRE(pb.Add(tx) == PrivateBroadcast::AddResult::Added);
BOOST_REQUIRE_EQUAL(pb.Add(tx), PrivateBroadcast::AddResult::Added);

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

will do if I touch commit again

// Further distinct transactions are rejected, and the queue is unchanged.
for (size_t i{0}; i < num_over; ++i) {
const auto tx{MakeDummyTx(/*id=*/static_cast<uint32_t>(num_cap + i), /*num_witness=*/0)};
BOOST_CHECK(pb.Add(tx) == PrivateBroadcast::AddResult::QueueFull);

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.

Suggested change
BOOST_CHECK(pb.Add(tx) == PrivateBroadcast::AddResult::QueueFull);
BOOST_CHECK_EQUAL(pb.Add(tx), PrivateBroadcast::AddResult::QueueFull);

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

will do if I touch commit again

}

// Re-adding an already-present tx is AlreadyPresent even at the cap (not QueueFull).
BOOST_CHECK(pb.Add(txs[0]) == PrivateBroadcast::AddResult::AlreadyPresent);

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.

Suggested change
BOOST_CHECK(pb.Add(txs[0]) == PrivateBroadcast::AddResult::AlreadyPresent);
BOOST_CHECK_EQUAL(pb.Add(txs[0]), PrivateBroadcast::AddResult::AlreadyPresent);

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

will do if I touch commit again

BOOST_REQUIRE(pb.Remove(txs[0]).has_value());
BOOST_CHECK_EQUAL(pb.GetBroadcastInfo().size(), num_cap - 1);
const auto fresh{MakeDummyTx(/*id=*/0xffffffff, /*num_witness=*/0)};
BOOST_CHECK(pb.Add(fresh) == PrivateBroadcast::AddResult::Added);

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.

Suggested change
BOOST_CHECK(pb.Add(fresh) == PrivateBroadcast::AddResult::Added);
BOOST_CHECK_EQUAL(pb.Add(fresh), PrivateBroadcast::AddResult::Added);

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

will do if I touch commit again


// A previously-removed tx can be added again as a brand-new entry
BOOST_REQUIRE(pb.Remove(fresh).has_value());
BOOST_CHECK(pb.Add(txs[0]) == PrivateBroadcast::AddResult::Added);

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.

Suggested change
BOOST_CHECK(pb.Add(txs[0]) == PrivateBroadcast::AddResult::Added);
BOOST_CHECK_EQUAL(pb.Add(txs[0]), PrivateBroadcast::AddResult::Added);

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

will do if I touch commit again

@DrahtBot
DrahtBot requested a review from frankomosh July 3, 2026 17:04

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

ACK 4e29de7


BOOST_AUTO_TEST_CASE(rejection_at_cap)
{
PrivateBroadcast pb;

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.

We could use a custom max count here to test non-default?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I added the custom cap to make fuzz target more efficient; leaving as-is unless I'm missing a wrinkle

@frankomosh

frankomosh commented Jul 5, 2026 •

Copy link
Copy Markdown
Contributor

tACK 4e29de7. Ran private_broadcast_tests and p2p_private_broadcast_cap.py. Great to have an explicit bound as the belt-and-suspenders against unbounded queue growth.

@instagibbs

Copy link
Copy Markdown
Member Author

Not touching commits for now, thanks for all the review everyone so far!

@stickies-v stickies-v 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.

ACK 4e29de7

I think the RPC_OUT_OF_MEMORY code sets bad precedent and I would prefer it being fixed in this PR, but am also happy open to open a follow-up if the author disagrees, so not considered blocking.

Comment thread src/rpc/util.cpp
case TransactionError::ALREADY_IN_UTXO_SET:
return RPC_VERIFY_ALREADY_IN_UTXO_SET;
case TransactionError::PRIVATE_BROADCAST_FULL:
return RPC_OUT_OF_MEMORY;

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 don't think RPC_OUT_OF_MEMORY is a sane code to use here. OOM is a fairly general and well established term, and I don't think we should give the wrong impression here that the server is running out of memory when it isn't.

RPC_OUT_OF_MEMORY usage was removed in commits cf0c47b and dd87b6d. In both cases, it seems like the implementation wrongly assumed there were OOM issues from a failing new resulting in a nullptr, when actually std::bad_alloc would've been throw, so the RPC_OUT_OF_MEMORY code was seemingly intended for memory allocation issues but never actually used that way. (note: until cf0c47b, the RPC_OUT_OF_MEMORY code could also be returned for failing wallet keypool issues, which doesn't seem OOM related at all).

The impact is probably limited, so I don't think this should be a blocker, so I'm happy to leave as-is if you prefer, but I wanted to raise that I think this sets bad precedent. Adding a dedicated RPC code seems straightforward enough.

Comment thread src/private_broadcast.cpp


bool PrivateBroadcast::Add(const CTransactionRef& tx)
[[nodiscard]] PrivateBroadcast::AddResult PrivateBroadcast::Add(const CTransactionRef& tx)

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.

nit: [[nodiscard]] is a declaration attribute, and it's correctly set in the header (sorry, I'm aware I left earlier comment in the wrong place)

Suggested change
[[nodiscard]] PrivateBroadcast::AddResult PrivateBroadcast::Add(const CTransactionRef& tx)
PrivateBroadcast::AddResult PrivateBroadcast::Add(const CTransactionRef& tx)

@fanquake
fanquake merged commit 4498fa5 into bitcoin:master Jul 7, 2026
26 checks passed
@stickies-v

Copy link
Copy Markdown
Contributor

Opened #35678 to address the RPC error code, and other outstanding suggestions/nits I found here. Ping me if there are any I've missed that you'd like to add.

sedited added a commit that referenced this pull request Jul 8, 2026
…D error code ( + other follow-ups)

8ac2224 private broadcast: remove no-op [[nodiscard]] (stickies-v)
191bdcb test: align test better with described scenario (stickies-v)
7ad311b test: use BOOST_CHECK_EQUAL for PrivateBroadcast::AddResult (stickies-v)
82a02a2 rpc: define and use new  RPC_LIMIT_EXCEEDED error code (stickies-v)

Pull request description:

  The server isn't running out of memory when the private broadcast transaction queue is full. Add and use a new `-37` (`RPC_LIMIT_EXCEEDED`) code that can be used whenever a resource is bound and currently at capacity.

  Addresses #35406 (comment)

  Also includes commits to address other outstanding suggestions/nits from #35406:
  - no-op `[[nodiscard]]`: #35406 (comment)
  - use `BOOST_CHECK_EQUAL`: #35406 (comment)
  - improve clarity remove-add test case: #35406 (comment)

ACKs for top commit:
  instagibbs:
    ACK 8ac2224
  andrewtoth:
    ACK 8ac2224
  sedited:
    ACK 8ac2224

Tree-SHA512: c5e0220060770032f3fea54beaabd1d14179a18df3c3e9c25e9f547ad893cea91e2f4b180dd28ad20f09a3cb6b063fad267caab792ee9727f52a2d49f4508523
oleonardolima added a commit to oleonardolima/rust-bitcoinkernel that referenced this pull request Jul 9, 2026
…05fc7ab

81405fc7ab Merge bitcoin/bitcoin#35689: test: Inline incorrect check in `util_tests`
cd2a4bc510 test: Redeclare variable as signed in `util_tests`
6f1c56f03a Merge bitcoin/bitcoin#35670: net: optimize compact block extra tx iteration
e94fda8a40 Merge bitcoin/bitcoin#35685: doc: Archive 30.3 release notes
5223cf1795 Merge bitcoin/bitcoin#35616: refactor: Use u64 over size_t for all cache sizes to fix a 32-bit overflow
c0e91efdb3 Merge bitcoin/bitcoin#35295: validation: fetch block input prevouts in parallel during ConnectBlock
f0da26cfc8 Merge bitcoin/bitcoin#34997: p2p: Don't participate in addr relay with feelers
443179a9eb doc: Archive 30.3 release notes
fabafd91f1 refactor: Use u64 over size_t for all cache sizes to fix a 32-bit overflow
32941e1314 Merge bitcoin/bitcoin#35649: depends: move FreeBSD SDK handling to CI
f379d716b1 Merge bitcoin/bitcoin#35669: doc: archive release notes for v31.1
881bb7b355 Merge bitcoin/bitcoin#35673: refactor: Move LoadGenesisBlock to ChainstateManager
3f3e644beb Merge bitcoin/bitcoin#35678: private broadcast: define and use new RPC_LIMIT_EXCEEDED error code ( + other follow-ups)
e3b026bf56 Merge bitcoin/bitcoin#34020: mining: add getTransactions(ByWitnessID) IPC methods
62f9089343 Merge bitcoin/bitcoin#35386: doc: add an AI contribution policy
fa615bd163 refactor: Move LoadGenesisBlock to ChainstateManager
8ac222484c private broadcast: remove no-op [[nodiscard]]
191bdcba26 test: align test better with described scenario
7ad311be18 test: use BOOST_CHECK_EQUAL for PrivateBroadcast::AddResult
82a02a2a22 rpc: define and use new  RPC_LIMIT_EXCEEDED error code
a64df338e6 Merge bitcoin/bitcoin#35651: doc: Improve offline-signing-tutorial after 32489
4498fa5d5b Merge bitcoin/bitcoin#35406: private broadcast: limit outstanding txs to count of 10,000
ec5edcd72b Merge bitcoin/bitcoin#35661: Update libmultiprocess subtree to add `ThreadMap.makePool` method
ea67fea062 Merge bitcoin/bitcoin#35464: kernel: Add function for creating chainparams with a signet challenge
a7b5f23bb8 Merge bitcoin/bitcoin#35667: refactor: Use `NetworkErrorString` for macOS code in `netif.cpp`
69fc991791 Merge bitcoin/bitcoin#32606: p2p: Drop unsolicited CMPCTBLOCK from non-HB peer and when blocksonly
1a3cbf1bd2 net: optimize compact block extra tx iteration
bc33509ae2 Merge bitcoin/bitcoin#35650: doc: Add release notes for 32489 (exportwatchonlywallet RPC)
2b6e767d96 doc: archive release notes for v31.1
b0735336ee p2p: Don't participate in addr relay with feeler connections
302733fd96 Merge bitcoin/bitcoin#35652: init: fix reindex deadlock by waking cv after interrupt
c1313b199f init: wake genesis wait after ImportBlocks() returns
eccb04a321 refactor: Use `NetworkErrorString` for macOS code in `netif.cpp`
f79ecfd9c7 Merge bitcoin/bitcoin#35658: refactor: Drop unneeded `<sys/types.h>` include before `<ifaddrs.h>`
22ac4ad949 ci: ensure we use correct lld version in OpenBSD job
495f43f7b3 ci: FreeBSD 15.1
244739db9d depends: move FreeBSD SDK handling to CI
bab0120053 Merge bitcoin/bitcoin#35621: validation: Ignore eventual error message from flushing in AcceptBlock
02afa66169 Merge commit '6b0a907302364649dcaffeb0340b985f14141b4e' into pr/subtree-11
6b0a907302 Squashed 'src/ipc/libmultiprocess/' changes from 3edbe8f67c1..16bf05dea02
22c328d388 refactor: Drop unneeded `<sys/types.h>` include before `<ifaddrs.h>`
2063f02bd5 Merge bitcoin/bitcoin#35510: test: SOCKS5 proxy: expect that connection may be reset during SOCKS5 handshake or data forwarding
1360001f43 Merge bitcoin/bitcoin#34959: wallet: Enforce BDB btree levels and overflow item sizes
10ffef4b3b Merge bitcoin/bitcoin#35604: log: expose `-logratelimit` in normal help
b393985aa0 Merge bitcoin/bitcoin#35634: txospenderindex: use zero-byte entry values
1835f2fcbf Merge bitcoin/bitcoin#35653: fuzz: Remove `ConsumeUniValue`
9f3e427228 fuzz: Remove ConsumeUniValue
68cb7840d2 doc: improve offline-signing-tutorial after 32489
32ddfc92d9 Merge bitcoin/bitcoin#35599: doc: Add release notes for #33671 (getbalances nonmempool field)
f56804bcf5 Merge bitcoin/bitcoin#35640: ci: use a 8x instance over 16x for riscv job
239d6c5260 Merge bitcoin/bitcoin#35614: HTTPServer: Prevent race condition between worker thread and I/O thread
cddbad325d doc: Add release notes for 32489 (exportwatchonlywallet RPC)
0a1bbec688 Merge bitcoin/bitcoin#32489: wallet: Add `exportwatchonlywallet` RPC to export a watchonly version of a wallet
4a007126fb Merge bitcoin/bitcoin#35147: depends: Boost 1.91.0-1
31abaa264c doc: add an AI contribution policy
a15bdc0598 doc: update offline-signing-tutorial to use exportwatchonlywallet rpc
a388076401 test: Test for exportwatchonlywallet
d053e3e5c8 wallet, rpc: Add exportwatchonlywallet RPC
444878efef wallet: Add CWallet::ExportWatchOnly
f9273f01db wallet: Move listdescriptors retrieving from RPC to CWallet
a1c83789a7 wallet: Write new descriptor's cache in AddWalletDescriptor
1e996640e6 wallet: Use Descriptor::CanSelfExpand() in CanGetAddresses()
d2ee9227da descriptor: Add CanSelfExpand()
2990bd7735 Merge bitcoin/bitcoin#35118: fuzz: add ipc round-trip fuzz target
fb1d152c24 depends: Boost 1.91.0-1
ba48852f9e Merge bitcoin/bitcoin#35438: test: introduce NodeSigner, run feature_taproot.py without wallet compiled
47bbed052e ci: use true|false over "true|false"
9a25bc3989 ci: use a 8x instance over 16x
9871dc7ab4 Merge bitcoin/bitcoin#31425: CI: Add Riscv bare metal job
113402286e doc: add txospenderindex release note
ce06878288 index: shrink txospenderindex value markers
a99148d576 test kernel: Don't log on warnings change
5b4fd284f4 kernel: Generate a signet with a challenge
037ad77071 fuzz: add IPC round-trip target
a8823c0996 Merge bitcoin/bitcoin#35607: nanobench: fix performance counter buffer initialization
f26c15bdd2 Merge bitcoin/bitcoin#35397: ci: add OpenBSD Clang cross job
91586f701e test: introduce NodeSigner, run feature_taproot.py without wallet compiled
771200ca43 test: return full keypair from `getnewdestination` helper
4e29de719e private broadcast: add release note for limited cap
cbf8c107c1 Release cs_main between individual private tx re-attempts
5aea3d0373 private broadcast: limit outstanding txs to count of 10,000
dc282ff31d Merge bitcoin/bitcoin#35597: logging: More fully remove libevent log category
ec98037f7a Merge bitcoin/bitcoin#35615: fuzz: restore CreateSock in PCP targets
43d89bb6e1 Merge bitcoin/bitcoin#35610: bitcoin-util: Add netmagic command
e35c805489 Merge bitcoin/bitcoin#35129: test: add fuzz test for private broadcast
dc1c17c085 doc: add release notes
0e10937184 fuzz: add coins_view_stacked fuzz harness to test concurrent leveldb reads
ce610a6ff4 fuzz: update harnesses to cover CoinsViewOverlay::StartFetching
760fb22dc3 test: add unit tests for CoinsViewOverlay::StartFetching
d69a3b20de doc: update CoinsViewOverlay docstring to describe parallel fetching
ab2a379237 coins: fetch inputs in parallel
fdf283036a coins: add ready flag to InputToFetch
ede11b8314 validation: collect block inputs in CoinsViewOverlay before ConnectBlock
f82043af50 coins: introduce thread pool in CoinsViewOverlay
5bf1c32008 validation: add -prevoutfetchthreads configuration option
a318f43254 bitcoin-util: Add netmagic command
256482ab56 validation: In AcceptBlock, ignore flush result
3c76bd4356 Merge bitcoin/bitcoin#35603: build: QRencode cleanups
f595daf1dd test: ensure HTTPServer race condition is fixed
b98b10c072 test: introduce a worker thread in http socket error test
922b08d375 test: socket error handling in HTTPServer using ErrorSock mock socket
73da2a8a52 http: prevent race condition between worker thread and I/O thread
57b3bf8496 Merge bitcoin/bitcoin#35609: ci: Bump tsan config to ubuntu:26.04 with -U_FORTIFY_SOURCE
d64ea15824 ci: add openBSD cross CI job
5404b62074 depends: add openbsd_LDFLAGS
2a9e35d293 Merge bitcoin/bitcoin#35588: scripted-diff: Rename `Sock::{RECV,SEND,ERR}`
a0e5e30010 fuzz: restore CreateSock in PCP targets
41ceea400e scripted-diff: Rename `StatusLevel::{INFO,WARN,ERR}`
f395acdeee scripted-diff: Rename `Sock::{RECV,SEND,ERR}`
7a74f65293 Merge bitcoin/bitcoin#35536: fuzz: share a single mocked steady clock across FuzzedSock instances
e1290ce7f7 Merge bitcoin/bitcoin#35543: test: introduce ExtendedPrivateKey and ExtendedPublicKey classes
7ac25c9177 util, refactor: Rename local `ERR` in `Sock::Accept`
bbbbab86a8 ci: Bump tsan config to ubuntu:26.04 with -U_FORTIFY_SOURCE
095596ddf7 log: expose -logratelimit option
ea9afb61a1 Merge bitcoin/bitcoin#35602: doc: Clarify build docs about `pkgconf` / `pkg-config` requirements
672eedc46b Merge bitcoin/bitcoin#35220: fuzz: connman: strengthen assertions and extend coverage
0e5c718d8a Merge bitcoin/bitcoin#35506: test: ensure group data cluster pointers are live
b6b1d0653a nanobench: fix perf counter buffer init
93012d7ff9 Merge bitcoin/bitcoin#35601: wallet: remove experimental warning from send and sendall
829255c8be cmake: Remove `SelectLibraryConfigurations` from `FindQRencode` module
5c55606da9 depends: Remove unused `lib/pkgconfig` in `qrencode` package
402ba10b20 cmake: Drop optional `PkgConfig` use in `FindQRencode` module
8ebfff0f88 doc: add send RPC release note
fb8a103886 doc: Clarify build docs about `pkgconf` / `pkg-config` requirements
5884f5a4fa wallet: remove experimental warning from send RPCs
7b84e5106c Merge bitcoin/bitcoin#35595: ci: remove some packages from Chimera job
58560c281d ci: remove some packages from Chimera job
295ce6f45c Merge bitcoin/bitcoin#35576: test: raise `feature_reindex` RPC timeout
b36730a3ef  Add CI job for riscv bare metal
bfdbf513f6 Add CI job for producing a static bare metal binary
a9a1d92a1d build: Add option for building for bare metal envs
9b2ef81757 doc: add release notes for #33671 (getbalances nonmempool field)
633044f143 Merge bitcoin/bitcoin#35266: rpc, wallet: add an option to not load the wallet after migrating
d6269e2a90 Merge bitcoin/bitcoin#35594: fuzz: cover async chainstate compaction
3765b428d1 logging: More fully remove libevent log category
703a671fbc fuzz: compact coins view db during fuzzing
0868c85fd5 refactor: rename async coin compaction
6fa4132298 fuzz: share a single mocked steady clock across FuzzedSock instances
8791c4764c test: use ExtendedPrivateKey in wallet_taproot.py
89ceafafb9 test: use ExtendedPrivateKey in wallet_listdescriptors.py
bbfffcab58 test: use ExtendedPrivateKey in wallet_send.py
2ab6e590f7 test: use ExtendedPrivateKey in wallet_keypool.py
9e20118720 test: use ExtendedPrivateKey in wallet_fundrawtransaction.py
06af0cddbb test: use ExtendedPrivateKey in wallet_descriptor.py
4100fac20e test: use ExtendedPrivateKey in wallet_createwallet.py
ff3f6def9a test: use ExtendedPrivateKey in wallet_bumpfee.py
003f2a01f6 test: use ExtendedPrivateKey in feature_notifications.py
f988e6d6e6 test: use ExtendedPrivateKey in wallet_importdescriptors.py
0cdd817a82 add release note
517d37ce3e test: tests wallet migration with load_wallet disabled
b98dd63da7 rpc: Add load_wallet argument to migratewallet RPC
4acd063ba6 wallet: make loading the wallet after migrating optional
1a3cfdf1b7 fuzz: connman: cover AddLocalServices/RemoveLocalServices
c507fb3063 fuzz: connman: add outbound-bytes invariants
4a6fce43ea fuzz: connman: add AddNode/RemoveAddedNode invariants
9e6546c517 test: raise reindex mining RPC timeout
d2a03d50ac test: add extendedkey.py unit tests by using BIP32 test vectors
afdb378082 test: introduce ExtendedPrivateKey and ExtendedPublicKey classes
55e3a57f22 qa: Avoid UTXO reuse between test functions
9c5dd2926a p2p: Ignore CMPCTBLOCK from peer that hasn't sent SENDCMPCT
bf9884f4e5 p2p: make blocksonly nodes ignore CMPCTBLOCK messages
92cea63c71 test: (Un)solicited invalid cb -> get disconnected.
e845e26344 test: p2p: Nodes ignore unsolicited CMPCTBLOCK's
8313591715 p2p: Drop unsolicited CMPCTBLOCK from non-HB peer
44f377a71f refactor: test: Static assert_highbandwidth_states
25457a3272 test: Tighten getblocktxn checks in parallel cb reconstruction test.
2ee4fafa3f test: add fuzz test for private broadcast
08b7c61fc7 private broadcast: enforce sending to unique node ids
9a8ef9b0a3 test: SOCKS5 proxy: expect that connection may be reset during handshake
eb3208364a test: SOCKS5 proxy: expect that connection may be reset when forwarding
4dbaa7cc65 test: generalise byte_to_base58 utility function to allow more version types
df9eb72b12 test: ensure group data cluster pointers are live
a5859edef4 fuzz: connman: set m_local_services/m_use_addrman_outgoing/m_max_automatic_connections
4b84c9125a fuzz: connman: add network activity invariants
9784818442 mining: add getTransactionsByWitnessID() IPC method
d282ae6883 mining: add getTransactionsByTxID() IPC method
0d5e4d4712 test: restart node after IPC option override test
f16b3613cd ipc: Serialize null CTransactionRef as empty Data
0f466e1094 mempool: add lookup by witness hash
51dd90fb50 refactor: Merge announce_cmpct_block() defs into one
97d08d62ba refactor: store wallet names to MigrationResult
8a739a5510 build: allow ipc fuzz builds
b2de59d486 wallet, bdbro: Validate btree page levels
dc3a2b9c3b wallet, bdbro: Enforce overflow data lengths

git-subtree-dir: libbitcoinkernel-sys/bitcoin
git-subtree-split: 81405fc7abbd1889f3978b8924e7acbe12b3403b
fanquake pushed a commit to fanquake/bitcoin that referenced this pull request Jul 10, 2026
Add a belt-and-suspenders feature, limit the amount of
memory and cpu possible when unlucky or simply misconfigured.
The worst case limit is roughly 400kB * 10,000 = 4GB, regardless
of usage pattern.

Before this change, sheer volume of broadcasts, mismatches in
standardness rules, or simply fee mismatches may result in unbounded
growth of memory usage. As the feature may be expanded in
the future, explicit bounds helps reasoning going forward.

Github-Pull: bitcoin#35406
Rebased-From: 5aea3d0
fanquake pushed a commit to fanquake/bitcoin that referenced this pull request Jul 10, 2026
This queue may be hundreds to thousands of items, each of
which are being revalidated at short interval. Allow the
node to be more responsive in this scenario.

Github-Pull: bitcoin#35406
Rebased-From: cbf8c10
@fanquake fanquake mentioned this pull request Jul 10, 2026
@fanquake

Copy link
Copy Markdown
Member

Backported to 31.x in #35699.

Kino1994 pushed a commit to Kino1994/bitcoin-full-history that referenced this pull request Jul 10, 2026
… to count of 10,000

23bc510 private broadcast: add release note for limited cap (Gregory Sanders)
8ce4094 Release cs_main between individual private tx re-attempts (Greg Sanders)
02aea1d private broadcast: limit outstanding txs to count of 10,000 (Gregory Sanders)

Pull request description:

  Add a belt-and-suspenders feature, limit the amount of memory and cpu possible when unlucky or simply misconfigured. The worst case limit is roughly 400kB * 10,000 = 4GB, regardless of usage pattern.

  Before this change, sheer volume of broadcasts, mismatches in standardness rules, or simply fee mismatches may result in unbounded growth of memory usage. As the feature may be expanded in the future, explicit bounds helps reasoning going forward.

ACKs for top commit:
  frankomosh:
    tACK 23bc510. Ran private_broadcast_tests and p2p_private_broadcast_cap.py. Great to have an explicit bound as the belt-and-suspenders against unbounded queue growth.
  vasild:
    ACK 23bc510
  andrewtoth:
    ACK 23bc510
  stickies-v:
    ACK 23bc510

Tree-SHA512: 18161755f37d07cca185a09e782dbe2fd0025b8befd4f6660e988865cc3a9b705d41769b816161e8142fe6ce31a56e0288bd78efc25135cedfc47fc855011799
Kino1994 pushed a commit to Kino1994/bitcoin-full-history that referenced this pull request Jul 10, 2026
…C_LIMIT_EXCEEDED error code ( + other follow-ups)

61bb799 private broadcast: remove no-op [[nodiscard]] (stickies-v)
6440f58 test: align test better with described scenario (stickies-v)
c7d7912 test: use BOOST_CHECK_EQUAL for PrivateBroadcast::AddResult (stickies-v)
4ce5c3b rpc: define and use new  RPC_LIMIT_EXCEEDED error code (stickies-v)

Pull request description:

  The server isn't running out of memory when the private broadcast transaction queue is full. Add and use a new `-37` (`RPC_LIMIT_EXCEEDED`) code that can be used whenever a resource is bound and currently at capacity.

  Addresses bitcoin/bitcoin#35406 (comment)

  Also includes commits to address other outstanding suggestions/nits from #35406:
  - no-op `[[nodiscard]]`: bitcoin/bitcoin#35406 (comment)
  - use `BOOST_CHECK_EQUAL`: bitcoin/bitcoin#35406 (comment)
  - improve clarity remove-add test case: bitcoin/bitcoin#35406 (comment)

ACKs for top commit:
  instagibbs:
    ACK 61bb799
  andrewtoth:
    ACK 61bb799
  sedited:
    ACK 61bb799

Tree-SHA512: c5e0220060770032f3fea54beaabd1d14179a18df3c3e9c25e9f547ad893cea91e2f4b180dd28ad20f09a3cb6b063fad267caab792ee9727f52a2d49f4508523
fanquake added a commit that referenced this pull request Aug 10, 2026
859c920 doc: update release notes for v31.x (fanquake)
2ba8685 versionbits: update VersionBitsCache doc comment to match current behaviour (Antoine Poinsot)
4a1fe04 doc: release notes and bips doc update for #34779 (Antoine Poinsot)
513fd01 qa: test we don't warn for ignored unknown version bits deployments (Antoine Poinsot)
3fa1a36 versionbits: Limit live activation params and activation warnings per BIP323 (Anthony Towns)
1638216 depends, zeromq: Apply upstream patch (Hennadii Stepanov)
c02ff3e p2p: Assume v2transport for addresses from seeds (Martin Zumsande)
444f2d7 fuzz, refactor: Remove `Serialize` overload (Hennadii Stepanov)
504ded6 fuzz: Remove unused `DeserializeFromFuzzingInput` params overload (Hennadii Stepanov)
ec1123a rpc: define and use new  RPC_LIMIT_EXCEEDED error code (stickies-v)
cd32ebd Release cs_main between individual private tx re-attempts (Greg Sanders)
c1a0ed5 private broadcast: limit outstanding txs to count of 10,000 (Gregory Sanders)
ef7542a net: delay stale evaluation and expose time_added in private broadcast (Mccalabrese)
0086a23 net: introduce TxSendStatus internal state container (Mccalabrese)
b4dd6ba chainparams: delete my DNS seed (Pieter Wuille)

Pull request description:

  Backports:
  * #34779
  * #34873
  * #35406
  * #35678 (partial)
  * #35679
  * #35691
  * #35766
  * #35769

ACKs for top commit:
  marcofleon:
    lgtm ACK 859c920
  darosior:
    utACK 859c920
  willcl-ark:
    ACK 859c920

Tree-SHA512: 66753c651d4ed922ca35d9565512d245af45a7358b9763a8c5c63973ed952a50be38048604549f8122bb591986589aaabb25b13465f309004a10e66f227a7e87
Kino1994 pushed a commit to Kino1994/bitcoin-full-history that referenced this pull request Aug 19, 2026
… to count of 10,000

4e29de719e6dc2a080f8a0c00cd137d3cd4dac96 private broadcast: add release note for limited cap (Gregory Sanders)
cbf8c107c12f53045d584f5286337d45f1080954 Release cs_main between individual private tx re-attempts (Greg Sanders)
5aea3d0373f7f1961ddbab4a6c26fd0d8e35275e private broadcast: limit outstanding txs to count of 10,000 (Gregory Sanders)

Pull request description:

  Add a belt-and-suspenders feature, limit the amount of memory and cpu possible when unlucky or simply misconfigured. The worst case limit is roughly 400kB * 10,000 = 4GB, regardless of usage pattern.

  Before this change, sheer volume of broadcasts, mismatches in standardness rules, or simply fee mismatches may result in unbounded growth of memory usage. As the feature may be expanded in the future, explicit bounds helps reasoning going forward.

ACKs for top commit:
  frankomosh:
    tACK 4e29de719e6dc2a080f8a0c00cd137d3cd4dac96. Ran private_broadcast_tests and p2p_private_broadcast_cap.py. Great to have an explicit bound as the belt-and-suspenders against unbounded queue growth.
  vasild:
    ACK 4e29de719e6dc2a080f8a0c00cd137d3cd4dac96
  andrewtoth:
    ACK 4e29de719e6dc2a080f8a0c00cd137d3cd4dac96
  stickies-v:
    ACK 4e29de719e6dc2a080f8a0c00cd137d3cd4dac96

Tree-SHA512: 18161755f37d07cca185a09e782dbe2fd0025b8befd4f6660e988865cc3a9b705d41769b816161e8142fe6ce31a56e0288bd78efc25135cedfc47fc855011799
Kino1994 pushed a commit to Kino1994/bitcoin-full-history that referenced this pull request Aug 19, 2026
…C_LIMIT_EXCEEDED error code ( + other follow-ups)

8ac222484c92f320f56273035bc66dbc14c0b9a1 private broadcast: remove no-op [[nodiscard]] (stickies-v)
191bdcba266daa89fd66af06e0f776e810872322 test: align test better with described scenario (stickies-v)
7ad311be181ce1859308c022c81d7b41c69e1638 test: use BOOST_CHECK_EQUAL for PrivateBroadcast::AddResult (stickies-v)
82a02a2a2208a94686949cf3b5991a834b37263a rpc: define and use new  RPC_LIMIT_EXCEEDED error code (stickies-v)

Pull request description:

  The server isn't running out of memory when the private broadcast transaction queue is full. Add and use a new `-37` (`RPC_LIMIT_EXCEEDED`) code that can be used whenever a resource is bound and currently at capacity.

  Addresses bitcoin/bitcoin#35406 (comment)

  Also includes commits to address other outstanding suggestions/nits from #35406:
  - no-op `[[nodiscard]]`: bitcoin/bitcoin#35406 (comment)
  - use `BOOST_CHECK_EQUAL`: bitcoin/bitcoin#35406 (comment)
  - improve clarity remove-add test case: bitcoin/bitcoin#35406 (comment)

ACKs for top commit:
  instagibbs:
    ACK 8ac222484c92f320f56273035bc66dbc14c0b9a1
  andrewtoth:
    ACK 8ac222484c92f320f56273035bc66dbc14c0b9a1
  sedited:
    ACK 8ac222484c92f320f56273035bc66dbc14c0b9a1

Tree-SHA512: c5e0220060770032f3fea54beaabd1d14179a18df3c3e9c25e9f547ad893cea91e2f4b180dd28ad20f09a3cb6b063fad267caab792ee9727f52a2d49f4508523
mraksoll4 added a commit to bitweb-project/bitweb that referenced this pull request Nov 19, 2026
…ep): private broadcast, versionbits, flatfile/sock/net fixes, tx INV dedup, asmap, tests

bitcoin/bitcoin/pull/35406
bitcoin/bitcoin/pull/35678
bitcoin/bitcoin/pull/35679
bitcoin/bitcoin/pull/35766
bitcoin/bitcoin/pull/35769
bitcoin/bitcoin/pull/34779
bitcoin/bitcoin/pull/35878
bitcoin/bitcoin/pull/36312
bitcoin/bitcoin/pull/36309
bitcoin/bitcoin/pull/36665
bitcoin/bitcoin/pull/36667
bitcoin/bitcoin/pull/36669
bitcoin/bitcoin/pull/36199
bitcoin/bitcoin/pull/36201
bitcoin/bitcoin/pull/36177
bitcoin/bitcoin/pull/36218
bitcoin/bitcoin/pull/36045
bitcoin/bitcoin/pull/35937
bitcoin/bitcoin/pull/36599
bitcoin/bitcoin/pull/35168
bitcoin/bitcoin/pull/35914
bitcoin/bitcoin/pull/35978
bitcoin/bitcoin/pull/35908
bitcoin/bitcoin/pull/35928
bitcoin/bitcoin/pull/36377

- private broadcast: outstanding txs limited to 10,000 with a new
  RPC_LIMIT_EXCEEDED error code, cs_main released between individual tx
  re-attempts, peers are no longer discouraged, feature marked experimental
  and docs/RPC help scope their claims.
- versionbits: live activation params and activation warnings limited per
  BIP 323, with test coverage and doc updates.
- net_processing: process unique tx INVs only.
- p2p: assume v2transport for addresses from seeds.
- flatfile/sock/net: file positions stored as 64-bit integers and 64-bit
  file positioning syscalls on Windows; exception monitoring aligned between
  poll() and select() backends; timeout interval enforced for paused send
  peers.
- net: RFC 9637 IPv6 documentation range treated as invalid, embedded asmap
  updated.
- proxy: network name case preserved in errors, "onion" used in help and
  examples.
- depends/build/test/doc: zeromq upstream patch, avoid pipe2 on Darwin,
  Boost.Test signal stacks, LSAN options, ibd_wtxid getdata flake,
  m_blocks_unlinked LoadBlockIndex coverage, fuzz Serialize/Deserialize
  cleanups, unused variable cleanups, openrc script, NetBSD/macOS build
  docs, BIP 323/461 in bips.md.
- release prep: example config updated for v31.2, version bumped to 31.3.0.

All of these are in official bitcoin/bitcoin 31.x.

Ported from bitcoin/bitcoin:
bitcoin/bitcoin@5aea3d0373 -- private broadcast: limit outstanding txs to count of 10,000 (Gregory Sanders)
bitcoin/bitcoin@cbf8c107c1 -- Release cs_main between individual private tx re-attempts (Greg Sanders)
bitcoin/bitcoin@82a02a2a22 -- rpc: define and use new RPC_LIMIT_EXCEEDED error code (stickies-v)
bitcoin/bitcoin@efa7f8c143 -- fuzz: Remove unused `DeserializeFromFuzzingInput` params overload (Hennadii Stepanov)
bitcoin/bitcoin@afab8d4225 -- fuzz, refactor: Remove `Serialize` overload (Hennadii Stepanov)
bitcoin/bitcoin@cf0f2aeae0 -- p2p: Assume v2transport for addresses from seeds (Martin Zumsande)
bitcoin/bitcoin@e446ea09c4 -- depends, zeromq: Apply upstream patch (Hennadii Stepanov)
bitcoin/bitcoin@f802edf57c -- versionbits: Limit live activation params and activation warnings per BIP323 (Anthony Towns)
bitcoin/bitcoin@1d5240574a -- qa: test we don't warn for ignored unknown version bits deployments (Antoine Poinsot)
bitcoin/bitcoin@107d4178d9 -- versionbits: update VersionBitsCache doc comment to match current behaviour (Antoine Poinsot)
bitcoin/bitcoin@94e3ac0b21 -- doc: bips doc update (release notes part not ported) (Antoine Poinsot)
bitcoin/bitcoin@1278a5970d -- net_processing: process unique tx INVs only (Gregory Sanders)
bitcoin/bitcoin@eab6630add -- net: don't discourage private broadcast peers (Andrew Toth)
bitcoin/bitcoin@2630d8e6c9 -- doc: scope claims about private broadcast feature (Greg Sanders)
bitcoin/bitcoin@f413729983 -- private broadcast: mark feature as experimental (Greg Sanders)
bitcoin/bitcoin@1e0c407377 -- sock: align exception monitoring between poll() and select() backends (Antoine Poinsot)
bitcoin/bitcoin@cc2534cdf7 -- net: enforce timeout interval for paused send peers (Antoine Poinsot)
bitcoin/bitcoin@17556cb1f5 -- flatfile: store position as a 64 bits integer (Antoine Poinsot)
bitcoin/bitcoin@48092a9042 -- flatfile: use 64-bit file positioning syscalls in Windows (Antoine Poinsot)
bitcoin/bitcoin@e6c775c6d6 -- net: treat RFC 9637 new IPv6 documentation range as invalid (Fabian Jahr)
bitcoin/bitcoin@b48a27691d -- fuzz: assert invalid addresses are not routable (Fabian Jahr)
bitcoin/bitcoin@3c91db262b -- net: Update embedded asmap to 1788801420 (Fabian Jahr)
bitcoin/bitcoin@332c3e8e3e -- test: characterize proxy network name errors (Lőrinc)
bitcoin/bitcoin@b0375749d4 -- refactor: share proxy network parsing (Lőrinc)
bitcoin/bitcoin@fd65406b39 -- net: preserve network name case in proxy errors (Lőrinc)
bitcoin/bitcoin@6c7c27f615 -- doc: use onion in proxy help and examples (Lőrinc)
bitcoin/bitcoin@9c7748315d -- build: avoid pipe2 on Darwin (for now) (fanquake)
bitcoin/bitcoin@9eba3aafa6 -- test: avoid undersized Boost.Test signal stacks (Lőrinc)
bitcoin/bitcoin@fad9ab714b -- test: Append print_suppressions=0 to LSAN_OPTIONS, and suppress bitcoin-qt (MarcoFalke)
bitcoin/bitcoin@7777598f87 -- test: Fix intermittent timeout waiting for ibd_wtxid getdata (MarcoFalke)
bitcoin/bitcoin@3f44f9aef7 -- test: Add coverage for m_blocks_unlinked invariant in LoadBlockIndex (marcofleon)
bitcoin/bitcoin@da58e55986 -- test, refactor: Remove unused `warnings` in `wallet/test/util.cpp` (Hennadii Stepanov)
bitcoin/bitcoin@fc28914de4 -- fuzz, refactor: Remove unused `linearization` in `cluster_linearize.cpp` (Hennadii Stepanov)
bitcoin/bitcoin@3df0d067ad -- fuzz, refactor: Remove unused `random_string` in `locale.cpp` (Hennadii Stepanov)
bitcoin/bitcoin@b7ae50e2e2 -- fuzz, refactor: Remove unused `header` in `p2p_transport_serialization.cpp` (Hennadii Stepanov)
bitcoin/bitcoin@e50f422d25 -- test, refactor: Remove unused variables in `test/rbf_tests.cpp` (Hennadii Stepanov)
bitcoin/bitcoin@e550945a39 -- test, refactor: Remove unused `removed_refs` in `txgraph_tests.cpp` (Hennadii Stepanov)
bitcoin/bitcoin@422f1bd92f -- test, refactor: Remove unused `utxo_pool` in `coinselector_tests.cpp` (Hennadii Stepanov)
bitcoin/bitcoin@3175d57628 -- test, refactor: Remove unused `error` in `wallet_tests.cpp` (Hennadii Stepanov)
bitcoin/bitcoin@d837bb38a4 -- contrib/init: fix unused variables in openrc script (jpk68)
bitcoin/bitcoin@9b85c9814d -- doc: Drop GCC upgrade instructions for NetBSD (Hennadii Stepanov)
bitcoin/bitcoin@5964c7229f -- doc: Switch `pkg-config` package to modern `pkgconf` on NetBSD (Hennadii Stepanov)
bitcoin/bitcoin@222855ed11 -- doc: mention -DWITH_ZMQ=ON in macOS build guide (cyb3ralbert)
bitcoin/bitcoin@d57346d682 -- doc: add 461 (Deterministic ECDSA signatures with low-R grinding) to bips.md (Sebastian Falbesoner)
bitcoin/bitcoin@a48dd277ed -- doc: update example bitcoin.conf for v31.2 (fanquake)
bitcoin/bitcoin@bb5978023d -- build: bump version to v31.3 (fanquake)

Local adjustments (not from upstream):
- node/blockstorage.cpp: BACKPORT comment for the m_blocks_unlinked dedup
  corrected; the BLOCK_HAVE_DATA guard is already in official 31.x, only
  the AddUnlinkedBlock dedup remains unmerged.
- test/util/time.h: typo fixed in the FakeNodeClock BACKPORT comment.
- private_broadcast.h: removed the stale BACKPORT marker for the TxSendStatus
  changes, now in official 31.x.

Tree-SHA512: 0afeda49b755a50ff21487839b8bc8da6010136a0431ac9015aa3bd9106721a88a6d86aa8607a282c92f61757a4bf7959ab28d049276d09b8429f84c1e7e4066
mraksoll4 added a commit to bitweb-project/bitweb that referenced this pull request Nov 19, 2026
…prep): private broadcast, versionbits, flatfile/sock/net fixes, tx INV dedup, asmap, tests

bitcoin/bitcoin/pull/35406
bitcoin/bitcoin/pull/35678
bitcoin/bitcoin/pull/35679
bitcoin/bitcoin/pull/35766
bitcoin/bitcoin/pull/35769
bitcoin/bitcoin/pull/34779
bitcoin/bitcoin/pull/35878
bitcoin/bitcoin/pull/36312
bitcoin/bitcoin/pull/36309
bitcoin/bitcoin/pull/36665
bitcoin/bitcoin/pull/36667
bitcoin/bitcoin/pull/36669
bitcoin/bitcoin/pull/36199
bitcoin/bitcoin/pull/36201
bitcoin/bitcoin/pull/36177
bitcoin/bitcoin/pull/36218
bitcoin/bitcoin/pull/36045
bitcoin/bitcoin/pull/35937
bitcoin/bitcoin/pull/36599
bitcoin/bitcoin/pull/35168
bitcoin/bitcoin/pull/35914
bitcoin/bitcoin/pull/35978
bitcoin/bitcoin/pull/35908
bitcoin/bitcoin/pull/35928
bitcoin/bitcoin/pull/36377

- private broadcast: outstanding txs limited to 10,000 with a new
  RPC_LIMIT_EXCEEDED error code, cs_main released between individual tx
  re-attempts, peers are no longer discouraged, feature marked experimental
  and docs/RPC help scope their claims.
- versionbits: live activation params and activation warnings limited per
  BIP 323, with test coverage and doc updates.
- net_processing: process unique tx INVs only.
- p2p: assume v2transport for addresses from seeds.
- flatfile/sock/net: file positions stored as 64-bit integers and 64-bit
  file positioning syscalls on Windows; exception monitoring aligned between
  poll() and select() backends; timeout interval enforced for paused send
  peers.
- net: RFC 9637 IPv6 documentation range treated as invalid, embedded asmap
  updated.
- proxy: network name case preserved in errors, "onion" used in help and
  examples.
- depends/build/test/doc: zeromq upstream patch, avoid pipe2 on Darwin,
  Boost.Test signal stacks, LSAN options, ibd_wtxid getdata flake,
  m_blocks_unlinked LoadBlockIndex coverage, fuzz Serialize/Deserialize
  cleanups, unused variable cleanups, openrc script, NetBSD/macOS build
  docs, BIP 323/461 in bips.md.
- release prep: example config updated for v31.2, version bumped to 31.3.0.

All of these are in official bitcoin/bitcoin 31.x.

Ported from bitcoin/bitcoin:
bitcoin/bitcoin@5aea3d0373 -- private broadcast: limit outstanding txs to count of 10,000 (Gregory Sanders)
bitcoin/bitcoin@cbf8c107c1 -- Release cs_main between individual private tx re-attempts (Greg Sanders)
bitcoin/bitcoin@82a02a2a22 -- rpc: define and use new RPC_LIMIT_EXCEEDED error code (stickies-v)
bitcoin/bitcoin@efa7f8c143 -- fuzz: Remove unused `DeserializeFromFuzzingInput` params overload (Hennadii Stepanov)
bitcoin/bitcoin@afab8d4225 -- fuzz, refactor: Remove `Serialize` overload (Hennadii Stepanov)
bitcoin/bitcoin@cf0f2aeae0 -- p2p: Assume v2transport for addresses from seeds (Martin Zumsande)
bitcoin/bitcoin@e446ea09c4 -- depends, zeromq: Apply upstream patch (Hennadii Stepanov)
bitcoin/bitcoin@f802edf57c -- versionbits: Limit live activation params and activation warnings per BIP323 (Anthony Towns)
bitcoin/bitcoin@1d5240574a -- qa: test we don't warn for ignored unknown version bits deployments (Antoine Poinsot)
bitcoin/bitcoin@107d4178d9 -- versionbits: update VersionBitsCache doc comment to match current behaviour (Antoine Poinsot)
bitcoin/bitcoin@94e3ac0b21 -- doc: bips doc update (release notes part not ported) (Antoine Poinsot)
bitcoin/bitcoin@1278a5970d -- net_processing: process unique tx INVs only (Gregory Sanders)
bitcoin/bitcoin@eab6630add -- net: don't discourage private broadcast peers (Andrew Toth)
bitcoin/bitcoin@2630d8e6c9 -- doc: scope claims about private broadcast feature (Greg Sanders)
bitcoin/bitcoin@f413729983 -- private broadcast: mark feature as experimental (Greg Sanders)
bitcoin/bitcoin@1e0c407377 -- sock: align exception monitoring between poll() and select() backends (Antoine Poinsot)
bitcoin/bitcoin@cc2534cdf7 -- net: enforce timeout interval for paused send peers (Antoine Poinsot)
bitcoin/bitcoin@17556cb1f5 -- flatfile: store position as a 64 bits integer (Antoine Poinsot)
bitcoin/bitcoin@48092a9042 -- flatfile: use 64-bit file positioning syscalls in Windows (Antoine Poinsot)
bitcoin/bitcoin@e6c775c6d6 -- net: treat RFC 9637 new IPv6 documentation range as invalid (Fabian Jahr)
bitcoin/bitcoin@b48a27691d -- fuzz: assert invalid addresses are not routable (Fabian Jahr)
bitcoin/bitcoin@3c91db262b -- net: Update embedded asmap to 1788801420 (Fabian Jahr)
bitcoin/bitcoin@332c3e8e3e -- test: characterize proxy network name errors (Lőrinc)
bitcoin/bitcoin@b0375749d4 -- refactor: share proxy network parsing (Lőrinc)
bitcoin/bitcoin@fd65406b39 -- net: preserve network name case in proxy errors (Lőrinc)
bitcoin/bitcoin@6c7c27f615 -- doc: use onion in proxy help and examples (Lőrinc)
bitcoin/bitcoin@9c7748315d -- build: avoid pipe2 on Darwin (for now) (fanquake)
bitcoin/bitcoin@9eba3aafa6 -- test: avoid undersized Boost.Test signal stacks (Lőrinc)
bitcoin/bitcoin@fad9ab714b -- test: Append print_suppressions=0 to LSAN_OPTIONS, and suppress bitcoin-qt (MarcoFalke)
bitcoin/bitcoin@7777598f87 -- test: Fix intermittent timeout waiting for ibd_wtxid getdata (MarcoFalke)
bitcoin/bitcoin@3f44f9aef7 -- test: Add coverage for m_blocks_unlinked invariant in LoadBlockIndex (marcofleon)
bitcoin/bitcoin@da58e55986 -- test, refactor: Remove unused `warnings` in `wallet/test/util.cpp` (Hennadii Stepanov)
bitcoin/bitcoin@fc28914de4 -- fuzz, refactor: Remove unused `linearization` in `cluster_linearize.cpp` (Hennadii Stepanov)
bitcoin/bitcoin@3df0d067ad -- fuzz, refactor: Remove unused `random_string` in `locale.cpp` (Hennadii Stepanov)
bitcoin/bitcoin@b7ae50e2e2 -- fuzz, refactor: Remove unused `header` in `p2p_transport_serialization.cpp` (Hennadii Stepanov)
bitcoin/bitcoin@e50f422d25 -- test, refactor: Remove unused variables in `test/rbf_tests.cpp` (Hennadii Stepanov)
bitcoin/bitcoin@e550945a39 -- test, refactor: Remove unused `removed_refs` in `txgraph_tests.cpp` (Hennadii Stepanov)
bitcoin/bitcoin@422f1bd92f -- test, refactor: Remove unused `utxo_pool` in `coinselector_tests.cpp` (Hennadii Stepanov)
bitcoin/bitcoin@3175d57628 -- test, refactor: Remove unused `error` in `wallet_tests.cpp` (Hennadii Stepanov)
bitcoin/bitcoin@d837bb38a4 -- contrib/init: fix unused variables in openrc script (jpk68)
bitcoin/bitcoin@9b85c9814d -- doc: Drop GCC upgrade instructions for NetBSD (Hennadii Stepanov)
bitcoin/bitcoin@5964c7229f -- doc: Switch `pkg-config` package to modern `pkgconf` on NetBSD (Hennadii Stepanov)
bitcoin/bitcoin@222855ed11 -- doc: mention -DWITH_ZMQ=ON in macOS build guide (cyb3ralbert)
bitcoin/bitcoin@d57346d682 -- doc: add 461 (Deterministic ECDSA signatures with low-R grinding) to bips.md (Sebastian Falbesoner)
bitcoin/bitcoin@a48dd277ed -- doc: update example bitcoin.conf for v31.2 (fanquake)
bitcoin/bitcoin@bb5978023d -- build: bump version to v31.3 (fanquake)

Local adjustments (not from upstream):
- node/blockstorage.cpp: BACKPORT comment for the m_blocks_unlinked dedup
  corrected; the BLOCK_HAVE_DATA guard is already in official 31.x, only
  the AddUnlinkedBlock dedup remains unmerged.
- test/util/time.h: typo fixed in the FakeNodeClock BACKPORT comment.
- private_broadcast.h: removed the stale BACKPORT marker for the TxSendStatus
  changes, now in official 31.x.

Tree-SHA512: 0afeda49b755a50ff21487839b8bc8da6010136a0431ac9015aa3bd9106721a88a6d86aa8607a282c92f61757a4bf7959ab28d049276d09b8429f84c1e7e4066
mraksoll4 added a commit to bitweb-project/bitweb that referenced this pull request Nov 19, 2026
PrivateBroadcast::Add() now returns AddResult (bitcoin/bitcoin/pull/35406)
instead of bool, so the fuzz target no longer compiled.

Tree-SHA512: 46dcf7ae2a09f585d43d4668ce04b200a1ff39d5af3fe0753636d599e6f4f84f840814715d9078fd8ee6ee3882b2b73b1acfa8dda6f28441a680ab5e5bc64438
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants