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

[Fix] Make --rest optional to prevent auto-change of REST port with --dev #3221

Draft
wants to merge 9 commits into
base: mainnet-staging
Choose a base branch
from

Conversation

christianwwwwwwww
Copy link

@christianwwwwwwww christianwwwwwwww commented Apr 18, 2024

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)

@christianwwwwwwww christianwwwwwwww changed the title [Fix] Make --rest optional to prevent auto-change of REST port with --dev [Fix] Make --rest optional to prevent auto-change of REST port with --dev flag Apr 18, 2024
@christianwwwwwwww christianwwwwwwww changed the title [Fix] Make --rest optional to prevent auto-change of REST port with --dev flag [Fix] Make --rest flag optional to prevent auto-change of REST port with --dev flag Apr 18, 2024
@christianwwwwwwww christianwwwwwwww changed the title [Fix] Make --rest flag optional to prevent auto-change of REST port with --dev flag [Fix] Make --rest optional to prevent auto-change of REST port with --dev Apr 18, 2024
cli/src/commands/start.rs Outdated Show resolved Hide resolved
@christianwwwwwwww christianwwwwwwww marked this pull request as draft April 18, 2024 21:35
Copy link
Contributor

@iamalwaysuncomfortable iamalwaysuncomfortable left a 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

Comment on lines 839 to 855
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()));
}
Copy link
Contributor

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?

Copy link
Author

Choose a reason for hiding this comment

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

🫡

@damons
Copy link

damons commented May 24, 2024

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.

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.

None yet

3 participants