-
Notifications
You must be signed in to change notification settings - Fork 62
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
Generic provider #218
Generic provider #218
Conversation
01c9560
to
68ef419
Compare
Benchmark results for
|
Date (UTC) | 2024-10-23T18:42:52+00:00 |
Commit | ce433b212cd3b3eb8441279480484c6c0c94dad9 |
Base SHA | d96e7215483bac0ab145459f4ddaa811d99459d6 |
Significant changes
None
impl<P, DB> CombinatorContext<P, DB> | ||
where | ||
DB: Database + Clone + 'static, | ||
P: DatabaseProviderFactory<DB> + StateProviderFactory + Clone + 'static, |
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.
How does this work with Rbuilder as a module? AFAIK It only receives the StateProviderFactory, not DatabaseProviderFactory.
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.
It is also DatabaseProviderFactory
https://github.com/paradigmxyz/reth/blob/661b260f6172c047e8530e2331b2c84141e03c2b/crates/storage/provider/src/traits/full.rs#L14
68ef419
to
fe5d9a0
Compare
fe5d9a0
to
b125994
Compare
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.
LGTM overall.
I've tested it for a bit and it looks good.
I want to be sure that best block number will work in our case so we can avoid subtle bugs.
if !self.testing_mode { | ||
match check_provider_factory_health(current_block_number, &provider_factory) { | ||
|
||
// Don't need to check consistency for the block that was just checked. |
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.
I am pretty sure that its true but it can be possible that its not.
The only place that I see that would suffer from too much checking here is nonce cache in sim tree. But even then this check can have a small impact.
I don't think that we should change it now but I marked it to remember to revisit if we see some problems with reopening.
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.
LGTM
Closes #216 Replaces all concrete usage of `ProviderFactory` and `ProviderFactoryReopener` with generics bounded by [reth provider traits](https://github.com/paradigmxyz/reth/blob/661b260f6172c047e8530e2331b2c84141e03c2b/crates/storage/provider/src/traits/full.rs#L14-L24). This allows running rbuilder in-process using a node provider and eases swapping to a more modern provider like `BlockchainProvider` in the future. Note that not all trait methods can be implemented because `ProviderFactoryReopener` has no access to the blockchain tree (pending state etc.). Consistency checks have been moved out of the rbuilder core into the trait implementation for `ProviderFactoryReopener`. Inside the trait implementation, the current head block number is not known, so the reopener cannot assume that the state of the block given - 256 blocks will be available. To not redundantly re-check the consistency of the same block, `ProviderFactoryReopener` tracks the last block verified to have consistent state and will only re-check it when it changes. This adds 1 additional read per provider call to get the head of the chain, however I believe the cost will be insignificant.
Closes #216
Replaces all concrete usage of
ProviderFactory
andProviderFactoryReopener
with generics bounded by reth provider traits. This allows running rbuilder in-process using a node provider and eases swapping to a more modern provider likeBlockchainProvider
in the future.Note that not all trait methods can be implemented because
ProviderFactoryReopener
has no access to the blockchain tree (pending state etc.).DB Consistency Checks
Consistency checks have been moved out of the rbuilder core into the trait implementation for
ProviderFactoryReopener
. Inside the trait implementation, the current head block number is not known, so the reopener cannot assume that the state of the block given - 256 blocks will be available.To not redundantly re-check the consistency of the same block,
ProviderFactoryReopener
tracks the last block verified to have consistent state and will only re-check it when it changes. This adds 1 additional read per provider call to get the head of the chain, however I believe the cost will be insignificant.