Skip to content
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

Merged
merged 15 commits into from
Nov 11, 2024

Conversation

TropicalDog17
Copy link
Contributor

Closes #3893

Copy link
Member

@Rjected Rjected left a 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

@@ -0,0 +1,5 @@
/// Trait for calculating a heuristic for the in-memory size of a struct.
pub trait HeuristicSize {
Copy link
Member

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)]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should remove this

Comment on lines 163 to 173

/// 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()
}
Copy link
Member

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?

Copy link
Contributor Author

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

@@ -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 _;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should remove this

Comment on lines 28 to 29
#[cfg(any(test, feature = "arbitrary"))]
use reth_primitives_traits::HeuristicSize;
Copy link
Member

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

Copy link
Collaborator

@mattsse mattsse left a 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

@mattsse mattsse added the C-enhancement New feature or request label Nov 8, 2024
@mattsse mattsse added this pull request to the merge queue Nov 11, 2024
Merged via the queue into paradigmxyz:main with commit eccff7d Nov 11, 2024
41 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use a trait for size methods in primitive types
3 participants