Skip to content

Commit

Permalink
Merge branch 'hyperlane-xyz:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
mshojaei-txfusion authored Jan 21, 2025
2 parents ae3acc4 + 62702d3 commit 19a4cc2
Show file tree
Hide file tree
Showing 35 changed files with 585 additions and 96 deletions.
5 changes: 5 additions & 0 deletions .changeset/proud-waves-camp.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@hyperlane-xyz/cli': minor
---

Fix issue where warp deploy artifacts did not include correct symbols.
5 changes: 5 additions & 0 deletions .changeset/quick-walls-deny.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@hyperlane-xyz/sdk': minor
---

Deploy to trumpchain.
2 changes: 1 addition & 1 deletion .registryrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0797d4ddc91b48b62b1b7c9b64a638ad03c71212
9e900994370ccc702b84c332eb4a0479bfeabe07
8 changes: 4 additions & 4 deletions rust/main/agents/relayer/src/merkle_tree/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ impl MerkleTreeProcessor {
// Update the metrics
// we assume that leaves are inserted in order so this will be monotonically increasing
self.metrics
.latest_leaf_index_gauge
.latest_tree_insertion_index_gauge
.set(insertion.index() as i64);
Some(insertion)
} else {
Expand All @@ -89,14 +89,14 @@ impl MerkleTreeProcessor {

#[derive(Debug)]
pub struct MerkleTreeProcessorMetrics {
latest_leaf_index_gauge: IntGauge,
latest_tree_insertion_index_gauge: IntGauge,
}

impl MerkleTreeProcessorMetrics {
pub fn new(metrics: &CoreMetrics, origin: &HyperlaneDomain) -> Self {
Self {
latest_leaf_index_gauge: metrics
.latest_leaf_index()
latest_tree_insertion_index_gauge: metrics
.latest_tree_insertion_index()
.with_label_values(&[origin.name()]),
}
}
Expand Down
6 changes: 0 additions & 6 deletions rust/main/agents/relayer/src/msg/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,12 +282,6 @@ impl ProcessorExt for MessageProcessor {
return Ok(());
}

// Skip if the message is intended for this origin
if destination == self.domain().id() {
debug!(?msg, "Message destined for self, skipping");
return Ok(());
}

// Skip if the message is intended for a destination we do not service
if !self.send_channels.contains_key(&destination) {
debug!(?msg, "Message destined for unknown domain, skipping");
Expand Down
1 change: 0 additions & 1 deletion rust/main/agents/relayer/src/relayer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,6 @@ impl Relayer {
let destination_ctxs: HashMap<_, _> = self
.destination_chains
.keys()
.filter(|&destination| destination != origin)
.map(|destination| {
(
destination.id(),
Expand Down
40 changes: 25 additions & 15 deletions rust/main/chains/hyperlane-cosmos/src/providers/cosmos/provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -354,21 +354,8 @@ impl CosmosProvider {

Ok(fee / gas_limit)
}
}

impl HyperlaneChain for CosmosProvider {
fn domain(&self) -> &HyperlaneDomain {
&self.domain
}

fn provider(&self) -> Box<dyn HyperlaneProvider> {
Box::new(self.clone())
}
}

#[async_trait]
impl HyperlaneProvider for CosmosProvider {
async fn get_block_by_height(&self, height: u64) -> ChainResult<BlockInfo> {
async fn block_info_by_height(&self, height: u64) -> ChainResult<BlockInfo> {
let response = self
.rpc_client
.call(|provider| Box::pin(async move { provider.get_block(height as u32).await }))
Expand All @@ -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<dyn HyperlaneProvider> {
Box::new(self.clone())
}
}

#[async_trait]
impl HyperlaneProvider for CosmosProvider {
async fn get_block_by_height(&self, height: u64) -> ChainResult<BlockInfo> {
let block_info = self.block_info_by_height(height).await?;
Ok(block_info)
}

Expand Down Expand Up @@ -459,6 +463,12 @@ impl HyperlaneProvider for CosmosProvider {
}

async fn get_chain_metrics(&self) -> ChainResult<Option<ChainInfo>> {
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))
}
}
40 changes: 25 additions & 15 deletions rust/main/chains/hyperlane-sealevel/src/provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,23 @@ impl SealevelProvider {
))?,
})
}

async fn block_info_by_height(&self, slot: u64) -> Result<BlockInfo, ChainCommunicationError> {
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 {
Expand All @@ -180,20 +197,7 @@ impl HyperlaneChain for SealevelProvider {
#[async_trait]
impl HyperlaneProvider for SealevelProvider {
async fn get_block_by_height(&self, slot: u64) -> ChainResult<BlockInfo> {
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)
}

Expand Down Expand Up @@ -260,6 +264,12 @@ impl HyperlaneProvider for SealevelProvider {
}

async fn get_chain_metrics(&self) -> ChainResult<Option<ChainInfo>> {
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))
}
}
23 changes: 17 additions & 6 deletions rust/main/chains/hyperlane-sealevel/src/rpc/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use solana_client::{
},
rpc_response::{Response, RpcSimulateTransactionResult},
};
use solana_program::clock::Slot;
use solana_sdk::{
account::Account,
commitment_config::CommitmentConfig,
Expand Down Expand Up @@ -189,16 +190,21 @@ impl SealevelRpcClient {

pub async fn get_slot(&self) -> ChainResult<u32> {
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<Slot> {
self.0
.get_slot_with_commitment(CommitmentConfig::finalized())
.await
.map_err(ChainCommunicationError::from_other)
}

pub async fn get_transaction(
&self,
signature: &Signature,
Expand Down Expand Up @@ -415,9 +421,14 @@ impl SealevelRpcClient {
}
}

let priority_fee_numerator: u64 = std::env::var("SVM_PRIORITY_FEE_NUMERATOR")
.ok()
.and_then(|s| s.parse::<u64>().ok())
.unwrap_or(PRIORITY_FEE_MULTIPLIER_NUMERATOR);

// Bump the priority fee to be conservative
let priority_fee = (priority_fee * PRIORITY_FEE_MULTIPLIER_NUMERATOR)
/ PRIORITY_FEE_MULTIPLIER_DENOMINATOR;
let priority_fee =
(priority_fee * priority_fee_numerator) / PRIORITY_FEE_MULTIPLIER_DENOMINATOR;

Ok(SealevelTxCostEstimate {
compute_units: simulation_compute_units,
Expand Down
61 changes: 61 additions & 0 deletions rust/main/config/mainnet_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -7695,6 +7695,67 @@
"index": {
"from": 12446115
}
},
"trumpchain": {
"blockExplorers": [
{
"apiUrl": "https://explorer.trumpchain.dev/api",
"family": "blockscout",
"name": "TRUMPCHAIN Explorer",
"url": "https://explorer.trumpchain.dev"
}
],
"blocks": {
"confirmations": 1,
"estimateBlockTime": 1,
"reorgPeriod": 0
},
"chainId": 4547,
"deployer": {
"name": "Abacus Works",
"url": "https://www.hyperlane.xyz"
},
"displayName": "TRUMPCHAIN",
"domainId": 4547,
"index": {
"from": 18
},
"gasCurrencyCoinGeckoId": "official-trump",
"name": "trumpchain",
"nativeToken": {
"decimals": 18,
"name": "TRUMP",
"symbol": "TRUMP"
},
"protocol": "ethereum",
"rpcUrls": [
{
"http": "https://rpc.trumpchain.dev"
}
],
"technicalStack": "arbitrumnitro",
"aggregationHook": "0xeC573a5279717059C397E3b5E090C84901BbaC75",
"domainRoutingIsm": "0xBD70Ea9D599a0FC8158B026797177773C3445730",
"domainRoutingIsmFactory": "0x1052eF3419f26Bec74Ed7CEf4a4FA6812Bc09908",
"fallbackRoutingHook": "0xb2674E213019972f937CCFc5e23BF963D915809e",
"interchainGasPaymaster": "0x93D41E41cA545a35A81d11b08D2eE8b852C768df",
"interchainSecurityModule": "0xcba52E0E345fd80e29772724282431D85B9dB8C8",
"mailbox": "0x3a464f746D23Ab22155710f44dB16dcA53e0775E",
"merkleTreeHook": "0x67F36550b73B731e5b2FC44E4F8f250d89c87bD6",
"pausableHook": "0xD8aF449f8fEFbA2064863DCE5aC248F8B232635F",
"pausableIsm": "0x1A4F09A615aA4a35E5a146DC2fa19975bebF21A5",
"protocolFee": "0xA9D06082F4AA449D95b49D85F27fdC0cFb491d4b",
"proxyAdmin": "0x2f2aFaE1139Ce54feFC03593FeE8AB2aDF4a85A7",
"staticAggregationHookFactory": "0xEb9FcFDC9EfDC17c1EC5E1dc085B98485da213D6",
"staticAggregationIsm": "0xcba52E0E345fd80e29772724282431D85B9dB8C8",
"staticAggregationIsmFactory": "0x8F7454AC98228f3504Bb91eA3D8Adafe6406110A",
"staticMerkleRootMultisigIsmFactory": "0x2C1FAbEcd7bFBdEBF27CcdB67baADB38b6Df90fC",
"staticMerkleRootWeightedMultisigIsmFactory": "0x0761b0827849abbf7b0cC09CE14e1C93D87f5004",
"staticMessageIdMultisigIsmFactory": "0x8b83fefd896fAa52057798f6426E9f0B080FCCcE",
"staticMessageIdWeightedMultisigIsmFactory": "0x4Ed7d626f1E96cD1C0401607Bf70D95243E3dEd1",
"storageGasOracle": "0x7B032cBB00AD7438E802A66D8b64761A06E5df22",
"testRecipient": "0x46008F5971eFb16e6c354Ef993EA021B489bc055",
"validatorAnnounce": "0xf0F937943Cd6D2a5D02b7f96C9Dd9e04AB633813"
}
},
"defaultRpcConsensusType": "fallback"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,17 +101,6 @@ impl<T: Debug + Clone + Sync + Send + Indexable + 'static> ForwardSequenceAwareS
}
}

/// Get target sequence or return 0 if request failed
pub async fn target_sequence(&self) -> u32 {
let (count, _) = self
.latest_sequence_querier
.latest_sequence_count_and_tip()
.await
.ok()
.unwrap_or((None, 0));
count.unwrap_or(0).saturating_sub(1)
}

/// Get the last indexed sequence or 0 if no logs have been indexed yet.
pub fn last_sequence(&self) -> u32 {
self.last_indexed_snapshot.sequence.unwrap_or(0)
Expand All @@ -134,6 +123,10 @@ impl<T: Debug + Clone + Sync + Send + Indexable + 'static> ForwardSequenceAwareS
return Ok(None);
};

// for updating metrics even if there's no indexable events available
let max_sequence = onchain_sequence_count.saturating_sub(1) as i64;
self.update_metrics(max_sequence).await;

let current_sequence = self.current_indexing_snapshot.sequence;
let range = match current_sequence.cmp(&onchain_sequence_count) {
Ordering::Equal => {
Expand Down Expand Up @@ -432,7 +425,7 @@ impl<T: Debug + Clone + Sync + Send + Indexable + 'static> ForwardSequenceAwareS
}

// Updates the cursor metrics.
async fn update_metrics(&self) {
async fn update_metrics(&self, max_sequence: i64) {
let mut labels = hashmap! {
"event_type" => T::name(),
"chain" => self.domain.name(),
Expand All @@ -452,7 +445,6 @@ impl<T: Debug + Clone + Sync + Send + Indexable + 'static> ForwardSequenceAwareS
.set(sequence as i64);

labels.remove("cursor_type");
let max_sequence = self.target_sequence().await as i64;
self.metrics
.cursor_max_sequence
.with(&labels)
Expand Down Expand Up @@ -501,7 +493,6 @@ impl<T: Send + Sync + Clone + Debug + Indexable + 'static> ContractSyncCursor<T>
logs: Vec<(Indexed<T>, LogMeta)>,
range: RangeInclusive<u32>,
) -> Result<()> {
self.update_metrics().await;
// Remove any sequence duplicates, filter out any logs preceding our current snapshot,
// and sort in ascending order.
let logs = indexed_to_sequence_indexed_array(logs)?
Expand Down
12 changes: 6 additions & 6 deletions rust/main/hyperlane-base/src/metrics/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ pub struct CoreMetrics {
span_counts: IntCounterVec,
span_events: IntCounterVec,
last_known_message_nonce: IntGaugeVec,
latest_leaf_index: IntGaugeVec,
latest_tree_insertion_index: IntGaugeVec,
submitter_queue_length: IntGaugeVec,

operations_processed_count: IntCounterVec,
Expand Down Expand Up @@ -113,9 +113,9 @@ impl CoreMetrics {
registry
)?;

let latest_leaf_index = register_int_gauge_vec_with_registry!(
let latest_tree_insertion_index = register_int_gauge_vec_with_registry!(
opts!(
namespaced!("latest_leaf_index"),
namespaced!("latest_tree_insertion_index"),
"Latest leaf index inserted into the merkle tree",
const_labels_ref
),
Expand Down Expand Up @@ -188,7 +188,7 @@ impl CoreMetrics {
span_counts,
span_events,
last_known_message_nonce,
latest_leaf_index,
latest_tree_insertion_index,

submitter_queue_length,

Expand Down Expand Up @@ -325,8 +325,8 @@ impl CoreMetrics {
///
/// Labels:
/// - `origin`: Origin chain the leaf index is being tracked at.
pub fn latest_leaf_index(&self) -> IntGaugeVec {
self.latest_leaf_index.clone()
pub fn latest_tree_insertion_index(&self) -> IntGaugeVec {
self.latest_tree_insertion_index.clone()
}

/// Latest message nonce in the validator.
Expand Down
Loading

0 comments on commit 19a4cc2

Please sign in to comment.