Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
921f0f5
fix
tomg10 Oct 25, 2024
7b36d33
several improvements
tomg10 Oct 29, 2024
76eb39e
bump
tomg10 Oct 29, 2024
3abd4c0
various improvements
tomg10 Oct 31, 2024
b8c9e26
functional(ish) L1 recovery for EN
tomg10 Nov 3, 2024
d889bce
most of the eth-watch code, initial state in json file and with facto…
tomg10 Nov 4, 2024
744013d
added initial state for v24
tomg10 Nov 4, 2024
8e3828e
passing almost all integration tests
tomg10 Nov 13, 2024
a1ac032
passing all integration tests
tomg10 Nov 17, 2024
165ce18
fixes after rebase
tomg10 Nov 18, 2024
aa4ac6c
removed abi directory
tomg10 Nov 18, 2024
4fe6cfa
fix
tomg10 Nov 20, 2024
223fd62
version with working sepolia EN recovery
tomg10 Nov 21, 2024
63c8f11
fix
tomg10 Nov 23, 2024
2c467f0
Merge branch 'main' into l1-recovery
tomg10 Nov 23, 2024
60fe1c7
fix
tomg10 Nov 23, 2024
ccb10bf
lint
tomg10 Nov 23, 2024
b6a7b06
improvements
tomg10 Dec 18, 2024
64cf8a1
lint
tomg10 Dec 18, 2024
7d0164e
merge
tomg10 Dec 18, 2024
a5cd16d
fixes
tomg10 Dec 18, 2024
f0e0b73
fixes
tomg10 Dec 18, 2024
d02804c
fixes
tomg10 Dec 18, 2024
b3dcc04
fmt
tomg10 Dec 18, 2024
986fa2c
lint
tomg10 Dec 18, 2024
4a60208
lint
tomg10 Dec 18, 2024
2a0e964
fix
tomg10 Dec 19, 2024
79e8c3f
Merge branch 'main' into l1-recovery
Deniallugo Oct 2, 2025
417e88d
Fix lints
Deniallugo Oct 2, 2025
f584679
Retun local_blobs_dump
Deniallugo Oct 6, 2025
7a1653b
Add variaty for commit functions
Deniallugo Oct 7, 2025
3bbbe3c
Support multiple protocol versions for stored batches
Deniallugo Oct 8, 2025
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
3,561 changes: 1,789 additions & 1,772 deletions core/Cargo.lock

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ members = [
"bin/zksync_server",
"bin/genesis_generator",
"bin/zksync_tee_prover",
"bin/local_blobs_dump",
# Node services
"node/jemalloc",
"node/proof_data_handler",
Expand Down Expand Up @@ -43,6 +44,7 @@ members = [
"node/gateway_migrator",
"node/zk_os_tree_manager",
"node/eth_proof_manager",
"node/l1_recovery",
# Libraries
"lib/db_connection",
"lib/basic_types",
Expand Down Expand Up @@ -210,6 +212,7 @@ time = "0.3.36" # Has to be same as used by `tracing-subscriber`
url = "2"
web3 = "0.19.0"
yab = "0.1.0"
indexmap = { version = "2.0.2", features = ["serde"] }

# Proc-macro
syn = "2.0"
Expand Down Expand Up @@ -281,6 +284,7 @@ zksync_consensus_roles = "=0.13"
zksync_consensus_utils = "=0.13"
zksync_protobuf = "=0.13"
zksync_protobuf_build = "=0.13"
zkevm_circuits = "=0.153.1"

# "Local" dependencies
zksync_multivm = { version = "29.4.1-non-semver-compat", path = "lib/multivm" }
Expand Down Expand Up @@ -356,3 +360,5 @@ zksync_node_api_server = { version = "29.4.1-non-semver-compat", path = "node/ap
zksync_base_token_adjuster = { version = "29.4.1-non-semver-compat", path = "node/base_token_adjuster" }
zksync_logs_bloom_backfill = { version = "29.4.1-non-semver-compat", path = "node/logs_bloom_backfill" }
zksync_gateway_migrator = { version = "29.4.1-non-semver-compat", path = "node/gateway_migrator" }
zksync_l1_recovery = { version = "29.4.1-non-semver-compat", path = "node/l1_recovery" }
local_blobs_dump = { version = "29.4.1-non-semver-compat", path = "bin/local_blobs_dump" }
2 changes: 1 addition & 1 deletion core/bin/block_reverter/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ enum Command {
priority_fee_per_gas: Option<u64>,
/// Nonce used for reverting Ethereum transaction.
#[arg(long)]
nonce: u64,
nonce: Option<u64>,
},

/// Rolls back internal database state to a previous L1 batch.
Expand Down
1 change: 1 addition & 0 deletions core/bin/external_node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ zksync_node_consensus.workspace = true
zksync_node_framework.workspace = true
zksync_settlement_layer_data.workspace = true
zksync_vlog = { workspace = true, features = ["node_framework"] }
zksync_l1_recovery.workspace = true

zksync_consensus_roles.workspace = true
zksync_consensus_crypto.workspace = true
Expand Down
23 changes: 22 additions & 1 deletion core/bin/external_node/src/node_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ use zksync_da_clients::node::{
};
use zksync_dal::node::{PoolsLayer, PostgresMetricsLayer};
use zksync_eth_client::node::BridgeAddressesUpdaterLayer;
use zksync_l1_recovery::{BlobClientLayer, BlobClientMode};
use zksync_logs_bloom_backfill::node::LogsBloomBackfillLayer;
use zksync_metadata_calculator::{
node::{MetadataCalculatorLayer, TreeApiClientLayer, TreeApiServerLayer},
Expand Down Expand Up @@ -53,7 +54,7 @@ use zksync_reorg_detector::node::ReorgDetectorLayer;
use zksync_settlement_layer_data::{ENConfig, SettlementLayerData};
use zksync_state::RocksdbStorageOptions;
use zksync_state_keeper::node::{MainBatchExecutorLayer, OutputHandlerLayer, StateKeeperLayer};
use zksync_types::L1BatchNumber;
use zksync_types::{L1BatchNumber, L1ChainId};
use zksync_vlog::node::{PrometheusExporterLayer, SigintHandlerLayer};
use zksync_web3_decl::node::{MainNodeClientLayer, QueryEthClientLayer};

Expand Down Expand Up @@ -477,6 +478,20 @@ impl ExternalNodeBuilder {
Ok(self)
}

fn add_blob_client_layer(mut self, l1_chain_id: L1ChainId) -> anyhow::Result<Self> {
let url = if l1_chain_id.0 == 1 {
"https://api.blobscan.com/blobs/"
} else {
"https://api.sepolia.blobscan.com/blobs/"
};
let layer = BlobClientLayer {
mode: BlobClientMode::Blobscan,
blobscan_url: Some(url.to_string()),
};
self.node.add_layer(layer);
Ok(self)
}

/// This layer will make sure that the database is initialized correctly,
/// e.g.:
/// - genesis or snapshot recovery will be performed if it's required.
Expand All @@ -496,11 +511,15 @@ impl ExternalNodeBuilder {
snapshot_l1_batch_override: config.l1_batch,
drop_storage_key_preimages: config.drop_storage_key_preimages,
object_store_config: config.object_store.clone(),
recover_from_l1: config.recover_from_l1,
// TODO verify if we need to recover main node components on EN
recover_main_node_components: false,
});
self.node.add_layer(ExternalNodeInitStrategyLayer {
l2_chain_id: self.config.local.networks.l2_chain_id,
max_postgres_concurrency: config.postgres.max_concurrency,
snapshot_recovery_config,
// diamond_proxy_addr: self.config.l1_diamond_proxy_address(),
});
let mut layer = NodeStorageInitializerLayer::new();
if matches!(kind, LayerKind::Precondition) {
Expand Down Expand Up @@ -602,11 +621,13 @@ impl ExternalNodeBuilder {

pub fn build(mut self, mut components: Vec<Component>) -> anyhow::Result<ZkStackService> {
// Add "base" layers
let l1_chain_id = self.config.local.networks.l1_chain_id;
self = self
.add_sigint_handler_layer()?
.add_healthcheck_layer()?
.add_prometheus_exporter_layer()?
.add_pools_layer()?
.add_blob_client_layer(l1_chain_id)?
.add_main_node_client_layer()?
.add_query_eth_client_layer()?
.add_settlement_layer_data()?
Expand Down
24 changes: 24 additions & 0 deletions core/bin/local_blobs_dump/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[package]
name = "local_blobs_dump"
version = "0.1.0"
edition.workspace = true
authors.workspace = true
homepage.workspace = true
repository.workspace = true
license.workspace = true
keywords.workspace = true
categories.workspace = true
publish = false

[dependencies]
tokio.workspace = true
anyhow.workspace = true
clap.workspace = true
tracing.workspace = true
hex.workspace = true
zksync_object_store.workspace = true

zksync_dal.workspace = true
zksync_types.workspace = true
zksync_config.workspace = true
zksync_l1_recovery.workspace = true
90 changes: 90 additions & 0 deletions core/bin/local_blobs_dump/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
use std::path::PathBuf;

use anyhow::Context;
use clap::Parser;
use zksync_config::{
configs::{GeneralConfig, Secrets},
full_config_schema,
sources::ConfigFilePaths,
};
use zksync_dal::{ConnectionPool, Core, CoreDal};
use zksync_l1_recovery::{BlobKey, BlobWrapper};
use zksync_object_store::ObjectStoreFactory;
use zksync_types::eth_sender::EthTxBlobSidecar;

#[derive(Debug, Parser)]
#[command(author, version, about, long_about)]
struct Cli {
#[arg(long, global = true)]
secrets_path: PathBuf,

#[arg(long, global = true)]
config_path: PathBuf,
}

#[tokio::main]
async fn main() -> anyhow::Result<()> {
let opt = Cli::parse();

let schema = full_config_schema();

let config_file_paths = ConfigFilePaths {
general: Some(opt.config_path),
secrets: Some(opt.secrets_path),
..ConfigFilePaths::default()
};
let config_sources = config_file_paths.into_config_sources("ZKSYNC_")?;
let mut repo = config_sources.build_repository(&schema);
repo.capture_parsed_params();
let general_config: GeneralConfig = repo.parse()?;
let secrets_config: Secrets = repo.parse()?;

let database_secrets = secrets_config.postgres.clone();

let connection_pool = ConnectionPool::<Core>::singleton(database_secrets.master_url()?)
.build()
.await
.context("failed to build a connection pool")?;

let object_store_config = general_config
.snapshot_recovery
.unwrap()
.object_store
.context("failed to find core object store config")?;
let object_store = ObjectStoreFactory::new(object_store_config)
.create_store()
.await?;

let mut id = 1;
loop {
let mut storage = connection_pool.connection().await.unwrap();
let tx = storage.eth_sender_dal().get_eth_tx(id).await.unwrap();
id += 1;
if tx.is_none() {
break;
}

if let Some(blob_sidecar) = tx.unwrap().blob_sidecar {
match blob_sidecar {
EthTxBlobSidecar::EthTxBlobSidecarV1(sidecar) => {
for blob in sidecar.blobs {
object_store
.put(
BlobKey {
kzg_commitment: blob
.commitment
.try_into()
.expect("unable to convert kzg_commitment to [u8; 48]"),
},
&BlobWrapper { blob: blob.blob },
)
.await?;
}
}
}
}
}

println!("Finished dumping blobs");
Ok(())
}
2 changes: 2 additions & 0 deletions core/bin/zksync_server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ zksync_base_token_adjuster.workspace = true
zksync_commitment_generator.workspace = true
zksync_contract_verification_server.workspace = true
zksync_da_clients.workspace = true
zksync_block_reverter.workspace = true
zksync_da_dispatcher.workspace = true
zksync_eth_sender.workspace = true
zksync_eth_watch.workspace = true
Expand All @@ -49,6 +50,7 @@ zksync_tee_proof_data_handler.workspace = true
zksync_vm_runner.workspace = true
zksync_eth_proof_manager.workspace = true
zksync_settlement_layer_data.workspace = true
zksync_l1_recovery.workspace = true


# Consensus dependenices
Expand Down
8 changes: 8 additions & 0 deletions core/bin/zksync_server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ struct Cli {
/// Generate genesis block for the first contract deployment using temporary DB.
#[arg(long)]
genesis: bool,
#[arg(long)]
l1_recovery: bool,
/// Comma-separated list of components to launch.
#[arg(
long,
Expand Down Expand Up @@ -148,6 +150,12 @@ fn main() -> anyhow::Result<()> {
return Ok(());
}

if opt.l1_recovery {
// If genesis is requested, we don't need to run the node.
node.only_l1_recovery()?.run(observability_guard)?;
return Ok(());
}

let node = node.build(opt.components.0)?;

if opt.no_run {
Expand Down
Loading
Loading