fix(sync): guarantee consecutive L1 gas price samples are fed into L1GasPriceProvider#3243
Open
fix(sync): guarantee consecutive L1 gas price samples are fed into L1GasPriceProvider#3243
L1GasPriceProvider#3243Conversation
…so the caller can deal with each case)
…sed to channel-based
… and reorg recovery
…ed`) to minimize initial gap with subscription
Contributor
Note that this incompatible with the apollo implementation, which uses not just finalized blocks, but a configurable "finality gap" (but I agree the difference hopefully won't matter). |
669dcef to
a41076a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Relevant context for this PR can be found in #3197
This should now be way more reliable. Been running it for ~1d and it seems to work as expected.
Summary of key changes:
In our ethereum client:
a) Made the
get_gas_price_data_rangestrict. It used to just silently skip errors.b) Changed
subscribe_block_headersfrom callback-based to channel-based. Otherwise I couldn't make the caller have full control over the processing loop.c) Also added tracking of parent block hash to
L1GasPriceDatato detect reorgs.In the
L1GasPriceProvider:a) Proper errors when adding a gas price sample. This allows the caller to take the right action accordingly.
b) Detect reorgs by using those parent block hashes mentioned previously.
The new sync loop:
There's an outer loop that runs forever (reconnects on failures) and an inner "cycle" which bootstraps the provider, subscribes to block header updates, and processes them. Here's where we pay attention to the two errors (gap or reorg detected) and we act accordingly. For gaps, we just inline fill them and keep going, for reorgs we restart the whole thing.
Worth noting that I changed the bootstrap initial block from
finalizedtolatest. The latter is way closer to what we'll get on our first subscribed items, and thus reduces the initial gap fill. I think for gas prices it should be fine to rely onlatest.Closes #3196
Closes #3197