You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug] AnyHeader fails to deserialize baseFeePerGas values exceeding u64::MAX #3741
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:
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.
Whether the value is "reasonable" isn't really the point; the spec says Uint and AnyHeader exists for non-standard chains. I'd expect AnyHeader to follow the spec here is there a reason for not doing so?
Saturating on deser would fix the deserialization failure, which is the main blocker. For our use case we'd still need the full value because expose baseFeePerGas to subgraph wasm mappings as BigInt, and it needs to be determinisitc across versions. The previous web3 crate used U256, so we'd need to preserve that to avoid a determinism break. I guess we'll need to use a custom header type on our end for this to keep supporting the chain. But saturating in AnyHeader would at least unblock other consumers hitting this.
Taking this with the saturating-on-deser direction.
Plan: custom deserialize_with on AnyHeader::base_fee_per_gas that accepts any numeric input and saturates to u64::MAX when the value exceeds u64. Wraps alloy_serde::quantity so hex strings and plain numbers both work, with overflow handled instead of erroring. Unit tests covering: in-range hex, in-range decimal, u64::MAX, exactly u64::MAX + 1, the chain-988 case (0x3635c9adc5dea00000 = 1e21), and null/absent (preserves None).
Activity
mattsse commentedon Feb 25, 2026
yeah maybe they shouldnt use a value > u64::max for a field that is supposed to be u64
incrypto32 commentedon Feb 25, 2026
Whether the value is "reasonable" isn't really the point; the spec says Uint and AnyHeader exists for non-standard chains. I'd expect AnyHeader to follow the spec here is there a reason for not doing so?
mattsse commentedon Feb 25, 2026
the "spec" says a lot of things
I'd expect chains not do to hacks like this.
I assume this was done to prevent any txs to land in earlier blocks.
would simply saturating this on deserde be an option? this could also lead to some issues but I'm hesitant to change the types here
incrypto32 commentedon Feb 25, 2026
Saturating on deser would fix the deserialization failure, which is the main blocker. For our use case we'd still need the full value because expose
baseFeePerGasto subgraph wasm mappings asBigInt, and it needs to be determinisitc across versions. The previous web3 crate usedU256, so we'd need to preserve that to avoid a determinism break. I guess we'll need to use a custom header type on our end for this to keep supporting the chain. But saturating inAnyHeaderwould at least unblock other consumers hitting this.gastonmichel commentedon May 5, 2026
Hello folks!
big fan of the project! appreciate every bit of it.
This issue hit us on the face after stable bumped the baseFeePerGas to 1000000000000000000000.
Is there a plan to change this baseFeePerGas from u64 to u128 at least?
satyakwok commentedon May 11, 2026
Taking this with the saturating-on-deser direction.
Plan: custom
deserialize_withonAnyHeader::base_fee_per_gasthat accepts any numeric input and saturates tou64::MAXwhen the value exceedsu64. Wrapsalloy_serde::quantityso hex strings and plain numbers both work, with overflow handled instead of erroring. Unit tests covering: in-range hex, in-range decimal,u64::MAX, exactlyu64::MAX + 1, the chain-988 case (0x3635c9adc5dea00000= 1e21), and null/absent (preservesNone).→ PR opened: #
fix(consensus-any): saturate baseFeePerGas above u64::MAX on deser (a…