Skip to content

Commit

Permalink
Merge branch 'master' into ttd-and-merge-fork-fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
scorbajio authored Jan 24, 2025
2 parents ea98866 + 60ed998 commit 28ac7e7
Show file tree
Hide file tree
Showing 40 changed files with 143 additions and 241 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/node-versions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18, 20, 22]
node-version: [20, 22]
fail-fast: false
steps:
- uses: actions/checkout@v4
Expand Down
1 change: 1 addition & 0 deletions config/eslint.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ module.exports = {
'vitest.config.ts',
'vitest.config.browser.ts',
'vitest.config.unit.ts',
'vitest.config.coverage.ts',
'vite.*.ts',
'ethereum-tests',
'archive',
Expand Down
18 changes: 18 additions & 0 deletions config/vitest.config.coverage.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { defineConfig } from 'vitest/config'

const config = defineConfig({
test: {
silent: true,
testTimeout: 180000,
coverage: {
provider: 'v8',
enabled: true,
all: true,
},
},
optimizeDeps: {
exclude: ['kzg-wasm'],
},
})

export default config
165 changes: 1 addition & 164 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,8 @@
"@types/tape": "4.13.2",
"@typescript-eslint/eslint-plugin": "5.33.1",
"@typescript-eslint/parser": "5.33.1",
"@vitest/coverage-v8": "3.0.2",
"@vitest/coverage-v8": "^3.0.2",
"@vitest/ui": "3.0.2",
"c8": "7.12.0",
"cspell": "^8.13.3",
"embedme": "1.22.1",
"eslint": "8.57.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/block/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"biome:fix": "npx @biomejs/biome check --write",
"build": "../../config/cli/ts-build.sh",
"clean": "../../config/cli/clean-package.sh",
"coverage": "DEBUG=ethjs npx vitest run --coverage.enabled --coverage.reporter=lcov",
"coverage": "DEBUG=ethjs npx vitest run -c ../../config/vitest.config.coverage.mts",
"docs:build": "typedoc --options typedoc.cjs",
"examples": "tsx ../../scripts/examples-runner.ts -- block",
"examples:build": "npx embedme README.md",
Expand Down
2 changes: 1 addition & 1 deletion packages/block/src/block/block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ export class Block {
const blobGasPerBlob = this.common.param('blobGasPerBlob')
let blobGasUsed = BIGINT_0

const expectedExcessBlobGas = parentHeader.calcNextExcessBlobGas()
const expectedExcessBlobGas = parentHeader.calcNextExcessBlobGas(this.common)
if (this.header.excessBlobGas !== expectedExcessBlobGas) {
throw new Error(
`block excessBlobGas mismatch: have ${this.header.excessBlobGas}, want ${expectedExcessBlobGas}`,
Expand Down
24 changes: 6 additions & 18 deletions packages/block/src/header/header.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import {
CLIQUE_EXTRA_VANITY,
cliqueIsEpochTransition,
} from '../consensus/clique.js'
import { fakeExponential } from '../helpers.js'
import { computeBlobGasPrice } from '../helpers.js'
import { paramsBlock } from '../params.js'

import type { BlockHeaderBytes, BlockOptions, HeaderData, JSONHeader } from '../types.js'
Expand Down Expand Up @@ -532,19 +532,7 @@ export class BlockHeader {
if (this.excessBlobGas === undefined) {
throw new Error('header must have excessBlobGas field populated')
}
return this._getBlobGasPrice(this.excessBlobGas)
}

/**
* Returns the blob gas price depending upon the `excessBlobGas` value
* @param excessBlobGas
*/
private _getBlobGasPrice(excessBlobGas: bigint) {
return fakeExponential(
this.common.param('minBlobGas'),
excessBlobGas,
this.common.param('blobGasPriceUpdateFraction'),
)
return computeBlobGasPrice(this.excessBlobGas, this.common)
}

/**
Expand All @@ -564,10 +552,10 @@ export class BlockHeader {
/**
* Calculates the excess blob gas for next (hopefully) post EIP 4844 block.
*/
public calcNextExcessBlobGas(): bigint {
public calcNextExcessBlobGas(childCommon: Common): bigint {
// The validation of the fields and 4844 activation is already taken care in BlockHeader constructor
const targetGasConsumed = (this.excessBlobGas ?? BIGINT_0) + (this.blobGasUsed ?? BIGINT_0)
const targetBlobGasPerBlock = this.common.param('targetBlobGasPerBlock')
const targetBlobGasPerBlock = childCommon.param('targetBlobGasPerBlock')

if (targetGasConsumed <= targetBlobGasPerBlock) {
return BIGINT_0
Expand All @@ -580,8 +568,8 @@ export class BlockHeader {
* Calculate the blob gas price of the block built on top of this one
* @returns The blob gas price
*/
public calcNextBlobGasPrice(): bigint {
return this._getBlobGasPrice(this.calcNextExcessBlobGas())
public calcNextBlobGasPrice(childCommon: Common): bigint {
return computeBlobGasPrice(this.calcNextExcessBlobGas(childCommon), childCommon)
}

/**
Expand Down
15 changes: 14 additions & 1 deletion packages/block/src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import { Blob4844Tx } from '@ethereumjs/tx'
import { BIGINT_0, BIGINT_1, TypeOutput, concatBytes, isHexString, toType } from '@ethereumjs/util'

import type { BlockHeaderBytes, HeaderData } from './types.js'
import type { Common } from '@ethereumjs/common'
import type { TypedTransaction } from '@ethereumjs/tx'
import type { CLRequest, CLRequestType, PrefixedHexString, Withdrawal } from '@ethereumjs/util'

/**
* Returns a 0x-prefixed hex number string from a hex string or string integer.
* @param {string} input string to check, convert, and return
Expand Down Expand Up @@ -119,6 +119,19 @@ export const fakeExponential = (factor: bigint, numerator: bigint, denominator:
return output / denominator
}

/**
* Returns the blob gas price depending upon the `excessBlobGas` value
* @param excessBlobGas
* @param common
*/
export const computeBlobGasPrice = (excessBlobGas: bigint, common: Common) => {
return fakeExponential(
common.param('minBlobGas'),
excessBlobGas,
common.param('blobGasPriceUpdateFraction'),
)
}

/**
* Returns the withdrawals trie root for array of Withdrawal.
* @param wts array of Withdrawal to compute the root of
Expand Down
Loading

0 comments on commit 28ac7e7

Please sign in to comment.