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: add StaticFileSegment::BlockMeta to StaticFileProducer and Pruner #13666

Open
wants to merge 1 commit into
base: joshie/bmeta
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 24 additions & 4 deletions crates/cli/commands/src/db/get.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ use alloy_primitives::{hex, BlockHash};
use clap::Parser;
use reth_db::{
static_file::{
ColumnSelectorOne, ColumnSelectorTwo, HeaderWithHashMask, ReceiptMask, TransactionMask,
AllBlockMetaMask, ColumnSelectorOne, ColumnSelectorThree, ColumnSelectorTwo,
HeaderWithHashMask, ReceiptMask, TransactionMask,
},
tables, RawKey, RawTable, Receipts, TableViewer, Transactions,
tables, BlockBodyIndices, BlockOmmers, BlockWithdrawals, RawKey, RawTable, Receipts,
TableViewer, Transactions,
};
use reth_db_api::table::{Decompress, DupSort, Table};
use reth_db_common::DbTool;
Expand Down Expand Up @@ -72,7 +74,10 @@ impl Command {
StaticFileSegment::Receipts => {
(table_key::<tables::Receipts>(&key)?, <ReceiptMask<ReceiptTy<N>>>::MASK)
}
StaticFileSegment::BlockMeta => todo!(),
StaticFileSegment::BlockMeta => (
table_key::<tables::BlockBodyIndices>(&key)?,
<AllBlockMetaMask<Header>>::MASK,
),
};

let content = tool.provider_factory.static_file_provider().find_static_file(
Expand Down Expand Up @@ -115,7 +120,22 @@ impl Command {
println!("{}", serde_json::to_string_pretty(&receipt)?);
}
StaticFileSegment::BlockMeta => {
todo!()
let indices = <<BlockBodyIndices as Table>::Value>::decompress(
content[0].as_slice(),
)?;
let ommers = <<BlockOmmers as Table>::Value>::decompress(
content[1].as_slice(),
)?;
let withdrawals =
<<BlockWithdrawals as Table>::Value>::decompress(
content[2].as_slice(),
)?;
println!(
"BlockIndices\n{}\nOmmers\n{}\nWithdrawals\n{}",
serde_json::to_string_pretty(&indices)?,
serde_json::to_string_pretty(&ommers)?,
serde_json::to_string_pretty(&withdrawals)?
);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/prune/prune/src/segments/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use reth_provider::{errors::provider::ProviderResult, BlockReader, PruneCheckpoi
use reth_prune_types::{PruneCheckpoint, PruneMode, PrunePurpose, PruneSegment, SegmentOutput};
pub use set::SegmentSet;
pub use static_file::{
Headers as StaticFileHeaders, Receipts as StaticFileReceipts,
BlockMeta as StaticFileBlockMeta, Headers as StaticFileHeaders, Receipts as StaticFileReceipts,
Transactions as StaticFileTransactions,
};
use std::{fmt::Debug, ops::RangeInclusive};
Expand Down
7 changes: 4 additions & 3 deletions crates/prune/prune/src/segments/set.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use super::{StaticFileBlockMeta, StaticFileHeaders, StaticFileReceipts, StaticFileTransactions};
use crate::segments::{
AccountHistory, ReceiptsByLogs, Segment, SenderRecovery, StorageHistory, TransactionLookup,
UserReceipts,
Expand All @@ -11,8 +12,6 @@ use reth_provider::{
};
use reth_prune_types::PruneModes;

use super::{StaticFileHeaders, StaticFileReceipts, StaticFileTransactions};

/// Collection of [`Segment`]. Thread-safe, allocated on the heap.
#[derive(Debug)]
pub struct SegmentSet<Provider> {
Expand Down Expand Up @@ -73,7 +72,9 @@ where
// Static file transactions
.segment(StaticFileTransactions::new(static_file_provider.clone()))
// Static file receipts
.segment(StaticFileReceipts::new(static_file_provider))
.segment(StaticFileReceipts::new(static_file_provider.clone()))
// Static file block meta
.segment(StaticFileBlockMeta::new(static_file_provider))
// Account history
.segment_opt(account_history.map(AccountHistory::new))
// Storage history
Expand Down
Loading
Loading