Skip to content

Commit

Permalink
Add log for cosmos cursors (#3366)
Browse files Browse the repository at this point in the history
### Description

IGP indexing seemed to not be working. Adding these logs revealed that
igp indexing was just super slow... After waiting for 15 mins to do a
full local sync based on the hyperlane context db, turns out we're
actually successfully indexing igp! Keeping the log for improved
troubleshooting in the future.

### Drive-by changes

<!--
Are there any minor or drive-by changes also included?
-->

### Related issues

- Fixes #3372


### Backward compatibility

<!--
Are these changes backward compatible? Are there any infrastructure
implications, e.g. changes that would prohibit deploying older commits
using this infra tooling?

Yes/No
-->

### Testing

<!--
What kind of testing have these changes undergone?

None/Manual/Unit Tests
-->
  • Loading branch information
daniel-savu authored Mar 7, 2024
1 parent 043f756 commit 2c2f79c
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 9 deletions.
6 changes: 5 additions & 1 deletion rust/chains/hyperlane-cosmos/src/interchain_gas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,11 @@ impl Indexer<InterchainGasPayment> for CosmosInterchainGasPaymasterIndexer {
tokio::spawn(async move {
let logs = self_clone
.indexer
.get_logs_in_block(block_number, Self::interchain_gas_payment_parser)
.get_logs_in_block(
block_number,
Self::interchain_gas_payment_parser,
"InterchainGasPaymentCursor",
)
.await;
(logs, block_number)
})
Expand Down
6 changes: 5 additions & 1 deletion rust/chains/hyperlane-cosmos/src/mailbox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,11 @@ impl Indexer<HyperlaneMessage> for CosmosMailboxIndexer {
tokio::spawn(async move {
let logs = self_clone
.indexer
.get_logs_in_block(block_number, Self::hyperlane_message_parser)
.get_logs_in_block(
block_number,
Self::hyperlane_message_parser,
"HyperlaneMessageCursor",
)
.await;
(logs, block_number)
})
Expand Down
6 changes: 5 additions & 1 deletion rust/chains/hyperlane-cosmos/src/merkle_tree_hook.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,11 @@ impl Indexer<MerkleTreeInsertion> for CosmosMerkleTreeHookIndexer {
tokio::spawn(async move {
let logs = self_clone
.indexer
.get_logs_in_block(block_number, Self::merkle_tree_insertion_parser)
.get_logs_in_block(
block_number,
Self::merkle_tree_insertion_parser,
"MerkleTreeInsertionCursor",
)
.await;
(logs, block_number)
})
Expand Down
13 changes: 9 additions & 4 deletions rust/chains/hyperlane-cosmos/src/providers/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use cosmrs::rpc::client::Client;
use hyperlane_core::rpc_clients::call_with_retry;
use hyperlane_core::{ChainCommunicationError, ChainResult, ContractLocator, LogMeta, H256, U256};
use sha256::digest;
use std::fmt::Debug;
use tendermint::abci::{Event, EventAttribute};
use tendermint::hash::Algorithm;
use tendermint::Hash;
Expand All @@ -25,9 +26,10 @@ pub trait WasmIndexer: Send + Sync {
&self,
block_number: u32,
parser: for<'a> fn(&'a Vec<EventAttribute>) -> ChainResult<ParsedEvent<T>>,
cursor_label: &'static str,
) -> ChainResult<Vec<(T, LogMeta)>>
where
T: Send + Sync + PartialEq + 'static;
T: Send + Sync + PartialEq + Debug + 'static;
}

#[derive(Debug, Eq, PartialEq)]
Expand Down Expand Up @@ -122,9 +124,10 @@ impl CosmosWasmIndexer {
block: BlockResponse,
block_results: BlockResultsResponse,
parser: for<'a> fn(&'a Vec<EventAttribute>) -> ChainResult<ParsedEvent<T>>,
cursor_label: &'static str,
) -> Vec<(T, LogMeta)>
where
T: PartialEq + 'static,
T: PartialEq + Debug + 'static,
{
let Some(tx_results) = block_results.txs_results else {
return vec![];
Expand Down Expand Up @@ -231,17 +234,19 @@ impl WasmIndexer for CosmosWasmIndexer {
&self,
block_number: u32,
parser: for<'a> fn(&'a Vec<EventAttribute>) -> ChainResult<ParsedEvent<T>>,
cursor_label: &'static str,
) -> ChainResult<Vec<(T, LogMeta)>>
where
T: Send + Sync + PartialEq + 'static,
T: Send + Sync + PartialEq + Debug + 'static,
{
let client = self.provider.rpc().clone();
debug!(?block_number, ?cursor_label, "Getting logs in block");

let (block, block_results) = tokio::join!(
call_with_retry(|| { Box::pin(Self::get_block(client.clone(), block_number)) }),
call_with_retry(|| { Box::pin(Self::get_block_results(client.clone(), block_number)) }),
);

Ok(self.handle_txs(block?, block_results?, parser))
Ok(self.handle_txs(block?, block_results?, parser, cursor_label))
}
}
4 changes: 2 additions & 2 deletions rust/config/mainnet3_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@
"contractAddressBytes": 32,
"index": {
"from": 4000000,
"chunk": 1
"chunk": 50
},
"blocks": {
"reorgPeriod": 1
Expand Down Expand Up @@ -533,7 +533,7 @@
"contractAddressBytes": 20,
"index": {
"from": 58419500,
"chunk": 1
"chunk": 50
},
"blocks": {
"reorgPeriod": 10
Expand Down

0 comments on commit 2c2f79c

Please sign in to comment.