Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
437 changes: 240 additions & 197 deletions Cargo.lock

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions aggregator/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
[package]
name = "aggregator"
version = "0.2.0"
version = "0.3.0"
authors = ["Cardinal Cryptography"]
edition = "2021"
license = "Apache 2.0"


[dependencies]
aleph-bft-rmc = "0.5.0"
aleph-bft-types = "0.6.0"
aleph-bft-rmc = "0.6"
aleph-bft-types = "0.8"

async-trait = "0.1"
futures = "0.3"
Expand Down
14 changes: 7 additions & 7 deletions finality-aleph/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
[package]
name = "finality-aleph"
version = "0.5.4"
version = "0.6.0"
authors = ["Cardinal Cryptography"]
edition = "2021"
license = "Apache 2.0"

[dependencies]
# fixed version to 'freeze' some types used in abft, mainly `SignatureSet` used in justification and signature aggregation
aleph-bft-crypto = "0.4.0"
aleph-bft-crypto = "0.5"

current-aleph-bft = { package = "aleph-bft", version = "0.19.1" }
current-aleph-bft-rmc = { package = "aleph-bft-rmc", version = "0.5.0" }
legacy-aleph-bft = { package = "aleph-bft", version = "0.18.1" }
legacy-aleph-bft-rmc = { package = "aleph-bft-rmc", version = "0.4.0" }
current-aleph-bft = { package = "aleph-bft", version = "0.20" }
current-aleph-bft-rmc = { package = "aleph-bft-rmc", version = "0.6" }
legacy-aleph-bft = { package = "aleph-bft", version = "0.19" }
legacy-aleph-bft-rmc = { package = "aleph-bft-rmc", version = "0.5" }

aleph-primitives = { package = "primitives", path = "../primitives" }
legacy-aleph-aggregator = { package = "aggregator", git = "https://github.com/Cardinal-Cryptography/aleph-node.git", tag = "aggregator-v0.1.0" }
legacy-aleph-aggregator = { package = "aggregator", git = "https://github.com/Cardinal-Cryptography/aleph-node.git", tag = "aggregator-v0.2.1" }
current-aleph-aggregator = { path = "../aggregator", package = "aggregator" }

async-trait = "0.1"
Expand Down
21 changes: 14 additions & 7 deletions finality-aleph/src/abft/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,12 @@ fn exponential_slowdown(
}

pub type DelaySchedule = Arc<dyn Fn(usize) -> Duration + Sync + Send + 'static>;
pub type RecipientCountSchedule = Arc<dyn Fn(usize) -> usize + Sync + Send + 'static>;

pub fn unit_creation_delay_fn(unit_creation_delay: UnitCreationDelay) -> DelaySchedule {
Arc::new(move |t| {
if t == 0 {
Duration::from_millis(2000)
} else {
exponential_slowdown(t, unit_creation_delay.0 as f64, 5000, 1.005)
}
Arc::new(move |t| match t {
0 => Duration::from_millis(2000),
_ => exponential_slowdown(t, unit_creation_delay.0 as f64, 5000, 1.005),
})
}

Expand All @@ -42,6 +40,11 @@ pub struct DelayConfig {
pub unit_rebroadcast_interval_min: Duration,
pub unit_rebroadcast_interval_max: Duration,
pub unit_creation_delay: DelaySchedule,
pub coord_request_delay: DelaySchedule,
pub coord_request_recipients: RecipientCountSchedule,
pub parent_request_delay: DelaySchedule,
pub parent_request_recipients: RecipientCountSchedule,
pub newest_request_delay: DelaySchedule,
}

pub struct AlephConfig {
Expand Down Expand Up @@ -83,10 +86,14 @@ impl From<DelayConfig> for current_aleph_bft::DelayConfig {
fn from(cfg: DelayConfig) -> Self {
Self {
tick_interval: cfg.tick_interval,
requests_interval: cfg.requests_interval,
unit_rebroadcast_interval_max: cfg.unit_rebroadcast_interval_max,
unit_rebroadcast_interval_min: cfg.unit_rebroadcast_interval_min,
unit_creation_delay: cfg.unit_creation_delay,
coord_request_delay: cfg.coord_request_delay,
coord_request_recipients: cfg.coord_request_recipients,
parent_request_delay: cfg.parent_request_delay,
parent_request_recipients: cfg.parent_request_recipients,
newest_request_delay: cfg.newest_request_delay,
}
}
}
Expand Down
22 changes: 6 additions & 16 deletions finality-aleph/src/abft/current.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
use std::time::Duration;

use current_aleph_bft::{Config, LocalIO, Terminator};
use current_aleph_bft::{default_config, Config, LocalIO, Terminator};
use log::debug;
use sp_blockchain::HeaderBackend;
use sp_runtime::traits::Block;

use crate::{
abft::{
common::{unit_creation_delay_fn, AlephConfig, DelayConfig},
NetworkWrapper, SpawnHandleT,
},
abft::{common::unit_creation_delay_fn, NetworkWrapper, SpawnHandleT},
crypto::Signature,
data_io::{AlephData, OrderedDataInterpreter},
network::data::Network,
Expand All @@ -22,7 +17,7 @@ use crate::{
};

/// Version of the current abft
pub const VERSION: u32 = 1;
pub const VERSION: u32 = 2;

pub fn run_member<
B: Block,
Expand Down Expand Up @@ -75,13 +70,8 @@ pub fn create_aleph_config(
session_id: SessionId,
unit_creation_delay: UnitCreationDelay,
) -> Config {
let delay_config = DelayConfig {
tick_interval: Duration::from_millis(100),
requests_interval: Duration::from_millis(3000),
unit_rebroadcast_interval_min: Duration::from_millis(15000),
unit_rebroadcast_interval_max: Duration::from_millis(20000),
unit_creation_delay: unit_creation_delay_fn(unit_creation_delay),
};
let mut config = default_config(n_members.into(), node_id.into(), session_id.0 as u64);
config.delay_config.unit_creation_delay = unit_creation_delay_fn(unit_creation_delay);

AlephConfig::new(delay_config, n_members, node_id, session_id).into()
config
}
26 changes: 9 additions & 17 deletions finality-aleph/src/abft/legacy.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
use std::time::Duration;

use legacy_aleph_bft::{Config, LocalIO};
use legacy_aleph_bft::{default_config, Config, LocalIO, Terminator};
use log::debug;
use sp_blockchain::HeaderBackend;
use sp_runtime::traits::Block;

use super::common::unit_creation_delay_fn;
use crate::{
abft::{
common::{unit_creation_delay_fn, AlephConfig, DelayConfig},
NetworkWrapper, SpawnHandleT,
},
abft::{NetworkWrapper, SpawnHandleT},
data_io::{AlephData, OrderedDataInterpreter},
network::data::Network,
oneshot,
Expand All @@ -21,7 +17,7 @@ use crate::{
};

/// Version of the legacy abft
pub const VERSION: u32 = 0;
pub const VERSION: u32 = 1;

pub fn run_member<
B: Block,
Expand All @@ -41,6 +37,7 @@ pub fn run_member<
session_id,
} = subtask_common;
let (stop, exit) = oneshot::channel();
let member_terminator = Terminator::create_root(exit, "member");
let local_io = LocalIO::new(data_provider, ordered_data_interpreter, backup.0, backup.1);

let task = {
Expand All @@ -53,7 +50,7 @@ pub fn run_member<
network,
multikeychain,
spawn_handle,
exit,
member_terminator,
)
.await;
debug!(target: "aleph-party", "Member task stopped for {:?}", session_id);
Expand All @@ -70,13 +67,8 @@ pub fn create_aleph_config(
session_id: SessionId,
unit_creation_delay: UnitCreationDelay,
) -> Config {
let delay_config = DelayConfig {
tick_interval: Duration::from_millis(100),
requests_interval: Duration::from_millis(3000),
unit_rebroadcast_interval_min: Duration::from_millis(15000),
unit_rebroadcast_interval_max: Duration::from_millis(20000),
unit_creation_delay: unit_creation_delay_fn(unit_creation_delay),
};
let mut config = default_config(n_members.into(), node_id.into(), session_id.0 as u64);
config.delay_config.unit_creation_delay = unit_creation_delay_fn(unit_creation_delay);

AlephConfig::new(delay_config, n_members, node_id, session_id).into()
config
}
2 changes: 1 addition & 1 deletion finality-aleph/src/aggregation/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ where
fn send(
&self,
data: D,
recipient: legacy_aleph_bft::Recipient,
recipient: current_aleph_bft::Recipient,
) -> Result<(), CurrentNetworkError> {
self.0.send(data, recipient.into()).map_err(|e| match e {
SendError::SendFailed => CurrentNetworkError::SendFail,
Expand Down
2 changes: 1 addition & 1 deletion pallets/aleph/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ use sp_std::prelude::*;
/// The current storage version.
const STORAGE_VERSION: StorageVersion = StorageVersion::new(2);

const DEFAULT_FINALITY_VERSION: Version = 0;
const DEFAULT_FINALITY_VERSION: Version = 2;

#[frame_support::pallet]
pub mod pallet {
Expand Down