Skip to content

Conversation

@ogabrielides
Copy link
Collaborator

No description provided.

string memory committeeHosts = vm.envString("POD_COMMITTEE_HOSTS");

// Split comma-separated host:port pairs
string[] memory entries = vm.split(committeeHosts, ",");
Copy link
Contributor

Choose a reason for hiding this comment

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

If the env var is empty string "" or has a trailing comma (e.g., "a:1,b:2,"), vm.split yields an empty entry ("") that will fail with invalid host:port entry, which is confusing vs. having an early check for bytes(committeeHosts).length > 0 and having instead an error handling message like "no hosts provided"

Copy link
Contributor

Choose a reason for hiding this comment

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

another case, accidental white space, vm.split doesn’t trim; vm.parseUint(" 8080") will likely revert if we let spaces out, say if someone sets "host1:8080, host2:9090" (note the space), parts.length == 2 passes, but vm.parseUint(parts[1]) will revert.

maybe a prior removal of possible spaces beforevm.split could help avoid that

Copy link
Contributor

Choose a reason for hiding this comment

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

IPv6 not supported by this split

[2001:db8::1]:8080 would break vm.split(entry, ":") below

Copy link
Contributor

@gubatron gubatron left a comment

Choose a reason for hiding this comment

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

some suggestions to harden getValidatorHostsAndPorts() against fat fingers on the env POD_COMITTEE_HOSTS values

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.

3 participants