Skip to content

Commit

Permalink
feat: Remove old EN code (#2595)
Browse files Browse the repository at this point in the history
## What ❔

- Removes old EN code.
- Some configs weren't used in the framework code by mistake. This is
fixed now.
- Diamond proxy address was made private in config so that it's obtained
in a checked manner.

Some changes are not done in this PR to reduce the scope (e.g. removing
unneeded dependencies).

## Why ❔

Switch to framework.

## 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
popzxc authored Aug 12, 2024
1 parent 931e452 commit 8d31ebc
Show file tree
Hide file tree
Showing 10 changed files with 116 additions and 1,145 deletions.
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

0 comments on commit 8d31ebc

Please sign in to comment.