Skip to content

Commit

Permalink
Merge branch 'main' into A0-4560
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcin-Radecki authored Jan 2, 2025
2 parents e3b8482 + 71f0314 commit 3abe30e
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 25 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/cargo-audit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ jobs:
- name: Checkout source code
uses: actions/checkout@v4

- name: Install cargo audit
shell: bash
run: |
cargo install cargo-audit --locked
- name: Run `cargo-audit`
uses: actions-rs/audit-check@v1
with:
Expand Down
40 changes: 20 additions & 20 deletions Cargo.lock

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

9 changes: 7 additions & 2 deletions consensus/src/dag/reconstruction/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,15 @@ impl<U: Unit> ReconstructedUnit<U> {
== ControlHash::<U::Hasher>::combine_hashes(&parents)
{
true => {
let parents = unit.control_hash().parents_round_lookup.clone();
let unit_round = unit.round();
let mut parents_with_rounds = NodeMap::with_size(parents.size());
for (parent_index, hash) in parents.into_iter() {
// we cannot have here round 0 units
parents_with_rounds.insert(parent_index, (hash, unit_round.saturating_sub(1)));
}
Ok(ReconstructedUnit {
unit,
parents,
parents: parents_with_rounds,
})
}
false => Err(unit),
Expand Down
1 change: 1 addition & 0 deletions consensus/src/extension/election.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ impl<U: UnitWithParents> CandidateElection<U> {
// Otherwise we compute the vote based on the parents' votes.
_ => {
let threshold = voter.node_count().consensus_threshold();
let direct_parents = voter.direct_parents().cloned().collect();
self.vote_from_parents(direct_parents, threshold, relative_round)?
}
};
Expand Down
4 changes: 2 additions & 2 deletions consensus/src/testing/dag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ impl DagFeeder {

fn on_reconstructed_unit(&mut self, unit: ReconstructedUnit) {
let h = unit.hash();
let parents = unit.parents().cloned().collect::<Vec<_>>();
let parents: HashSet<_> = unit.parents().cloned().collect();
let expected_hashes: HashSet<_> = self
.units_map
.get(&h)
Expand All @@ -148,7 +148,7 @@ impl DagFeeder {
.into_iter()
.collect();

assert_eq!(parents.into_iter().collect::<HashSet<_>>(), expected_hashes);
assert_eq!(parents, expected_hashes);
self.result.push(unit.clone());
self.store.insert(unit);
}
Expand Down
2 changes: 1 addition & 1 deletion examples/ordering/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ log = "0.4"
parking_lot = "0.12"
time = { version = "0.3", features = ["formatting", "macros", "local-offset"] }
tokio = { version = "1", features = ["macros", "rt", "rt-multi-thread", "io-util", "net", "time", "fs"] }
tokio-util = { version = "0.7.12", features = ["compat"] }
tokio-util = { version = "0.7.13", features = ["compat"] }

0 comments on commit 3abe30e

Please sign in to comment.