-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
fix: use --syncmode=execution-layer
from op-node
for optimistic pipeline sync
#7552
Merged
Merged
Changes from all commits
Commits
Show all changes
62 commits
Select commit
Hold shift + click to select a range
458ee1a
dont set finalized on op-reth start
joshieDo 1704948
make UnknownSafeOrFinalizedBlock error with upper case
joshieDo 12f5ee9
sync to head if finalized does not exist on optimism pipeline
joshieDo 7df63db
add some docs and scenario on finished pipeline
joshieDo 1f02388
Merge remote-tracking branch 'origin/main' into joshie/hot-op
joshieDo f56103a
Merge remote-tracking branch 'origin/main' into joshie/hot-op
joshieDo 42158aa
enable optimism feature flags on missing dep
joshieDo de8928a
refactor e2e op tests
joshieDo 1d51433
smol clean-up
joshieDo bd9a17b
add StageCheckpointReader to FullProvider
joshieDo 72501de
add span node identifiers on e2e
joshieDo 2c96574
e2e: chain of payloads + optimism reorg
joshieDo 522d65c
on pipeline outcome, skip handling if it's optimistic sync but update…
joshieDo 9320432
move node creation and peering into setup
joshieDo e7a6aa6
merge origin/main
joshieDo d28dc31
restore optimism wallet logic
joshieDo 57e530b
fmt
joshieDo e4c11eb
fix: derank peers that responded with bad data
mattsse e377c57
reduce to 90 blocks
joshieDo 13a426c
optimistic sync with reorg failure
joshieDo 4c35e9d
Merge branch 'main' into joshie/hot-op
joshieDo 5703bbd
doc fix
joshieDo 63df12d
reset download_range on is_terminated
joshieDo 3167f7f
handle reorgs from optimistic syncing
joshieDo 93f0f64
remove unused test code
joshieDo 3ad4cb2
wait_unwind more aggr and check header stage checkpoint
joshieDo c7ba89d
remove canonical block from buffered ones
joshieDo 3dd46f7
rename to update_block_hashes_and_clear_buffered
joshieDo 0fcfb8d
clippy
joshieDo 7e05cc6
Merge remote-tracking branch 'origin/main' into joshie/hot-op
joshieDo dab38a0
remove optimistic syncing as an optimism feature flag only
joshieDo e22e187
add doc to OptimisticCanonicalRevert
joshieDo f9c584e
clippy fmt
joshieDo ce6de02
cargo doc
joshieDo 0dcf372
add more docs on revert_canonical_from_database & static
joshieDo b44d842
Merge remote-tracking branch 'origin/main' into joshie/hot-op
joshieDo c2f7b39
import StaticFileProviderFactory
joshieDo c0c83c5
extend test
joshieDo a3f08cd
allow downloading subset, if the set has terminated
joshieDo 0da350c
dont allow subsets
joshieDo fd51d36
only run pruner once we have a finalized block
joshieDo 17f886c
review traces and docs
joshieDo 982dd8b
Merge remote-tracking branch 'origin/main' into joshie/hot-op
joshieDo 89077c6
clippy
joshieDo 61e5898
unbreak continuous pipeline
joshieDo 89b9645
handle err if optimistic revert
joshieDo 5fdadde
Merge remote-tracking branch 'origin/main' into joshie/hot-op
joshieDo 02d7d0a
add set_canonical_head
joshieDo 963156a
dedup pipeline unwind target setting
joshieDo e18a704
renames
joshieDo a2b9ac3
use PayloadStatus::from_status instead
joshieDo b3e354e
cargo docs fix
joshieDo 1a3939f
Merge remote-tracking branch 'origin/main' into joshie/hot-op
joshieDo 6119832
clippy
joshieDo e0867c8
updated clippy
joshieDo d620b13
move update_block_hashes_and_clear_buffered impl to blockchain tree s…
joshieDo 643c420
add TODO to doc
joshieDo 53cacf4
whitespace
joshieDo 42df97a
review comments
joshieDo 0419207
remove unnecessary todo
joshieDo 0dd1825
add more docs on PipelineTarget
joshieDo c17460b
fmt
joshieDo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,13 +19,14 @@ use reth_interfaces::{ | |
}; | ||
use reth_primitives::{ | ||
BlockHash, BlockNumHash, BlockNumber, ForkBlock, GotExpected, Hardfork, PruneModes, Receipt, | ||
SealedBlock, SealedBlockWithSenders, SealedHeader, U256, | ||
SealedBlock, SealedBlockWithSenders, SealedHeader, StaticFileSegment, B256, U256, | ||
}; | ||
use reth_provider::{ | ||
chain::{ChainSplit, ChainSplitTarget}, | ||
BlockExecutionWriter, BlockNumReader, BlockWriter, BundleStateWithReceipts, | ||
CanonStateNotification, CanonStateNotificationSender, CanonStateNotifications, Chain, | ||
ChainSpecProvider, DisplayBlocksChain, HeaderProvider, ProviderError, | ||
StaticFileProviderFactory, | ||
}; | ||
use reth_stages_api::{MetricEvent, MetricEventsSender}; | ||
use std::{ | ||
|
@@ -783,6 +784,11 @@ where | |
Ok(InsertPayloadOk::Inserted(status)) | ||
} | ||
|
||
/// Discard all blocks that precede block number from the buffer. | ||
pub fn remove_old_blocks(&mut self, block: BlockNumber) { | ||
self.state.buffered_blocks.remove_old_blocks(block); | ||
} | ||
|
||
/// Finalize blocks up until and including `finalized_block`, and remove them from the tree. | ||
pub fn finalize_block(&mut self, finalized_block: BlockNumber) { | ||
// remove blocks | ||
|
@@ -797,7 +803,7 @@ where | |
} | ||
} | ||
// clean block buffer. | ||
self.state.buffered_blocks.remove_old_blocks(finalized_block); | ||
self.remove_old_blocks(finalized_block); | ||
} | ||
|
||
/// Reads the last `N` canonical hashes from the database and updates the block indices of the | ||
|
@@ -817,6 +823,16 @@ where | |
) -> RethResult<()> { | ||
self.finalize_block(last_finalized_block); | ||
|
||
let last_canonical_hashes = self.update_block_hashes()?; | ||
|
||
self.connect_buffered_blocks_to_hashes(last_canonical_hashes)?; | ||
|
||
Ok(()) | ||
} | ||
|
||
/// Update all block hashes. iterate over present and new list of canonical hashes and compare | ||
/// them. Remove all mismatches, disconnect them and removes all chains. | ||
pub fn update_block_hashes(&mut self) -> RethResult<BTreeMap<BlockNumber, B256>> { | ||
let last_canonical_hashes = self | ||
.externals | ||
.fetch_latest_canonical_hashes(self.config.num_of_canonical_hashes() as usize)?; | ||
|
@@ -831,9 +847,22 @@ where | |
} | ||
} | ||
|
||
self.connect_buffered_blocks_to_hashes(last_canonical_hashes)?; | ||
Ok(last_canonical_hashes) | ||
} | ||
|
||
Ok(()) | ||
/// Update all block hashes. iterate over present and new list of canonical hashes and compare | ||
/// them. Remove all mismatches, disconnect them, removes all chains and clears all buffered | ||
/// blocks before the tip. | ||
pub fn update_block_hashes_and_clear_buffered( | ||
&mut self, | ||
) -> RethResult<BTreeMap<BlockNumber, BlockHash>> { | ||
let chain = self.update_block_hashes()?; | ||
|
||
if let Some((block, _)) = chain.last_key_value() { | ||
self.remove_old_blocks(*block); | ||
} | ||
|
||
Ok(chain) | ||
} | ||
|
||
/// Reads the last `N` canonical hashes from the database and updates the block indices of the | ||
|
@@ -1220,6 +1249,28 @@ where | |
&self, | ||
revert_until: BlockNumber, | ||
) -> Result<Option<Chain>, CanonicalError> { | ||
// This should only happen when an optimistic sync target was re-orged. | ||
// | ||
// Static files generally contain finalized data. The blockchain tree only deals | ||
// with unfinalized data. The only scenario where canonical reverts go past the highest | ||
// static file is when an optimistic sync occured and unfinalized data was written to | ||
// static files. | ||
if self | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should be feature gated? feel free to introduce one if there isn't |
||
.externals | ||
.provider_factory | ||
.static_file_provider() | ||
.get_highest_static_file_block(StaticFileSegment::Headers) | ||
.unwrap_or_default() > | ||
joshieDo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
revert_until | ||
{ | ||
trace!( | ||
target: "blockchain_tree", | ||
"Reverting optimistic canonical chain to block {}", | ||
revert_until | ||
); | ||
return Err(CanonicalError::OptimisticTargetRevert(revert_until)) | ||
} | ||
|
||
// read data that is needed for new sidechain | ||
let provider_rw = self.externals.provider_factory.provider_rw()?; | ||
|
||
|
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.
Oops, something went wrong.
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.
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'm pretty sure this was problematic from the start