Skip to content
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

quinn-proto: Non-determinism in endpoint/connection/congestion #1684

Closed
michael-yxchen opened this issue Oct 13, 2023 · 6 comments · Fixed by #1691
Closed

quinn-proto: Non-determinism in endpoint/connection/congestion #1684

michael-yxchen opened this issue Oct 13, 2023 · 6 comments · Fixed by #1691

Comments

@michael-yxchen
Copy link
Contributor

While debugging an issue I have, I found that quinn-proto protocol isn't fully deterministic. The source of randomness seems to be the call to StdRng::from_entropy in three places:

rng: StdRng::from_entropy(),

let mut rng = StdRng::from_entropy();

random_number_generator: rand::rngs::StdRng::from_entropy(),

Are these intended?

Thank you for the help!

@djc
Copy link
Member

djc commented Oct 13, 2023

It's more interesting to look at how those random number generators are used. Did we promise somewhere that it would be fully deterministic?

@michael-yxchen
Copy link
Contributor Author

Sure, I'll circle back on how those RNGs are are used.

I got the idea that quinn-proto would be fully deterministic from here

//! quinn-proto contains a fully deterministic implementation of QUIC protocol logic. It contains
//! no networking code and does not get any relevant timestamps from the operating system. Most
//! users may want to use the futures-based quinn API instead.

I was thinking that it'd imply that there'd be no source of randomness from within, though it wasn't explicitly mentioned.

@djc
Copy link
Member

djc commented Oct 13, 2023

Yeah, I suppose the "fully deterministic" is a bit of a lie!

@Ralith
Copy link
Collaborator

Ralith commented Oct 13, 2023

Yep, that comment is out of date. The randomized stuff is usually of little interest, though -- tokens and a few skipped packet numbers, and whatever BBR does if you opt into that.

We could allow a RNG seed to be passed in to recover perfect determinism if someone actually wants that.

@michael-yxchen
Copy link
Contributor Author

For context, one of our nightly tests depends on quinn-proto. It failed one time but we were never able to reproduce the error. It would be really helpful if the protocol can accept some RNG seeds so the test is perfectly deterministic.

I can write up a patch if people don't have the capacity to do it.

@Ralith
Copy link
Collaborator

Ralith commented Oct 16, 2023

I'd be happy to review such a patch. I think adding an argument to quinn_proto::{Endpoint, Connection}::new should do the trick.

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 a pull request may close this issue.

3 participants