Skip to content

fix: widen trace gas fields from u32 to u64 to prevent overflow#259

Open
dylantirandaz wants to merge 1 commit intoparadigmxyz:mainfrom
dylantirandaz:fix/trace-gas-overflow
Open

fix: widen trace gas fields from u32 to u64 to prevent overflow#259
dylantirandaz wants to merge 1 commit intoparadigmxyz:mainfrom
dylantirandaz:fix/trace-gas-overflow

Conversation

@dylantirandaz
Copy link
Copy Markdown

Motivation

On chains like BSC, transactions can have gas values exceeding u32::MAX (4,294,967,295). The action_gas and result_gas_used fields in both the Traces and TraceCalls datasets were stored as u32, and gas values were cast with as u32 which silently truncates large values (#173).

The blocks and transactions datasets already correctly use u64 for gas fields, consistent with the schema design guide which specifies gas_used: u64 and gas_limit: u64.

Solution

Widen action_gas and result_gas_used from Vec<Option<u32>> to Vec<Option<u64>> in both Traces and TraceCalls structs, and update all corresponding casts from as u32 to as u64.

Changed files:

  • crates/freeze/src/datasets/traces.rs — 2 field types + 4 casts
  • crates/freeze/src/datasets/trace_calls.rs — 2 field types + 4 casts

Fixes #173

PR Checklist

  • Added Tests
  • Added Documentation
  • Breaking changes

On chains like BSC, transactions can have gas values exceeding u32::MAX
(4,294,967,295). The action_gas and result_gas_used fields in both the
Traces and TraceCalls datasets were stored as u32 and cast with
`as u32`, silently truncating large values and causing incorrect data.

Widen these fields to u64 to match the convention already used by the
blocks and transactions datasets, as documented in the schema design
guide (gas_used: u64, gas_limit: u64).

Fixes paradigmxyz#173
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