-
Notifications
You must be signed in to change notification settings - Fork 180
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
feat(relay)!: relay only mode now configurable #3056
Conversation
Documentation for this PR has been generated and is available at: https://n0-computer.github.io/iroh/pr/3056/docs/iroh/ Last updated: 2025-01-03T20:07:54Z |
please also remove the old env variable, to simplify things |
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.
I think it is a good move that this is still cfg(any(test, feature = "test-utils"))
. I think this generally looks fine?
iroh/bench/src/lib.rs
Outdated
/// to test throughput for relay-only traffic locally. | ||
/// (e.g. `DEV_RELAY_ONLY=true cargo run --release -- iroh --with-relay`) | ||
#[clap(long, default_value_t = false)] | ||
pub with_relay: bool, |
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.
Thanks for adjusting the docs here, but these docs are actually the CLI help text.
So saying "hey you can change the endpoint config" doesn't really help when you're reading this as CLI text 😬
I'd appreciate if there'd be two possible solutions:
- Add another
pub only_relay: bool
option, so you can runcargo run --release -- iroh --only-relay
(andonly-relay
should implywith-relay
) or - Rename
with_relay
toonly_relay
and make that also set.relay_only(true)
on the endpoint.
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.
Went with option 2 but am not happy about it as it depends on the test/test-utils feature to be active. I'll revert it to option 1.
Nvm, works just fine because local-relay
pulls in the iroh/test-utils
feature.
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.
Nice!
Only other thing that might be nice is documenting that you need the local-relay
feature to be active (and telling the user how to run this thing, so cargo run --release --features=local-relay -- iroh --only-relay
).
iroh/src/endpoint.rs
Outdated
@@ -417,6 +421,14 @@ impl Builder { | |||
self.insecure_skip_relay_cert_verify = skip_verify; | |||
self | |||
} | |||
|
|||
/// "relay_only" mode implies we only use the relay to communicate |
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.
nit: something like "Setting this, implies ... " reads bettert than repeating the function name
FWIW this PR is nowhere ready to be merged, the pieces checking and utilizing the relay_only flag are disconnected from the endpoint and never get passed in. This was circumvented by just dropping in that env var, but had some random loose bits. I managed to clean up the confusing bits, but need to thread the needle a bit more. |
iroh/src/endpoint.rs
Outdated
/// This implies we only use the relay to communicate | ||
/// and do not attempt to do any hole punching. | ||
#[cfg(any(test, feature = "test-utils"))] | ||
pub fn relay_only(mut self, relay_only: bool) -> Self { |
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.
It is not the end of the world since this is a debug feature, but I would probably favour an enum to configure which path to use instead of a bool. E.g. we might in the future want to have more complex logic to select which path to take (IPV4/IPV6/Relay)
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.
I guess that will make more sense to implement once we start dealing with multipath as we currently don't really have an idea of everything we will need to pass in.
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.
Make it an enum with 2 cases, then it is still easier to extend than a bool
Any particular reason we need the feature flag dance? #[cfg(any(test, feature = "test-utils"))] I think in none of the places where this is used a flag check is going to be a performance problem. So let's make the path use (for now just RelayOnly and All) an enum, set it to All by default, and have this enabled even without feature flags. |
We generally wanted to avoid exposing this fluff to end users without specific reason as you generally should never want to do relay only. Im fine with doing that, simplifies the code a nice bit. @dignifiedquire you wanted to have it feature flagged initially, anything against it? |
I can see why we don't want users to mess with this, but having lots of code gated by feature flags is not nice. So either mark the builder fn to set this with docs(hidden), or have just the public fn to set this feature gated? |
that usually leads to a bunch of dead code warnings |
This is now at a middle ground using and enum for path selection. |
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.
Needs some CI massage.
- Keeping this behind the
test_utils
feature flag sets expectations. IMO important ones. Generally we want people to avoid enabling relay-only mode. - If someone really wants relay-only mode, it's just a feature flag away. It's not dangerous to enable
test_utils
. I'll totally steal this for e.g. iroh-doctor for testing stuff on mobile.
/// Create a new [`NodeMap`] from a list of [`NodeAddr`]s. | ||
pub(super) fn load_from_vec(nodes: Vec<NodeAddr>) -> Self { | ||
Self::from_inner(NodeMapInner::load_from_vec(nodes)) | ||
} | ||
|
||
#[cfg(any(test, feature = "test-utils"))] | ||
/// Create a new [`NodeMap`] from a list of [`NodeAddr`]s. | ||
pub(super) fn load_from_vec(nodes: Vec<NodeAddr>, path_selection: PathSelection) -> Self { |
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.
I would prefer to make this a seperate method, like set_path_selection
, instead of changing the signature
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.
Issue is, the inner requires the flag and it needs to be provided at load time. Should I keep it or move forward and unpack the whole thing?
Description
This will allow us to configure relay only mode at runtime.
Useful for easy testing without having to rebuild with theDEV_RELAY_ONLY
environment variable set.The
DEV_RELAY_ONLY
compile time env var has been completely dropped and arelay_only
option has been threaded through the entire stack whentest-utils
is enabled. An example of it can be followed with theiroh/examples/transfer.rs
where you can set up a provide and fetch node with--relay-only
.Breaking Changes
Notes & open questions
Change checklist