Skip to content

Commit

Permalink
producer & pruner
Browse files Browse the repository at this point in the history
  • Loading branch information
joshieDo committed Jan 7, 2025
1 parent dfe8f68 commit 3e10222
Show file tree
Hide file tree
Showing 15 changed files with 524 additions and 41 deletions.
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

0 comments on commit 3e10222

Please sign in to comment.