Skip to content

Update tokio to 1.0 #781

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

Merged
merged 4 commits into from
Feb 2, 2021
Merged

Conversation

TheBlueMatt
Copy link
Collaborator

This requires ensuring TcpStreams are set in nonblocking mode as
tokio doesn't handle this for us anymore, so we adapt the public
API to just accept std TcpStreams instead of an extra conversion
hop. Luckily converting them is cheap.

This requires ensuring TcpStreams are set in nonblocking mode as
tokio doesn't handle this for us anymore, so we adapt the public
API to just accept std TcpStreams instead of an extra conversion
hop. Luckily converting them is cheap.
Comment on lines 187 to 188
with:
fetch-depth: 0
Copy link
Contributor

Choose a reason for hiding this comment

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

The error message may have been a red herring. Instead, the location of the coverage data may be different in Rust 1.45 as @valentinewallace pointed out: #774 (comment)

Comment on lines +233 to +234
stream.set_nonblocking(true).unwrap();
let (reader, writer) = io::split(TcpStream::from_std(stream).unwrap());
Copy link
Contributor

Choose a reason for hiding this comment

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

IIUC, the problem was that our test was using std::net::TcpStream::connect without setting the result to non-blocking before converting it to tokio::net::TcpStream.

Could we fix the problem by updating the test to use tokio::net::TcpStream::connect instead? Then a conversion wouldn't be needed here nor in connect_outbound.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'd initially gone with tokio::net::TcpStream in the public API but then realized its much neater to do the set_nonblocking call in Connection::new given its pretty easy to accidentally do the same issue again, and its simpler for our users to not have to think about it than not. Given that, its fewer conversion calls to just accept an std::net::TcpStream instead of a tokio one. It doesn't really matter, though, just pretty poor API design on Tokio's part.

@TheBlueMatt TheBlueMatt force-pushed the 2021-01-tokio-1 branch 2 times, most recently from 6affd0b to bf45c98 Compare January 27, 2021 02:52
Rustc 1.45 moved the paths to test binaries, so we need to update
our CI scripts to run the correct ones under kcov.

The solution to this was pointed out by Val at
lightningdevkit#774 (comment)
@codecov
Copy link

codecov bot commented Jan 27, 2021

Codecov Report

Merging #781 (0809662) into main (f151c02) will decrease coverage by 0.49%.
The diff coverage is 93.75%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #781      +/-   ##
==========================================
- Coverage   91.29%   90.79%   -0.50%     
==========================================
  Files          37       38       +1     
  Lines       22921    23168     +247     
==========================================
+ Hits        20925    21036     +111     
- Misses       1996     2132     +136     
Impacted Files Coverage Δ
lightning/src/ln/peer_handler.rs 49.72% <ø> (-1.30%) ⬇️
lightning-net-tokio/src/lib.rs 76.36% <93.75%> (ø)
lightning/src/util/logger.rs 57.14% <0.00%> (-2.54%) ⬇️
lightning/src/ln/wire.rs 59.24% <0.00%> (-2.37%) ⬇️
lightning/src/util/config.rs 48.78% <0.00%> (-1.22%) ⬇️
lightning/src/routing/network_graph.rs 90.97% <0.00%> (-1.22%) ⬇️
lightning/src/util/macro_logger.rs 88.33% <0.00%> (-0.96%) ⬇️
lightning/src/ln/onion_route_tests.rs 96.85% <0.00%> (-0.69%) ⬇️
lightning/src/chain/chainmonitor.rs 94.11% <0.00%> (-0.55%) ⬇️
... and 24 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f151c02...32abba7. Read the comment docs.

@TheBlueMatt
Copy link
Collaborator Author

Not sure why CI had refused to run previously, but this is pretty trivial and the last commit is completely trivial. Going to merge.

@TheBlueMatt TheBlueMatt merged commit 1ce1902 into lightningdevkit:main Feb 2, 2021
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.

2 participants