Skip to content

http: throttle send buffer when client stops draining - #36174

Merged
sedited merged 1 commit into
bitcoin:masterfrom
pinheadmz:http-throttle-send
Sep 10, 2026
Merged

sedited merged 1 commit into
bitcoin:masterfrom
pinheadmz:http-throttle-send

Conversation

@pinheadmz

@pinheadmz pinheadmz commented Sep 5, 2026 •

Copy link
Copy Markdown
Member

This is a follow-up to #36123 and applies a second throttle mechanism to the send-side. If a misbehaving client refuses to read data from the socket, the server will now stop processing requests instead of packing more and more responses to m_send_buffer without bound.

After we parse a complete request from a client, before we dispatch it to a worker, we quickly lock and check the size of m_send_buffer. If there's already 32MiB of data there (reusing MAX_BODY_SIZE here, open for bikeshedding...) we do not dispatch the request to a worker, leaving it in place as m_req.

This was found and disclosed responsibly by the Red Team 🟥.

@DrahtBot

DrahtBot commented Sep 5, 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/36174.

Reviews

See the guideline and AI policy for information on the review process.

Type Reviewers
ACK hodlinator, janb84, sedited
Concept ACK winterrdog, l0rinc, jeanpablojp

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:

  • #36124 (http: Make HTTPRequest update state internally by hodlinator)

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 places where comparison-specific test macros should replace generic comparisons:

  • [test/functional/interface_http.py] assert response_body_size > 7 * 1024 * 1024, f"Big block JSON response size is {response_body_size} bytes" -> recommend assert_greater_than(response_body_size, 7 * 1024 * 1024, ...)
  • [test/functional/interface_http.py] assert count < num_req, f"Server handled the whole batch of {num_req}: nothing was throttled" -> recommend assert_greater_than(num_req, count, ...)
  • [test/functional/interface_http.py] assert tries > 0, f"Progress failed to stall after {count} requests were handled." -> recommend assert_greater_than(tries, 0, ...)

2026-09-09 17:16:07

@fanquake fanquake added this to the 32.0 milestone Sep 5, 2026

@winterrdog winterrdog 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

@l0rinc

l0rinc commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Concept ACK

@pinheadmz

Copy link
Copy Markdown
Member Author

push to 4e2caa0

Rebase on master after merge of #36123

@jeanpablojp jeanpablojp 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

The new test does not separate a correct throttle from a wrong one. Swapping MAX_BODY_SIZE for zero in the condition, the server stops after the first response and the test passes all the same, reporting "stalled after 1 requests were handled". With 1 MiB in its place it passes too. Neither of those made it fail. Deleting the return nullptr did, and then it reports 58 requests.

The wait loop breaks as soon as two consecutive samples of the log give the same number, whatever that number is.

Would it make sense to pin how many responses have to be queued before that counts as a stall?

log = dl.read()
count = log.count(URI)
if count == prev_count:
self.log.info(f"Response progress stalled after {count} requests were handled.")

@jeanpablojp jeanpablojp Sep 7, 2026 •

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 comparison has no floor, so it matches a count of zero and a server that answered only once.

The product below is not the buffer size, the log counts dispatches and the kernel drains as it goes, but a stall reached with less output than the threshold cannot be this throttle. MAX_BODY_SIZE is already at the top of the file and response_size was measured just above.

Suggested change
self.log.info(f"Response progress stalled after {count} requests were handled.")
self.log.info(f"Response progress stalled after {count} requests were handled.")
assert count < num_req, f"server handled the whole batch of {num_req}: nothing was throttled"
assert count * response_size > MAX_BODY_SIZE, (
f"progress stopped after {count} responses ({count * response_size} bytes), "
f"below the {MAX_BODY_SIZE} byte send-buffer throttle")

Green on the head with count 5 and red with the constant swapped for zero. Worth it?

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.

You're right even though buffer sizes differ across platforms we should always be able to assert that the throttle kicked in at least after 32 MB and before all the requests were handled. I'm also going to require count > 1 so the test doesn't break at 0 == 0

Comment thread src/httpserver.cpp Outdated
if (http_client->ReadyToSend()) {
event = Sock::SendEvent;
} else if (http_client->GetRequest() != nullptr || http_client->ReceiveBufferEmpty()) {
} else if ((http_client->GetRequest() != nullptr && http_client->GetRequest()->GetState() != HTTPRequest::State::Complete)

@jeanpablojp jeanpablojp Sep 7, 2026 •

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.

Did you manage to reach this branch? ReadyToSend() is tested before it, and a request is only held with m_send_buffer above 32 MiB, which as far as I read already guarantees m_send_ready on any connection that is not already being dropped for a permanent send error.

Instrumenting the loop, the held-and-complete state showed up 44 times over two runs of the whole test file, every one of them with ReadyToSend() true. Reverting the condition to the previous form leaves the file passing with the same numbers.

Is there a live case where m_send_ready goes false with the buffer full?

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.

This is a great catch. I built with coverage and ran a few different permutations of code and test and you're right, there's no way m_req would be complete at this point with ReadyToSend() true. I just removed the dead condition.

Comment thread src/httpserver.cpp Outdated
const size_t buffer_used{WITH_LOCK(
client->m_send_mutex,
return client->m_send_buffer.size();)};
if (buffer_used > MAX_BODY_SIZE) return nullptr;

@jeanpablojp jeanpablojp Sep 7, 2026 •

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.

On the bikeshed, with numbers from both sides. The suspension threshold is per connection and -rpcmaxconnections defaults to 16, so that is 512 MiB before counting the in-flight response each connection can still put on top of it.

With 16 connections that never read the plateau sits at 1474 MB, against 327 MB with 1 MiB in place of the constant, and with the default -rpcservertimeout they are dropped after 36 seconds.

On the other side, the allowance is what pays for pipelining. Twelve 7.5 MB responses to a fast-reading client take 1.3 to 1.9 s here and 2.5 to 2.9 s with 1 MiB, over twenty-six runs with no overlap, and at 8 MB/s the two are level. Is 32 MiB deliberate?

@hodlinator hodlinator Sep 7, 2026 •

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.

re #36174 (comment):
32 MiB was inherited from the 2 previous HTTP servers AFAIK:

evhttp_set_max_body_size(http, MAX_SIZE);

ReadHTTPMessage(conn->stream(), mapHeaders, strRequest, nProto, MAX_SIZE);

bitcoin/src/serialize.h

Lines 31 to 35 in 9463e98

/**
* The maximum size of a serialized object in bytes or number of elements
* (for eg vectors) when the size is encoded as CompactSize.
*/
static constexpr uint64_t MAX_SIZE = 0x02000000;

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.

It's a fairly arbitrary choice, I just needed to bound it somewhere. I think ~1GB worst case scenario under default settings is OK.

Comment thread src/httpserver.h Outdated
* but before reading any new data from m_recv_buffer.
* @note The returned request may also be in State::Complete when it has
* been fully parsed but is being held back by TryReadRequest()'s
* send-buffer throttle; check GetState() to distinguish the two.

@jeanpablojp jeanpablojp Sep 7, 2026 •

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.

The functional test never lets the client drain, so neither the release of the held request nor this Complete state ends up covered, and nor does the order between the held one and the one queued behind it.

The DummyClient already in httpserver_tests.cpp closes all three. It passes on the head, and without the new return nullptr it fails on the two checks that assert the request was held. Want it?

BOOST_AUTO_TEST_CASE(http_send_buffer_throttle_tests)
{
    // A socket that accepts no outbound bytes while m_blocked is set, standing in
    // for a client that has stopped draining its end of the connection.
    class StalledSock : public ZeroSock
    {
    public:
        ssize_t Send(const void*, size_t len, int) const override
        {
            return m_blocked ? 0 : static_cast<ssize_t>(len);
        }
        mutable bool m_blocked{true};
    };

    class DummyClient : public HTTPRemoteClient
    {
    public:
        explicit DummyClient(std::unique_ptr<Sock> sock)
            : HTTPRemoteClient{/*id=*/0, /*addr=*/CService(), /*socket=*/std::move(sock)} {}

        void receive(std::string_view s) { MutateRecvBuffer().append(s); }
    };

    const std::string wire1{"GET /first HTTP/1.1\r\nHost: 127.0.0.1\r\n\r\n"};
    const std::string wire2{"GET /second HTTP/1.1\r\nHost: 127.0.0.1\r\n\r\n"};
    const std::string wire3{"GET /third HTTP/1.1\r\nHost: 127.0.0.1\r\n\r\n"};

    auto sock{std::make_unique<StalledSock>()};
    StalledSock& stalled{*sock};
    std::shared_ptr<DummyClient> client{std::make_shared<DummyClient>(std::move(sock))};

    // The first request is dispatched normally.
    client->receive(wire1);
    auto first{HTTPRemoteClient::TryReadRequest(client)};
    BOOST_REQUIRE(first);
    BOOST_CHECK_EQUAL(first->GetURI(), "/first");
    BOOST_CHECK(!client->GetRequest());

    // Its reply is larger than the throttle and the client is not reading it,
    // so it stays in m_send_buffer.
    first->WriteReply(HTTP_OK, std::string(MAX_BODY_SIZE + 1, 'x'));
    BOOST_CHECK(client->ReadyToSend());

    // The next two arrive while the throttle holds. The second parses to
    // Complete and is held back instead of dispatched, and the third is left
    // untouched in the receive buffer behind it.
    client->receive(wire2);
    client->receive(wire3);
    BOOST_CHECK(!HTTPRemoteClient::TryReadRequest(client));
    BOOST_REQUIRE(client->GetRequest());
    BOOST_CHECK_EQUAL(client->GetRequest()->GetState(), HTTPRequest::State::Complete);
    BOOST_CHECK_EQUAL(client->GetRequest()->GetURI(), "/second");
    BOOST_CHECK_EQUAL(client->GetRecvBuffer(), wire3);

    // Draining the send buffer releases the held request, and the one queued
    // behind it follows in the order it arrived.
    stalled.m_blocked = false;
    BOOST_CHECK(client->MaybeSendBytesFromBuffer());
    BOOST_CHECK(!client->ReadyToSend());
    auto second{HTTPRemoteClient::TryReadRequest(client)};
    BOOST_REQUIRE(second);
    BOOST_CHECK_EQUAL(second->GetURI(), "/second");
    second->WriteReply(HTTP_OK, "");
    auto third{HTTPRemoteClient::TryReadRequest(client)};
    BOOST_REQUIRE(third);
    BOOST_CHECK_EQUAL(third->GetURI(), "/third");
    BOOST_CHECK_EQUAL(client->GetRecvBuffer().size(), 0);
}

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.

Due to your point above, I can remove this extra comment as well. I think request pipelining is well covered in other tests. I will drain a few responses in this new functional test, but not all 500+ that were requested ;-)

@hodlinator hodlinator 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 4e2caa0

Comment thread src/httpserver.cpp Outdated
Comment on lines +1009 to +1010
} else if ((http_client->GetRequest() != nullptr && http_client->GetRequest()->GetState() != HTTPRequest::State::Complete)
|| http_client->ReceiveBufferEmpty()) {

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: The current indentation implies the or-operator is part of the inner parenthesis above.

Suggested change
} else if ((http_client->GetRequest() != nullptr && http_client->GetRequest()->GetState() != HTTPRequest::State::Complete)
|| http_client->ReceiveBufferEmpty()) {
} else if ((http_client->GetRequest() != nullptr && http_client->GetRequest()->GetState() != HTTPRequest::State::Complete)
|| http_client->ReceiveBufferEmpty()) {

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.

👍

Comment thread src/httpserver.cpp Outdated
const size_t buffer_used{WITH_LOCK(
client->m_send_mutex,
return client->m_send_buffer.size();)};
if (buffer_used > MAX_BODY_SIZE) return nullptr;

@hodlinator hodlinator Sep 7, 2026 •

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.

re #36174 (comment):
32 MiB was inherited from the 2 previous HTTP servers AFAIK:

evhttp_set_max_body_size(http, MAX_SIZE);

ReadHTTPMessage(conn->stream(), mapHeaders, strRequest, nProto, MAX_SIZE);

bitcoin/src/serialize.h

Lines 31 to 35 in 9463e98

/**
* The maximum size of a serialized object in bytes or number of elements
* (for eg vectors) when the size is encoded as CompactSize.
*/
static constexpr uint64_t MAX_SIZE = 0x02000000;

Comment thread test/functional/interface_http.py Outdated
self.restart_node(0, extra_args=["-rest=1"])
# Generate a big block
self.wallet = MiniWallet(self.node)
self.generate(self.wallet, 130)

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.

Why generate more than 1?

Suggested change
self.generate(self.wallet, 130)
self.generate(self.wallet, 1)

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.

Heh thanks, you caught me copypasting from feature_maxuploadtarget.py

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.

Hm... upon further inspection, it seems like only mine_large_block() is needed for the test to complete and the call to generate() can be removed entirely?

Comment thread test/functional/interface_http.py Outdated
Comment on lines +808 to +812
batch = ""
num_req = 0
while len(batch) < 0x10000:
batch += f"GET {URI} HTTP/1.1\r\nHost: somehost\r\n\r\n"
num_req += 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.

Could make this more declarative and only interpolate the string once:

Suggested change
batch = ""
num_req = 0
while len(batch) < 0x10000:
batch += f"GET {URI} HTTP/1.1\r\nHost: somehost\r\n\r\n"
num_req += 1
single_req = f"GET {URI} HTTP/1.1\r\nHost: somehost\r\n\r\n"
num_req = 0x10000 // len(single_req)
batch = single_req * num_req

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.

Thanks this is much cleaner

@janb84 janb84 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 4e2caa0

I agree with (most) of the NITS/suggestions above. Have one suggestion myself. The direction of the PR looks good.

Comment thread src/httpserver.cpp Outdated
Comment on lines 1096 to 1106
// If this client's send buffer is full, don't move the request
// to a worker. This will prevent the server from reading any more
// data from this client until they drain their end of the socket,
// and prevent the server from packing more responses into the send buffer.
const size_t buffer_used{WITH_LOCK(
client->m_send_mutex,
return client->m_send_buffer.size();)};
if (buffer_used > MAX_BODY_SIZE) return nullptr;

// If the request is ready, hand it to a worker.
if (client->m_req->GetState() == HTTPRequest::State::Complete) {

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; could move the if statement up. Currently, the lock is taken on every call, including for clients whose receive buffer yielded nothing to dispatch.

The move also keeps the same behaviour but with less cognitive load. An incomplete request with a full send buffer returned null here before, and afterwards falls through to the same return nullptr at the end of the function. The check also stays ahead of the LogDebug, so a throttled request still does not log on every loop iteration. In the case of an incomplete request, it's pretty easy to follow what happens, where before you it was not as clear. (imho)

Suggested change
// If this client's send buffer is full, don't move the request
// to a worker. This will prevent the server from reading any more
// data from this client until they drain their end of the socket,
// and prevent the server from packing more responses into the send buffer.
const size_t buffer_used{WITH_LOCK(
client->m_send_mutex,
return client->m_send_buffer.size();)};
if (buffer_used > MAX_BODY_SIZE) return nullptr;
// If the request is ready, hand it to a worker.
if (client->m_req->GetState() == HTTPRequest::State::Complete) {
// If the request is ready, hand it to a worker.
if (client->m_req->GetState() == HTTPRequest::State::Complete) {
// Unless this client's send buffer is full: in that case hold the
// parsed request here instead of moving it to a worker. This prevents
// the server from reading any more data from this client until they
// drain their end of the socket, and prevents the server from packing
// more responses into the send buffer.
const size_t buffer_used{WITH_LOCK(
client->m_send_mutex,
return client->m_send_buffer.size();)};
if (buffer_used > MAX_BODY_SIZE) return nullptr;

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.

Great suggestion thanks, moving the lock inside the condition.

@pinheadmz pinheadmz left a comment

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.

push to 9220000

Address feedback from @janb84 @jeanpablojp and @hodlinator

Mostly clean up, removed a dead forking condition and added a little extra test coverage.

Comment thread test/functional/interface_http.py Outdated
self.restart_node(0, extra_args=["-rest=1"])
# Generate a big block
self.wallet = MiniWallet(self.node)
self.generate(self.wallet, 130)

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.

Heh thanks, you caught me copypasting from feature_maxuploadtarget.py

Comment thread test/functional/interface_http.py Outdated
Comment on lines +808 to +812
batch = ""
num_req = 0
while len(batch) < 0x10000:
batch += f"GET {URI} HTTP/1.1\r\nHost: somehost\r\n\r\n"
num_req += 1

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.

Thanks this is much cleaner

log = dl.read()
count = log.count(URI)
if count == prev_count:
self.log.info(f"Response progress stalled after {count} requests were handled.")

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.

You're right even though buffer sizes differ across platforms we should always be able to assert that the throttle kicked in at least after 32 MB and before all the requests were handled. I'm also going to require count > 1 so the test doesn't break at 0 == 0

Comment thread src/httpserver.cpp Outdated
Comment on lines +1009 to +1010
} else if ((http_client->GetRequest() != nullptr && http_client->GetRequest()->GetState() != HTTPRequest::State::Complete)
|| http_client->ReceiveBufferEmpty()) {

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.

👍

Comment thread src/httpserver.cpp Outdated
Comment on lines 1096 to 1106
// If this client's send buffer is full, don't move the request
// to a worker. This will prevent the server from reading any more
// data from this client until they drain their end of the socket,
// and prevent the server from packing more responses into the send buffer.
const size_t buffer_used{WITH_LOCK(
client->m_send_mutex,
return client->m_send_buffer.size();)};
if (buffer_used > MAX_BODY_SIZE) return nullptr;

// If the request is ready, hand it to a worker.
if (client->m_req->GetState() == HTTPRequest::State::Complete) {

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.

Great suggestion thanks, moving the lock inside the condition.

Comment thread src/httpserver.cpp Outdated
if (http_client->ReadyToSend()) {
event = Sock::SendEvent;
} else if (http_client->GetRequest() != nullptr || http_client->ReceiveBufferEmpty()) {
} else if ((http_client->GetRequest() != nullptr && http_client->GetRequest()->GetState() != HTTPRequest::State::Complete)

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.

This is a great catch. I built with coverage and ran a few different permutations of code and test and you're right, there's no way m_req would be complete at this point with ReadyToSend() true. I just removed the dead condition.

Comment thread src/httpserver.cpp Outdated
const size_t buffer_used{WITH_LOCK(
client->m_send_mutex,
return client->m_send_buffer.size();)};
if (buffer_used > MAX_BODY_SIZE) return nullptr;

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.

It's a fairly arbitrary choice, I just needed to bound it somewhere. I think ~1GB worst case scenario under default settings is OK.

Comment thread src/httpserver.h Outdated
* but before reading any new data from m_recv_buffer.
* @note The returned request may also be in State::Complete when it has
* been fully parsed but is being held back by TryReadRequest()'s
* send-buffer throttle; check GetState() to distinguish the two.

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.

Due to your point above, I can remove this extra comment as well. I think request pipelining is well covered in other tests. I will drain a few responses in this new functional test, but not all 500+ that were requested ;-)

Comment thread src/httpserver.cpp Outdated
Comment on lines +1012 to +1018
// buffer is non-empty but no parse is in progress, or a fully parsed
// request is being held back by TryReadRequest()'s send-buffer
// throttle, leave event=0: the client stays in the I/O map so
// TryReadRequest() runs first to consume buffered bytes before
// admitting more socket data. Excess pipelined data backs up in the
// kernel socket buffer, applying TCP backpressure instead of
// accumulating without bound in m_recv_buffer.

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: should this not also be reverted to the old comment? It now describes outcomes the code no-longer produces. (I think)

@pinheadmz pinheadmz Sep 9, 2026 •

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.

The comment is correct but arguably could be moved up, or expanded to specify that ReadyToSend() actually covers the "held back" case.

  1. Data to send? -> send.
  2. No data to send?
    1. m_req is not null (held back by throttle or incomplete)? -> receive
    2. m_req is null (no request in progress)?
      1. m_recv_buffer is empty? -> receive
      2. m_recv_buffer is NOT empty? -> 0 (parse whatever is in the buffer first)

My original concern when looking at this was that 2-i would break the read-side throttle we just added in #36123, if m_req is complete I don't want to read any more data from the socket. What @jeanpablojp pointed out is that in that case where we are already throttling the send-side, the outcome of the logic above MUST be, simply, 1.

So whatever we can do here to make the next developer less confused is good. What do you think?

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.

suggestion: It changes a bit more than the original PR so only take it if you think it will helpt to confuse the next developer less.

        // Event choice (send wins):
        //   1. ReadyToSend() -> Send
        //      Includes the throttle: a held-back request keeps m_send_ready
        //      set, so we do not Recv until send has drained.
        //   2. Else, parse in progress or recv buffer empty -> Recv
        //   3. Else (no parse in progress, leftover bytes in m_recv_buffer) -> 0
        //      Stay in the I/O map so TryReadRequest() drains the buffer first.
        //      Extra pipelined data waits in the kernel socket buffer
        //      (TCP backpressure), not in m_recv_buffer.
        //
        // Keep this as a separate critical section from the m_sock_mutex one above:
        // never hold m_sock_mutex and m_send_mutex at the same time here.
        // MaybeSendBytesFromBuffer() locks m_send_mutex then m_sock_mutex, so nesting
        // them in the opposite order here would risk a lock-order inversion deadlock.
        Sock::Event event{0};
        if (http_client->ReadyToSend()) {
            event = Sock::SendEvent;
        } else if (http_client->GetRequest() != nullptr || http_client->ReceiveBufferEmpty()) {
            // Mid-parse (need more bytes) or buffer empty.
            event = Sock::RecvEvent;
        }

@pinheadmz

Copy link
Copy Markdown
Member Author

push to e89854b

Clean up the comment by @janb84 suggestions.

I added a bit more description in there for my own benefit, and also re-wrote the part of the comment about lock order since now all the locking in this function is executed by helper functions outside the visible code block

@janb84 janb84 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 e89854b

This PR fixes the found issue from the Red Team 🟥. Confirmed the fix, build tested and reviewed the code. LGTM.

Thanks for incorporating my suggestion.

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

Reviewed e89854b

Comment thread test/functional/interface_http.py Outdated
self.log.info(f"Sending {num_req} big block JSON requests")

# Save a debug log checkpoint
dl_prev_size = self.node.debug_log_size(encoding="utf-8")

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: dl_prev_size sounds like the value will be updated later in the loop. Maybe call it dl_pre_request_size or dl_start_size?

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.

Using dl_start_size here

Comment thread test/functional/interface_http.py Outdated
self.restart_node(0, extra_args=["-rest=1"])
# Generate a big block
self.wallet = MiniWallet(self.node)
self.generate(self.wallet, 130)

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.

Hm... upon further inspection, it seems like only mine_large_block() is needed for the test to complete and the call to generate() can be removed entirely?

Comment thread test/functional/interface_http.py Outdated
Comment on lines +802 to +804
response = conn.get(URI).read()
response_size = len(response)
self.log.debug(f"Big block JSON response size is {response_size} bytes")

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.

nits:

  • Python's HTTPResponse.read() only returns the HTTP body.
  • response is only referenced once.
  • As can be shown by removing the mine_large_block()-call above, the test requires the response to be fairly large. Might as well assert to enforce it rather than log it for later troubleshooting.
Suggested change
response = conn.get(URI).read()
response_size = len(response)
self.log.debug(f"Big block JSON response size is {response_size} bytes")
response_body_size = len(conn.get(URI).read())
assert response_body_size > 7 * 1024 * 1024, \
f"Big block JSON response was only {response_body_size} bytes"

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.

ok, adding assertion here

# Expect progress to stall after a few seconds.
tries = 10
prev_count = -1
with open(self.node.debug_log_path, encoding="utf-8", errors="replace") as dl:

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.

Encoding should be omitted here and for the debug_log_size() call above, see fae6124.

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 copied these parts of the test from assert_debug_log() in test_node.py which existed at the time of that PR, and the encoding arguments were left alone. Looks to me like there's two reasons:

  • seek() and tell() have to match encoding in text mode (not byte count) explained by a comment in test_node.py
  • the addition of errors="replace" is not the default policy (default is 'strict')

So, leaving as is for now

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.

re https://github.com/bitcoin/bitcoin/pull/36174/changes#r3969343424:
I should have read the commit message more closely. We'll have to wait until Python 3.15 to become minimum version before removing the encoding with full certainty I guess https://peps.python.org/pep-0686/#abstract.

Regarding errors="replace", I think that should also be passed into debug_log_size () to avoid it throwing a ValueError.

@pinheadmz pinheadmz left a comment

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.

push to 749c1f7

Address nits in the test from @hodlinator

Comment thread test/functional/interface_http.py Outdated
self.log.info(f"Sending {num_req} big block JSON requests")

# Save a debug log checkpoint
dl_prev_size = self.node.debug_log_size(encoding="utf-8")

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.

Using dl_start_size here

Comment thread test/functional/interface_http.py Outdated
Comment on lines +802 to +804
response = conn.get(URI).read()
response_size = len(response)
self.log.debug(f"Big block JSON response size is {response_size} bytes")

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.

ok, adding assertion here

# Expect progress to stall after a few seconds.
tries = 10
prev_count = -1
with open(self.node.debug_log_path, encoding="utf-8", errors="replace") as dl:

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 copied these parts of the test from assert_debug_log() in test_node.py which existed at the time of that PR, and the encoding arguments were left alone. Looks to me like there's two reasons:

  • seek() and tell() have to match encoding in text mode (not byte count) explained by a comment in test_node.py
  • the addition of errors="replace" is not the default policy (default is 'strict')

So, leaving as is for now

@pinheadmz

Copy link
Copy Markdown
Member Author

https://github.com/bitcoin/bitcoin/actions/runs/34364929164/job/102511078827?pr=36174#step:11:7231

[18](https://github.com/bitcoin/bitcoin/actions/runs/34364929164/job/102511078827?pr=36174#step:11:7219)
 test  2026-09-09T14:53:22.541160Z TestFramework (INFO): Response progress stalled after 3 requests were handled. 
 test  2026-09-09T14:53:22.541291Z TestFramework (ERROR): Unexpected exception: 
                                   Traceback (most recent call last):
                                     File "/home/runner/work/_temp/test/functional/test_framework/test_framework.py", line 145, in main
                                       self.run_test()
                                       ~~~~~~~~~~~~~^^
                                     File "/home/runner/work/_temp/build_ ₿🧪_/test/functional/interface_http.py", line 164, in run_test
                                       self.check_slow_read_throttle()
                                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
                                     File "/home/runner/work/_temp/build_ ₿🧪_/test/functional/interface_http.py", line 843, in check_slow_read_throttle
                                       assert count * response_body_size > MAX_BODY_SIZE, (
                                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                                   AssertionError: Progress stopped after 3 responses (22738449 bytes), below the 33554432 byte send-buffer throttle

Ok yeah I was worried about this @jeanpablojp I am going to check if there is a code regression or just a test flake

@pinheadmz

Copy link
Copy Markdown
Member Author

push to 85428ed

Fix flaky test, from this change

Now the server has 30 seconds to stall, and we don't even check for stalls until we know at least 32 MB has been written.

@DrahtBot DrahtBot removed the CI failed label Sep 9, 2026
Prevents a memory exhaustion case where a misbehaving client
refuses to read responses and drain the socket buffer. Instead of
packing more data on to the server-side m_send_buffer, stop
dispatching requests from the client to workers
@pinheadmz

Copy link
Copy Markdown
Member Author

push to 28b69e2

One more test tweak, setting the stall timeout to 5 seconds instead of 1 second. I noticed the test passed on master regularly, now it fails regularly.

@hodlinator hodlinator 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 28b69e2

Punting on handing new requests to the worker thread until the other side drains the response to a reasonable size puts an upper bound on the amount of memory that aspect can take.
The worst case remaining "loop-hole" would be request A filling the send-buffer with MAX_BODY_SIZE bytes exactly, letting request B to be processed, which in turn can write many multiples of MAX_BODY_SIZE if the response for B just happens to be that gigantic.

Reverted httpserver.cpp to verify that the test fails. It runs out of tries in the loop as it should.

Thanks for putting up with and incorporating most of my test suggestions!

# Expect progress to stall after a few seconds.
tries = 10
prev_count = -1
with open(self.node.debug_log_path, encoding="utf-8", errors="replace") as dl:

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.

re https://github.com/bitcoin/bitcoin/pull/36174/changes#r3969343424:
I should have read the commit message more closely. We'll have to wait until Python 3.15 to become minimum version before removing the encoding with full certainty I guess https://peps.python.org/pep-0686/#abstract.

Regarding errors="replace", I think that should also be passed into debug_log_size () to avoid it throwing a ValueError.

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

re ACK 28b69e2

changes since last ACK:

  • some nits from hodlman
  • some tweaks to tests

@sedited sedited 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 28b69e2

The functional test seems a bit slow and convoluted, but could not detect any flakiness after running it many times.

@sedited
sedited merged commit a42da81 into bitcoin:master Sep 10, 2026
29 checks passed
@hodlinator

Copy link
Copy Markdown
Contributor

The functional test seems a bit slow and convoluted, but could not detect any flakiness after running it many times.

The slowness of the 5 second sleep stood out to me as well at first, but I started experimenting with timing the initial one request which is currently used to measure response size. Then I multiplied that by the min_count to get close to what is required to get the write buffer to stall request processing. Then I multiplied by 2 to have some leeway and account for the server being able to process some requests. In the end 5 seconds wasn't that far off and seemed like a decent choice.

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

post-merge tACK 28b69e2

left some thoughts, just below

Comment thread src/httpserver.cpp
Comment on lines +1109 to +1112
const size_t buffer_used{WITH_LOCK(
client->m_send_mutex,
return client->m_send_buffer.size();)};
if (buffer_used > MAX_BODY_SIZE) return nullptr;

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.

one idea i went back and forth on when looking at the send-buffer throttle: instead of a single 32 MiB cutoff for the send-buffer throttle, this uses two marks: a high-water mark (HWM) that enables throttling, and a lower-water mark (LWM) that disables it

the motivation is to avoid flapping around the boundary. with a single cutoff, a connection sitting near 32 MiB can repeatedly cross above/below it as a few bytes drain and refill. that means we keep changing whether reads are allowed even though the connection's behaviour has not meaningfully changed. also, the fact that the send buffer is not fixed in size so it is continuously changing as the server queues more responses or the remote peer socket drains data

with HWM/LWM, once we enter the congested state, we stay there until the buffer drains meaningfully below the LWM. that adds m_send_congested as a new piece of state on the client that can persist/changed across I/O ticks

upsides of HWM/LWM over the current single-boundary approach:

  • no thrash for a connection parked near the boundary therefore fewer wake-ups on the I/O thread
  • makes the congestion state explicit and deterministic
  • gives us clear transitions to test: HWM turns throttling on, LWM turns it off

upsides of the current single-boundary approach over HWM/LWM:

  • two constants instead of one, so there's another value to justify/tune
  • adds per-connection state that we now need to keep correct
  • a client that recovers quickly (crosses back under 32MiB right away) resumes immediately, instead of having to drain further down to LWM first. so, it is strictly better for a legitimate-but-bursty client's latency

Note

those are some on the pros and cons i'd quickly think of. you'd think of more

genuinely unsure which way nets out better here therefore i wanted to flag this as its own discussion point. curious if others think the hysteresis is worth the extra state, or if we're solving a thrash problem that is less likely to actually show up in practice

a quick rough idea of how i think it could be implemented
diff --git a/src/httpserver.cpp b/src/httpserver.cpp
index a29109c211..38282c475d 100644
--- a/src/httpserver.cpp
+++ b/src/httpserver.cpp
@@ -632,6 +632,20 @@ void HTTPRemoteClient::Send(const HTTPResponse& res, std::span<const std::byte>
         // then only ever poll the socket for writeability, never read the client's
         // next request, and wedge the connection.
         if (!send_buffer_was_empty) m_send_ready = true;
+
+        // Latch congestion on once we cross the high watermark. This is only
+        // ever set here; it's only cleared in MaybeSendBytesFromBuffer()
+        // once the buffer has drained back below the low watermark, which
+        // is what gives the hysteresis its effect.
+        if (!m_send_congested && m_send_buffer.size() > SEND_BUF_HIGH_WATERMARK) {
+            m_send_congested = true;
+            LogDebug(
+                BCLog::HTTP,
+                "Client %s (id=%llu) is send-congested (%d bytes queued) throttling reads/dispatch",
+                m_origin,
+                m_id,
+                m_send_buffer.size());
+        }
     }

     LogDebug(
@@ -1005,7 +1019,8 @@ HTTPServer::IOReadiness HTTPServer::GenerateWaitSockets() const
         //      full, TryReadRequest() holds a completed request back from a
         //      worker, so nothing new is read until send has drained.
         //   2. Else, m_req is incomplete and needs more data, or there is no
-        //      m_req at all and the recv buffer is empty -> Recv
+        //      m_req at all and the recv buffer is empty, provided the send buffer
+        //      is not congested -> Recv
         //   3. Else (no parse in progress, leftover bytes in m_recv_buffer) -> 0
         //      Stay in the I/O map so TryReadRequest() drains the buffer first.
         //      Extra pipelined data waits in the kernel socket buffer
@@ -1021,8 +1036,8 @@ HTTPServer::IOReadiness HTTPServer::GenerateWaitSockets() const
         Sock::Event event{0};
         if (http_client->ReadyToSend()) {
             event = Sock::SendEvent;
-        } else if (http_client->GetRequest() != nullptr || http_client->ReceiveBufferEmpty()) {
-            // Mid-parse (need more bytes) or buffer empty.
+        } else if (!http_client->IsSendCongested() && (http_client->GetRequest() != nullptr || http_client->ReceiveBufferEmpty())) {
+            // Mid-parse (need more bytes) or buffer empty - but only when the send buffer is not congested.
             event = Sock::RecvEvent;
         }

@@ -1067,6 +1082,12 @@ std::unique_ptr<HTTPRequest> HTTPRemoteClient::TryReadRequest(const std::shared_
     // loop iteration.
     if (client->m_req_busy) return nullptr;

+    // If this client's send buffer is congested, don't read or parse
+    // anything new from it either. This is what stops the server from
+    // packing more responses into m_send_buffer for a client that has
+    // stopped draining its socket
+    if (client->IsSendCongested()) return nullptr;
+
     if (!client->m_req) {
         client->m_req = std::make_unique<HTTPRequest>(client);
     }
@@ -1106,10 +1127,10 @@ std::unique_ptr<HTTPRequest> HTTPRemoteClient::TryReadRequest(const std::shared_
         // the server from reading any more data from this client until they
         // drain their end of the socket, and prevents the server from packing
         // more responses into the send buffer.
-        const size_t buffer_used{WITH_LOCK(
-            client->m_send_mutex,
-            return client->m_send_buffer.size();)};
-        if (buffer_used > MAX_BODY_SIZE) return nullptr;
+        // const size_t buffer_used{WITH_LOCK(
+        // client->m_send_mutex,
+        // return client->m_send_buffer.size();)};
+        // if (buffer_used > MAX_BODY_SIZE) return nullptr;
         LogDebug(
             BCLog::HTTP,
             "Received a %s request for %s from %s (id=%llu)",
@@ -1293,6 +1314,16 @@ bool HTTPRemoteClient::MaybeSendBytesFromBuffer()
         m_send_buffer.erase(m_send_buffer.begin(),
                             m_send_buffer.begin() + bytes_sent);

+        // Only clear congestion once drained below the low watermark
+        if (m_send_congested && m_send_buffer.size() < SEND_BUF_LOW_WATERMARK) {
+            m_send_congested = false;
+            LogDebug(
+                BCLog::HTTP,
+                "Client %s (id=%llu) send buffer drained, resuming reads/dispatch",
+                m_origin,
+                m_id);
+        }
+
         LogDebug(
             BCLog::HTTP,
             "Sent %d bytes to client %s (id=%llu)",
diff --git a/src/httpserver.h b/src/httpserver.h
index dae59a9443..f043dbe655 100644
--- a/src/httpserver.h
+++ b/src/httpserver.h
@@ -78,7 +78,6 @@ inline constexpr size_t MIN_REQUEST_LINE_LENGTH = std::string_view("GET / HTTP/1
 inline constexpr size_t MAX_HEADERS_SIZE{8192};

 //! Maximum size of an HTTP request body received from a client.
-//! Also used to limit data queued for sending back to client.
 inline constexpr uint64_t MAX_BODY_SIZE{32_MiB};

 //! Thrown when a request body exceeds MAX_BODY_SIZE (or *will* exceed, in chunked transfer)
@@ -86,6 +85,17 @@ inline constexpr uint64_t MAX_BODY_SIZE{32_MiB};
 struct ContentTooLargeError : std::runtime_error {
     using std::runtime_error::runtime_error;
 };
+
+//! Send-buffer backpressure thresholds, deliberately kept separate from
+//! MAX_BODY_SIZE: that constant bounds request bodies we accept, this pair
+//! bounds queued response bytes we're willing to hold for a slow/stalled
+//! reader. Once a client's queued send data exceeds the high watermark it is
+//! marked congested (see HTTPRemoteClient::IsSendCongested()); it stays
+//! congested until the buffer drains back below the low watermark, so a
+//! connection sitting near the boundary does not flap in and out of
+//! throttling on every I/O loop tick.
+inline constexpr size_t SEND_BUF_LOW_WATERMARK{16_MiB};
+inline constexpr size_t SEND_BUF_HIGH_WATERMARK{32_MiB};
 } // namespace bitcoin_http

 class HTTPHeaders
@@ -505,6 +515,17 @@ public:
     bool ReadyToSend() const EXCLUSIVE_LOCKS_REQUIRED(!m_send_mutex) { return WITH_LOCK(m_send_mutex, return m_send_ready;); }
     bool ReceiveBufferEmpty() const { return m_recv_buffer.empty(); }

+    /**
+     * True once queued response bytes for this client have crossed
+     * SEND_BUFFER_HIGH_WATERMARK, and stays true until they drain below
+     * SEND_BUFFER_LOW_WATERMARK (see the constants' doc comment). Checked
+     * identically by HTTPServer::GenerateWaitSockets() (to stop reading more
+     * request data from the connection's socket) and TryReadRequest() (to stop
+     * dispatching this client's requests to a worker), so both consult one
+     * source of truth.
+     */
+    bool IsSendCongested() const EXCLUSIVE_LOCKS_REQUIRED(!m_send_mutex) { return WITH_LOCK(m_send_mutex, return m_send_congested;); }
+
     void Send(const HTTPResponse& res, std::span<const std::byte> reply_body, bool keep_alive) EXCLUSIVE_LOCKS_REQUIRED(!m_send_mutex, !m_sock_mutex);
     void Receive() EXCLUSIVE_LOCKS_REQUIRED(!m_sock_mutex);

@@ -514,7 +535,11 @@ public:
      * Try to read an HTTPRequest from a client's receive buffer.
      * Only complete requests are returned, incomplete requests are
      * left in the buffer to wait for more data. Some read errors
-     * will mark this client for disconnection.
+     * will mark this client for disconnection. Also returns nullptr,
+     * without reading or parsing anything, while the client is
+     * send-congested -- this is what stops a misbehaving client that
+     * is not draining its socket from causing m_send_buffer to grow
+     * without bound.
      */
     static std::unique_ptr<HTTPRequest> TryReadRequest(const std::shared_ptr<HTTPRemoteClient>& client) EXCLUSIVE_LOCKS_REQUIRED(!client->m_send_mutex);

@@ -580,6 +605,12 @@ private:
     /// @{
     mutable Mutex m_send_mutex;
     std::vector<std::byte> m_send_buffer GUARDED_BY(m_send_mutex);
+
+    //! Hysteretic congestion flag;. Only ever set in
+    //! Send() (where m_send_buffer grows) and only ever cleared in
+    //! MaybeSendBytesFromBuffer() (where it shrinks), so it always reflects
+    //! the buffer's size as of the last time it changed.
+    bool m_send_congested GUARDED_BY(m_send_mutex){false};
     /// @}

     /**

any thoughts ?

Kino1994 pushed a commit to Kino1994/bitcoin-full-history that referenced this pull request Sep 13, 2026
…tops draining

28b69e298884ed3f0b03023d9ad1cf37d15bcec6 http: stop processing requests from a client when send buffer is full (Matthew Zipkin)

Pull request description:

  This is a follow-up to #36123 and applies a second throttle mechanism to the send-side. If a misbehaving client refuses to read data from the socket, the server will now stop processing requests instead of packing more and more responses to `m_send_buffer` without bound.

  After we parse a complete request from a client, **before** we dispatch it to a worker, we quickly lock and check the size of `m_send_buffer`. If there's already 32MiB of data there (reusing `MAX_BODY_SIZE` here, open for bikeshedding...) we do not dispatch the request to a worker, leaving it in place as `m_req`.

  This was found and disclosed responsibly by the Red Team 🟥.

ACKs for top commit:
  hodlinator:
    ACK 28b69e298884ed3f0b03023d9ad1cf37d15bcec6
  janb84:
    re ACK 28b69e298884ed3f0b03023d9ad1cf37d15bcec6
  sedited:
    ACK 28b69e298884ed3f0b03023d9ad1cf37d15bcec6

Tree-SHA512: ecefdf6406fa40aa28fe284fd4b5a148a0e4ef84b857e373cc7a55c84bac5c7a928b09c088d9ebe5a2adadfbd95a5ae1644f024947ed891da067130d1aa84ae6
achow101 added a commit that referenced this pull request Oct 5, 2026
…ceive-throttle regression test

493850c test: assert HTTP receive throttle from server-side log (Matthew Zipkin)
767d86a http: log received bytes per client read (Matthew Zipkin)

Pull request description:

  Closes #36216

  Improves and fixes the test introduced by #36123 to cover regressions in the server's receive throttle. The original test relied on client-side signals to assert server-side behavior which can easily be disrupted by a platform's TCP stack. Macos for example may suddenly re-open a TCP window size based on heuristics out of our control (`SB_AUTOSIZE`), despite the application not reading any data from the socket. Macos also may delay transmission of data between 5-60 seconds as the TCP window shrinks (`TCPTV_PERSMIN` / `TCPT_PERSIST` / "silly window syndrome" avoidance). All these behaviors were observed by running the current CI test on my fork hundreds of times, capturing TCP packets and processing them locally against the CI debug log.

  The improved approach is similar to how we test the send-side throttle in #36174 using debug log messages. This way we test the thing we know we can control (bitcoind).

  To introduce the regression patched by #36123 and fail the new test:

  ```diff
  diff --git a/src/httpserver.cpp b/src/httpserver.cpp
  --- a/src/httpserver.cpp
  +++ b/src/httpserver.cpp
  @@ -1040,13 +1040,7 @@ HTTPServer::IOReadiness HTTPServer::GenerateWaitSockets() const
           // before the next is taken and they stay separate critical sections.
           // Holding m_sock_mutex while acquiring m_send_mutex would invert that
           // order and risk a lock-order-inversion deadlock.
  -        Sock::Event event{0};
  -        if (http_client->ReadyToSend()) {
  -            event = Sock::SendEvent;
  -        } else if (http_client->GetRequest() != nullptr || http_client->ReceiveBufferEmpty()) {
  -            // Mid-parse (need more bytes) or buffer empty.
  -            event = Sock::RecvEvent;
  -        }
  +        Sock::Event event = (http_client->ReadyToSend() ? Sock::SendEvent : Sock::RecvEvent);

           io_readiness.events_per_sock.emplace(sock, Sock::Events{event});
           io_readiness.httpclients_per_sock.emplace(sock, http_client);
  ```

  For usual bitcoind activity, httpo debug logs will only grow by one extra line per request. Huge requests like those generated by the test may produce a hundred or so lines of "Received data" messages. These are optional debug lines in a worst-case scenario, but reviewers can discuss rate-limiting that log activity if we're afraid it's too much.

ACKs for top commit:
  davidgumberg:
    crtACK 493850c
  achow101:
    ACK 493850c
  winterrdog:
    tACK 493850c
  ismaelsadeeq:
     Code review ACK 493850c

Tree-SHA512: 2c501b69c1b3cebb7c15e574edf8d24f50a4c49af48073123f0864ac38813d696bca3ccb5dd86cd98b47eac77c71bb8943a974a35e81b0df8f9690d2239f2922
alexanderwiederin added a commit to alexanderwiederin/rust-bitcoinkernel that referenced this pull request Oct 6, 2026
…8aedda9e983

38aedda9e983 test: add kernel tapscript v2 evaluation coverage
7d10a1c7a3c2 kernel: expose tapscript v2 script evaluation
4d9d46470a04 script: extract tapscript v2 witness execution
16c0ca94bf8f kernel: add varops to ScriptTraceFrame in Kernel API
599682f1815f kernel: add varops to script tracer
01d61cb08ebd script: extend trace hooks to tapscript v2 evaluation
231b0b2c80d7 kernel: Add script tracer
82cfa2cd9c47 bench: add BIP 440 varops calibration tool
a87b56a1fdae fuzz: add tapscript v2 and Val64 targets
b45d72f04a78 rpc: report script restoration deployment
9afee38c25c0 test: add tapscript v2 functional coverage
133151204f20 test: add BIP 440/441 unit coverage
a5a612b4bb3a script: support tapscript v2 in signing and utilities
0575a794c6b7 script: implement tapscript v2 evaluation
7be8cda33f5d consensus: add BIP 441 script restoration deployment
ecf3a0eb3e49 script: copy EvalScript for tapscript v2
004f8a6fc936 script: plumb transaction-wide varops budgets
cf43ac7d1f77 script: define tapscript v2 limits and opcode classification
ecd26db635fe script: add size-accounting stack for tapscript v2
ecc7779e4f74 test: add Val64 unit coverage
5c526ff67219 script: add Val64 for BIP 441 arithmetic
b6f80778126e script: define varops budgets and costs
ced4c6e6ab47 Merge bitcoin/bitcoin#36321: net: cast vector size to avoid overflow, truncation, sign change
e7a18350967f Merge bitcoin/bitcoin#36235: ci: fail iwyu job on compiler errors instead of silently logging them
05bc2f53ce0c Merge bitcoin/bitcoin#36024: ci: Make `test_bitcoin-qt.exe` output visible
ed7dd7cf4e15 Merge bitcoin/bitcoin#34371: wallet: allow importprunedfunds for spending transactions
f80aaf4bd7c6 Merge bitcoin/bitcoin#29278: Wallet:  Add `maxfeerate` wallet startup option
e19f83e944e9 Merge bitcoin/bitcoin#35984: sign: skip signing SIGHASH_SINGLE inputs with no corresponding output
ab8033566757 Merge bitcoin/bitcoin#36135: fuzz: test HTTPRequest state machine in http_request
65e075f89fdd Merge bitcoin/bitcoin#35696: i2p: update leaseset encryption types
d26f19c77c7b Merge bitcoin/bitcoin#35948: init: correct first-run disk space estimate
90374132737e Merge bitcoin/bitcoin#36335: Remove my key from SECURITY.md
f6b19b190b2e Merge bitcoin/bitcoin#36322: init: fee estimates can lag behind the chain after restart
5820537e1b4b Remove my key from SECURITY.md
da03790dbb11 Merge bitcoin/bitcoin#36324: test: Fixup MAX_BODY_SIZE http throttling test
37969fc15211 Merge bitcoin/bitcoin#36312: net: don't discourage private broadcast peers
e8e7e91a1144 Merge bitcoin/bitcoin#36284: wallet: don't double discard output groups with avoidpartialspends
8c27c3852641 init: drain callbacks before saving fee estimates
08729e6ef9c9 test: characterize fee callback loss at shutdown
308cd670195d net: cast vector size to avoid overflow, truncation, sign change
bfdcd9797cd1 Merge bitcoin/bitcoin#35890: doc: use overwrite (>) instead of append (>>) for one-shot PSBT files in offline-signing-tutorial.md
de9f42c497df Merge bitcoin/bitcoin#36316: ci: use POSIX threads for Nix Windows builds
fa2c62036b1d test: Fixup MAX_BODY_SIZE http throttling test
5c726f2058a4 Merge bitcoin/bitcoin#35675: mining: add block template manager
26241482e530 Merge bitcoin/bitcoin#35923: mempool: count unbroadcast txids in memory usage
a632d4f697f3 Merge bitcoin/bitcoin#35177: test: use MiniWallet for getblockstats test data generation
be5d0b5503fa Merge bitcoin/bitcoin#35301: Silent Payments: Implement bip352 (take 2)
b3f846ec3e5c Merge bitcoin/bitcoin#35440: wallet: check descriptor cache xpub length before decoding
dc3cd1969ed3 Merge bitcoin/bitcoin#35809: contrib: add deterministic fuzz coverage mode
81e2de897dbc Merge bitcoin/bitcoin#35893: test: cover submitpackage other-wtxid for same-txid-diff-witness
eab6630addc3 net: don't discourage private broadcast peers
31754523cd81 Merge bitcoin/bitcoin#36309: private broadcast: clarify claims, mark as experimental
9fd18aedb088 ci: print Windows cross compiler thread model
1d59d5ad2550 ci: use POSIX threads in Nix Windows cross shell
e3ee0ebd89e9 tests: add BIP352 test vectors as unit tests
f133d1373af6 common: add bip352.{h,cpp} secp256k1 module
96d487c11e8f ci: raise BuildKit step log limit
44997c391afc Add "sp" HRP
356c91f6ae51 crypto: add KeyPair::GetSecpKeypair
2b95b45a9abd Merge bitcoin/bitcoin#35813: wallet, rpc: Add listrawtransactions RPC
71c30b608382 Merge bitcoin/bitcoin#27052: test: rpc: add last block announcement time to getpeerinfo result
d36f4a1788da Merge bitcoin/bitcoin#36155: doc: remove json quoting from gettxoutsetinfo and getblockstats cli examples
b7211ba80cde Merge bitcoin/bitcoin#34717: p2p: remove m_getaddr_sent
7ee3d622e5fa Merge bitcoin/bitcoin#35752: wallet: make encryption state updates atomic
f41372998377 private broadcast: mark feature as experimental
2630d8e6c9d6 doc: scope claims about private broadcast feature
248ce46faf70 Merge bitcoin/bitcoin#35619: test:  ExtendedPrivateKey follow-ups
995da8678a02 Merge bitcoin/bitcoin#36302: ci: simplify macOS codesign check
db7ec4fb9762 refactor: (de)serialize CExtKey/CExtPubKey through streams
cb69853fc160 wallet: check descriptor cache xpub length before decoding
f86cbf53eb3e Merge bitcoin/bitcoin#36310: rpc: clarify that `getaddrmaninfo` counts unique addresses
bbc40ede1ba6 Merge bitcoin/bitcoin#36261: test: cover PSBT unknown field merging
f839ee1afb0f Merge bitcoin/bitcoin#35887: ipc: use std::optional for checkSpawned(), add tests and rename arg -ipcfd to -ipcchild
dac53c585b6a Merge bitcoin/bitcoin#31888: contrib: Support re-writing linearize-data dumps
0d34b6e9287f rpc: clarify that getaddrmaninfo counts unique addresses
4ecbc82d412f Merge bitcoin/bitcoin#36278: Update minisketch subtree to latest master
622817f097d6 ci, iwyu: fail job on compiler errors instead of ignoring them
5ca3773414df Merge bitcoin/bitcoin#36298: Update crc32c subtree to latest master
5945cb83ddcf contrib: add deterministic fuzz coverage mode
69ad2a67f26c Merge bitcoin/bitcoin#36283: kernel: expose transaction version
716e8605e5c8 ci: simplify macOS codesign check
bb5296576e8f Merge bitcoin/bitcoin#36206: build: drop use of `OBJC_OLD_DISPATCH_PROTOTYPES`
170d37983c7a Merge bitcoin/bitcoin#36198: http: Add missing LIFETIMEBOUND annotations
c08489fb2741 Merge bitcoin/bitcoin#36288: build: Revert remove `cmake/script/CoverageFuzz.cmake`"
4a583f38ef2f Merge bitcoin/bitcoin#36230: wallet: Improve `HasWalletDescriptor` performance and other canonical descriptor string followups
5f05d8c5f6dd Merge bitcoin/bitcoin#36297: rpc: Correct invalid OpenRPC defaults
b7f740c594ba rpc: Correct OpenRPC default metadata
2c8372db1131 Update crc32c subtree to latest master
5181c61d734f Squashed 'src/crc32c/' changes from efb8ea04e4..60bcf13edf
83434f7683e4 kernel: expose transaction version
7c311f5c6c3e doc: Add release notes for listrawtransactions
b377786df14e test: Add functional test for listrawtransactions
605c4fd3aee0 wallet, rpc: Add listrawtransactions RPC
ba6c179ba07c wallet, rpc: allow omitting parent_descs from TransactionDescriptionString
d48e76e689bb Merge bitcoin/bitcoin#36286: crypto: Fix MuHash3072 division by itself
719324977a41 test: Check that ineligible output groups are discarded only once
6d2414542b86 wallet: reuse unlock and passphrase change errors
593554622e2c wallet: return passphrase errors with Expected
f949b3ba2ad7 wallet: publish descriptor keys after writes
e3712b7d492f test: characterize descriptor insertion failure
bd558107784c wallet: abort failed descriptor key erases
537e79191585 test: cover encrypted descriptor key insertion
d8a6f5e48d6b wallet: abort failed descriptor key writes
14ce3fdb493a test: characterize descriptor key failures
5bc0be16fe4d wallet: reject failed passphrase changes
ee6d45a07e3a test: characterize passphrase write failure
2daa2f94f4a2 wallet: restore lock state before re-encryption
8b23fa47737a wallet: abort failed encryption transactions
e6c374d30201 test: characterize encryption transaction failures
70381010c0af refactor/test: add wallet failure injection
0e9018e8b656 Merge bitcoin/bitcoin#36249: net, rpc: Asmap version improvements/follow-ups
61edcf925325 test: Add 31.1 to wallet back compat
ebf2f69ee819 test: Simplify miniscript descriptor check in wallet back compat
f6cbcfd98a00 wallet: Document WalletDescriptor::UpdateFrom
f0f6dce84963 descriptor, doc: Clarify miniscript CompatDescriptorHash
405b1d6055e7 descriptor: Explicitly handle use_apostrophe cases
64abb3e8d361 wallet: Compare descriptors by hash of canonical string
bb5e8320d76f wallet: Make WalletDescriptor's descriptor const
4cc00f7bc04b wallet: Remove WalletDescriptor's default constructor
dc3e2bc6df68 wallet, rpc: extract PushTxAmountAndFee/PushTxDecoded helpers
b388f9bd0d2b crypto: Fix MuHash3072 division by itself
4f624bb82ddf Revert "build: Remove `cmake/script/CoverageFuzz.cmake`"
ad97933af248 Merge bitcoin/bitcoin#36285: refactor: Use static const over inline const to work around ld64 bug
a604a7647588 Merge bitcoin/bitcoin#36282: Update leveldb subtree to latest master
fa8fefb29b6c refactor: Use static const over inline const to work around ld64 bug
2bbbeaa663ec Merge bitcoin/bitcoin#34861: wallet: Add importdescriptors interface
20307f0ac0e1 wallet: don't double count discarded output groups with avoidpartialspends
7528f799d99d Update leveldb subtree to latest master
4be88b9bce45 Squashed 'src/leveldb/' changes from 13da2d6758..53a1914e00
749bd10fdf01 Update minisketch subtree to latest master
fcb2d832b2d9 Squashed 'src/minisketch/' changes from 4a179c61e3..a12f5de1c9
21e4ea8134d8 test: cover PSBT unknown field merging
59f7f3d07d95 build: drop use of OBJC_OLD_DISPATCH_PROTOTYPES
b82158554372 Merge bitcoin/bitcoin#33593: guix: Use UCRT runtime for Windows release binaries
0b353a9e872e netgroup: Cache asmap version
fb68c27002a7 Merge bitcoin/bitcoin#36260: torcontrol: Use reconnect backoff after dropped connections
7dedc4545a49 Merge bitcoin/bitcoin#36256: guix: Update osslsigncode to 2.14
a687188101af Merge bitcoin/bitcoin#36160: refactor: Minor improvements to HTTP unit tests
651e44f32797 Merge bitcoin/bitcoin#36194: kernel: expose block header Merkle root
d32a515fb0bb Merge bitcoin/bitcoin#34566: feature: Use different datadirs for different signets
59a465ce3782 guix: Validate codesigned windows binaries
66eeac216ad5 guix: Use osslsigncode 2.14
4556ef626754 torcontrol: Apply reconnect backoff after dropped connections
57721f8074c2 Merge bitcoin/bitcoin#36253: fuzz: Use `LIMITED_WHILE` in `connect_block`
dadca55f60ad Merge bitcoin/bitcoin#36251: rest: add `generated` and `height` to spenttxouts JSON
de394ad3b739 Merge bitcoin/bitcoin#36207: kernel: add wtxid accessor
f69e56bc1c43 [doc]: add release notes
40ab7aa90de5 [wallet]: warn when `-maxtxfee` conflicts with `-minrelaytxfee`
df1feeb487dc [wallet]: enforce `-maxfeerate` on wallet transactions
d2c832e9e79d [util]: add a new transaction error type
633c08d3f7af [node]: update `BroadcastTransaction` to check fee rate limit
7bfce65801bf [wallet]: add `maxfeerate` wallet startup option
607568f2b002 [wallet]: update `max_fee` to `max_tx_fee`
6b913b6224bd doc: add missing verb to make sentence readable
a9c39696f4be scripted-diff: rename `m_default_max_tx_fee` to `m_max_tx_fee`
16278c28166b kernel: expose block header Merkle root
51ddab532cb3 Merge bitcoin/bitcoin#35819: test: add coverage for untested descriptor parse error paths
2c249dbdf5c9 wallet: Add an importDescriptors() interface for the wallet
3be5f401370e wallet: add CheckDescriptorRangeBounds
43bba1ed74f8 kernel: expose transaction witness presence
31224d068077 kernel: expose transaction wtxid
a9cd985d0a54 wallet: Move ImportDescriptor and ProcessDescriptorsImport to imports.cpp
c9650d8f0e2f wallet: rename ProcessDescriptorImport to ImportDescriptor and add ProcessDescriptorsImport
a40ee4ec2659 wallet: rpc: refactor: ProcessDescriptorImport returns ImportDescriptorResult
48d3d717fb6e wallet, util: Add HandleWalletErrorCode
04c73a91d2cc wallet: Add ImportError struct and new WalletError codes
975215618505 wallet: rpc: refactor: Extract UniValue processing from ProcessDescriptorImport
f1f61af35727 wallet: Add ImportDescriptorRequest structs
7375124f4c9a wallet: refactor: make is_ranged no longer an optional
90485103c67d wallet: lower the minimum timestamp to 0
380d3ae0deab wallet: rpc: Use std::optional in GetImportTimestamp
e0229ca68515 fuzz: Use LIMITED_WHILE in connect_block
1566a4767afd rest: add generated and height to spenttxouts JSON
cff00c547e74 Merge bitcoin/bitcoin#34743: p2p: don't disconnect manual peers for block stalling
a09a81ebfce3 Merge bitcoin/bitcoin#35961: depends: Update `boost` package to 1.92.0
76343a09f802 Merge bitcoin/bitcoin#36186: test: return False for a too-short ECDSA signature
5551d39b202b doc: document manual peer stalling behavior
24628d3ae7dc test: cover manual peer block download cooldown
4c79f3a34d00 test: support manual connections in addconnection
698b5bbf3a0a p2p: pause stalling manual block downloads
c38e0d20c3c0 Merge bitcoin/bitcoin#36093: test: ipc should reject invalid json
a49fa1f6e698 Merge bitcoin/bitcoin#35849: init: don't suggest -reindex-chainstate for recovery on a pruned node
dd3c62c55fdc Merge bitcoin/bitcoin#36083: test: cover getrawtransaction on a stale block via txindex
36c1b149fe37 Merge bitcoin/bitcoin#35472: test: add coverage for feebumper uncomputable cluster error path
7c4facb51bbe Merge bitcoin/bitcoin#36081: rpc: add bestblockhash to getmininginfo
c1e9d15406fb doc: Describe how to verify the asmap in use
87ce88c1b53c rpc: Add asmap_version to getnetworkinfo
dd5a8a63b223 test: Check embedded asmap version log and addrman re-bucketing
d9d057841029 Merge bitcoin/bitcoin#34681: wallet: move rescan logic into ChainScanner and wallet/scan
2ca83ba2622a Merge bitcoin/bitcoin#35436: wallet: Add addHDkey interface
0bc87365cac1 init: Log asmap version from NetGroupManager
fdfd196908e1 rpc: Reuse AsmapVersion in exportasmap
adca0a97406d Merge bitcoin/bitcoin#36247: iwyu: Always keep `bitcoin-build-info.h` header
1aa500b6b7d8 iwyu: Always keep `bitcoin-build-info.h` header
d25470d992b7 Merge bitcoin/bitcoin#35975: wallet: Fix `CWalletTx` malleated transaction metadata sync
2c6047df8746 test: Bumping a transaction prevents bumping malleations
a44f9ad35058 test: Test rbf metadata sync of malleated tx
752fd437c7cf wallet: persist synced metadata and do not sync on load
31eedfc6fc8b wallet: simplify wtx metadata sync
6c16d76f790c wallet: sync tx replacement metadata to malleated txs
34533d5d22b6 wallet: Clarify IsEquivalentTo is actually checking malleation
b973a355c4eb Replace CTransaction::operator== with Equals that has options
8df006f23383 wallet: skip signing SIGHASH_SINGLE inputs with no corresponding output
3d7d190b6995 ci: enforce iwyu for block template manager
ffe3a631f38b node: remove NodeContext::mining and EnsureMining
6c71166bcfa4 test: create templates via BlockTemplateManager
ec4f24ef181a rpc: wait for tips via BlockTemplateManager
8372721f20e2 rpc: build generation templates via BlockTemplateManager
38556f817e06 rpc: only copy the header in getblocktemplate
951fac807d37 rpc: do not copy template data in getblocktemplate
0998c0bbdfcc rpc: build getblocktemplate via BlockTemplateManager
011cbfbcd2e3 rpc: route getblocktemplate internals through node
400ac328c91b interfaces: create block template via BlockTemplateManager
037d3519f2ff node: move tip and wait helpers into BlockTemplateManager
07964c525d47 miner: move SubmitBlock into BlockTemplateManager
bcdadf2b7111 node: move mining_args to BlockTemplateManager
482a5d27124c node: introduce BlockTemplateManager
2efaa6763bd2 wallet: simplify and restrict SyncMetaData to malleated txs
fc718ade4fce test: Test that metadata is synced to malleated transactions
17817818da3c Merge bitcoin/bitcoin#36228: ci, iwyu: generate embedded ASMap header explicitly
1cbbf64ea810 ci, iwyu: generate embedded ASMap header explicitly
1afa0cd70a09 cmake: add raw data header generation target
0476444e33bd Merge bitcoin/bitcoin#35935: wallet: Avoid unnecessary wtxvariant rewrites
feeb00af8cf3 cli: Add -signetchallenge info on RPC auth error
c47ea370dc9f doc: Update documentation for signet datadir
6f8c43f9efc6 test: Add signet datadir tests
9b37d42b23be Use different datadirs for different signets
6bdcae3f768b refactor: Import signet constant and helper from kernel/signet.h
f3fec67c3eeb Merge bitcoin/bitcoin#36227: Pre 32.x branching updates
9a48134aea11 docs: Update bips.md
57d3d0013054 build: Bump version to 32.99
4d463de80408 Merge bitcoin/bitcoin#36226: doc: Move release notes to wiki ahead of branch-off
5df082721cdb doc: Move release notes to wiki ahead of branch-off
8c64ff02425d Merge bitcoin/bitcoin#34914: contrib: replace deprecated --deep codesign flag, fix accidental --verify skip on ci
501ba4cad4b3 Merge bitcoin/bitcoin#36196: contrib, kernel: fixed seeds, chainparams, headerssync params, and assumeutxo updates pre-32.0
92986c736223 Merge bitcoin/bitcoin#36213: Release: 32.0 translations update
1a4e034ddbdc Merge bitcoin/bitcoin#36209: guix: cache GUI depends separately
a6b330973e64 Merge bitcoin/bitcoin#36150: indexes: set prune lock to genesis before first block
fed50258f8f0 kernel: add recent assumeutxo snapshot
7eb4cec1a983 kernel: Update headerssync params
9b2299514028 indexes: set prune lock to genesis before first block
fc6923cec5b4 Merge bitcoin/bitcoin#36215: asmap: Make version match externally computed hashes
2c2667eaa902 qt: 32.0 translations update
51b540c59aae Merge bitcoin/bitcoin#36218: build: avoid `pipe2` on Darwin (for now)
a42da819a96c Merge bitcoin/bitcoin#36174: http: throttle send buffer when client stops draining
da7d7dbc7c00 contrib: remove deprecated --deep codesign flag
9c7748315d31 build: avoid pipe2 on Darwin (for now)
1fe87c250547 guix: cache GUI depends separately
7ee94bf4b023 asmap: Make outputted ASMap version match externally computed hashes
4a15e0b6f9c5 Merge bitcoin/bitcoin#36195: test: `get_previous_releases.py` use `PREVIOUS_RELEASES_DIR`
b5ef74b248cd Merge bitcoin/bitcoin#36211: doc: Fix PR reference in productivity guide
5a5b1ed7471f Merge bitcoin/bitcoin#36201: Update embedded asmap to 1788801420
b3a9b84b37c0 doc: Correct upstream-pull reference
fc4f35fdce4d Merge bitcoin/bitcoin#35513: rpc: help metadata fixes
af83bacdf9d6 Merge bitcoin/bitcoin#36202: doc: add rel note about potential CJDNS removal
ecdf9db906b4 test: get_previous_releases.py use `PREVIOUS_RELEASES_DIR`
28b69e298884 http: stop processing requests from a client when send buffer is full
ad4eeaf859c4 ci: avoid modifying GOAL in 03_test_script.sh
7e75b3b922f9 Merge bitcoin/bitcoin#36116: iwyu: Fix warnings in `src/rpc` and treat them as errors
9d4325f40316 Merge bitcoin/bitcoin#36203: Update secp256k1 subtree to latest master
3c91db262b74 net: Update embedded asmap to 1788801420
ffe6aa57fef1 Merge bitcoin/bitcoin#36199: net: treat RFC 9637 new IPv6 documentation range as invalid
00d0c5107b92 test: return False for a too-short ECDSA signature
ba9050ac9b35 Update secp256k1 subtree to latest master
da3401e50fc1 Squashed 'src/secp256k1/' changes from 687155df6b..a7f264373e
7d54a88b4453 iwyu: Fix warnings in `src/rpc` and treat them as errors
462ff18d79bd iwyu, refactor: Fix includes in some source files
2285d1931aa8 Merge bitcoin/bitcoin#35468: ci, iwyu: Request IPC file generation explicitly
b48a27691ded fuzz: assert invalid addresses are not routable
e6c775c6d63a net: treat RFC 9637 new IPv6 documentation range as invalid
005ea9f42e50 Merge bitcoin/bitcoin#35778: scripted-diff: Use C.UTF-8 locale in all shell scripts
064122af269b Merge bitcoin/bitcoin#36181: ci: Upgrade IWYU to 0.27 compatible with Clang 23
99f81fe0296b Merge bitcoin/bitcoin#35303: policy: fix negative CFeeRate::ToString() formatting
46654094beef lint: Use C.UTF-8 locale only in shell scripts
d6a2341632a0 doc: add rel note about potential CJDNS removal
fb26bc9cfefe Merge bitcoin/bitcoin#35445: wallet, descriptor: Revert `StringType::COMPAT` for Miniscript expressions and drop the concept of a Descriptor ID that can be validated
494300f4cc92 Merge bitcoin/bitcoin#35796: depends: fix IPC listeners on macOS dying when accepting a dead socket
42d93d40de35 kernel: update chainTxData
a25511dfbcd3 kernel: update defaultAssumeValid and minimumChainWork
67726a63a41f kernel: update assumed blockchain and chainstate sizes
fcfc1df041b8 contrib: Update fixed seeds
6385aa1df8ab contrib: Update makeseeds for 30.3 and 31.x
0ae3b40c274a test: characterize startup with newly added prune and index
4c9d55a6125a Merge bitcoin/bitcoin#36076: psbt: preserve sighash type when merging inputs
59fd053dac83 Merge bitcoin/bitcoin#34931: validation: abort on DB unreadable coins instead of treating them as missing
33a363ea2508 Merge bitcoin/bitcoin#36168: PSBT: Make input/output `Merge()` methods return void
0b46fc9c5935 http: Add missing LIFETIMEBOUND annotations
ea785a31f783 psbt: preserve sighash type when merging inputs
013b0b2de481 Merge bitcoin/bitcoin#36176: wallet: avoid a crash when creating a wallet with -nosettings
2ed4be47213f Merge bitcoin/bitcoin#36113: psbt: fix rendering for invalid long sighash type field
19b0ff2fa050 Merge bitcoin/bitcoin#36136: rpc: remove stale "canonical form" claim from getdescriptorinfo help
0c6f2af97b5c Merge bitcoin/bitcoin#36127: wallet: remove unused code
3b944f194fdd iwyu: Switch to generated Clang intrinsics mapping file
1b5ee3be5948 ci: Upgrade IWYU to 0.27 compatible with Clang 23
6ed7c535adb0 iwyu: Prefer canonical headers
35104a8654f8 Merge bitcoin/bitcoin#35949: miner: Enforce Murch-Zawy rule (BIP54)
51db0e7696ed Merge bitcoin/bitcoin#36096: rpc: avoid quadratic JSON construction when keys are unique
161a9add8e02 Merge bitcoin/bitcoin#35164: test: cover P2SH sigop counting in test_witness_sigops
a174dd4017cf Merge bitcoin/bitcoin#36161: build: Remove `cmake/script/CoverageFuzz.cmake`
b557fb2728e9 Merge bitcoin/bitcoin#36164: util: diagnose dangling views of temporary strings
5f0daa0eae80 Merge bitcoin/bitcoin#36169: http: Use SO_EXCLUSIVEADDRUSE on Windows
a34fc8b11a42 wallet: handle disabled startup settings
b7113e6f42c2 test: characterize disabled wallet settings
f0c839ace5a2 Merge bitcoin/bitcoin#36123: http: throttle per-connection reads while a request is in flight
0f206eed51e2 Merge bitcoin/bitcoin#36130: test: add tests in transaction_tests.cpp covering live mutants
0b43dea121fc Merge bitcoin/bitcoin#36163: test: Add coverage for unsatisfiable locktime combination in PSBT `ComputeTimeLock()`
3596658af5eb Merge bitcoin/bitcoin#36166: validation: refactor: encapsulate Chainstate::m_target_blockhash
f32bfb25934f Merge bitcoin/bitcoin#35738: coins: parallel input prevout fetching followups
bcb09b3f4aec qa: Verify HTTP listen port exclusivity
af65069fd15b windows: Use SO_EXCLUSIVEADDRUSE over SO_REUSEADDR
82deb69111f1 PSBT: Make input/output `Merge()` methods return void
f04b0c31627a refactor(test): Make test method use Uppercase, shorten enum values
6eea8e313cce refactor(test): Simplify HTTP response check
852f201e09cb validation: refactor: encapsulate Chainstate::m_target_blockhash
fca8fef8f903 fuzz: assert HTTP framing is independent of stream segmentation
b57b0dbebd56 util: annotate `Split` input lifetime
34c5dc0583dd util: annotate string view input lifetimes
c368de3eec9c fuzz: exercise the HTTPRequest state machine
00a5f9b7375e build: Remove `cmake/script/CoverageFuzz.cmake`
69a640e05ec0 test: Add coverage for unsatisfiable locktime combination in PSBT ComputeTimeLock
5ce3a0b4aab5 test: cover legacy sigops count CHECKMULTISIG inaccurately
a5fc82e2b140 test: cover enforce BIP68 to tx versions higher than 2
bba1d4150ee8 test: cover IsFinalTx requires every input to be SEQUENCE_FINAL
4519933391dd Merge bitcoin/bitcoin#36137: validation: use unused SetTargetBlockHash
4ec6ff022a4b Merge bitcoin/bitcoin#36100: ci: use LLVM 23 in *san, fuzz, *cross jobs
7f0c4020e8d3 Merge bitcoin/bitcoin#36118: test: tolerate race condition in interface_http.py
455080105835 validation: use unused SetTargetBlockHash
5ba9af6b6922 ci: pass LIBCXX_INCLUDE_TESTS=OFF to LLVM build
feb3bd46e4c8 clang-tidy: remove some performance-* options
b4bd12d3d5d6 ci: use LLVM 23 in *san, fuzz, *cross jobs
d840adb9da54 Merge bitcoin/bitcoin#36144: rpc: detail x-bitcoin-unit in openrpc help
f41b917f47cd Merge bitcoin/bitcoin#36145: qa: Use IP_PORTRANGE_HIGH on OpenBSD for dynamic port allocation
d5fbe61f55b2 Merge bitcoin/bitcoin#35958: net: align v2 message type validation with v1 range
64ab0a06979e Merge bitcoin/bitcoin#36148: test: Avoid unsafe memory race in index_reorg_crash shutdown
57a79c69627d doc: remove json quoting from gettxoutsetinfo and getblockstats cli examples
a51df9b0ecf6 test: tolerate race condition in interface_http.py
fab80e82c108 test: Avoid unsafe memory race in baseindex_no_commit_ahead_of_flush
b811aeabad94 Merge bitcoin/bitcoin#36048: util: keep wallet names literal in notification commands
fa0f14ef5e76 test: Avoid unsafe memory race in index_reorg_crash shutdown
faf9c8e8a12c test: Clarify index.GetSummary().synced state in index_reorg_crash
a34861d280b3 test: unify how to avoid the creation of the default wallet in nodes
3458837a0b76 test: use ExtendedPrivateKey in wallet_importdescriptors.py
59ebf558f345 qa: Use IP_PORTRANGE_HIGH on OpenBSD for dynamic port allocation
6f6b2bbde244 Merge bitcoin/bitcoin#35808: fuzz: reset connman state in p2p targets
e85e27976bfb rpc: detail x-bitcoin-unit in openrpc help
3d1004cb9b8f http: throttle per-connection reads while a request is in flight
db39de560109 doc: add `-walletnotify` security note
1f9dfabef641 refactor: use string views in `ReplaceAll`
469b0e59a29a util: make `ReplaceAll` literal
604d7e8fdd95 test: characterize walletnotify shell injection
4efaa6763a7e test: simplify `ReplaceAll` coverage
793e22eed586 test: cover getrawtransaction on a stale block via txindex
a84fbf9dfd2c test: name the getrawtransaction test nodes
74ddf1c0a0ef refactor: use structured bindings for map entries
21d5d5cb7390 rpc: append unique container keys directly
23e512a58e69 rpc: avoid quadratic prioritised transaction JSON
9f0543d69a13 wallet: remove unused DatabaseOptions members
dc0395c5858a Merge bitcoin/bitcoin#36112: ci: Exclude subtrees from iwyu
37c57bc5c297 Merge bitcoin/bitcoin#36065: test: refactor: Remove confusing ignore_errors=True
8157964e66ce Merge bitcoin/bitcoin#36134: doc: Correct comment about which subsystem detects lagging clocks
259553c6628a Merge bitcoin/bitcoin#36131: rpc: Improve two field's OpenRPC types
1dad06eff3d5 remove stale canonical form claim from getdescriptorinfo help
55390d1827c7 doc: Correct comment about which subsystem detects lagging clocks
fe3c92cfe0da Merge bitcoin/bitcoin#36102: util: Replace !ContainsNoNUL() with ContainsNUL()
d23b53e0cfbc fuzz: allow http_request inputs to reach MAX_HEADERS_SIZE
58dfcf29f6da Merge bitcoin/bitcoin#35351: net: Disallow invalid HeadersSyncState due to lagging clock
c0ed327845be Merge bitcoin/bitcoin#36103: validation: remove unused code
78e691ea10a1 rpc: Change listunspent's ancestorfees type to NUM
73fb9ced563c rpc: Fix private key type in signrawtransactionwithkey
128e5c6805a0 Merge bitcoin/bitcoin#35477: test: exercise Schnorr signature cache in txvalidationcache_tests.cpp
bbed824a64f0 wallet: remove unused warnings parameter from CreateFromDump
2f6aa41d3d19 wallet: remove unused WalletDatabase::m_refcount
f64b3fa70f6a wallet: remove unused CHDChain keypool index members
4afc7bc40d4f wallet: remove unused COutput::ToString
a0e9aac42802 wallet: remove unused DescriptorScriptPubKeyMan::AddDescriptorKey
56af5e072a0d fuzz: extract http_request parse and framing check into helpers
d2e24e951de4 Merge bitcoin/bitcoin#36054: test: add script_tests cases covering interpreter mutants
75f64e50c67d test: exercise node abort on UTXO deserialization failure
4652cd0d828a txdb: detect UTXO deserialization errors via CDBWrapper::TryRead()
5dfbb91b6cc5 dbwrapper: add TryRead() to distinguish errors from valid outcomes
ca7162cde58e Merge bitcoin/bitcoin#35868: rpc, wallet: fix invalid JSON in HelpExampleRpc curl examples
d0e777baf5e2 Merge bitcoin/bitcoin#36111: rpc: bound memory for overlong Bech32 errors
fa3971011d1e ci: Exclude subtrees from iwyu
fa8566152a05 refactor: Bump old copyright header in univalue
05e49b342faa Merge bitcoin/bitcoin#36107: iwyu: Fix warnings in `src/init` and treat them as errors
1fca81960abc psbt: fix rendering for invalid long sighash type field
f14569f97d08 test: ipc should reject invalid json
858814146dd2 test: refactor Cap'n Proto exception assertions
7fcaccd9d0b7 bech32: bound overlength error locations
1bb5820b4411 wallet: Add addhdkey interface
1ad864127832 iwyu: Fix warnings in `src/init` and treat them as errors
82867073d6c3 wallet: Use WalletError for AddHDKey failures
f8769fc0b124 wallet: Move addhdkey logic into CWallet
e1a2b25d6c3b test: expand addhdkey coverage for locked wallet and bad key
21d4e0ba759b rpc, wallet, test: fix invalid JSON in HelpExampleRpc curl examples
15630c7b852c validation: remove unused m_chainparams from ATMPArgs
fa7be0a8df9d test: refactor: Remove confusing ignore_errors=True
84c5290149a3 validation: remove unused args from PolicyScriptChecks
a9d5cf7f9901 validation: remove unused args from ConsensusScriptChecks
d26dc09ee33e validation: remove unused total_vsize arg from PackageRBFChecks
2cb6c156e18b validation: remove unused PackageMempoolAcceptResult constructor
8d930981e9e1 refactor: Replace !ContainsNoNUL() with ContainsNUL()
f78834fac916 test: add missing coverage for CDBWrapper::Read() errors
1548d15de618 walletdb: Rename WriteTx to WriteFullTx
9a0628d9320d wallet: Write tx to database during CWalletTx::Update
74e1cd38f2a3 rpc: add bestblockhash to getmininginfo
ec2adf3c51ca test: Check miniscript descriptor h and apostrophe equivalence
a2d001b57c5f test: Enforce descriptor reimport is an update
e2b2f1c5c6f7 descriptor: Rename DescriptorID to CompatDescriptorHash
6ad31c062c70 test: Add 31.0 to wallet backwards compatibility test
2a6c53371be7 wallet, spkm: Treat Descriptor ID as an opaque SPKM ID
62e826fa7617 wallet: Update WalletDescriptor from another one instead of overwriting
1113f7590ed0 wallet, export: Include descriptor cache when exporting descriptors
9fc7b2618b6a spkm: Remove DescriptorSPKM constructor that doesn't take a descriptor
770ff64bd7fd test: Add v30.2 and Miniscript to wallet backwards compatibility test
35d6a60dbf5a descriptor: Add ToCanonicalString
1d87af26ce14 descriptors: Remove default StringType from PubkeyProvider::ToString()
1c7f9aaf758f miniscript: Don't use StringType::COMPAT
e07224f2d554 depends: fix IPC listeners on macOS dying when accepting a dead socket
b07810544f15 Remove MSVCRT-specific workarounds
7c86a370c8a2 doc: Update Windows build docs to reflect migration from MSVCRT to UCRT
f5910d1a3aaa ci: Remove Windows + MSVCRT jobs for cross-compiling and native testing
55f86ab1624a guix: Use UCRT runtime for Windows release binaries
4a12773f2697 test: cover DERSIG rejects a non-compound signature type
86c7fb910d67 test: cover OP_16 does not count towards the opcode limit
331bf798819c test: cover OP_WITHIN must pop all 3 elements
3bb87bc61b48 test: cover OP_FROMALTSTACK must pop the altstack
70701de7c555 ci: Make `test_bitcoin-qt.exe` output visible
ff3e2e4ebdce net: Trigger process abort when behind start block MTP
1883cecb4d05 test: Characterize lagging-clock headers presync
05e7d5731840 ipc, test: add checkSpawned() unit tests
42215b85811a init: correct first-run disk space estimate
e014e5bb61c1 miner: Enforce murch-zawy rule (BIP54)
d29b22d07897 fuzz: reset connman state in p2p targets
4200f8163a55 policy: fix negative CFeeRate::ToString() formatting
94cb65945738 depends: Update `boost` package to 1.92.0
cc577de95467 net: align v2 message type validation with v1 range
9054f7cde43a test: cover submitpackage other-wtxid for same-txid-diff-witness
1c557a380288 wallet: Add WriteTxMetadata to write just the tx record
e67f75cf7d3e wallet/scan: extract progress tracking helpers from `ChainScanner::Scan`
062aa3ce56d7 wallet/scan: extract QueueNextBlock
3655beb8f153 wallet/scan: extract block scanning logic to ScanBlock
4535dc0c7885 wallet/scan: extract block filter matching to ShouldFetchBlock
72a37031d325 wallet/scan: move WalletRescanReserver to scan files
0274e80130af wallet/scan: move RescanFromTime to ChainScanner as ScanFromTime
db9185a44464 wallet: introduce ChainScanner as a CWallet member
525163c2413e wallet/tests: pin rescan behavior
d180b891a290 test: add mixed P2SH/witness sigop accounting
c2da52d3660f wallet: allow importprunedfunds for spending transactions
db21e03c9d50 mempool: include unbroadcast txid memory
8d5c4a9290b0 test: characterize unbroadcast memory accounting
be30864ed1a6 doc: use overwrite (>) instead of append (>>) for one-shot PSBT files in offline-signing-tutorial.md
8bca7555f832 ipc, refactor: rename arg -ipcfd to -ipcchild
bd3a38f10ab7 ipc, refactor: return std::optional<mp::SocketId> from checkSpawned()
a31eb8bfa412 ci, iwyu: Request IPC file generation explicitly
0b3bb071036a test: add coverage for untested descriptor parse error paths
8e4b7ab7258a fuzz: use per-level fetch scopes in coinscache_sim
5292386b785a doc: improve CoinsViewOverlay documentation
d552c52b081c coins: log error reason when prevout fetch submission fails
2ffaa6e6a7db coins: delete Sync and SetBackend on CoinsViewOverlay
330022993fb9 coins: filter coinbase txid from parallel input fetching
adbff4d44286 init: don't suggest -reindex-chainstate for recovery on a pruned node
8976ba50a2b9 rpc: require connman in getnetworkinfo
975229580f74 rpc: Fix inaccuracies in RPC help docs
47632ab2a387 test: add coverage for feebumper uncomputable cluster error path
982ee649381f lint: Skip `libmultiprocess` subtree in `lint-shell-locale.py`
1194918a5d9c scripted-diff: Use C.UTF-8 locale in all shell scripts
13ce46ba1a79 doc: add release note for 27052
5d5397d84108 test: add functional test for block announcement time tracking
7d3d04e925c7 rpc: add last_block_announcement to the getpeerinfo output
26a25162a48a net: add m_last_block_announcement to CNodeStateStats
bb8bca630a8a change m_last_block_announcement type from int64_t to NodeClock::time_point
6e60c362bc1e test: add P2SH sigop counting coverage
412540e18d87 i2p: update leaseset encryption types
3ba1bbfa3f85 test: exercise Schnorr signature cache in txvalidationcache_tests.cpp
198b36bc85d5 test: respect "TAPROOT requires WITNESS" rule in `ValidateCheckInputsForAllFlags`
e78a2a0d00cf test: refactor: simplify tx vin/vout creation in txvalidationcache_tests.cpp
b7cbd804284b test: use MiniWallet for getblockstats test data generation
c8ee319fffa1 net: remove m_getaddr_sent
a1ecda260996 test: delete redundant addr relay assertion
e9dc16194b47 correct the linearize-data script (minor)
REVERT: e8a8daf3fad1 kernel: Add script tracer

git-subtree-dir: libbitcoinkernel-sys/bitcoin
git-subtree-split: 38aedda9e983f6dd1df7f3ec7bc5f1d0782e9459
fanquake added a commit that referenced this pull request Oct 15, 2026
3f7f845 fuzz: fix stale comments in http_request (frankomosh)

Pull request description:

  Follow-up to #36135 (comment), fixing a false comment flagged in review.

  The comment says a completed request is always handed back to a worker. Since #36174 it stays in `m_req` when the send buffer is over MAX_BODY_SIZE.

ACKs for top commit:
  pinheadmz:
    ACK 3f7f845
  hodlinator:
    ACK 3f7f845

Tree-SHA512: 6f499c394f8e933ba8b5eccd8228f3a7f5e77f41b7e998712c67af004d23c557b7191ace1ad47980920fde802debc73efb9e9b7163db564d3f35086dfeb46b37
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.

9 participants