-
Notifications
You must be signed in to change notification settings - Fork 382
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
Add Intersection
trait and implement it on RelayConstraints
#5835
Conversation
Intersection
trait and implement it on RelayConstraint
Intersection
trait and implement it on RelayConstraints
099d5e7
to
5724de5
Compare
5eb6fd5
to
5beb23f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 18 of 24 files at r1, 9 of 9 files at r3, 5 of 5 files at r4, 2 of 3 files at r5, 6 of 6 files at r6, all commit messages.
Reviewable status: all files reviewed, 10 unresolved discussions (waiting on @MarkusPettersson98 and @Serock3)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: all files reviewed, 9 unresolved discussions (waiting on @Serock3)
mullvad-types/Cargo.toml
line 31 at r1 (raw file):
Previously, MarkusPettersson98 (Markus Pettersson) wrote…
Sure 😊
Done
mullvad-types/src/relay_constraints.rs
line 685 at r1 (raw file):
Previously, Serock3 (Sebastian Holmin) wrote…
// otherwise = None
Done.
mullvad-types/src/relay_constraints.rs
line 1018 at r1 (raw file):
Previously, Serock3 (Sebastian Holmin) wrote…
/// Internal builder state for a [`RelayConstraint`] parametrized over the
Done.
mullvad-types/src/relay_constraints.rs
line 1022 at r1 (raw file):
Previously, Serock3 (Sebastian Holmin) wrote…
/// - The type parameter `VpnProtocol` keeps track of which VPN protocol that
Done.
mullvad-types/src/relay_constraints.rs
line 1036 at r1 (raw file):
Previously, Serock3 (Sebastian Holmin) wrote…
/// Create a new [`RelayConstraintBuilder`] with unopinionated defaults.
Done.
mullvad-types/src/relay_constraints.rs
line 1094 at r1 (raw file):
Previously, Serock3 (Sebastian Holmin) wrote…
/// otherwise unopinionated defaults.
Done.
mullvad-types/src/relay_constraints.rs
line 1158 at r1 (raw file):
Previously, Serock3 (Sebastian Holmin) wrote…
/// otherwise unopinionated defaults.
Done.
mullvad-types/src/constraints/constraint.rs
line 95 at r1 (raw file):
Previously, Serock3 (Sebastian Holmin) wrote…
/// Define the intersection between two arbitrary [`Constraint`]s. This
Done.
36af939
to
0f56503
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 4 of 4 files at r7, all commit messages.
Reviewable status: all files reviewed, 9 unresolved discussions (waiting on @Serock3)
test/test-manager/src/tests/tunnel.rs
line 301 at r7 (raw file):
) -> Result<(), Error> { let relay_constraints = relay_constraints::builder::wireguard::new() .multihop()
Clean.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: all files reviewed, 9 unresolved discussions (waiting on @Serock3)
test/test-manager/src/tests/tunnel.rs
line 301 at r7 (raw file):
Previously, dlon (David Lönnhager) wrote…
Clean.
:D
0f56503
to
973a436
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: all files reviewed, 9 unresolved discussions (waiting on @Serock3)
6756abe
to
3b16dab
Compare
fn test_identity(relay_constraints in relay_constraint()) { | ||
// The identity element | ||
let identity = builder::any().build(); | ||
prop_assert_eq!(identity.clone().intersection(relay_constraints.clone()), relay_constraints.clone().into()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This becomes a bit less readable because of the .clone()
s. I don't suppose that intersection
could take references instead of consuming both the arguments?
// The identity element | ||
let identity = Constraint::Any; | ||
prop_assert_eq!(x.intersection(identity), x.into()); | ||
prop_assert_eq!(identity.intersection(x), x.into()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both of these are not technically needed since you also test commutativity
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True, but I think I want to leave it in for documentation's sake 😊
ebc5009
to
fbf049a
Compare
This commit initializes a series of commits which aims to decompose `relay_constraints.rs` into smaller modules.
Add `Intersection` trait and implement it on the `Constraint` type. Use `proptest` write a "proof" for associativity of `intersection`
Convert `WireguardConstraints::use_multihop` to `Constraint<bool>` in order to cleanly conform to the `identity` property required by `Intersection`. This is important to be able to express the merge between our retry strategy and user-defined relay constraints.
fbf049a
to
056e7bf
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 7 of 11 files at r8, 7 of 7 files at r9, all commit messages.
Reviewable status: all files reviewed, 21 unresolved discussions (waiting on @MarkusPettersson98 and @Serock3)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: all files reviewed, 22 unresolved discussions (waiting on @MarkusPettersson98 and @Serock3)
mullvad-types/src/relay_constraints.rs
line 1116 at r9 (raw file):
pub use wireguard::*; /// Internal builder state for a [`RelayConstraint`] parameterized over the
Is RelayConstraint
(rather than RelayConstraints
) a typo? I also think the whole thing should be called RelayConstraintsBuilder
, but that might be verging on nitpicking.
Closing this in favor of #5935 |
This PR is one in a series of PRs which aims to make working with the relay selector easier.
The goal of this PR is to be able to in a declarative way express a set of
RelayConstraints
and define a semantic for how to merge differentRelayConstraints
which are compatible. This is useful for when the app wants to use a set of defaultRelayConstraints
to try on successive reconnection attempts while always respecting user preferences.This change is