From c54276e740d0691ee9fb59041bd36d9477ac07f9 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Tue, 28 May 2024 17:25:19 +0200 Subject: [PATCH] chore: misc storage api (#8432) --- .../bundle_state_with_receipts.rs | 34 ++++++++----------- crates/storage/storage-api/src/block.rs | 12 +------ .../storage/storage-api/src/transactions.rs | 16 +++++++-- 3 files changed, 30 insertions(+), 32 deletions(-) diff --git a/crates/storage/provider/src/bundle_state/bundle_state_with_receipts.rs b/crates/storage/provider/src/bundle_state/bundle_state_with_receipts.rs index 90f7e5f8a..37cdc9484 100644 --- a/crates/storage/provider/src/bundle_state/bundle_state_with_receipts.rs +++ b/crates/storage/provider/src/bundle_state/bundle_state_with_receipts.rs @@ -65,21 +65,8 @@ impl StateWriter for BundleStateWithReceipts { #[cfg(test)] mod tests { - use std::collections::{BTreeMap, HashMap}; - - use revm::{ - db::{ - states::{ - bundle_state::BundleRetention, changes::PlainStorageRevert, PlainStorageChangeset, - }, - BundleState, EmptyDB, - }, - primitives::{ - Account as RevmAccount, AccountInfo as RevmAccountInfo, AccountStatus, StorageSlot, - }, - DatabaseCommit, State, - }; - + use super::*; + use crate::{test_utils::create_test_provider_factory, AccountReader}; use reth_db::{ cursor::DbDupCursorRO, database::Database, @@ -92,10 +79,19 @@ mod tests { Account, Address, Receipt, Receipts, StorageEntry, B256, U256, }; use reth_trie::{test_utils::state_root, StateRoot}; - - use crate::{test_utils::create_test_provider_factory, AccountReader}; - - use super::*; + use revm::{ + db::{ + states::{ + bundle_state::BundleRetention, changes::PlainStorageRevert, PlainStorageChangeset, + }, + BundleState, EmptyDB, + }, + primitives::{ + Account as RevmAccount, AccountInfo as RevmAccountInfo, AccountStatus, StorageSlot, + }, + DatabaseCommit, State, + }; + use std::collections::{BTreeMap, HashMap}; #[test] fn write_to_db_account_info() { diff --git a/crates/storage/storage-api/src/block.rs b/crates/storage/storage-api/src/block.rs index bac6053f7..c85b15e39 100644 --- a/crates/storage/storage-api/src/block.rs +++ b/crates/storage/storage-api/src/block.rs @@ -1,6 +1,6 @@ use crate::{ BlockIdReader, BlockNumReader, HeaderProvider, ReceiptProvider, ReceiptProviderIdExt, - RequestsProvider, TransactionsProvider, WithdrawalsProvider, + RequestsProvider, TransactionVariant, TransactionsProvider, WithdrawalsProvider, }; use reth_db::models::StoredBlockBodyIndices; use reth_primitives::{ @@ -10,16 +10,6 @@ use reth_primitives::{ use reth_storage_errors::provider::ProviderResult; use std::ops::RangeInclusive; -/// Enum to control transaction hash inclusion. -#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)] -pub enum TransactionVariant { - /// Indicates that transactions should be processed without including their hashes. - NoHash, - /// Indicates that transactions should be processed along with their hashes. - #[default] - WithHash, -} - /// A helper enum that represents the origin of the requested block. /// /// This helper type's sole purpose is to give the caller more control over from where blocks can be diff --git a/crates/storage/storage-api/src/transactions.rs b/crates/storage/storage-api/src/transactions.rs index 763632a38..0553ef787 100644 --- a/crates/storage/storage-api/src/transactions.rs +++ b/crates/storage/storage-api/src/transactions.rs @@ -1,11 +1,23 @@ -use std::ops::{Range, RangeBounds, RangeInclusive}; - use crate::{BlockNumReader, BlockReader}; use reth_primitives::{ Address, BlockHashOrNumber, BlockNumber, TransactionMeta, TransactionSigned, TransactionSignedNoHash, TxHash, TxNumber, }; use reth_storage_errors::provider::{ProviderError, ProviderResult}; +use std::ops::{Range, RangeBounds, RangeInclusive}; + +/// Enum to control transaction hash inclusion. +/// +/// This serves as a hint to the provider to include or omit exclude hashes because hashes are +/// stored separately and are not always needed. +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)] +pub enum TransactionVariant { + /// Indicates that transactions should be processed without including their hashes. + NoHash, + /// Indicates that transactions should be processed along with their hashes. + #[default] + WithHash, +} /// Client trait for fetching [TransactionSigned] related data. #[auto_impl::auto_impl(&, Arc)]