Skip to content

chore: slim the futures facade dependency - #663

Merged
emlautarom1 merged 2 commits into
mainfrom
chore/slim-futures-facade
Aug 20, 2026
Merged

chore: slim the futures facade dependency#663
emlautarom1 merged 2 commits into
mainfrom
chore/slim-futures-facade

Conversation

@emlautarom1-agent

@emlautarom1-agent emlautarom1-agent Bot commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Closes #596

Summary

core, eth2api and cluster no longer depend on the futures facade, and ten call sites move to std::task::Waker::noop / std::pin::pin!.

This does not slim the build graph

The Cargo.lock diff is 2 insertions / 3 deletions — only the three crates' dependent lists. futures is a direct dependency of 20 crates we don't control (libp2p plus 13 of its sub-crates, four alloy crates, if-watch, rw-stream-sink, yamux, wiremock), and ten Pluto crates still need it. tokio-stream was already in the graph via p2p.

Two suggestions from the issue are unreachable for that reason and are not implemented:

  1. default-features = false would not drop the executor. libp2p-core declares futures with features = ["executor", "thread-pool"], and cargo unifies features graph-wide.
  2. Dropping futures-timer from peerinfo changes nothing — nine libp2p crates depend on it directly, and it is what libp2p's own ConnectionHandlers use for timeouts.

What this buys is manifest honesty: every remaining futures dependency is traceable to a libp2p-driven need.

Out of scope

join_all stays. JoinSet::join_all returns results in completion order where join_all preserves input order, and FuturesUnordered has no tokio equivalent.

The other ten crates keep futures for select_next_some (app, relay-server), FuturesUnordered (cli), and futures' AsyncRead/AsyncWrite/io::Cursor for libp2p's protocol APIs (p2p, consensus, peerinfo, parsigex, dkg, priority).

Both APIs are stable in the pinned 1.95 toolchain, so the ten call
sites that reached for `futures::task::noop_waker{,_ref}` and
`futures::pin_mut!` now use std directly.

Refs #596
`core` boxes its recast future with std types. `eth2api` and `cluster`
take their `Stream`/`StreamExt` from `tokio-stream`, whose `Stream` is
the same `futures_core` trait, so `event_stream`'s public signature is
unchanged.

Refs #596

@emlautarom1-agent emlautarom1-agent Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Notes on the three spots that aren't self-evident from the diff.

};

type RecastFuture = BoxFuture<'static, Result<()>>;
type RecastFuture = Pin<Box<dyn Future<Output = Result<()>> + Send>>;

@emlautarom1-agent emlautarom1-agent Bot Aug 20, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Why inline rather than keep BoxFuture. This alias was the only thing core used futures for, so spelling it out drops the dependency from the workspace's most-depended-on crate. app's node/wire.rs already defines a SyncBoxFuture alias this way.

) -> Result<(Stream, PeerInfo), Failure> {
let send = protocol.send_peer_info(stream, &request);
futures::pin_mut!(send);
let send = std::pin::pin!(protocol.send_peer_info(stream, &request));

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No mut needed here, unlike the other two pin! sites. futures::pin_mut! expands to let mut $x = ... unconditionally. future::select takes the pinned future by value, so a plain binding is enough.

The two sites that poll in a loop — app/src/sse/mod.rs and this crate's sibling in eth2api — do need let mut, since StreamExt::next borrows &mut self.

@emlautarom1 emlautarom1 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Very quick refactor, drops some dependencies in the Cargo.toml files.

@emlautarom1
emlautarom1 marked this pull request as ready for review August 20, 2026 22:35
@emlautarom1
emlautarom1 merged commit c0495e2 into main Aug 20, 2026
28 checks passed
@emlautarom1
emlautarom1 deleted the chore/slim-futures-facade branch August 20, 2026 22:35
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.

Slim the futures package facade dependency

1 participant