diff --git a/Cargo.lock b/Cargo.lock index 6d618bf6..bcc08931 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -40,7 +40,7 @@ dependencies = [ [[package]] name = "aleph-bft" -version = "0.29.0" +version = "0.30.0" dependencies = [ "aleph-bft-mock", "aleph-bft-rmc", @@ -134,7 +134,7 @@ dependencies = [ [[package]] name = "aleph-bft-mock" -version = "0.10.0" +version = "0.11.0" dependencies = [ "aleph-bft-types", "async-trait", @@ -163,7 +163,7 @@ dependencies = [ [[package]] name = "aleph-bft-types" -version = "0.9.0" +version = "0.10.0" dependencies = [ "aleph-bft-crypto", "async-trait", diff --git a/README.md b/README.md index 626ea4c5..9a8afcaf 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.29" + aleph-bft = "^0.30" ``` - 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 4772e545..275cb989 100644 --- a/consensus/Cargo.toml +++ b/consensus/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "aleph-bft" -version = "0.29.0" +version = "0.30.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.10" } -aleph-bft-types = { path = "../types", version = "0.9" } +aleph-bft-types = { path = "../types", version = "0.10" } 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 d2aa172f..b19d5def 100644 --- a/consensus/src/runway/mod.rs +++ b/consensus/src/runway/mod.rs @@ -657,18 +657,21 @@ where fn on_ordered_batch(&mut self, batch: Vec) { let data_iter: Vec<_> = batch .iter() - .filter_map(|h| { - self.store + .map(|h| { + let unit = self + .store .unit_by_hash(h) .expect("Ordered units must be in store") - .as_signable() - .data() - .clone() + .as_signable(); + + (unit.data().clone(), unit.creator()) }) .collect(); - for d in data_iter { - self.finalization_handler.data_finalized(d); + for (d, creator) in data_iter { + if let Some(d) = d { + self.finalization_handler.data_finalized(d, creator); + } } } diff --git a/docs/src/aleph_bft_api.md b/docs/src/aleph_bft_api.md index ad8ce235..7cb600c7 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); + fn data_finalized(&mut self, data: Data, creator: NodeIndex); } ``` diff --git a/examples/ordering/src/dataio.rs b/examples/ordering/src/dataio.rs index efd5e3f9..b8cbbe0e 100644 --- a/examples/ordering/src/dataio.rs +++ b/examples/ordering/src/dataio.rs @@ -56,7 +56,7 @@ pub struct FinalizationHandler { } impl FinalizationHandlerT for FinalizationHandler { - fn data_finalized(&mut self, d: Data) { + fn data_finalized(&mut self, d: Data, _creator: NodeIndex) { 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 950e4428..46e10b72 100644 --- a/mock/Cargo.toml +++ b/mock/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "aleph-bft-mock" -version = "0.10.0" +version = "0.11.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.9" } +aleph-bft-types = { path = "../types", version = "0.10" } 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 7828d925..a9db89cc 100644 --- a/mock/src/dataio.rs +++ b/mock/src/dataio.rs @@ -1,4 +1,6 @@ -use aleph_bft_types::{DataProvider as DataProviderT, FinalizationHandler as FinalizationHandlerT}; +use aleph_bft_types::{ + DataProvider as DataProviderT, FinalizationHandler as FinalizationHandlerT, NodeIndex, +}; use async_trait::async_trait; use codec::{Decode, Encode}; use futures::{channel::mpsc::unbounded, future::pending}; @@ -71,7 +73,7 @@ pub struct FinalizationHandler { } impl FinalizationHandlerT for FinalizationHandler { - fn data_finalized(&mut self, d: Data) { + fn data_finalized(&mut self, d: Data, _creator: NodeIndex) { if let Err(e) = self.tx.unbounded_send(d) { error!(target: "finalization-handler", "Error when sending data from FinalizationHandler {:?}.", e); } diff --git a/types/Cargo.toml b/types/Cargo.toml index 3626f4d6..50de6c66 100644 --- a/types/Cargo.toml +++ b/types/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "aleph-bft-types" -version = "0.9.0" +version = "0.10.0" edition = "2021" authors = ["Cardinal Cryptography"] documentation = "https://docs.rs/?" diff --git a/types/src/dataio.rs b/types/src/dataio.rs index 3844f258..ce8a7a51 100644 --- a/types/src/dataio.rs +++ b/types/src/dataio.rs @@ -1,5 +1,7 @@ use async_trait::async_trait; +use crate::NodeIndex; + /// The source of data items that consensus should order. /// /// AlephBFT internally calls [`DataProvider::get_data`] whenever a new unit is created and data needs to be placed inside. @@ -19,5 +21,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); + fn data_finalized(&mut self, data: Data, creator: NodeIndex); }