-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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: get BlockMeta
table values from static file or database
#13844
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
use crate::{DBProvider, StorageLocation}; | ||
use crate::{DBProvider, OmmersProvider, StorageLocation}; | ||
use alloy_consensus::Header; | ||
use alloy_primitives::BlockNumber; | ||
use reth_chainspec::{ChainSpecProvider, EthereumHardforks}; | ||
use reth_db::{ | ||
|
@@ -138,7 +139,9 @@ where | |
|
||
impl<Provider, T> BlockBodyReader<Provider> for EthStorage<T> | ||
where | ||
Provider: DBProvider + ChainSpecProvider<ChainSpec: EthereumHardforks>, | ||
Provider: DBProvider | ||
+ ChainSpecProvider<ChainSpec: EthereumHardforks> | ||
+ OmmersProvider<Header = Header>, | ||
T: SignedTransaction, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. necessary since |
||
{ | ||
type Block = reth_primitives::Block<T>; | ||
|
@@ -151,7 +154,6 @@ where | |
// TODO: Ideally storage should hold its own copy of chain spec | ||
let chain_spec = provider.chain_spec(); | ||
|
||
let mut ommers_cursor = provider.tx_ref().cursor_read::<tables::BlockOmmers>()?; | ||
let mut withdrawals_cursor = provider.tx_ref().cursor_read::<tables::BlockWithdrawals>()?; | ||
|
||
let mut bodies = Vec::with_capacity(inputs.len()); | ||
|
@@ -171,7 +173,7 @@ where | |
let ommers = if chain_spec.final_paris_total_difficulty(header.number).is_some() { | ||
Vec::new() | ||
} else { | ||
ommers_cursor.seek_exact(header.number)?.map(|(_, o)| o.ommers).unwrap_or_default() | ||
provider.ommers(header.number.into())?.unwrap_or_default() | ||
}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. smol perf hit since it's no longer using a cursor, but since it's just ommers i'd be okay with it. The alternative is to implement I do plan to add |
||
|
||
bodies.push(reth_primitives::BlockBody { transactions, ommers, withdrawals }); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should still delegate to the
self.provider()
I think? given that it already doesget_with_static_file_or_database
internallyThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this way a database transaction wont get opened unless truly necessary