Skip to content

Commit

Permalink
v1.18: patches bug in chained Merkle root update (backport of #1689) (#…
Browse files Browse the repository at this point in the history
…1692)

patches bug in chained Merkle root update (#1689)

Option::ok_or_else always maps None to Err which is not what was intended in
this code.

(cherry picked from commit e804bcc)

Co-authored-by: behzad nouri <[email protected]>
  • Loading branch information
mergify[bot] and behzadnouri authored Jun 11, 2024
1 parent b4a4aa5 commit cb502b4
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions turbine/src/broadcast_stage/standard_broadcast_run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,20 +243,20 @@ impl StandardBroadcastRun {
return Err(Error::DuplicateSlotBroadcast(bank.slot()));
}
// Reinitialize state for this slot.
let chained_merkle_root = (self.slot == bank.parent_slot())
.then_some(self.chained_merkle_root)
.ok_or_else(|| {
broadcast_utils::get_chained_merkle_root_from_parent(
bank.slot(),
bank.parent_slot(),
blockstore,
)
})
.unwrap_or_else(|err| {
let chained_merkle_root = if self.slot == bank.parent_slot() {
self.chained_merkle_root
} else {
broadcast_utils::get_chained_merkle_root_from_parent(
bank.slot(),
bank.parent_slot(),
blockstore,
)
.unwrap_or_else(|err: Error| {
error!("Unknown chained Merkle root: {err:?}");
process_stats.err_unknown_chained_merkle_root += 1;
Hash::default()
});
})
};
self.slot = bank.slot();
self.parent = bank.parent_slot();
self.chained_merkle_root = chained_merkle_root;
Expand Down

0 comments on commit cb502b4

Please sign in to comment.