Skip to content
This repository was archived by the owner on Jan 22, 2025. It is now read-only.

Commit 70ad347

Browse files
mergify[bot]behzadnouri
authored andcommitted
v1.18: patches bug in chained Merkle root update (backport of #1689) (#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]>
1 parent f0a4c54 commit 70ad347

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

turbine/src/broadcast_stage/standard_broadcast_run.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -243,20 +243,20 @@ impl StandardBroadcastRun {
243243
return Err(Error::DuplicateSlotBroadcast(bank.slot()));
244244
}
245245
// Reinitialize state for this slot.
246-
let chained_merkle_root = (self.slot == bank.parent_slot())
247-
.then_some(self.chained_merkle_root)
248-
.ok_or_else(|| {
249-
broadcast_utils::get_chained_merkle_root_from_parent(
250-
bank.slot(),
251-
bank.parent_slot(),
252-
blockstore,
253-
)
254-
})
255-
.unwrap_or_else(|err| {
246+
let chained_merkle_root = if self.slot == bank.parent_slot() {
247+
self.chained_merkle_root
248+
} else {
249+
broadcast_utils::get_chained_merkle_root_from_parent(
250+
bank.slot(),
251+
bank.parent_slot(),
252+
blockstore,
253+
)
254+
.unwrap_or_else(|err: Error| {
256255
error!("Unknown chained Merkle root: {err:?}");
257256
process_stats.err_unknown_chained_merkle_root += 1;
258257
Hash::default()
259-
});
258+
})
259+
};
260260
self.slot = bank.slot();
261261
self.parent = bank.parent_slot();
262262
self.chained_merkle_root = chained_merkle_root;

0 commit comments

Comments
 (0)