diff --git a/rust/main/chains/hyperlane-sealevel/src/interchain_gas.rs b/rust/main/chains/hyperlane-sealevel/src/interchain_gas.rs index 16e9ea16e..e415e9bc7 100644 --- a/rust/main/chains/hyperlane-sealevel/src/interchain_gas.rs +++ b/rust/main/chains/hyperlane-sealevel/src/interchain_gas.rs @@ -257,7 +257,10 @@ impl Indexer for SealevelInterchainGasPaymasterIndexer { #[instrument(level = "debug", err, ret, skip(self))] #[allow(clippy::blocks_in_conditions)] // TODO: `rustc` 1.80.1 clippy issue async fn get_finalized_block_number(&self) -> ChainResult { - self.rpc_client.get_block_height().await + // we should not report block height since SequenceAwareIndexer uses block slot in + // `latest_sequence_count_and_tip` and we should not report block slot here + // since block slot cannot be used as watermark + unimplemented!() } } @@ -277,7 +280,7 @@ impl SequenceAwareIndexer for SealevelInterchainGasPaymast .payment_count .try_into() .map_err(StrOrIntParseError::from)?; - let tip = self.rpc_client.get_block_height().await?; + let tip = self.igp.provider.rpc().get_slot().await?; Ok((Some(payment_count), tip)) } } diff --git a/rust/main/chains/hyperlane-sealevel/src/mailbox.rs b/rust/main/chains/hyperlane-sealevel/src/mailbox.rs index 7e83b355b..d376801fe 100644 --- a/rust/main/chains/hyperlane-sealevel/src/mailbox.rs +++ b/rust/main/chains/hyperlane-sealevel/src/mailbox.rs @@ -679,10 +679,6 @@ impl SealevelMailboxIndexer { &self.mailbox.rpc() } - async fn get_finalized_block_number(&self) -> ChainResult { - self.rpc().get_block_height().await - } - async fn get_dispatched_message_with_nonce( &self, nonce: u32, @@ -867,17 +863,6 @@ impl SealevelMailboxIndexer { } } -#[async_trait] -impl SequenceAwareIndexer for SealevelMailboxIndexer { - #[instrument(err, skip(self))] - async fn latest_sequence_count_and_tip(&self) -> ChainResult<(Option, u32)> { - let tip = Indexer::::get_finalized_block_number(self).await?; - // TODO: need to make sure the call and tip are at the same height? - let count = Mailbox::count(&self.mailbox, &ReorgPeriod::None).await?; - Ok((Some(count), tip)) - } -} - #[async_trait] impl Indexer for SealevelMailboxIndexer { async fn fetch_logs_in_range( @@ -898,7 +883,21 @@ impl Indexer for SealevelMailboxIndexer { } async fn get_finalized_block_number(&self) -> ChainResult { - self.get_finalized_block_number().await + // we should not report block height since SequenceAwareIndexer uses block slot in + // `latest_sequence_count_and_tip` and we should not report block slot here + // since block slot cannot be used as watermark + unimplemented!() + } +} + +#[async_trait] +impl SequenceAwareIndexer for SealevelMailboxIndexer { + #[instrument(err, skip(self))] + async fn latest_sequence_count_and_tip(&self) -> ChainResult<(Option, u32)> { + let tip = self.mailbox.provider.rpc().get_slot().await?; + // TODO: need to make sure the call and tip are at the same height? + let count = Mailbox::count(&self.mailbox, &ReorgPeriod::None).await?; + Ok((Some(count), tip)) } } @@ -922,7 +921,10 @@ impl Indexer for SealevelMailboxIndexer { } async fn get_finalized_block_number(&self) -> ChainResult { - self.get_finalized_block_number().await + // we should not report block height since SequenceAwareIndexer uses block slot in + // `latest_sequence_count_and_tip` and we should not report block slot here + // since block slot cannot be used as watermark + unimplemented!() } } @@ -931,7 +933,7 @@ impl SequenceAwareIndexer for SealevelMailboxIndexer { async fn latest_sequence_count_and_tip(&self) -> ChainResult<(Option, u32)> { // TODO: implement when sealevel scraper support is implemented info!("Message delivery indexing not implemented"); - let tip = Indexer::::get_finalized_block_number(self).await?; + let tip = self.mailbox.provider.rpc().get_slot().await?; Ok((Some(1), tip)) } } diff --git a/rust/main/chains/hyperlane-sealevel/src/merkle_tree_hook.rs b/rust/main/chains/hyperlane-sealevel/src/merkle_tree_hook.rs index a0813bfba..c2fc81909 100644 --- a/rust/main/chains/hyperlane-sealevel/src/merkle_tree_hook.rs +++ b/rust/main/chains/hyperlane-sealevel/src/merkle_tree_hook.rs @@ -93,7 +93,10 @@ impl Indexer for SealevelMerkleTreeHookIndexer { } async fn get_finalized_block_number(&self) -> ChainResult { - Indexer::::get_finalized_block_number(&self.0).await + // we should not report block height since SequenceAwareIndexer uses block slot in + // `latest_sequence_count_and_tip` and we should not report block slot here + // since block slot cannot be used as watermark + unimplemented!() } } diff --git a/rust/main/chains/hyperlane-sealevel/src/rpc/client.rs b/rust/main/chains/hyperlane-sealevel/src/rpc/client.rs index 9eae0b8ae..6186bf31e 100644 --- a/rust/main/chains/hyperlane-sealevel/src/rpc/client.rs +++ b/rust/main/chains/hyperlane-sealevel/src/rpc/client.rs @@ -125,18 +125,6 @@ impl SealevelRpcClient { .map_err(Into::into) } - pub async fn get_block_height(&self) -> ChainResult { - let height = self - .0 - .get_block_height_with_commitment(CommitmentConfig::finalized()) - .await - .map_err(ChainCommunicationError::from_other)? - .try_into() - // FIXME solana block height is u64... - .expect("sealevel block height exceeds u32::MAX"); - Ok(height) - } - pub async fn get_multiple_accounts_with_finalized_commitment( &self, pubkeys: &[Pubkey], @@ -183,6 +171,18 @@ impl SealevelRpcClient { .map_err(ChainCommunicationError::from_other) } + pub async fn get_slot(&self) -> ChainResult { + let slot = self + .0 + .get_slot_with_commitment(CommitmentConfig::finalized()) + .await + .map_err(ChainCommunicationError::from_other)? + .try_into() + // FIXME solana block height is u64... + .expect("sealevel block slot exceeds u32::MAX"); + Ok(slot) + } + pub async fn get_transaction( &self, signature: &Signature,