Skip to content

testdata: add testdata package #3940

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 29 commits into from
Apr 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
dd1ab3c
chore: add testdata package
gabrocheleau Mar 24, 2025
3e87b2c
testdata: fix build
gabrocheleau Mar 26, 2025
5454d24
chore: use exact version number instead of workspace:*
gabrocheleau Mar 26, 2025
951e846
chore: add 4844 testdata to testdata packgae
gabrocheleau Mar 26, 2025
d28efed
chore: refactor testdata
gabrocheleau Mar 26, 2025
0c4a7ce
Merge branch 'master' into testdata/test-data-package
gabrocheleau Mar 26, 2025
19558c2
Merge branch 'master' into testdata/test-data-package
gabrocheleau Mar 27, 2025
bc7fc1f
chore: npm i
gabrocheleau Mar 27, 2025
a0a1521
Merge branch 'testdata/test-data-package' of https://github.com/ether…
gabrocheleau Mar 27, 2025
27e879c
Merge branch 'master' into testdata/test-data-package
gabrocheleau Apr 7, 2025
ef0c37d
Merge branch 'master' into testdata/test-data-package
gabrocheleau Apr 7, 2025
7ff3c57
chore: migrate more test files2
gabrocheleau Apr 7, 2025
00456fa
refactor: eip4844 test data2
gabrocheleau Apr 7, 2025
7265c24
refactor: migate withdrawals geth genesis
gabrocheleau Apr 7, 2025
6f699e3
refactor: gethGenesis misc data cleanup
gabrocheleau Apr 7, 2025
9ef2b5c
refactor: migrate goerli and other test data
gabrocheleau Apr 7, 2025
c83ca97
refactor: post merge geth genesis
gabrocheleau Apr 7, 2025
e679e03
fix: failing tests
gabrocheleau Apr 7, 2025
7417354
refactor: more geth genesis test data
gabrocheleau Apr 7, 2025
67b96ef
refactor: prelondon test data
gabrocheleau Apr 7, 2025
a1f0178
Merge branch 'master' into testdata/test-data-package
gabrocheleau Apr 8, 2025
41b8ee5
chore: restructure folder
gabrocheleau Apr 8, 2025
525237d
refactor: consolidate 4844 files and create chainConfigs folder
gabrocheleau Apr 8, 2025
6e3c9aa
chore: add missing allocations
gabrocheleau Apr 8, 2025
aa1a30b
Merge branch 'master' into testdata/test-data-package
gabrocheleau Apr 8, 2025
ae85ee6
client: fix test
gabrocheleau Apr 8, 2025
90ed07a
Merge branch 'testdata/test-data-package' of https://github.com/ether…
gabrocheleau Apr 8, 2025
289d79e
Merge branch 'master' into testdata/test-data-package
gabrocheleau Apr 8, 2025
a98e895
monorepo: remove build step
gabrocheleau Apr 10, 2025
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
16 changes: 16 additions & 0 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"test:node": "npm run test:node --workspaces --if-present",
"test:browser": "npm run test:browser --workspaces --if-present",
"preinstall": "npm run checkNpmVersion",
"postinstall": "npm run build --workspaces",
"postinstall": "npm run build --workspaces --if-present",
"prepare": "git config --local core.hooksPath .githooks",
"sc": "npm run spellcheck",
"sort-package-json": "sort-package-json \"package.json\" \"packages/*/package.json\"",
Expand Down
5 changes: 2 additions & 3 deletions packages/block/examples/clique.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { createBlock } from '@ethereumjs/block'
import { Common, Hardfork } from '@ethereumjs/common'
import { goerliChainConfig } from '@ethereumjs/testdata'

import { Goerli } from '../test/testdata/goerliCommon.ts'

const common = new Common({ chain: Goerli, hardfork: Hardfork.Chainstart })
const common = new Common({ chain: goerliChainConfig, hardfork: Hardfork.Chainstart })

console.log(common.consensusType()) // 'poa'
console.log(common.consensusAlgorithm()) // 'clique'
Expand Down
1 change: 1 addition & 0 deletions packages/block/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
"ethereum-cryptography": "^3.1.0"
},
"devDependencies": {
"@ethereumjs/testdata": "1.0.0",
"@paulmillr/trusted-setups": "^0.1.2",
"micro-eth-signer": "^0.14.0"
},
Expand Down
28 changes: 15 additions & 13 deletions packages/block/test/block.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import { Common, Hardfork, Mainnet, createCustomCommon } from '@ethereumjs/common'
import { RLP } from '@ethereumjs/rlp'
import {
goerliChainConfig,
preLondonTestDataBlocks1,
preLondonTestDataBlocks2,
testnetMergeChainConfig,
} from '@ethereumjs/testdata'
import { createLegacyTx } from '@ethereumjs/tx'
import { KECCAK256_RLP_ARRAY, bytesToHex, equalsBytes, hexToBytes, toBytes } from '@ethereumjs/util'
import { assert, describe, it } from 'vitest'
Expand All @@ -17,11 +23,7 @@ import {
} from '../src/index.ts'

import { genesisHashesTestData } from './testdata/genesisHashesTest.ts'
import { Goerli } from './testdata/goerliCommon.ts'
import { testdataFromRPCGoerliData } from './testdata/testdata-from-rpc-goerli.ts'
import { testdataPreLondon2Data } from './testdata/testdata_pre-london-2.ts'
import { testdataPreLondonData } from './testdata/testdata_pre-london.ts'
import { testnetMergeData } from './testdata/testnetMerge.ts'

import type { NestedUint8Array, PrefixedHexString } from '@ethereumjs/util'

Expand Down Expand Up @@ -83,7 +85,7 @@ describe('[Block]: block functions', () => {
})

it('initialization -> setHardfork option', () => {
const common = createCustomCommon(testnetMergeData, Mainnet)
const common = createCustomCommon(testnetMergeChainConfig, Mainnet)

let block = createBlock(
{
Expand Down Expand Up @@ -135,7 +137,7 @@ describe('[Block]: block functions', () => {

it('should test block validation on pow chain', async () => {
const common = new Common({ chain: Mainnet, hardfork: Hardfork.Istanbul })
const blockRlp = hexToBytes(testdataPreLondonData.blocks[0].rlp as PrefixedHexString)
const blockRlp = hexToBytes(preLondonTestDataBlocks1.blocks[0].rlp as PrefixedHexString)
try {
createBlockFromRLP(blockRlp, { common })
assert.isTrue(true, 'should pass')
Expand All @@ -145,7 +147,7 @@ describe('[Block]: block functions', () => {
})

it('should test block validation on poa chain', async () => {
const common = new Common({ chain: Goerli, hardfork: Hardfork.Chainstart })
const common = new Common({ chain: goerliChainConfig, hardfork: Hardfork.Chainstart })

try {
createBlockFromRPC(testdataFromRPCGoerliData, [], { common })
Expand All @@ -161,7 +163,7 @@ describe('[Block]: block functions', () => {
}

it('should test transaction validation - invalid tx trie', async () => {
const blockRlp = hexToBytes(testdataPreLondonData.blocks[0].rlp as PrefixedHexString)
const blockRlp = hexToBytes(preLondonTestDataBlocks1.blocks[0].rlp as PrefixedHexString)
const common = new Common({ chain: Mainnet, hardfork: Hardfork.London })
const block = createBlockFromRLP(blockRlp, { common, freeze: false })
await testTransactionValidation(block)
Expand Down Expand Up @@ -203,7 +205,7 @@ describe('[Block]: block functions', () => {

it('should test transaction validation with legacy tx in london', async () => {
const common = new Common({ chain: Mainnet, hardfork: Hardfork.London })
const blockRlp = hexToBytes(testdataPreLondonData.blocks[0].rlp as PrefixedHexString)
const blockRlp = hexToBytes(preLondonTestDataBlocks1.blocks[0].rlp as PrefixedHexString)
const block = createBlockFromRLP(blockRlp, { common, freeze: false })
await testTransactionValidation(block)
// @ts-expect-error -- Assigning to read-only property
Expand All @@ -217,7 +219,7 @@ describe('[Block]: block functions', () => {

it('should test uncles hash validation', async () => {
const common = new Common({ chain: Mainnet, hardfork: Hardfork.Istanbul })
const blockRlp = hexToBytes(testdataPreLondon2Data.blocks[2].rlp as PrefixedHexString)
const blockRlp = hexToBytes(preLondonTestDataBlocks2.blocks[2].rlp as PrefixedHexString)
const block = createBlockFromRLP(blockRlp, { common, freeze: false })
assert.equal(block.uncleHashIsValid(), true)
// @ts-expect-error -- Assigning to read-only property
Expand Down Expand Up @@ -355,7 +357,7 @@ describe('[Block]: block functions', () => {
it('should return the same block data from raw()', () => {
const common = new Common({ chain: Mainnet, hardfork: Hardfork.Istanbul })
const block = createBlockFromRLP(
toBytes(testdataPreLondon2Data.blocks[2].rlp as PrefixedHexString),
toBytes(preLondonTestDataBlocks2.blocks[2].rlp as PrefixedHexString),
{
common,
},
Expand All @@ -367,7 +369,7 @@ describe('[Block]: block functions', () => {
it('should test toJSON', () => {
const common = new Common({ chain: Mainnet, hardfork: Hardfork.Istanbul })
const block = createBlockFromRLP(
toBytes(testdataPreLondon2Data.blocks[2].rlp as PrefixedHexString),
toBytes(preLondonTestDataBlocks2.blocks[2].rlp as PrefixedHexString),
{
common,
},
Expand All @@ -377,7 +379,7 @@ describe('[Block]: block functions', () => {

it('DAO hardfork', () => {
const blockData = RLP.decode(
testdataPreLondon2Data.blocks[0].rlp as PrefixedHexString,
preLondonTestDataBlocks2.blocks[0].rlp as PrefixedHexString,
) as NestedUint8Array
// Set block number from test block to mainnet DAO fork block 1920000
blockData[0][8] = hexToBytes('0x1D4C00')
Expand Down
4 changes: 2 additions & 2 deletions packages/block/test/clique.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ import {
createSealedCliqueBlockHeader,
} from '../src/index.ts'

import { Goerli } from './testdata/goerliCommon.ts'
import { goerliChainConfig } from '@ethereumjs/testdata'

describe('[Header]: Clique PoA Functionality', () => {
const common = new Common({ chain: Goerli, hardfork: Hardfork.Chainstart })
const common = new Common({ chain: goerliChainConfig, hardfork: Hardfork.Chainstart })

it('Header Data', () => {
let header = createBlockHeader({ number: 1 })
Expand Down
8 changes: 4 additions & 4 deletions packages/block/test/eip4844block.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ import { fakeExponential, getNumBlobs } from '../src/helpers.ts'
import { createBlock, createBlockHeader } from '../src/index.ts'
import { paramsBlock } from '../src/params.ts'

import { hardfork4844Data } from './testdata/4844-hardfork.ts'
import { eip4844GethGenesis } from '@ethereumjs/testdata'

import type { TypedTransaction } from '@ethereumjs/tx'

describe('EIP4844 header tests', () => {
const kzg = new microEthKZG(trustedSetup)

const common = createCommonFromGethGenesis(hardfork4844Data, {
const common = createCommonFromGethGenesis(eip4844GethGenesis, {
chain: 'customChain',
hardfork: Hardfork.Cancun,
customCrypto: { kzg },
Expand Down Expand Up @@ -96,7 +96,7 @@ describe('EIP4844 header tests', () => {
describe('blob gas tests', () => {
const kzg = new microEthKZG(trustedSetup)

const common = createCommonFromGethGenesis(hardfork4844Data, {
const common = createCommonFromGethGenesis(eip4844GethGenesis, {
chain: 'customChain',
hardfork: Hardfork.Cancun,
params: paramsBlock,
Expand Down Expand Up @@ -154,7 +154,7 @@ describe('blob gas tests', () => {
describe('transaction validation tests', () => {
const kzg = new microEthKZG(trustedSetup)

const common = createCommonFromGethGenesis(hardfork4844Data, {
const common = createCommonFromGethGenesis(eip4844GethGenesis, {
chain: 'customChain',
hardfork: Hardfork.Cancun,
params: paramsBlock,
Expand Down
8 changes: 4 additions & 4 deletions packages/block/test/from-beacon-payload.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ import { assert, describe, expect, it } from 'vitest'

import { createBlockFromBeaconPayloadJSON, createBlockHeader } from '../src/index.ts'

import { devnet4844Config } from './testdata/4844-devnet.ts'
import { eip4844GethGenesis } from '@ethereumjs/testdata'
import { payloadKaustinenData } from './testdata/payload-kaustinen.ts'
import { payloadSlot87335Data } from './testdata/payload-slot-87335.ts'
import { payloadSlot87475Data } from './testdata/payload-slot-87475.ts'
import { testnetVerkleKaustinenData } from './testdata/testnetVerkleKaustinen.ts'
import { verkleKaustinenGethGenesis } from './testdata/testnetVerkleKaustinen.ts'

const kzg = new microEthKZG(trustedSetup)
describe('[fromExecutionPayloadJSON]: 4844 devnet 5', () => {
const commonConfig = { ...devnet4844Config }
const commonConfig = { ...eip4844GethGenesis }
commonConfig.config = { ...commonConfig.config, chainId: 4844001005 }
const network = 'sharding'
const common = createCommonFromGethGenesis(commonConfig, {
Expand Down Expand Up @@ -74,7 +74,7 @@ describe('[fromExecutionPayloadJSON]: kaustinen', () => {
const network = 'kaustinen'

// safely change chainId without modifying underlying json
const common = createCommonFromGethGenesis(testnetVerkleKaustinenData, {
const common = createCommonFromGethGenesis(verkleKaustinenGethGenesis, {
chain: network,
eips: [6800],
})
Expand Down
6 changes: 3 additions & 3 deletions packages/block/test/from-rpc.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import {
createBlockHeaderFromRPC,
} from '../src/index.ts'

import { goerliChainConfig } from '@ethereumjs/testdata'
import { alchemy14151203Data } from './testdata/alchemy14151203.ts'
import { Goerli } from './testdata/goerliCommon.ts'
import { infuraGoerliBlock10536893Data } from './testdata/infura-goerli-block-10536893.ts'
import { infura2000004withTransactionsData } from './testdata/infura2000004withTransactions.ts'
import { infura2000004withoutTransactionsData } from './testdata/infura2000004withoutTransactions.ts'
Expand Down Expand Up @@ -91,7 +91,7 @@ describe('[fromRPC]:', () => {
})

it('should create a block from london hardfork', () => {
const common = new Common({ chain: Goerli, hardfork: Hardfork.London })
const common = new Common({ chain: goerliChainConfig, hardfork: Hardfork.London })
const block = createBlockFromRPC(testdataFromRPCGoerliLondonData, [], { common })
assert.equal(
`0x${block.header.baseFeePerGas?.toString(16)}`,
Expand Down Expand Up @@ -172,7 +172,7 @@ describe('[fromRPC] - Alchemy/Infura API block responses', () => {
})

it('should correctly parse a cancun block over rpc', () => {
const common = new Common({ chain: Goerli, hardfork: Hardfork.Cancun })
const common = new Common({ chain: goerliChainConfig, hardfork: Hardfork.Cancun })
const block = createBlockHeaderFromRPC(infuraGoerliBlock10536893Data, { common }) // cspell:disable-line
const hash = hexToBytes(infuraGoerliBlock10536893Data.hash)
assert.isTrue(equalsBytes(block.hash(), hash))
Expand Down
18 changes: 8 additions & 10 deletions packages/block/test/header.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Common, Hardfork, Mainnet } from '@ethereumjs/common'
import { RLP } from '@ethereumjs/rlp'
import { goerliBlocks, goerliChainConfig, mainnetBlocks } from '@ethereumjs/testdata'
import {
KECCAK256_RLP,
KECCAK256_RLP_ARRAY,
Expand All @@ -21,9 +22,6 @@ import {
} from '../src/index.ts'

import { bcBlockGasLimitTestData } from './testdata/bcBlockGasLimitTest.ts'
import { blocksGoerliData } from './testdata/blocks_goerli.ts'
import { blocksMainnetData } from './testdata/blocks_mainnet.ts'
import { Goerli } from './testdata/goerliCommon.ts'

import type { CliqueConfig } from '@ethereumjs/common'
import type { PrefixedHexString } from '@ethereumjs/util'
Expand Down Expand Up @@ -177,7 +175,7 @@ describe('[Block]: Header functions', () => {
})

it('Initialization -> Clique Blocks', () => {
const common = new Common({ chain: Goerli, hardfork: Hardfork.Chainstart })
const common = new Common({ chain: goerliChainConfig, hardfork: Hardfork.Chainstart })
const header = createBlockHeader({ extraData: new Uint8Array(97) }, { common })
assert.isDefined(bytesToHex(header.hash()), 'default block should initialize')
})
Expand Down Expand Up @@ -219,7 +217,7 @@ describe('[Block]: Header functions', () => {
)

// PoA
common = new Common({ chain: Goerli, hardfork: Hardfork.Chainstart })
common = new Common({ chain: goerliChainConfig, hardfork: Hardfork.Chainstart })
genesis = createBlock({ header: { extraData: new Uint8Array(97) } }, { common })

parentHash = genesis.hash()
Expand Down Expand Up @@ -271,7 +269,7 @@ describe('[Block]: Header functions', () => {
})

it('should skip consensusFormatValidation if flag is set to false', () => {
const common = new Common({ chain: Goerli, hardfork: Hardfork.Chainstart })
const common = new Common({ chain: goerliChainConfig, hardfork: Hardfork.Chainstart })

assert.doesNotThrow(
() =>
Expand Down Expand Up @@ -319,7 +317,7 @@ describe('[Block]: Header functions', () => {
it('header validation -> poa checks', () => {
const headerData = testDataPreLondon.blocks[0].blockHeader

const common = new Common({ chain: Goerli, hardfork: Hardfork.Istanbul })
const common = new Common({ chain: goerliChainConfig, hardfork: Hardfork.Istanbul })
const blockchain = new Mockchain()

const genesisRlp = toBytes(testDataPreLondon.genesisRLP)
Expand Down Expand Up @@ -453,15 +451,15 @@ describe('[Block]: Header functions', () => {

it('should test hash() function', () => {
let common = new Common({ chain: Mainnet, hardfork: Hardfork.Chainstart })
let header = createBlockHeader(blocksMainnetData[0]['header'], { common })
let header = createBlockHeader(mainnetBlocks[0]['header'], { common })
assert.equal(
bytesToHex(header.hash()),
'0x88e96d4537bea4d9c05d12549907b32561d3bf31f45aae734cdc119f13406cb6',
'correct PoW hash (mainnet block 1)',
)

common = new Common({ chain: Goerli, hardfork: Hardfork.Chainstart })
header = createBlockHeader(blocksGoerliData[0]['header'], { common })
common = new Common({ chain: goerliChainConfig, hardfork: Hardfork.Chainstart })
header = createBlockHeader(goerliBlocks[0]['header'], { common })
assert.equal(
bytesToHex(header.hash()),
'0x8f5bab218b6bb34476f51ca588e9f4553a3a7ce5e13a66c660a5283e97e9a85a',
Expand Down
Loading
Loading