-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Conversation
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.
great start, I have a few suggestions
crates/primitives-traits/src/size.rs
Outdated
@@ -0,0 +1,5 @@ | |||
/// Trait for calculating a heuristic for the in-memory size of a struct. | |||
pub trait HeuristicSize { |
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
, or InMemorySize
or something like that
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
should remove this
|
||
/// 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 comment
The 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 comment
The reason will be displayed to describe this comment to others. Learn more.
yeah sorry I messed up my local branch
crates/transaction-pool/src/lib.rs
Outdated
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
should remove this
#[cfg(any(test, feature = "arbitrary"))] | ||
use reth_primitives_traits::HeuristicSize; |
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.
if the use reth_primitives_traits as _;
is required since this is feature gated, I'd try to instead make primitives-traits an optional dep, including it by default as a dev-dependency, and when arbitrary
is enabled
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.
seems okay, pending @Rjected
2777384
to
ba032e3
Compare
Closes #3893