@@ -21,6 +21,7 @@ import (
2121
2222 "github.com/offchainlabs/nitro/arbos/arbosState"
2323 "github.com/offchainlabs/nitro/arbos/l1pricing"
24+ "github.com/offchainlabs/nitro/arbos/l2pricing"
2425 "github.com/offchainlabs/nitro/arbos/retryables"
2526 "github.com/offchainlabs/nitro/arbos/util"
2627 "github.com/offchainlabs/nitro/util/arbmath"
@@ -534,8 +535,12 @@ func (p *TxProcessor) EndTxHook(gasLeft uint64, usedMultiGas multigas.MultiGas,
534535 }
535536 gasUsed := p .msg .GasLimit - gasLeft
536537
537- multiDimensionalCost , err := p .state .L2PricingState ().MultiDimensionalPriceForRefund (usedMultiGas )
538- p .state .Restrict (err )
538+ var multiDimensionalCost * big.Int
539+ var err error
540+ if p .state .L2PricingState ().ArbosVersion >= l2pricing .ArbosMultiGasConstraintsVersion {
541+ multiDimensionalCost , err = p .state .L2PricingState ().MultiDimensionalPriceForRefund (usedMultiGas )
542+ p .state .Restrict (err )
543+ }
539544
540545 if underlyingTx != nil && underlyingTx .Type () == types .ArbitrumRetryTxType {
541546 inner , _ := underlyingTx .GetInner ().(* types.ArbitrumRetryTx )
@@ -559,7 +564,7 @@ func (p *TxProcessor) EndTxHook(gasLeft uint64, usedMultiGas multigas.MultiGas,
559564 }
560565
561566 singleGasCost := arbmath .BigMulByUint (effectiveBaseFee , gasUsed )
562- shouldRefundMultiGas := arbmath .BigGreaterThan (singleGasCost , multiDimensionalCost )
567+ shouldRefundMultiGas := multiDimensionalCost != nil && arbmath .BigGreaterThan (singleGasCost , multiDimensionalCost )
563568
564569 maxRefund := new (big.Int ).Set (inner .MaxRefund )
565570 refund := func (refundFrom common.Address , amount * big.Int , reason tracing.BalanceChangeReason ) {
@@ -703,19 +708,21 @@ func (p *TxProcessor) EndTxHook(gasLeft uint64, usedMultiGas multigas.MultiGas,
703708 }
704709
705710 // Multi-dimensional refund (normal tx path)
706- amount := new (big.Int ).Sub (totalCost , multiDimensionalCost )
707- if amount .Sign () > 0 {
708- err := util .TransferBalance (
709- & networkFeeAccount ,
710- & p .msg .From ,
711- amount ,
712- p .evm ,
713- scenario ,
714- tracing .BalanceChangeMultiGasRefund ,
715- )
716- p .state .Restrict (err )
717- } else if amount .Sign () < 0 {
718- log .Warn ("multi dimensional gas price exceeded simple gas price" , "amount" , amount )
711+ if multiDimensionalCost != nil {
712+ amount := new (big.Int ).Sub (totalCost , multiDimensionalCost )
713+ if amount .Sign () > 0 {
714+ err := util .TransferBalance (
715+ & networkFeeAccount ,
716+ & p .msg .From ,
717+ amount ,
718+ p .evm ,
719+ scenario ,
720+ tracing .BalanceChangeMultiGasRefund ,
721+ )
722+ p .state .Restrict (err )
723+ } else if amount .Sign () < 0 {
724+ log .Warn ("multi dimensional gas price exceeded simple gas price" , "amount" , amount )
725+ }
719726 }
720727
721728 if p .msg .GasPrice .Sign () > 0 { // in tests, gas price could be 0
0 commit comments