Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bump versions #820

Merged
merged 8 commits into from
Dec 22, 2022
Merged
Show file tree
Hide file tree
Changes from 2 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
431 changes: 237 additions & 194 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
12 changes: 6 additions & 6 deletions finality-aleph/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ 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
34 changes: 27 additions & 7 deletions finality-aleph/src/abft/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,39 @@ 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),
})
}

pub fn coord_request_delay_fn() -> DelaySchedule {
Arc::new(|t| match t {
0 => Duration::from_millis(0),
1 => Duration::from_millis(50),
2 => Duration::from_millis(1000),
_ => Duration::from_millis(3000 * (t as u64 - 2)),
})
}

pub fn coord_request_recipients_fn() -> RecipientCountSchedule {
Arc::new(|t| if t <= 2 { 3 } else { 1 })
timorl marked this conversation as resolved.
Show resolved Hide resolved
}

pub struct DelayConfig {
pub tick_interval: Duration,
pub requests_interval: Duration,
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 +99,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
14 changes: 11 additions & 3 deletions finality-aleph/src/abft/current.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::time::Duration;
use std::{sync::Arc, time::Duration};

use current_aleph_bft::{Config, LocalIO, Terminator};
use log::debug;
Expand All @@ -7,7 +7,10 @@ use sp_runtime::traits::Block;

use crate::{
abft::{
common::{unit_creation_delay_fn, AlephConfig, DelayConfig},
common::{
coord_request_delay_fn, coord_request_recipients_fn, unit_creation_delay_fn,
AlephConfig, DelayConfig,
},
NetworkWrapper, SpawnHandleT,
},
crypto::Signature,
Expand Down Expand Up @@ -76,11 +79,16 @@ pub fn create_aleph_config(
unit_creation_delay: UnitCreationDelay,
) -> Config {
let delay_config = DelayConfig {
tick_interval: Duration::from_millis(100),
tick_interval: Duration::from_millis(10),
kostekIV marked this conversation as resolved.
Show resolved Hide resolved
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),
coord_request_delay: coord_request_delay_fn(),
coord_request_recipients: coord_request_recipients_fn(),
parent_request_delay: Arc::new(|_| Duration::from_millis(3000)),
parent_request_recipients: Arc::new(|_| 1),
newest_request_delay: Arc::new(|_| Duration::from_millis(3000)),
};

AlephConfig::new(delay_config, n_members, node_id, session_id).into()
Expand Down
19 changes: 14 additions & 5 deletions finality-aleph/src/abft/legacy.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
use std::time::Duration;
use std::{sync::Arc, time::Duration};

use legacy_aleph_bft::{Config, LocalIO};
use legacy_aleph_bft::{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},
common::{
coord_request_delay_fn, coord_request_recipients_fn, unit_creation_delay_fn,
AlephConfig, DelayConfig,
},
NetworkWrapper, SpawnHandleT,
},
data_io::{AlephData, OrderedDataInterpreter},
Expand Down Expand Up @@ -41,6 +44,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 +57,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 @@ -71,11 +75,16 @@ pub fn create_aleph_config(
unit_creation_delay: UnitCreationDelay,
) -> Config {
let delay_config = DelayConfig {
tick_interval: Duration::from_millis(100),
tick_interval: Duration::from_millis(10),
kostekIV marked this conversation as resolved.
Show resolved Hide resolved
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),
coord_request_delay: coord_request_delay_fn(),
coord_request_recipients: coord_request_recipients_fn(),
parent_request_delay: Arc::new(|_| Duration::from_millis(3000)),
parent_request_recipients: Arc::new(|_| 1),
newest_request_delay: Arc::new(|_| Duration::from_millis(3000)),
};

AlephConfig::new(delay_config, n_members, node_id, session_id).into()
Expand Down
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
6 changes: 3 additions & 3 deletions finality-aleph/src/testing/data_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ async fn correct_messages_go_through() {
.await;

for i in 1..=MAX_DATA_BRANCH_LEN {
let blocks_branch = blocks[0..(i as usize)].to_vec();
let blocks_branch = blocks[0..i].to_vec();
let test_data: TestData = vec![aleph_data_from_blocks(blocks_branch)];
test_handler.send_data(test_data.clone());

Expand All @@ -282,7 +282,7 @@ async fn too_long_branch_message_does_not_go_through() {

test_handler.finalize_block(&blocks[MAX_DATA_BRANCH_LEN + 2].hash());

let blocks_branch = blocks[0..((MAX_DATA_BRANCH_LEN + 1) as usize)].to_vec();
let blocks_branch = blocks[0..(MAX_DATA_BRANCH_LEN + 1)].to_vec();
let test_data: TestData = vec![aleph_data_from_blocks(blocks_branch)];
test_handler.send_data(test_data.clone());
test_handler
Expand Down Expand Up @@ -381,7 +381,7 @@ async fn branch_with_not_finalized_ancestor_correctly_handled() {

fn send_proposals_of_each_len(blocks: Vec<Block>, test_handler: &mut TestHandler) {
for i in 1..=MAX_DATA_BRANCH_LEN {
let blocks_branch = blocks[0..(i as usize)].to_vec();
let blocks_branch = blocks[0..i].to_vec();
let test_data: TestData = vec![aleph_data_from_blocks(blocks_branch)];
test_handler.send_data(test_data.clone());
}
Expand Down
5 changes: 1 addition & 4 deletions pallets/elections/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,10 +275,7 @@ impl TestExtBuilder {
.chain(self.reserved_validators.iter())
.collect();

let balances: Vec<_> = validators
.iter()
.map(|i| (**i as u64, 10_000_000))
.collect();
let balances: Vec<_> = validators.iter().map(|i| (**i, 10_000_000)).collect();

pallet_balances::GenesisConfig::<Test> { balances }
.assimilate_storage(&mut t)
Expand Down