mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-01-26 23:58:46 -05:00
chore(sdk): Add InMemorySize as super trait of data primitive traits (#12465)
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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<Header: Compact> + 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<Self::BlockWithSenders<Self>>;
|
||||
|
||||
/// Calculates a heuristic for the in-memory size of the [`Block`].
|
||||
fn size(&self) -> usize;
|
||||
}
|
||||
|
||||
@@ -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"))]
|
||||
|
||||
Reference in New Issue
Block a user