informalsystems / tendermint-rs

Client libraries for Tendermint/CometBFT in Rust!
Apache License 2.0
615 stars 225 forks source link

[WIP] p2p: add `AsyncSecretConnection` based on tokio #1464

Open tony-iqlusion opened 3 months ago

tony-iqlusion commented 3 months ago

Adds an async version of SecretConnection, currently specialized to TCP-based connections exclusively.

This requires quite a bit of duplication, especially since the existing SecretConnection implementation is entirely built around std::io traits, which are unusable in an async context.

The implementation returns whole chunks as a Vec<u8>, which avoids the need to "double buffer" incoming data as ownership of such data is passed directly to the caller upon completing a read.

tony-iqlusion commented 3 months ago

Note: I'd like to move TMKMS to an async architecture, which would make it better at concurrency (e.g. supporting multiple YubiHSMs, and pipelining extension signing requests to multiple YubiHSMs) but that's difficult to do when the entire request layer is synchronous.

I thought I'd do this in an additive manner for now, rather than attempting to make any breaking changes to tendermint-p2p.

This implementation is currently untested. I'd like to get some tests in to show it can at least interop against the synchronous SecretConnection server.