From bd151124554d182a225b738065eb2eaa93786ae1 Mon Sep 17 00:00:00 2001 From: Gabriel de Quadros Ligneul <8294320+gligneul@users.noreply.github.com> Date: Tue, 21 Nov 2023 15:19:56 -0300 Subject: [PATCH] fix(claimer): previous too high error This condition will happen when the checker reads blocks faster than they are produced, so it shouldn't be considered an error. Instead, the code just skips the update. --- offchain/authority-claimer/src/checker.rs | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/offchain/authority-claimer/src/checker.rs b/offchain/authority-claimer/src/checker.rs index fc622bcb0..34235ea30 100644 --- a/offchain/authority-claimer/src/checker.rs +++ b/offchain/authority-claimer/src/checker.rs @@ -67,13 +67,6 @@ pub enum DuplicateCheckerError { latest ))] DepthTooHigh { depth: u64, latest: u64 }, - - #[snafu(display( - "Previous block `{}` higher than latest block `{}`", - previous, - latest - ))] - PreviousTooHigh { previous: u64, latest: u64 }, } impl DefaultDuplicateChecker { @@ -140,13 +133,14 @@ impl DefaultDuplicateChecker { ensure!(depth <= latest, DepthTooHighSnafu { depth, latest }); let latest = latest - depth; - ensure!( - self.next_block_to_read <= latest, - PreviousTooHighSnafu { - previous: self.next_block_to_read, + if latest < self.next_block_to_read { + trace!( + "nothing to read; next block is {}, but current block is {}", + self.next_block_to_read, latest - } - ); + ); + return Ok(()); + } let dapp_address = H160(self.dapp_address.inner().to_owned()); let topic = ValueOrArray::Value(Some(dapp_address.into()));