Skip to content
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

feat: introduce StaticFileSegment::BlockMeta #13226

Merged
merged 8 commits into from
Jan 15, 2025
Merged

feat: introduce StaticFileSegment::BlockMeta #13226

merged 8 commits into from
Jan 15, 2025

Conversation

joshieDo
Copy link
Collaborator

@joshieDo joshieDo commented Dec 9, 2024

Related to History pre-merge sync#13186 as this data would need to be provided as well.

Adds StaticFileSegment::BlockMeta which would contain:

  • BlockBodyIndices
  • BlockOmmers
  • BlockWithdrawals

Only introduces the segment, alongside some of the future methods.

Side-effect: on booting up, it will create an empty block meta static file which won't be used.
Should have no side effects

@joshieDo joshieDo added C-enhancement New feature or request A-db Related to the database A-static-files Related to static files labels Dec 9, 2024
@joshieDo joshieDo force-pushed the joshie/bmeta branch 7 times, most recently from 67be940 to 342105c Compare December 16, 2024 16:33
@joshieDo joshieDo force-pushed the joshie/bmeta branch 3 times, most recently from 69a497a to 9c241b1 Compare December 20, 2024 09:46
@joshieDo joshieDo force-pushed the joshie/bmeta branch 3 times, most recently from 0aace8c to b7b5e83 Compare December 27, 2024 14:01
Copy link

codspeed-hq bot commented Dec 27, 2024

CodSpeed Performance Report

Merging #13226 will not alter performance

Comparing joshie/bmeta (0a80ff5) with main (46f4d73)

Summary

✅ 77 untouched benchmarks

@joshieDo joshieDo force-pushed the joshie/bmeta branch 7 times, most recently from 0e13249 to 900b334 Compare January 6, 2025 11:08
@joshieDo joshieDo force-pushed the joshie/bmeta branch 3 times, most recently from c2a840a to 26a65be Compare January 8, 2025 11:38
@joshieDo joshieDo marked this pull request as ready for review January 8, 2025 15:29
Copy link
Collaborator

@mattsse mattsse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think all of this makes sense, this doesn't integrate this yet, so this doesn't take effect, right?

Side-effect: on booting up, it will create an empty block meta static file which won't be used.

can you elaborate on this

@@ -72,6 +72,7 @@ impl Command {
StaticFileSegment::Receipts => {
(table_key::<tables::Receipts>(&key)?, <ReceiptMask<ReceiptTy<N>>>::MASK)
}
StaticFileSegment::BlockMeta => todo!(),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these should be fine for now I think

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done on the follow-up (linked above)

crates/static-file/types/src/lib.rs Outdated Show resolved Hide resolved
crates/static-file/types/src/segment.rs Outdated Show resolved Hide resolved
Comment on lines +256 to +274
if self.segment.is_block_based() {
if let Some(range) = &mut self.block_range {
if num > range.end - range.start {
self.block_range = None;
} else {
range.end = range.end.saturating_sub(num);
}
};
} else if let Some(range) = &mut self.tx_range {
if num > range.end - range.start {
self.tx_range = None;
} else {
range.end = range.end.saturating_sub(num);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these are functially unchanged it appears?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, better to have is_block_based instead of enumerating all variants imo

@@ -890,8 +902,11 @@ impl<N: NodePrimitives> StaticFileProvider<N> {
);
let mut writer = self.latest_writer(segment)?;
if segment.is_headers() {
// TODO(joshie): is_block_meta
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's missing here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done on the followup

Err(ProviderError::UnsupportedProvider)
}
}

impl<N: FullNodePrimitives<BlockHeader: Value>> OmmersProvider for StaticFileProvider<N> {
fn ommers(&self, _id: BlockHashOrNumber) -> ProviderResult<Option<Vec<Self::Header>>> {
// Required data not present in static_files
fn ommers(&self, id: BlockHashOrNumber) -> ProviderResult<Option<Vec<Self::Header>>> {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see we now have to impl all of these for statics

Comment on lines +584 to +585
field1: &F1,
field2: &F2,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this perhaps be an iter over additional comlumns?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The number of columns of a static file are statically defined. I think it's okay for now as is and improve on it if necessary

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually, why not

@joshieDo joshieDo force-pushed the joshie/bmeta branch 2 times, most recently from a6347c2 to 2874270 Compare January 9, 2025 12:55
@joshieDo
Copy link
Collaborator Author

joshieDo commented Jan 9, 2025

Side-effect: on booting up, it will create an empty block meta static file which won't be used.

can you elaborate on this

No longer happening, but:

When checking the consistency of a static file segment in a RW env, we fetch a StaticFileWriter of that segment, which leads to creating it (empty) on disk if it doesn't exist yet. Skipped block meta for now.

@joshieDo joshieDo force-pushed the joshie/bmeta branch 3 times, most recently from 7ed1564 to 674a603 Compare January 9, 2025 14:38
@joshieDo joshieDo requested a review from mattsse January 9, 2025 16:27
put on bottom
@joshieDo joshieDo added this pull request to the merge queue Jan 14, 2025
Merged via the queue into main with commit 1267718 Jan 15, 2025
43 checks passed
@joshieDo joshieDo deleted the joshie/bmeta branch January 15, 2025 00:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-db Related to the database A-static-files Related to static files C-enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants