Skip to content

Commit

Permalink
Merge branch 'main' into eigen-client-extra-features-and-main
Browse files Browse the repository at this point in the history
  • Loading branch information
gianbelinche committed Nov 28, 2024
2 parents 7a61574 + 38afdd5 commit bc90cc6
Show file tree
Hide file tree
Showing 253 changed files with 9,504 additions and 4,394 deletions.
2 changes: 1 addition & 1 deletion .github/release-please/manifest.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"core": "25.2.0",
"prover": "17.1.0",
"prover": "17.1.1",
"zkstack_cli": "0.1.2"
}
3 changes: 1 addition & 2 deletions .github/workflows/zk-environment-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,7 @@ jobs:
push: ${{ (github.event_name == 'push' && github.ref == 'refs/heads/main') || (github.event_name == 'workflow_dispatch') }}

zk_environment_multiarch_manifest:
# We'll update the 'latest' tag, only on environments generated from 'main'.
if: needs.changed_files.outputs.zk_environment == 'true' && github.event_name == 'push' && github.ref == 'refs/heads/main'
if: ${{ (needs.changed_files.outputs.zk_environment == 'true' && github.event_name == 'push' && github.ref == 'refs/heads/main') || (github.event_name == 'workflow_dispatch') }}
# Needed to push to Gihub Package Registry
permissions:
packages: write
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -120,3 +120,6 @@ configs/*
era-observability/
core/tests/ts-integration/deployments-zk
transactions/

# foundry-zksync
install
22 changes: 12 additions & 10 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ members = [
# Test infrastructure
"core/tests/loadnext",
"core/tests/vm-benchmark",
"core/lib/bin_metadata",
]
resolver = "2"

Expand Down Expand Up @@ -249,16 +250,16 @@ zk_evm_1_5_0 = { package = "zk_evm", version = "=0.150.7" }
zksync_vm2 = { git = "https://github.com/matter-labs/vm2.git", rev = "457d8a7eea9093af9440662e33e598c13ba41633" }

# Consensus dependencies.
zksync_concurrency = "=0.5.0"
zksync_consensus_bft = "=0.5.0"
zksync_consensus_crypto = "=0.5.0"
zksync_consensus_executor = "=0.5.0"
zksync_consensus_network = "=0.5.0"
zksync_consensus_roles = "=0.5.0"
zksync_consensus_storage = "=0.5.0"
zksync_consensus_utils = "=0.5.0"
zksync_protobuf = "=0.5.0"
zksync_protobuf_build = "=0.5.0"
zksync_concurrency = "=0.6.0"
zksync_consensus_bft = "=0.6.0"
zksync_consensus_crypto = "=0.6.0"
zksync_consensus_executor = "=0.6.0"
zksync_consensus_network = "=0.6.0"
zksync_consensus_roles = "=0.6.0"
zksync_consensus_storage = "=0.6.0"
zksync_consensus_utils = "=0.6.0"
zksync_protobuf = "=0.6.0"
zksync_protobuf_build = "=0.6.0"

# "Local" dependencies
zksync_multivm = { version = "0.1.0", path = "core/lib/multivm" }
Expand All @@ -281,6 +282,7 @@ zksync_health_check = { version = "0.1.0", path = "core/lib/health_check" }
zksync_l1_contract_interface = { version = "0.1.0", path = "core/lib/l1_contract_interface" }
zksync_mempool = { version = "0.1.0", path = "core/lib/mempool" }
zksync_merkle_tree = { version = "0.1.0", path = "core/lib/merkle_tree" }
zksync_bin_metadata = { version = "0.1.0", path = "core/lib/bin_metadata" }
zksync_mini_merkle_tree = { version = "0.1.0", path = "core/lib/mini_merkle_tree" }
zksync_object_store = { version = "0.1.0", path = "core/lib/object_store" }
zksync_protobuf_config = { version = "0.1.0", path = "core/lib/protobuf_config" }
Expand Down
66 changes: 40 additions & 26 deletions core/bin/external_node/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,15 @@ impl ConfigurationSource for Environment {
/// This part of the external node config is fetched directly from the main node.
#[derive(Debug, Deserialize)]
pub(crate) struct RemoteENConfig {
pub bridgehub_proxy_addr: Option<Address>,
pub state_transition_proxy_addr: Option<Address>,
pub transparent_proxy_admin_addr: Option<Address>,
/// Should not be accessed directly. Use [`ExternalNodeConfig::diamond_proxy_address`] instead.
diamond_proxy_addr: Address,
#[serde(alias = "bridgehub_proxy_addr")]
pub l1_bridgehub_proxy_addr: Option<Address>,
#[serde(alias = "state_transition_proxy_addr")]
pub l1_state_transition_proxy_addr: Option<Address>,
#[serde(alias = "transparent_proxy_admin_addr")]
pub l1_transparent_proxy_admin_addr: Option<Address>,
/// Should not be accessed directly. Use [`ExternalNodeConfig::l1_diamond_proxy_address`] instead.
#[serde(alias = "diamond_proxy_addr")]
l1_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 @@ -144,7 +148,7 @@ impl RemoteENConfig {
.rpc_context("ecosystem_contracts")
.await
.ok();
let diamond_proxy_addr = client
let l1_diamond_proxy_addr = client
.get_main_contract()
.rpc_context("get_main_contract")
.await?;
Expand Down Expand Up @@ -180,14 +184,14 @@ impl RemoteENConfig {
}

Ok(Self {
bridgehub_proxy_addr: ecosystem_contracts.as_ref().map(|a| a.bridgehub_proxy_addr),
state_transition_proxy_addr: ecosystem_contracts
l1_bridgehub_proxy_addr: ecosystem_contracts.as_ref().map(|a| a.bridgehub_proxy_addr),
l1_state_transition_proxy_addr: ecosystem_contracts
.as_ref()
.map(|a| a.state_transition_proxy_addr),
transparent_proxy_admin_addr: ecosystem_contracts
l1_transparent_proxy_admin_addr: ecosystem_contracts
.as_ref()
.map(|a| a.transparent_proxy_admin_addr),
diamond_proxy_addr,
l1_diamond_proxy_addr,
l2_testnet_paymaster_addr,
l1_erc20_bridge_proxy_addr: bridges.l1_erc20_default_bridge,
l2_erc20_bridge_addr: l2_erc20_default_bridge,
Expand All @@ -212,10 +216,10 @@ impl RemoteENConfig {
#[cfg(test)]
fn mock() -> Self {
Self {
bridgehub_proxy_addr: None,
state_transition_proxy_addr: None,
transparent_proxy_admin_addr: None,
diamond_proxy_addr: Address::repeat_byte(1),
l1_bridgehub_proxy_addr: None,
l1_state_transition_proxy_addr: None,
l1_transparent_proxy_admin_addr: None,
l1_diamond_proxy_addr: Address::repeat_byte(1),
l1_erc20_bridge_proxy_addr: Some(Address::repeat_byte(2)),
l2_erc20_bridge_addr: Some(Address::repeat_byte(3)),
l2_weth_bridge_addr: None,
Expand Down Expand Up @@ -479,7 +483,6 @@ pub(crate) struct OptionalENConfig {
#[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>,
/// Interval for bridge addresses refreshing in seconds.
bridge_addresses_refresh_interval_sec: Option<NonZeroU64>,
Expand All @@ -489,7 +492,11 @@ pub(crate) struct OptionalENConfig {
}

impl OptionalENConfig {
fn from_configs(general_config: &GeneralConfig, enconfig: &ENConfig) -> anyhow::Result<Self> {
fn from_configs(
general_config: &GeneralConfig,
enconfig: &ENConfig,
secrets: &Secrets,
) -> anyhow::Result<Self> {
let api_namespaces = load_config!(general_config.api_config, web3_json_rpc.api_namespaces)
.map(|a: Vec<String>| a.iter().map(|a| a.parse()).collect::<Result<_, _>>())
.transpose()?;
Expand Down Expand Up @@ -721,7 +728,10 @@ 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(),
gateway_url: secrets
.l1
.as_ref()
.and_then(|l1| l1.gateway_rpc_url.clone()),
bridge_addresses_refresh_interval_sec: enconfig.bridge_addresses_refresh_interval_sec,
timestamp_asserter_min_time_till_end_sec: general_config
.timestamp_asserter_config
Expand Down Expand Up @@ -1340,7 +1350,11 @@ impl ExternalNodeConfig<()> {
&external_node_config,
&secrets_config,
)?;
let optional = OptionalENConfig::from_configs(&general_config, &external_node_config)?;
let optional = OptionalENConfig::from_configs(
&general_config,
&external_node_config,
&secrets_config,
)?;
let postgres = PostgresConfig {
database_url: secrets_config
.database
Expand Down Expand Up @@ -1383,7 +1397,7 @@ 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;
let remote_diamond_proxy_addr = remote.l1_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,
Expand Down Expand Up @@ -1430,14 +1444,14 @@ impl ExternalNodeConfig {
}
}

/// Returns a verified diamond proxy address.
/// Returns verified L1 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 {
pub fn l1_diamond_proxy_address(&self) -> Address {
self.optional
.contracts_diamond_proxy_addr
.unwrap_or(self.remote.diamond_proxy_addr)
.unwrap_or(self.remote.l1_diamond_proxy_addr)
}
}

Expand All @@ -1461,10 +1475,10 @@ impl From<&ExternalNodeConfig> for InternalApiConfig {
l1_weth_bridge: config.remote.l1_weth_bridge_addr,
l2_weth_bridge: config.remote.l2_weth_bridge_addr,
},
bridgehub_proxy_addr: config.remote.bridgehub_proxy_addr,
state_transition_proxy_addr: config.remote.state_transition_proxy_addr,
transparent_proxy_admin_addr: config.remote.transparent_proxy_admin_addr,
diamond_proxy_addr: config.remote.diamond_proxy_addr,
l1_bridgehub_proxy_addr: config.remote.l1_bridgehub_proxy_addr,
l1_state_transition_proxy_addr: config.remote.l1_state_transition_proxy_addr,
l1_transparent_proxy_admin_addr: config.remote.l1_transparent_proxy_admin_addr,
l1_diamond_proxy_addr: config.remote.l1_diamond_proxy_addr,
l2_testnet_paymaster_addr: config.remote.l2_testnet_paymaster_addr,
req_entities_limit: config.optional.req_entities_limit,
fee_history_limit: config.optional.fee_history_limit,
Expand Down
3 changes: 2 additions & 1 deletion core/bin/external_node/src/metrics/framework.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use zksync_node_framework::{
implementations::resources::pools::{MasterPool, PoolResource},
FromContext, IntoContext, StopReceiver, Task, TaskId, WiringError, WiringLayer,
};
use zksync_shared_metrics::rustc::RUST_METRICS;
use zksync_shared_metrics::{GIT_METRICS, RUST_METRICS};
use zksync_types::{L1ChainId, L2ChainId, SLChainId};

use super::EN_METRICS;
Expand Down Expand Up @@ -40,6 +40,7 @@ impl WiringLayer for ExternalNodeMetricsLayer {

async fn wire(self, input: Self::Input) -> Result<Self::Output, WiringError> {
RUST_METRICS.initialize();
GIT_METRICS.initialize();
EN_METRICS.observe_config(
self.l1_chain_id,
self.sl_chain_id,
Expand Down
30 changes: 16 additions & 14 deletions core/bin/external_node/src/node_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ use zksync_node_framework::{
NodeStorageInitializerLayer,
},
pools_layer::PoolsLayerBuilder,
postgres_metrics::PostgresMetricsLayer,
postgres::PostgresLayer,
prometheus_exporter::PrometheusExporterLayer,
pruning::PruningLayer,
query_eth_client::QueryEthClientLayer,
Expand All @@ -57,7 +57,7 @@ use zksync_node_framework::{
service::{ZkStackService, ZkStackServiceBuilder},
};
use zksync_state::RocksdbStorageOptions;
use zksync_types::L2_NATIVE_TOKEN_VAULT_ADDRESS;
use zksync_types::L2_ASSET_ROUTER_ADDRESS;

use crate::{config::ExternalNodeConfig, metrics::framework::ExternalNodeMetricsLayer, Component};

Expand Down Expand Up @@ -125,8 +125,8 @@ impl ExternalNodeBuilder {
Ok(self)
}

fn add_postgres_metrics_layer(mut self) -> anyhow::Result<Self> {
self.node.add_layer(PostgresMetricsLayer);
fn add_postgres_layer(mut self) -> anyhow::Result<Self> {
self.node.add_layer(PostgresLayer);
Ok(self)
}

Expand Down Expand Up @@ -181,8 +181,7 @@ impl ExternalNodeBuilder {
let query_eth_client_layer = QueryEthClientLayer::new(
self.config.required.settlement_layer_id(),
self.config.required.eth_client_url.clone(),
// TODO(EVM-676): add this config for external node
Default::default(),
self.config.optional.gateway_url.clone(),
);
self.node.add_layer(query_eth_client_layer);
Ok(self)
Expand All @@ -200,12 +199,11 @@ impl ExternalNodeBuilder {
.remote
.l2_shared_bridge_addr
.context("Missing `l2_shared_bridge_addr`")?;
let l2_legacy_shared_bridge_addr = if l2_shared_bridge_addr == L2_NATIVE_TOKEN_VAULT_ADDRESS
{
// System has migrated to `L2_NATIVE_TOKEN_VAULT_ADDRESS`, use legacy shared bridge address from main node.
let l2_legacy_shared_bridge_addr = if l2_shared_bridge_addr == L2_ASSET_ROUTER_ADDRESS {
// System has migrated to `L2_ASSET_ROUTER_ADDRESS`, use legacy shared bridge address from main node.
self.config.remote.l2_legacy_shared_bridge_addr
} else {
// System hasn't migrated on `L2_NATIVE_TOKEN_VAULT_ADDRESS`, we can safely use `l2_shared_bridge_addr`.
// System hasn't migrated on `L2_ASSET_ROUTER_ADDRESS`, we can safely use `l2_shared_bridge_addr`.
Some(l2_shared_bridge_addr)
};

Expand Down Expand Up @@ -278,7 +276,7 @@ impl ExternalNodeBuilder {

fn add_l1_batch_commitment_mode_validation_layer(mut self) -> anyhow::Result<Self> {
let layer = L1BatchCommitmentModeValidationLayer::new(
self.config.diamond_proxy_address(),
self.config.l1_diamond_proxy_address(),
self.config.optional.l1_batch_commit_data_generator_mode,
);
self.node.add_layer(layer);
Expand All @@ -297,9 +295,10 @@ impl ExternalNodeBuilder {
fn add_consistency_checker_layer(mut self) -> anyhow::Result<Self> {
let max_batches_to_recheck = 10; // TODO (BFT-97): Make it a part of a proper EN config
let layer = ConsistencyCheckerLayer::new(
self.config.diamond_proxy_address(),
self.config.l1_diamond_proxy_address(),
max_batches_to_recheck,
self.config.optional.l1_batch_commit_data_generator_mode,
self.config.required.l2_chain_id,
);
self.node.add_layer(layer);
Ok(self)
Expand All @@ -324,7 +323,10 @@ impl ExternalNodeBuilder {
}

fn add_tree_data_fetcher_layer(mut self) -> anyhow::Result<Self> {
let layer = TreeDataFetcherLayer::new(self.config.diamond_proxy_address());
let layer = TreeDataFetcherLayer::new(
self.config.l1_diamond_proxy_address(),
self.config.required.l2_chain_id,
);
self.node.add_layer(layer);
Ok(self)
}
Expand Down Expand Up @@ -582,7 +584,7 @@ impl ExternalNodeBuilder {
// so until we have a dedicated component for "auxiliary" tasks,
// it's responsible for things like metrics.
self = self
.add_postgres_metrics_layer()?
.add_postgres_layer()?
.add_external_node_metrics_layer()?;
// We assign the storage initialization to the core, as it's considered to be
// the "main" component.
Expand Down
6 changes: 3 additions & 3 deletions core/bin/external_node/src/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ async fn external_node_basics(components_str: &'static str) {
}

let l2_client = utils::mock_l2_client(&env);
let eth_client = utils::mock_eth_client(env.config.diamond_proxy_address());
let eth_client = utils::mock_eth_client(env.config.l1_diamond_proxy_address());

let node_handle = tokio::task::spawn_blocking(move || {
std::thread::spawn(move || {
Expand Down Expand Up @@ -104,7 +104,7 @@ async fn node_reacts_to_stop_signal_during_initial_reorg_detection() {
let (env, env_handles) = utils::TestEnvironment::with_genesis_block("core").await;

let l2_client = utils::mock_l2_client_hanging();
let eth_client = utils::mock_eth_client(env.config.diamond_proxy_address());
let eth_client = utils::mock_eth_client(env.config.l1_diamond_proxy_address());

let mut node_handle = tokio::task::spawn_blocking(move || {
std::thread::spawn(move || {
Expand Down Expand Up @@ -140,7 +140,7 @@ async fn running_tree_without_core_is_not_allowed() {
let (env, _env_handles) = utils::TestEnvironment::with_genesis_block("tree").await;

let l2_client = utils::mock_l2_client(&env);
let eth_client = utils::mock_eth_client(env.config.diamond_proxy_address());
let eth_client = utils::mock_eth_client(env.config.l1_diamond_proxy_address());

let node_handle = tokio::task::spawn_blocking(move || {
std::thread::spawn(move || {
Expand Down
3 changes: 3 additions & 0 deletions core/bin/external_node/src/tests/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,13 @@ pub(super) fn block_details_base(hash: H256) -> api::BlockDetailsBase {
status: api::BlockStatus::Sealed,
commit_tx_hash: None,
committed_at: None,
commit_chain_id: None,
prove_tx_hash: None,
proven_at: None,
prove_chain_id: None,
execute_tx_hash: None,
executed_at: None,
execute_chain_id: None,
l1_gas_price: 0,
l2_fair_gas_price: 0,
fair_pubdata_price: None,
Expand Down
Loading

0 comments on commit bc90cc6

Please sign in to comment.