From cb502b45a92feb0fede0c667bd7c1fd6cb985bbf Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Tue, 11 Jun 2024 18:32:04 +0000 Subject: [PATCH] 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 e804bcce291e517442515f12e2b47298e8b6f4c1) Co-authored-by: behzad nouri --- .../broadcast_stage/standard_broadcast_run.rs | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/turbine/src/broadcast_stage/standard_broadcast_run.rs b/turbine/src/broadcast_stage/standard_broadcast_run.rs index 262ef946ea83a2..ee6c9abbd7ebdb 100644 --- a/turbine/src/broadcast_stage/standard_broadcast_run.rs +++ b/turbine/src/broadcast_stage/standard_broadcast_run.rs @@ -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;