Skip to content

Commit

Permalink
chore: bumped consensus deps (matter-labs#1824)
Browse files Browse the repository at this point in the history
This PR bumps era-consensus to a non-backward compatible version, so
I've purged the consensus deployment on stage. I'll reenable consensus
on stage once this PR is merged.
  • Loading branch information
pompon0 committed Apr 29, 2024
1 parent 437fd18 commit ae9ecc2
Show file tree
Hide file tree
Showing 20 changed files with 140 additions and 154 deletions.
49 changes: 18 additions & 31 deletions Cargo.lock

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

20 changes: 10 additions & 10 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -170,16 +170,16 @@ zk_evm_1_3_3 = { package = "zk_evm", git = "https://github.com/matter-labs/era-z
zk_evm_1_4_0 = { package = "zk_evm", git = "https://github.com/matter-labs/era-zk_evm.git", branch = "v1.4.0" }
zk_evm_1_4_1 = { package = "zk_evm", git = "https://github.com/matter-labs/era-zk_evm.git", branch = "v1.4.1" }
zk_evm_1_5_0 = { package = "zk_evm", git = "https://github.com/matter-labs/era-zk_evm.git", branch = "v1.5.0" }
zksync_concurrency = { version = "0.1.0", git = "https://github.com/matter-labs/era-consensus.git", rev = "1dcda70c1c25d0e4db6781ba8d2645d7e8966d49" }
zksync_consensus_bft = { version = "0.1.0", git = "https://github.com/matter-labs/era-consensus.git", rev = "1dcda70c1c25d0e4db6781ba8d2645d7e8966d49" }
zksync_consensus_crypto = { version = "0.1.0", git = "https://github.com/matter-labs/era-consensus.git", rev = "1dcda70c1c25d0e4db6781ba8d2645d7e8966d49" }
zksync_consensus_executor = { version = "0.1.0", git = "https://github.com/matter-labs/era-consensus.git", rev = "1dcda70c1c25d0e4db6781ba8d2645d7e8966d49" }
zksync_consensus_network = { version = "0.1.0", git = "https://github.com/matter-labs/era-consensus.git", rev = "1dcda70c1c25d0e4db6781ba8d2645d7e8966d49" }
zksync_consensus_roles = { version = "0.1.0", git = "https://github.com/matter-labs/era-consensus.git", rev = "1dcda70c1c25d0e4db6781ba8d2645d7e8966d49" }
zksync_consensus_storage = { version = "0.1.0", git = "https://github.com/matter-labs/era-consensus.git", rev = "1dcda70c1c25d0e4db6781ba8d2645d7e8966d49" }
zksync_consensus_utils = { version = "0.1.0", git = "https://github.com/matter-labs/era-consensus.git", rev = "1dcda70c1c25d0e4db6781ba8d2645d7e8966d49" }
zksync_protobuf = { version = "0.1.0", git = "https://github.com/matter-labs/era-consensus.git", rev = "1dcda70c1c25d0e4db6781ba8d2645d7e8966d49" }
zksync_protobuf_build = { version = "0.1.0", git = "https://github.com/matter-labs/era-consensus.git", rev = "1dcda70c1c25d0e4db6781ba8d2645d7e8966d49" }
zksync_concurrency = { version = "0.1.0", git = "https://github.com/matter-labs/era-consensus.git", rev = "92ecb2d5d65e3bc4a883dacd18d0640e86576c8c" }
zksync_consensus_bft = { version = "0.1.0", git = "https://github.com/matter-labs/era-consensus.git", rev = "92ecb2d5d65e3bc4a883dacd18d0640e86576c8c" }
zksync_consensus_crypto = { version = "0.1.0", git = "https://github.com/matter-labs/era-consensus.git", rev = "92ecb2d5d65e3bc4a883dacd18d0640e86576c8c" }
zksync_consensus_executor = { version = "0.1.0", git = "https://github.com/matter-labs/era-consensus.git", rev = "92ecb2d5d65e3bc4a883dacd18d0640e86576c8c" }
zksync_consensus_network = { version = "0.1.0", git = "https://github.com/matter-labs/era-consensus.git", rev = "92ecb2d5d65e3bc4a883dacd18d0640e86576c8c" }
zksync_consensus_roles = { version = "0.1.0", git = "https://github.com/matter-labs/era-consensus.git", rev = "92ecb2d5d65e3bc4a883dacd18d0640e86576c8c" }
zksync_consensus_storage = { version = "0.1.0", git = "https://github.com/matter-labs/era-consensus.git", rev = "92ecb2d5d65e3bc4a883dacd18d0640e86576c8c" }
zksync_consensus_utils = { version = "0.1.0", git = "https://github.com/matter-labs/era-consensus.git", rev = "92ecb2d5d65e3bc4a883dacd18d0640e86576c8c" }
zksync_protobuf = { version = "0.1.0", git = "https://github.com/matter-labs/era-consensus.git", rev = "92ecb2d5d65e3bc4a883dacd18d0640e86576c8c" }
zksync_protobuf_build = { version = "0.1.0", git = "https://github.com/matter-labs/era-consensus.git", rev = "92ecb2d5d65e3bc4a883dacd18d0640e86576c8c" }

# "Local" dependencies
multivm = { path = "core/lib/multivm" }
Expand Down
3 changes: 0 additions & 3 deletions core/lib/config/src/configs/consensus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,6 @@ pub struct ConsensusConfig {
/// node.
pub public_addr: Host,

/// Validators participating in consensus.
pub validators: BTreeSet<ValidatorPublicKey>,

/// Maximal allowed size of the payload in bytes.
pub max_payload_size: usize,

Expand Down
6 changes: 1 addition & 5 deletions core/lib/config/src/testonly.rs
Original file line number Diff line number Diff line change
Expand Up @@ -698,14 +698,10 @@ impl Distribution<configs::SharedBridge> for EncodeDist {

impl Distribution<configs::consensus::ConsensusConfig> for EncodeDist {
fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> configs::consensus::ConsensusConfig {
use configs::consensus::{ConsensusConfig, Host, NodePublicKey, ValidatorPublicKey};
use configs::consensus::{ConsensusConfig, Host, NodePublicKey};
ConsensusConfig {
server_addr: self.sample(rng),
public_addr: Host(self.sample(rng)),
validators: self
.sample_range(rng)
.map(|_| ValidatorPublicKey(self.sample(rng)))
.collect(),
max_payload_size: self.sample(rng),
gossip_dynamic_inbound_limit: self.sample(rng),
gossip_static_inbound: self
Expand Down
49 changes: 26 additions & 23 deletions core/lib/dal/src/consensus_dal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,12 @@ impl ConsensusDal<'_, '_> {
"#
)
.try_map(|row| {
row.genesis
.map(|genesis| {
zksync_protobuf::serde::deserialize(genesis).decode_column("genesis")
})
.transpose()
let Some(genesis) = row.genesis else {
return Ok(None);
};
let genesis: validator::GenesisRaw =
zksync_protobuf::serde::deserialize(genesis).decode_column("genesis")?;
Ok(Some(genesis.with_hash()))
})
.instrument("genesis")
.fetch_optional(self.storage)
Expand All @@ -57,10 +58,10 @@ impl ConsensusDal<'_, '_> {
return Ok(());
}
anyhow::ensure!(
got.fork.number < genesis.fork.number,
got.fork_number < genesis.fork_number,
"transition to a past fork is not allowed: old = {:?}, new = {:?}",
got.fork.number,
genesis.fork.number,
got.fork_number,
genesis.fork_number,
);
}
let genesis =
Expand Down Expand Up @@ -138,13 +139,16 @@ impl ConsensusDal<'_, '_> {
.await
.context("get_block_range()")?
.end;
let new = validator::Genesis {
validators: old.validators,
fork: validator::Fork {
number: old.fork.number.next(),
first_block,
},
};
let new = validator::GenesisRaw {
chain_id: old.chain_id,
fork_number: old.fork_number.next(),
first_block,

protocol_version: validator::ProtocolVersion::CURRENT,
committee: old.committee.clone(),
leader_selection: old.leader_selection.clone(),
}
.with_hash();
txn.consensus_dal().try_update_genesis(&new).await?;
txn.commit().await?;
Ok(())
Expand Down Expand Up @@ -355,17 +359,16 @@ mod tests {
let mut conn = pool.connection().await.unwrap();
assert_eq!(None, conn.consensus_dal().genesis().await.unwrap());
for n in 0..3 {
let fork = validator::Fork {
number: validator::ForkNumber(n),
first_block: rng.gen(),
};
let setup = validator::testonly::Setup::new_with_fork(rng, 3, fork);
let setup = validator::testonly::Setup::new(rng, 3);
let mut genesis = (*setup.genesis).clone();
genesis.fork_number = validator::ForkNumber(n);
let genesis = genesis.with_hash();
conn.consensus_dal()
.try_update_genesis(&setup.genesis)
.try_update_genesis(&genesis)
.await
.unwrap();
assert_eq!(
setup.genesis,
genesis,
conn.consensus_dal().genesis().await.unwrap().unwrap()
);
assert_eq!(
Expand All @@ -376,7 +379,7 @@ mod tests {
let want: ReplicaState = rng.gen();
conn.consensus_dal().set_replica_state(&want).await.unwrap();
assert_eq!(
setup.genesis,
genesis,
conn.consensus_dal().genesis().await.unwrap().unwrap()
);
assert_eq!(want, conn.consensus_dal().replica_state().await.unwrap());
Expand Down
9 changes: 1 addition & 8 deletions core/lib/protobuf_config/src/consensus.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use anyhow::Context as _;
use zksync_config::configs::consensus::{
ConsensusConfig, ConsensusSecrets, Host, NodePublicKey, NodeSecretKey, ValidatorPublicKey,
ValidatorSecretKey,
ConsensusConfig, ConsensusSecrets, Host, NodePublicKey, NodeSecretKey, ValidatorSecretKey,
};
use zksync_protobuf::{repr::ProtoRepr, required};

Expand All @@ -20,11 +19,6 @@ impl ProtoRepr for proto::Config {
.and_then(|x| Ok(x.parse()?))
.context("server_addr")?,
public_addr: Host(required(&self.public_addr).context("public_addr")?.clone()),
validators: self
.validators
.iter()
.map(|x| ValidatorPublicKey(x.clone()))
.collect(),
max_payload_size: required(&self.max_payload_size)
.and_then(|x| Ok((*x).try_into()?))
.context("max_payload_size")?,
Expand All @@ -49,7 +43,6 @@ impl ProtoRepr for proto::Config {
Self {
server_addr: Some(this.server_addr.to_string()),
public_addr: Some(this.public_addr.0.clone()),
validators: this.validators.iter().map(|x| x.0.clone()).collect(),
max_payload_size: Some(this.max_payload_size.try_into().unwrap()),
gossip_dynamic_inbound_limit: Some(
this.gossip_dynamic_inbound_limit.try_into().unwrap(),
Expand Down
7 changes: 3 additions & 4 deletions core/lib/protobuf_config/src/proto/core/consensus.proto
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ message NodeAddr {
}

message Config {
reserved 3;
reserved "validators";

// IP:port to listen on, for incoming TCP connections.
// Use `0.0.0.0:<port>` to listen on all network interfaces (i.e. on all IPs exposed by this VM).
optional string server_addr = 1; // required; IpAddr
Expand All @@ -44,10 +47,6 @@ message Config {
// Can be `127.0.0.1:<port>` for local tests.
optional string public_addr = 2; // required; Host

// Public keys of all validators.
// Currently it has to be a singleton with a public key corresponding to secret key in CONSENSUS_VALIDATOR_KEY env var.
repeated string validators = 3; // required; ValidatorPublicKey

// Maximal allowed size of the payload.
optional uint64 max_payload_size = 4; // required; bytes

Expand Down
Loading

0 comments on commit ae9ecc2

Please sign in to comment.