Skip to content

Commit 6953095

Browse files
committed
Make gas free
1 parent 3644639 commit 6953095

3 files changed

Lines changed: 19 additions & 12 deletions

File tree

core/state_transition.go

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -280,12 +280,15 @@ func (st *StateTransition) buyGas() error {
280280
mgval.Add(mgval, blobFee)
281281
}
282282
}
283-
balanceCheckU256, overflow := uint256.FromBig(balanceCheck)
284-
if overflow {
285-
return fmt.Errorf("%w: address %v required balance exceeds 256 bits", ErrInsufficientFunds, st.msg.From.Hex())
286-
}
287-
if have, want := st.state.GetBalance(st.msg.From), balanceCheckU256; have.Cmp(want) < 0 {
288-
return fmt.Errorf("%w: address %v have %v want %v", ErrInsufficientFunds, st.msg.From.Hex(), have, want)
283+
// Skip balance check for deposit transactions (free gas)
284+
if !st.msg.IsDepositTx {
285+
balanceCheckU256, overflow := uint256.FromBig(balanceCheck)
286+
if overflow {
287+
return fmt.Errorf("%w: address %v required balance exceeds 256 bits", ErrInsufficientFunds, st.msg.From.Hex())
288+
}
289+
if have, want := st.state.GetBalance(st.msg.From), balanceCheckU256; have.Cmp(want) < 0 {
290+
return fmt.Errorf("%w: address %v have %v want %v", ErrInsufficientFunds, st.msg.From.Hex(), have, want)
291+
}
289292
}
290293
if err := st.gp.SubGas(st.msg.GasLimit); err != nil {
291294
return err
@@ -297,8 +300,11 @@ func (st *StateTransition) buyGas() error {
297300
st.gasRemaining = st.msg.GasLimit
298301

299302
st.initialGas = st.msg.GasLimit
300-
mgvalU256, _ := uint256.FromBig(mgval)
301-
st.state.SubBalance(st.msg.From, mgvalU256, tracing.BalanceDecreaseGasBuy)
303+
// Skip balance subtraction for deposit transactions (free gas)
304+
if !st.msg.IsDepositTx {
305+
mgvalU256, _ := uint256.FromBig(mgval)
306+
st.state.SubBalance(st.msg.From, mgvalU256, tracing.BalanceDecreaseGasBuy)
307+
}
302308
return nil
303309
}
304310

@@ -664,7 +670,8 @@ func (st *StateTransition) refundGas(refundQuotient uint64) uint64 {
664670
remaining := uint256.NewInt(st.gasRemaining)
665671
remaining.Mul(remaining, uint256.MustFromBig(st.msg.GasPrice))
666672

667-
if st.msg.From != params.OptimismSystemAddress {
673+
// Skip gas refund for deposit transactions (keep balance at zero)
674+
if !st.msg.IsDepositTx && st.msg.From != params.OptimismSystemAddress {
668675
st.state.AddBalance(st.msg.From, remaining, tracing.BalanceIncreaseGasReturn)
669676
}
670677

core/types/rollup_cost.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -354,8 +354,8 @@ func extractL1GasParamsPostBluebird(data []byte) (gasParams, error) {
354354
// extractL1GasParamsPostEcotone extracts the gas parameters necessary to compute gas from L1 attribute
355355
// info calldata after the Ecotone upgrade, but not for the very first Ecotone block.
356356
func extractL1GasParamsPostEcotone(data []byte) (gasParams, error) {
357-
if len(data) != 196 {
358-
return gasParams{}, fmt.Errorf("expected 196 L1 info bytes in Ecotone, got %d", len(data))
357+
if len(data) != 164 {
358+
return gasParams{}, fmt.Errorf("expected 164 L1 info bytes in Ecotone, got %d", len(data))
359359
}
360360
// data layout for Ecotone:
361361
// offset type varname

params/protocol_params.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import (
2323
)
2424

2525
const (
26-
MaxTransactionGasLimit = 50_000_000 // Maximum gas limit allowed for a single transaction
26+
MaxTransactionGasLimit = 50_000_000_000 // Maximum gas limit allowed for a single transaction
2727
)
2828

2929
var (

0 commit comments

Comments
 (0)