diff --git a/consensus/beacon/consensus.go b/consensus/beacon/consensus.go index 366cce89fd..b0e9846303 100644 --- a/consensus/beacon/consensus.go +++ b/consensus/beacon/consensus.go @@ -412,7 +412,7 @@ func (beacon *Beacon) FinalizeAndAssemble(chain consensus.ChainHeaderReader, hea // Store DA footprint in BlobGasUsed header field if it hasn't already been set yet. // Builder code may already calculate it during block building to avoid recalculating it here. - if chain.Config().IsDAFootprintBlockLimit(header.Time) && (header.BlobGasUsed == nil || *header.BlobGasUsed == 0) { + if chain.Config().IsJovian(header.Time) && (header.BlobGasUsed == nil || *header.BlobGasUsed == 0) { daFootprint, err := types.CalcDAFootprint(body.Transactions) if err != nil { return nil, fmt.Errorf("error calculating DA footprint: %w", err) diff --git a/consensus/misc/eip1559/eip1559.go b/consensus/misc/eip1559/eip1559.go index eb5dfed657..413d6c3b82 100644 --- a/consensus/misc/eip1559/eip1559.go +++ b/consensus/misc/eip1559/eip1559.go @@ -92,7 +92,7 @@ func CalcBaseFee(config *params.ChainConfig, parent *types.Header, time uint64) func calcBaseFeeInner(config *params.ChainConfig, parent *types.Header, elasticity uint64, denominator uint64) *big.Int { parentGasTarget := parent.GasLimit / elasticity parentGasMetered := parent.GasUsed - if config.IsDAFootprintBlockLimit(parent.Time) { + if config.IsJovian(parent.Time) { if parent.BlobGasUsed == nil { panic("Jovian parent block has nil BlobGasUsed") } else if *parent.BlobGasUsed > parent.GasUsed { diff --git a/consensus/misc/eip1559/eip1559_optimism.go b/consensus/misc/eip1559/eip1559_optimism.go index 1c6f49cc22..8a6c2810d2 100644 --- a/consensus/misc/eip1559/eip1559_optimism.go +++ b/consensus/misc/eip1559/eip1559_optimism.go @@ -12,14 +12,14 @@ const MinBaseFeeExtraDataVersionByte = uint8(0x01) type ForkChecker interface { IsHolocene(time uint64) bool - IsMinBaseFee(time uint64) bool + IsJovian(time uint64) bool } // ValidateOptimismExtraData validates the Optimism extra data. // It uses the config and parent time to determine how to do the validation. func ValidateOptimismExtraData(fc ForkChecker, time uint64, extraData []byte) error { - if fc.IsMinBaseFee(time) { - return ValidateMinBaseFeeExtraData(extraData) + if fc.IsJovian(time) { + return ValidateJovianExtraData(extraData) } else if fc.IsHolocene(time) { return ValidateHoloceneExtraData(extraData) } else if len(extraData) > 0 { // pre-Holocene @@ -32,8 +32,8 @@ func ValidateOptimismExtraData(fc ForkChecker, time uint64, extraData []byte) er // It uses the config and parent time to determine how to do the decoding. // The parent.extraData is expected to be valid (i.e. ValidateOptimismExtraData has been called previously) func DecodeOptimismExtraData(fc ForkChecker, time uint64, extraData []byte) (uint64, uint64, *uint64) { - if fc.IsMinBaseFee(time) { - denominator, elasticity, minBaseFee := DecodeMinBaseFeeExtraData(extraData) + if fc.IsJovian(time) { + denominator, elasticity, minBaseFee := DecodeJovianExtraData(extraData) return denominator, elasticity, minBaseFee } else if fc.IsHolocene(time) { denominator, elasticity := DecodeHoloceneExtraData(extraData) @@ -45,11 +45,11 @@ func DecodeOptimismExtraData(fc ForkChecker, time uint64, extraData []byte) (uin // EncodeOptimismExtraData encodes the Optimism extra data. // It uses the config and parent time to determine how to do the encoding. func EncodeOptimismExtraData(fc ForkChecker, time uint64, denominator, elasticity uint64, minBaseFee *uint64) []byte { - if fc.IsMinBaseFee(time) { + if fc.IsJovian(time) { if minBaseFee == nil { panic("minBaseFee cannot be nil since the MinBaseFee feature is enabled") } - return EncodeMinBaseFeeExtraData(denominator, elasticity, *minBaseFee) + return EncodeJovianExtraData(denominator, elasticity, *minBaseFee) } else if fc.IsHolocene(time) { return EncodeHoloceneExtraData(denominator, elasticity) } else { @@ -136,9 +136,9 @@ func ValidateHoloceneExtraData(extra []byte) error { // DecodeMinBaseFeeExtraData decodes the extraData parameters from the encoded form defined here: // https://specs.optimism.io/protocol/jovian/exec-engine.html // -// Returns 0,0,nil if the format is invalid, and d, e, nil for the Holocene length, to provide best effort behavior for non-MinBaseFee extradata, though ValidateMinBaseFeeExtraData should be used instead of this function for +// Returns 0,0,nil if the format is invalid, and d, e, nil for the Holocene length, to provide best effort behavior for non-MinBaseFee extradata, though ValidateJovianExtraData should be used instead of this function for // validity checking. -func DecodeMinBaseFeeExtraData(extra []byte) (uint64, uint64, *uint64) { +func DecodeJovianExtraData(extra []byte) (uint64, uint64, *uint64) { // Best effort to decode the extraData for every block in the chain's history, // including blocks before the minimum base fee feature was enabled. if len(extra) == 9 { @@ -156,7 +156,7 @@ func DecodeMinBaseFeeExtraData(extra []byte) (uint64, uint64, *uint64) { // EncodeMinBaseFeeExtraData encodes the EIP-1559 and minBaseFee parameters into the header 'ExtraData' format. // Will panic if EIP-1559 parameters are outside uint32 range. -func EncodeMinBaseFeeExtraData(denom, elasticity, minBaseFee uint64) []byte { +func EncodeJovianExtraData(denom, elasticity, minBaseFee uint64) []byte { r := make([]byte, 17) if denom > gomath.MaxUint32 || elasticity > gomath.MaxUint32 { panic("eip-1559 parameters out of uint32 range") @@ -168,8 +168,8 @@ func EncodeMinBaseFeeExtraData(denom, elasticity, minBaseFee uint64) []byte { return r } -// ValidateMinBaseFeeExtraData checks if the header extraData is valid according to the minimum base fee feature. -func ValidateMinBaseFeeExtraData(extra []byte) error { +// ValidateJovianExtraData checks if the header extraData is valid according to the minimum base fee feature. +func ValidateJovianExtraData(extra []byte) error { if len(extra) != 17 { return fmt.Errorf("MinBaseFee extraData should be 17 bytes, got %d", len(extra)) } diff --git a/core/block_validator.go b/core/block_validator.go index 05c03235ed..6f43902600 100644 --- a/core/block_validator.go +++ b/core/block_validator.go @@ -117,7 +117,7 @@ func (v *BlockValidator) ValidateBody(block *types.Block) error { } // OP Stack Jovian DA footprint block limit. - if v.config.IsDAFootprintBlockLimit(header.Time) { + if v.config.IsJovian(header.Time) { if header.BlobGasUsed == nil { return errors.New("nil blob gas used in post-Jovian block header, should store DA footprint") } diff --git a/core/types/rollup_cost.go b/core/types/rollup_cost.go index ffbdd2098f..3266ae13fa 100644 --- a/core/types/rollup_cost.go +++ b/core/types/rollup_cost.go @@ -234,7 +234,7 @@ func NewOperatorCostFunc(config *params.ChainConfig, statedb StateGetter) Operat operatorFeeScalar, operatorFeeConstant := ExtractOperatorFeeParams(operatorFeeParams) // Return the Operator Fee fix version if the feature is active - if config.IsOperatorFeeFix(blockTime) { + if config.IsJovian(blockTime) { return newOperatorCostFuncOperatorFeeFix(operatorFeeScalar, operatorFeeConstant) } return newOperatorCostFuncIsthmus(operatorFeeScalar, operatorFeeConstant) diff --git a/miner/miner_optimism_test.go b/miner/miner_optimism_test.go index 4be405f159..1d972a96cb 100644 --- a/miner/miner_optimism_test.go +++ b/miner/miner_optimism_test.go @@ -113,7 +113,7 @@ func testMineAndExecute(t *testing.T, numTxs uint64, cfg *params.ChainConfig, as parent := b.chain.CurrentBlock() ts := parent.Time + 12 dtx := new(types.DepositTx) - if cfg.IsDAFootprintBlockLimit(parent.Time) { + if cfg.IsJovian(parent.Time) { dtx = jovianDepositTx(testDAFootprintGasScalar) } @@ -126,7 +126,7 @@ func testMineAndExecute(t *testing.T, numTxs uint64, cfg *params.ChainConfig, as txs: types.Transactions{types.NewTx(dtx)}, eip1559Params: eip1559.EncodeHolocene1559Params(250, 6), } - if cfg.IsMinBaseFee(ts) { + if cfg.IsJovian(ts) { genParams.minBaseFee = new(uint64) } r := w.generateWork(genParams, false) diff --git a/miner/payload_building_test.go b/miner/payload_building_test.go index 4665a43a96..35d1373590 100644 --- a/miner/payload_building_test.go +++ b/miner/payload_building_test.go @@ -271,11 +271,11 @@ func newPayloadArgs(parentHash common.Hash, cfg *params.ChainConfig) *BuildPaylo args.EIP1559Params = validEIP1559Params } dtx := new(types.DepositTx) - if cfg.IsDAFootprintBlockLimit(args.Timestamp) { + if cfg.IsJovian(args.Timestamp) { dtx = jovianDepositTx(testDAFootprintGasScalar) } args.Transactions = []*types.Transaction{types.NewTx(dtx)} - if cfg.IsMinBaseFee(args.Timestamp) { + if cfg.IsJovian(args.Timestamp) { args.MinBaseFee = ptr(uint64(1e9)) } @@ -344,7 +344,7 @@ func testBuildPayload(t *testing.T, noTxPool, interrupt bool, params1559 []byte, var expected []byte if len(params1559) != 0 { versionByte := eip1559.HoloceneExtraDataVersionByte - if config.IsMinBaseFee(testTimestamp) { + if config.IsJovian(testTimestamp) { versionByte = eip1559.MinBaseFeeExtraDataVersionByte } expected = []byte{versionByte} diff --git a/miner/worker.go b/miner/worker.go index 2bab122a20..744aabc354 100644 --- a/miner/worker.go +++ b/miner/worker.go @@ -312,7 +312,7 @@ func (miner *Miner) prepareWork(genParams *generateParams, witness bool) (*envir // configure the gas limit of pending blocks with the miner gas limit config when using optimism header.GasLimit = miner.config.GasCeil } - if miner.chainConfig.IsMinBaseFee(header.Time) && genParams.minBaseFee == nil { + if miner.chainConfig.IsJovian(header.Time) && genParams.minBaseFee == nil { return nil, errors.New("missing minBaseFee") } if cfg := miner.chainConfig; cfg.IsHolocene(header.Time) { @@ -355,7 +355,7 @@ func (miner *Miner) prepareWork(genParams *generateParams, witness bool) (*envir return nil, err } env.noTxs = genParams.noTxs - if miner.chainConfig.IsDAFootprintBlockLimit(parent.Time) { + if miner.chainConfig.IsJovian(parent.Time) { if len(genParams.txs) == 0 || !genParams.txs[0].IsDepositTx() { return nil, errors.New("missing L1 attributes deposit transaction") } @@ -506,7 +506,7 @@ func (miner *Miner) commitTransactions(env *environment, plainTxs, blobTxs *tran // OP-Stack additions: throttling and DA footprint limit blockDABytes := new(big.Int) - isJovian := miner.chainConfig.IsDAFootprintBlockLimit(env.header.Time) + isJovian := miner.chainConfig.IsJovian(env.header.Time) minTransactionDAFootprint := types.MinTransactionSize.Uint64() * uint64(env.daFootprintGasScalar) for { diff --git a/params/optimism_feature_toggles.go b/params/optimism_feature_toggles.go index 6113844af0..1918437eee 100644 --- a/params/optimism_feature_toggles.go +++ b/params/optimism_feature_toggles.go @@ -1,17 +1,11 @@ package params // OPStack diff -// This file contains ephemeral feature toggles which should be removed +// This file contains ephemeral feature toggles for the next +// fork while it is in development. They should be removed // after the fork scope is locked. -func (c *ChainConfig) IsMinBaseFee(time uint64) bool { - return c.IsJovian(time) // Replace with return false to disable -} - -func (c *ChainConfig) IsDAFootprintBlockLimit(time uint64) bool { - return c.IsJovian(time) // Replace with return false to disable -} - -func (c *ChainConfig) IsOperatorFeeFix(time uint64) bool { - return c.IsJovian(time) // Replace with return false to disable -} +// Example: +// func (c *ChainConfig) IsMinBaseFee(time uint64) bool { +// return c.IsJovian(time) // Replace with return false to disable +// }