Skip to content
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: Remove old EN code #2595

Merged
merged 6 commits into from
Aug 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion core/bin/external_node/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ pub(crate) struct RemoteENConfig {
pub bridgehub_proxy_addr: Option<Address>,
pub state_transition_proxy_addr: Option<Address>,
pub transparent_proxy_admin_addr: Option<Address>,
pub diamond_proxy_addr: Address,
/// Should not be accessed directly. Use [`ExternalNodeConfig::diamond_proxy_address`] instead.
diamond_proxy_addr: Address,
// While on L1 shared bridge and legacy bridge are different contracts with different addresses,
// the `l2_erc20_bridge_addr` and `l2_shared_bridge_addr` are basically the same contract, but with
// a different name, with names adapted only for consistency.
Expand Down Expand Up @@ -1310,6 +1311,19 @@ impl ExternalNodeConfig<()> {
let remote = RemoteENConfig::fetch(main_node_client)
.await
.context("Unable to fetch required config values from the main node")?;
let remote_diamond_proxy_addr = remote.diamond_proxy_addr;
if let Some(local_diamond_proxy_addr) = self.optional.contracts_diamond_proxy_addr {
anyhow::ensure!(
local_diamond_proxy_addr == remote_diamond_proxy_addr,
"Diamond proxy address {local_diamond_proxy_addr:?} specified in config doesn't match one returned \
by main node ({remote_diamond_proxy_addr:?})"
);
} else {
tracing::info!(
"Diamond proxy address is not specified in config; will use address \
returned by main node: {remote_diamond_proxy_addr:?}"
);
}
Ok(ExternalNodeConfig {
required: self.required,
postgres: self.postgres,
Expand Down Expand Up @@ -1341,6 +1355,16 @@ impl ExternalNodeConfig {
tree_component: TreeComponentConfig { api_port: None },
}
}

/// Returns a verified diamond proxy address.
/// If local configuration contains the address, it will be checked against the one returned by the main node.
/// Otherwise, the remote value will be used. However, using remote value has trust implications for the main
/// node so relying on it solely is not recommended.
pub fn diamond_proxy_address(&self) -> Address {
self.optional
.contracts_diamond_proxy_addr
.unwrap_or(self.remote.diamond_proxy_addr)
}
}

impl From<&ExternalNodeConfig> for InternalApiConfig {
Expand Down
141 changes: 0 additions & 141 deletions core/bin/external_node/src/init.rs

This file was deleted.

Loading
Loading