avoiding back in time travel

Signed-off-by: Uncle Stinky <uncle.stinky@ghostchain.io>
This commit is contained in:
Uncle Stinky 2025-07-31 15:30:28 +03:00
parent b969081cbf
commit 1c4c517728
Signed by: st1nky
GPG Key ID: 016064BD97603B40
2 changed files with 14 additions and 17 deletions

View File

@ -1,6 +1,6 @@
[package] [package]
name = "ghost-slow-clap" name = "ghost-slow-clap"
version = "0.3.38" version = "0.3.39"
description = "Applause protocol for the EVM bridge" description = "Applause protocol for the EVM bridge"
license.workspace = true license.workspace = true
authors.workspace = true authors.workspace = true

View File

@ -763,23 +763,20 @@ impl<T: Config> Pallet<T> {
Ok(match maybe_block_range { Ok(match maybe_block_range {
Some((from_block, to_block)) => match maybe_new_evm_block { Some((from_block, to_block)) => match maybe_new_evm_block {
Some(_) => { Some(_) if from_block.le(&to_block) => {
match estimated_block.checked_sub(from_block) { let adjusted_to_block = estimated_block
Some(current_distance) .checked_sub(from_block)
if current_distance .map(|current_distance| current_distance
< max_block_distance => .le(&max_block_distance)
{ .then(|| estimated_block)
(from_block, estimated_block) )
} .flatten()
_ => ( .unwrap_or(from_block
from_block, .saturating_add(max_block_distance)
from_block .min(estimated_block));
.saturating_add(max_block_distance) (from_block, adjusted_to_block)
.min(estimated_block),
),
}
} }
None => (to_block, to_block), _ => (to_block, to_block),
}, },
None => (estimated_block, estimated_block), None => (estimated_block, estimated_block),
}) })