diff --git a/crates/primitives-traits/src/block/body.rs b/crates/primitives-traits/src/block/body.rs index 9b703c0d2f..14941ffed0 100644 --- a/crates/primitives-traits/src/block/body.rs +++ b/crates/primitives-traits/src/block/body.rs @@ -6,7 +6,7 @@ use alloy_consensus::{BlockHeader, Transaction, TxType}; use alloy_eips::{eip4895::Withdrawal, eip7685::Requests}; use alloy_primitives::{Address, B256}; -use crate::Block; +use crate::{Block, InMemorySize}; /// Abstraction for block's body. pub trait BlockBody: @@ -22,6 +22,7 @@ pub trait BlockBody: + for<'de> serde::Deserialize<'de> + alloy_rlp::Encodable + alloy_rlp::Decodable + + InMemorySize { /// Ordered list of signed transactions as committed in block. // todo: requires trait for signed transaction @@ -93,7 +94,4 @@ pub trait BlockBody: fn blob_versioned_hashes(&self) -> Vec<&B256> { self.blob_versioned_hashes_iter().collect() } - - /// Calculates a heuristic for the in-memory size of the [`BlockBody`]. - fn size(&self) -> usize; } diff --git a/crates/primitives-traits/src/block/mod.rs b/crates/primitives-traits/src/block/mod.rs index 185b61e978..cfc9e9a550 100644 --- a/crates/primitives-traits/src/block/mod.rs +++ b/crates/primitives-traits/src/block/mod.rs @@ -8,7 +8,7 @@ use alloc::{fmt, vec::Vec}; use alloy_primitives::{Address, B256}; use reth_codecs::Compact; -use crate::{BlockBody, BlockHeader, FullBlockHeader}; +use crate::{BlockBody, BlockHeader, FullBlockHeader, InMemorySize}; /// Helper trait that unifies all behaviour required by block to support full node operations. pub trait FullBlock: Block + Compact {} @@ -32,6 +32,7 @@ pub trait Block: + for<'a> serde::Deserialize<'a> + From<(Self::Header, Self::Body)> + Into<(Self::Header, Self::Body)> + + InMemorySize { /// Header part of the block. type Header: BlockHeader; @@ -104,7 +105,4 @@ pub trait Block: // todo: can be default impl if sealed block type is made generic over header and body and // migrated to alloy fn with_recovered_senders(self) -> Option>; - - /// Calculates a heuristic for the in-memory size of the [`Block`]. - fn size(&self) -> usize; } diff --git a/crates/primitives-traits/src/transaction/mod.rs b/crates/primitives-traits/src/transaction/mod.rs index 7fd0ec88b3..d5061ca390 100644 --- a/crates/primitives-traits/src/transaction/mod.rs +++ b/crates/primitives-traits/src/transaction/mod.rs @@ -7,6 +7,8 @@ use alloy_primitives::{TxKind, B256}; use reth_codecs::Compact; use serde::{Deserialize, Serialize}; +use crate::InMemorySize; + pub mod signed; #[allow(dead_code)] @@ -26,6 +28,7 @@ pub trait Transaction: + alloy_rlp::Decodable + for<'de> Deserialize<'de> + alloy_consensus::Transaction + + InMemorySize + MaybeArbitrary { /// Heavy operation that return signature hash over rlp encoded transaction. @@ -45,9 +48,6 @@ pub trait Transaction: /// This encodes the transaction _without_ the signature, and is only suitable for creating a /// hash intended for signing. fn encode_without_signature(&self, out: &mut dyn bytes::BufMut); - - /// Calculates a heuristic for the in-memory size of the [Transaction]. - fn size(&self) -> usize; } #[cfg(not(feature = "arbitrary"))]