Skip to content

Commit

Permalink
refactor: updated attestation logic to the new algorithm (#2657)
Browse files Browse the repository at this point in the history
The new algorithm
(matter-labs/era-consensus#175)
supports dynamic attestation committee. This pr does NOT implement
committee rotation,
it will be done once the consensus registry contract is merged.

ENs no longer store the certificates.
I've also implemented a test of the attestation logic.
  • Loading branch information
pompon0 authored Aug 16, 2024
1 parent b4ffcd2 commit 8b8397a
Show file tree
Hide file tree
Showing 15 changed files with 810 additions and 612 deletions.
53 changes: 22 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 @@ -221,16 +221,16 @@ zk_evm_1_5_0 = { package = "zk_evm", version = "=0.150.4" }
vm2 = { git = "https://github.com/matter-labs/vm2.git", rev = "9a38900d7af9b1d72b47ce3be980e77c1239a61d" }

# Consensus dependencies.
zksync_concurrency = "=0.1.0-rc.10"
zksync_consensus_bft = "=0.1.0-rc.10"
zksync_consensus_crypto = "=0.1.0-rc.10"
zksync_consensus_executor = "=0.1.0-rc.10"
zksync_consensus_network = "=0.1.0-rc.10"
zksync_consensus_roles = "=0.1.0-rc.10"
zksync_consensus_storage = "=0.1.0-rc.10"
zksync_consensus_utils = "=0.1.0-rc.10"
zksync_protobuf = "=0.1.0-rc.10"
zksync_protobuf_build = "=0.1.0-rc.10"
zksync_concurrency = "=0.1.0-rc.11"
zksync_consensus_bft = "=0.1.0-rc.11"
zksync_consensus_crypto = "=0.1.0-rc.11"
zksync_consensus_executor = "=0.1.0-rc.11"
zksync_consensus_network = "=0.1.0-rc.11"
zksync_consensus_roles = "=0.1.0-rc.11"
zksync_consensus_storage = "=0.1.0-rc.11"
zksync_consensus_utils = "=0.1.0-rc.11"
zksync_protobuf = "=0.1.0-rc.11"
zksync_protobuf_build = "=0.1.0-rc.11"

# "Local" dependencies
zksync_multivm = { version = "0.1.0", path = "core/lib/multivm" }
Expand Down
12 changes: 6 additions & 6 deletions core/lib/dal/src/consensus_dal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ impl ConsensusDal<'_, '_> {

/// Gets a number of the last L1 batch that was inserted. It might have gaps before it,
/// depending on the order in which votes have been collected over gossip by consensus.
pub async fn get_last_batch_certificate_number(
pub async fn last_batch_certificate_number(
&mut self,
) -> anyhow::Result<Option<attester::BatchNumber>> {
let row = sqlx::query!(
Expand All @@ -465,7 +465,7 @@ impl ConsensusDal<'_, '_> {
l1_batches_consensus
"#
)
.instrument("get_last_batch_certificate_number")
.instrument("last_batch_certificate_number")
.report_latency()
.fetch_one(self.storage)
.await?;
Expand All @@ -480,7 +480,7 @@ impl ConsensusDal<'_, '_> {

/// Number of L1 batch that the L2 block belongs to.
/// None if the L2 block doesn't exist.
async fn batch_of_block(
pub async fn batch_of_block(
&mut self,
block: validator::BlockNumber,
) -> anyhow::Result<Option<attester::BatchNumber>> {
Expand Down Expand Up @@ -535,9 +535,9 @@ impl ConsensusDal<'_, '_> {
let Some(next_batch_to_attest) = async {
// First batch that we don't have a certificate for.
if let Some(last) = self
.get_last_batch_certificate_number()
.last_batch_certificate_number()
.await
.context("get_last_batch_certificate_number()")?
.context("last_batch_certificate_number()")?
{
return Ok(Some(last + 1));
}
Expand Down Expand Up @@ -669,7 +669,7 @@ mod tests {
// Retrieve the latest certificate.
let number = conn
.consensus_dal()
.get_last_batch_certificate_number()
.last_batch_certificate_number()
.await
.unwrap()
.unwrap();
Expand Down
Loading

0 comments on commit 8b8397a

Please sign in to comment.