mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
fix: make WithdrawalsProvider methods aware of in-memory state (#10245)
This commit is contained in:
@ -17,9 +17,9 @@ use reth_db_api::{
|
||||
use reth_evm::ConfigureEvmEnv;
|
||||
use reth_primitives::{
|
||||
Account, Address, Block, BlockHash, BlockHashOrNumber, BlockId, BlockNumHash, BlockNumber,
|
||||
BlockNumberOrTag, BlockWithSenders, Header, Receipt, SealedBlock, SealedBlockWithSenders,
|
||||
SealedHeader, TransactionMeta, TransactionSigned, TransactionSignedNoHash, TxHash, TxNumber,
|
||||
Withdrawal, Withdrawals, B256, U256,
|
||||
BlockNumberOrTag, BlockWithSenders, EthereumHardforks, Header, Receipt, SealedBlock,
|
||||
SealedBlockWithSenders, SealedHeader, TransactionMeta, TransactionSigned,
|
||||
TransactionSignedNoHash, TxHash, TxNumber, Withdrawal, Withdrawals, B256, U256,
|
||||
};
|
||||
use reth_prune_types::{PruneCheckpoint, PruneSegment};
|
||||
use reth_stages_types::{StageCheckpoint, StageId};
|
||||
@ -797,12 +797,30 @@ where
|
||||
id: BlockHashOrNumber,
|
||||
timestamp: u64,
|
||||
) -> ProviderResult<Option<Withdrawals>> {
|
||||
if !self.database.chain_spec().is_shanghai_active_at_timestamp(timestamp) {
|
||||
return Ok(None)
|
||||
}
|
||||
|
||||
let Some(number) = self.convert_hash_or_number(id)? else { return Ok(None) };
|
||||
|
||||
if let Some(block) = self.canonical_in_memory_state.state_by_number(number) {
|
||||
Ok(block.block().block().withdrawals.clone())
|
||||
} else {
|
||||
self.database.withdrawals_by_block(id, timestamp)
|
||||
}
|
||||
}
|
||||
|
||||
fn latest_withdrawal(&self) -> ProviderResult<Option<Withdrawal>> {
|
||||
let best_block_num = self.best_block_number()?;
|
||||
|
||||
// If the best block is in memory, use that. Otherwise, use the latest withdrawal in the
|
||||
// database.
|
||||
if let Some(block) = self.canonical_in_memory_state.state_by_number(best_block_num) {
|
||||
Ok(block.block().block().withdrawals.clone().and_then(|mut w| w.pop()))
|
||||
} else {
|
||||
self.database.latest_withdrawal()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<DB> RequestsProvider for BlockchainProvider2<DB>
|
||||
|
||||
Reference in New Issue
Block a user