Skip to content

Commit d1b4308

Browse files
authored
feat(consensus): Add consensus protocol versioning (#3720)
## What ❔ It makes some necessary changes to allow supporting multiple consensus protocol versions. Most of the changes are on the era-consensus side (which this PR updates to v0.9). On the zksync-era side, I changed the DB to store versioned block certificates. This PR also removes the genesis column on the consensus_replica_state table since that was deprecated a long time ago. Also updates the Rust toolchain a bit (needed for a stable feature used in era-consensus). This caused a bunch of lints to need to also be fixed in this PR (mostly `too_long_first_doc_paragraph`). Part of BFT-483 ## Why ❔ We need to be able to support at least 2 consensus protocol versions concurrently in order to be able to do consensus protocol upgrades. ## Is this a breaking change? - [ ] Yes - [x] No ## Operational changes None. ## Checklist - [x] PR title corresponds to the body of PR (we generate changelog entries from PRs). - [x] Tests for the changes have been added / updated. - [x] Documentation comments have been added / updated. - [x] Code has been formatted via `zkstack dev fmt` and `zkstack dev lint`.
1 parent ed4926f commit d1b4308

File tree

129 files changed

+567
-368
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

129 files changed

+567
-368
lines changed

.github/workflows/build-contract-verifier-template.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ jobs:
9494
if: env.BUILD_CONTRACTS == 'true'
9595
uses: actions-rust-lang/setup-rust-toolchain@1fbea72663f6d4c03efaab13560c8a24cfd2a7cc # v1.9.0
9696
with:
97-
toolchain: nightly-2024-08-01
97+
toolchain: nightly-2024-09-01
9898

9999
- name: Install foundry-zksync
100100
if: env.BUILD_CONTRACTS == 'true'

.github/workflows/build-core-template.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ jobs:
9999
if: env.BUILD_CONTRACTS == 'true'
100100
uses: actions-rust-lang/setup-rust-toolchain@1fbea72663f6d4c03efaab13560c8a24cfd2a7cc # v1.9.0
101101
with:
102-
toolchain: nightly-2024-08-01
102+
toolchain: nightly-2024-09-01
103103

104104
- name: Install foundry-zksync
105105
if: env.BUILD_CONTRACTS == 'true'

.github/workflows/build-prover-template.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ jobs:
6363
- name: setup rust
6464
uses: actions-rust-lang/setup-rust-toolchain@1fbea72663f6d4c03efaab13560c8a24cfd2a7cc # v1.9.0
6565
with:
66-
toolchain: nightly-2024-08-01
66+
toolchain: nightly-2024-09-01
6767

6868
- name: Prepare sccache-cache env vars
6969
shell: bash

.github/workflows/build-witness-generator-template.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ jobs:
5353
- name: setup rust
5454
uses: actions-rust-lang/setup-rust-toolchain@1fbea72663f6d4c03efaab13560c8a24cfd2a7cc # v1.9.0
5555
with:
56-
toolchain: nightly-2024-08-01
56+
toolchain: nightly-2024-09-01
5757

5858
- name: Prepare sccache-cache env vars
5959
shell: bash

.github/workflows/release-zkstack-bins.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ jobs:
4646
- name: Install Rust
4747
uses: actions-rust-lang/setup-rust-toolchain@v1
4848
with:
49-
toolchain: nightly-2024-08-01
49+
toolchain: nightly-2024-09-01
5050
rustflags: ""
5151

5252
- name: Install target

core/Cargo.lock

Lines changed: 20 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

core/Cargo.toml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -254,16 +254,16 @@ bellman = { package = "zksync_bellman", version = "=0.31.0" }
254254
zksync_vm2 = "=0.3.0"
255255

256256
# Consensus dependencies.
257-
zksync_concurrency = "=0.8.0"
258-
zksync_consensus_bft = "=0.8.0"
259-
zksync_consensus_crypto = "=0.8.0"
260-
zksync_consensus_executor = "=0.8.0"
261-
zksync_consensus_network = "=0.8.0"
262-
zksync_consensus_roles = "=0.8.0"
263-
zksync_consensus_storage = "=0.8.0"
264-
zksync_consensus_utils = "=0.8.0"
265-
zksync_protobuf = "=0.8.0"
266-
zksync_protobuf_build = "=0.8.0"
257+
zksync_concurrency = "=0.9.0"
258+
zksync_consensus_bft = "=0.9.0"
259+
zksync_consensus_crypto = "=0.9.0"
260+
zksync_consensus_executor = "=0.9.0"
261+
zksync_consensus_network = "=0.9.0"
262+
zksync_consensus_roles = "=0.9.0"
263+
zksync_consensus_storage = "=0.9.0"
264+
zksync_consensus_utils = "=0.9.0"
265+
zksync_protobuf = "=0.9.0"
266+
zksync_protobuf_build = "=0.9.0"
267267

268268
# "Local" dependencies
269269
zksync_multivm = { version = "27.0.0-non-semver-compat", path = "lib/multivm" }

core/lib/basic_types/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,7 @@ basic_type!(
255255

256256
basic_type!(
257257
/// ChainId in the Ethereum network.
258+
///
258259
/// IMPORTANT: Please, use this method when exactly the L1 chain id is required.
259260
/// Note, that typically this is not the case and the majority of methods need to work
260261
/// with *settlement layer* chain id, which is represented by `SLChainId`.

core/lib/basic_types/src/protocol_version.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ pub const PACKED_SEMVER_MINOR_OFFSET: u32 = 32;
2121
pub const PACKED_SEMVER_MINOR_MASK: u32 = 0xFFFF;
2222

2323
/// `ProtocolVersionId` is a unique identifier of the protocol version.
24+
///
2425
/// Note, that it is an identifier of the `minor` semver version of the protocol, with
2526
/// the `major` version being `0`. Also, the protocol version on the contracts may contain
2627
/// potential minor versions, that may have different contract behavior (e.g. Verifier), but it should not

core/lib/basic_types/src/serde_wrappers.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ impl Prefix for ZeroxPrefix {
1515
}
1616
}
1717

18+
/// `BytesToHexSerde` is a helper struct that allows to serialize and deserialize `Vec<u8>` fields as hex-encoded strings with a prefix.
19+
///
1820
/// Used to annotate `Vec<u8>` fields that you want to serialize like hex-encoded string with prefix
1921
/// Use this struct in annotation like that `[serde(with = "BytesToHexSerde::<T>"]`
2022
/// where T is concrete prefix type (e.g. `SyncBlockPrefix`)

0 commit comments

Comments
 (0)