Skip to content

Commit

Permalink
Update from upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
slowli committed May 14, 2024
2 parents 59a5641 + 41f74cd commit f7bd796
Show file tree
Hide file tree
Showing 49 changed files with 1,253 additions and 467 deletions.
4 changes: 2 additions & 2 deletions .github/release-please/manifest.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"core": "24.1.0",
"prover": "14.0.0"
"core": "24.2.0",
"prover": "14.1.0"
}
2 changes: 1 addition & 1 deletion Cargo.lock

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

18 changes: 18 additions & 0 deletions core/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
# Changelog

## [24.2.0](https://github.com/matter-labs/zksync-era/compare/core-v24.1.0...core-v24.2.0) (2024-05-14)


### Features

* **api:** Add zeppelinos well-known slots ([#1892](https://github.com/matter-labs/zksync-era/issues/1892)) ([1c041cc](https://github.com/matter-labs/zksync-era/commit/1c041ccd4226f7f9c520814f3af8d00d6d8784c7))
* **en:** Brush up EN observability config ([#1897](https://github.com/matter-labs/zksync-era/issues/1897)) ([086f768](https://github.com/matter-labs/zksync-era/commit/086f7683307b2b9c6a43cb8cf2c1a8a8874277a7))
* **node_framework:** Add tree api server & client to the metadata calculator ([#1885](https://github.com/matter-labs/zksync-era/issues/1885)) ([6dda157](https://github.com/matter-labs/zksync-era/commit/6dda15773295c36d4a8ef56d4e84e4b944829922))


### Bug Fixes

* **core/prover:** Changes to support Validium ([#1910](https://github.com/matter-labs/zksync-era/issues/1910)) ([1cb0dc5](https://github.com/matter-labs/zksync-era/commit/1cb0dc5504d226c55217accca87f2fd75addc917))
* **eth-client:** Fix call error detection ([#1890](https://github.com/matter-labs/zksync-era/issues/1890)) ([c22ce63](https://github.com/matter-labs/zksync-era/commit/c22ce639e08f78b5fd12f2ba7f1e419e8849b1ca))
* **eth-client:** Make block params non-optional ([#1882](https://github.com/matter-labs/zksync-era/issues/1882)) ([3005862](https://github.com/matter-labs/zksync-era/commit/3005862be1ea7c40dea0ae9442b3299b15cf20ca))
* **pruning:** Don't require metadata to exist for first L1 batches to be pruned ([#1850](https://github.com/matter-labs/zksync-era/issues/1850)) ([75c8565](https://github.com/matter-labs/zksync-era/commit/75c85654c4ac4638f3f0705485c95e72727880d4))
* **pruning:** query optimization ([#1904](https://github.com/matter-labs/zksync-era/issues/1904)) ([9154390](https://github.com/matter-labs/zksync-era/commit/9154390ff1d0c2d66a4a811795afa66e6c3c742e))

## [24.1.0](https://github.com/matter-labs/zksync-era/compare/core-v24.0.0...core-v24.1.0) (2024-05-08)


Expand Down
2 changes: 1 addition & 1 deletion core/bin/external_node/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "zksync_external_node"
version = "24.1.0" # x-release-please-version
version = "24.2.0" # x-release-please-version
edition.workspace = true
authors.workspace = true
homepage.workspace = true
Expand Down
15 changes: 13 additions & 2 deletions core/bin/external_node/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ use tokio::{
};
use zksync_block_reverter::{BlockReverter, NodeRole};
use zksync_commitment_generator::{
commitment_post_processor::{
CommitmentPostProcessor, RollupCommitmentPostProcessor, ValidiumCommitmentPostProcessor,
},
input_generation::{InputGenerator, RollupInputGenerator, ValidiumInputGenerator},
CommitmentGenerator,
};
Expand Down Expand Up @@ -196,6 +199,7 @@ async fn run_tree(
tree_reader
.wait()
.await
.context("Cannot initialize tree reader")?
.run_api_server(address, stop_receiver)
.await
}));
Expand Down Expand Up @@ -346,17 +350,20 @@ async fn run_core(
)
.await?;

let (l1_batch_commit_data_generator, input_generator): (
let (l1_batch_commit_data_generator, input_generator, commitment_post_processor): (
Arc<dyn L1BatchCommitDataGenerator>,
Box<dyn InputGenerator>,
Box<dyn CommitmentPostProcessor>,
) = match config.optional.l1_batch_commit_data_generator_mode {
L1BatchCommitDataGeneratorMode::Rollup => (
Arc::new(RollupModeL1BatchCommitDataGenerator {}),
Box::new(RollupInputGenerator),
Box::new(RollupCommitmentPostProcessor),
),
L1BatchCommitDataGeneratorMode::Validium => (
Arc::new(ValidiumModeL1BatchCommitDataGenerator {}),
Box::new(ValidiumInputGenerator),
Box::new(ValidiumCommitmentPostProcessor),
),
};

Expand Down Expand Up @@ -388,7 +395,11 @@ async fn run_core(
.build()
.await
.context("failed to build a commitment_generator_pool")?;
let commitment_generator = CommitmentGenerator::new(commitment_generator_pool, input_generator);
let commitment_generator = CommitmentGenerator::new(
commitment_generator_pool,
input_generator,
commitment_post_processor,
);
app_health.insert_component(commitment_generator.health_check())?;
let commitment_generator_handle = tokio::spawn(commitment_generator.run(stop_receiver.clone()));

Expand Down
39 changes: 21 additions & 18 deletions core/lib/basic_types/src/basic_fri_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,16 @@ type Eip4844BlobsInner = [Option<Blob>; MAX_4844_BLOBS_PER_BLOCK];
/// Current invariants:
/// - there are between [1, 16] blobs
/// - all blobs are of the same size [`EIP_4844_BLOB_SIZE`]
/// - there may be no blobs in case of Validium
/// Creating a structure violating these constraints will panic.
///
/// Note: blobs are padded to fit the correct size.
#[derive(Debug, Serialize, Deserialize, Clone)]
// TODO: PLA-932
/// Note 2: this becomes a rather leaky abstraction.
/// It will be reworked once `BWIP` is introduced.
/// Provers shouldn't need to decide between loading data from database or making it empty.
/// Data should just be available
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
pub struct Eip4844Blobs {
blobs: Eip4844BlobsInner,
}
Expand All @@ -39,23 +45,27 @@ impl Eip4844Blobs {
}

impl Eip4844Blobs {
pub fn empty() -> Self {
Self {
blobs: Default::default(),
}
}

pub fn encode(self) -> Vec<u8> {
self.blobs().into_iter().flatten().flatten().collect()
}

pub fn decode(blobs: &[u8]) -> anyhow::Result<Self> {
// Validium case
if blobs.is_empty() {
return Ok(Self::empty());
}
let mut chunks: Vec<Blob> = blobs
.chunks(EIP_4844_BLOB_SIZE)
.map(|chunk| chunk.into())
.collect();

if let Some(last_chunk) = chunks.last_mut() {
last_chunk.resize(EIP_4844_BLOB_SIZE, 0u8);
} else {
return Err(anyhow::anyhow!(
"cannot create Eip4844Blobs, received empty pubdata"
));
}
// Unwrapping here is safe because of check on first line of the function.
chunks.last_mut().unwrap().resize(EIP_4844_BLOB_SIZE, 0u8);

if chunks.len() > MAX_4844_BLOBS_PER_BLOCK {
return Err(anyhow::anyhow!(
Expand Down Expand Up @@ -181,15 +191,8 @@ mod tests {
#[test]
fn test_eip_4844_blobs_empty_pubdata() {
let payload = vec![];
match Eip4844Blobs::decode(&payload) {
Ok(_) => panic!("expected error, got Ok"),
Err(e) => {
assert_eq!(
e.to_string(),
"cannot create Eip4844Blobs, received empty pubdata"
);
}
}
let blobs = Eip4844Blobs::decode(&payload).unwrap();
assert_eq!(blobs, Eip4844Blobs::empty());
}

#[test]
Expand Down

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

This file was deleted.

18 changes: 9 additions & 9 deletions core/lib/dal/src/pruning_dal/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -320,17 +320,17 @@ impl PruningDal<'_, '_> {
) -> DalResult<u64> {
let execution_result = sqlx::query!(
r#"
DELETE FROM storage_logs USING (
SELECT
*
FROM
storage_logs
WHERE
miniblock_number BETWEEN $1 AND $2
) AS batches_to_prune
DELETE FROM storage_logs
WHERE
storage_logs.miniblock_number < $1
AND batches_to_prune.hashed_key = storage_logs.hashed_key
AND hashed_key IN (
SELECT
hashed_key
FROM
storage_logs
WHERE
miniblock_number BETWEEN $1 AND $2
)
"#,
i64::from(l2_blocks_to_prune.start().0),
i64::from(l2_blocks_to_prune.end().0)
Expand Down
12 changes: 8 additions & 4 deletions core/lib/types/src/commitment/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,15 +259,15 @@ impl SerializeCommitment for StateDiffRecord {

#[derive(Debug, Clone, Eq, PartialEq)]
#[cfg_attr(test, derive(Serialize, Deserialize))]
struct L1BatchAuxiliaryCommonOutput {
pub struct L1BatchAuxiliaryCommonOutput {
l2_l1_logs_merkle_root: H256,
protocol_version: ProtocolVersionId,
}

/// Block Output produced by Virtual Machine
#[derive(Debug, Clone, Eq, PartialEq)]
#[cfg_attr(test, derive(Serialize, Deserialize))]
enum L1BatchAuxiliaryOutput {
pub enum L1BatchAuxiliaryOutput {
PreBoojum {
common: L1BatchAuxiliaryCommonOutput,
l2_l1_logs_linear_hash: H256,
Expand Down Expand Up @@ -528,8 +528,8 @@ impl L1BatchPassThroughData {
#[derive(Debug, Clone)]
pub struct L1BatchCommitment {
pass_through_data: L1BatchPassThroughData,
auxiliary_output: L1BatchAuxiliaryOutput,
meta_parameters: L1BatchMetaParameters,
pub auxiliary_output: L1BatchAuxiliaryOutput,
pub meta_parameters: L1BatchMetaParameters,
}

#[derive(Debug, Clone, PartialEq, Eq)]
Expand Down Expand Up @@ -574,6 +574,10 @@ impl L1BatchCommitment {
self.meta_parameters.clone()
}

pub fn aux_output(&self) -> L1BatchAuxiliaryOutput {
self.auxiliary_output.clone()
}

pub fn l2_l1_logs_merkle_root(&self) -> H256 {
self.auxiliary_output.common().l2_l1_logs_merkle_root
}
Expand Down
1 change: 1 addition & 0 deletions core/lib/zksync_core/src/api_server/tree/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ async fn merkle_tree_api() {
let api_server = tree_reader
.wait()
.await
.unwrap()
.create_api_server(&api_addr, stop_receiver.clone())
.unwrap();
let local_addr = *api_server.local_addr();
Expand Down
34 changes: 28 additions & 6 deletions core/lib/zksync_core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ use zksync_circuit_breaker::{
CircuitBreakerChecker, CircuitBreakers,
};
use zksync_commitment_generator::{
commitment_post_processor::{
CommitmentPostProcessor, RollupCommitmentPostProcessor, ValidiumCommitmentPostProcessor,
},
input_generation::{InputGenerator, RollupInputGenerator, ValidiumInputGenerator},
CommitmentGenerator,
};
Expand Down Expand Up @@ -76,6 +79,9 @@ use zksync_node_fee_model::{
};
use zksync_node_genesis::{ensure_genesis_state, GenesisParams};
use zksync_object_store::{ObjectStore, ObjectStoreFactory};
use zksync_proof_data_handler::blob_processor::{
BlobProcessor, RollupBlobProcessor, ValidiumBlobProcessor,
};
use zksync_shared_metrics::{InitStage, APP_METRICS};
use zksync_state::{PostgresStorageCaches, RocksdbStorageOptions};
use zksync_types::{ethabi::Contract, fee_model::FeeModelConfig, Address, L2ChainId};
Expand Down Expand Up @@ -605,13 +611,24 @@ pub async fn initialize_components(
tracing::info!("initialized ETH-Watcher in {elapsed:?}");
}

let input_generator: Box<dyn InputGenerator> = if genesis_config
.l1_batch_commit_data_generator_mode
let (input_generator, commitment_post_processor, blob_processor): (
Box<dyn InputGenerator>,
Box<dyn CommitmentPostProcessor>,
Arc<dyn BlobProcessor>,
) = if genesis_config.l1_batch_commit_data_generator_mode
== L1BatchCommitDataGeneratorMode::Validium
{
Box::new(ValidiumInputGenerator)
(
Box::new(ValidiumInputGenerator),
Box::new(ValidiumCommitmentPostProcessor),
Arc::new(ValidiumBlobProcessor),
)
} else {
Box::new(RollupInputGenerator)
(
Box::new(RollupInputGenerator),
Box::new(RollupCommitmentPostProcessor),
Arc::new(RollupBlobProcessor),
)
};

if components.contains(&Component::EthTxAggregator) {
Expand Down Expand Up @@ -771,6 +788,7 @@ pub async fn initialize_components(
.context("proof_data_handler_config")?,
store_factory.create_store().await,
connection_pool.clone(),
blob_processor,
stop_receiver.clone(),
)));
}
Expand All @@ -781,8 +799,11 @@ pub async fn initialize_components(
.build()
.await
.context("failed to build commitment_generator_pool")?;
let commitment_generator =
CommitmentGenerator::new(commitment_generator_pool, input_generator);
let commitment_generator = CommitmentGenerator::new(
commitment_generator_pool,
input_generator,
commitment_post_processor,
);
app_health.insert_component(commitment_generator.health_check())?;
task_futures.push(tokio::spawn(
commitment_generator.run(stop_receiver.clone()),
Expand Down Expand Up @@ -1019,6 +1040,7 @@ async fn run_tree(
tree_reader
.wait()
.await
.context("Cannot initialize tree reader")?
.run_api_server(address, stop_receiver)
.await
}));
Expand Down
Loading

0 comments on commit f7bd796

Please sign in to comment.