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(sdk): Remove duplicate trait BlockHeader #12584

Merged
merged 2 commits into from
Nov 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 0 additions & 64 deletions crates/primitives-traits/src/header/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,72 +7,8 @@ pub use error::HeaderError;
#[cfg(any(test, feature = "test-utils", feature = "arbitrary"))]
pub mod test_utils;

use alloy_consensus::Header;
use alloy_primitives::{Address, BlockNumber, B256, U256};

/// Bincode-compatible header type serde implementations.
#[cfg(feature = "serde-bincode-compat")]
pub mod serde_bincode_compat {
pub use super::sealed::serde_bincode_compat::SealedHeader;
}

/// Trait for extracting specific Ethereum block data from a header
pub trait BlockHeader {
/// Retrieves the beneficiary (miner) of the block
fn beneficiary(&self) -> Address;

/// Retrieves the difficulty of the block
fn difficulty(&self) -> U256;

/// Retrieves the block number
fn number(&self) -> BlockNumber;

/// Retrieves the gas limit of the block
fn gas_limit(&self) -> u64;

/// Retrieves the timestamp of the block
fn timestamp(&self) -> u64;

/// Retrieves the mix hash of the block
fn mix_hash(&self) -> B256;

/// Retrieves the base fee per gas of the block, if available
fn base_fee_per_gas(&self) -> Option<u64>;

/// Retrieves the excess blob gas of the block, if available
fn excess_blob_gas(&self) -> Option<u64>;
}

impl BlockHeader for Header {
fn beneficiary(&self) -> Address {
self.beneficiary
}

fn difficulty(&self) -> U256 {
self.difficulty
}

fn number(&self) -> BlockNumber {
self.number
}

fn gas_limit(&self) -> u64 {
self.gas_limit
}

fn timestamp(&self) -> u64 {
self.timestamp
}

fn mix_hash(&self) -> B256 {
self.mix_hash
}

fn base_fee_per_gas(&self) -> Option<u64> {
self.base_fee_per_gas
}

fn excess_blob_gas(&self) -> Option<u64> {
self.excess_blob_gas
}
}
9 changes: 5 additions & 4 deletions crates/primitives-traits/src/header/sealed.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
use super::Header;
use crate::InMemorySize;
use alloy_consensus::Sealed;
use core::mem;

use alloy_consensus::{Header, Sealed};
use alloy_eips::BlockNumHash;
use alloy_primitives::{keccak256, BlockHash, Sealable, B256};
use alloy_rlp::{Decodable, Encodable};
use bytes::BufMut;
use core::mem;
use derive_more::{AsRef, Deref};
use reth_codecs::add_arbitrary_tests;
use serde::{Deserialize, Serialize};

use crate::InMemorySize;

/// A helper struct to store the block number/hash and its parent hash.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub struct BlockWithParent {
Expand Down
Loading