Skip to content

[POC] Full Libevent removal#34411

Draft
fanquake wants to merge 43 commits intobitcoin:masterfrom
fanquake:full_libevent_removal
Draft

[POC] Full Libevent removal#34411
fanquake wants to merge 43 commits intobitcoin:masterfrom
fanquake:full_libevent_removal

Conversation

@fanquake
Copy link
Member

@fanquake fanquake commented Jan 26, 2026

This builds on all the work being done by pinheadmz and fjahr (#32061, #34342, #34158), to demo a libevent-less bitcoind.

One thing we could decide to change, or not, is the libevent logging catergory. Other than that, any remaining references to libevent, should be in documentation/code comments.

@DrahtBot
Copy link
Contributor

DrahtBot commented Jan 26, 2026

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

Reviews

See the guideline for information on the review process.
A summary of reviews will appear here.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #34589 (ci: Temporarily use clang in valgrind tasks by maflcko)
  • #34562 (ThreadPool follow-ups, proactive shutdown and HasReason dependency cleanup by furszy)
  • #34495 (Replace boost signals with minimal compatible implementation by theuni)
  • #34486 (net: Reduce local network activity when networkactive=0 by willcl-ark)
  • #34342 (cli: Replace libevent usage with simple http client by fjahr)
  • #33974 (cmake: Check dependencies after build option interaction by hebasto)
  • #33414 (tor: enable PoW defenses for automatically created hidden services by vasild)
  • #31723 (qa: Facilitate debugging bitcoind inside functional tests by hodlinator)
  • #31425 (RFC: Riscv bare metal CI job by sedited)
  • #28690 (build: Introduce internal kernel library by sedited)
  • #26812 (test: add end-to-end tests for CConnman and PeerManager by vasild)
  • #26022 (Add util::ResultPtr class by ryanofsky)
  • #25665 (refactor: Add util::Result failure types and ability to merge result values by ryanofsky)
  • #21283 (Implement BIP 370 PSBTv2 by achow101)

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

LLM Linter (✨ experimental)

Possible typos and grammar issues:

  • an unique -> a unique [Use "a" before a consonant sound; "unique" begins with a consonant sound, so "a unique" is correct]

Possible places where named args for integral literals may be used (e.g. func(x, /*named_arg=*/0) in C++, and func(x, named_arg=0) in Python):

  • sock.Recv(recv_buf, sizeof(recv_buf), /flags=/0) in src/bitcoin-cli.cpp
  • sock.Recv(recv_buf, sizeof(recv_buf), /flags=/0) in src/bitcoin-cli.cpp
  • sock.Recv(recv_buf, sizeof(recv_buf), /flags=/0) in src/bitcoin-cli.cpp

(Only occurrences matching the criteria were these third-argument integral literals used in C++ socket Recv calls.)

2026-02-25 15:14:37

@pinheadmz
Copy link
Member

nit: Pull request description should be replaced by the lyrics of Taylor Swift's "We Are Never Ever Getting Back Together" before merging.

@fanquake fanquake force-pushed the full_libevent_removal branch from cd01007 to 71fc75c Compare January 28, 2026 13:36
@fanquake fanquake force-pushed the full_libevent_removal branch 2 times, most recently from bf11d79 to 4c1f788 Compare February 3, 2026 11:12
@fanquake fanquake force-pushed the full_libevent_removal branch from 4c1f788 to 2811bb3 Compare February 9, 2026 10:23
pinheadmz and others added 22 commits February 25, 2026 14:38
Sockets-touching bits copied and adapted from `CConnman::SocketSendData()`

Testing this requires adding a new feature to the SocketTestingSetup,
returning the DynSock I/O pipes from the mock socket so the received
data can be checked.

Co-authored-by: Vasil Dimov <vd@FreeBSD.org>
See https://www.rfc-editor.org/rfc/rfc7230#section-6.3.2

> A server MAY process a sequence of pipelined requests in
  parallel if they all have safe methods (Section 4.2.1 of [RFC7231]),
  but it MUST send the corresponding responses in the same order that
  the requests were received.

We choose NOT to process requests in parallel. They are executed in
the order recevied as well as responded to in the order received.
This prevents race conditions where old state may get sent in response
to requests that are very quick to process but were requested later on
in the queue.
This is a refactor to prepare for matching the API of HTTPRequest
definitions in both namespaces http_bitcoin and http_libevent. In
particular, to provide a consistent return type for GetRequestMethod()
in both classes.
These methods are called by http_request_cb() and are present in the
original http_libevent::HTTPRequest.
The original function is passed to libevent as a callback when HTTP
requests are received and processed. It wrapped the libevent request
object in a http_libevent::HTTPRequest and then handed that off to
bitcoin for basic checks and finally dispatch to worker threads.

In this commit we split the function after the
http_libevent::HTTPRequest is created, and pass that object to a new
function that maintains the logic of checking and dispatching.

This will be the merge point for http_libevent and http_bitcoin,
where HTTPRequest objects from either namespace have the same
downstream lifecycle.
The original function was already naturally split into two chunks:
First, we parse and validate the users' RPC configuration for IPs and
ports. Next we bind libevent's http server to the appropriate
endpoints.

This commit splits these chunks into two separate functions, leaving
the argument parsing in the common space of the module and moving the
libevent-specific binding into the http_libevent namespace.

A future commit will implement http_bitcoin::HTTPBindAddresses to
bind the validate list of endpoints by the new HTTP server.
@DrahtBot
Copy link
Contributor

🐙 This pull request conflicts with the target branch and needs rebase.

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.

4 participants