@@ -8,18 +8,18 @@ import (
88)
99
1010const HoloceneExtraDataVersionByte = uint8 (0x00 )
11- const JovianExtraDataVersionByte = uint8 (0x01 )
11+ const MinBaseFeeExtraDataVersionByte = uint8 (0x01 )
1212
1313type ForkChecker interface {
1414 IsHolocene (time uint64 ) bool
15- IsJovian (time uint64 ) bool
15+ IsMinBaseFee (time uint64 ) bool
1616}
1717
1818// ValidateOptimismExtraData validates the Optimism extra data.
1919// It uses the config and parent time to determine how to do the validation.
2020func ValidateOptimismExtraData (fc ForkChecker , time uint64 , extraData []byte ) error {
21- if fc .IsJovian (time ) {
22- return ValidateJovianExtraData (extraData )
21+ if fc .IsMinBaseFee (time ) {
22+ return ValidateMinBaseFeeExtraData (extraData )
2323 } else if fc .IsHolocene (time ) {
2424 return ValidateHoloceneExtraData (extraData )
2525 } else if len (extraData ) > 0 { // pre-Holocene
@@ -32,8 +32,8 @@ func ValidateOptimismExtraData(fc ForkChecker, time uint64, extraData []byte) er
3232// It uses the config and parent time to determine how to do the decoding.
3333// The parent.extraData is expected to be valid (i.e. ValidateOptimismExtraData has been called previously)
3434func DecodeOptimismExtraData (fc ForkChecker , time uint64 , extraData []byte ) (uint64 , uint64 , * uint64 ) {
35- if fc .IsJovian (time ) {
36- denominator , elasticity , minBaseFee := DecodeJovianExtraData (extraData )
35+ if fc .IsMinBaseFee (time ) {
36+ denominator , elasticity , minBaseFee := DecodeMinBaseFeeExtraData (extraData )
3737 return denominator , elasticity , minBaseFee
3838 } else if fc .IsHolocene (time ) {
3939 denominator , elasticity := DecodeHoloceneExtraData (extraData )
@@ -45,11 +45,11 @@ func DecodeOptimismExtraData(fc ForkChecker, time uint64, extraData []byte) (uin
4545// EncodeOptimismExtraData encodes the Optimism extra data.
4646// It uses the config and parent time to determine how to do the encoding.
4747func EncodeOptimismExtraData (fc ForkChecker , time uint64 , denominator , elasticity uint64 , minBaseFee * uint64 ) []byte {
48- if fc .IsJovian (time ) {
48+ if fc .IsMinBaseFee (time ) {
4949 if minBaseFee == nil {
50- panic ("minBaseFee cannot be nil for Jovian " )
50+ panic ("minBaseFee cannot be nil since the MinBaseFee feature is enabled " )
5151 }
52- return EncodeJovianExtraData (denominator , elasticity , * minBaseFee )
52+ return EncodeMinBaseFeeExtraData (denominator , elasticity , * minBaseFee )
5353 } else if fc .IsHolocene (time ) {
5454 return EncodeHoloceneExtraData (denominator , elasticity )
5555 } else {
@@ -133,12 +133,12 @@ func ValidateHoloceneExtraData(extra []byte) error {
133133 return ValidateHolocene1559Params (extra [1 :])
134134}
135135
136- // DecodeJovianExtraData decodes the extraData parameters from the encoded form defined here:
136+ // DecodeMinBaseFeeExtraData decodes the extraData parameters from the encoded form defined here:
137137// https://specs.optimism.io/protocol/jovian/exec-engine.html
138138//
139- // Returns 0,0,nil if the format is invalid, and d, e, nil for the Holocene length, to provide best effort behavior for non-Jovian extradata, though ValidateMinBaseFeeExtraData should be used instead of this function for
139+ // 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
140140// validity checking.
141- func DecodeJovianExtraData (extra []byte ) (uint64 , uint64 , * uint64 ) {
141+ func DecodeMinBaseFeeExtraData (extra []byte ) (uint64 , uint64 , * uint64 ) {
142142 // Best effort to decode the extraData for every block in the chain's history,
143143 // including blocks before the minimum base fee feature was enabled.
144144 if len (extra ) == 9 {
@@ -154,27 +154,27 @@ func DecodeJovianExtraData(extra []byte) (uint64, uint64, *uint64) {
154154 return 0 , 0 , nil
155155}
156156
157- // EncodeJovianExtraData encodes the EIP-1559 and minBaseFee parameters into the header 'ExtraData' format.
157+ // EncodeMinBaseFeeExtraData encodes the EIP-1559 and minBaseFee parameters into the header 'ExtraData' format.
158158// Will panic if EIP-1559 parameters are outside uint32 range.
159- func EncodeJovianExtraData (denom , elasticity , minBaseFee uint64 ) []byte {
159+ func EncodeMinBaseFeeExtraData (denom , elasticity , minBaseFee uint64 ) []byte {
160160 r := make ([]byte , 17 )
161161 if denom > gomath .MaxUint32 || elasticity > gomath .MaxUint32 {
162162 panic ("eip-1559 parameters out of uint32 range" )
163163 }
164- r [0 ] = JovianExtraDataVersionByte
164+ r [0 ] = MinBaseFeeExtraDataVersionByte
165165 binary .BigEndian .PutUint32 (r [1 :5 ], uint32 (denom ))
166166 binary .BigEndian .PutUint32 (r [5 :9 ], uint32 (elasticity ))
167167 binary .BigEndian .PutUint64 (r [9 :], minBaseFee )
168168 return r
169169}
170170
171- // ValidateJovianExtraData checks if the header extraData is valid according to the minimum base fee feature.
172- func ValidateJovianExtraData (extra []byte ) error {
171+ // ValidateMinBaseFeeExtraData checks if the header extraData is valid according to the minimum base fee feature.
172+ func ValidateMinBaseFeeExtraData (extra []byte ) error {
173173 if len (extra ) != 17 {
174- return fmt .Errorf ("jovian extraData should be 17 bytes, got %d" , len (extra ))
174+ return fmt .Errorf ("MinBaseFee extraData should be 17 bytes, got %d" , len (extra ))
175175 }
176- if extra [0 ] != JovianExtraDataVersionByte {
177- return fmt .Errorf ("jovian extraData version byte should be %d, got %d" , JovianExtraDataVersionByte , extra [0 ])
176+ if extra [0 ] != MinBaseFeeExtraDataVersionByte {
177+ return fmt .Errorf ("MinBaseFee extraData version byte should be %d, got %d" , MinBaseFeeExtraDataVersionByte , extra [0 ])
178178 }
179179 return ValidateHolocene1559Params (extra [1 :9 ])
180180}
0 commit comments