Skip to content

Commit

Permalink
feat: Add gateway_url to EN config (#2698)
Browse files Browse the repository at this point in the history
## 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 fmt` and `zk lint`.
  • Loading branch information
ly0va authored Aug 21, 2024
1 parent efa3bd6 commit cfdda01
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 0 deletions.
4 changes: 4 additions & 0 deletions core/bin/external_node/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,9 @@ pub(crate) struct OptionalENConfig {
/// If set to 0, L1 batches will not be retained based on their timestamp. The default value is 7 days.
#[serde(default = "OptionalENConfig::default_pruning_data_retention_sec")]
pruning_data_retention_sec: u64,
/// Gateway RPC URL, needed for operating during migration.
#[allow(dead_code)]
pub gateway_url: Option<SensitiveUrl>,
}

impl OptionalENConfig {
Expand Down Expand Up @@ -663,6 +666,7 @@ impl OptionalENConfig {
.unwrap_or_else(Self::default_main_node_rate_limit_rps),
api_namespaces,
contracts_diamond_proxy_addr: None,
gateway_url: enconfig.gateway_url.clone(),
})
}

Expand Down
2 changes: 2 additions & 0 deletions core/lib/config/src/configs/en_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,6 @@ pub struct ENConfig {
// Main node configuration
pub main_node_url: SensitiveUrl,
pub main_node_rate_limit_rps: Option<NonZeroUsize>,

pub gateway_url: Option<SensitiveUrl>,
}
2 changes: 2 additions & 0 deletions core/lib/config/src/testonly.rs
Original file line number Diff line number Diff line change
Expand Up @@ -928,6 +928,8 @@ impl Distribution<configs::en_config::ENConfig> for EncodeDist {
_ => L1BatchCommitmentMode::Validium,
},
main_node_rate_limit_rps: self.sample_opt(|| rng.gen()),
gateway_url: self
.sample_opt(|| format!("localhost:{}", rng.gen::<u16>()).parse().unwrap()),
}
}
}
Expand Down
9 changes: 9 additions & 0 deletions core/lib/protobuf_config/src/en.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ impl ProtoRepr for proto::ExternalNode {
main_node_rate_limit_rps: self
.main_node_rate_limit_rps
.and_then(|a| NonZeroUsize::new(a as usize)),
gateway_url: self
.gateway_url
.as_ref()
.map(|a| a.parse().context("gateway_url"))
.transpose()?,
})
}

Expand All @@ -46,6 +51,10 @@ impl ProtoRepr for proto::ExternalNode {
.into(),
),
main_node_rate_limit_rps: this.main_node_rate_limit_rps.map(|a| a.get() as u64),
gateway_url: this
.gateway_url
.as_ref()
.map(|a| a.expose_str().to_string()),
}
}
}
1 change: 1 addition & 0 deletions core/lib/protobuf_config/src/proto/config/en.proto
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ message ExternalNode {
optional uint64 l1_chain_id = 3; // required
optional uint64 main_node_rate_limit_rps = 6; // optional
optional config.genesis.L1BatchCommitDataGeneratorMode l1_batch_commit_data_generator_mode = 7; // optional, default to rollup
optional string gateway_url = 8; // optional
}
3 changes: 3 additions & 0 deletions etc/env/configs/ext-node.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ file_backed_base_path = "artifacts"
[en.main_node]
url = "http://127.0.0.1:3050"

[en.gateway]
url = "http://127.0.0.1:3052"

[rust]
# `RUST_LOG` environment variable for `env_logger`
# Here we use TOML multiline strings: newlines will be trimmed.
Expand Down
2 changes: 2 additions & 0 deletions etc/env/file_based/external_node.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ l1_batch_commit_data_generator_mode: Rollup

main_node_url: http://localhost:3050
main_node_rate_limit_rps: 1000

gateway_url: http://localhost:3052
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ fn prepare_configs(
.http_url,
)?,
main_node_rate_limit_rps: None,
gateway_url: None,
};
let mut general_en = general.clone();

Expand Down

0 comments on commit cfdda01

Please sign in to comment.