@@ -154,20 +154,14 @@ func verifyHeaderGasFields(config *params.ChainConfig, header *types.Header, par
154
154
return fmt .Errorf ("expected base fee (%d), found (%d)" , expectedBaseFee , header .BaseFee )
155
155
}
156
156
157
- if ! config .IsSubnetEVM (header .Time ) {
158
- if header .BlockGasCost != nil {
159
- return fmt .Errorf ("invalid blockGasCost before fork: have %d, want <nil>" , header .BlockGasCost )
160
- }
161
- return nil
162
- }
163
-
164
157
// Enforce BlockGasCost constraints
165
158
expectedBlockGasCost := customheader .BlockGasCost (
159
+ config ,
166
160
feeConfig ,
167
161
parent ,
168
162
header .Time ,
169
163
)
170
- if ! utils .BigEqualUint64 (header .BlockGasCost , expectedBlockGasCost ) {
164
+ if ! utils .BigEqual (header .BlockGasCost , expectedBlockGasCost ) {
171
165
return fmt .Errorf ("invalid block gas cost: have %d, want %d" , header .BlockGasCost , expectedBlockGasCost )
172
166
}
173
167
return nil
@@ -334,25 +328,24 @@ func (eng *DummyEngine) verifyBlockFee(
334
328
func (eng * DummyEngine ) Finalize (chain consensus.ChainHeaderReader , block * types.Block , parent * types.Header , state * state.StateDB , receipts []* types.Receipt ) error {
335
329
config := chain .Config ()
336
330
timestamp := block .Time ()
331
+ // we use the parent to determine the fee config
332
+ // since the current block has not been finalized yet.
333
+ feeConfig , _ , err := chain .GetFeeConfigAt (parent )
334
+ if err != nil {
335
+ return err
336
+ }
337
+ // Verify the BlockGasCost set in the header matches the expected value.
338
+ blockGasCost := block .BlockGasCost ()
339
+ expectedBlockGasCost := customheader .BlockGasCost (
340
+ config ,
341
+ feeConfig ,
342
+ parent ,
343
+ timestamp ,
344
+ )
345
+ if ! utils .BigEqual (blockGasCost , expectedBlockGasCost ) {
346
+ return fmt .Errorf ("invalid blockGasCost: have %d, want %d" , blockGasCost , expectedBlockGasCost )
347
+ }
337
348
if config .IsSubnetEVM (timestamp ) {
338
- // we use the parent to determine the fee config
339
- // since the current block has not been finalized yet.
340
- feeConfig , _ , err := chain .GetFeeConfigAt (parent )
341
- if err != nil {
342
- return err
343
- }
344
-
345
- // Verify the BlockGasCost set in the header matches the expected value.
346
- blockGasCost := block .BlockGasCost ()
347
- expectedBlockGasCost := customheader .BlockGasCost (
348
- feeConfig ,
349
- parent ,
350
- timestamp ,
351
- )
352
- if ! utils .BigEqualUint64 (blockGasCost , expectedBlockGasCost ) {
353
- return fmt .Errorf ("invalid blockGasCost: have %d, want %d" , blockGasCost , expectedBlockGasCost )
354
- }
355
-
356
349
// Verify the block fee was paid.
357
350
if err := eng .verifyBlockFee (
358
351
block .BaseFee (),
@@ -371,21 +364,20 @@ func (eng *DummyEngine) FinalizeAndAssemble(chain consensus.ChainHeaderReader, h
371
364
uncles []* types.Header , receipts []* types.Receipt ,
372
365
) (* types.Block , error ) {
373
366
config := chain .Config ()
367
+ // we use the parent to determine the fee config
368
+ // since the current block has not been finalized yet.
369
+ feeConfig , _ , err := chain .GetFeeConfigAt (parent )
370
+ if err != nil {
371
+ return nil , err
372
+ }
373
+ // Calculate the required block gas cost for this block.
374
+ header .BlockGasCost = customheader .BlockGasCost (
375
+ config ,
376
+ feeConfig ,
377
+ parent ,
378
+ header .Time ,
379
+ )
374
380
if config .IsSubnetEVM (header .Time ) {
375
- // we use the parent to determine the fee config
376
- // since the current block has not been finalized yet.
377
- feeConfig , _ , err := chain .GetFeeConfigAt (parent )
378
- if err != nil {
379
- return nil , err
380
- }
381
- // Calculate the required block gas cost for this block.
382
- blockGasCost := customheader .BlockGasCost (
383
- feeConfig ,
384
- parent ,
385
- header .Time ,
386
- )
387
- header .BlockGasCost = new (big.Int ).SetUint64 (blockGasCost )
388
-
389
381
// Verify that this block covers the block fee.
390
382
if err := eng .verifyBlockFee (
391
383
header .BaseFee ,
0 commit comments