|
8 | 8 | "math/big" |
9 | 9 |
|
10 | 10 | "github.com/ethereum/go-ethereum/arbitrum/multigas" |
| 11 | + "github.com/ethereum/go-ethereum/log" |
11 | 12 | "github.com/ethereum/go-ethereum/params" |
12 | 13 |
|
13 | 14 | "github.com/offchainlabs/nitro/util/arbmath" |
@@ -35,14 +36,6 @@ const ( |
35 | 36 | GasModelMultiGasConstraints |
36 | 37 | ) |
37 | 38 |
|
38 | | -var FeeRelevantResourceKinds = [...]multigas.ResourceKind{ |
39 | | - multigas.ResourceKindComputation, |
40 | | - multigas.ResourceKindHistoryGrowth, |
41 | | - multigas.ResourceKindStorageAccess, |
42 | | - multigas.ResourceKindStorageGrowth, |
43 | | - multigas.ResourceKindL1Calldata, |
44 | | -} |
45 | | - |
46 | 39 | func (ps *L2PricingState) GasModelToUse(arbosVersion uint64) (GasModel, error) { |
47 | 40 | if arbosVersion >= ArbosMultiGasConstraintsVersion { |
48 | 41 | constraintsLength, err := ps.MultiGasConstraintsLength() |
@@ -85,7 +78,7 @@ func (ps *L2PricingState) AddToGasPool(growBacklog bool, usedGas uint64, usedMul |
85 | 78 | case GasModelSingleGasConstraints: |
86 | 79 | return ps.addToGasPoolWithSingleGasConstraints(growBacklog, usedGas) |
87 | 80 | case GasModelMultiGasConstraints: |
88 | | - return ps.addToGasPoolWithMultiGasConstraints(growBacklog, usedMultiGas) |
| 81 | + return ps.addToGasPoolWithMultiGasConstraints(growBacklog, usedGas, usedMultiGas) |
89 | 82 | default: |
90 | 83 | return fmt.Errorf("can not determine gas model") |
91 | 84 | } |
@@ -119,20 +112,24 @@ func (ps *L2PricingState) addToGasPoolWithSingleGasConstraints(growBacklog bool, |
119 | 112 | return nil |
120 | 113 | } |
121 | 114 |
|
122 | | -func (ps *L2PricingState) addToGasPoolWithMultiGasConstraints(growBacklog bool, usedGas multigas.MultiGas) error { |
| 115 | +func (ps *L2PricingState) addToGasPoolWithMultiGasConstraints(growBacklog bool, usedGas uint64, usedMultiGas multigas.MultiGas) error { |
| 116 | + if usedMultiGas.SingleGas() != usedGas { |
| 117 | + log.Warn("usedGas does not match sum of usedMultiGas", "usedGas", usedGas, "usedMultiGas", usedMultiGas.SingleGas()) |
| 118 | + } |
| 119 | + |
123 | 120 | constraintsLength, err := ps.multigasConstraints.Length() |
124 | 121 | if err != nil { |
125 | 122 | return fmt.Errorf("failed to get number of multi-gas constraints: %w", err) |
126 | 123 | } |
127 | 124 | for i := range constraintsLength { |
128 | 125 | constraint := ps.OpenMultiGasConstraintAt(i) |
129 | 126 | if growBacklog { |
130 | | - err = constraint.IncrementBacklog(usedGas) |
| 127 | + err = constraint.IncrementBacklog(usedMultiGas) |
131 | 128 | if err != nil { |
132 | 129 | return fmt.Errorf("failed to increment backlog of multi-gas constraint %v: %w", i, err) |
133 | 130 | } |
134 | 131 | } else { |
135 | | - err = constraint.DecrementBacklog(usedGas) |
| 132 | + err = constraint.DecrementBacklog(usedMultiGas) |
136 | 133 | if err != nil { |
137 | 134 | return fmt.Errorf("failed to decrement backlog of multi-gas constraint %v: %w", i, err) |
138 | 135 | } |
|
0 commit comments