From ba1593b259c108150672c85f9c5ab4e836c863c3 Mon Sep 17 00:00:00 2001 From: Gabriel Rocheleau Date: Wed, 18 Sep 2024 22:32:43 -0400 Subject: [PATCH 1/2] ethash: migrate test data to js --- packages/ethash/test/block.spec.ts | 15 +++-- packages/ethash/test/block_tests_data.json | 63 ------------------ packages/ethash/test/block_tests_data.ts | 65 +++++++++++++++++++ packages/ethash/test/ethash.spec.ts | 6 +- .../ethash/test/ethash_block_rlp_tests.json | 4 -- .../ethash/test/ethash_block_rlp_tests.ts | 5 ++ packages/ethash/test/ethash_tests.json | 24 ------- packages/ethash/test/ethash_tests.ts | 26 ++++++++ 8 files changed, 107 insertions(+), 101 deletions(-) delete mode 100644 packages/ethash/test/block_tests_data.json create mode 100644 packages/ethash/test/block_tests_data.ts delete mode 100644 packages/ethash/test/ethash_block_rlp_tests.json create mode 100644 packages/ethash/test/ethash_block_rlp_tests.ts delete mode 100644 packages/ethash/test/ethash_tests.json create mode 100644 packages/ethash/test/ethash_tests.ts diff --git a/packages/ethash/test/block.spec.ts b/packages/ethash/test/block.spec.ts index d14dc88626..1ad52a0e69 100644 --- a/packages/ethash/test/block.spec.ts +++ b/packages/ethash/test/block.spec.ts @@ -1,17 +1,19 @@ import { createBlock, createBlockFromBytesArray, createBlockFromRLP } from '@ethereumjs/block' import { Common, Hardfork, Mainnet } from '@ethereumjs/common' import { RLP } from '@ethereumjs/rlp' -import { MapDB, hexToBytes, toBytes } from '@ethereumjs/util' +import { MapDB, hexToBytes } from '@ethereumjs/util' import { assert, describe, it } from 'vitest' import { Ethash } from '../src/index.js' +import { blockTestsData } from './block_tests_data.js' +import { invalidBlockRLP, validBlockRLP } from './ethash_block_rlp_tests.js' + import type { BlockBytes } from '@ethereumjs/block' +import type { PrefixedHexString } from '@ethereumjs/util' const cacheDB = new MapDB() -const { validBlockRlp, invalidBlockRlp } = require('./ethash_block_rlp_tests.json') - describe('Verify POW for valid and invalid blocks', () => { it('should work', async () => { const e = new Ethash(cacheDB as any) @@ -22,12 +24,12 @@ describe('Verify POW for valid and invalid blocks', () => { const genesisResult = await e.verifyPOW(genesis) assert.ok(genesisResult, 'genesis block should be valid') - const validRlp = hexToBytes(`0x${validBlockRlp}`) + const validRlp = hexToBytes(validBlockRLP) const validBlock = createBlockFromRLP(validRlp, { common }) const validBlockResult = await e.verifyPOW(validBlock) assert.ok(validBlockResult, 'should be valid') - const invalidRlp = hexToBytes(`0x${invalidBlockRlp}`) + const invalidRlp = hexToBytes(invalidBlockRLP) // Put correct amount of extraData in block extraData field so block can be deserialized const values = RLP.decode(Uint8Array.from(invalidRlp)) as BlockBytes values[0][12] = new Uint8Array(32) @@ -35,8 +37,7 @@ describe('Verify POW for valid and invalid blocks', () => { const invalidBlockResult = await e.verifyPOW(invalidBlock) assert.ok(!invalidBlockResult, 'should be invalid') - const testData = require('./block_tests_data.json') - const blockRlp = toBytes(testData.blocks[0].rlp) + const blockRlp = hexToBytes(blockTestsData.blocks[0].rlp as PrefixedHexString) const block = createBlockFromRLP(blockRlp, { common }) const uncleBlockResult = await e.verifyPOW(block) assert.ok(uncleBlockResult, 'should be valid') diff --git a/packages/ethash/test/block_tests_data.json b/packages/ethash/test/block_tests_data.json deleted file mode 100644 index 0708cde5b0..0000000000 --- a/packages/ethash/test/block_tests_data.json +++ /dev/null @@ -1,63 +0,0 @@ -{ - "_info": { - "comment": "", - "filledwith": "cpp-1.3.0+commit.26123543.Linux.g++", - "source": "/src/BlockchainTestsFiller/bcUncleHeaderValiditiy/correctFiller.json" - }, - "blocks": [ - { - "blockHeader": { - "bloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "coinbase": "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty": "0x020080", - "extraData": "", - "gasLimit": "0x2fefba", - "gasUsed": "0x5208", - "hash": "0xc6208f30be1fb9053b073c49cc16795001bd07c6d2650b28d2e4a37a5eb2dde2", - "mixHash": "0x16bd3db367a3b218565e6744de193fb601587af40ba093e8e3cf9b29f0aa4ff1", - "nonce": "0xf5c0d237b1a07faa", - "number": "0x03", - "parentHash": "0x2b530c31b2556d8ad5e12311658f0ec47e35a4ceffecd83d06e7cd918d3a85f1", - "receiptTrie": "0x4ede0225773c7a517b91994aca65ade45124e7ef4b8be1e6097c9773a11920af", - "stateRoot": "0x77f96f4c766c10cd0207e2672b1b747c741ed75bc94e7be7abacb71cdca3c8fb", - "timestamp": "0x5982d2d1", - "transactionsTrie": "0x1722b8a91bfc4f5614ce36ee77c7cce6620ab4af36d3c54baa66d7dbeb7bce1a", - "uncleHash": "0xbeb175854a56183e630cd77e1c6dcd50a8bab221f81f2376919c649b33c500e0" - }, - "rlp": "0xf9045df901f9a02b530c31b2556d8ad5e12311658f0ec47e35a4ceffecd83d06e7cd918d3a85f1a0beb175854a56183e630cd77e1c6dcd50a8bab221f81f2376919c649b33c500e0948888f1f195afa192cfee860698584c030f4c9db1a077f96f4c766c10cd0207e2672b1b747c741ed75bc94e7be7abacb71cdca3c8fba01722b8a91bfc4f5614ce36ee77c7cce6620ab4af36d3c54baa66d7dbeb7bce1aa04ede0225773c7a517b91994aca65ade45124e7ef4b8be1e6097c9773a11920afb90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008302008003832fefba825208845982d2d180a016bd3db367a3b218565e6744de193fb601587af40ba093e8e3cf9b29f0aa4ff188f5c0d237b1a07faaf862f86002018304cb2f94095e7baea6a6c7c4c2dfeb977efac326af552d870a801ca015eb1cc916728b9799e55c489857727669afb2986433d5f54cde11faaed9f0eea05d36f6d06c34aae8d0a2a5895c8ba4a17ad46a5fa59f361cb3e7e01a23030e38f901faf901f7a0ca028b1318795714d130a99d8023bd7463cf8084f31d2f95f1a2d9eb342e9caca01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347940000000000000000000000000000000000000000a0cb52de543653d86ccd13ba3ddf8b052525b04231c6884a4db3188a184681d878a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008302004002832fefba80845982d2cf80a0b5488407bc8b147a9b3c4811864ebfc5bdb568fc8f91dcf9232ed6b7429c52f8882b9b47250942c14e", - "transactions": [ - { - "data": "", - "gasLimit": "0x04cb2f", - "gasPrice": "0x01", - "nonce": "0x02", - "r": "0x15eb1cc916728b9799e55c489857727669afb2986433d5f54cde11faaed9f0ee", - "s": "0x5d36f6d06c34aae8d0a2a5895c8ba4a17ad46a5fa59f361cb3e7e01a23030e38", - "to": "0x095e7baea6a6c7c4c2dfeb977efac326af552d87", - "v": "0x1c", - "value": "0x0a" - } - ], - "uncleHeaders": [ - { - "bloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "coinbase": "0x0000000000000000000000000000000000000000", - "difficulty": "0x020040", - "extraData": "", - "gasLimit": "0x2fefba", - "gasUsed": "0x00", - "hash": "0xcac5903348d2b4ca370227f7bd24bc3101b327a05172a3d7d3106a11d2019c16", - "mixHash": "0xb5488407bc8b147a9b3c4811864ebfc5bdb568fc8f91dcf9232ed6b7429c52f8", - "nonce": "0x2b9b47250942c14e", - "number": "0x02", - "parentHash": "0xca028b1318795714d130a99d8023bd7463cf8084f31d2f95f1a2d9eb342e9cac", - "receiptTrie": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "stateRoot": "0xcb52de543653d86ccd13ba3ddf8b052525b04231c6884a4db3188a184681d878", - "timestamp": "0x5982d2cf", - "transactionsTrie": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "uncleHash": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" - } - ] - } - ] -} diff --git a/packages/ethash/test/block_tests_data.ts b/packages/ethash/test/block_tests_data.ts new file mode 100644 index 0000000000..bf47e14bb4 --- /dev/null +++ b/packages/ethash/test/block_tests_data.ts @@ -0,0 +1,65 @@ +export const blockTestsData = { + _info: { + comment: '', + filledwith: 'cpp-1.3.0+commit.26123543.Linux.g++', + source: '/src/BlockchainTestsFiller/bcUncleHeaderValiditiy/correctFiller.json', + }, + blocks: [ + { + blockHeader: { + bloom: + '0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000', + coinbase: '0x8888f1f195afa192cfee860698584c030f4c9db1', + difficulty: '0x020080', + extraData: '', + gasLimit: '0x2fefba', + gasUsed: '0x5208', + hash: '0xc6208f30be1fb9053b073c49cc16795001bd07c6d2650b28d2e4a37a5eb2dde2', + mixHash: '0x16bd3db367a3b218565e6744de193fb601587af40ba093e8e3cf9b29f0aa4ff1', + nonce: '0xf5c0d237b1a07faa', + number: '0x03', + parentHash: '0x2b530c31b2556d8ad5e12311658f0ec47e35a4ceffecd83d06e7cd918d3a85f1', + receiptTrie: '0x4ede0225773c7a517b91994aca65ade45124e7ef4b8be1e6097c9773a11920af', + stateRoot: '0x77f96f4c766c10cd0207e2672b1b747c741ed75bc94e7be7abacb71cdca3c8fb', + timestamp: '0x5982d2d1', + transactionsTrie: '0x1722b8a91bfc4f5614ce36ee77c7cce6620ab4af36d3c54baa66d7dbeb7bce1a', + uncleHash: '0xbeb175854a56183e630cd77e1c6dcd50a8bab221f81f2376919c649b33c500e0', + }, + rlp: '0xf9045df901f9a02b530c31b2556d8ad5e12311658f0ec47e35a4ceffecd83d06e7cd918d3a85f1a0beb175854a56183e630cd77e1c6dcd50a8bab221f81f2376919c649b33c500e0948888f1f195afa192cfee860698584c030f4c9db1a077f96f4c766c10cd0207e2672b1b747c741ed75bc94e7be7abacb71cdca3c8fba01722b8a91bfc4f5614ce36ee77c7cce6620ab4af36d3c54baa66d7dbeb7bce1aa04ede0225773c7a517b91994aca65ade45124e7ef4b8be1e6097c9773a11920afb90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008302008003832fefba825208845982d2d180a016bd3db367a3b218565e6744de193fb601587af40ba093e8e3cf9b29f0aa4ff188f5c0d237b1a07faaf862f86002018304cb2f94095e7baea6a6c7c4c2dfeb977efac326af552d870a801ca015eb1cc916728b9799e55c489857727669afb2986433d5f54cde11faaed9f0eea05d36f6d06c34aae8d0a2a5895c8ba4a17ad46a5fa59f361cb3e7e01a23030e38f901faf901f7a0ca028b1318795714d130a99d8023bd7463cf8084f31d2f95f1a2d9eb342e9caca01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347940000000000000000000000000000000000000000a0cb52de543653d86ccd13ba3ddf8b052525b04231c6884a4db3188a184681d878a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008302004002832fefba80845982d2cf80a0b5488407bc8b147a9b3c4811864ebfc5bdb568fc8f91dcf9232ed6b7429c52f8882b9b47250942c14e', + transactions: [ + { + data: '', + gasLimit: '0x04cb2f', + gasPrice: '0x01', + nonce: '0x02', + r: '0x15eb1cc916728b9799e55c489857727669afb2986433d5f54cde11faaed9f0ee', + s: '0x5d36f6d06c34aae8d0a2a5895c8ba4a17ad46a5fa59f361cb3e7e01a23030e38', + to: '0x095e7baea6a6c7c4c2dfeb977efac326af552d87', + v: '0x1c', + value: '0x0a', + }, + ], + uncleHeaders: [ + { + bloom: + '0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000', + coinbase: '0x0000000000000000000000000000000000000000', + difficulty: '0x020040', + extraData: '', + gasLimit: '0x2fefba', + gasUsed: '0x00', + hash: '0xcac5903348d2b4ca370227f7bd24bc3101b327a05172a3d7d3106a11d2019c16', + mixHash: '0xb5488407bc8b147a9b3c4811864ebfc5bdb568fc8f91dcf9232ed6b7429c52f8', + nonce: '0x2b9b47250942c14e', + number: '0x02', + parentHash: '0xca028b1318795714d130a99d8023bd7463cf8084f31d2f95f1a2d9eb342e9cac', + receiptTrie: '0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421', + stateRoot: '0xcb52de543653d86ccd13ba3ddf8b052525b04231c6884a4db3188a184681d878', + timestamp: '0x5982d2cf', + transactionsTrie: '0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421', + uncleHash: '0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347', + }, + ], + }, + ], +} diff --git a/packages/ethash/test/ethash.spec.ts b/packages/ethash/test/ethash.spec.ts index d22e26823c..004379f7a2 100644 --- a/packages/ethash/test/ethash.spec.ts +++ b/packages/ethash/test/ethash.spec.ts @@ -6,16 +6,16 @@ import { assert, describe, it } from 'vitest' import { Ethash } from '../src/index.js' import { getCacheSize, getEpoc, getFullSize } from '../src/util.js' -const powTests = require('./ethash_tests.json') +import { ethhashTests } from './ethash_tests.js' const ethash = new Ethash() -const tests = Object.keys(powTests) +const tests = Object.keys(ethhashTests) as (keyof typeof ethhashTests)[] const common = new Common({ chain: Mainnet, hardfork: Hardfork.Istanbul }) describe('POW tests', () => { it('should work', async () => { for (const key of tests) { - const test = powTests[key] + const test = ethhashTests[key] const header = createBlockHeaderFromRLP(hexToBytes(`0x${test.header}`), { common }) const headerHash = ethash.headerHash(header.raw()) diff --git a/packages/ethash/test/ethash_block_rlp_tests.json b/packages/ethash/test/ethash_block_rlp_tests.json deleted file mode 100644 index af3fd4f000..0000000000 --- a/packages/ethash/test/ethash_block_rlp_tests.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "validBlockRlp": "f90221f9021ca03cfde7bfb7187bc175f3a40fc930a20b3fa384a27e7639d23a223f8b52b31974a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d493479488d74a59454f6cf3b51ef6b9136afb6b9d405a88a0e8acbfca503fb67433f7427666e2a2b0152901ae53d9c5bb900334c1e969c0bda056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421b901000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000086016a6d87a32182ca00830d30b3808455c58acaa0476574682f76312e302e302d66633739643332642f6c696e75782f676f312e34a0f069cbc921fb229a9d8c79e32727291e6af8e33bec8ac184203ae1ca67f0a9148844b300df423f783cc0c0", - "invalidBlockRlp": "f90667f905fba0a8d5b7a4793baaede98b5236954f634a0051842df6a252f6a80492fd888678bda01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347948888f1f195afa192cfee860698584c030f4c9db1a0f93c8db1e931daa2e22e39b5d2da6fb4074e3d544094857608536155e3521bc1a0bb7495628f9160ddbcf6354380ee32c300d594e833caec3a428041a66e7bade1a0c7778a7376099ee2e5c455791c1885b5c361b95713fddcbe32d97fd01334d296b90100000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000400000000000000000000000000000000000000000000000000000008302000001832fefd882560b84559c17b9b9040001020304050607080910151213141516171819202122232410000000000000000000200000000000000000003000000000000000000040000000000000000000500000000000000000006000000000000000000070000000000000000000800000000000000000009000000000000000000010000000000000000000100000000000000000002000000000000000000030000000000000000000400000000000000000005000000000000000000060000000000000000000700000000000000000008000000000000000000090000000000000000000100000000000000000001000000000000000000020000000000000000000300000000000000000004000000000000000000050000000000000000000600000000000000000007000000000000000000080000000000000000000900000000000000000001000000000000000000010000000000000000000200000000000000000003000000000000000000040000000000000000000500000000000000000006000000000000000000070000000000000000000800000000000000000009000000000000000000010000000000000000000100000000000000000002000000000000000000030000000000000000000400000000000000000005000000000000000000060000000000000000000700000000000000000008000000000000000000090000000000000000000100000000000000000001000000000000000000020000000000000000000300000000000000000004000000000000000000050000000000000000000600000000000000000007000000000000000000080000000000000000000900000000000000000001000000000000000000010000000000000000000200000000000000000003000000000000000000040000000000000000000500000000000000000006000000000000000000070000000000000000000800000000000000000009000000000000000000010000000000000000000100000000000000000002000000000000000000030000000000000000000400000000000000000005000000000000000000060000000000000000000700000000000000000008000000000000000000090000000000000000000100000000000000000001000000000000000000020000000000000000000300000000000000000004000000000000000000050000000000000000000600000000000000000007000000000000000000080000000000000000000900000000000000000001000000000000000000010000000000000000000200000000000000000003000000000000000000040000000000000000000500000000000000000006000000000000000000070000000000000000000800000000000000000009000000000000000000010000000000000000000a09c7b47112a3afb385c12924bf6280d273c106eea7caeaf5131d8776f61056c148876ae05d46b58d1fff866f864800a82c35094095e7baea6a6c7c4c2dfeb977efac326af552d8785012a05f200801ba01d2c92cfaeb04e53acdff2b5d42005ff6aacdb0105e64eb8c30c273f445d2782a01e7d50ffce57840360c57d94977b8cdebde614da23e8d1e77dc07928763cfe21c0" -} diff --git a/packages/ethash/test/ethash_block_rlp_tests.ts b/packages/ethash/test/ethash_block_rlp_tests.ts new file mode 100644 index 0000000000..12bb0cafac --- /dev/null +++ b/packages/ethash/test/ethash_block_rlp_tests.ts @@ -0,0 +1,5 @@ +export const invalidBlockRLP = + '0xf90667f905fba0a8d5b7a4793baaede98b5236954f634a0051842df6a252f6a80492fd888678bda01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347948888f1f195afa192cfee860698584c030f4c9db1a0f93c8db1e931daa2e22e39b5d2da6fb4074e3d544094857608536155e3521bc1a0bb7495628f9160ddbcf6354380ee32c300d594e833caec3a428041a66e7bade1a0c7778a7376099ee2e5c455791c1885b5c361b95713fddcbe32d97fd01334d296b90100000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000400000000000000000000000000000000000000000000000000000008302000001832fefd882560b84559c17b9b9040001020304050607080910151213141516171819202122232410000000000000000000200000000000000000003000000000000000000040000000000000000000500000000000000000006000000000000000000070000000000000000000800000000000000000009000000000000000000010000000000000000000100000000000000000002000000000000000000030000000000000000000400000000000000000005000000000000000000060000000000000000000700000000000000000008000000000000000000090000000000000000000100000000000000000001000000000000000000020000000000000000000300000000000000000004000000000000000000050000000000000000000600000000000000000007000000000000000000080000000000000000000900000000000000000001000000000000000000010000000000000000000200000000000000000003000000000000000000040000000000000000000500000000000000000006000000000000000000070000000000000000000800000000000000000009000000000000000000010000000000000000000100000000000000000002000000000000000000030000000000000000000400000000000000000005000000000000000000060000000000000000000700000000000000000008000000000000000000090000000000000000000100000000000000000001000000000000000000020000000000000000000300000000000000000004000000000000000000050000000000000000000600000000000000000007000000000000000000080000000000000000000900000000000000000001000000000000000000010000000000000000000200000000000000000003000000000000000000040000000000000000000500000000000000000006000000000000000000070000000000000000000800000000000000000009000000000000000000010000000000000000000100000000000000000002000000000000000000030000000000000000000400000000000000000005000000000000000000060000000000000000000700000000000000000008000000000000000000090000000000000000000100000000000000000001000000000000000000020000000000000000000300000000000000000004000000000000000000050000000000000000000600000000000000000007000000000000000000080000000000000000000900000000000000000001000000000000000000010000000000000000000200000000000000000003000000000000000000040000000000000000000500000000000000000006000000000000000000070000000000000000000800000000000000000009000000000000000000010000000000000000000a09c7b47112a3afb385c12924bf6280d273c106eea7caeaf5131d8776f61056c148876ae05d46b58d1fff866f864800a82c35094095e7baea6a6c7c4c2dfeb977efac326af552d8785012a05f200801ba01d2c92cfaeb04e53acdff2b5d42005ff6aacdb0105e64eb8c30c273f445d2782a01e7d50ffce57840360c57d94977b8cdebde614da23e8d1e77dc07928763cfe21c0' + +export const validBlockRLP = + '0xf90221f9021ca03cfde7bfb7187bc175f3a40fc930a20b3fa384a27e7639d23a223f8b52b31974a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d493479488d74a59454f6cf3b51ef6b9136afb6b9d405a88a0e8acbfca503fb67433f7427666e2a2b0152901ae53d9c5bb900334c1e969c0bda056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421b901000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000086016a6d87a32182ca00830d30b3808455c58acaa0476574682f76312e302e302d66633739643332642f6c696e75782f676f312e34a0f069cbc921fb229a9d8c79e32727291e6af8e33bec8ac184203ae1ca67f0a9148844b300df423f783cc0c0' diff --git a/packages/ethash/test/ethash_tests.json b/packages/ethash/test/ethash_tests.json deleted file mode 100644 index 134d74089e..0000000000 --- a/packages/ethash/test/ethash_tests.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "first": { - "nonce": "4242424242424242", - "mixHash": "58f759ede17a706c93f13030328bcea40c1d1341fb26f2facd21ceb0dae57017", - "header": "f901f3a00000000000000000000000000000000000000000000000000000000000000000a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347940000000000000000000000000000000000000000a09178d0f23c965d81f0834a4c72c6253ce6830f4022b1359aaebfc1ecba442d4ea056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008302000080830f4240808080a058f759ede17a706c93f13030328bcea40c1d1341fb26f2facd21ceb0dae57017884242424242424242", - "seed": "0000000000000000000000000000000000000000000000000000000000000000", - "result": "dd47fd2d98db51078356852d7c4014e6a5d6c387c35f40e2875b74a256ed7906", - "cache_size": 16776896, - "full_size": 1073739904, - "header_hash": "2a8de2adf89af77358250bf908bf04ba94a6e8c3ba87775564a41d269a05e4ce", - "cache_hash": "35ded12eecf2ce2e8da2e15c06d463aae9b84cb2530a00b932e4bbc484cde353" - }, - "second": { - "nonce": "307692cf71b12f6d", - "mixHash": "e55d02c555a7969361cf74a9ec6211d8c14e4517930a00442f171bdb1698d175", - "header": "f901f7a01bef91439a3e070a6586851c11e6fd79bbbea074b2b836727b8e75c7d4a6b698a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d4934794ea3cb5f94fa2ddd52ec6dd6eb75cf824f4058ca1a00c6e51346be0670ce63ac5f05324e27d20b180146269c5aab844d09a2b108c64a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008302004002832fefd880845511ed2a80a0e55d02c555a7969361cf74a9ec6211d8c14e4517930a00442f171bdb1698d17588307692cf71b12f6d", - "seed": "0000000000000000000000000000000000000000000000000000000000000000", - "result": "ab9b13423cface72cbec8424221651bc2e384ef0f7a560e038fc68c8d8684829", - "cache_size": 16776896, - "full_size": 1073739904, - "header_hash": "100cbec5e5ef82991290d0d93d758f19082e71f234cf479192a8b94df6da6bfe", - "cache_hash": "35ded12eecf2ce2e8da2e15c06d463aae9b84cb2530a00b932e4bbc484cde353" - } -} diff --git a/packages/ethash/test/ethash_tests.ts b/packages/ethash/test/ethash_tests.ts new file mode 100644 index 0000000000..7906ac87e8 --- /dev/null +++ b/packages/ethash/test/ethash_tests.ts @@ -0,0 +1,26 @@ +export const ethhashTests = { + first: { + nonce: '4242424242424242', + mixHash: '58f759ede17a706c93f13030328bcea40c1d1341fb26f2facd21ceb0dae57017', + header: + 'f901f3a00000000000000000000000000000000000000000000000000000000000000000a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347940000000000000000000000000000000000000000a09178d0f23c965d81f0834a4c72c6253ce6830f4022b1359aaebfc1ecba442d4ea056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008302000080830f4240808080a058f759ede17a706c93f13030328bcea40c1d1341fb26f2facd21ceb0dae57017884242424242424242', + seed: '0000000000000000000000000000000000000000000000000000000000000000', + result: 'dd47fd2d98db51078356852d7c4014e6a5d6c387c35f40e2875b74a256ed7906', + cache_size: 16776896, + full_size: 1073739904, + header_hash: '2a8de2adf89af77358250bf908bf04ba94a6e8c3ba87775564a41d269a05e4ce', + cache_hash: '35ded12eecf2ce2e8da2e15c06d463aae9b84cb2530a00b932e4bbc484cde353', + }, + second: { + nonce: '307692cf71b12f6d', + mixHash: 'e55d02c555a7969361cf74a9ec6211d8c14e4517930a00442f171bdb1698d175', + header: + 'f901f7a01bef91439a3e070a6586851c11e6fd79bbbea074b2b836727b8e75c7d4a6b698a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d4934794ea3cb5f94fa2ddd52ec6dd6eb75cf824f4058ca1a00c6e51346be0670ce63ac5f05324e27d20b180146269c5aab844d09a2b108c64a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008302004002832fefd880845511ed2a80a0e55d02c555a7969361cf74a9ec6211d8c14e4517930a00442f171bdb1698d17588307692cf71b12f6d', + seed: '0000000000000000000000000000000000000000000000000000000000000000', + result: 'ab9b13423cface72cbec8424221651bc2e384ef0f7a560e038fc68c8d8684829', + cache_size: 16776896, + full_size: 1073739904, + header_hash: '100cbec5e5ef82991290d0d93d758f19082e71f234cf479192a8b94df6da6bfe', + cache_hash: '35ded12eecf2ce2e8da2e15c06d463aae9b84cb2530a00b932e4bbc484cde353', + }, +} From 6fb328ae34dffd2f8b7c4a542569b4018727a6bf Mon Sep 17 00:00:00 2001 From: Gabriel Rocheleau Date: Wed, 18 Sep 2024 22:36:32 -0400 Subject: [PATCH 2/2] ethash: cspell fix --- packages/ethash/test/block_tests_data.ts | 1 + packages/ethash/test/ethash.spec.ts | 6 +++--- packages/ethash/test/ethash_tests.ts | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/ethash/test/block_tests_data.ts b/packages/ethash/test/block_tests_data.ts index bf47e14bb4..b14489ba5d 100644 --- a/packages/ethash/test/block_tests_data.ts +++ b/packages/ethash/test/block_tests_data.ts @@ -1,3 +1,4 @@ +// cspell:disable export const blockTestsData = { _info: { comment: '', diff --git a/packages/ethash/test/ethash.spec.ts b/packages/ethash/test/ethash.spec.ts index 004379f7a2..fbc79567d9 100644 --- a/packages/ethash/test/ethash.spec.ts +++ b/packages/ethash/test/ethash.spec.ts @@ -6,16 +6,16 @@ import { assert, describe, it } from 'vitest' import { Ethash } from '../src/index.js' import { getCacheSize, getEpoc, getFullSize } from '../src/util.js' -import { ethhashTests } from './ethash_tests.js' +import { ethashTests } from './ethash_tests.js' const ethash = new Ethash() -const tests = Object.keys(ethhashTests) as (keyof typeof ethhashTests)[] +const tests = Object.keys(ethashTests) as (keyof typeof ethashTests)[] const common = new Common({ chain: Mainnet, hardfork: Hardfork.Istanbul }) describe('POW tests', () => { it('should work', async () => { for (const key of tests) { - const test = ethhashTests[key] + const test = ethashTests[key] const header = createBlockHeaderFromRLP(hexToBytes(`0x${test.header}`), { common }) const headerHash = ethash.headerHash(header.raw()) diff --git a/packages/ethash/test/ethash_tests.ts b/packages/ethash/test/ethash_tests.ts index 7906ac87e8..50dff936d2 100644 --- a/packages/ethash/test/ethash_tests.ts +++ b/packages/ethash/test/ethash_tests.ts @@ -1,4 +1,4 @@ -export const ethhashTests = { +export const ethashTests = { first: { nonce: '4242424242424242', mixHash: '58f759ede17a706c93f13030328bcea40c1d1341fb26f2facd21ceb0dae57017',