-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
[Fix] Make --rest optional to prevent auto-change of REST port with --dev #3221
base: mainnet-staging
Are you sure you want to change the base?
Conversation
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 needs a few more tests, but looking good
cli/src/commands/start.rs
Outdated
fn test_rest_ip_behavior() { | ||
// Test default REST IP when not specified in dev mode | ||
let config = Start::try_parse_from(["snarkos", "--dev", "1"].iter()).unwrap(); | ||
assert_eq!(config.rest, Some(SocketAddr::from_str("0.0.0.0:3030").unwrap())); | ||
|
||
// Test specified REST IP when passed in dev mode | ||
let config = Start::try_parse_from(["snarkos", "--dev", "1", "--rest", "127.0.0.1:8080"].iter()).unwrap(); | ||
assert_eq!(config.rest, Some(SocketAddr::from_str("127.0.0.1:8080").unwrap())); | ||
|
||
// Test default REST IP when REST flag is not passed in prod mode | ||
let config = Start::try_parse_from(["snarkos"].iter()).unwrap(); | ||
assert_eq!(config.rest, Some(SocketAddr::from_str("0.0.0.0:3030").unwrap())); | ||
|
||
// Test specified REST IP when passed in prod mode | ||
let config = Start::try_parse_from(["snarkos", "--rest", "192.168.1.1:8080"].iter()).unwrap(); | ||
assert_eq!(config.rest, Some(SocketAddr::from_str("192.168.1.1:8080").unwrap())); | ||
} |
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 is a great start, can you write a few more test cases covering more potential cases?
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'm not sure of the scope of this change, but no matter what, I want to make sure that anytime we require a port that we can set both host:port to a specific values. There's a tendency for us to simply bind to 0.0.0.0:port and this breaks multi-homed deployments in production environments. Dev environments, I understand, are special, but for everything else, these values, at a minimum, should be configurable either via command line or in a config file. |
Motivation
Solves Issue #3220 wherein specified rest port was overwritten by the default when the
--dev
flag was being used.Test Plan
This will only change a node's behavior when both
--dev
and--rest
are used.Tested locally.
Related PRs
(Link any related PRs here)