refactor(gas): rename InitialAndFloorGas.initial_total_gas to regular_gas#3589
Open
refactor(gas): rename InitialAndFloorGas.initial_total_gas to regular_gas#3589
Conversation
…_gas Replace `initial_total_gas` (which stored regular + state) with `regular_gas` (regular portion only), and rename `initial_state_gas` to `state_gas`. Total is now derived on demand via `total_gas()`. Also adds helpers for accumulating into each portion: - `total_gas(&self) -> u64` — saturating `regular_gas + state_gas` - `add_regular_gas(&mut self, u64)` — saturating `+=` on regular - `add_state_gas(&mut self, u64)` — saturating `+=` on state The `initial_regular_gas()` method is retained as a transition alias. Internal callers (`initial_tx_gas`, validation, post-execution) switch to the new API; `initial_tx_gas` drops its trailing `initial_total_gas += initial_state_gas` merge line since total is now computed on read.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Refactors
InitialAndFloorGasto store the regular and state portions of the intrinsic gas as separate fields and derive the total on demand, rather than keeping a pre-merged total plus a state subset. Also adds small accumulator helpers so call sites don't have to touch the fields directly.Field change
initial_total_gas: u64regular_gas: u64initial_state_gas: u64state_gas: u64floor_gaseip7702_reservoir_refundNew methods
total_gas(&self) -> u64— saturatingregular_gas + state_gasadd_regular_gas(&mut self, gas: u64)— saturating+=on the regular portionadd_state_gas(&mut self, gas: u64)— saturating+=on the state portioninitial_regular_gas()retained as a transition alias for pre-rename call sitesMigration
Downstream code that read
gas.initial_total_gasshould switch togas.total_gas(); direct writes (gas.initial_total_gas += x) becomegas.add_regular_gas(x)(if the increment was regular) orgas.add_state_gas(x)(if it was state).gas.initial_state_gasbecomesgas.state_gas.Internal callers updated
GasParams::initial_tx_gas— usesadd_regular_gas/add_state_gas; dropped the trailinginitial_total_gas += initial_state_gasmerge.validation.rs—total_gas()for the intrinsic-vs-gas-limit check;gas.regular_gasfor the EIP-8037 regular cap check.post_execution.rs::build_result_gas— readsstate_gas.pre_execution.rs/gas_params.rsupdated to the new field names.Test plan
cargo check --workspace— clean.cargo test --workspace --lib— all green, includingtest_initial_state_gas_for_create(updated to usestate_gas+total_gas()) and the handler validation suite.cargo clippy --workspace --all-targets— no new warnings.