-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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(zk_inception): Add ecosystem ports scanner #2849
base: main
Are you sure you want to change the base?
Conversation
Marking as draft as ports in docker files are not parsed and tool is not yet used for allocation. |
zk_toolbox/crates/zk_inception/src/commands/ecosystem/args/init.rs
Outdated
Show resolved
Hide resolved
pub const DEFAULT_CONSENSUS_PORT: u16 = 3054; | ||
/// Default port for the web3 json rpc service | ||
pub const DEFAULT_WEB3_JSON_RPC_PORT: u16 = 3050; | ||
/// Default port for the web3 ws rpc service | ||
pub const DEFAULT_WEB3_WS_RPC_PORT: u16 = 3051; | ||
/// Default port for the healthcheck service | ||
pub const DEFAULT_HEALTHCHECK_PORT: u16 = 3071; | ||
/// Default port for the merkle tree | ||
pub const DEFAULT_MERKLE_TREE_PORT: u16 = 3072; | ||
/// Default port for the prometheus service | ||
pub const DEFAULT_PROMETHEUS_PORT: u16 = 3314; | ||
/// Default port for the contract verifier service | ||
pub const DEFAULT_CONTRACT_VERIFIER_PORT: u16 = 3070; |
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.
do we still need them?
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.
These are used for default port + offset allocation
format!("{}:{}", path, key.as_str().unwrap_or_default()) | ||
}; | ||
|
||
if key.as_str() == Some("ports") { |
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.
probably services is fine
HashMap::from([ | ||
( | ||
"web3_json_rpc_http_port".to_string(), | ||
DEFAULT_WEB3_JSON_RPC_PORT, | ||
), | ||
( | ||
"web3_json_rpc_ws_port".to_string(), | ||
DEFAULT_WEB3_WS_RPC_PORT, | ||
), | ||
("healthcheck_port".to_string(), DEFAULT_HEALTHCHECK_PORT), | ||
("merkle_tree_port".to_string(), DEFAULT_MERKLE_TREE_PORT), | ||
( | ||
"prometheus_listener_port".to_string(), | ||
DEFAULT_PROMETHEUS_PORT, | ||
), | ||
( | ||
"contract_verifier_port".to_string(), | ||
DEFAULT_CONTRACT_VERIFIER_PORT, | ||
), | ||
("consensus_port".to_string(), DEFAULT_CONSENSUS_PORT), | ||
]) |
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.
why do we need this function? We have already allocated ports in config file
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 will see if I can use those instead
]) | ||
} | ||
|
||
fn set_ports(&mut self, ports: HashMap<String, u16>) -> anyhow::Result<()> { |
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.
Do I understand it right, that if we have some another port, which is not specified, it'd fail?
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.
In this case, i'd rather save the whole paths to the value and write a small macros for updating it
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.
set_ports
is used here
This means set_ports
uses the same ports as the ones in get_default_ports
So it wouldn't fail as long as get_default_ports
is consistent with set_ports
. Both functions belong to the same trait: ConfigWithChainPorts
making it easy to keep it consistent.
How do you think we can improve this?
let consensus_port_range = DEFAULT_CONSENSUS_PORT + offset..PORT_RANGE_END; | ||
let consensus_port = |
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.
can't we reuse the ecosystem ports for it?
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.
You mean adding a function to EcosystemPorts
to allocate consensus port?
What ❔
Added
EcosystemPortsScanner
tool to scan ecosystem directory config and find all values for ports.Returns
EcosystemPorts
object with ports found and custom description of a service.EcosystemPorts
also contains methods to: check whether the port is assigned, allocate a new port in range, etc.Why ❔
With multiple chains and number of services (like explorer, etc.) growing - it is useful to have a tool (
EcosystemPorts
) that can be used to allocate new ports, thus, lowering the chance of port conflicts within created configuration.Checklist
zk fmt
andzk lint
.