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

consensus: make Header base_fee_per_gas u64 #1375

Merged
merged 1 commit into from
Sep 26, 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
10 changes: 5 additions & 5 deletions crates/consensus/src/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ pub struct Header {
skip_serializing_if = "Option::is_none"
)
)]
pub base_fee_per_gas: Option<u128>,
pub base_fee_per_gas: Option<u64>,
/// The total amount of blob gas consumed by the transactions within the block, added in
/// EIP-4844.
#[cfg_attr(
Expand Down Expand Up @@ -235,7 +235,7 @@ impl Header {
Some(calc_next_block_base_fee(
self.gas_used,
self.gas_limit,
self.base_fee_per_gas? as u64,
self.base_fee_per_gas?,
base_fee_params,
))
}
Expand Down Expand Up @@ -511,7 +511,7 @@ impl Decodable for Header {
if buf.first().map(|b| *b == EMPTY_LIST_CODE).unwrap_or_default() {
buf.advance(1)
} else {
this.base_fee_per_gas = Some(U256::decode(buf)?.to::<u128>());
this.base_fee_per_gas = Some(U256::decode(buf)?.to::<u64>());
}
}

Expand Down Expand Up @@ -695,7 +695,7 @@ pub trait BlockHeader {
fn nonce(&self) -> B64;

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

/// Retrieves the blob gas used by the block, if available
fn blob_gas_used(&self) -> Option<u128>;
Expand Down Expand Up @@ -774,7 +774,7 @@ impl BlockHeader for Header {
self.nonce
}

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

Expand Down
4 changes: 2 additions & 2 deletions crates/network-primitives/src/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ pub trait HeaderResponse {
fn extra_data(&self) -> &Bytes;

/// Base fee per unit of gas (If EIP-1559 is supported)
fn base_fee_per_gas(&self) -> Option<u128>;
fn base_fee_per_gas(&self) -> Option<u64>;

/// Blob fee for the next block (if EIP-4844 is supported)
fn next_block_blob_fee(&self) -> Option<u128>;
Expand Down Expand Up @@ -380,7 +380,7 @@ impl<T: HeaderResponse> HeaderResponse for WithOtherFields<T> {
self.inner.extra_data()
}

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

Expand Down
2 changes: 1 addition & 1 deletion crates/provider/src/ext/anvil.rs
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ mod tests {
let block =
provider.get_block_by_number(BlockNumberOrTag::Latest, false).await.unwrap().unwrap();

assert_eq!(block.header.base_fee_per_gas, Some(basefee.to::<u128>()));
assert_eq!(block.header.base_fee_per_gas, Some(basefee.to::<u64>()));
}

#[tokio::test]
Expand Down
3 changes: 2 additions & 1 deletion crates/provider/src/provider/trait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ pub trait Provider<T: Transport + Clone = BoxTransport, N: Network = Ethereum>:
self.client().request("eth_simulateV1", payload).into()
}

/// Gets the chain ID.
/// Gets the chain ID.
fn get_chain_id(&self) -> ProviderCall<T, NoParams, U64, u64> {
self.client()
.request_noparams("eth_chainId")
Expand Down Expand Up @@ -230,6 +230,7 @@ pub trait Provider<T: Transport + Clone = BoxTransport, N: Network = Ethereum>:
.header()
.base_fee_per_gas()
.ok_or(RpcError::UnsupportedFeature("eip1559"))?
.into()
}
};

Expand Down
4 changes: 2 additions & 2 deletions crates/rpc-types-eth/src/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ pub struct Header {
with = "alloy_serde::quantity::opt"
)
)]
pub base_fee_per_gas: Option<u128>,
pub base_fee_per_gas: Option<u64>,
/// Withdrawals root hash added by EIP-4895 and is ignored in legacy headers.
#[cfg_attr(feature = "serde", serde(default, skip_serializing_if = "Option::is_none"))]
pub withdrawals_root: Option<B256>,
Expand Down Expand Up @@ -247,7 +247,7 @@ impl HeaderResponse for Header {
&self.extra_data
}

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

Expand Down