Skip to content

Commit 5dc32f7

Browse files
wip: switch AddToGasPool on multi-dimensional gas
1 parent 75a3468 commit 5dc32f7

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

arbos/l2pricing/model.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"fmt"
88
"math/big"
99

10+
"github.com/ethereum/go-ethereum/arbitrum/multigas"
1011
"github.com/ethereum/go-ethereum/params"
1112

1213
"github.com/offchainlabs/nitro/util/arbmath"
@@ -56,16 +57,16 @@ func (ps *L2PricingState) GasModelToUse(arbosVersion uint64) (GasModel, error) {
5657
return GasModelLegacy, nil
5758
}
5859

59-
func (ps *L2PricingState) AddToGasPool(gas int64, arbosVersion uint64) error {
60+
func (ps *L2PricingState) AddToGasPool(gas multigas.MultiGas, arbosVersion uint64) error {
6061
gasModel, err := ps.GasModelToUse(arbosVersion)
6162
if err != nil {
6263
return err
6364
}
6465
switch gasModel {
6566
case GasModelLegacy:
66-
return ps.addToGasPoolLegacy(gas)
67+
return ps.addToGasPoolLegacy(arbmath.SaturatingCast[int64](gas.SingleGas()))
6768
case GasModelSingleGasConstraints:
68-
return ps.addToGasPoolWithSingleGasConstraints(gas)
69+
return ps.addToGasPoolWithSingleGasConstraints(arbmath.SaturatingCast[int64](gas.SingleGas()))
6970
case GasModelMultiGasConstraints:
7071
return ps.addToGasPoolWithMultiGasConstraints(gas)
7172
default:
@@ -101,7 +102,7 @@ func (ps *L2PricingState) addToGasPoolWithSingleGasConstraints(gas int64) error
101102
return nil
102103
}
103104

104-
func (ps *L2PricingState) addToGasPoolWithMultiGasConstraints(_gas int64) error {
105+
func (ps *L2PricingState) addToGasPoolWithMultiGasConstraints(_gas multigas.MultiGas) error {
105106
return fmt.Errorf("addToGasPoolWithMultiGasConstraints not implemented")
106107
}
107108

precompiles/ArbRetryableTx.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,8 @@ func (con ArbRetryableTx) Redeem(c ctx, evm mech, ticketId bytes32) (bytes32, er
136136

137137
// Add the gasToDonate back to the gas pool: the retryable attempt will then consume it.
138138
// This ensures that the gas pool has enough gas to run the retryable attempt.
139-
return retryTxHash, c.State.L2PricingState().AddToGasPool(arbmath.SaturatingCast[int64](gasToDonate), c.State.ArbOSVersion())
139+
// TODO(NIT-4120): clarify the gas dimension for gasToDonate
140+
return retryTxHash, c.State.L2PricingState().AddToGasPool(multigas.ComputationGas(gasToDonate), c.State.ArbOSVersion())
140141
}
141142

142143
// GetLifetime gets the default lifetime period a retryable has at creation

0 commit comments

Comments
 (0)