filePath
stringlengths
19
70
prefix
stringlengths
0
7.99k
middle
stringlengths
10
14.8k
suffix
stringlengths
0
8k
nodeType
stringclasses
10 values
examples/custom-node-components/src/main.rs
//! This example shows how to configure custom components for a reth node. #![warn(unused_crate_dependencies)] use reth_ethereum::{ chainspec::ChainSpec, cli::interface::Cli, evm::primitives::ConfigureEvm, node::{ api::{FullNodeTypes, NodeTypes}, builder::{components::PoolBuilder, Buil...
use reth_tracing::tracing::{debug, info};
fn main() { Cli::parse_args() .run(async move |builder, _| { let handle = builder // use the default ethereum node types .with_types::<EthereumNode>() // Configure the components of the node // use default ethereum components but u...
Use
examples/custom-node-components/src/main.rs
//! This example shows how to configure custom components for a reth node. #![warn(unused_crate_dependencies)] use reth_ethereum::{ chainspec::ChainSpec, cli::interface::Cli, evm::primitives::ConfigureEvm, node::{ api::{FullNodeTypes, NodeTypes}, builder::{components::PoolBuilder, Buil...
/// A custom pool builder #[derive(Debug, Clone, Default)] #[non_exhaustive] pub struct CustomPoolBuilder { /// Use custom pool config pool_config: PoolConfig, }
/// Implement the [`PoolBuilder`] trait for the custom pool builder /// /// This will be used to build the transaction pool and its maintenance tasks during launch. impl<Node, Evm> PoolBuilder<Node, Evm> for CustomPoolBuilder where Node: FullNodeTypes<Types: NodeTypes<ChainSpec = ChainSpec, Primitives = EthPrimiti...
Struct
crates/storage/db-common/src/init.rs
//! Reth genesis initialization utility functions.
use alloy_consensus::BlockHeader;
use alloy_genesis::GenesisAccount; use alloy_primitives::{ keccak256, map::{AddressMap, B256Map, B256Set, HashMap}, Address, B256, U256, }; use reth_chainspec::EthChainSpec; use reth_codecs::Compact; use reth_config::config::EtlConfig; use reth_db_api::{ cursor::{DbCursorRW, DbDupCursorRW}, models::...
Use
crates/storage/db-common/src/init.rs
//! Reth genesis initialization utility functions. use alloy_consensus::BlockHeader;
use alloy_genesis::GenesisAccount;
use alloy_primitives::{ keccak256, map::{AddressMap, B256Map, B256Set, HashMap}, Address, B256, U256, }; use reth_chainspec::EthChainSpec; use reth_codecs::Compact; use reth_config::config::EtlConfig; use reth_db_api::{ cursor::{DbCursorRW, DbDupCursorRW}, models::{ storage_sharded_key::Stor...
Use
crates/storage/db-common/src/init.rs
//! Reth genesis initialization utility functions. use alloy_consensus::BlockHeader; use alloy_genesis::GenesisAccount;
use alloy_primitives::{ keccak256, map::{AddressMap, B256Map, B256Set, HashMap}, Address, B256, U256, };
use reth_chainspec::EthChainSpec; use reth_codecs::Compact; use reth_config::config::EtlConfig; use reth_db_api::{ cursor::{DbCursorRW, DbDupCursorRW}, models::{ storage_sharded_key::StorageShardedKey, AccountBeforeTx, BlockNumberAddress, IntegerList, ShardedKey, }, tables, transacti...
Use
crates/storage/db-common/src/init.rs
//! Reth genesis initialization utility functions. use alloy_consensus::BlockHeader; use alloy_genesis::GenesisAccount; use alloy_primitives::{ keccak256, map::{AddressMap, B256Map, B256Set, HashMap}, Address, B256, U256, };
use reth_chainspec::EthChainSpec;
use reth_codecs::Compact; use reth_config::config::EtlConfig; use reth_db_api::{ cursor::{DbCursorRW, DbDupCursorRW}, models::{ storage_sharded_key::StorageShardedKey, AccountBeforeTx, BlockNumberAddress, IntegerList, ShardedKey, }, tables, transaction::DbTxMut, DatabaseError, };...
Use
crates/storage/db-common/src/init.rs
//! Reth genesis initialization utility functions. use alloy_consensus::BlockHeader; use alloy_genesis::GenesisAccount; use alloy_primitives::{ keccak256, map::{AddressMap, B256Map, B256Set, HashMap}, Address, B256, U256, }; use reth_chainspec::EthChainSpec;
use reth_codecs::Compact;
use reth_config::config::EtlConfig; use reth_db_api::{ cursor::{DbCursorRW, DbDupCursorRW}, models::{ storage_sharded_key::StorageShardedKey, AccountBeforeTx, BlockNumberAddress, IntegerList, ShardedKey, }, tables, transaction::DbTxMut, DatabaseError, }; use reth_etl::Collector; ...
Use
crates/storage/db-common/src/init.rs
//! Reth genesis initialization utility functions. use alloy_consensus::BlockHeader; use alloy_genesis::GenesisAccount; use alloy_primitives::{ keccak256, map::{AddressMap, B256Map, B256Set, HashMap}, Address, B256, U256, }; use reth_chainspec::EthChainSpec; use reth_codecs::Compact;
use reth_config::config::EtlConfig;
use reth_db_api::{ cursor::{DbCursorRW, DbDupCursorRW}, models::{ storage_sharded_key::StorageShardedKey, AccountBeforeTx, BlockNumberAddress, IntegerList, ShardedKey, }, tables, transaction::DbTxMut, DatabaseError, }; use reth_etl::Collector; use reth_execution_errors::StateRoot...
Use
crates/storage/db-common/src/init.rs
//! Reth genesis initialization utility functions. use alloy_consensus::BlockHeader; use alloy_genesis::GenesisAccount; use alloy_primitives::{ keccak256, map::{AddressMap, B256Map, B256Set, HashMap}, Address, B256, U256, }; use reth_chainspec::EthChainSpec; use reth_codecs::Compact; use reth_config::confi...
use reth_db_api::{ cursor::{DbCursorRW, DbDupCursorRW}, models::{ storage_sharded_key::StorageShardedKey, AccountBeforeTx, BlockNumberAddress, IntegerList, ShardedKey, }, tables, transaction::DbTxMut, DatabaseError, };
use reth_etl::Collector; use reth_execution_errors::StateRootError; use reth_primitives_traits::{ Account, Bytecode, GotExpected, NodePrimitives, SealedHeader, StorageEntry, }; use reth_provider::{ errors::provider::ProviderResult, providers::StaticFileWriter, BlockHashReader, BlockNumReader, BundleStateIni...
Use
crates/storage/db-common/src/init.rs
//! Reth genesis initialization utility functions. use alloy_consensus::BlockHeader; use alloy_genesis::GenesisAccount; use alloy_primitives::{ keccak256, map::{AddressMap, B256Map, B256Set, HashMap}, Address, B256, U256, }; use reth_chainspec::EthChainSpec; use reth_codecs::Compact; use reth_config::confi...
use reth_etl::Collector;
use reth_execution_errors::StateRootError; use reth_primitives_traits::{ Account, Bytecode, GotExpected, NodePrimitives, SealedHeader, StorageEntry, }; use reth_provider::{ errors::provider::ProviderResult, providers::StaticFileWriter, BlockHashReader, BlockNumReader, BundleStateInit, ChainSpecProvider, DBP...
Use
crates/storage/db-common/src/init.rs
//! Reth genesis initialization utility functions. use alloy_consensus::BlockHeader; use alloy_genesis::GenesisAccount; use alloy_primitives::{ keccak256, map::{AddressMap, B256Map, B256Set, HashMap}, Address, B256, U256, }; use reth_chainspec::EthChainSpec; use reth_codecs::Compact; use reth_config::confi...
use reth_execution_errors::StateRootError;
use reth_primitives_traits::{ Account, Bytecode, GotExpected, NodePrimitives, SealedHeader, StorageEntry, }; use reth_provider::{ errors::provider::ProviderResult, providers::StaticFileWriter, BlockHashReader, BlockNumReader, BundleStateInit, ChainSpecProvider, DBProvider, DatabaseProviderFactory, Execution...
Use
crates/storage/db-common/src/init.rs
//! Reth genesis initialization utility functions. use alloy_consensus::BlockHeader; use alloy_genesis::GenesisAccount; use alloy_primitives::{ keccak256, map::{AddressMap, B256Map, B256Set, HashMap}, Address, B256, U256, }; use reth_chainspec::EthChainSpec; use reth_codecs::Compact; use reth_config::confi...
use reth_primitives_traits::{ Account, Bytecode, GotExpected, NodePrimitives, SealedHeader, StorageEntry, };
use reth_provider::{ errors::provider::ProviderResult, providers::StaticFileWriter, BlockHashReader, BlockNumReader, BundleStateInit, ChainSpecProvider, DBProvider, DatabaseProviderFactory, ExecutionOutcome, HashingWriter, HeaderProvider, HistoryWriter, MetadataProvider, MetadataWriter, NodePrimitivesPr...
Use
crates/storage/db-common/src/init.rs
//! Reth genesis initialization utility functions. use alloy_consensus::BlockHeader; use alloy_genesis::GenesisAccount; use alloy_primitives::{ keccak256, map::{AddressMap, B256Map, B256Set, HashMap}, Address, B256, U256, }; use reth_chainspec::EthChainSpec; use reth_codecs::Compact; use reth_config::confi...
use reth_provider::{ errors::provider::ProviderResult, providers::StaticFileWriter, BlockHashReader, BlockNumReader, BundleStateInit, ChainSpecProvider, DBProvider, DatabaseProviderFactory, ExecutionOutcome, HashingWriter, HeaderProvider, HistoryWriter, MetadataProvider, MetadataWriter, NodePrimitivesPr...
use reth_stages_types::{StageCheckpoint, StageId}; use reth_static_file_types::StaticFileSegment; use reth_trie::{ prefix_set::TriePrefixSets, IntermediateStateRootState, StateRoot as StateRootComputer, StateRootProgress, }; use reth_trie_db::DatabaseStateRoot; type DbStateRoot<'a, TX, A> = StateRootComputer< ...
Use
crates/storage/db-common/src/init.rs
//! Reth genesis initialization utility functions. use alloy_consensus::BlockHeader; use alloy_genesis::GenesisAccount; use alloy_primitives::{ keccak256, map::{AddressMap, B256Map, B256Set, HashMap}, Address, B256, U256, }; use reth_chainspec::EthChainSpec; use reth_codecs::Compact; use reth_config::confi...
use reth_stages_types::{StageCheckpoint, StageId};
use reth_static_file_types::StaticFileSegment; use reth_trie::{ prefix_set::TriePrefixSets, IntermediateStateRootState, StateRoot as StateRootComputer, StateRootProgress, }; use reth_trie_db::DatabaseStateRoot; type DbStateRoot<'a, TX, A> = StateRootComputer< reth_trie_db::DatabaseTrieCursorFactory<&'a TX,...
Use
crates/storage/db-common/src/init.rs
//! Reth genesis initialization utility functions. use alloy_consensus::BlockHeader; use alloy_genesis::GenesisAccount; use alloy_primitives::{ keccak256, map::{AddressMap, B256Map, B256Set, HashMap}, Address, B256, U256, }; use reth_chainspec::EthChainSpec; use reth_codecs::Compact; use reth_config::confi...
use reth_static_file_types::StaticFileSegment;
use reth_trie::{ prefix_set::TriePrefixSets, IntermediateStateRootState, StateRoot as StateRootComputer, StateRootProgress, }; use reth_trie_db::DatabaseStateRoot; type DbStateRoot<'a, TX, A> = StateRootComputer< reth_trie_db::DatabaseTrieCursorFactory<&'a TX, A>, reth_trie_db::DatabaseHashedCursorFact...
Use
crates/storage/db-common/src/init.rs
//! Reth genesis initialization utility functions. use alloy_consensus::BlockHeader; use alloy_genesis::GenesisAccount; use alloy_primitives::{ keccak256, map::{AddressMap, B256Map, B256Set, HashMap}, Address, B256, U256, }; use reth_chainspec::EthChainSpec; use reth_codecs::Compact; use reth_config::confi...
use reth_trie::{ prefix_set::TriePrefixSets, IntermediateStateRootState, StateRoot as StateRootComputer, StateRootProgress, };
use reth_trie_db::DatabaseStateRoot; type DbStateRoot<'a, TX, A> = StateRootComputer< reth_trie_db::DatabaseTrieCursorFactory<&'a TX, A>, reth_trie_db::DatabaseHashedCursorFactory<&'a TX>, >; use serde::{Deserialize, Serialize}; use std::io::BufRead; use tracing::{debug, error, info, trace, warn}; pub use re...
Use
crates/storage/db-common/src/init.rs
//! Reth genesis initialization utility functions. use alloy_consensus::BlockHeader; use alloy_genesis::GenesisAccount; use alloy_primitives::{ keccak256, map::{AddressMap, B256Map, B256Set, HashMap}, Address, B256, U256, }; use reth_chainspec::EthChainSpec; use reth_codecs::Compact; use reth_config::confi...
use reth_trie_db::DatabaseStateRoot;
type DbStateRoot<'a, TX, A> = StateRootComputer< reth_trie_db::DatabaseTrieCursorFactory<&'a TX, A>, reth_trie_db::DatabaseHashedCursorFactory<&'a TX>, >; use serde::{Deserialize, Serialize}; use std::io::BufRead; use tracing::{debug, error, info, trace, warn}; pub use reth_provider::init::{ insert_accou...
Use
crates/storage/db-common/src/init.rs
//! Reth genesis initialization utility functions. use alloy_consensus::BlockHeader; use alloy_genesis::GenesisAccount; use alloy_primitives::{ keccak256, map::{AddressMap, B256Map, B256Set, HashMap}, Address, B256, U256, }; use reth_chainspec::EthChainSpec; use reth_codecs::Compact; use reth_config::confi...
type DbStateRoot<'a, TX, A> = StateRootComputer< reth_trie_db::DatabaseTrieCursorFactory<&'a TX, A>, reth_trie_db::DatabaseHashedCursorFactory<&'a TX>, >;
use serde::{Deserialize, Serialize}; use std::io::BufRead; use tracing::{debug, error, info, trace, warn}; pub use reth_provider::init::{ insert_account_history, insert_genesis_account_history, insert_genesis_history, insert_genesis_storage_history, insert_history, insert_storage_history, }; /// Default soft...
Other
crates/storage/db-common/src/init.rs
//! Reth genesis initialization utility functions. use alloy_consensus::BlockHeader; use alloy_genesis::GenesisAccount; use alloy_primitives::{ keccak256, map::{AddressMap, B256Map, B256Set, HashMap}, Address, B256, U256, }; use reth_chainspec::EthChainSpec; use reth_codecs::Compact; use reth_config::confi...
use serde::{Deserialize, Serialize};
use std::io::BufRead; use tracing::{debug, error, info, trace, warn}; pub use reth_provider::init::{ insert_account_history, insert_genesis_account_history, insert_genesis_history, insert_genesis_storage_history, insert_history, insert_storage_history, }; /// Default soft limit for number of bytes to read fro...
Use
crates/storage/db-common/src/init.rs
//! Reth genesis initialization utility functions. use alloy_consensus::BlockHeader; use alloy_genesis::GenesisAccount; use alloy_primitives::{ keccak256, map::{AddressMap, B256Map, B256Set, HashMap}, Address, B256, U256, }; use reth_chainspec::EthChainSpec; use reth_codecs::Compact; use reth_config::confi...
use std::io::BufRead;
use tracing::{debug, error, info, trace, warn}; pub use reth_provider::init::{ insert_account_history, insert_genesis_account_history, insert_genesis_history, insert_genesis_storage_history, insert_history, insert_storage_history, }; /// Default soft limit for number of bytes to read from state dump file, bef...
Use
crates/storage/db-common/src/init.rs
//! Reth genesis initialization utility functions. use alloy_consensus::BlockHeader; use alloy_genesis::GenesisAccount; use alloy_primitives::{ keccak256, map::{AddressMap, B256Map, B256Set, HashMap}, Address, B256, U256, }; use reth_chainspec::EthChainSpec; use reth_codecs::Compact; use reth_config::confi...
use tracing::{debug, error, info, trace, warn};
pub use reth_provider::init::{ insert_account_history, insert_genesis_account_history, insert_genesis_history, insert_genesis_storage_history, insert_history, insert_storage_history, }; /// Default soft limit for number of bytes to read from state dump file, before inserting into /// database. /// /// Default...
Use
crates/storage/db-common/src/init.rs
//! Reth genesis initialization utility functions. use alloy_consensus::BlockHeader; use alloy_genesis::GenesisAccount; use alloy_primitives::{ keccak256, map::{AddressMap, B256Map, B256Set, HashMap}, Address, B256, U256, }; use reth_chainspec::EthChainSpec; use reth_codecs::Compact; use reth_config::confi...
pub use reth_provider::init::{ insert_account_history, insert_genesis_account_history, insert_genesis_history, insert_genesis_storage_history, insert_history, insert_storage_history, };
/// Default soft limit for number of bytes to read from state dump file, before inserting into /// database. /// /// Default is 1 GB. pub const DEFAULT_SOFT_LIMIT_BYTE_LEN_ACCOUNTS_CHUNK: usize = 1_000_000_000; /// Soft limit for the number of flushed updates after which to log progress summary. const SOFT_LIMIT_COUN...
Use
crates/storage/db-common/src/init.rs
//! Reth genesis initialization utility functions. use alloy_consensus::BlockHeader; use alloy_genesis::GenesisAccount; use alloy_primitives::{ keccak256, map::{AddressMap, B256Map, B256Set, HashMap}, Address, B256, U256, }; use reth_chainspec::EthChainSpec; use reth_codecs::Compact; use reth_config::confi...
/// Default soft limit for number of bytes to read from state dump file, before inserting into /// database. /// /// Default is 1 GB. pub const DEFAULT_SOFT_LIMIT_BYTE_LEN_ACCOUNTS_CHUNK: usize = 1_000_000_000;
/// Soft limit for the number of flushed updates after which to log progress summary. const SOFT_LIMIT_COUNT_FLUSHED_UPDATES: usize = 1_000_000; /// Max number of storage "units" (1 per account + 1 per storage slot) before committing /// the current MDBX transaction and opening a new one. This bounds dirty page accum...
Const
crates/storage/db-common/src/init.rs
//! Reth genesis initialization utility functions. use alloy_consensus::BlockHeader; use alloy_genesis::GenesisAccount; use alloy_primitives::{ keccak256, map::{AddressMap, B256Map, B256Set, HashMap}, Address, B256, U256, }; use reth_chainspec::EthChainSpec; use reth_codecs::Compact; use reth_config::confi...
/// Soft limit for the number of flushed updates after which to log progress summary. const SOFT_LIMIT_COUNT_FLUSHED_UPDATES: usize = 1_000_000;
/// Max number of storage "units" (1 per account + 1 per storage slot) before committing /// the current MDBX transaction and opening a new one. This bounds dirty page accumulation /// and prevents OOM on large state imports. const STORAGE_COMMIT_THRESHOLD: usize = 100_000; /// Max number of trie updates retained bef...
Const
crates/storage/db-common/src/init.rs
//! Reth genesis initialization utility functions. use alloy_consensus::BlockHeader; use alloy_genesis::GenesisAccount; use alloy_primitives::{ keccak256, map::{AddressMap, B256Map, B256Set, HashMap}, Address, B256, U256, }; use reth_chainspec::EthChainSpec; use reth_codecs::Compact; use reth_config::confi...
/// Max number of storage "units" (1 per account + 1 per storage slot) before committing /// the current MDBX transaction and opening a new one. This bounds dirty page accumulation /// and prevents OOM on large state imports. const STORAGE_COMMIT_THRESHOLD: usize = 100_000;
/// Max number of trie updates retained before init-state state root computation commits progress. const STATE_ROOT_COMMIT_THRESHOLD: u64 = 25_000; /// Storage initialization error type. #[derive(Debug, thiserror::Error, Clone)] pub enum InitStorageError { /// Genesis header found on static files but the database...
Const
crates/storage/db-common/src/init.rs
//! Reth genesis initialization utility functions. use alloy_consensus::BlockHeader; use alloy_genesis::GenesisAccount; use alloy_primitives::{ keccak256, map::{AddressMap, B256Map, B256Set, HashMap}, Address, B256, U256, }; use reth_chainspec::EthChainSpec; use reth_codecs::Compact; use reth_config::confi...
/// Max number of trie updates retained before init-state state root computation commits progress. const STATE_ROOT_COMMIT_THRESHOLD: u64 = 25_000;
/// Storage initialization error type. #[derive(Debug, thiserror::Error, Clone)] pub enum InitStorageError { /// Genesis header found on static files but the database is empty. #[error( "static files found, but the database is uninitialized. If attempting to re-syncing, delete both." )] Uniniti...
Const
crates/storage/db-common/src/init.rs
//! Reth genesis initialization utility functions. use alloy_consensus::BlockHeader; use alloy_genesis::GenesisAccount; use alloy_primitives::{ keccak256, map::{AddressMap, B256Map, B256Set, HashMap}, Address, B256, U256, }; use reth_chainspec::EthChainSpec; use reth_codecs::Compact; use reth_config::confi...
/// Storage initialization error type. #[derive(Debug, thiserror::Error, Clone)] pub enum InitStorageError { /// Genesis header found on static files but the database is empty. #[error( "static files found, but the database is uninitialized. If attempting to re-syncing, delete both." )] Uninitia...
impl From<DatabaseError> for InitStorageError { fn from(error: DatabaseError) -> Self { Self::Provider(ProviderError::Database(error)) } } /// Write the genesis block if it has not already been written pub fn init_genesis<PF>(factory: &PF) -> Result<B256, InitStorageError> where PF: DatabaseProvid...
Enum
crates/storage/db-common/src/init.rs
//! Reth genesis initialization utility functions. use alloy_consensus::BlockHeader; use alloy_genesis::GenesisAccount; use alloy_primitives::{ keccak256, map::{AddressMap, B256Map, B256Set, HashMap}, Address, B256, U256, }; use reth_chainspec::EthChainSpec; use reth_codecs::Compact; use reth_config::confi...
impl From<DatabaseError> for InitStorageError { fn from(error: DatabaseError) -> Self { Self::Provider(ProviderError::Database(error)) } }
/// Write the genesis block if it has not already been written pub fn init_genesis<PF>(factory: &PF) -> Result<B256, InitStorageError> where PF: DatabaseProviderFactory + StaticFileProviderFactory<Primitives: NodePrimitives<BlockHeader: Compact>> + ChainSpecProvider + StageCheckpointReader ...
Impl
crates/storage/db-common/src/init.rs
//! Reth genesis initialization utility functions. use alloy_consensus::BlockHeader; use alloy_genesis::GenesisAccount; use alloy_primitives::{ keccak256, map::{AddressMap, B256Map, B256Set, HashMap}, Address, B256, U256, }; use reth_chainspec::EthChainSpec; use reth_codecs::Compact; use reth_config::confi...
fn from(error: DatabaseError) -> Self { Self::Provider(ProviderError::Database(error)) }
} /// Write the genesis block if it has not already been written pub fn init_genesis<PF>(factory: &PF) -> Result<B256, InitStorageError> where PF: DatabaseProviderFactory + StaticFileProviderFactory<Primitives: NodePrimitives<BlockHeader: Compact>> + ChainSpecProvider + StageCheckpointReade...
Function
crates/storage/db-common/src/init.rs
nesisAccount; use alloy_primitives::{ keccak256, map::{AddressMap, B256Map, B256Set, HashMap}, Address, B256, U256, }; use reth_chainspec::EthChainSpec; use reth_codecs::Compact; use reth_config::config::EtlConfig; use reth_db_api::{ cursor::{DbCursorRW, DbDupCursorRW}, models::{ storage_sha...
{ Self::Provider(ProviderError::Database(error)) }
} /// Write the genesis block if it has not already been written pub fn init_genesis<PF>(factory: &PF) -> Result<B256, InitStorageError> where PF: DatabaseProviderFactory + StaticFileProviderFactory<Primitives: NodePrimitives<BlockHeader: Compact>> + ChainSpecProvider + StageCheckpointRead...
FunctionBody
crates/storage/db-common/src/init.rs
//! Reth genesis initialization utility functions. use alloy_consensus::BlockHeader; use alloy_genesis::GenesisAccount; use alloy_primitives::{ keccak256, map::{AddressMap, B256Map, B256Set, HashMap}, Address, B256, U256, }; use reth_chainspec::EthChainSpec; use reth_codecs::Compact; use reth_config::confi...
pub fn init_genesis<PF>(factory: &PF) -> Result<B256, InitStorageError> where PF: DatabaseProviderFactory + StaticFileProviderFactory<Primitives: NodePrimitives<BlockHeader: Compact>> + ChainSpecProvider + StageCheckpointReader + BlockNumReader + MetadataProvider + St...
/// Write the genesis block if it has not already been written with [`StorageSettings`]. pub fn init_genesis_with_settings<PF>( factory: &PF, genesis_storage_settings: StorageSettings, ) -> Result<B256, InitStorageError> where PF: DatabaseProviderFactory + StaticFileProviderFactory<Primitives: Node...
Function
crates/storage/db-common/src/init.rs
NodePrimitivesProvider, OriginalValuesKnown, ProviderError, RevertsInit, RocksDBProviderFactory, StageCheckpointReader, StageCheckpointWriter, StateWriteConfig, StateWriter, StaticFileProviderFactory, StorageSettings, StorageSettingsCache, TrieWriter, }; use reth_stages_types::{StageCheckpoint, StageId}; use ...
{ init_genesis_with_settings(factory, StorageSettings::base()) }
/// Write the genesis block if it has not already been written with [`StorageSettings`]. pub fn init_genesis_with_settings<PF>( factory: &PF, genesis_storage_settings: StorageSettings, ) -> Result<B256, InitStorageError> where PF: DatabaseProviderFactory + StaticFileProviderFactory<Primitives: Nod...
FunctionBody
crates/storage/db-common/src/init.rs
actory<&'a TX, A>, reth_trie_db::DatabaseHashedCursorFactory<&'a TX>, >; use serde::{Deserialize, Serialize}; use std::io::BufRead; use tracing::{debug, error, info, trace, warn}; pub use reth_provider::init::{ insert_account_history, insert_genesis_account_history, insert_genesis_history, insert_genesis_...
pub fn init_genesis_with_settings<PF>( factory: &PF, genesis_storage_settings: StorageSettings, ) -> Result<B256, InitStorageError> where PF: DatabaseProviderFactory + StaticFileProviderFactory<Primitives: NodePrimitives<BlockHeader: Compact>> + ChainSpecProvider + StageCheckpointRea...
/// Write the genesis block if it has not already been written with [`StorageSettings`], /// optionally validating the DB-resident genesis hash against the chainspec hash. pub fn init_genesis_with_settings_and_validate<PF>( factory: &PF, genesis_storage_settings: StorageSettings, validate_genesis_hash: boo...
Function
crates/storage/db-common/src/init.rs
//! Reth genesis initialization utility functions. use alloy_consensus::BlockHeader; use alloy_genesis::GenesisAccount; use alloy_primitives::{ keccak256, map::{AddressMap, B256Map, B256Set, HashMap}, Address, B256, U256, }; use reth_chainspec::EthChainSpec; use reth_codecs::Compact; use reth_config::confi...
{ init_genesis_with_settings_and_validate(factory, genesis_storage_settings, true) }
/// Write the genesis block if it has not already been written with [`StorageSettings`], /// optionally validating the DB-resident genesis hash against the chainspec hash. pub fn init_genesis_with_settings_and_validate<PF>( factory: &PF, genesis_storage_settings: StorageSettings, validate_genesis_hash: bo...
FunctionBody
crates/storage/db-common/src/init.rs
f bytes to read from state dump file, before inserting into /// database. /// /// Default is 1 GB. pub const DEFAULT_SOFT_LIMIT_BYTE_LEN_ACCOUNTS_CHUNK: usize = 1_000_000_000; /// Soft limit for the number of flushed updates after which to log progress summary. const SOFT_LIMIT_COUNT_FLUSHED_UPDATES: usize = 1_000_000...
{ let chain = factory.chain_spec(); let genesis = chain.genesis(); let hash = chain.genesis_hash(); // Get the genesis block number from the chain spec let genesis_block_number = chain.genesis_header().number(); // Check if we already have the genesis header or if we have the wrong one. m...
/// Inserts the genesis state into the database. pub fn insert_genesis_state<'a, 'b, Provider>( provider: &Provider, alloc: impl Iterator<Item = (&'a Address, &'b GenesisAccount)>, ) -> ProviderResult<()> where Provider: StaticFileProviderFactory + DBProvider<Tx: DbTxMut> + HeaderProvider ...
FunctionBody
crates/storage/db-common/src/init.rs
b fn init_genesis_with_settings<PF>( factory: &PF, genesis_storage_settings: StorageSettings, ) -> Result<B256, InitStorageError> where PF: DatabaseProviderFactory + StaticFileProviderFactory<Primitives: NodePrimitives<BlockHeader: Compact>> + ChainSpecProvider + StageCheckpointReade...
pub fn insert_genesis_state<'a, 'b, Provider>( provider: &Provider, alloc: impl Iterator<Item = (&'a Address, &'b GenesisAccount)>, ) -> ProviderResult<()> where Provider: StaticFileProviderFactory + DBProvider<Tx: DbTxMut> + HeaderProvider + StateWriter + ChainSpecProvider ...
/// Inserts state at given block into database. pub fn insert_state<'a, 'b, Provider>( provider: &Provider, alloc: impl Iterator<Item = (&'a Address, &'b GenesisAccount)>, block: u64, ) -> ProviderResult<()> where Provider: StaticFileProviderFactory + DBProvider<Tx: DbTxMut> + HeaderPro...
Function
crates/storage/db-common/src/init.rs
return Ok(block_hash) } return Err(InitStorageError::GenesisHashMismatch { chainspec_hash: hash, storage_hash: block_hash, }) } Err(e) => { debug!(?e); return Err(e.into()); } } debug!("Writi...
{ let genesis_block_number = provider.chain_spec().genesis_header().number(); insert_state(provider, alloc, genesis_block_number) }
/// Inserts state at given block into database. pub fn insert_state<'a, 'b, Provider>( provider: &Provider, alloc: impl Iterator<Item = (&'a Address, &'b GenesisAccount)>, block: u64, ) -> ProviderResult<()> where Provider: StaticFileProviderFactory + DBProvider<Tx: DbTxMut> + HeaderPr...
FunctionBody
crates/storage/db-common/src/init.rs
r); } if genesis_storage_settings.storage_v2 { static_file_provider .get_writer(genesis_block_number, StaticFileSegment::StorageChangeSets)? .user_header_mut() .set_expected_block_start(genesis_block_number); } } insert_genesis...
pub fn insert_state<'a, 'b, Provider>( provider: &Provider, alloc: impl Iterator<Item = (&'a Address, &'b GenesisAccount)>, block: u64, ) -> ProviderResult<()> where Provider: StaticFileProviderFactory + DBProvider<Tx: DbTxMut> + HeaderProvider + StateWriter + AsRef<Provi...
/// Inserts hashes for the genesis state. pub fn insert_genesis_hashes<'a, 'b, Provider>( provider: &Provider, alloc: impl Iterator<Item = (&'a Address, &'b GenesisAccount)> + Clone, ) -> ProviderResult<()> where Provider: DBProvider<Tx: DbTxMut> + HashingWriter, { // insert and hash accounts to hashin...
Function
crates/storage/db-common/src/init.rs
t::StorageChangeSets)? .user_header_mut() .set_expected_block_start(genesis_block_number); } } insert_genesis_hashes(&provider_rw, alloc.iter())?; insert_genesis_history(&provider_rw, alloc.iter())?; // Insert header insert_genesis_header(&provider_rw, &chai...
{ let capacity = alloc.size_hint().1.unwrap_or(0); let mut state_init: BundleStateInit = AddressMap::with_capacity_and_hasher(capacity, Default::default()); let mut reverts_init: AddressMap<_> = AddressMap::with_capacity_and_hasher(capacity, Default::default()); let mut contracts: B256Ma...
/// Inserts hashes for the genesis state. pub fn insert_genesis_hashes<'a, 'b, Provider>( provider: &Provider, alloc: impl Iterator<Item = (&'a Address, &'b GenesisAccount)> + Clone, ) -> ProviderResult<()> where Provider: DBProvider<Tx: DbTxMut> + HashingWriter, { // insert and hash accounts to hashi...
FunctionBody
crates/storage/db-common/src/init.rs
ted = ?genesis_storage_settings, "Storage settings mismatch detected. Using the stored settings from the existing database." ); } debug!("Genesis already written, skipping."); return Ok(hash) } if !vali...
pub fn insert_genesis_hashes<'a, 'b, Provider>( provider: &Provider, alloc: impl Iterator<Item = (&'a Address, &'b GenesisAccount)> + Clone, ) -> ProviderResult<()> where Provider: DBProvider<Tx: DbTxMut> + HashingWriter, { // insert and hash accounts to hashing table let alloc_accounts = alloc.clon...
/// Inserts header for the genesis state. pub fn insert_genesis_header<Provider, Spec>( provider: &Provider, chain: &Spec, ) -> ProviderResult<()> where Provider: StaticFileProviderFactory<Primitives: NodePrimitives<BlockHeader: Compact>> + DBProvider<Tx: DbTxMut>, Spec: EthChainSpec<Header = <...
Function
crates/storage/db-common/src/init.rs
ngs from the existing database." ); } debug!("Genesis already written, skipping."); return Ok(hash) } if !validate_genesis_hash { warn!( target: "reth::storage", chainspe...
{ // insert and hash accounts to hashing table let alloc_accounts = alloc.clone().map(|(addr, account)| (*addr, Some(Account::from(account)))); provider.insert_account_for_hashing(alloc_accounts)?; trace!(target: "reth::cli", "Inserted account hashes"); let alloc_storage = alloc.filter_map(|(addr,...
/// Inserts header for the genesis state. pub fn insert_genesis_header<Provider, Spec>( provider: &Provider, chain: &Spec, ) -> ProviderResult<()> where Provider: StaticFileProviderFactory<Primitives: NodePrimitives<BlockHeader: Compact>> + DBProvider<Tx: DbTxMut>, Spec: EthChainSpec<Header = ...
FunctionBody
crates/storage/db-common/src/init.rs
let bytecode_hash = if let Some(code) = &account.code { match Bytecode::new_raw_checked(code.clone()) { Ok(bytecode) => { let hash = bytecode.hash_slow(); contracts.insert(hash, bytecode); Some(hash) } ...
pub fn insert_genesis_header<Provider, Spec>( provider: &Provider, chain: &Spec, ) -> ProviderResult<()> where Provider: StaticFileProviderFactory<Primitives: NodePrimitives<BlockHeader: Compact>> + DBProvider<Tx: DbTxMut>, Spec: EthChainSpec<Header = <Provider::Primitives as NodePrimitives>::Bl...
/// Reads account state from a [`BufRead`] reader and initializes it at the highest block that can /// be found on database. /// /// It's similar to [`init_genesis`] but supports importing state too big to fit in memory, and can /// be set to the highest block present. One practical usecase is to import OP mainnet sta...
Function
crates/storage/db-common/src/init.rs
block number. This would cause increment_block(N) to fail. let static_file_provider = provider_rw.static_file_provider(); if genesis_block_number > 0 { if genesis_storage_settings.storage_v2 { static_file_provider .get_writer(genesis_block_number, StaticFileSegment::AccountC...
{ let (header, block_hash) = (chain.genesis_header(), chain.genesis_hash()); let static_file_provider = provider.static_file_provider(); // Get the actual genesis block number from the header let genesis_block_number = header.number(); match static_file_provider.block_hash(genesis_block_number) { ...
/// Reads account state from a [`BufRead`] reader and initializes it at the highest block that can /// be found on database. /// /// It's similar to [`init_genesis`] but supports importing state too big to fit in memory, and can /// be set to the highest block present. One practical usecase is to import OP mainnet st...
FunctionBody
crates/storage/db-common/src/init.rs
sAccount)>, block: u64, ) -> ProviderResult<()> where Provider: StaticFileProviderFactory + DBProvider<Tx: DbTxMut> + HeaderProvider + StateWriter + AsRef<Provider>, { let capacity = alloc.size_hint().1.unwrap_or(0); let mut state_init: BundleStateInit = AddressMa...
pub fn init_from_state_dump<PF>( mut reader: impl BufRead, provider_factory: &PF, etl_config: EtlConfig, ) -> eyre::Result<B256> where PF: DatabaseProviderFactory< ProviderRW: StaticFileProviderFactory + DBProvider<Tx: DbTxMut> + BlockNumReader ...
/// Parses and returns expected state root. fn parse_state_root(reader: &mut impl BufRead) -> eyre::Result<B256> { let mut line = String::new(); reader.read_line(&mut line)?; let expected_state_root = serde_json::from_str::<StateRoot>(&line)?.root; trace!(target: "reth::cli", root=%expected_st...
Function
crates/storage/db-common/src/init.rs
AddressMap::with_capacity_and_hasher(capacity, Default::default()); let mut contracts: B256Map<Bytecode> = B256Map::with_capacity_and_hasher(capacity, Default::default()); for (address, account) in alloc { let bytecode_hash = if let Some(code) = &account.code { match Bytecode::...
{ if etl_config.file_size == 0 { return Err(eyre::eyre!("ETL file size cannot be zero")) } let (block, hash, expected_state_root) = { let provider_rw = provider_factory.database_provider_rw()?; let block = provider_rw.last_block_number()?; let hash = provider_rw ...
/// Parses and returns expected state root. fn parse_state_root(reader: &mut impl BufRead) -> eyre::Result<B256> { let mut line = String::new(); reader.read_line(&mut line)?; let expected_state_root = serde_json::from_str::<StateRoot>(&line)?.root; trace!(target: "reth::cli", root=%expected_s...
FunctionBody
crates/storage/db-common/src/init.rs
evertsInit = HashMap::from_iter([(block, reverts_init)]); let execution_outcome = ExecutionOutcome::new_init( state_init, all_reverts_init, contracts, Vec::default(), block, Vec::new(), ); provider.write_state( &execution_outcome, OriginalVal...
fn parse_state_root(reader: &mut impl BufRead) -> eyre::Result<B256> { let mut line = String::new(); reader.read_line(&mut line)?; let expected_state_root = serde_json::from_str::<StateRoot>(&line)?.root; trace!(target: "reth::cli", root=%expected_state_root, "Read state root from file"...
/// Parses accounts and pushes them to a [`Collector`]. fn parse_accounts( reader: impl BufRead, etl_config: EtlConfig, ) -> Result<Collector<Address, GenesisAccount>, eyre::Error> { let mut collector = Collector::new(etl_config.file_size, etl_config.dir); let mut parsed_accounts = 0usize; let str...
Function
crates/storage/db-common/src/init.rs
aseProviderFactory< ProviderRW: StaticFileProviderFactory + DBProvider<Tx: DbTxMut> + BlockNumReader + BlockHashReader + ChainSpecProvider + StageCheckpointWriter + His...
{ let mut line = String::new(); reader.read_line(&mut line)?; let expected_state_root = serde_json::from_str::<StateRoot>(&line)?.root; trace!(target: "reth::cli", root=%expected_state_root, "Read state root from file" ); Ok(expected_state_root) }
/// Parses accounts and pushes them to a [`Collector`]. fn parse_accounts( reader: impl BufRead, etl_config: EtlConfig, ) -> Result<Collector<Address, GenesisAccount>, eyre::Error> { let mut collector = Collector::new(etl_config.file_size, etl_config.dir); let mut parsed_accounts = 0usize; let st...
FunctionBody
crates/storage/db-common/src/init.rs
a Address, &'b GenesisAccount)> + Clone, ) -> ProviderResult<()> where Provider: DBProvider<Tx: DbTxMut> + HashingWriter, { // insert and hash accounts to hashing table let alloc_accounts = alloc.clone().map(|(addr, account)| (*addr, Some(Account::from(account)))); provider.insert_account_for_hashing(al...
fn parse_accounts( reader: impl BufRead, etl_config: EtlConfig, ) -> Result<Collector<Address, GenesisAccount>, eyre::Error> { let mut collector = Collector::new(etl_config.file_size, etl_config.dir); let mut parsed_accounts = 0usize; let stream = serde_json::Deserializer::from_reader(reade...
/// Takes a [`Collector`] and writes all accounts directly to database tables. /// /// This bypasses the higher-level `insert_state`/`insert_genesis_hashes`/`insert_history` /// functions which build intermediate structures (`BundleStateInit`, `RevertsInit`, /// `ExecutionOutcome`) that duplicate all storage data 2-3x...
Function
crates/storage/db-common/src/init.rs
er + AsRef<PF::ProviderRW>, >, { if etl_config.file_size == 0 { return Err(eyre::eyre!("ETL file size cannot be zero")) } let (block, hash, expected_state_root) = { let provider_rw = provider_factory.database_provider_rw()?; let block = provider_rw.last_b...
{ let mut collector = Collector::new(etl_config.file_size, etl_config.dir); let mut parsed_accounts = 0usize; let stream = serde_json::Deserializer::from_reader(reader).into_iter::<GenesisAccountWithAddress>(); for account in stream { let GenesisAccountWithAddress { genesis_account, add...
/// Takes a [`Collector`] and writes all accounts directly to database tables. /// /// This bypasses the higher-level `insert_state`/`insert_genesis_hashes`/`insert_history` /// functions which build intermediate structures (`BundleStateInit`, `RevertsInit`, /// `ExecutionOutcome`) that duplicate all storage data 2-3...
FunctionBody
crates/storage/db-common/src/init.rs
et: "reth::cli", ?computed_state_root, ?expected_state_root, "Computed state root does not match state root in state dump" ); return Err(InitStorageError::StateRootMismatch(GotExpected { got: computed_state_root, expected: expected_state_root,...
fn dump_state<PF>( mut collector: Collector<Address, GenesisAccount>, provider_factory: &PF, block: u64, ) -> Result<(), eyre::Error> where PF: DatabaseProviderFactory<ProviderRW: DBProvider<Tx: DbTxMut>>, PF::ProviderRW: StaticFileProviderFactory + StorageSettingsCache + RocksDBProv...
fn dump_state_v2<PF>( mut collector: Collector<Address, GenesisAccount>, provider_factory: &PF, block: u64, ) -> Result<(), eyre::Error> where PF: DatabaseProviderFactory< ProviderRW: StaticFileProviderFactory + DBProvider<Tx: DbTxMut> + StorageSe...
Function
crates/storage/db-common/src/init.rs
urn Err(InitStorageError::StateRootMismatch(GotExpected { got: computed_state_root, expected: expected_state_root, }) .into()) } // insert sync stages for stages that require state { let provider_rw = provider_factory.database_provider_rw()?; for stag...
{ let storage_settings = provider_factory.database_provider_rw()?.cached_storage_settings(); if storage_settings.storage_v2 { return dump_state_v2(collector, provider_factory, block) } let accounts_len = collector.len(); let mut total_accounts: usize = 0; let mut storage_units: usize = ...
fn dump_state_v2<PF>( mut collector: Collector<Address, GenesisAccount>, provider_factory: &PF, block: u64, ) -> Result<(), eyre::Error> where PF: DatabaseProviderFactory< ProviderRW: StaticFileProviderFactory + DBProvider<Tx: DbTxMut> + StorageS...
FunctionBody
crates/storage/db-common/src/init.rs
o!(target: "reth::cli", "All accounts written to database, starting state root computation (may take some time)"); // clear trie tables so state root is computed from scratch { let provider_rw = provider_factory.database_provider_rw()?; provider_rw.tx_ref().clear::<tables::AccountsTrie>()?; ...
fn dump_state_v2<PF>( mut collector: Collector<Address, GenesisAccount>, provider_factory: &PF, block: u64, ) -> Result<(), eyre::Error> where PF: DatabaseProviderFactory< ProviderRW: StaticFileProviderFactory + DBProvider<Tx: DbTxMut> + StorageSet...
fn prepare_account_changeset_writer<N: NodePrimitives>( writer: &mut reth_provider::providers::StaticFileProviderRWRefMut<'_, N>, block: u64, ) -> ProviderResult<()> { let next_block = writer.next_block_number(); if next_block < block { info!( target: "reth::cli", from_b...
Function
crates/storage/db-common/src/init.rs
er_factory.database_provider_rw()?; provider_rw.tx_ref().clear::<tables::AccountsTrie>()?; provider_rw.tx_ref().clear::<tables::StoragesTrie>()?; provider_rw.commit()?; } // compute and compare state root let computed_state_root = compute_state_root_chunked(provider_factory)?; i...
{ let accounts_len = collector.len(); let mut total_accounts: usize = 0; let mut storage_units: usize = 0; // pre-allocate the history list once — every entry uses the same single-block bitmap let history_list = IntegerList::new([block])?; // track seen bytecode hashes to avoid re-hashing and ...
fn prepare_account_changeset_writer<N: NodePrimitives>( writer: &mut reth_provider::providers::StaticFileProviderRWRefMut<'_, N>, block: u64, ) -> ProviderResult<()> { let next_block = writer.next_block_number(); if next_block < block { info!( target: "reth::cli", from_...
FunctionBody
crates/storage/db-common/src/init.rs
+ RocksDBProviderFactory + NodePrimitivesProvider, >, { let accounts_len = collector.len(); let mut total_accounts: usize = 0; let mut storage_units: usize = 0; // pre-allocate the history list once — every entry uses the same single-block bitmap let history_list = I...
fn prepare_account_changeset_writer<N: NodePrimitives>( writer: &mut reth_provider::providers::StaticFileProviderRWRefMut<'_, N>, block: u64, ) -> ProviderResult<()> { let next_block = writer.next_block_number(); if next_block < block { info!( target: "reth::cli", from_bl...
fn prepare_storage_changeset_writer<N: NodePrimitives>( writer: &mut reth_provider::providers::StaticFileProviderRWRefMut<'_, N>, block: u64, ) -> ProviderResult<()> { let next_block = writer.next_block_number(); if next_block < block { info!( target: "reth::cli", from_b...
Function
crates/storage/db-common/src/init.rs
ultiple_of(100_000) { info!(target: "reth::cli", parsed_accounts, "Parsed accounts"); } } Ok(collector) } /// Takes a [`Collector`] and writes all accounts directly to database tables. /// /// This bypasses the higher-level `insert_state`/`insert_genesis_hashes`/`insert_history` /// functi...
{ let next_block = writer.next_block_number(); if next_block < block { info!( target: "reth::cli", from_block = next_block, to_block = block - 1, "Padding empty account changesets before state import" ); for empty_block in next_block..block...
fn prepare_storage_changeset_writer<N: NodePrimitives>( writer: &mut reth_provider::providers::StaticFileProviderRWRefMut<'_, N>, block: u64, ) -> ProviderResult<()> { let next_block = writer.next_block_number(); if next_block < block { info!( target: "reth::cli", from_...
FunctionBody
crates/storage/db-common/src/init.rs
Segment::AccountChangeSets, block, )?; reset_pre_snapshot_changeset_segment( &static_file_provider, StaticFileSegment::StorageChangeSets, block, )?; } { let mut account_changeset_writer = static_file_provider.get_writer...
fn prepare_storage_changeset_writer<N: NodePrimitives>( writer: &mut reth_provider::providers::StaticFileProviderRWRefMut<'_, N>, block: u64, ) -> ProviderResult<()> { let next_block = writer.next_block_number(); if next_block < block { info!( target: "reth::cli", from_bl...
fn snapshot_state_tables_empty<TX: reth_db_api::transaction::DbTx>( tx: &TX, ) -> ProviderResult<bool> { Ok(tx.entries::<tables::PlainAccountState>()? == 0 && tx.entries::<tables::PlainStorageState>()? == 0 && tx.entries::<tables::HashedAccounts>()? == 0 && tx.entries::<tables::HashedSt...
Function
crates/storage/db-common/src/init.rs
crashes mid-import, the database /// must be wiped before retrying. fn dump_state<PF>( mut collector: Collector<Address, GenesisAccount>, provider_factory: &PF, block: u64, ) -> Result<(), eyre::Error> where PF: DatabaseProviderFactory<ProviderRW: DBProvider<Tx: DbTxMut>>, PF::ProviderRW: StaticFil...
{ let next_block = writer.next_block_number(); if next_block < block { info!( target: "reth::cli", from_block = next_block, to_block = block - 1, "Padding empty storage changesets before state import" ); for empty_block in next_block..block...
fn snapshot_state_tables_empty<TX: reth_db_api::transaction::DbTx>( tx: &TX, ) -> ProviderResult<bool> { Ok(tx.entries::<tables::PlainAccountState>()? == 0 && tx.entries::<tables::PlainStorageState>()? == 0 && tx.entries::<tables::HashedAccounts>()? == 0 && tx.entries::<tables::HashedS...
FunctionBody
crates/storage/db-common/src/init.rs
let (address_raw, account_raw) = entry?; let (address, _) = Address::from_compact(address_raw.as_slice(), address_raw.len()); let (account, _) = GenesisAccount::from_compact(account_raw.as_slice(), account_raw.len()); let account_storage_len = account.storage.a...
fn snapshot_state_tables_empty<TX: reth_db_api::transaction::DbTx>( tx: &TX, ) -> ProviderResult<bool> { Ok(tx.entries::<tables::PlainAccountState>()? == 0 && tx.entries::<tables::PlainStorageState>()? == 0 && tx.entries::<tables::HashedAccounts>()? == 0 && tx.entries::<tables::HashedSto...
fn reset_pre_snapshot_changeset_segment<N: NodePrimitives>( static_file_provider: &reth_provider::providers::StaticFileProvider<N>, segment: StaticFileSegment, block: u64, ) -> ProviderResult<()> { if block == 0 { return Ok(()) } let Some(highest_block) = static_file_provider.get_highe...
Function
crates/storage/db-common/src/init.rs
); let mut total_accounts: usize = 0; let mut storage_units: usize = 0; // pre-allocate the history list once — every entry uses the same single-block bitmap let history_list = IntegerList::new([block])?; // track seen bytecode hashes to avoid re-hashing and re-writing duplicates let mut seen_...
{ Ok(tx.entries::<tables::PlainAccountState>()? == 0 && tx.entries::<tables::PlainStorageState>()? == 0 && tx.entries::<tables::HashedAccounts>()? == 0 && tx.entries::<tables::HashedStorages>()? == 0 && tx.entries::<tables::AccountChangeSets>()? == 0 && tx.entries::<tables::S...
fn reset_pre_snapshot_changeset_segment<N: NodePrimitives>( static_file_provider: &reth_provider::providers::StaticFileProvider<N>, segment: StaticFileSegment, block: u64, ) -> ProviderResult<()> { if block == 0 { return Ok(()) } let Some(highest_block) = static_file_provider.get_high...
FunctionBody
crates/storage/db-common/src/init.rs
)); let (account, _) = GenesisAccount::from_compact(account_raw.as_slice(), account_raw.len()); let account_storage_len = account.storage.as_ref().map_or(0, |s| s.len()); let account_units = 1 + account_storage_len; // commit before this account would push us over the threshold ...
fn reset_pre_snapshot_changeset_segment<N: NodePrimitives>( static_file_provider: &reth_provider::providers::StaticFileProvider<N>, segment: StaticFileSegment, block: u64, ) -> ProviderResult<()> { if block == 0 { return Ok(()) } let Some(highest_block) = static_file_provider.get_highes...
fn commit_mdbx_only<Provider>(provider: Provider) -> ProviderResult<()> where Provider: DBProvider<Tx: DbTxMut>, { reth_db_api::transaction::DbTx::commit(provider.into_tx()).map_err(ProviderError::from) } /// Writes a single account and all its storage to every required DB table directly, /// without building...
Function
crates/storage/db-common/src/init.rs
let account_storage_len = account.storage.as_ref().map_or(0, |s| s.len()); let account_units = 1 + account_storage_len; // commit before this account would push us over the threshold if storage_units > 0 && storage_units + account_units > STORAGE_COMMIT_THRESHOLD { provider...
{ if block == 0 { return Ok(()) } let Some(highest_block) = static_file_provider.get_highest_static_file_block(segment) else { return Ok(()) }; if highest_block >= block { return Ok(()) } let file_start = static_file_provider.find_fixed_range(segment, block).start(...
fn commit_mdbx_only<Provider>(provider: Provider) -> ProviderResult<()> where Provider: DBProvider<Tx: DbTxMut>, { reth_db_api::transaction::DbTx::commit(provider.into_tx()).map_err(ProviderError::from) } /// Writes a single account and all its storage to every required DB table directly, /// without buildin...
FunctionBody
crates/storage/db-common/src/init.rs
info!(target: "reth::cli", total_accounts, accounts_len, storage_units, "Committed chunk" ); storage_units = 0; seen_bytecodes = B256Set::default(); } write_account_to_db( provider_rw.t...
fn commit_mdbx_only<Provider>(provider: Provider) -> ProviderResult<()> where Provider: DBProvider<Tx: DbTxMut>, { reth_db_api::transaction::DbTx::commit(provider.into_tx()).map_err(ProviderError::from) }
/// Writes a single account and all its storage to every required DB table directly, /// without building intermediary structures. /// /// Uses `append_dup` for `DupSort` tables where insertion order matches key order (the ETL /// collector sorts by address, so `AccountChangeSets`, `PlainStorageState`, and /// `Storag...
Function
crates/storage/db-common/src/init.rs
ounts, accounts_len, storage_units, "Committed chunk" ); storage_units = 0; seen_bytecodes = B256Set::default(); } write_account_to_db( provider_rw.tx_ref(), &address, &account, ...
{ reth_db_api::transaction::DbTx::commit(provider.into_tx()).map_err(ProviderError::from) }
/// Writes a single account and all its storage to every required DB table directly, /// without building intermediary structures. /// /// Uses `append_dup` for `DupSort` tables where insertion order matches key order (the ETL /// collector sorts by address, so `AccountChangeSets`, `PlainStorageState`, and /// `Stora...
FunctionBody
crates/storage/db-common/src/init.rs
before state import" ); for empty_block in next_block..block { writer.append_storage_changeset(Vec::new(), empty_block)?; if empty_block > next_block && empty_block.is_multiple_of(1_000_000) { info!( target: "reth::cli", pad...
fn write_account_to_db<TX: DbTxMut>( tx: &TX, address: &Address, genesis_account: &GenesisAccount, block: u64, history_list: &IntegerList, seen_bytecodes: &mut B256Set, ) -> Result<(), eyre::Error> { let bytecode_hash = if let Some(code) = &genesis_account.code { let bytecode = Bytec...
/// Writes a single account to the v2 storage destinations. /// /// Storage v2 uses hashed state as the canonical state, static-file change sets, and `RocksDB` /// history indices. The ETL collector yields accounts sorted by address and genesis storage is a /// `BTreeMap`, so the streaming static-file writes preserve ...
Function
crates/storage/db-common/src/init.rs
ge_changeset(Vec::new(), empty_block)?; if empty_block > next_block && empty_block.is_multiple_of(1_000_000) { info!( target: "reth::cli", padded_to_block = empty_block, "Padded empty storage changesets" ); ...
{ let bytecode_hash = if let Some(code) = &genesis_account.code { let bytecode = Bytecode::new_raw_checked(code.clone()) .map_err(|e| eyre::eyre!("Invalid bytecode for {address}: {e}"))?; let hash = bytecode.hash_slow(); if seen_bytecodes.insert(hash) { tx.put::<table...
/// Writes a single account to the v2 storage destinations. /// /// Storage v2 uses hashed state as the canonical state, static-file change sets, and `RocksDB` /// history indices. The ETL collector yields accounts sorted by address and genesis storage is a /// `BTreeMap`, so the streaming static-file writes preserve...
FunctionBody
crates/storage/db-common/src/init.rs
< block { info!( target: "reth::cli", from_block = next_block, to_block = block - 1, "Padding empty account changesets before state import" ); for empty_block in next_block..block { writer.append_account_changeset(Vec::new(), empty_blo...
fn write_account_to_db_v2<TX, N>( tx: &TX, changeset_writers: ( &mut reth_provider::providers::StaticFileProviderRWRefMut<'_, N>, &mut reth_provider::providers::StaticFileProviderRWRefMut<'_, N>, ), history_batch: &mut reth_provider::providers::RocksDBBatch<'_>, address: &Address, ...
/// Computes the state root (from scratch) based on the accounts and storages present in the /// database. fn compute_state_root<Provider>( provider: &Provider, prefix_sets: Option<TriePrefixSets>, ) -> Result<B256, InitStorageError> where Provider: DBProvider<Tx: DbTxMut> + TrieWriter + StorageSettingsCac...
Function
crates/storage/db-common/src/init.rs
} Some(hash) } else { None }; let account = Account { nonce: genesis_account.nonce.unwrap_or_default(), balance: genesis_account.balance, bytecode_hash, }; let hashed_address = keccak256(address); // plain state — sorted by address (ETL order), u...
{ let bytecode_hash = if let Some(code) = &genesis_account.code { let bytecode = Bytecode::new_raw_checked(code.clone()) .map_err(|e| eyre::eyre!("Invalid bytecode for {address}: {e}"))?; let hash = bytecode.hash_slow(); if seen_bytecodes.insert(hash) { tx.put::<table...
/// Computes the state root (from scratch) based on the accounts and storages present in the /// database. fn compute_state_root<Provider>( provider: &Provider, prefix_sets: Option<TriePrefixSets>, ) -> Result<B256, InitStorageError> where Provider: DBProvider<Tx: DbTxMut> + TrieWriter + StorageSettingsCa...
FunctionBody
crates/storage/db-common/src/init.rs
ty_block, "Padded empty storage changesets" ); } } } writer.begin_storage_changeset(block) } fn snapshot_state_tables_empty<TX: reth_db_api::transaction::DbTx>( tx: &TX, ) -> ProviderResult<bool> { Ok(tx.entries::<tables::PlainAccountState>()? ==...
fn compute_state_root<Provider>( provider: &Provider, prefix_sets: Option<TriePrefixSets>, ) -> Result<B256, InitStorageError> where Provider: DBProvider<Tx: DbTxMut> + TrieWriter + StorageSettingsCache, { reth_trie_db::with_adapter!(provider, |A| { compute_state_root_inner::<_, A>(provider, pre...
fn compute_state_root_inner<Provider, A>( provider: &Provider, prefix_sets: Option<TriePrefixSets>, ) -> Result<B256, InitStorageError> where Provider: DBProvider<Tx: DbTxMut> + TrieWriter + StorageSettingsCache, A: reth_trie_db::TrieTableAdapter, { trace!(target: "reth::cli", "Computing state root...
Function
crates/storage/db-common/src/init.rs
n storage { let value_u256 = U256::from_be_bytes(value.0); // plain storage — sorted by (address, key), use append_dup plain_storage_cursor.append_dup(*address, StorageEntry { key, value: value_u256 })?; // hashed storage — unsorted keccak order, use upsert ...
{ reth_trie_db::with_adapter!(provider, |A| { compute_state_root_inner::<_, A>(provider, prefix_sets) }) }
fn compute_state_root_inner<Provider, A>( provider: &Provider, prefix_sets: Option<TriePrefixSets>, ) -> Result<B256, InitStorageError> where Provider: DBProvider<Tx: DbTxMut> + TrieWriter + StorageSettingsCache, A: reth_trie_db::TrieTableAdapter, { trace!(target: "reth::cli", "Computing state roo...
FunctionBody
crates/storage/db-common/src/init.rs
l state, static-file change sets, and `RocksDB` /// history indices. The ETL collector yields accounts sorted by address and genesis storage is a /// `BTreeMap`, so the streaming static-file writes preserve the required order. fn write_account_to_db_v2<TX, N>( tx: &TX, changeset_writers: ( &mut reth_pro...
fn compute_state_root_inner<Provider, A>( provider: &Provider, prefix_sets: Option<TriePrefixSets>, ) -> Result<B256, InitStorageError> where Provider: DBProvider<Tx: DbTxMut> + TrieWriter + StorageSettingsCache, A: reth_trie_db::TrieTableAdapter, { trace!(target: "reth::cli", "Computing state root"...
/// Computes the state root (from scratch) with periodic commits to free MDBX dirty pages. /// /// Opens a fresh transaction each iteration to release dirty pages, preventing OOM on large /// states where trie updates accumulate gigabytes of MDBX dirty pages. fn compute_state_root_chunked<PF>(provider_factory: &PF) ->...
Function
crates/storage/db-common/src/init.rs
art, "Resetting pre-snapshot changeset static files before state import" ); static_file_provider.delete_segment(segment)?; Ok(()) } fn commit_mdbx_only<Provider>(provider: Provider) -> ProviderResult<()> where Provider: DBProvider<Tx: DbTxMut>, { reth_db_api::transaction::DbTx::commit(prov...
{ trace!(target: "reth::cli", "Computing state root"); let tx = provider.tx_ref(); let mut intermediate_state: Option<IntermediateStateRootState> = None; let mut total_flushed_updates = 0; loop { let mut state_root = DbStateRoot::<_, A>::from_tx(tx).with_intermediate_state(inte...
/// Computes the state root (from scratch) with periodic commits to free MDBX dirty pages. /// /// Opens a fresh transaction each iteration to release dirty pages, preventing OOM on large /// states where trie updates accumulate gigabytes of MDBX dirty pages. fn compute_state_root_chunked<PF>(provider_factory: &PF) -...
FunctionBody
crates/storage/db-common/src/init.rs
sh_slow(); if seen_bytecodes.insert(hash) { tx.put::<tables::Bytecodes>(hash, bytecode)?; } Some(hash) } else { None }; let account = Account { nonce: genesis_account.nonce.unwrap_or_default(), balance: genesis_account.balance, bytecode_ha...
fn compute_state_root_chunked<PF>(provider_factory: &PF) -> Result<B256, InitStorageError> where PF: DatabaseProviderFactory< ProviderRW: DBProvider<Tx: DbTxMut> + TrieWriter + StorageSettingsCache, >, { let provider_rw = provider_factory.database_provider_rw().map_err(provider_db_err)?; reth_t...
fn compute_state_root_chunked_inner<PF, A>(provider_factory: &PF) -> Result<B256, InitStorageError> where PF: DatabaseProviderFactory< ProviderRW: DBProvider<Tx: DbTxMut> + TrieWriter + StorageSettingsCache, >, A: reth_trie_db::TrieTableAdapter, { trace!(target: "reth::cli", "Computing state ro...
Function
crates/storage/db-common/src/init.rs
} Some(hash) } else { None }; let account = Account { nonce: genesis_account.nonce.unwrap_or_default(), balance: genesis_account.balance, bytecode_hash, }; let hashed_address = keccak256(address); // plain state — sorted by address (ETL order),...
{ let provider_rw = provider_factory.database_provider_rw().map_err(provider_db_err)?; reth_trie_db::with_adapter!(&provider_rw, |A| { drop(provider_rw); compute_state_root_chunked_inner::<PF, A>(provider_factory) }) }
fn compute_state_root_chunked_inner<PF, A>(provider_factory: &PF) -> Result<B256, InitStorageError> where PF: DatabaseProviderFactory< ProviderRW: DBProvider<Tx: DbTxMut> + TrieWriter + StorageSettingsCache, >, A: reth_trie_db::TrieTableAdapter, { trace!(target: "reth::cli", "Computing state r...
FunctionBody
crates/storage/db-common/src/init.rs
) -> Result<B256, InitStorageError> where Provider: DBProvider<Tx: DbTxMut> + TrieWriter + StorageSettingsCache, { reth_trie_db::with_adapter!(provider, |A| { compute_state_root_inner::<_, A>(provider, prefix_sets) }) } fn compute_state_root_inner<Provider, A>( provider: &Provider, prefix_s...
fn compute_state_root_chunked_inner<PF, A>(provider_factory: &PF) -> Result<B256, InitStorageError> where PF: DatabaseProviderFactory< ProviderRW: DBProvider<Tx: DbTxMut> + TrieWriter + StorageSettingsCache, >, A: reth_trie_db::TrieTableAdapter, { trace!(target: "reth::cli", "Computing state roo...
/// Converts a provider error into an [`InitStorageError`]. fn provider_db_err(e: impl std::fmt::Display) -> InitStorageError { InitStorageError::from(StateRootError::Database(DatabaseError::Other(e.to_string()))) } /// Type to deserialize state root from state dump file. #[derive(Debug, Serialize, Deserialize, P...
Function
crates/storage/db-common/src/init.rs
db::with_adapter!(provider, |A| { compute_state_root_inner::<_, A>(provider, prefix_sets) }) } fn compute_state_root_inner<Provider, A>( provider: &Provider, prefix_sets: Option<TriePrefixSets>, ) -> Result<B256, InitStorageError> where Provider: DBProvider<Tx: DbTxMut> + TrieWriter + StorageSe...
{ trace!(target: "reth::cli", "Computing state root"); let mut intermediate_state: Option<IntermediateStateRootState> = None; let mut total_flushed_updates = 0; loop { let provider_rw = provider_factory.database_provider_rw().map_err(provider_db_err)?; let tx = provider_rw.tx_ref(); ...
/// Converts a provider error into an [`InitStorageError`]. fn provider_db_err(e: impl std::fmt::Display) -> InitStorageError { InitStorageError::from(StateRootError::Database(DatabaseError::Other(e.to_string()))) } /// Type to deserialize state root from state dump file. #[derive(Debug, Serialize, Deserialize, ...
FunctionBody
crates/storage/db-common/src/init.rs
ie_updates(updates)?; total_flushed_updates += updated_len; trace!(target: "reth::cli", last_account_key = %state.account_root_state.last_hashed_key, updated_len, total_flushed_updates, "Flushing trie update...
fn provider_db_err(e: impl std::fmt::Display) -> InitStorageError { InitStorageError::from(StateRootError::Database(DatabaseError::Other(e.to_string()))) }
/// Type to deserialize state root from state dump file. #[derive(Debug, Serialize, Deserialize, PartialEq, Eq)] struct StateRoot { root: B256, } /// An account as in the state dump file. This contains a [`GenesisAccount`] and the account's /// address. #[derive(Debug, Serialize, Deserialize)] struct GenesisAccou...
Function
crates/storage/db-common/src/init.rs
total_flushed_updates += updated_len; trace!(target: "reth::cli", last_account_key = %state.account_root_state.last_hashed_key, updated_len, total_flushed_updates, "Flushing trie updates" ); ...
{ InitStorageError::from(StateRootError::Database(DatabaseError::Other(e.to_string()))) }
/// Type to deserialize state root from state dump file. #[derive(Debug, Serialize, Deserialize, PartialEq, Eq)] struct StateRoot { root: B256, } /// An account as in the state dump file. This contains a [`GenesisAccount`] and the account's /// address. #[derive(Debug, Serialize, Deserialize)] struct GenesisAcco...
FunctionBody
crates/storage/db-common/src/init.rs
change sets, and `RocksDB` /// history indices. The ETL collector yields accounts sorted by address and genesis storage is a /// `BTreeMap`, so the streaming static-file writes preserve the required order. fn write_account_to_db_v2<TX, N>( tx: &TX, changeset_writers: ( &mut reth_provider::providers::Sta...
/// Type to deserialize state root from state dump file. #[derive(Debug, Serialize, Deserialize, PartialEq, Eq)] struct StateRoot { root: B256, }
/// An account as in the state dump file. This contains a [`GenesisAccount`] and the account's /// address. #[derive(Debug, Serialize, Deserialize)] struct GenesisAccountWithAddress { /// The account's balance, nonce, code, and storage. #[serde(flatten)] genesis_account: GenesisAccount, /// The account...
Struct
crates/storage/db-common/src/init.rs
changeset_writers: ( &mut reth_provider::providers::StaticFileProviderRWRefMut<'_, N>, &mut reth_provider::providers::StaticFileProviderRWRefMut<'_, N>, ), history_batch: &mut reth_provider::providers::RocksDBBatch<'_>, address: &Address, genesis_account: &GenesisAccount, history_...
/// An account as in the state dump file. This contains a [`GenesisAccount`] and the account's /// address. #[derive(Debug, Serialize, Deserialize)] struct GenesisAccountWithAddress { /// The account's balance, nonce, code, and storage. #[serde(flatten)] genesis_account: GenesisAccount, /// The account'...
#[cfg(test)] mod tests { use super::*; use alloy_consensus::constants::{ HOLESKY_GENESIS_HASH, MAINNET_GENESIS_HASH, SEPOLIA_GENESIS_HASH, }; use alloy_genesis::Genesis; use reth_chainspec::{Chain, ChainSpec, HOLESKY, MAINNET, SEPOLIA}; use reth_db::DatabaseEnv; use reth_db_api::{ ...
Struct
crates/storage/db-common/src/init.rs
dates" ); } } StateRootProgress::Complete(root, _, updates) => { let updated_len = provider.write_trie_updates(updates)?; total_flushed_updates += updated_len; trace!(target: "reth::cli", %ro...
use super::*;
use alloy_consensus::constants::{ HOLESKY_GENESIS_HASH, MAINNET_GENESIS_HASH, SEPOLIA_GENESIS_HASH, }; use alloy_genesis::Genesis; use reth_chainspec::{Chain, ChainSpec, HOLESKY, MAINNET, SEPOLIA}; use reth_db::DatabaseEnv; use reth_db_api::{ cursor::DbCursorRO, models::{...
Use
crates/storage/db-common/src/init.rs
StateRootProgress::Complete(root, _, updates) => { let updated_len = provider.write_trie_updates(updates)?; total_flushed_updates += updated_len; trace!(target: "reth::cli", %root, updated_len, total_flushe...
use alloy_consensus::constants::{ HOLESKY_GENESIS_HASH, MAINNET_GENESIS_HASH, SEPOLIA_GENESIS_HASH, };
use alloy_genesis::Genesis; use reth_chainspec::{Chain, ChainSpec, HOLESKY, MAINNET, SEPOLIA}; use reth_db::DatabaseEnv; use reth_db_api::{ cursor::DbCursorRO, models::{storage_sharded_key::StorageShardedKey, IntegerList, ShardedKey}, table::{Table, TableRow}, transaction...
Use
crates/storage/db-common/src/init.rs
updated_len = provider.write_trie_updates(updates)?; total_flushed_updates += updated_len; trace!(target: "reth::cli", %root, updated_len, total_flushed_updates, "State root has been computed" ...
use alloy_genesis::Genesis;
use reth_chainspec::{Chain, ChainSpec, HOLESKY, MAINNET, SEPOLIA}; use reth_db::DatabaseEnv; use reth_db_api::{ cursor::DbCursorRO, models::{storage_sharded_key::StorageShardedKey, IntegerList, ShardedKey}, table::{Table, TableRow}, transaction::DbTx, Database, };...
Use
crates/storage/db-common/src/init.rs
; total_flushed_updates += updated_len; trace!(target: "reth::cli", %root, updated_len, total_flushed_updates, "State root has been computed" ); return Ok(root) }...
use reth_chainspec::{Chain, ChainSpec, HOLESKY, MAINNET, SEPOLIA};
use reth_db::DatabaseEnv; use reth_db_api::{ cursor::DbCursorRO, models::{storage_sharded_key::StorageShardedKey, IntegerList, ShardedKey}, table::{Table, TableRow}, transaction::DbTx, Database, }; use reth_provider::{ test_utils::{create_test_provider_fac...
Use
crates/storage/db-common/src/init.rs
bytecode_hash = if let Some(code) = &genesis_account.code { let bytecode = Bytecode::new_raw_checked(code.clone()) .map_err(|e| eyre::eyre!("Invalid bytecode for {address}: {e}"))?; let hash = bytecode.hash_slow(); if seen_bytecodes.insert(hash) { tx.put::<tables::Byteco...
use reth_db::DatabaseEnv;
use reth_db_api::{ cursor::DbCursorRO, models::{storage_sharded_key::StorageShardedKey, IntegerList, ShardedKey}, table::{Table, TableRow}, transaction::DbTx, Database, }; use reth_provider::{ test_utils::{create_test_provider_factory_with_chain_spec, MockNode...
Use
crates/storage/db-common/src/init.rs
.map_err(|e| eyre::eyre!("Invalid bytecode for {address}: {e}"))?; let hash = bytecode.hash_slow(); if seen_bytecodes.insert(hash) { tx.put::<tables::Bytecodes>(hash, bytecode)?; } Some(hash) } else { None }; let account = Account { non...
use reth_db_api::{ cursor::DbCursorRO, models::{storage_sharded_key::StorageShardedKey, IntegerList, ShardedKey}, table::{Table, TableRow}, transaction::DbTx, Database, };
use reth_provider::{ test_utils::{create_test_provider_factory_with_chain_spec, MockNodeTypesWithDB}, ProviderFactory, RocksDBProviderFactory, }; use std::{collections::BTreeMap, sync::Arc}; fn collect_table_entries<DB, T>( tx: &<DB as Database>::TX, ) -> Result<Vec<TableRow...
Use
crates/storage/db-common/src/init.rs
des>(hash, bytecode)?; } Some(hash) } else { None }; let account = Account { nonce: genesis_account.nonce.unwrap_or_default(), balance: genesis_account.balance, bytecode_hash, }; let hashed_address = keccak256(address); let (account_changeset_wri...
use reth_provider::{ test_utils::{create_test_provider_factory_with_chain_spec, MockNodeTypesWithDB}, ProviderFactory, RocksDBProviderFactory, };
use std::{collections::BTreeMap, sync::Arc}; fn collect_table_entries<DB, T>( tx: &<DB as Database>::TX, ) -> Result<Vec<TableRow<T>>, InitStorageError> where DB: Database, T: Table, { Ok(tx.cursor_read::<T>()?.walk_range(..)?.collect::<Result<Vec<_>, _>>()?) } ...
Use
crates/storage/db-common/src/init.rs
t { nonce: genesis_account.nonce.unwrap_or_default(), balance: genesis_account.balance, bytecode_hash, }; let hashed_address = keccak256(address); let (account_changeset_writer, storage_changeset_writer) = changeset_writers; tx.put::<tables::HashedAccounts>(hashed_address, acco...
use std::{collections::BTreeMap, sync::Arc};
fn collect_table_entries<DB, T>( tx: &<DB as Database>::TX, ) -> Result<Vec<TableRow<T>>, InitStorageError> where DB: Database, T: Table, { Ok(tx.cursor_read::<T>()?.walk_range(..)?.collect::<Result<Vec<_>, _>>()?) } #[test] fn parse_accounts_streams_jsonl_a...
Use
crates/storage/db-common/src/init.rs
er_factory: &PF) -> Result<B256, InitStorageError> where PF: DatabaseProviderFactory< ProviderRW: DBProvider<Tx: DbTxMut> + TrieWriter + StorageSettingsCache, >, { let provider_rw = provider_factory.database_provider_rw().map_err(provider_db_err)?; reth_trie_db::with_adapter!(&provider_rw, |A| ...
fn collect_table_entries<DB, T>( tx: &<DB as Database>::TX, ) -> Result<Vec<TableRow<T>>, InitStorageError> where DB: Database, T: Table, { Ok(tx.cursor_read::<T>()?.walk_range(..)?.collect::<Result<Vec<_>, _>>()?) }
#[test] fn parse_accounts_streams_jsonl_accounts() { let input = br#"{"address":"0x0000000000000000000000000000000000000002","balance":"0x2"} {"address":"0x0000000000000000000000000000000000000001","balance":"0x1"} "#; let mut collector = parse_accounts(&input[..], EtlConfig::new(N...
Function
crates/storage/db-common/src/init.rs
eset_writers; tx.put::<tables::HashedAccounts>(hashed_address, account)?; account_changeset_writer .append_account_changeset_entry(AccountBeforeTx { address: *address, info: None })?; history_batch .put::<tables::AccountsHistory>(ShardedKey::new(*address, u64::MAX), history_list)?; if ...
{ Ok(tx.cursor_read::<T>()?.walk_range(..)?.collect::<Result<Vec<_>, _>>()?) }
#[test] fn parse_accounts_streams_jsonl_accounts() { let input = br#"{"address":"0x0000000000000000000000000000000000000002","balance":"0x2"} {"address":"0x0000000000000000000000000000000000000001","balance":"0x1"} "#; let mut collector = parse_accounts(&input[..], EtlConfig::new(...
FunctionBody
crates/storage/db-common/src/init.rs
_db::TrieTableAdapter, { trace!(target: "reth::cli", "Computing state root"); let mut intermediate_state: Option<IntermediateStateRootState> = None; let mut total_flushed_updates = 0; loop { let provider_rw = provider_factory.database_provider_rw().map_err(provider_db_err)?; let tx = p...
fn parse_accounts_streams_jsonl_accounts() { let input = br#"{"address":"0x0000000000000000000000000000000000000002","balance":"0x2"} {"address":"0x0000000000000000000000000000000000000001","balance":"0x1"} "#; let mut collector = parse_accounts(&input[..], EtlConfig::new(None, 128)).ex...
#[test] fn dump_state_uses_storage_v2_destinations() { let storage_key = B256::with_last_byte(3); let input = br#"{"address":"0x0000000000000000000000000000000000000001","balance":"0x1"} {"address":"0x0000000000000000000000000000000000000002","balance":"0x0","storage":{"0x0000000000000000000000...
Function
crates/storage/db-common/src/init.rs
hashed_storage_cursor .upsert(hashed_address, &StorageEntry { key: hashed_key, value: value_u256 })?; storage_changeset_writer.append_storage_changeset_entry( reth_db_api::models::StorageBeforeTx { address: *address, key, value: U256::ZERO }, )?; ...
{ let input = br#"{"address":"0x0000000000000000000000000000000000000002","balance":"0x2"} {"address":"0x0000000000000000000000000000000000000001","balance":"0x1"} "#; let mut collector = parse_accounts(&input[..], EtlConfig::new(None, 128)).expect("parse succeeds"); let accounts =...
#[test] fn dump_state_uses_storage_v2_destinations() { let storage_key = B256::with_last_byte(3); let input = br#"{"address":"0x0000000000000000000000000000000000000001","balance":"0x1"} {"address":"0x0000000000000000000000000000000000000002","balance":"0x0","storage":{"0x000000000000000000000...
FunctionBody
crates/storage/db-common/src/init.rs
last_hashed_key, updated_len, total_flushed_updates, "Flushing trie updates" ); intermediate_state = Some(*state); if total_flushed_updates.is_multiple_of(SOFT_LIMIT_COUNT_FLUSHED_UPDATES) { ...
fn dump_state_uses_storage_v2_destinations() { let storage_key = B256::with_last_byte(3); let input = br#"{"address":"0x0000000000000000000000000000000000000001","balance":"0x1"} {"address":"0x0000000000000000000000000000000000000002","balance":"0x0","storage":{"0x00000000000000000000000000000000000...
#[test] fn dump_state_v2_resets_presnapshot_changeset_static_files() { let storage_key = B256::with_last_byte(3); let input = br#"{"address":"0x0000000000000000000000000000000000000002","balance":"0x0","storage":{"0x0000000000000000000000000000000000000000000000000000000000000003":"0x0000000000...
Function
crates/storage/db-common/src/init.rs
updated_len, total_flushed_updates, "Flushing trie updates" ); intermediate_state = Some(*state); if total_flushed_updates.is_multiple_of(SOFT_LIMIT_COUNT_FLUSHED_UPDATES) { info!(target: "reth::cl...
{ let storage_key = B256::with_last_byte(3); let input = br#"{"address":"0x0000000000000000000000000000000000000001","balance":"0x1"} {"address":"0x0000000000000000000000000000000000000002","balance":"0x0","storage":{"0x0000000000000000000000000000000000000000000000000000000000000003":"0x000000000000000...
#[test] fn dump_state_v2_resets_presnapshot_changeset_static_files() { let storage_key = B256::with_last_byte(3); let input = br#"{"address":"0x0000000000000000000000000000000000000002","balance":"0x0","storage":{"0x0000000000000000000000000000000000000000000000000000000000000003":"0x000000000...
FunctionBody
crates/storage/db-common/src/init.rs
ap(); let tx = provider.tx_ref(); assert_eq!(tx.entries::<tables::PlainAccountState>().unwrap(), 0); assert_eq!(tx.entries::<tables::PlainStorageState>().unwrap(), 0); assert_eq!(tx.entries::<tables::AccountChangeSets>().unwrap(), 0); assert_eq!(tx.entries::<tables::StorageChange...
fn dump_state_v2_resets_presnapshot_changeset_static_files() { let storage_key = B256::with_last_byte(3); let input = br#"{"address":"0x0000000000000000000000000000000000000002","balance":"0x0","storage":{"0x0000000000000000000000000000000000000000000000000000000000000003":"0x00000000000000000000000...
#[test] fn success_init_genesis_mainnet() { let genesis_hash = init_genesis(&create_test_provider_factory_with_chain_spec(MAINNET.clone())).unwrap(); // actual, expected assert_eq!(genesis_hash, MAINNET_GENESIS_HASH); } #[test] fn success_init_genesis_sepolia()...
Function
crates/storage/db-common/src/init.rs
s += updated_len; info!(target: "reth::cli", %root, updated_len, total_flushed_updates, "State root computation complete" ); provider_rw.commit().map_err(provider_db_err)?; r...
{ let storage_key = B256::with_last_byte(3); let input = br#"{"address":"0x0000000000000000000000000000000000000002","balance":"0x0","storage":{"0x0000000000000000000000000000000000000000000000000000000000000003":"0x0000000000000000000000000000000000000000000000000000000000000004"}} "#; let col...
#[test] fn success_init_genesis_mainnet() { let genesis_hash = init_genesis(&create_test_provider_factory_with_chain_spec(MAINNET.clone())).unwrap(); // actual, expected assert_eq!(genesis_hash, MAINNET_GENESIS_HASH); } #[test] fn success_init_genesis_sepolia(...
FunctionBody
crates/storage/db-common/src/init.rs
ey::new(address_with_storage, u64::MAX), IntegerList::new([block]).unwrap() ) ] ); assert_eq!( storages, vec![( StorageShardedKey::new(address_with_storage, storage_key, u64::MAX), IntegerList::new([b...
fn success_init_genesis_mainnet() { let genesis_hash = init_genesis(&create_test_provider_factory_with_chain_spec(MAINNET.clone())).unwrap(); // actual, expected assert_eq!(genesis_hash, MAINNET_GENESIS_HASH); }
#[test] fn success_init_genesis_sepolia() { let genesis_hash = init_genesis(&create_test_provider_factory_with_chain_spec(SEPOLIA.clone())).unwrap(); // actual, expected assert_eq!(genesis_hash, SEPOLIA_GENESIS_HASH); } #[test] fn success_init_genesis_holesky()...
Function
crates/storage/db-common/src/init.rs
( tx: &<DB as Database>::TX, ) -> Result<Vec<TableRow<T>>, InitStorageError> where DB: Database, T: Table, { Ok(tx.cursor_read::<T>()?.walk_range(..)?.collect::<Result<Vec<_>, _>>()?) } #[test] fn parse_accounts_streams_jsonl_accounts() { let input = br#"...
{ let genesis_hash = init_genesis(&create_test_provider_factory_with_chain_spec(MAINNET.clone())).unwrap(); // actual, expected assert_eq!(genesis_hash, MAINNET_GENESIS_HASH); }
#[test] fn success_init_genesis_sepolia() { let genesis_hash = init_genesis(&create_test_provider_factory_with_chain_spec(SEPOLIA.clone())).unwrap(); // actual, expected assert_eq!(genesis_hash, SEPOLIA_GENESIS_HASH); } #[test] fn success_init_genesis_holesky(...
FunctionBody
crates/storage/db-common/src/init.rs
n parse_accounts_streams_jsonl_accounts() { let input = br#"{"address":"0x0000000000000000000000000000000000000002","balance":"0x2"} {"address":"0x0000000000000000000000000000000000000001","balance":"0x1"} "#; let mut collector = parse_accounts(&input[..], EtlConfig::new(None, 128)).expect(...
fn success_init_genesis_sepolia() { let genesis_hash = init_genesis(&create_test_provider_factory_with_chain_spec(SEPOLIA.clone())).unwrap(); // actual, expected assert_eq!(genesis_hash, SEPOLIA_GENESIS_HASH); }
#[test] fn success_init_genesis_holesky() { let genesis_hash = init_genesis(&create_test_provider_factory_with_chain_spec(HOLESKY.clone())).unwrap(); // actual, expected assert_eq!(genesis_hash, HOLESKY_GENESIS_HASH); } #[test] fn fail_init_inconsistent_db() { ...
Function
crates/storage/db-common/src/init.rs
IntegerList::new([block]).unwrap() )] ); } #[test] fn dump_state_v2_resets_presnapshot_changeset_static_files() { let storage_key = B256::with_last_byte(3); let input = br#"{"address":"0x0000000000000000000000000000000000000002","balance":"0x0","storage":{"0...
{ let genesis_hash = init_genesis(&create_test_provider_factory_with_chain_spec(SEPOLIA.clone())).unwrap(); // actual, expected assert_eq!(genesis_hash, SEPOLIA_GENESIS_HASH); }
#[test] fn success_init_genesis_holesky() { let genesis_hash = init_genesis(&create_test_provider_factory_with_chain_spec(HOLESKY.clone())).unwrap(); // actual, expected assert_eq!(genesis_hash, HOLESKY_GENESIS_HASH); } #[test] fn fail_init_inconsistent_db() {...
FunctionBody
crates/storage/db-common/src/init.rs
nts(&input[..], EtlConfig::new(None, 128)).expect("parse succeeds"); let accounts = collector .iter() .unwrap() .map(|entry| { let (address_raw, account_raw) = entry.unwrap(); let (address, _) = Address::from_compact(address_raw.as_slice(), ad...
fn success_init_genesis_holesky() { let genesis_hash = init_genesis(&create_test_provider_factory_with_chain_spec(HOLESKY.clone())).unwrap(); // actual, expected assert_eq!(genesis_hash, HOLESKY_GENESIS_HASH); }
#[test] fn fail_init_inconsistent_db() { let factory = create_test_provider_factory_with_chain_spec(SEPOLIA.clone()); let static_file_provider = factory.static_file_provider(); let rocksdb_provider = factory.rocksdb_provider(); init_genesis(&factory).unwrap(); // Try to...
Function