Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion consensus/beacon/consensus.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion consensus/misc/eip1559/eip1559.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
24 changes: 12 additions & 12 deletions consensus/misc/eip1559/eip1559_optimism.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -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 {
Expand Down Expand Up @@ -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 {
Expand All @@ -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")
Expand All @@ -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))
}
Expand Down
2 changes: 1 addition & 1 deletion core/block_validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down
2 changes: 1 addition & 1 deletion core/types/rollup_cost.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions miner/miner_optimism_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand All @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions miner/payload_building_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}

Expand Down Expand Up @@ -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}
Expand Down
6 changes: 3 additions & 3 deletions miner/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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")
}
Expand Down Expand Up @@ -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 {
Expand Down
18 changes: 6 additions & 12 deletions params/optimism_feature_toggles.go
Original file line number Diff line number Diff line change
@@ -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
// }