-
Notifications
You must be signed in to change notification settings - Fork 197
fix: eth block returns correctly filled logs bloom field #7156
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
Open
akaladarshi
wants to merge
10
commits into
main
Choose a base branch
from
akaladarshi/fix-logs-bloom
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+515
−28
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
221f098
feat: add EthBlockBloom store and column
akaladarshi 78cf48a
feat: add db migration for EthBlockBloom column
akaladarshi 4081294
feat: cache eth block logsBloom in the db
akaladarshi 7da1b35
feat: prune stale block blooms during gc
akaladarshi 0b29077
update the changelog entry
akaladarshi 5bd8ce2
fix fmt issues
akaladarshi 0e5a0eb
address comments
akaladarshi 0fd4c9d
address comments and update forest version
akaladarshi 3c8939c
update the snap versions
akaladarshi 8042ce8
Merge branch 'main' into akaladarshi/fix-logs-bloom
akaladarshi 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 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,2 @@ | ||
| # This list contains potentially broken methods (or tests) that are ignored. | ||
| # They should be considered bugged, and not used until the root cause is resolved. | ||
|
|
||
| !Filecoin.EthGetBlockByHash | ||
| !Filecoin.EthGetBlockByNumber |
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
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
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,141 @@ | ||
| // Copyright 2019-2026 ChainSafe Systems | ||
| // SPDX-License-Identifier: Apache-2.0, MIT | ||
|
|
||
| //! Migration logic for databases with the v0.33.7 schema to v0.33.8. | ||
| //! An `EthBlockBloom` column has been added to store per-tipset Ethereum block logs blooms. | ||
|
|
||
| use super::migration_map::MigrationOperation; | ||
| use crate::Config; | ||
| use crate::db::migration::migration_map::MigrationOperationExt as _; | ||
| use anyhow::Context; | ||
| use semver::Version; | ||
| use std::path::{Path, PathBuf}; | ||
| use tracing::info; | ||
|
|
||
| pub(super) struct Migration0_33_7_0_33_8 { | ||
| from: Version, | ||
| to: Version, | ||
| } | ||
|
|
||
| /// Migrates the database from version 0.33.7 to 0.33.8 | ||
| impl MigrationOperation for Migration0_33_7_0_33_8 { | ||
| fn new(from: Version, to: Version) -> Self | ||
| where | ||
| Self: Sized, | ||
| { | ||
| Self { from, to } | ||
| } | ||
|
|
||
| fn from(&self) -> &Version { | ||
| &self.from | ||
| } | ||
|
|
||
| fn to(&self) -> &Version { | ||
| &self.to | ||
| } | ||
|
|
||
| fn migrate_core(&self, chain_data_path: &Path, _: &Config) -> anyhow::Result<PathBuf> { | ||
| let old_db = self.old_db_path(chain_data_path); | ||
| let temp_db = self.temporary_db_path(chain_data_path); | ||
|
|
||
| info!( | ||
| "Renaming database directory from {} to {}", | ||
| old_db.display(), | ||
| temp_db.display() | ||
| ); | ||
| std::fs::rename(&old_db, &temp_db).context("failed to rename database directory")?; | ||
|
|
||
| info!("Adding EthBlockBloom column to database"); | ||
| let mut opts = paritydb_0_33_7::to_options(temp_db.clone()); | ||
| if let Err(e) = | ||
| parity_db::Db::add_column(&mut opts, paritydb_0_33_7::eth_block_bloom_column_options()) | ||
| { | ||
| // Restore the original database so a failed migration never strands the only copy in temp. | ||
| if let Err(restore) = std::fs::rename(&temp_db, &old_db) { | ||
| tracing::error!( | ||
| "failed to restore database to {}; data is preserved at {}: {restore}", | ||
| old_db.display(), | ||
| temp_db.display() | ||
| ); | ||
| } | ||
| return Err(e).context("failed to add EthBlockBloom column"); | ||
| } | ||
|
|
||
| // Create a placeholder so the delete step in `migrate` succeeds. | ||
| std::fs::create_dir_all(&old_db).context("failed to create placeholder directory")?; | ||
|
|
||
| info!("Migration completed successfully"); | ||
| Ok(temp_db) | ||
| } | ||
| } | ||
|
|
||
| /// Database settings from Forest `v0.33.7` | ||
| mod paritydb_0_33_7 { | ||
| use parity_db::{ColumnOptions, CompressionType, Options}; | ||
| use std::path::PathBuf; | ||
| use strum::{Display, EnumIter, IntoEnumIterator}; | ||
|
|
||
| #[derive(Copy, Clone, Debug, PartialEq, EnumIter, Display)] | ||
| #[repr(u8)] | ||
| pub(super) enum DbColumn { | ||
| GraphDagCborBlake2b256, | ||
| GraphFull, | ||
| Settings, | ||
| EthMappings, | ||
| PersistentGraph, | ||
| } | ||
|
|
||
| impl DbColumn { | ||
| fn create_column_options(compression: CompressionType) -> Vec<ColumnOptions> { | ||
| DbColumn::iter() | ||
| .map(|col| match col { | ||
| DbColumn::GraphDagCborBlake2b256 | DbColumn::PersistentGraph => ColumnOptions { | ||
| preimage: true, | ||
| compression, | ||
| ..Default::default() | ||
| }, | ||
| DbColumn::GraphFull => ColumnOptions { | ||
| preimage: true, | ||
| btree_index: true, | ||
| compression, | ||
| ..Default::default() | ||
| }, | ||
| DbColumn::Settings => ColumnOptions { | ||
| preimage: false, | ||
| btree_index: true, | ||
| compression, | ||
| ..Default::default() | ||
| }, | ||
| DbColumn::EthMappings => ColumnOptions { | ||
| preimage: false, | ||
| btree_index: false, | ||
| compression, | ||
| ..Default::default() | ||
| }, | ||
| }) | ||
| .collect() | ||
| } | ||
| } | ||
|
|
||
| /// Options for the `EthBlockBloom` column introduced in v0.33.8. | ||
| pub(super) fn eth_block_bloom_column_options() -> ColumnOptions { | ||
| ColumnOptions { | ||
| preimage: false, | ||
| btree_index: true, | ||
| compression: CompressionType::Lz4, | ||
| ..Default::default() | ||
| } | ||
| } | ||
|
|
||
| pub(super) fn to_options(path: PathBuf) -> Options { | ||
| Options { | ||
| path, | ||
| sync_wal: true, | ||
| sync_data: true, | ||
| stats: false, | ||
| salt: None, | ||
| columns: DbColumn::create_column_options(CompressionType::Lz4), | ||
| compression_threshold: [(0, 128)].into_iter().collect(), | ||
| } | ||
| } | ||
| } |
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'll let @hanabi1224 chip in here.