-
Notifications
You must be signed in to change notification settings - Fork 403
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix lag issue with Mailbox message sequence_and_tip (#2879)
### Description The old implementation of the `sequence_and_tip` fn in mailbox.rs used to look like this, where it'd end up passing the tip as the lag! ``` let sequence = match NonZeroU64::new(tip as u64) { None => None, Some(n) => Some(self.nonce(Some(n)).await?), }; ``` Shuffled things around where we correctly just specify the `tip` as the block number instead of a lag. This means that all functions that were calling `wasm_query` with the lag needed to start getting the lagged block num instead Sometimes I believe this would create a bug where we'd ask for a block height 1 and get back RPC errors. I believe most of the time we'd ask for a block height of 0, in which case it'd just act like we were asking for the tip ### Drive-by changes n/a ### Related issues n/a ### Backward compatibility n/a ### Testing plan to roll it out once I get an image
- Loading branch information
Showing
5 changed files
with
71 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
use std::num::NonZeroU64; | ||
|
||
use crate::grpc::{WasmGrpcProvider, WasmProvider}; | ||
use hyperlane_core::ChainResult; | ||
|
||
/// Given a lag, returns the block height at the moment. | ||
/// If the lag is None, a block height of None is given, indicating that the | ||
/// tip directly can be used. | ||
pub(crate) async fn get_block_height_for_lag( | ||
provider: &WasmGrpcProvider, | ||
lag: Option<NonZeroU64>, | ||
) -> ChainResult<Option<u64>> { | ||
let block_height = match lag { | ||
Some(lag) => { | ||
let tip = provider.latest_block_height().await?; | ||
let block_height = tip - lag.get(); | ||
Some(block_height) | ||
} | ||
None => None, | ||
}; | ||
|
||
Ok(block_height) | ||
} |