From 46a4814c175e05d96c687674e148e385842812f5 Mon Sep 17 00:00:00 2001 From: Boyu Yang Date: Fri, 5 Apr 2024 15:06:33 +0800 Subject: [PATCH] fix: failed to reorg when only one stale block --- src/components/spv_service.rs | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/components/spv_service.rs b/src/components/spv_service.rs index ed962fb..b848ce7 100644 --- a/src/components/spv_service.rs +++ b/src/components/spv_service.rs @@ -113,12 +113,20 @@ impl SpvService { let packed_spv_header_root = spv_header_root.pack(); if packed_stg_header_root.as_slice() == packed_spv_header_root.as_slice() { - let input = SpvReorgInput { - info, - curr: cell.clone(), - stale, - }; - return Ok(input); + if stale.len() > 1 { + let input = SpvReorgInput { + info, + curr: cell.clone(), + stale, + }; + return Ok(input); + } else { + log::warn!( + "[TODO::KnownIssue] this is a dirty patch to fix an issue in the contract: \ + update and reorg only 1 block are indistinguishable, \ + let's just reorg 1 more client" + ); + } } log::trace!("[onchain] header#{spv_height}; mmr-root {spv_header_root}");