From 574aa05df79ba0c11a15325bd9dd0337369f8b0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=BAc=C3=A1s=20Meier?= Date: Mon, 10 Jun 2024 13:32:52 -0700 Subject: [PATCH] View Service: Don't sync the same block twice (#4578) This should fix an issue wherein a load balanced RPC can cause data corruption by delivering the same block twice in the stream. ## Issue ticket number and link This should close #4577. ## Checklist before requesting a review - [x] If this code contains consensus-breaking changes, I have added the "consensus-breaking" label. Otherwise, I declare my belief that there are not consensus-breaking changes, for the following reason: > Just a client change (cherry picked from commit 4245ebcb8def4930ea3875af4f119489efe4cce2) --- crates/view/src/worker.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/crates/view/src/worker.rs b/crates/view/src/worker.rs index 996a6405c9..56bab3e862 100644 --- a/crates/view/src/worker.rs +++ b/crates/view/src/worker.rs @@ -231,10 +231,17 @@ impl Worker { } }); + let mut expected_height = start_height; + while let Some(block) = buffered_stream.recv().await { let block: CompactBlock = block?.try_into()?; let height = block.height; + if height != expected_height { + tracing::warn!("out of order block detected"); + continue; + } + expected_height += 1; // Lock the SCT only while processing this block. let mut sct_guard = self.sct.write().await;