Skip to content

Commit b3b3ed7

Browse files
authored
feat(hubble): testnet feature for lenient rpc handling (#4044)
2 parents d0cfeb7 + 89ee907 commit b3b3ed7

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

hubble/src/indexer/tendermint/config.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ pub struct Config {
2020
pub tx_search_max_page_size: Option<u8>,
2121
#[serde(default)]
2222
pub finalizer: FinalizerConfig,
23+
#[serde(default)]
24+
pub testnet: bool,
2325
}
2426

2527
impl Config {
@@ -35,6 +37,7 @@ impl Config {
3537
tx_search_max_page_size: self
3638
.tx_search_max_page_size
3739
.unwrap_or(DEFAULT_TRANSACTIONS_MAX_PAGE_SIZE),
40+
testnet: self.testnet,
3841
},
3942
))
4043
}

hubble/src/indexer/tendermint/context.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use url::Url;
66
pub struct TmContext {
77
pub rpc_urls: Vec<Url>,
88
pub tx_search_max_page_size: u8,
9+
pub testnet: bool,
910
}
1011

1112
impl Display for TmContext {

hubble/src/indexer/tendermint/fetcher_client.rs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use itertools::Itertools;
1818
use jsonrpsee::types::{error::INTERNAL_ERROR_CODE, ErrorObject};
1919
use time::OffsetDateTime;
2020
use tokio::task::JoinSet;
21-
use tracing::{debug, info, info_span, trace, Instrument};
21+
use tracing::{debug, info, info_span, trace, warn, Instrument};
2222

2323
use crate::{
2424
indexer::{
@@ -41,6 +41,7 @@ pub struct TmFetcherClient {
4141
pub chain_id: ChainId,
4242
pub provider: Provider,
4343
pub tx_search_max_page_size: u8,
44+
pub testnet: bool,
4445
}
4546

4647
impl Display for TmFetcherClient {
@@ -179,13 +180,25 @@ impl TmFetcherClient {
179180

180181
match txs_event_count == block_tx_event_count {
181182
true => Ok(()),
182-
false => Err(IndexerError::ProviderError(eyre!("provider: {:?} at height {} block_results tx events: {} <> transactions events: {}",
183+
false => match self.testnet {
184+
true => {
185+
// testnet rpcs often have inconsistencies. accept them
186+
warn!(
187+
"provider: {:?} at height {} block_results tx events: {} <> transactions events: {}",
188+
provider_id,
189+
block_results.height,
190+
block_tx_event_count,
191+
txs_event_count
192+
);
193+
Ok(())
194+
},
195+
false => Err(IndexerError::ProviderError(eyre!("provider: {:?} at height {} block_results tx events: {} <> transactions events: {}",
183196
provider_id,
184197
block_results.height,
185198
block_tx_event_count,
186199
txs_event_count
187200
)
188-
)),
201+
))},
189202
}
190203
}
191204

@@ -553,6 +566,7 @@ impl FetcherClient for TmFetcherClient {
553566
chain_id,
554567
provider,
555568
tx_search_max_page_size: context.tx_search_max_page_size,
569+
testnet: context.testnet,
556570
})
557571
}
558572
.instrument(indexing_span)

0 commit comments

Comments
 (0)