Skip to content

Commit

Permalink
Do not save parents after all
Browse files Browse the repository at this point in the history
In particular this means that this doesn't change the API, so only patch
version bump needed.
  • Loading branch information
timorleph committed Apr 10, 2024
1 parent 0930a7d commit bfa85f9
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 30 deletions.
2 changes: 1 addition & 1 deletion 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.37"
aleph-bft = "^0.36"
```
- The main entry point is the `run_session` function, which returns a Future that runs the
consensus algorithm.
Expand Down
2 changes: 1 addition & 1 deletion consensus/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "aleph-bft"
version = "0.37.0"
version = "0.36.4"
edition = "2021"
authors = ["Cardinal Cryptography"]
categories = ["algorithms", "data-structures", "cryptography", "database"]
Expand Down
23 changes: 6 additions & 17 deletions consensus/src/backup/loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use log::{error, info, warn};

use crate::{
units::{UncheckedSignedUnit, Unit, UnitCoord},
Data, Hasher, NodeIndex, NodeMap, Round, SessionId, Signature,
Data, Hasher, NodeIndex, Round, SessionId, Signature,
};

const LOG_TARGET: &str = "AlephBFT-backup-loader";
Expand Down Expand Up @@ -91,8 +91,7 @@ impl<H: Hasher, D: Data, S: Signature, R: AsyncRead> BackupLoader<H, D, S, R> {
let input = &mut &buf[..];
let mut result = Vec::new();
while !input.is_empty() {
// TODO(A0-4234): We should use the parents information to respond to reconstruction failures.
result.push(<(UncheckedSignedUnit<H, D, S>, NodeMap<H::Hash>)>::decode(input)?.0);
result.push(<UncheckedSignedUnit<H, D, S>>::decode(input)?);
}
Ok(result)
}
Expand Down Expand Up @@ -242,15 +241,15 @@ mod tests {
use codec::Encode;
use futures::channel::oneshot;

use aleph_bft_mock::{Data, Hash64, Hasher64, Keychain, Loader, Signature};
use aleph_bft_mock::{Data, Hasher64, Keychain, Loader, Signature};

use crate::{
backup::BackupLoader,
units::{
create_preunits, creator_set, preunit_to_full_unit, preunit_to_unchecked_signed_unit,
UncheckedSignedUnit as GenericUncheckedSignedUnit, Unit,
UncheckedSignedUnit as GenericUncheckedSignedUnit,
},
NodeCount, NodeIndex, NodeMap, Round, SessionId,
NodeCount, NodeIndex, Round, SessionId,
};

type UncheckedSignedUnit = GenericUncheckedSignedUnit<Hasher64, Data, Signature>;
Expand Down Expand Up @@ -309,17 +308,7 @@ mod tests {
}

fn encode_all(items: Vec<UncheckedSignedUnit>) -> Vec<Vec<u8>> {
items
.iter()
.map(|u| {
(
u,
// for now encode empty parents as we ignore them anyway
NodeMap::<Hash64>::with_size(u.as_signable().control_hash().n_members()),
)
.encode()
})
.collect()
items.iter().map(|u| u.encode()).collect()
}

fn prepare_test(encoded_items: Vec<u8>) -> PrepareTestResponse<impl futures::Future> {
Expand Down
3 changes: 1 addition & 2 deletions consensus/src/backup/saver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,8 @@ impl<H: Hasher, D: Data, MK: MultiKeychain, W: AsyncWrite> BackupSaver<H, D, MK,
}

pub async fn save_unit(&mut self, unit: &DagUnit<H, D, MK>) -> Result<(), std::io::Error> {
let parents = unit.parents().clone();
let unit: UncheckedSignedUnit<_, _, _> = unit.clone().unpack().into();
self.backup.write_all(&(unit, parents).encode()).await?;
self.backup.write_all(&unit.encode()).await?;
self.backup.flush().await
}

Expand Down
11 changes: 3 additions & 8 deletions consensus/src/testing/crash_recovery.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use crate::{
testing::{init_log, spawn_honest_member, HonestMember, Network, ReconnectSender},
units::{UncheckedSignedUnit, Unit, UnitCoord},
NodeCount, NodeIndex, NodeMap, SpawnHandle, TaskHandle,
NodeCount, NodeIndex, SpawnHandle, TaskHandle,
};
use aleph_bft_mock::{Data, Hash64, Hasher64, Router, Signature, Spawner};
use aleph_bft_mock::{Data, Hasher64, Router, Signature, Spawner};
use codec::Decode;
use futures::{
channel::{mpsc, oneshot},
Expand Down Expand Up @@ -129,12 +129,7 @@ fn verify_backup(buf: &mut &[u8]) -> HashSet<UnitCoord> {
let mut already_saved = HashSet::new();

while !buf.is_empty() {
let unit = <(
UncheckedSignedUnit<Hasher64, Data, Signature>,
NodeMap<Hash64>,
)>::decode(buf)
.unwrap()
.0;
let unit = <UncheckedSignedUnit<Hasher64, Data, Signature>>::decode(buf).unwrap();
let full_unit = unit.as_signable();
let coord = full_unit.coord();
let parent_ids = &full_unit.as_pre_unit().control_hash().parents_mask;
Expand Down

0 comments on commit bfa85f9

Please sign in to comment.