Skip to content

Commit

Permalink
Revert "A0-3240: Move Terminator to types (#351)"
Browse files Browse the repository at this point in the history
This reverts commit 60900ad.
  • Loading branch information
woocash2 committed Oct 27, 2023
1 parent 8ec90d3 commit 3887f33
Show file tree
Hide file tree
Showing 27 changed files with 31 additions and 59 deletions.
4 changes: 0 additions & 4 deletions Cargo.lock

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

3 changes: 1 addition & 2 deletions consensus/src/alerts/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ use crate::{
handler::{Handler, RmcResponse},
Alert, AlertMessage, ForkingNotification, NetworkMessage,
},
Data, Hasher, MultiKeychain, Multisigned, NodeIndex, Receiver, Recipient, Sender,
Data, Hasher, MultiKeychain, Multisigned, NodeIndex, Receiver, Recipient, Sender, Terminator,
};
use aleph_bft_rmc::{DoublingDelayScheduler, Message as RmcMessage};
use aleph_bft_types::Terminator;
use futures::{FutureExt, StreamExt};
use log::{debug, error, warn};
use std::time::Duration;
Expand Down
7 changes: 2 additions & 5 deletions consensus/src/backup/saver.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
use std::io::Write;

use aleph_bft_types::Terminator;
use crate::{units::UncheckedSignedUnit, Data, Hasher, Receiver, Sender, Signature, Terminator};
use codec::Encode;
use futures::{FutureExt, StreamExt};
use log::{debug, error};

use crate::{units::UncheckedSignedUnit, Data, Hasher, Receiver, Sender, Signature};

const LOG_TARGET: &str = "AlephBFT-backup-saver";

/// Component responsible for saving units into backup.
Expand Down Expand Up @@ -81,12 +79,11 @@ mod tests {
};

use aleph_bft_mock::{Data, Hasher64, Keychain, Saver, Signature};
use aleph_bft_types::Terminator;

use crate::{
backup::BackupSaver,
units::{creator_set, preunit_to_unchecked_signed_unit, UncheckedSignedUnit},
NodeCount, NodeIndex,
NodeCount, NodeIndex, Terminator,
};

type TestBackupSaver = BackupSaver<Hasher64, Data, Signature, Saver>;
Expand Down
4 changes: 2 additions & 2 deletions consensus/src/consensus.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use aleph_bft_types::{handle_task_termination, Terminator};
use futures::{
channel::{mpsc, oneshot},
future::pending,
Expand All @@ -10,9 +9,10 @@ use crate::{
config::Config,
creation,
extender::Extender,
handle_task_termination,
runway::{NotificationIn, NotificationOut},
terminal::Terminal,
Hasher, Receiver, Round, Sender, SpawnHandle,
Hasher, Receiver, Round, Sender, SpawnHandle, Terminator,
};

pub(crate) async fn run<H: Hasher + 'static>(
Expand Down
3 changes: 1 addition & 2 deletions consensus/src/creation/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ use crate::{
config::{Config as GeneralConfig, DelaySchedule},
runway::NotificationOut,
units::{PreUnit, Unit},
Hasher, NodeCount, NodeIndex, Receiver, Round, Sender,
Hasher, NodeCount, NodeIndex, Receiver, Round, Sender, Terminator,
};
use aleph_bft_types::Terminator;
use futures::{
channel::{
mpsc::{SendError, TrySendError},
Expand Down
3 changes: 1 addition & 2 deletions consensus/src/extender.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
use futures::{FutureExt, StreamExt};
use std::collections::{HashMap, VecDeque};

use aleph_bft_types::Terminator;
use log::{debug, warn};

use crate::{Hasher, NodeCount, NodeIndex, NodeMap, Receiver, Round, Sender};
use crate::{Hasher, NodeCount, NodeIndex, NodeMap, Receiver, Round, Sender, Terminator};

pub(crate) struct ExtenderUnit<H: Hasher> {
creator: NodeIndex,
Expand Down
2 changes: 2 additions & 0 deletions consensus/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ mod member;
mod network;
mod runway;
mod terminal;
mod terminator;
mod units;

mod backup;
Expand All @@ -29,6 +30,7 @@ pub use config::{
};
pub use member::{run_session, LocalIO};
pub use network::NetworkData;
pub use terminator::{handle_task_termination, Terminator};

type Receiver<T> = futures::channel::mpsc::UnboundedReceiver<T>;
type Sender<T> = futures::channel::mpsc::UnboundedSender<T>;
5 changes: 3 additions & 2 deletions consensus/src/member.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::{
handle_task_termination,
member::Task::{CoordRequest, ParentsRequest, RequestNewest, UnitBroadcast},
network,
runway::{
Expand All @@ -8,9 +9,9 @@ use crate::{
task_queue::TaskQueue,
units::{UncheckedSignedUnit, UnitCoord},
Config, Data, DataProvider, FinalizationHandler, Hasher, MultiKeychain, Network, NodeIndex,
Receiver, Recipient, Round, Sender, Signature, SpawnHandle, UncheckedSigned,
Receiver, Recipient, Round, Sender, Signature, SpawnHandle, Terminator, UncheckedSigned,
};
use aleph_bft_types::{handle_task_termination, NodeMap, Terminator};
use aleph_bft_types::NodeMap;
use codec::{Decode, Encode};
use futures::{channel::mpsc, pin_mut, FutureExt, StreamExt};
use futures_timer::Delay;
Expand Down
3 changes: 1 addition & 2 deletions consensus/src/network.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
use crate::{
alerts::AlertMessage, member::UnitMessage, Data, Hasher, Network, PartialMultisignature,
Receiver, Recipient, Sender, Signature,
Receiver, Recipient, Sender, Signature, Terminator,
};
use aleph_bft_types::Terminator;
use codec::{Decode, Encode};
use futures::{FutureExt, StreamExt};
use log::{debug, error, warn};
Expand Down
6 changes: 3 additions & 3 deletions consensus/src/runway/mod.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
use crate::{
alerts::{Alert, ForkProof, ForkingNotification, NetworkMessage},
consensus,
consensus, handle_task_termination,
member::UnitMessage,
units::{
ControlHash, PreUnit, SignedUnit, UncheckedSignedUnit, Unit, UnitCoord, UnitStore,
UnitStoreStatus, Validator,
},
Config, Data, DataProvider, FinalizationHandler, Hasher, Index, Keychain, MultiKeychain,
NodeCount, NodeIndex, NodeMap, Receiver, Round, Sender, Signature, Signed, SpawnHandle,
UncheckedSigned,
Terminator, UncheckedSigned,
};
use aleph_bft_types::{handle_task_termination, Recipient, Terminator};
use aleph_bft_types::Recipient;
use futures::{
channel::{mpsc, oneshot},
pin_mut, Future, FutureExt, StreamExt,
Expand Down
6 changes: 3 additions & 3 deletions consensus/src/runway/packer.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use crate::{
units::{FullUnit, PreUnit, SignedUnit},
Data, DataProvider, Hasher, MultiKeychain, NodeIndex, Receiver, Sender, SessionId, Signed,
Terminator,
};
use aleph_bft_types::Terminator;
use futures::{pin_mut, FutureExt, StreamExt};
use log::{debug, error};
use std::marker::PhantomData;
Expand Down Expand Up @@ -100,10 +100,10 @@ mod tests {
use super::Packer;
use crate::{
units::{ControlHash, PreUnit, SignedUnit},
NodeCount, NodeIndex, Receiver, Sender, SessionId,
NodeCount, NodeIndex, Receiver, Sender, SessionId, Terminator,
};
use aleph_bft_mock::{Data, DataProvider, Hasher64, Keychain, StalledDataProvider};
use aleph_bft_types::{NodeMap, Terminator};
use aleph_bft_types::NodeMap;
use futures::{
channel::{mpsc, oneshot},
pin_mut, FutureExt, StreamExt,
Expand Down
3 changes: 1 addition & 2 deletions consensus/src/terminal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@ use crate::{
extender::ExtenderUnit,
runway::{NotificationIn, NotificationOut},
units::{ControlHash, Unit, UnitCoord},
Hasher, NodeCount, NodeIndex, NodeMap, Receiver, Round, Sender,
Hasher, NodeCount, NodeIndex, NodeMap, Receiver, Round, Sender, Terminator,
};
use aleph_bft_types::Terminator;
use codec::{Decode, Encode};
use log::{debug, trace, warn};

Expand Down
3 changes: 1 addition & 2 deletions types/src/terminator.rs → consensus/src/terminator.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use aleph_bft_crypto::NodeIndex;
use futures::{
channel::oneshot::{channel, Receiver, Sender},
future::FusedFuture,
Expand Down Expand Up @@ -171,7 +170,7 @@ pub async fn handle_task_termination<T>(
task_handle: T,
target: &'static str,
name: &'static str,
index: NodeIndex,
index: aleph_bft_types::NodeIndex,
) where
T: FusedFuture<Output = Result<(), ()>>,
{
Expand Down
3 changes: 1 addition & 2 deletions consensus/src/testing/alerts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@ use crate::{
alerts::{Alert, AlertMessage, ForkProof, ForkingNotification, Handler, Service},
units::{ControlHash, FullUnit, PreUnit},
Index, Indexed, Keychain as _, NodeCount, NodeIndex, NodeMap, Recipient, Round, Signable,
Signed, UncheckedSigned,
Signed, Terminator, UncheckedSigned,
};
use aleph_bft_mock::{Data, Hasher64, Keychain, PartialMultisignature, Signature};
use aleph_bft_rmc::Message as RmcMessage;
use aleph_bft_types::Terminator;
use futures::{
channel::{mpsc, oneshot},
FutureExt, StreamExt,
Expand Down
3 changes: 1 addition & 2 deletions consensus/src/testing/consensus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ use crate::{
runway::{NotificationIn, NotificationOut},
testing::{complete_oneshot, gen_config, gen_delay_config, init_log},
units::{ControlHash, PreUnit, Unit, UnitCoord},
Hasher, NodeIndex, SpawnHandle,
Hasher, NodeIndex, SpawnHandle, Terminator,
};
use aleph_bft_mock::{Hasher64, Spawner};
use aleph_bft_types::Terminator;
use codec::Encode;
use futures::{
channel::{
Expand Down
3 changes: 1 addition & 2 deletions consensus/src/testing/creation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ use crate::{
runway::NotificationOut as GenericNotificationOut,
testing::{gen_config, gen_delay_config},
units::{FullUnit as GenericFullUnit, PreUnit as GenericPreUnit, Unit as GenericUnit},
NodeCount, Receiver, Round, Sender,
NodeCount, Receiver, Round, Sender, Terminator,
};
use aleph_bft_mock::{Data, Hasher64};
use aleph_bft_types::Terminator;
use futures::{
channel::{mpsc, oneshot},
FutureExt, StreamExt,
Expand Down
3 changes: 1 addition & 2 deletions consensus/src/testing/dag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ use crate::{
runway::{NotificationIn, NotificationOut},
testing::{complete_oneshot, gen_config, gen_delay_config},
units::{ControlHash, PreUnit, Unit},
NodeCount, NodeIndex, NodeMap, NodeSubset, Receiver, Round, Sender, SpawnHandle,
NodeCount, NodeIndex, NodeMap, NodeSubset, Receiver, Round, Sender, SpawnHandle, Terminator,
};
use aleph_bft_mock::{Hash64, Hasher64, Spawner};
use aleph_bft_types::Terminator;
use futures::{
channel::{mpsc, oneshot},
stream::StreamExt,
Expand Down
3 changes: 1 addition & 2 deletions consensus/src/testing/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,12 @@ mod unreliable;

use crate::{
create_config, run_session, Config, DelayConfig, LocalIO, Network as NetworkT, NodeCount,
NodeIndex, SpawnHandle, TaskHandle,
NodeIndex, SpawnHandle, TaskHandle, Terminator,
};
use aleph_bft_mock::{
Data, DataProvider, FinalizationHandler, Hasher64, Keychain, Loader, Network as MockNetwork,
PartialMultisignature, ReconnectSender as ReconnectSenderGeneric, Saver, Signature, Spawner,
};
use aleph_bft_types::Terminator;
use futures::channel::{mpsc::UnboundedReceiver, oneshot};
use parking_lot::Mutex;
use std::{sync::Arc, time::Duration};
Expand Down
1 change: 0 additions & 1 deletion examples/blockchain/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ publish = false
[dependencies]
aleph-bft = { path = "../../consensus", version = "*" }
aleph-bft-mock = { path = "../../mock", version = "*" }
aleph-bft-types = { path = "../../types", version = "*" }
async-trait = "0.1"
clap = { version = "4", features = ["derive"] }
codec = { package = "parity-scale-codec", version = "3.0", default-features = false, features = ["derive"] }
Expand Down
3 changes: 1 addition & 2 deletions examples/blockchain/src/chain.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use crate::{network::NetworkData, DataStore};
use aleph_bft::NodeIndex;
use aleph_bft_types::Terminator;
use aleph_bft::{NodeIndex, Terminator};
use codec::{Decode, Encode};
use futures::{
channel::mpsc::{UnboundedReceiver, UnboundedSender},
Expand Down
3 changes: 1 addition & 2 deletions examples/blockchain/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@ use futures::{channel::oneshot, StreamExt};
use log::{debug, error, info};
use time::{macros::format_description, OffsetDateTime};

use aleph_bft::{run_session, NodeIndex};
use aleph_bft::{run_session, NodeIndex, Terminator};
use aleph_bft_mock::{FinalizationHandler, Keychain, Loader, Saver, Spawner};
use aleph_bft_types::Terminator;
use chain::{run_blockchain, Block, BlockNum, ChainConfig};
use data::{Data, DataProvider, DataStore};
use network::{Address, NetworkData, NetworkManager};
Expand Down
3 changes: 1 addition & 2 deletions examples/blockchain/src/network.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use crate::{Block, Data};
use aleph_bft::{NodeIndex, Recipient};
use aleph_bft::{NodeIndex, Recipient, Terminator};
use aleph_bft_mock::{Hasher64, PartialMultisignature, Signature};
use aleph_bft_types::Terminator;
use codec::{Decode, Encode};
use futures::{
channel::mpsc::{self, UnboundedReceiver, UnboundedSender},
Expand Down
3 changes: 1 addition & 2 deletions examples/ordering/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
mod dataio;
mod network;

use aleph_bft::{run_session, NodeIndex};
use aleph_bft::{run_session, NodeIndex, Terminator};
use aleph_bft_mock::{Keychain, Spawner};
use aleph_bft_types::Terminator;
use clap::Parser;
use dataio::{Data, DataProvider, FinalizationHandler};
use futures::{channel::oneshot, StreamExt};
Expand Down
1 change: 0 additions & 1 deletion fuzz/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ cargo-fuzz = true
[dependencies]
aleph-bft = { path = "../consensus", version = "*" }
aleph-bft-mock = { path = "../mock", version = "*" }
aleph-bft-types = { path = "../types", version = "*" }
async-trait = "0.1"
codec = { package = "parity-scale-codec", version = "3.0", default-features = false, features = ["derive", "std"] }
env_logger = "0.10"
Expand Down
3 changes: 1 addition & 2 deletions fuzz/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
use aleph_bft::{
create_config, run_session, Config, DelayConfig, LocalIO, Network as NetworkT, NetworkData,
NodeCount, NodeIndex, Recipient, SpawnHandle, TaskHandle,
NodeCount, NodeIndex, Recipient, SpawnHandle, TaskHandle, Terminator,
};
use aleph_bft_mock::{
Data, DataProvider, FinalizationHandler, Hasher64, Keychain, Loader, NetworkHook,
PartialMultisignature, Router, Saver, Signature,
};
use aleph_bft_types::Terminator;
use codec::{Decode, Encode, IoReader};
use futures::{
channel::{oneshot, oneshot::Receiver},
Expand Down
4 changes: 0 additions & 4 deletions types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,3 @@ aleph-bft-crypto = { path = "../crypto", version = "0.8" }
async-trait = "0.1"
codec = { package = "parity-scale-codec", version = "3.0", default-features = false, features = ["derive"] }
futures = "0.3"
log = "0.4"

[dev-dependencies]
tokio = { version = "1", features = ["macros", "rt", "rt-multi-thread", "time"] }
2 changes: 0 additions & 2 deletions types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
mod dataio;
mod network;
mod tasks;
mod terminator;

pub use aleph_bft_crypto::{
IncompleteMultisignatureError, Index, Indexed, Keychain, MultiKeychain, Multisigned, NodeCount,
Expand All @@ -13,7 +12,6 @@ pub use aleph_bft_crypto::{
pub use dataio::{DataProvider, FinalizationHandler};
pub use network::{Network, Recipient};
pub use tasks::{SpawnHandle, TaskHandle};
pub use terminator::{handle_task_termination, Terminator};

use codec::Codec;
use std::{fmt::Debug, hash::Hash as StdHash};
Expand Down

0 comments on commit 3887f33

Please sign in to comment.