Skip to content

Commit

Permalink
feat: Extract block_reverter into separate crate (#1632)
Browse files Browse the repository at this point in the history
## What ❔
Extract `zksync_core::block_reverter` to separate the crate in the
`node` folder

## Why ❔

Part of the to "modularize the codebase" process, required for legolizer
and publishing on crates.io.

## 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`.
- [ ] Spellcheck has been run via `zk spellcheck`.
- [ ] Linkcheck has been run via `zk linkcheck`.
  • Loading branch information
AnastasiiaVashchuk committed Apr 17, 2024
1 parent 83eae5c commit 8ab2488
Show file tree
Hide file tree
Showing 11 changed files with 58 additions and 7 deletions.
22 changes: 21 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ members = [
"core/bin/genesis_generator",
# Node services
"core/node/node_framework",
"core/node/block_reverter",
"core/node/commitment_generator",
# Libraries
"core/lib/db_connection",
Expand Down Expand Up @@ -223,4 +224,5 @@ zksync_crypto_primitives = { path = "core/lib/crypto_primitives" }
zksync_node_framework = { path = "core/node/node_framework" }
zksync_eth_watch = { path = "core/node/eth_watch" }
zksync_shared_metrics = { path = "core/node/shared_metrics" }
zksync_block_reverter = { path = "core/node/block_reverter"}
zksync_commitment_generator = { path = "core/node/commitment_generator" }
2 changes: 1 addition & 1 deletion core/bin/block_reverter/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ zksync_config.workspace = true
zksync_env_config.workspace = true
zksync_dal.workspace = true
zksync_types.workspace = true
zksync_core.workspace = true
zksync_block_reverter.workspace = true
vlog.workspace = true

anyhow.workspace = true
Expand Down
6 changes: 3 additions & 3 deletions core/bin/block_reverter/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use anyhow::Context as _;
use clap::{Parser, Subcommand};
use tokio::io::{self, AsyncReadExt};
use zksync_block_reverter::{
BlockReverter, BlockReverterEthConfig, BlockReverterFlags, L1ExecutedBatchesRevert, NodeRole,
};
use zksync_config::{
configs::ObservabilityConfig, ContractsConfig, DBConfig, EthConfig, PostgresConfig,
};
use zksync_core::block_reverter::{
BlockReverter, BlockReverterEthConfig, BlockReverterFlags, L1ExecutedBatchesRevert, NodeRole,
};
use zksync_dal::{ConnectionPool, Core};
use zksync_env_config::FromEnv;
use zksync_types::{Address, L1BatchNumber, U256};
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 @@ -30,6 +30,7 @@ prometheus_exporter.workspace = true
zksync_health_check.workspace = true
zksync_web3_decl.workspace = true
zksync_types.workspace = true
zksync_block_reverter.workspace = true
vlog.workspace = true

zksync_concurrency.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion core/bin/external_node/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use tokio::{
sync::{oneshot, watch, RwLock},
task::{self, JoinHandle},
};
use zksync_block_reverter::{BlockReverter, BlockReverterFlags, L1ExecutedBatchesRevert, NodeRole};
use zksync_commitment_generator::CommitmentGenerator;
use zksync_concurrency::{ctx, scope};
use zksync_config::configs::{
Expand All @@ -21,7 +22,6 @@ use zksync_core::{
tx_sender::{proxy::TxProxy, ApiContracts, TxSenderBuilder},
web3::{mempool_cache::MempoolCache, ApiBuilder, Namespace},
},
block_reverter::{BlockReverter, BlockReverterFlags, L1ExecutedBatchesRevert, NodeRole},
consensus,
consistency_checker::ConsistencyChecker,
db_pruner::{DbPruner, DbPrunerConfig},
Expand Down
1 change: 0 additions & 1 deletion core/lib/zksync_core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ use crate::{

pub mod api_server;
pub mod basic_witness_input_producer;
pub mod block_reverter;
pub mod consensus;
pub mod consistency_checker;
pub mod db_pruner;
Expand Down
25 changes: 25 additions & 0 deletions core/node/block_reverter/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
[package]
name = "zksync_block_reverter"
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

[dependencies]
zksync_types.workspace = true
zksync_dal.workspace = true
zksync_config.workspace = true
zksync_contracts.workspace = true
zksync_storage.workspace = true
zksync_eth_signer.workspace = true
zksync_state.workspace = true
zksync_merkle_tree.workspace = true

tokio = { workspace = true, features = ["time"] }
bitflags.workspace = true
serde.workspace = true
tracing.workspace = true
3 changes: 3 additions & 0 deletions core/node/block_reverter/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# zkSync Era Block reverter

This crate contains functionality for zkSync state rollback.
File renamed without changes.
1 change: 1 addition & 0 deletions core/node/node_framework/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ zksync_utils.workspace = true
zksync_circuit_breaker.workspace = true
zksync_concurrency.workspace = true
zksync_eth_watch.workspace = true
zksync_block_reverter.workspace = true
zksync_commitment_generator.workspace = true

tracing.workspace = true
Expand Down

0 comments on commit 8ab2488

Please sign in to comment.