-
Notifications
You must be signed in to change notification settings - Fork 82
Do not log error if we are backwards, but in safe reorg range #321
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Do not log error if we are backwards, but in safe reorg range #321
Conversation
Cleanup provider handling Throw error when a provider chain id is different from one in rindexer config
|
@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)?; |
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
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
JsonRpcCachedProvidermethodcreate_providerfunction
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> { |
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
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.
Cleanup provider handling
Throw error when a provider chain id is different from one in rindexer config