@@ -297,6 +297,34 @@ export function verifyGas(results: any, testData: any, t: tape.Test) {
297
297
}
298
298
}
299
299
300
+ export function makeParentBlockHeader ( data : any , opts : BlockOptions ) {
301
+ const {
302
+ parentGasLimit,
303
+ parentGasUsed,
304
+ parentBaseFee,
305
+ parentDifficulty,
306
+ parentTimestamp,
307
+ parentUncleHash,
308
+ parentBlobGasUsed,
309
+ parentExcessBlobGas,
310
+ parentBeaconBlockRoot,
311
+ } = data
312
+ return createBlockHeader (
313
+ {
314
+ gasLimit : parentGasLimit ,
315
+ gasUsed : parentGasUsed ,
316
+ baseFeePerGas : parentBaseFee ,
317
+ difficulty : parentDifficulty ,
318
+ timestamp : parentTimestamp ,
319
+ uncleHash : parentUncleHash ,
320
+ blobGasUsed : parentBlobGasUsed ,
321
+ excessBlobGas : parentExcessBlobGas ,
322
+ parentBeaconBlockRoot,
323
+ } ,
324
+ { common : opts . common } ,
325
+ )
326
+ }
327
+
300
328
export function makeBlockHeader ( data : any , opts ?: BlockOptions ) {
301
329
const {
302
330
currentTimestamp,
@@ -309,9 +337,6 @@ export function makeBlockHeader(data: any, opts?: BlockOptions) {
309
337
currentNumber,
310
338
currentBaseFee,
311
339
currentRandom,
312
- parentGasLimit,
313
- parentGasUsed,
314
- parentBaseFee,
315
340
} = data
316
341
const headerData : any = {
317
342
number : currentNumber ,
@@ -321,17 +346,10 @@ export function makeBlockHeader(data: any, opts?: BlockOptions) {
321
346
gasLimit : currentGasLimit ,
322
347
timestamp : currentTimestamp ,
323
348
}
349
+ const parentBlockHeader = makeParentBlockHeader ( data , { common : opts ?. common } )
324
350
if ( opts ?. common && opts . common . gteHardfork ( 'london' ) ) {
325
351
headerData [ 'baseFeePerGas' ] = currentBaseFee
326
352
if ( currentBaseFee === undefined ) {
327
- const parentBlockHeader = createBlockHeader (
328
- {
329
- gasLimit : parentGasLimit ,
330
- gasUsed : parentGasUsed ,
331
- baseFeePerGas : parentBaseFee ,
332
- } ,
333
- { common : opts . common } ,
334
- )
335
353
headerData [ 'baseFeePerGas' ] = parentBlockHeader . calcNextBaseFee ( )
336
354
}
337
355
}
@@ -344,6 +362,9 @@ export function makeBlockHeader(data: any, opts?: BlockOptions) {
344
362
}
345
363
if ( opts ?. common && opts . common . gteHardfork ( 'cancun' ) ) {
346
364
headerData [ 'excessBlobGas' ] = currentExcessBlobGas
365
+ if ( currentExcessBlobGas === undefined ) {
366
+ headerData [ 'excessBlobGas' ] = parentBlockHeader . calcNextExcessBlobGas ( )
367
+ }
347
368
}
348
369
return createBlockHeader ( headerData , opts )
349
370
}
0 commit comments