Skip to content

Commit abe35bf

Browse files
authored
revert(configs): Add port parameter to ConsensusConfig (#2986) (#3046)
This reverts commit 25112df. ## What ❔ <!-- What are the changes this PR brings about? --> <!-- Example: This PR adds a PR template to the repo. --> <!-- (For bigger PRs adding more context is appreciated) --> ## Why ❔ <!-- Why are these changes done? What goal do they contribute to? What are the principles behind them? --> <!-- Example: PR templates ensure PR reviewers, observers, and future iterators are in context about the evolution of repos. --> ## Checklist <!-- Check your PR fulfills the following items. --> <!-- For draft PRs check the boxes as you complete them. --> - [ ] PR title corresponds to the body of PR (we generate changelog entries from PRs). - [ ] Tests for the changes have been added / updated. - [ ] Documentation comments have been added / updated. - [ ] Code has been formatted via `zk_supervisor fmt` and `zk_supervisor lint`.
1 parent b0ec79f commit abe35bf

File tree

14 files changed

+103
-54
lines changed

14 files changed

+103
-54
lines changed

core/lib/config/src/configs/consensus.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@ impl RpcConfig {
115115
/// Config (shared between main node and external node).
116116
#[derive(Clone, Debug, PartialEq)]
117117
pub struct ConsensusConfig {
118-
pub port: u16,
119118
/// Local socket address to listen for the incoming connections.
120119
pub server_addr: std::net::SocketAddr,
121120
/// Public address of this node (should forward to `server_addr`)

core/lib/config/src/testonly.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -802,7 +802,6 @@ impl Distribution<configs::consensus::ConsensusConfig> for EncodeDist {
802802
fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> configs::consensus::ConsensusConfig {
803803
use configs::consensus::{ConsensusConfig, Host, NodePublicKey};
804804
ConsensusConfig {
805-
port: self.sample(rng),
806805
server_addr: self.sample(rng),
807806
public_addr: Host(self.sample(rng)),
808807
max_payload_size: self.sample(rng),

core/lib/protobuf_config/src/consensus.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,6 @@ impl ProtoRepr for proto::Config {
148148
};
149149

150150
Ok(Self::Type {
151-
port: required(&self.port)
152-
.and_then(|x| Ok((*x).try_into()?))
153-
.context("port")?,
154151
server_addr: required(&self.server_addr)
155152
.and_then(|x| Ok(x.parse()?))
156153
.context("server_addr")?,
@@ -185,7 +182,6 @@ impl ProtoRepr for proto::Config {
185182

186183
fn build(this: &Self::Type) -> Self {
187184
Self {
188-
port: Some(this.port.into()),
189185
server_addr: Some(this.server_addr.to_string()),
190186
public_addr: Some(this.public_addr.0.clone()),
191187
max_payload_size: Some(this.max_payload_size.try_into().unwrap()),

core/lib/protobuf_config/src/proto/core/consensus.proto

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,6 @@ message Config {
7070
reserved 3;
7171
reserved "validators";
7272

73-
// Port to listen on, for incoming TCP connections.
74-
optional uint32 port = 12; // required
75-
7673
// IP:port to listen on, for incoming TCP connections.
7774
// Use `0.0.0.0:<port>` to listen on all network interfaces (i.e. on all IPs exposed by this VM).
7875
optional string server_addr = 1; // required; IpAddr

core/node/consensus/src/testonly.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,6 @@ fn make_config(
154154
genesis_spec: Option<config::GenesisSpec>,
155155
) -> config::ConsensusConfig {
156156
config::ConsensusConfig {
157-
port: cfg.server_addr.port(),
158157
server_addr: *cfg.server_addr,
159158
public_addr: config::Host(cfg.public_addr.0.clone()),
160159
max_payload_size: usize::MAX,

etc/env/consensus_config.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
port: 3054
21
server_addr: "127.0.0.1:3054"
32
public_addr: "127.0.0.1:3054"
43
max_payload_size: 2500000

etc/env/en_consensus_config.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
port: 3055
21
server_addr: '127.0.0.1:3055'
32
public_addr: '127.0.0.1:3055'
43
max_payload_size: 2500000

etc/env/file_based/general.yaml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -375,10 +375,3 @@ da_dispatcher:
375375

376376
external_proof_integration_api:
377377
http_port: 3073
378-
379-
consensus:
380-
port: 3054
381-
server_addr: "127.0.0.1:3054"
382-
public_addr: "127.0.0.1:3054"
383-
max_payload_size: 2500000
384-
gossip_dynamic_inbound_limit: 100

zk_toolbox/crates/config/src/consts.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ pub const DEFAULT_EXPLORER_WORKER_PORT: u16 = 3001;
6262
pub const DEFAULT_EXPLORER_API_PORT: u16 = 3002;
6363
/// Default port for the explorer data fetcher service
6464
pub const DEFAULT_EXPLORER_DATA_FETCHER_PORT: u16 = 3040;
65+
/// Default port for consensus service
66+
pub const DEFAULT_CONSENSUS_PORT: u16 = 3054;
6567

6668
pub const EXPLORER_API_DOCKER_IMAGE: &str = "matterlabs/block-explorer-api";
6769
pub const EXPLORER_DATA_FETCHER_DOCKER_IMAGE: &str = "matterlabs/block-explorer-data-fetcher";

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

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use anyhow::Context;
22
use common::logger;
33
use config::{
44
copy_configs, set_l1_rpc_url, traits::SaveConfigWithBasePath, update_from_chain_config,
5-
ChainConfig, ContractsConfig, EcosystemConfig,
5+
ChainConfig, ContractsConfig, EcosystemConfig, DEFAULT_CONSENSUS_PORT,
66
};
77
use ethers::types::Address;
88
use xshell::Shell;
@@ -15,12 +15,13 @@ use crate::{
1515
},
1616
portal::update_portal_config,
1717
},
18+
defaults::PORT_RANGE_END,
1819
messages::{
19-
MSG_CHAIN_CONFIGS_INITIALIZED, MSG_CHAIN_NOT_FOUND_ERR, MSG_CONSENSUS_CONFIG_MISSING_ERR,
20+
MSG_CHAIN_CONFIGS_INITIALIZED, MSG_CHAIN_NOT_FOUND_ERR,
2021
MSG_PORTAL_FAILED_TO_CREATE_CONFIG_ERR,
2122
},
2223
utils::{
23-
consensus::{generate_consensus_keys, get_consensus_secrets, get_genesis_specs},
24+
consensus::{generate_consensus_keys, get_consensus_config, get_consensus_secrets},
2425
ports::EcosystemPortsScanner,
2526
},
2627
};
@@ -56,14 +57,22 @@ pub async fn init_configs(
5657
)?;
5758
}
5859

60+
// Initialize general config
5961
let mut general_config = chain_config.get_general_config()?;
60-
let mut consensus_config = general_config
61-
.consensus_config
62-
.context(MSG_CONSENSUS_CONFIG_MISSING_ERR)?;
6362

64-
let consensus_keys = generate_consensus_keys();
65-
consensus_config.genesis_spec = Some(get_genesis_specs(chain_config, &consensus_keys));
63+
// TODO: This is a temporary solution. We should allocate consensus port using `EcosystemPorts::allocate_ports_in_yaml`
64+
let offset = ((chain_config.id - 1) * 100) as u16;
65+
let consensus_port_range = DEFAULT_CONSENSUS_PORT + offset..PORT_RANGE_END;
66+
let consensus_port =
67+
ecosystem_ports.allocate_port(consensus_port_range, "Consensus".to_string())?;
6668

69+
let consensus_keys = generate_consensus_keys();
70+
let consensus_config = get_consensus_config(
71+
chain_config,
72+
consensus_port,
73+
Some(consensus_keys.clone()),
74+
None,
75+
)?;
6776
general_config.consensus_config = Some(consensus_config);
6877
general_config.save_with_base_path(shell, &chain_config.configs)?;
6978

0 commit comments

Comments
 (0)