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

[Feature] Make some gas fields u64 for Header #1241

Closed
tcoratger opened this issue Sep 5, 2024 · 2 comments · Fixed by #1377
Closed

[Feature] Make some gas fields u64 for Header #1241

tcoratger opened this issue Sep 5, 2024 · 2 comments · Fixed by #1377
Labels
enhancement New feature or request

Comments

@tcoratger
Copy link
Contributor

Component

consensus, eips, genesis

Describe the feature you would like

At the moment, some header gas fields are u128:

pub gas_limit: u128,
/// A scalar value equal to the total gas used in transactions in this block; formally Hg.
#[cfg_attr(feature = "serde", serde(with = "alloy_serde::quantity"))]
pub gas_used: u128,
/// A scalar value equal to the reasonable output of Unix’s time() at this block’s inception;
/// formally Hs.
#[cfg_attr(feature = "serde", serde(with = "alloy_serde::quantity"))]
pub timestamp: u64,
/// A 256-bit hash which, combined with the
/// nonce, proves that a sufficient amount of computation has been carried out on this block;
/// formally Hm.
pub mix_hash: B256,
/// A 64-bit value which, combined with the mixhash, proves that a sufficient amount of
/// computation has been carried out on this block; formally Hn.
pub nonce: B64,
/// A scalar representing EIP1559 base fee which can move up or down each block according
/// to a formula which is a function of gas used in parent block and gas target
/// (block gas limit divided by elasticity multiplier) of parent block.
/// The algorithm results in the base fee per gas increasing when blocks are
/// above the gas target, and decreasing when blocks are below the gas target. The base fee per
/// gas is burned.
#[cfg_attr(
feature = "serde",
serde(
default,
with = "alloy_serde::quantity::opt",
skip_serializing_if = "Option::is_none"
)
)]
pub base_fee_per_gas: Option<u128>,
/// The total amount of blob gas consumed by the transactions within the block, added in
/// EIP-4844.
#[cfg_attr(
feature = "serde",
serde(
default,
with = "alloy_serde::quantity::opt",
skip_serializing_if = "Option::is_none"
)
)]
pub blob_gas_used: Option<u128>,

This includes:

  • gas_limit
  • gas_used
  • base_fee_per_gas
  • blob_gas_used
  • excess_blob_gas

All these fields are considered as u64 in reth which leads to a lot of unnecessary conversions as pointed out here paradigmxyz/reth#10691 (comment). If there is no particular contraindication, it would be good to make all these fields become u64 directly in alloy to standardize and avoid conversions in reth.

Additional context

No response

@klkvr
Copy link
Member

klkvr commented Sep 7, 2024

I think if we actually want to do this, any gas fields in alloy should be turned into u64 as otherwise we'd just end up with same conversions but in other places

this will be both breaking and a bit confusing, so would like @mattsse @yash-atreya to confirm that we're fine with doing this in next breaking release before someone starts working on this

also I think base_fee_per_gas should stay as u128, and should be set to u128 in reth too

@yash-atreya
Copy link
Member

yash-atreya commented Sep 9, 2024

We had done a numerical audit #454 #474 and decided that gas fields should be u128, but makes sense to unify them to u64 since reth and revm both use u64.

also I think base_fee_per_gas should stay as u128, and should be set to u128 in reth too

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants