Skip to content

Commit 2e9f283

Browse files
committed
New ABFT version
1 parent 18179fc commit 2e9f283

File tree

15 files changed

+606
-116
lines changed

15 files changed

+606
-116
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@ homepage = "https://alephzero.org"
4545
repository = "https://github.com/Cardinal-Cryptography/aleph-node"
4646

4747
[workspace.dependencies]
48-
aleph-bft-crypto = { version = "0.9" }
49-
aleph-bft-mock = { version = "0.15" }
50-
aleph-bft-rmc = { version = "0.14" }
51-
aleph-bft-types = { version = "0.14" }
48+
aleph-bft-crypto = { version = "0.10" }
49+
aleph-bft-mock = { version = "0.17" }
50+
aleph-bft-rmc = { version = "0.15" }
51+
aleph-bft-types = { version = "0.15" }
5252
async-trait = { version = "0.1" }
5353
array-bytes = { version = "6" }
5454
bytes = { version = "1.8" }

finality-aleph/Cargo.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ repository.workspace = true
1111
# fixed version to 'freeze' some types used in abft, mainly `SignatureSet` used in justification and signature aggregation
1212
aleph-bft-crypto = { workspace = true }
1313

14-
current-aleph-bft = { package = "aleph-bft", version = "0.42" }
15-
current-aleph-bft-rmc = { package = "aleph-bft-rmc", version = "0.14" }
16-
legacy-aleph-bft = { package = "aleph-bft", version = "0.36" }
17-
legacy-aleph-bft-rmc = { package = "aleph-bft-rmc", version = "0.13" }
14+
current-aleph-bft = { package = "aleph-bft", version = "0.44" }
15+
current-aleph-bft-rmc = { package = "aleph-bft-rmc", version = "0.15" }
16+
legacy-aleph-bft = { package = "aleph-bft", version = "0.42" }
17+
legacy-aleph-bft-rmc = { package = "aleph-bft-rmc", version = "0.14" }
1818

1919
network-clique = { workspace = true }
2020
primitives = { workspace = true }
21-
legacy-aleph-aggregator = { package = "aggregator", git = "https://github.com/Cardinal-Cryptography/aleph-node.git", tag = "r-14.0.0" }
21+
legacy-aleph-aggregator = { package = "aggregator", git = "https://github.com/Cardinal-Cryptography/aleph-node.git", tag = "r-15.2.0" }
2222
current-aleph-aggregator = { path = "../aggregator", package = "aggregator" }
2323
rate-limiter = { package = "rate-limiter", path = "../rate-limiter" }
2424
fake-runtime-api = { workspace = true, features = ["std"] }

finality-aleph/src/abft/crypto.rs

Lines changed: 46 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,18 @@ impl Keychain {
4848
}
4949
}
5050

51-
// Currently the traits for legacy and current match, so only one implementation needed.
5251
impl legacy_aleph_bft::Index for Keychain {
5352
fn index(&self) -> legacy_aleph_bft::NodeIndex {
5453
Keychain::index(self).into()
5554
}
5655
}
5756

58-
// Currently the traits for legacy and current match, so only one implementation needed.
57+
impl current_aleph_bft::Index for Keychain {
58+
fn index(&self) -> current_aleph_bft::NodeIndex {
59+
Keychain::index(self).into()
60+
}
61+
}
62+
5963
impl legacy_aleph_bft::Keychain for Keychain {
6064
type Signature = Signature;
6165

@@ -72,7 +76,22 @@ impl legacy_aleph_bft::Keychain for Keychain {
7276
}
7377
}
7478

75-
// Currently the traits for legacy and current match, so only one implementation needed.
79+
impl current_aleph_bft::Keychain for Keychain {
80+
type Signature = Signature;
81+
82+
fn node_count(&self) -> current_aleph_bft::NodeCount {
83+
Keychain::node_count(self).into()
84+
}
85+
86+
fn sign(&self, msg: &[u8]) -> Signature {
87+
Keychain::sign(self, msg)
88+
}
89+
90+
fn verify(&self, msg: &[u8], sgn: &Signature, index: current_aleph_bft::NodeIndex) -> bool {
91+
Keychain::verify(self, msg, sgn, index)
92+
}
93+
}
94+
7695
impl legacy_aleph_bft::MultiKeychain for Keychain {
7796
// Using `SignatureSet` is slow, but Substrate has not yet implemented aggregation.
7897
// We probably should do this for them at some point.
@@ -96,3 +115,27 @@ impl legacy_aleph_bft::MultiKeychain for Keychain {
96115
Keychain::is_complete(self, msg, partial)
97116
}
98117
}
118+
119+
impl current_aleph_bft::MultiKeychain for Keychain {
120+
// Using `SignatureSet` is slow, but Substrate has not yet implemented aggregation.
121+
// We probably should do this for them at some point.
122+
type PartialMultisignature = SignatureSet<Signature>;
123+
124+
fn bootstrap_multi(
125+
&self,
126+
signature: &Signature,
127+
index: current_aleph_bft::NodeIndex,
128+
) -> Self::PartialMultisignature {
129+
current_aleph_bft::PartialMultisignature::add_signature(
130+
SignatureSet(aleph_bft_crypto::SignatureSet::with_size(
131+
aleph_bft_crypto::Keychain::node_count(self),
132+
)),
133+
signature,
134+
index,
135+
)
136+
}
137+
138+
fn is_complete(&self, msg: &[u8], partial: &Self::PartialMultisignature) -> bool {
139+
Keychain::is_complete(self, msg, partial)
140+
}
141+
}

0 commit comments

Comments
 (0)