Skip to content

Commit

Permalink
A0-3461: Update ABFT and remove legacy data IO (#1692)
Browse files Browse the repository at this point in the history
# Description

Updates AlephBFT, letting us get rid of the ugly `data_io::legacy` hack.
Note that this updates `aleph_bft_crypto` which, in principle could be a
compatibility issue. Fortunately, the change from 0.8 to 0.9 is only in
some minor interfaces, the internal representation and, more
importantly, encoding of all the types remains unchanged.

## Type of change

- ABFT update

# Checklist:
  • Loading branch information
timorleph authored Apr 22, 2024
1 parent 4e89d71 commit 2a630c2
Show file tree
Hide file tree
Showing 23 changed files with 153 additions and 2,368 deletions.
83 changes: 42 additions & 41 deletions Cargo.lock

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

8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ homepage = "https://alephzero.org"
repository = "https://github.com/Cardinal-Cryptography/aleph-node"

[workspace.dependencies]
aleph-bft-crypto = { version = "0.8" }
aleph-bft-mock = { version = "0.11.1" }
aleph-bft-rmc = { version = "0.11" }
aleph-bft-types = { version = "0.11" }
aleph-bft-crypto = { version = "0.9" }
aleph-bft-mock = { version = "0.14" }
aleph-bft-rmc = { version = "0.13" }
aleph-bft-types = { version = "0.13" }
async-trait = { version = "0.1" }
bytes = { version = "1.6" }
derive_more = { version = "0.99" }
Expand Down
2 changes: 1 addition & 1 deletion aggregator/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "aggregator"
version = "0.6.0"
version = "0.7.0"
license = "Apache 2.0"
authors.workspace = true
edition.workspace = true
Expand Down
10 changes: 5 additions & 5 deletions finality-aleph/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ repository.workspace = true
# fixed version to 'freeze' some types used in abft, mainly `SignatureSet` used in justification and signature aggregation
aleph-bft-crypto = { workspace = true }

current-aleph-bft = { package = "aleph-bft", version = "0.33" }
current-aleph-bft-rmc = { package = "aleph-bft-rmc", version = "0.11" }
legacy-aleph-bft = { package = "aleph-bft", version = "0.20" }
legacy-aleph-bft-rmc = { package = "aleph-bft-rmc", version = "0.6" }
current-aleph-bft = { package = "aleph-bft", version = "0.36" }
current-aleph-bft-rmc = { package = "aleph-bft-rmc", version = "0.13" }
legacy-aleph-bft = { package = "aleph-bft", version = "0.33" }
legacy-aleph-bft-rmc = { package = "aleph-bft-rmc", version = "0.11" }

network-clique = { workspace = true }
primitives = { workspace = true }
legacy-aleph-aggregator = { package = "aggregator", git = "https://github.com/Cardinal-Cryptography/aleph-node.git", tag = "r-12.1" }
legacy-aleph-aggregator = { package = "aggregator", git = "https://github.com/Cardinal-Cryptography/aleph-node.git", tag = "r-13.3" }
current-aleph-aggregator = { path = "../aggregator", package = "aggregator" }
rate-limiter = { package = "rate-limiter", path = "../rate-limiter" }

Expand Down
28 changes: 0 additions & 28 deletions finality-aleph/src/abft/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,31 +35,3 @@ pub fn unit_creation_delay_fn(unit_creation_delay: UnitCreationDelay) -> DelaySc

// 7 days (as milliseconds)
pub const SESSION_LEN_LOWER_BOUND_MS: u128 = 1000 * 60 * 60 * 24 * 7;

pub fn sanity_check_round_delays(max_rounds: u16, round_delays: DelaySchedule) {
let delays_ok = sanity_check_round_delays_inner(max_rounds, round_delays);
assert!(
delays_ok,
"Incorrect setting of delays. Make sure the total AlephBFT session time is at least {SESSION_LEN_LOWER_BOUND_MS}ms."
);
}

fn sanity_check_round_delays_inner(max_rounds: u16, round_delays: DelaySchedule) -> bool {
let mut total_delay = Duration::from_millis(0);
for t in 0..=max_rounds {
total_delay += round_delays(t as usize);
}
total_delay.as_millis() > SESSION_LEN_LOWER_BOUND_MS
}

#[test]
fn sanity_check_fails_on_bad_config() {
let round_delays = unit_creation_delay_fn(UnitCreationDelay(300));
assert!(!sanity_check_round_delays_inner(5000, round_delays));
}

#[test]
fn sanity_check_passes_on_good_config() {
let round_delays = unit_creation_delay_fn(UnitCreationDelay(300));
assert!(sanity_check_round_delays_inner(7000, round_delays));
}
4 changes: 1 addition & 3 deletions finality-aleph/src/abft/crypto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ impl legacy_aleph_bft::Index for Keychain {
}
}

#[async_trait::async_trait]
impl current_aleph_bft::Keychain for Keychain {
type Signature = Signature;

Expand All @@ -77,15 +76,14 @@ impl current_aleph_bft::Keychain for Keychain {
}
}

#[async_trait::async_trait]
impl legacy_aleph_bft::Keychain for Keychain {
type Signature = Signature;

fn node_count(&self) -> legacy_aleph_bft::NodeCount {
Keychain::node_count(self).into()
}

async fn sign(&self, msg: &[u8]) -> Signature {
fn sign(&self, msg: &[u8]) -> Signature {
Keychain::sign(self, msg)
}

Expand Down
6 changes: 1 addition & 5 deletions finality-aleph/src/abft/current/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,7 @@ where
H: Header,
V: HeaderVerifier<H>,
{
fn data_finalized(
&mut self,
data: AlephData<H::Unverified>,
_creator: current_aleph_bft::NodeIndex,
) {
fn data_finalized(&mut self, data: AlephData<H::Unverified>) {
OrderedDataInterpreter::data_finalized(self, data)
}
}
Loading

0 comments on commit 2a630c2

Please sign in to comment.