From 5267b5b4a24a4d757a842ab44e263ae9e8745c90 Mon Sep 17 00:00:00 2001 From: joschisan <122358257+joschisan@users.noreply.github.com> Date: Sat, 25 Nov 2023 10:48:26 +0100 Subject: [PATCH] return the round of a unit with the unit data when the unit is finalized --- README.md | 2 +- consensus/Cargo.toml | 4 ++-- consensus/src/runway/mod.rs | 6 +++--- docs/src/aleph_bft_api.md | 2 +- examples/ordering/src/dataio.rs | 4 ++-- mock/Cargo.toml | 4 ++-- mock/src/dataio.rs | 4 ++-- rmc/Cargo.toml | 2 +- types/Cargo.toml | 2 +- types/src/dataio.rs | 3 ++- 10 files changed, 17 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 6ff99334..177e9bac 100644 --- a/README.md +++ b/README.md @@ -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.33" + aleph-bft = "^0.34" ``` - The main entry point is the `run_session` function, which returns a Future that runs the consensus algorithm. diff --git a/consensus/Cargo.toml b/consensus/Cargo.toml index f84a56f9..0382f9fe 100644 --- a/consensus/Cargo.toml +++ b/consensus/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "aleph-bft" -version = "0.33.0" +version = "0.34.0" edition = "2021" authors = ["Cardinal Cryptography"] categories = ["algorithms", "data-structures", "cryptography", "database"] @@ -14,7 +14,7 @@ description = "AlephBFT is an asynchronous and Byzantine fault tolerant consensu [dependencies] aleph-bft-rmc = { path = "../rmc", version = "0.11" } -aleph-bft-types = { path = "../types", version = "0.11" } +aleph-bft-types = { path = "../types", version = "0.12" } anyhow = "1.0" async-trait = "0.1" codec = { package = "parity-scale-codec", version = "3.0", default-features = false, features = ["derive"] } diff --git a/consensus/src/runway/mod.rs b/consensus/src/runway/mod.rs index 19eed02d..b6527b94 100644 --- a/consensus/src/runway/mod.rs +++ b/consensus/src/runway/mod.rs @@ -664,13 +664,13 @@ where .expect("Ordered units must be in store") .as_signable(); - (unit.data().clone(), unit.creator()) + (unit.data().clone(), unit.creator(), unit.round()) }) .collect(); - for (d, creator) in data_iter { + for (d, creator, round) in data_iter { if let Some(d) = d { - self.finalization_handler.data_finalized(d, creator); + self.finalization_handler.data_finalized(d, creator, round); } } } diff --git a/docs/src/aleph_bft_api.md b/docs/src/aleph_bft_api.md index 7cb600c7..c40b7d76 100644 --- a/docs/src/aleph_bft_api.md +++ b/docs/src/aleph_bft_api.md @@ -18,7 +18,7 @@ The FinalizationHandler trait is an abstraction for a component that should hand ```rust pub trait FinalizationHandler { - fn data_finalized(&mut self, data: Data, creator: NodeIndex); + fn data_finalized(&mut self, data: Data, creator: NodeIndex, round: Round); } ``` diff --git a/examples/ordering/src/dataio.rs b/examples/ordering/src/dataio.rs index b8cbbe0e..db48a019 100644 --- a/examples/ordering/src/dataio.rs +++ b/examples/ordering/src/dataio.rs @@ -1,5 +1,5 @@ use aleph_bft_types::{ - DataProvider as DataProviderT, FinalizationHandler as FinalizationHandlerT, NodeIndex, + DataProvider as DataProviderT, FinalizationHandler as FinalizationHandlerT, NodeIndex, Round, }; use async_trait::async_trait; use codec::{Decode, Encode}; @@ -56,7 +56,7 @@ pub struct FinalizationHandler { } impl FinalizationHandlerT for FinalizationHandler { - fn data_finalized(&mut self, d: Data, _creator: NodeIndex) { + fn data_finalized(&mut self, d: Data, _creator: NodeIndex, _round: Round) { if let Err(e) = self.tx.unbounded_send(d) { error!(target: "finalization-handler", "Error when sending data from FinalizationHandler {:?}.", e); } diff --git a/mock/Cargo.toml b/mock/Cargo.toml index 73a2a367..07cec124 100644 --- a/mock/Cargo.toml +++ b/mock/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "aleph-bft-mock" -version = "0.11.1" +version = "0.12.0" edition = "2021" authors = ["Cardinal Cryptography"] documentation = "https://docs.rs/?" @@ -11,7 +11,7 @@ readme = "./README.md" description = "Mock implementations of traits required by the aleph-bft package. Do NOT use outside of testing!" [dependencies] -aleph-bft-types = { path = "../types", version = "0.11" } +aleph-bft-types = { path = "../types", version = "0.12" } async-trait = "0.1" codec = { package = "parity-scale-codec", version = "3.0", default-features = false, features = ["derive"] } futures = "0.3" diff --git a/mock/src/dataio.rs b/mock/src/dataio.rs index a9db89cc..92ccae44 100644 --- a/mock/src/dataio.rs +++ b/mock/src/dataio.rs @@ -1,5 +1,5 @@ use aleph_bft_types::{ - DataProvider as DataProviderT, FinalizationHandler as FinalizationHandlerT, NodeIndex, + DataProvider as DataProviderT, FinalizationHandler as FinalizationHandlerT, NodeIndex, Round, }; use async_trait::async_trait; use codec::{Decode, Encode}; @@ -73,7 +73,7 @@ pub struct FinalizationHandler { } impl FinalizationHandlerT for FinalizationHandler { - fn data_finalized(&mut self, d: Data, _creator: NodeIndex) { + fn data_finalized(&mut self, d: Data, _creator: NodeIndex, _round: Round) { if let Err(e) = self.tx.unbounded_send(d) { error!(target: "finalization-handler", "Error when sending data from FinalizationHandler {:?}.", e); } diff --git a/rmc/Cargo.toml b/rmc/Cargo.toml index 70361d2a..c3c7d1d0 100644 --- a/rmc/Cargo.toml +++ b/rmc/Cargo.toml @@ -14,7 +14,7 @@ description = "Reliable MultiCast - a primitive for Reliable Broadcast protocol. [dependencies] aleph-bft-crypto = { path = "../crypto", version = "0.8" } -aleph-bft-types = { path = "../types", version = "0.11" } +aleph-bft-types = { path = "../types", version = "0.12" } async-trait = "0.1" codec = { package = "parity-scale-codec", version = "3.0", default-features = false, features = ["derive"] } futures = "0.3" diff --git a/types/Cargo.toml b/types/Cargo.toml index d0ec7e3b..560f5877 100644 --- a/types/Cargo.toml +++ b/types/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "aleph-bft-types" -version = "0.11.0" +version = "0.12.0" edition = "2021" authors = ["Cardinal Cryptography"] documentation = "https://docs.rs/?" diff --git a/types/src/dataio.rs b/types/src/dataio.rs index ce8a7a51..d1d6c21c 100644 --- a/types/src/dataio.rs +++ b/types/src/dataio.rs @@ -1,6 +1,7 @@ use async_trait::async_trait; use crate::NodeIndex; +use crate::Round; /// The source of data items that consensus should order. /// @@ -21,5 +22,5 @@ pub trait DataProvider: Sync + Send + 'static { pub trait FinalizationHandler: Sync + Send + 'static { /// Data, provided by [DataProvider::get_data], has been finalized. /// The calls to this function follow the order of finalization. - fn data_finalized(&mut self, data: Data, creator: NodeIndex); + fn data_finalized(&mut self, data: Data, creator: NodeIndex, round: Round); }