Skip to content

Commit 4905261

Browse files
authored
refactor(consensus): Deprecate attesters and prepare for validator committee rotation (matter-labs#3775)
## What ❔ It introduces some code necessary for validator committee rotation. This doesn't enable that functionality yet as we still need the new consensus registry contract to be merged (matter-labs/era-contracts#1365) and also change to matter-labs/era-consensus. A future PR will integrate those changes and enable it. It deprecates almost all the code related to the attester role. Since ZK OS won't have L1 batches, this role won't be needed in the future. Plus, if we decide to do L1 consensus verification before ZK OS, it's simpler to just do an operator multisig (the functionality is reduced but it's a temporary solution anyway). It also deprecates the genesis column in the consensus_replica_state Postgres table. Storing genesis has been deprecated in favor of storing global config a long time ago. matter-labs#3720 already removed all code related to it, this completes the deprecation by removing the column. My next PR will remove the attester method from ZK Stack CLI. I'll do it in a separate PR since this one is already somewhat large and ZK Stack CLI changes are best reviewed by someone familiar with it. Part of PLA-1112 and PLA-1113 ## Why ❔ It prepares the repo for validator committee rotation, which is the ability to change the validator set by interacting with a L2 smart contract (the consensus registry). This then enables staking, all being required after it is a contract that handles the staking UI and updates the validator set on the consensus registry. ## Is this a breaking change? - [X] Yes - [ ] No Technically, yes. Any chain that has a working attester set will stop attesting batches, but nothing else will break. ## Operational changes On the consensus config of the main node, the attesters field should be removed. Not removing it won't break anything, the field will just be ignored by protobuf. ## 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 87938b3 commit 4905261

File tree

51 files changed

+623
-1775
lines changed

Some content is hidden

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

51 files changed

+623
-1775
lines changed

.github/workflows/ci-core-reusable.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -472,11 +472,6 @@ jobs:
472472
ci_run zkstack server wait --ignore-prerequisites --verbose --chain custom_token
473473
ci_run zkstack server wait --ignore-prerequisites --verbose --chain consensus
474474
475-
- name: Set up attester committee for the consensus chain
476-
run: |
477-
ci_run zkstack consensus wait-for-registry --ignore-prerequisites --verbose --chain consensus
478-
ci_run zkstack consensus set-attester-committee --chain consensus --ignore-prerequisites --verbose --from-genesis &> ${{ env.INTEGRATION_TESTS_LOGS_DIR }}/consensus.log
479-
480475
- name: Run integration tests
481476
run: |
482477
ci_run ./bin/run_on_all_chains.sh "zkstack dev test integration --verbose --no-deps --ignore-prerequisites" \

core/bin/external_node/src/config/mod.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1222,12 +1222,9 @@ impl ExperimentalENConfig {
12221222
/// They should be copied over to the secrets.yaml/consensus_secrets.yaml file.
12231223
pub fn generate_consensus_secrets() {
12241224
let validator_key = roles::validator::SecretKey::generate();
1225-
let attester_key = roles::attester::SecretKey::generate();
12261225
let node_key = roles::node::SecretKey::generate();
12271226
println!("# {}", validator_key.public().encode());
12281227
println!("validator_key: {}", validator_key.encode());
1229-
println!("# {}", attester_key.public().encode());
1230-
println!("attester_key: {}", attester_key.encode());
12311228
println!("# {}", node_key.public().encode());
12321229
println!("node_key: {}", node_key.encode());
12331230
}

core/lib/config/src/configs/consensus.rs

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,6 @@ pub struct ValidatorPublicKey(pub String);
1212
#[derive(Debug, Clone)]
1313
pub struct ValidatorSecretKey(pub SecretString);
1414

15-
/// `zksync_consensus_crypto::TextFmt` representation of `zksync_consensus_roles::attester::PublicKey`.
16-
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
17-
pub struct AttesterPublicKey(pub String);
18-
19-
/// `zksync_consensus_crypto::TextFmt` representation of `zksync_consensus_roles::attester::SecretKey`.
20-
#[derive(Debug, Clone)]
21-
pub struct AttesterSecretKey(pub SecretString);
22-
2315
/// `zksync_consensus_crypto::TextFmt` representation of `zksync_consensus_roles::node::PublicKey`.
2416
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
2517
pub struct NodePublicKey(pub String);
@@ -34,12 +26,6 @@ impl PartialEq for ValidatorSecretKey {
3426
}
3527
}
3628

37-
impl PartialEq for AttesterSecretKey {
38-
fn eq(&self, other: &Self) -> bool {
39-
self.0.expose_secret().eq(other.0.expose_secret())
40-
}
41-
}
42-
4329
impl PartialEq for NodeSecretKey {
4430
fn eq(&self, other: &Self) -> bool {
4531
self.0.expose_secret().eq(other.0.expose_secret())
@@ -55,15 +41,6 @@ pub struct WeightedValidator {
5541
pub weight: u64,
5642
}
5743

58-
/// Copy-paste of `zksync_consensus_roles::attester::WeightedAttester`.
59-
#[derive(Debug, Clone, PartialEq, Eq)]
60-
pub struct WeightedAttester {
61-
/// Attester key
62-
pub key: AttesterPublicKey,
63-
/// Attester weight inside the Committee.
64-
pub weight: u64,
65-
}
66-
6744
/// Copy-paste of `zksync_concurrency::net::Host`.
6845
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
6946
pub struct Host(pub String);
@@ -84,8 +61,6 @@ pub struct GenesisSpec {
8461
pub protocol_version: ProtocolVersion,
8562
/// The validator committee. Represents `zksync_consensus_roles::validator::Committee`.
8663
pub validators: Vec<WeightedValidator>,
87-
/// The attester committee. Represents `zksync_consensus_roles::attester::Committee`.
88-
pub attesters: Vec<WeightedAttester>,
8964
/// Leader of the committee. Represents
9065
/// `zksync_consensus_roles::validator::LeaderSelectionMode::Sticky`.
9166
pub leader: ValidatorPublicKey,
@@ -170,6 +145,5 @@ impl ConsensusConfig {
170145
#[derive(Debug, Clone, PartialEq)]
171146
pub struct ConsensusSecrets {
172147
pub validator_key: Option<ValidatorSecretKey>,
173-
pub attester_key: Option<AttesterSecretKey>,
174148
pub node_key: Option<NodeSecretKey>,
175149
}

core/lib/config/src/testonly.rs

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -642,16 +642,6 @@ impl Distribution<configs::consensus::WeightedValidator> for EncodeDist {
642642
}
643643
}
644644

645-
impl Distribution<configs::consensus::WeightedAttester> for EncodeDist {
646-
fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> configs::consensus::WeightedAttester {
647-
use configs::consensus::{AttesterPublicKey, WeightedAttester};
648-
WeightedAttester {
649-
key: AttesterPublicKey(self.sample(rng)),
650-
weight: self.sample(rng),
651-
}
652-
}
653-
}
654-
655645
impl Distribution<configs::consensus::GenesisSpec> for EncodeDist {
656646
fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> configs::consensus::GenesisSpec {
657647
use configs::consensus::{
@@ -661,7 +651,6 @@ impl Distribution<configs::consensus::GenesisSpec> for EncodeDist {
661651
chain_id: L2ChainId::default(),
662652
protocol_version: ProtocolVersion(self.sample(rng)),
663653
validators: self.sample_collect(rng),
664-
attesters: self.sample_collect(rng),
665654
leader: ValidatorPublicKey(self.sample(rng)),
666655
registry_address: self.sample_opt(|| rng.gen()),
667656
seed_peers: self
@@ -708,12 +697,9 @@ impl Distribution<configs::consensus::RpcConfig> for EncodeDist {
708697

709698
impl Distribution<configs::consensus::ConsensusSecrets> for EncodeDist {
710699
fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> configs::consensus::ConsensusSecrets {
711-
use configs::consensus::{
712-
AttesterSecretKey, ConsensusSecrets, NodeSecretKey, ValidatorSecretKey,
713-
};
700+
use configs::consensus::{ConsensusSecrets, NodeSecretKey, ValidatorSecretKey};
714701
ConsensusSecrets {
715702
validator_key: self.sample_opt(|| ValidatorSecretKey(String::into(self.sample(rng)))),
716-
attester_key: self.sample_opt(|| AttesterSecretKey(String::into(self.sample(rng)))),
717703
node_key: self.sample_opt(|| NodeSecretKey(String::into(self.sample(rng)))),
718704
}
719705
}

core/lib/dal/.sqlx/query-20ca69ea882c8ebd4df309e90d282977fdd8fc7d817cab5d415ff95673540b13.json

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

core/lib/dal/.sqlx/query-3353dd735addf184732843151dd47e1ed84929bf75bb814ee2280d241912d38f.json

Lines changed: 0 additions & 15 deletions
This file was deleted.

core/lib/dal/.sqlx/query-46a5f88b445817c0f9ed60cdd96d49d2e57b21bbfe934b0e3e14f2e465d3bdd4.json

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

core/lib/dal/.sqlx/query-65bbf852d677e1f00a04785374148aa4e4a804519bcf68e14c5bbb0f58939da1.json

Lines changed: 0 additions & 22 deletions
This file was deleted.

core/lib/dal/.sqlx/query-883be3789994eac050df85056e4987e056c2bf423054e40236aba60f4d3b8a97.json

Lines changed: 0 additions & 20 deletions
This file was deleted.

core/lib/dal/.sqlx/query-8c763c05187a409a54806b0eb88e733f635b183960226848b280383042ea3637.json

Lines changed: 0 additions & 22 deletions
This file was deleted.

0 commit comments

Comments
 (0)