Skip to content

Commit 9821a20

Browse files
fix(zk_toolbox): fix port offset for new chains (matter-labs#2803)
## What ❔ Fixed port offset for newly created chains via `zk_inception`: - Use `chain.id` instead of `chain.chain_id` - Use `(chain.id - 1) * 100` as an offset to keep the port for the first chain as 3050 ## Why ❔ Using `chain.chain_id` was not intended as the resulting port number could potentially overflow. ## Checklist - [x] PR title corresponds to the body of PR (we generate changelog entries from PRs). - [x] Tests for the changes have been added / updated. - [x] Documentation comments have been added / updated. - [x] Code has been formatted via `zk fmt` and `zk lint`.
1 parent bc0d7d5 commit 9821a20

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

zk_toolbox/crates/config/src/general.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ pub fn update_ports(config: &mut GeneralConfig, ports_config: &PortsConfig) -> a
127127
let prometheus = config
128128
.prometheus_config
129129
.as_mut()
130-
.context("Contract Verifier config is not presented")?;
130+
.context("Prometheus config is not presented")?;
131131

132132
api.web3_json_rpc.http_port = ports_config.web3_json_rpc_http_port;
133133
update_port_in_url(

zk_toolbox/crates/zk_inception/src/commands/chain/args/init.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ pub struct PortOffset(u16);
2222

2323
impl PortOffset {
2424
pub fn from_chain_id(chain_id: u16) -> Self {
25-
Self(chain_id * 100)
25+
Self((chain_id - 1) * 100)
2626
}
2727
}
2828

@@ -88,7 +88,7 @@ impl InitArgs {
8888
l1_rpc_url,
8989
port_offset: self
9090
.port_offset
91-
.unwrap_or(PortOffset::from_chain_id(config.chain_id.as_u64() as u16))
91+
.unwrap_or(PortOffset::from_chain_id(config.id as u16))
9292
.into(),
9393
}
9494
}

0 commit comments

Comments
 (0)