Skip to content

Commit a15a068

Browse files
committed
apply comments
1 parent 2dafa03 commit a15a068

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

core/types/rollup_cost.go

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -220,13 +220,18 @@ func NewOperatorCostFunc(config *params.ChainConfig, statedb StateGetter) Operat
220220
}
221221
}
222222
operatorFeeParams := statedb.GetState(L1BlockAddr, OperatorFeeParamsSlot)
223+
if operatorFeeParams == (common.Hash{}) {
224+
return func(gas uint64) *uint256.Int {
225+
return uint256.NewInt(0)
226+
}
227+
}
223228
operatorFeeScalar, operatorFeeConstant := ExtractOperatorFeeParams(operatorFeeParams)
224229

225-
// Return the Jovian version if Jovian is active
226-
if config.IsOptimismJovian(blockTime) {
227-
return newOperatorCostFuncJovian(operatorFeeScalar, operatorFeeConstant)
230+
// Return the Operator Fee fix version if the feature is active
231+
if config.IsOperatorFeeFix(blockTime) {
232+
return newOperatorCostFuncOperatorFeeFix(operatorFeeScalar, operatorFeeConstant)
228233
}
229-
return newOperatorCostFunc(operatorFeeScalar, operatorFeeConstant)
234+
return newOperatorCostFuncIsthmus(operatorFeeScalar, operatorFeeConstant)
230235
}
231236

232237
return func(gas uint64, blockTime uint64) *uint256.Int {
@@ -239,8 +244,8 @@ func NewOperatorCostFunc(config *params.ChainConfig, statedb StateGetter) Operat
239244
}
240245
}
241246

242-
// newOperatorCostFunc returns the operator cost function for Isthmus.
243-
func newOperatorCostFunc(operatorFeeScalar *big.Int, operatorFeeConstant *big.Int) operatorCostFunc {
247+
// newOperatorCostFuncIsthmus returns the operator cost function introduced with Isthmus.
248+
func newOperatorCostFuncIsthmus(operatorFeeScalar *big.Int, operatorFeeConstant *big.Int) operatorCostFunc {
244249
return func(gas uint64) *uint256.Int {
245250
fee := new(big.Int).SetUint64(gas)
246251
fee = fee.Mul(fee, operatorFeeScalar)
@@ -257,8 +262,8 @@ func newOperatorCostFunc(operatorFeeScalar *big.Int, operatorFeeConstant *big.In
257262
}
258263
}
259264

260-
// newOperatorCostFuncJovian returns the operator cost function for Jovian and later.
261-
func newOperatorCostFuncJovian(operatorFeeScalar *big.Int, operatorFeeConstant *big.Int) operatorCostFunc {
265+
// newOperatorCostFuncOperatorFeeFix returns the operator cost function for the operator fee fix feature.
266+
func newOperatorCostFuncOperatorFeeFix(operatorFeeScalar *big.Int, operatorFeeConstant *big.Int) operatorCostFunc {
262267
return func(gas uint64) *uint256.Int {
263268
fee := new(big.Int).SetUint64(gas)
264269
fee = fee.Mul(fee, operatorFeeScalar)

params/config.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -898,6 +898,12 @@ func (c *ChainConfig) IsOptimismJovian(time uint64) bool {
898898
return c.IsOptimism() && c.IsJovian(time)
899899
}
900900

901+
// IsOperatorFeeFix returns true if the operator fee fix feature is active.
902+
// TODO(fakedev9999): decouple from Jovian activation by wiring this into an explicit feature toggle.
903+
func (c *ChainConfig) IsOperatorFeeFix(time uint64) bool {
904+
return c.IsOptimismJovian(time)
905+
}
906+
901907
// IsOptimismPreBedrock returns true iff this is an optimism node & bedrock is not yet active
902908
func (c *ChainConfig) IsOptimismPreBedrock(num *big.Int) bool {
903909
return c.IsOptimism() && !c.IsBedrock(num)

0 commit comments

Comments
 (0)