Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Removed protobuf encoding from zksync_types #562

Merged
merged 14 commits into from
Dec 5, 2023
Prev Previous commit
Next Next commit
Merge remote-tracking branch 'origin/main' into gprusak-dal-protobuf
pompon0 committed Dec 5, 2023

Verified

This commit was signed with the committer’s verified signature.
pompon0 Grzegorz Prusak
commit c6fc5f561b9f7d57b76e5fa1391c37c0c4bbde00
3 changes: 3 additions & 0 deletions Cargo.lock

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

6 changes: 3 additions & 3 deletions core/lib/dal/Cargo.toml
Original file line number Diff line number Diff line change
@@ -18,8 +18,8 @@ zksync_system_constants = { path = "../constants" }
zksync_contracts = { path = "../contracts" }
zksync_types = { path = "../types" }
zksync_health_check = { path = "../health_check" }
zksync_consensus_roles = { version = "0.1.0", git = "https://github.com/matter-labs/era-consensus.git", rev = "ed71b2e817c980a2daffef6a01885219e1dc6fa0" }
zksync_protobuf = { version = "0.1.0", git = "https://github.com/matter-labs/era-consensus.git", rev = "ed71b2e817c980a2daffef6a01885219e1dc6fa0" }
zksync_consensus_roles = { version = "0.1.0", git = "https://github.com/matter-labs/era-consensus.git", rev = "da015d4c94b19962bc11622b6cc256e214256555" }
zksync_protobuf = { version = "0.1.0", git = "https://github.com/matter-labs/era-consensus.git", rev = "da015d4c94b19962bc11622b6cc256e214256555" }

itertools = "0.10.1"
thiserror = "1.0"
@@ -53,4 +53,4 @@ tracing = "0.1"
assert_matches = "1.5.0"

[build-dependencies]
zksync_protobuf_build = { version = "0.1.0", git = "https://github.com/matter-labs/era-consensus.git", rev = "ed71b2e817c980a2daffef6a01885219e1dc6fa0" }
zksync_protobuf_build = { version = "0.1.0", git = "https://github.com/matter-labs/era-consensus.git", rev = "da015d4c94b19962bc11622b6cc256e214256555" }
5 changes: 5 additions & 0 deletions core/lib/types/Cargo.toml
Original file line number Diff line number Diff line change
@@ -21,6 +21,8 @@ codegen = { git = "https://github.com/matter-labs/solidity_plonk_verifier.git",
zkevm_test_harness = { git = "https://github.com/matter-labs/era-zkevm_test_harness.git", branch = "v1.3.3" }
zk_evm_1_4_0 = { git = "https://github.com/matter-labs/era-zk_evm.git", branch = "v1.4.0", package = "zk_evm" }
zk_evm = { git = "https://github.com/matter-labs/era-zk_evm.git", tag = "v1.3.3-rc2" }
zksync_consensus_roles = { version = "0.1.0", git = "https://github.com/matter-labs/era-consensus.git", rev = "da015d4c94b19962bc11622b6cc256e214256555" }
zksync_protobuf = { version = "0.1.0", git = "https://github.com/matter-labs/era-consensus.git", rev = "da015d4c94b19962bc11622b6cc256e214256555" }

anyhow = "1.0.75"
chrono = { version = "0.4", features = ["serde"] }
@@ -48,3 +50,6 @@ ethereum_types_old = { package = "ethereum-types", version = "0.12.0" }
secp256k1 = { version = "0.27", features = ["recovery"] }
tokio = { version = "1", features = ["rt", "macros"] }
serde_with = { version = "1", features = ["hex"] }

[build-dependencies]
zksync_protobuf_build = { version = "0.1.0", git = "https://github.com/matter-labs/era-consensus.git", rev = "da015d4c94b19962bc11622b6cc256e214256555" }
8 changes: 8 additions & 0 deletions core/lib/zksync_core/src/sync_layer/gossip/conversions.rs
Original file line number Diff line number Diff line change
@@ -15,6 +15,14 @@ pub(super) fn sync_block_to_consensus_block(block: en::SyncBlock) -> anyhow::Res
.context("Missing consensus fields")?;
let consensus =
ConsensusBlockFields::decode(consensus).context("ConsensusBlockFields::decode()")?;
let consensus_protocol_version = consensus.justification.message.protocol_version.as_u32();
let block_protocol_version = block.protocol_version as u32;
anyhow::ensure!(
consensus_protocol_version == block_protocol_version,
"Protocol version for justification ({consensus_protocol_version}) differs from \
SyncBlock.protocol_version={block_protocol_version}"
);

let payload: consensus::Payload = block.try_into().context("Missing `SyncBlock` data")?;
let payload = payload.encode();
let header = BlockHeader {
4 changes: 3 additions & 1 deletion core/lib/zksync_core/src/sync_layer/gossip/tests.rs
Original file line number Diff line number Diff line change
@@ -11,7 +11,9 @@ use zksync_consensus_roles::validator::{self, FinalBlock};
use zksync_consensus_storage::{InMemoryStorage, WriteBlockStore};
use zksync_dal::blocks_dal::ConsensusBlockFields;
use zksync_dal::{ConnectionPool, StorageProcessor};
use zksync_types::{api::en::SyncBlock, Address, L1BatchNumber, MiniblockNumber, H256};
use zksync_types::{
api::en::SyncBlock, Address, L1BatchNumber, MiniblockNumber, ProtocolVersionId, H256,
};

use super::*;
use crate::{
You are viewing a condensed version of this merge commit. You can view the full changes here.