Skip to content

feat(gl-signerproxy): convert to fully async tokio#728

Open
cdecker wants to merge 2 commits into
mainfrom
2026w23-async-signerproxy
Open

feat(gl-signerproxy): convert to fully async tokio#728
cdecker wants to merge 2 commits into
mainfrom
2026w23-async-signerproxy

Conversation

@cdecker

@cdecker cdecker commented Jun 9, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Replaces the sync/threaded gl-signerproxy architecture with a fully async Tokio implementation across three files (passfd.rs, wire.rs, hsmproxy.rs)
  • New AsyncFdPassingExt trait on tokio::net::UnixStream uses async_io() + MSG_DONTWAIT to integrate SCM_RIGHTS fd passing with Tokio's readiness machinery
  • Fixes a subtle O_NONBLOCK bug: tokio::UnixStream::pair() sets both ends non-blocking via mio; when the remote fd is passed to lightningd via SCM_RIGHTS, CLN's C subdaemons receive a non-blocking socket and immediately get EAGAIN. Fix: use std::os::unix::net::UnixStream::pair() for the remote end, then convert only the local end to Tokio
  • Bumps tonic 0.8→0.11 and prost 0.11→0.12 to match the rest of the workspace

Test plan

  • cargo check --package gl-signerproxy compiles cleanly
  • pytest tests/test_all.py::test_gossipd_immediate_sync passes (this is the test that caught the O_NONBLOCK bug)
  • pytest tests/test_all.py::test_start passes
  • cargo tree -p gl-signerproxy --duplicates shows no duplicate tokio or tonic

🤖 Generated with Claude Code

@cdecker cdecker marked this pull request as draft June 9, 2026 10:11
cdecker and others added 2 commits June 9, 2026 15:10
Replace the sync/threaded architecture with a fully async implementation:

- passfd: new AsyncFdPassingExt trait on tokio::net::UnixStream using
  async_io() + MSG_DONTWAIT so SCM_RIGHTS fd passing integrates with
  Tokio's readiness machinery without blocking
- wire: DaemonConnection now wraps tokio::net::UnixStream directly;
  read/write are async fns using AsyncReadExt/AsyncWriteExt; no Mutex
  needed as each connection is exclusively owned by its task
- hsmproxy: process_requests is a plain async fn; start_handler is a
  sync wrapper calling tokio::spawn to avoid recursive async types;
  Arc<Runtime> and all block_on calls removed

Fix: use std::os::unix::net::UnixStream::pair() for the remote end of
new subdaemon connections (type-9 handler). tokio::UnixStream::pair()
sets O_NONBLOCK on both ends via mio; SCM_RIGHTS inherits fd flags, so
CLN's C subdaemons received a non-blocking socket and got EAGAIN on
every blocking read/write. The local end is converted to Tokio via
set_nonblocking(true) + UnixStream::from_std().

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Brings gl-signerproxy in line with the rest of the workspace.
tonic-build build-dep updated to match.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@cdecker cdecker force-pushed the 2026w23-async-signerproxy branch from 0e4aced to 856d7ae Compare June 9, 2026 13:10
@cdecker cdecker marked this pull request as ready for review June 9, 2026 13:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant