-
Notifications
You must be signed in to change notification settings - Fork 224
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Secret Connection network timeouts #2
Comments
If anyone wants to take a crack at switching Secret Connection to use Tokio, they have just migrated to https://tokio.rs/blog/2019-08-alphas/ Using it will require nightly (soon to be 1.38 beta) Rust |
Another option (announced yesterday) is It allows easily adding timeouts which leverage futures while using an API that looks nearly identical to async fn get() -> io::Result<Vec<u8>> {
let mut stream = TcpStream::connect("example.com:80").await?;
stream.write_all(b"GET /index.html HTTP/1.0\r\n\r\n").await?;
let mut buf = vec![];
io::timeout(Duration::from_secs(5), async {
stream.read_to_end(&mut buf).await?
Ok(buf)
})
} |
@xla want to pair up on this soon? |
* build(deps): update tai64 requirement from 2 to 3 (informalsystems#22) Updates the requirements on [tai64](https://github.com/iqlusioninc/crates) to permit the latest version. - [Release notes](https://github.com/iqlusioninc/crates/releases) - [Commits](iqlusioninc/crates@canonical-path/v2.0.0...tai64/3.0.0) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * max_gas should be i64, can be -1 * remove unneed clones * remove secret_connection * implement utility traits for tendermint data types
Can we close this here then? |
Yes, doesn't make sense to have it open here. There used to be an open issue there tendermint/tmkms#310 but this is also tracked by tendermint/tmkms#352. |
* Removed amino traits, block, signature, vote * tendermint: Fix header hashing This commit fixes the header hashing mechanism to match that of the current Go version. It also adds a test to ensure the happy path works. Signed-off-by: Thane Thomson <connect@thanethomson.com> * light-client: Resolve #600 Demonstrates that the previous commit (fixing the header hash) fixes #600 when executed against a running Tendermint node. Signed-off-by: Thane Thomson <connect@thanethomson.com> * tendermint: Use shorthand form of method call Signed-off-by: Thane Thomson <connect@thanethomson.com> * tendermint: Add header hash check in integration test Signed-off-by: Thane Thomson <connect@thanethomson.com> * tendermint: Add workaround for empty BlockId Prost seems to encode an empty raw protobuf BlockId as an empty vector of bytes, whereas the Go encoder encodes the same object to [18, 0]. This commit adds a workaround to demonstrate that this is the case when testing against Tendermint v0.34 (otherwise header hashing would fail). Signed-off-by: Thane Thomson <connect@thanethomson.com> * rpc: Update integration test fixture It seems as though the previous commit data was generated by an older version of Tendermint. The new commit fixtures here are generated by Tendermint 0.34.0-99aea7b0 running in a Docker container on my local machine. Signed-off-by: Thane Thomson <connect@thanethomson.com> * Added Proposal domain type with signing - tests fail for now * tendermint: Make last_block_id encoding workaround more explicit Signed-off-by: Thane Thomson <connect@thanethomson.com> * tendermint: Fix empty last_block_id encoding issue Signed-off-by: Thane Thomson <connect@thanethomson.com> * Proposal and Vote signable bytes functions * PubKeyResponse made into PublicKey * Header.Hash() fixes * Merge conflict fixes * Proposal test fixes * Updated CHANGELOG * Update CHANGELOG.md * Update CHANGELOG.md * regenerate static model-based files * Update tendermint/Cargo.toml * Remvoed amino bech32 encoding * Updated priv_validator.json test with non-amino public key result * Removed comments referencing amino. * Review fixes #1 * Review fixes #2 * Review fixes #3 * Updated tests using testgen (#615) * Update tendermint/src/public_key.rs Co-authored-by: Tomas Tauber <2410580+tomtau@users.noreply.github.com> * fmt fix * Fixes number four, additional derive traits Co-authored-by: Thane Thomson <connect@thanethomson.com> Co-authored-by: Andrey Kuprianov <andrey@informal.systems> Co-authored-by: Tomas Tauber <2410580+tomtau@users.noreply.github.com>
Copying/pasting this from the original issue at tendermint/tmkms#310
The Secret Connection implementation presently has no notion of timeouts for things like connecting/"dialing" validators or reading from/writing to sockets.
Without timeouts, there are many cases which could potentially deadlock indefinitely inside of blocking I/O operations, and at least one user has experienced this.
Here are a few recommendations:
futures
/tokio
: this is the up-and-coming ecosystem solution to this general problem, and the one I'd recommend. It's a full asynchronous event model which solves, among other things, timeouts. Whenasync
/await
support ships in Rust 1.38 (scheduled to be released in August), migrating from blocking I/O should be fairly straightforward.libc
crate +poll(2)
system call: if we wanted to stick with blocking I/O, thepoll(2)
system call, as invoked through thelibc
crate, can be used to determine I/O readiness prior to performing a blocking I/O call, and also takes a timeout as an argument. This would probably be the lowest impact way to implement timeouts as it wouldn't involve switching away from blocking I/O.I would suggest migrating to
futures-rs
/Tokio to solve this problem, and leveraging theasync
/await
syntax when it lands later this month.The text was updated successfully, but these errors were encountered: