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

A0-3185: split rmc #347

Merged
merged 38 commits into from
Oct 13, 2023
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
898de5d
in progress
woocash2 Sep 11, 2023
01d7d35
Revert "in progress"
woocash2 Sep 13, 2023
abc28bf
actual split of rmc to service / handler
woocash2 Sep 26, 2023
1b430cb
adjust of tests
woocash2 Sep 27, 2023
38dff1f
rewrite tests for rmc
woocash2 Sep 29, 2023
94a2977
simplify arguments to alerter::Service::new
woocash2 Sep 29, 2023
5eef5d9
rebase
woocash2 Oct 2, 2023
66d02f6
dependency bump
woocash2 Oct 2, 2023
a176d70
consensus version bump
woocash2 Oct 2, 2023
1dd0155
resolve problems
woocash2 Oct 2, 2023
ac632f4
fmt
woocash2 Oct 4, 2023
5808247
resolve questions
woocash2 Oct 4, 2023
fd24117
add LOG_TARGET
woocash2 Oct 4, 2023
48569bf
simplify handler
woocash2 Oct 6, 2023
d55db7e
add RmcIO
woocash2 Oct 6, 2023
38be508
resolve cloning and log msgs
woocash2 Oct 6, 2023
a5936a5
version bump in crypto (new pub method in Indexed<>)
woocash2 Oct 6, 2023
28be885
and update dependencies
woocash2 Oct 6, 2023
ce76da1
nicer exit in test
woocash2 Oct 9, 2023
e1c2db6
dont fail in test network when rmc becomes unavailable
woocash2 Oct 9, 2023
4e59c65
fmt
woocash2 Oct 9, 2023
4787278
fix rmc terminator exit
woocash2 Oct 9, 2023
dbec451
rmc service not as a separate task
woocash2 Oct 10, 2023
65d3fb4
ultra simplify rmc
woocash2 Oct 10, 2023
c252f91
adjust docstrings and rewrite rmc tests
woocash2 Oct 11, 2023
128c403
enable logger back
woocash2 Oct 11, 2023
ac72062
fix rmc test
woocash2 Oct 11, 2023
16b27bc
simplify rmc tests
woocash2 Oct 11, 2023
96cc56f
resolve issues
woocash2 Oct 11, 2023
3410d79
fmtgit add rmc/
woocash2 Oct 11, 2023
f7abda0
rename RmcMessage to Message
woocash2 Oct 11, 2023
2ab3bf8
better return from start_rmc
woocash2 Oct 11, 2023
5c72baa
use aliases for rmc::Message as RmcMessage
woocash2 Oct 11, 2023
31d039d
Revert "better return from start_rmc"
woocash2 Oct 11, 2023
a96de17
change hash -> message in comment
woocash2 Oct 11, 2023
c776985
rmc handler unit tests
woocash2 Oct 12, 2023
66159d7
exceed -> reach
woocash2 Oct 13, 2023
970150f
clone fix
woocash2 Oct 13, 2023
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
5 changes: 3 additions & 2 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ More details are available [in the book][reference-link-implementation-details].
- Import AlephBFT in your crate
```toml
[dependencies]
aleph-bft = "^0.30"
aleph-bft = "^0.31"
```
- The main entry point is the `run_session` function, which returns a Future that runs the
consensus algorithm.
Expand Down
4 changes: 2 additions & 2 deletions consensus/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "aleph-bft"
version = "0.30.0"
version = "0.31.0"
edition = "2021"
authors = ["Cardinal Cryptography"]
categories = ["algorithms", "data-structures", "cryptography", "database"]
Expand All @@ -13,7 +13,7 @@ readme = "../README.md"
description = "AlephBFT is an asynchronous and Byzantine fault tolerant consensus protocol aimed at ordering arbitrary messages (transactions). It has been designed to continuously operate even in the harshest conditions: with no bounds on message-delivery delays and in the presence of malicious actors. This makes it an excellent fit for blockchain-related applications."

[dependencies]
aleph-bft-rmc = { path = "../rmc", version = "0.10" }
aleph-bft-rmc = { path = "../rmc", version = "0.11" }
aleph-bft-types = { path = "../types", version = "0.10" }
anyhow = "1.0"
async-trait = "0.1"
Expand Down
18 changes: 9 additions & 9 deletions consensus/src/alerts/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::{
Data, Hasher, Keychain, MultiKeychain, Multisigned, NodeIndex, PartialMultisignature,
Recipient, SessionId, Signature, Signed, UncheckedSigned,
};
use aleph_bft_rmc::Message as RmcMessage;
use aleph_bft_rmc::RmcHash;
use aleph_bft_types::Round;
use codec::{Decode, Encode};
use std::{
Expand Down Expand Up @@ -66,7 +66,7 @@ type OnAlertRequestResponse<H, D, MK> = (

#[derive(Clone, Eq, PartialEq, Hash, Debug, Decode, Encode)]
pub enum RmcResponse<H: Hasher, S: Signature, MS: PartialMultisignature> {
RmcMessage(RmcMessage<H::Hash, S, MS>),
RmcMessage(RmcHash<H::Hash, S, MS>),
AlertRequest(H::Hash, Recipient),
Noop,
}
Expand Down Expand Up @@ -223,7 +223,7 @@ impl<H: Hasher, D: Data, MK: MultiKeychain> Handler<H, D, MK> {
pub fn on_rmc_message(
&self,
sender: NodeIndex,
message: RmcMessage<H::Hash, MK::Signature, MK::PartialMultisignature>,
message: RmcHash<H::Hash, MK::Signature, MK::PartialMultisignature>,
) -> RmcResponse<H, MK::Signature, MK::PartialMultisignature> {
let hash = message.hash();
if let Some(alert) = self.known_alerts.get(hash) {
Expand Down Expand Up @@ -279,12 +279,13 @@ mod tests {
use crate::{
alerts::{
handler::{Error, Handler, RmcResponse},
Alert, AlertMessage, ForkProof, ForkingNotification, RmcMessage,
Alert, AlertMessage, ForkProof, ForkingNotification,
},
units::{ControlHash, FullUnit, PreUnit},
PartiallyMultisigned, Recipient, Round,
};
use aleph_bft_mock::{Data, Hasher64, Keychain, Signature};
use aleph_bft_rmc::RmcHash;
use aleph_bft_types::{NodeCount, NodeIndex, NodeMap, Signable, Signed};

type TestForkProof = ForkProof<Hasher64, Data, Signature>;
Expand Down Expand Up @@ -375,8 +376,7 @@ mod tests {
let alert_hash = Signable::hash(&alert);
let signed_alert_hash =
Signed::sign_with_index(alert_hash, &alerter_keychain).into_unchecked();
let response =
this.on_rmc_message(alerter_index, RmcMessage::SignedHash(signed_alert_hash));
let response = this.on_rmc_message(alerter_index, RmcHash::SignedHash(signed_alert_hash));
assert_eq!(
response,
RmcResponse::AlertRequest(alert_hash, Recipient::Node(alerter_index),),
Expand Down Expand Up @@ -460,7 +460,7 @@ mod tests {
empty_alert_hash,
)),
);
let message = RmcMessage::MultisignedHash(multisigned_empty_alert_hash.into_unchecked());
let message = RmcHash::MultisignedHash(multisigned_empty_alert_hash.into_unchecked());
assert_eq!(
this.on_rmc_message(other_honest_node, message.clone()),
RmcResponse::RmcMessage(message),
Expand Down Expand Up @@ -489,7 +489,7 @@ mod tests {
&keychains[double_committer.0],
);
}
let message = RmcMessage::MultisignedHash(multisigned_nonempty_alert_hash.into_unchecked());
let message = RmcHash::MultisignedHash(multisigned_nonempty_alert_hash.into_unchecked());
assert_eq!(
this.on_network_alert(signed_nonempty_alert),
Err(Error::RepeatedAlert(double_committer, forker_index)),
Expand Down Expand Up @@ -547,7 +547,7 @@ mod tests {
&keychains[double_committer.0],
);
}
let message = RmcMessage::MultisignedHash(multisigned_nonempty_alert_hash.into_unchecked());
let message = RmcHash::MultisignedHash(multisigned_nonempty_alert_hash.into_unchecked());
assert_eq!(
this.on_network_alert(signed_nonempty_alert),
Err(Error::RepeatedAlert(double_committer, forker_index)),
Expand Down
8 changes: 4 additions & 4 deletions consensus/src/alerts/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::{
units::UncheckedSignedUnit, Data, Hasher, Index, Keychain, MultiKeychain, Multisigned,
NodeIndex, PartialMultisignature, Signable, Signature, UncheckedSigned,
};
use aleph_bft_rmc::Message as RmcMessage;
use aleph_bft_rmc::RmcHash;
use codec::{Decode, Encode};
use derivative::Derivative;
use parking_lot::RwLock;
Expand All @@ -12,7 +12,7 @@ mod handler;
mod service;

pub use handler::Handler;
pub use service::Service;
pub use service::{Service, IO};

pub type ForkProof<H, D, S> = (UncheckedSignedUnit<H, D, S>, UncheckedSignedUnit<H, D, S>);

Expand Down Expand Up @@ -106,7 +106,7 @@ pub enum AlertMessage<H: Hasher, D: Data, S: Signature, MS: PartialMultisignatur
/// Alert regarding forks, signed by the person claiming misconduct.
ForkAlert(UncheckedSigned<Alert<H, D, S>, S>),
/// An internal RMC message, together with the id of the sender.
RmcMessage(NodeIndex, RmcMessage<H::Hash, S, MS>),
RmcHash(NodeIndex, RmcHash<H::Hash, S, MS>),
/// A request by a node for a fork alert identified by the given hash.
AlertRequest(NodeIndex, H::Hash),
}
Expand All @@ -115,7 +115,7 @@ impl<H: Hasher, D: Data, S: Signature, MS: PartialMultisignature> AlertMessage<H
pub fn included_data(&self) -> Vec<D> {
match self {
Self::ForkAlert(unchecked_alert) => unchecked_alert.as_signable().included_data(),
Self::RmcMessage(_, _) => Vec::new(),
Self::RmcHash(_, _) => Vec::new(),
Self::AlertRequest(_, _) => Vec::new(),
}
}
Expand Down
Loading
Loading