Skip to content

Conversation

@desfero
Copy link
Contributor

@desfero desfero commented Oct 8, 2025

Cleanup provider handling
Throw error when a provider chain id is different from one in rindexer config

Cleanup provider handling
Throw error when a provider chain id is different from one in rindexer config
@vercel
Copy link

vercel bot commented Oct 8, 2025

@desfero is attempting to deploy a commit to the joshaavecom's projects Team on Vercel.

A member of the Team first needs to authorize it.

let mut indexing_distance_from_head = U64::ZERO;
if reorg_safe_distance {
let chain_id =
provider.get_chain_id().await.map_err(StartIndexingError::GetChainIdError)?;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was not optimal, there is no need to call eth_chain_id every safe block number calculation.
Also this function is not a sync one with is another win

}

impl JsonRpcCachedProvider {
pub async fn new(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic was spread across two separate functions

  • JsonRpcCachedProvider method
  • create_provider function

don't see a need for that as we can nicely abstract all in single function. JsonRpcCachedProvider has private fields that are only accessible in this module so there is also no other way to create the struct than by calling create_provider method

On top of that having Struct::new() is not fully idiomatic rust given constructors should be not async.

}

#[tracing::instrument(skip_all)]
pub async fn get_chain_id(&self) -> Result<U256, ProviderError> {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hiding this as should be never called by our code as affects negatively indexing speed

})?;

if real_rpc_chain_id != chain_id {
return Err(RetryClientError::InvalidClientChainId(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

adding this check to make sure config chain_id matches the real RPC chain_id.
Tested this locally and if there is a mismatch indexer is going into a weird broken state.

@joshstevens19 joshstevens19 merged commit 341d8a0 into joshstevens19:master Oct 8, 2025
8 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants