From 2b684e86d84c54dd5676c7ee3106ffcae401cf61 Mon Sep 17 00:00:00 2001 From: Danil Nemirovsky <4614623+ameten@users.noreply.github.com> Date: Thu, 16 Jan 2025 14:44:31 +0000 Subject: [PATCH 1/3] Upgrade validator image --- typescript/infra/config/environments/mainnet3/agent.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/typescript/infra/config/environments/mainnet3/agent.ts b/typescript/infra/config/environments/mainnet3/agent.ts index d2bf764c7c..adb5201326 100644 --- a/typescript/infra/config/environments/mainnet3/agent.ts +++ b/typescript/infra/config/environments/mainnet3/agent.ts @@ -662,7 +662,7 @@ const hyperlane: RootAgentConfig = { validators: { docker: { repo, - tag: '53fafa6-20250110-125541', + tag: '11a4e95-20250116-145528', }, rpcConsensusType: RpcConsensusType.Quorum, chains: validatorChainConfig(Contexts.Hyperlane), @@ -700,7 +700,7 @@ const releaseCandidate: RootAgentConfig = { validators: { docker: { repo, - tag: 'a64af8b-20241024-120818', + tag: '11a4e95-20250116-145528', }, rpcConsensusType: RpcConsensusType.Quorum, chains: validatorChainConfig(Contexts.ReleaseCandidate), From 251cf0b7843f2fa87a97828a253822d313b3a4b6 Mon Sep 17 00:00:00 2001 From: Danil Nemirovsky <4614623+ameten@users.noreply.github.com> Date: Thu, 16 Jan 2025 16:29:24 +0000 Subject: [PATCH 2/3] Add chain metrics for cosmos chains --- .../src/providers/cosmos/provider.rs | 40 ++++++++++++------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/rust/main/chains/hyperlane-cosmos/src/providers/cosmos/provider.rs b/rust/main/chains/hyperlane-cosmos/src/providers/cosmos/provider.rs index 2ca98e3fb7..b277fc306c 100644 --- a/rust/main/chains/hyperlane-cosmos/src/providers/cosmos/provider.rs +++ b/rust/main/chains/hyperlane-cosmos/src/providers/cosmos/provider.rs @@ -354,21 +354,8 @@ impl CosmosProvider { Ok(fee / gas_limit) } -} - -impl HyperlaneChain for CosmosProvider { - fn domain(&self) -> &HyperlaneDomain { - &self.domain - } - - fn provider(&self) -> Box { - Box::new(self.clone()) - } -} -#[async_trait] -impl HyperlaneProvider for CosmosProvider { - async fn get_block_by_height(&self, height: u64) -> ChainResult { + async fn block_info_by_height(&self, height: u64) -> ChainResult { let response = self .rpc_client .call(|provider| Box::pin(async move { provider.get_block(height as u32).await })) @@ -392,7 +379,24 @@ impl HyperlaneProvider for CosmosProvider { timestamp: time.unix_timestamp() as u64, number: block_height, }; + Ok(block_info) + } +} + +impl HyperlaneChain for CosmosProvider { + fn domain(&self) -> &HyperlaneDomain { + &self.domain + } + fn provider(&self) -> Box { + Box::new(self.clone()) + } +} + +#[async_trait] +impl HyperlaneProvider for CosmosProvider { + async fn get_block_by_height(&self, height: u64) -> ChainResult { + let block_info = self.block_info_by_height(height).await?; Ok(block_info) } @@ -459,6 +463,12 @@ impl HyperlaneProvider for CosmosProvider { } async fn get_chain_metrics(&self) -> ChainResult> { - Ok(None) + let height = self.grpc_provider.latest_block_height().await?; + let latest_block = self.block_info_by_height(height).await?; + let chain_info = ChainInfo { + latest_block, + min_gas_price: None, + }; + Ok(Some(chain_info)) } } From 610dba0bb53f2382af7adfaf29d6163a9d661e92 Mon Sep 17 00:00:00 2001 From: Danil Nemirovsky <4614623+ameten@users.noreply.github.com> Date: Thu, 16 Jan 2025 16:41:33 +0000 Subject: [PATCH 3/3] Add chain metrics for sealevel chains --- .../chains/hyperlane-sealevel/src/provider.rs | 40 ++++++++++++------- .../hyperlane-sealevel/src/rpc/client.rs | 14 +++++-- 2 files changed, 35 insertions(+), 19 deletions(-) diff --git a/rust/main/chains/hyperlane-sealevel/src/provider.rs b/rust/main/chains/hyperlane-sealevel/src/provider.rs index 7c431558ae..ea970fef67 100644 --- a/rust/main/chains/hyperlane-sealevel/src/provider.rs +++ b/rust/main/chains/hyperlane-sealevel/src/provider.rs @@ -161,6 +161,23 @@ impl SealevelProvider { ))?, }) } + + async fn block_info_by_height(&self, slot: u64) -> Result { + let confirmed_block = self.rpc_client.get_block(slot).await?; + + let block_hash = decode_h256(&confirmed_block.blockhash)?; + + let block_time = confirmed_block + .block_time + .ok_or(HyperlaneProviderError::CouldNotFindBlockByHeight(slot))?; + + let block_info = BlockInfo { + hash: block_hash, + timestamp: block_time as u64, + number: slot, + }; + Ok(block_info) + } } impl HyperlaneChain for SealevelProvider { @@ -180,20 +197,7 @@ impl HyperlaneChain for SealevelProvider { #[async_trait] impl HyperlaneProvider for SealevelProvider { async fn get_block_by_height(&self, slot: u64) -> ChainResult { - let confirmed_block = self.rpc_client.get_block(slot).await?; - - let block_hash = decode_h256(&confirmed_block.blockhash)?; - - let block_time = confirmed_block - .block_time - .ok_or(HyperlaneProviderError::CouldNotFindBlockByHeight(slot))?; - - let block_info = BlockInfo { - hash: block_hash, - timestamp: block_time as u64, - number: slot, - }; - + let block_info = self.block_info_by_height(slot).await?; Ok(block_info) } @@ -260,6 +264,12 @@ impl HyperlaneProvider for SealevelProvider { } async fn get_chain_metrics(&self) -> ChainResult> { - Ok(None) + let slot = self.rpc_client.get_slot_raw().await?; + let latest_block = self.block_info_by_height(slot).await?; + let chain_info = ChainInfo { + latest_block, + min_gas_price: None, + }; + Ok(Some(chain_info)) } } diff --git a/rust/main/chains/hyperlane-sealevel/src/rpc/client.rs b/rust/main/chains/hyperlane-sealevel/src/rpc/client.rs index f9b08170a5..4832fb7ae5 100644 --- a/rust/main/chains/hyperlane-sealevel/src/rpc/client.rs +++ b/rust/main/chains/hyperlane-sealevel/src/rpc/client.rs @@ -10,6 +10,7 @@ use solana_client::{ }, rpc_response::{Response, RpcSimulateTransactionResult}, }; +use solana_program::clock::Slot; use solana_sdk::{ account::Account, commitment_config::CommitmentConfig, @@ -189,16 +190,21 @@ impl SealevelRpcClient { pub async fn get_slot(&self) -> ChainResult { let slot = self - .0 - .get_slot_with_commitment(CommitmentConfig::finalized()) - .await - .map_err(ChainCommunicationError::from_other)? + .get_slot_raw() + .await? .try_into() // FIXME solana block height is u64... .expect("sealevel block slot exceeds u32::MAX"); Ok(slot) } + pub async fn get_slot_raw(&self) -> ChainResult { + self.0 + .get_slot_with_commitment(CommitmentConfig::finalized()) + .await + .map_err(ChainCommunicationError::from_other) + } + pub async fn get_transaction( &self, signature: &Signature,