|
32 | 32 | ApricotPhase4BlockGasCostStep = big.NewInt(50_000) |
33 | 33 | ApricotPhase4TargetBlockRate uint64 = 2 // in seconds |
34 | 34 | ApricotPhase5BlockGasCostStep = big.NewInt(200_000) |
35 | | - rollupWindow uint64 = 10 |
36 | 35 | ) |
37 | 36 |
|
38 | 37 | // CalcBaseFee takes the previous header and the timestamp of its child block |
@@ -87,7 +86,7 @@ func CalcBaseFee(config *params.ChainConfig, parent *types.Header, timestamp uin |
87 | 86 | // Add in the gas used by the parent block in the correct place |
88 | 87 | // If the parent consumed gas within the rollup window, add the consumed |
89 | 88 | // gas in. |
90 | | - if roll < rollupWindow { |
| 89 | + if roll < params.RollupWindow { |
91 | 90 | var blockGasCost, parentExtraStateGasUsed uint64 |
92 | 91 | switch { |
93 | 92 | case isApricotPhase5: |
@@ -133,13 +132,13 @@ func CalcBaseFee(config *params.ChainConfig, parent *types.Header, timestamp uin |
133 | 132 | } |
134 | 133 | } |
135 | 134 |
|
136 | | - slot := rollupWindow - 1 - roll |
| 135 | + slot := params.RollupWindow - 1 - roll |
137 | 136 | start := slot * wrappers.LongLen |
138 | 137 | updateLongWindow(newRollupWindow, start, addedGas) |
139 | 138 | } |
140 | 139 |
|
141 | 140 | // Calculate the amount of gas consumed within the rollup window. |
142 | | - totalGas := sumLongWindow(newRollupWindow, int(rollupWindow)) |
| 141 | + totalGas := sumLongWindow(newRollupWindow, params.RollupWindow) |
143 | 142 |
|
144 | 143 | if totalGas == parentGasTarget { |
145 | 144 | return newRollupWindow, baseFee, nil |
@@ -167,9 +166,9 @@ func CalcBaseFee(config *params.ChainConfig, parent *types.Header, timestamp uin |
167 | 166 | // for the interval during which no blocks were produced. |
168 | 167 | // We use roll/rollupWindow, so that the transition is applied for every [rollupWindow] seconds |
169 | 168 | // that has elapsed between the parent and this block. |
170 | | - if roll > rollupWindow { |
| 169 | + if roll > params.RollupWindow { |
171 | 170 | // Note: roll/rollupWindow must be greater than 1 since we've checked that roll > rollupWindow |
172 | | - baseFeeDelta = new(big.Int).Mul(baseFeeDelta, new(big.Int).SetUint64(roll/rollupWindow)) |
| 171 | + baseFeeDelta = new(big.Int).Mul(baseFeeDelta, new(big.Int).SetUint64(roll/params.RollupWindow)) |
173 | 172 | } |
174 | 173 | baseFee.Sub(baseFee, baseFeeDelta) |
175 | 174 | } |
|
0 commit comments