-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
chore(reth_primitives): Use trait for size
methods in primitive types
#12201
Changes from 8 commits
39f89aa
5cc82b6
bff715a
6cef5ea
a3d6279
25b2bc3
ebe3d3a
081d3f1
1dc630c
94b6a15
9b48915
46b5938
3f4465b
ba032e3
5e17831
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
/// Trait for calculating a heuristic for the in-memory size of a struct. | ||
pub trait HeuristicSize { | ||
/// Returns a heuristic for the in-memory size of a struct. | ||
fn size(&self) -> usize; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,13 +4,14 @@ use crate::{ | |
PrunerError, | ||
}; | ||
use reth_db::{tables, transaction::DbTxMut}; | ||
#[allow(unused_imports)] | ||
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. should remove this |
||
use reth_primitives_traits::HeuristicSize; | ||
use reth_provider::{BlockReader, DBProvider, PruneCheckpointWriter, TransactionsProvider}; | ||
use reth_prune_types::{ | ||
PruneCheckpoint, PruneMode, PruneProgress, PrunePurpose, PruneSegment, ReceiptsLogPruneConfig, | ||
SegmentOutput, MINIMUM_PRUNING_DISTANCE, | ||
}; | ||
use tracing::{instrument, trace}; | ||
|
||
#[derive(Debug)] | ||
pub struct ReceiptsByLogs { | ||
config: ReceiptsLogPruneConfig, | ||
|
@@ -223,6 +224,7 @@ mod tests { | |
use assert_matches::assert_matches; | ||
use reth_db::tables; | ||
use reth_db_api::{cursor::DbCursorRO, transaction::DbTx}; | ||
use reth_primitives_traits::HeuristicSize; | ||
use reth_provider::{DatabaseProviderFactory, PruneCheckpointReader, TransactionsProvider}; | ||
use reth_prune_types::{PruneLimiter, PruneMode, PruneSegment, ReceiptsLogPruneConfig}; | ||
use reth_stages::test_utils::{StorageKind, TestStageDB}; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -160,3 +160,14 @@ pub fn transaction_to_call_request(tx: TransactionSignedEcRecovered) -> Transact | |
authorization_list, | ||
} | ||
} | ||
|
||
/// Convert [`reth_primitives::TxType`] to [`alloy_consensus::TxType`] | ||
/// Will panics if the `TxType` is `TxType::Deposit` (Optimism Deposit transaction) | ||
pub fn tx_type_to_alloy(tx_type: TxType) -> alloy_consensus::TxType { | ||
u8::from(tx_type).try_into().unwrap() | ||
} | ||
|
||
/// Convert [`alloy_consensus::TxType`] to [`reth_primitives::TxType`] | ||
pub fn tx_type_from_alloy(tx_type: alloy_consensus::TxType) -> TxType { | ||
u8::from(tx_type).try_into().unwrap() | ||
} | ||
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. these changes are unrelated right? 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. yeah sorry I messed up my local branch |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -157,6 +157,7 @@ use aquamarine as _; | |
use reth_eth_wire_types::HandleMempoolData; | ||
use reth_execution_types::ChangedAccount; | ||
use reth_primitives::{BlobTransactionSidecar, PooledTransactionsElement}; | ||
use reth_primitives_traits as _; | ||
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. should remove this |
||
use reth_storage_api::StateProviderFactory; | ||
use std::{collections::HashSet, sync::Arc}; | ||
use tokio::sync::mpsc::Receiver; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,9 +23,11 @@ use reth_primitives::{ | |
BlobTransactionValidationError, PooledTransactionsElementEcRecovered, Signature, Transaction, | ||
TransactionSigned, TransactionSignedEcRecovered, TxType, | ||
}; | ||
|
||
use std::{ops::Range, sync::Arc, time::Instant, vec::IntoIter}; | ||
|
||
#[cfg(any(test, feature = "arbitrary"))] | ||
use reth_primitives_traits::HeuristicSize; | ||
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. if the |
||
|
||
/// A transaction pool implementation using [`MockOrdering`] for transaction ordering. | ||
/// | ||
/// This type is an alias for [`TxPool<MockOrdering>`]. | ||
|
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.
maybe name it
SizeHeuristic
, orInMemorySize
or something like that