[POC] Full Libevent removal #34411

pull fanquake wants to merge 43 commits into bitcoin:master from fanquake:full_libevent_removal changing 57 files +2967 −1530
  1. fanquake commented at 12:35 pm on January 26, 2026: member

    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.

  2. DrahtBot commented at 12:35 pm on January 26, 2026: 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/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

  3. fanquake force-pushed on Jan 26, 2026
  4. DrahtBot added the label CI failed on Jan 26, 2026
  5. pinheadmz commented at 4:05 pm on January 26, 2026: member
    nit: Pull request description should be replaced by the lyrics of Taylor Swift’s “We Are Never Ever Getting Back Together” before merging.
  6. fanquake force-pushed on Jan 28, 2026
  7. fanquake force-pushed on Feb 2, 2026
  8. fanquake force-pushed on Feb 3, 2026
  9. fanquake force-pushed on Feb 9, 2026
  10. fanquake force-pushed on Feb 10, 2026
  11. DrahtBot added the label Needs rebase on Feb 11, 2026
  12. fanquake force-pushed on Feb 18, 2026
  13. DrahtBot removed the label Needs rebase on Feb 18, 2026
  14. DrahtBot added the label Needs rebase on Feb 19, 2026
  15. common: Add unused UrlEncode function 3d34a61e75
  16. http: Add HTTPHeader file in common
    This will be shared between the http server and the bitcoin-cli http client code.
    8d8e2c051f
  17. cli: Remove libevent usage
    Replace libevent-based HTTP client with a simple synchronous implementation using the Sock class directly.
    44988e1943
  18. refactor: Use constexpr in torcontrol where possible b005f12c83
  19. refactor: Modernize member variable names in torcontrol e32ed51c39
  20. refactor: Get rid of unnecessary newlines in logs 7c20e98980
  21. torcontrol: Remove libevent usage
    Replace libevent-based approach with using the Sock class and CThreadInterrupt.
    1730f4bac5
  22. fuzz: Improve torcontrol fuzz test
    Gets rid of the Dummy class and adds coverage of get_socks_cb.
    8bcb66edc8
  23. test: Add simple functional test for torcontrol e354eeefdb
  24. test: Add test for partial message handling in torcontrol 96e32538eb
  25. string: replace AsciiCaseInsensitiveKeyEqual with CaseInsensitiveEqual
    This reverts commit eea38787b9be99c3f192cb83fc18358397e4ab52 from PR #34242
    
    We do not need comparators for an unordered_map for HTTPHeaders, we just
    need a simple, locale-independent, ascii-only compare function for
    a vector of key-value pairs of strings.
    
    We have CaseInsensitiveEqual already in test utils, this commit moves
    it to the strencodings module for use in the application code.
    8037b5e3a1
  26. http: enclose libevent-dependent code in a namespace
    This commit is a no-op to isolate HTTP methods and objects that
    depend on libevent. Following commits will add replacement objects
    and methods in a new namespace for testing and review before
    switching over the server.
    1192966fa6
  27. http: Implement HTTPHeaders class
    see:
    https://www.rfc-editor.org/rfc/rfc2616#section-4.2
    https://www.rfc-editor.org/rfc/rfc7231#section-5
    https://www.rfc-editor.org/rfc/rfc7231#section-7
    https://httpwg.org/specs/rfc9111.html#header.field.definitions
    
    This commit also moves StringToBuffer to test/util/str
    since it is now used in more than one test.
    9848bfdccb
  28. http: Implement HTTPResponse class
    HTTP Response message:
    https://datatracker.ietf.org/doc/html/rfc1945#section-6
    
    Status line (first line of response):
    https://datatracker.ietf.org/doc/html/rfc1945#section-6.1
    
    Status code definitions:
    https://datatracker.ietf.org/doc/html/rfc1945#section-9
    5d2029e6b7
  29. http: Implement HTTPRequest class
    HTTP Request message:
    https://datatracker.ietf.org/doc/html/rfc1945#section-5
    
    Request Line aka Control Line aka first line:
    https://datatracker.ietf.org/doc/html/rfc1945#section-5.1
    
    See message_read_status() in libevent http.c for how
    `MORE_DATA_EXPECTED` is handled there
    e669dc8cdf
  30. http: Introduce HTTPServer class and implement binding to listening socket
    Introduce a new low-level socket managing class `HTTPServer`.
    
    BindAndStartListening() was copied from CConnMan's BindListenPort()
    in net.cpp and modernized.
    
    Unit-test it with a new class `SocketTestingSetup` which mocks
    `CreateSock()` and will enable mock client I/O in future commits.
    
    Co-authored-by: Vasil Dimov <vd@FreeBSD.org>
    6919661201
  31. HTTPServer: implement and test AcceptConnection()
    AcceptConnection() is mostly copied from CConmann in net.cpp
    and then modernized.
    
    Co-authored-by: Vasil Dimov <vd@FreeBSD.org>
    42789ed804
  32. HTTPServer: generate sequential Ids for each newly accepted connection
    Co-authored-by: Vasil Dimov <vd@FreeBSD.org>
    58703e3b33
  33. http: Introduce HTTPClient class 651e3828eb
  34. HTTPServer: start an I/O loop in a new thread and accept connections
    Socket handling methods are copied from CConnMan:
    
    `CConnman::GenerateWaitSockets()`
    `CConnman::SocketHandlerListening()`
    `CConnman::ThreadSocketHandler()` and `CConnman::SocketHandler()` are combined into ThreadSocketHandler()`.
    
    Co-authored-by: Vasil Dimov <vd@FreeBSD.org>
    e647b1af8d
  35. HTTPServer: read requests from connected clients
    `SocketHandlerConnected()` adapted from CConnman
    
    Testing this requires adding a new feature to the SocketTestingSetup,
    inserting a "request" payload into the mock client that connects
    to us.
    
    Co-authored-by: Vasil Dimov <vd@FreeBSD.org>
    851799761c
  36. HTTPserver: support "chunked" Transfer-Encoding 96226e3639
  37. HTTPServer: compose and send replies to connected clients
    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>
    1da887758f
  38. HTTPServer: disconnect clients b7170f034a
  39. Allow http workers to send data optimistically as an optimization e37ad1f18a
  40. HTTPServer: use a queue to pipeline requests from each connected client
    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.
    36b1d0bb8a
  41. define HTTP request methods at module level outside of class
    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.
    7f4d1e5073
  42. Add helper methods to HTTPRequest to match original API
    These methods are called by http_request_cb() and are present in the
    original http_libevent::HTTPRequest.
    22716eedff
  43. refactor: split http_request_cb into libevent callback and dispatch
    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.
    7e318a079d
  44. refactor: split HTTPBindAddresses into config parse and libevent setup
    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.
    fb9b0f01c0
  45. HTTPServer: implement control methods to match legacy API 8c00e0c400
  46. HTTPServer: disconnect after idle timeout (-rpcservertimeout) 822b0b0cee
  47. http: switch servers from libevent to bitcoin 7ae4054de3
  48. fuzz: switch http_libevent::HTTPRequest to http_bitcoin::HTTPRequest 1528884ecb
  49. http: delete libevent! ab62dfee61
  50. Revert "http: Add HTTPHeader file in common"
    This reverts commit 8d8e2c051fccd9d549892d06a3d674fc6927e300.
    82ff275b4d
  51. f: fixup b2de495ff2
  52. test: remove raii_event_tests 9d19b5729e
  53. cmake: remove libevent 2fa73d25da
  54. depends: remove libevent 8cb4229d38
  55. ci: remove libevent 18a7594d47
  56. vcpkg: remove libevent b3695e18a1
  57. doc: remove libevent 3b3f8eb7e2
  58. fanquake force-pushed on Feb 25, 2026
  59. DrahtBot removed the label Needs rebase on Feb 25, 2026
  60. DrahtBot commented at 8:51 pm on February 26, 2026: contributor
    🐙 This pull request conflicts with the target branch and needs rebase.
  61. DrahtBot added the label Needs rebase on Feb 26, 2026

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-03-09 21:13 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me