Skip to content
This repository has been archived by the owner on Feb 6, 2025. It is now read-only.

Commit

Permalink
fix: add sidecars to db when doing insert_block
Browse files Browse the repository at this point in the history
  • Loading branch information
pythonberg1997 committed Jul 17, 2024
1 parent 566eeb3 commit 8c4dc0d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
4 changes: 4 additions & 0 deletions crates/storage/provider/src/providers/database/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ pub(crate) enum Action {
InsertTransactions,
InsertTransactionHashNumbers,
InsertBlockWithdrawals,
InsertBlockSidecars,
InsertBlockRequests,
InsertBlockBodyIndices,
InsertTransactionBlocks,
Expand Down Expand Up @@ -106,6 +107,8 @@ struct DatabaseProviderMetrics {
insert_tx_hash_numbers: Histogram,
/// Duration of insert block withdrawals
insert_block_withdrawals: Histogram,
/// Duration of insert block sidecars
insert_block_sidecars: Histogram,
/// Duration of insert block requests
insert_block_requests: Histogram,
/// Duration of insert block body indices
Expand Down Expand Up @@ -139,6 +142,7 @@ impl DatabaseProviderMetrics {
Action::InsertTransactions => self.insert_transactions.record(duration),
Action::InsertTransactionHashNumbers => self.insert_tx_hash_numbers.record(duration),
Action::InsertBlockWithdrawals => self.insert_block_withdrawals.record(duration),
Action::InsertBlockSidecars => self.insert_block_sidecars.record(duration),
Action::InsertBlockRequests => self.insert_block_requests.record(duration),
Action::InsertBlockBodyIndices => self.insert_block_body_indices.record(duration),
Action::InsertTransactionBlocks => self.insert_tx_blocks.record(duration),
Expand Down
4 changes: 4 additions & 0 deletions crates/storage/provider/src/providers/database/provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2796,6 +2796,10 @@ impl<TX: DbTxMut + DbTx> BlockWriter for DatabaseProvider<TX> {
}
}

let sidecars = block.block.sidecars.unwrap_or_default();
self.tx.put::<tables::Sidecars>(block_number, sidecars)?;
durations_recorder.record_relative(metrics::Action::InsertBlockSidecars);

let block_indices = StoredBlockBodyIndices { first_tx_num, tx_count };
self.tx.put::<tables::BlockBodyIndices>(block_number, block_indices.clone())?;
durations_recorder.record_relative(metrics::Action::InsertBlockBodyIndices);
Expand Down
3 changes: 2 additions & 1 deletion crates/storage/provider/src/providers/static_file/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,8 @@ impl StaticFileProvider {
highest_static_file_block == 0 &&
checkpoint_block_number != 0
{
let range_start = find_fixed_range(checkpoint_block_number).start();
let fixed_range_start = find_fixed_range(checkpoint_block_number).start();
let range_start = if fixed_range_start > 0 { fixed_range_start } else { 1 };

// create static file of newest block
let mut writer = StaticFileProviderRW::new(
Expand Down

0 comments on commit 8c4dc0d

Please sign in to comment.