feat: make DatabaseProvider generic over chainspec (#10978)

This commit is contained in:
Arsenii Kulikov
2024-09-19 17:23:06 +03:00
committed by GitHub
parent 161c2d2b0d
commit 6cb26f72af
38 changed files with 290 additions and 190 deletions

View File

@ -10,7 +10,7 @@ use crate::{
use alloy_eips::BlockHashOrNumber;
use alloy_primitives::{Address, BlockHash, BlockNumber, TxHash, TxNumber, B256, U256};
use core::fmt;
use reth_chainspec::ChainInfo;
use reth_chainspec::{ChainInfo, EthereumHardforks};
use reth_db::{init_db, mdbx::DatabaseArguments, DatabaseEnv};
use reth_db_api::{database::Database, models::StoredBlockBodyIndices};
use reth_errors::{RethError, RethResult};
@ -130,7 +130,7 @@ impl<N: ProviderNodeTypes> ProviderFactory<N> {
/// This sets the [`PruneModes`] to [`None`], because they should only be relevant for writing
/// data.
#[track_caller]
pub fn provider(&self) -> ProviderResult<DatabaseProviderRO<N::DB>> {
pub fn provider(&self) -> ProviderResult<DatabaseProviderRO<N::DB, N::ChainSpec>> {
Ok(DatabaseProvider::new(
self.db.tx()?,
self.chain_spec.clone(),
@ -144,7 +144,7 @@ impl<N: ProviderNodeTypes> ProviderFactory<N> {
/// [`BlockHashReader`]. This may fail if the inner read/write database transaction fails to
/// open.
#[track_caller]
pub fn provider_rw(&self) -> ProviderResult<DatabaseProviderRW<N::DB>> {
pub fn provider_rw(&self) -> ProviderResult<DatabaseProviderRW<N::DB, N::ChainSpec>> {
Ok(DatabaseProviderRW(DatabaseProvider::new_rw(
self.db.tx_mut()?,
self.chain_spec.clone(),
@ -186,8 +186,8 @@ impl<N: ProviderNodeTypes> ProviderFactory<N> {
impl<N: ProviderNodeTypes> DatabaseProviderFactory for ProviderFactory<N> {
type DB = N::DB;
type Provider = DatabaseProviderRO<N::DB>;
type ProviderRW = DatabaseProvider<<N::DB as Database>::TXMut>;
type Provider = DatabaseProvider<<N::DB as Database>::TX, N::ChainSpec>;
type ProviderRW = DatabaseProvider<<N::DB as Database>::TXMut, N::ChainSpec>;
fn database_provider_ro(&self) -> ProviderResult<Self::Provider> {
self.provider()