Skip to content

[Bug] AnyHeader fails to deserialize baseFeePerGas values exceeding u64::MAX #3741

@incrypto32

Description

@incrypto32

Component

consensus, eips, genesis

What version of Alloy are you on?

No response

Operating System

macOS (Apple Silicon)

Describe the bug

AnyHeader::base_fee_per_gas is typed as Option<u64>, which causes deserialization failures on chains where baseFeePerGas exceeds u64::MAX.

We encountered this on a live EVM-compatible chain (Stable, chain ID 988) that returns baseFeePerGas: "0x3635c9adc5dea00000" (10^21) for a range of historical blocks. Deserializing the RPC response fails with:

invalid type: integer `1000000000000000000000`, expected u64

Spec vs implementation

The Ethereum execution spec defines base_fee_per_gas as Uint (arbitrary-precision), while explicitly choosing U64 for blob_gas_used and excess_blob_gas. This distinction appears intentional.

In alloy, AnyHeader uses Option<u64> for base_fee_per_gas, and the BlockHeader trait constrains the return type to Option<u64>.

Suggestion

Change AnyHeader::base_fee_per_gas from Option<u64> to Option<U256> (or Option<u128>). This would be consistent with AnyHeader's documented purpose of accounting for "possible differences in network implementations". Ideally the BlockHeader trait method would also be widened, but even just changing AnyHeader would eliminate the deserialization failure.

The same consideration may apply to gas_limit and gas_used, which the spec also defines as Uint.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions