Skip to content

Commit

Permalink
fix: read sidecars from table in get_take_block_range (paradigmxyz#79)
Browse files Browse the repository at this point in the history
* fix: read sidecars from table in `get_take_block_range`

* fix lint issue
  • Loading branch information
pythonberg1997 authored Jul 22, 2024
1 parent 27aaf5d commit eee1b05
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions crates/storage/provider/src/providers/database/provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -969,6 +969,7 @@ impl<TX: DbTxMut + DbTx> DatabaseProvider<TX> {
let block_withdrawals =
self.get_or_take::<tables::BlockWithdrawals, TAKE>(range.clone())?;
let block_requests = self.get_or_take::<tables::BlockRequests, TAKE>(range.clone())?;
let block_sidecars = self.get_or_take::<tables::Sidecars, TAKE>(range.clone())?;

let block_tx = self.get_take_block_transaction_range::<TAKE>(range.clone())?;

Expand All @@ -993,9 +994,11 @@ impl<TX: DbTxMut + DbTx> DatabaseProvider<TX> {
let mut block_ommers_iter = block_ommers.into_iter();
let mut block_withdrawals_iter = block_withdrawals.into_iter();
let mut block_requests_iter = block_requests.into_iter();
let mut block_sidecars_iter = block_sidecars.into_iter();
let mut block_ommers = block_ommers_iter.next();
let mut block_withdrawals = block_withdrawals_iter.next();
let mut block_requests = block_requests_iter.next();
let mut block_sidecars = block_sidecars_iter.next();

let mut blocks = Vec::new();
for ((main_block_number, header), (_, header_hash), (_, tx)) in
Expand Down Expand Up @@ -1044,10 +1047,17 @@ impl<TX: DbTxMut + DbTx> DatabaseProvider<TX> {
}

// sidecars can be missing
let sidecars = if self.chain_spec.is_cancun_active_at_timestamp(header.timestamp) {
self.static_file_provider.sidecars(&header.hash())?
let cancun_is_active = self.chain_spec.is_cancun_active_at_timestamp(header.timestamp);
let mut sidecars = Some(BlobSidecars::default());
if cancun_is_active {
if let Some((block_number, _)) = block_sidecars.as_ref() {
if *block_number == main_block_number {
sidecars = Some(block_sidecars.take().unwrap().1);
block_sidecars = block_sidecars_iter.next();
}
}
} else {
None
sidecars = None;
};

blocks.push(SealedBlockWithSenders {
Expand Down

0 comments on commit eee1b05

Please sign in to comment.