Skip to content

fix(traces): use u64 for action_gas and result_gas_used to prevent overflow#256

Open
AuburyEssentian wants to merge 2 commits intoparadigmxyz:mainfrom
AuburyEssentian:fix/traces-gas-u64
Open

fix(traces): use u64 for action_gas and result_gas_used to prevent overflow#256
AuburyEssentian wants to merge 2 commits intoparadigmxyz:mainfrom
AuburyEssentian:fix/traces-gas-u64

Conversation

@AuburyEssentian
Copy link
Copy Markdown

Problem

Closes #173.

On BSC and other high-throughput EVM chains, gas values can exceed u32::MAX (~4.29 billion). The alloy parity types already use u64 for these fields, but cryo was narrowing them with as u32 casts before storing, causing integer overflow panics on any block containing a transaction with gas above the u32 ceiling.

The affected transaction in the issue (0x33bd1edf...07920a6) has a gas limit larger than u32::MAX, which panics in dev builds and silently wraps in release.

Root cause

Two dataset structs both declared their gas columns as u32:

  • Traces: action_gas: Vec<Option<u32>> and result_gas_used: Vec<Option<u32>>
  • TraceCalls: same fields, same types

The store! calls then cast action.gas as u32 and result.gas_used as u32, truncating any value > 4,294,967,295.

Fix

Change both column types to u64 and remove the casts. The underlying alloy types (Call::gas, CallOutput::gas_used, Create::gas, CreateOutput::gas_used) are already u64, so no other changes are needed.

Affected files:

  • crates/freeze/src/datasets/traces.rs
  • crates/freeze/src/datasets/trace_calls.rs

Aubury Essentian added 2 commits March 7, 2026 04:04
When --reorg-buffer N is set, apply_reorg_buffer previously filtered out
any chunk whose max block exceeded latest_block - N. This silently dropped
the partial tail chunk (e.g. blocks 20030000-20030787 when only up to
20029999 is safe), causing cryo to never collect those trailing blocks.

Fix: replace the filter_map that drops whole chunks with clamp_chunk_to_max,
which truncates Range chunks to max_allowed and filters Numbers vectors,
preserving all safe blocks within a chunk.

Fixes paradigmxyz#193
…erflow

Closes paradigmxyz#173.

On BSC and other high-throughput EVM chains, gas values can exceed u32::MAX
(~4.29 billion). The alloy parity types already use u64 for gas fields, but
cryo was truncating them with `as u32` before storing, causing integer
overflow panics on any block containing a transaction with gas > 4,294,967,295.

Fix: change action_gas and result_gas_used column types from u32 to u64 in
both Traces and TraceCalls datasets, and remove the unsafe casts.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cryo crashes on BSC: Integer overflow when casting to u32

1 participant