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

primitives: remove BlockHeader and Header reexport #11127

Closed
Tracked by #12576
tcoratger opened this issue Sep 23, 2024 · 3 comments
Closed
Tracked by #12576

primitives: remove BlockHeader and Header reexport #11127

tcoratger opened this issue Sep 23, 2024 · 3 comments
Labels
C-enhancement New feature or request S-needs-triage This issue needs to be labelled S-stale This issue/PR is stale and will close with no further activity

Comments

@tcoratger
Copy link
Contributor

Describe the feature

After the merge of alloy-rs/alloy#1302 and its inclusion over the next release of alloy, we can completely remove BlockHeader trait and Header reexport here

use alloy_primitives::{Address, BlockNumber, B256, U256};
/// 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 as u64
}
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.map(|base_fee| base_fee as u64)
}
fn excess_blob_gas(&self) -> Option<u64> {
self.excess_blob_gas.map(|excess_blob_gas| excess_blob_gas as u64)
}
}

We can then import everything from alloy directly when needed around the codebase.

Additional context

No response

@0xkrane
Copy link
Contributor

0xkrane commented Sep 24, 2024

can take a stab at this

Copy link
Contributor

This issue is stale because it has been open for 21 days with no activity.

@github-actions github-actions bot added the S-stale This issue/PR is stale and will close with no further activity label Oct 16, 2024
@mattsse
Copy link
Collaborator

mattsse commented Oct 16, 2024

we likely want a smaller trait for this because we only need a subset from this alloy trait

@mattsse mattsse closed this as completed Oct 16, 2024
@github-project-automation github-project-automation bot moved this from Todo to Done in Reth Tracker Oct 16, 2024
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 S-needs-triage This issue needs to be labelled S-stale This issue/PR is stale and will close with no further activity
Projects
Archived in project
Development

No branches or pull requests

3 participants