diff --git a/packages/block/src/header.ts b/packages/block/src/header.ts index 7a3ac1f258..06cdb01c4f 100644 --- a/packages/block/src/header.ts +++ b/packages/block/src/header.ts @@ -34,7 +34,6 @@ import { paramsBlock } from './params.js' import type { BlockHeaderBytes, BlockOptions, HeaderData, JsonHeader } from './types.js' import type { CliqueConfig } from '@ethereumjs/common' -import type { BigIntLike } from '@ethereumjs/util' interface HeaderCache { hash: Uint8Array | undefined @@ -154,12 +153,6 @@ export class BlockHeader { blockNumber: number, timestamp, }) - } else if (typeof setHardfork !== 'boolean') { - this.common.setHardforkBy({ - blockNumber: number, - td: setHardfork as BigIntLike, - timestamp, - }) } // Hardfork defaults which couldn't be paired with earlier defaults diff --git a/packages/block/src/types.ts b/packages/block/src/types.ts index 470faed400..8957546946 100644 --- a/packages/block/src/types.ts +++ b/packages/block/src/types.ts @@ -40,12 +40,9 @@ export interface BlockOptions { * Set the hardfork either by timestamp (for HFs from Shanghai onwards) or by block number * for older Hfs. * - * Additionally it is possible to pass in a specific TD value to support live-Merge-HF - * transitions. Note that this should only be needed in very rare and specific scenarios. - * * Default: `false` (HF is set to whatever default HF is set by the {@link Common} instance) */ - setHardfork?: boolean | BigIntLike + setHardfork?: boolean /** * Block parameters sorted by EIP can be found in the exported `paramsBlock` dictionary, * which is internally passed to the associated `@ethereumjs/common` instance which diff --git a/packages/block/test/block.spec.ts b/packages/block/test/block.spec.ts index 28c68dd9b5..e3c6ac19fd 100644 --- a/packages/block/test/block.spec.ts +++ b/packages/block/test/block.spec.ts @@ -114,27 +114,12 @@ describe('[Block]: block functions', () => { number: 20, // Future block }, }, - { common, setHardfork: 5001 }, + { common, setHardfork: true }, ) assert.equal( block.common.hardfork(), Hardfork.Paris, - 'should use setHardfork option (td > threshold)', - ) - - block = createBlock( - { - header: { - number: 12, // Berlin block, - extraData: new Uint8Array(97), - }, - }, - { common, setHardfork: 3000 }, - ) - assert.equal( - block.common.hardfork(), - Hardfork.Berlin, - 'should work with setHardfork option (td < threshold)', + 'should use setHardfork option post merge', ) }) diff --git a/packages/block/test/from-rpc.spec.ts b/packages/block/test/from-rpc.spec.ts index 1027dd58f9..cd3b2ad5a4 100644 --- a/packages/block/test/from-rpc.spec.ts +++ b/packages/block/test/from-rpc.spec.ts @@ -147,7 +147,7 @@ describe('[fromRPC] - Alchemy/Infura API block responses', () => { ) block = createBlockFromRpc(infura15571241woTxs as JsonRpcBlock, [], { common, - setHardfork: 58750000000000000000000n, + setHardfork: true, }) assert.equal( bytesToHex(block.hash()), @@ -157,7 +157,7 @@ describe('[fromRPC] - Alchemy/Infura API block responses', () => { block = createBlockFromRpc(infura15571241wTxs as JsonRpcBlock, [], { common, - setHardfork: 58750000000000000000000n, + setHardfork: true, }) assert.equal( bytesToHex(block.hash()), diff --git a/packages/block/test/header.spec.ts b/packages/block/test/header.spec.ts index 8a22d26119..914aa5fa19 100644 --- a/packages/block/test/header.spec.ts +++ b/packages/block/test/header.spec.ts @@ -107,18 +107,6 @@ describe('[Block]: Header functions', () => { 'block should not be frozen when freeze deactivated in options', ) - assert.throws( - () => - createHeaderFromRLP(rlpHeader, { - common, - freeze: false, - setHardfork: 1n, // Added to bypass defaulting setHardfork to true in static constructor - }), - 'A base fee', - undefined, - 'throws when RLP serialized block with no base fee on default hardfork (london) and setHardfork left undefined', - ) - header = createHeaderFromRLP( hexToBytes( '0xf90214a00000000000000000000000000000000000000000000000000000000000000000a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347940000000000000000000000000000000000000000a0d7f8974fb5ac78d9ac099b9ad5018bedc2ce0a72dad1827a1709da30580f0544a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421b9010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000850400000000808213888080a011bbe8db4e347b4e8c937c1c8370e4b5ed33adb3db69cbdb7a38e1e50b1b82faa00000000000000000000000000000000000000000000000000000000000000000880000000000000042', diff --git a/packages/block/test/testdata/4844-hardfork.json b/packages/block/test/testdata/4844-hardfork.json index 9ee53c6112..bb954f80e4 100644 --- a/packages/block/test/testdata/4844-hardfork.json +++ b/packages/block/test/testdata/4844-hardfork.json @@ -19,7 +19,7 @@ "period": 5, "epoch": 30000 }, - "terminalTotalDifficulty": 2, + "terminalTotalDifficulty": 0, "terminalTotalDifficultyPassed": true }, "nonce": "0x42", diff --git a/packages/block/test/testdata/testnetMerge.json b/packages/block/test/testdata/testnetMerge.json index e6698fa6b3..5103197fcd 100644 --- a/packages/block/test/testdata/testnetMerge.json +++ b/packages/block/test/testdata/testnetMerge.json @@ -53,8 +53,7 @@ }, { "name": "paris", - "block": null, - "ttd": "5000" + "block": 15 }, { "name": "shanghai", diff --git a/packages/blockchain/src/blockchain.ts b/packages/blockchain/src/blockchain.ts index d4e97e182e..a50b1bf933 100644 --- a/packages/blockchain/src/blockchain.ts +++ b/packages/blockchain/src/blockchain.ts @@ -318,14 +318,13 @@ export class Blockchain implements BlockchainInterface { throw new Error(`no block for ${canonicalHead} found in DB`) } const header = await this._getHeader(hash, canonicalHead) - const td = await this.getParentTD(header) const dbOps: DBOp[] = [] await this._deleteCanonicalChainReferences(canonicalHead + BIGINT_1, hash, dbOps) const ops = dbOps.concat(this._saveHeadOps()) await this.dbManager.batch(ops) - await this.checkAndTransitionHardForkByNumber(canonicalHead, td, header.timestamp) + await this.checkAndTransitionHardForkByNumber(canonicalHead, header.timestamp) }) if (this._deletedBlocks.length > 0) { this.events.emit('deletedCanonicalBlocks', this._deletedBlocks) @@ -429,7 +428,7 @@ export class Blockchain implements BlockchainInterface { this._headBlockHash = blockHash } if (this._hardforkByHeadBlockNumber) { - await this.checkAndTransitionHardForkByNumber(blockNumber, parentTd, header.timestamp) + await this.checkAndTransitionHardForkByNumber(blockNumber, header.timestamp) } // delete higher number assignments and overwrite stale canonical chain @@ -1211,12 +1210,10 @@ export class Blockchain implements BlockchainInterface { async checkAndTransitionHardForkByNumber( number: BigIntLike, - td?: BigIntLike, timestamp?: BigIntLike, ): Promise { this.common.setHardforkBy({ blockNumber: number, - td, timestamp, }) @@ -1263,7 +1260,6 @@ export class Blockchain implements BlockchainInterface { const common = this.common.copy() common.setHardforkBy({ blockNumber: 0, - td: BigInt(common.genesis().difficulty), timestamp: common.genesis().timestamp, }) diff --git a/packages/blockchain/src/constructors.ts b/packages/blockchain/src/constructors.ts index dce7e3f485..824957f63f 100644 --- a/packages/blockchain/src/constructors.ts +++ b/packages/blockchain/src/constructors.ts @@ -78,12 +78,7 @@ export async function createBlockchain(opts: BlockchainOptions = {}) { if (blockchain['_hardforkByHeadBlockNumber']) { const latestHeader = await blockchain['_getHeader'](blockchain['_headHeaderHash']) - const td = await blockchain.getParentTD(latestHeader) - await blockchain.checkAndTransitionHardForkByNumber( - latestHeader.number, - td, - latestHeader.timestamp, - ) + await blockchain.checkAndTransitionHardForkByNumber(latestHeader.number, latestHeader.timestamp) } return blockchain diff --git a/packages/blockchain/src/db/manager.ts b/packages/blockchain/src/db/manager.ts index 99ec462790..0b0d5f1eb8 100644 --- a/packages/blockchain/src/db/manager.ts +++ b/packages/blockchain/src/db/manager.ts @@ -1,12 +1,6 @@ -import { - createBlockFromValuesArray, - createHeaderFromValuesArray, - valuesArrayToHeaderData, -} from '@ethereumjs/block' +import { createBlockFromValuesArray, createHeaderFromValuesArray } from '@ethereumjs/block' import { RLP } from '@ethereumjs/rlp' import { - BIGINT_0, - BIGINT_1, KECCAK256_RLP, KECCAK256_RLP_ARRAY, bytesToBigInt, @@ -146,12 +140,7 @@ export class DBManager { } const blockData = [header.raw(), ...body] as BlockBytes - const opts: BlockOptions = { common: this.common } - if (number === BIGINT_0) { - opts.setHardfork = await this.getTotalDifficulty(hash, BIGINT_0) - } else { - opts.setHardfork = await this.getTotalDifficulty(header.parentHash, number - BIGINT_1) - } + const opts: BlockOptions = { common: this.common, setHardfork: true } return createBlockFromValuesArray(blockData, opts) } @@ -170,16 +159,7 @@ export class DBManager { const encodedHeader = await this.get(DBTarget.Header, { blockHash, blockNumber }) const headerValues = RLP.decode(encodedHeader) - const opts: BlockOptions = { common: this.common } - if (blockNumber === BIGINT_0) { - opts.setHardfork = await this.getTotalDifficulty(blockHash, BIGINT_0) - } else { - // Lets fetch the parent hash but not by number since this block might not - // be in canonical chain - const headerData = valuesArrayToHeaderData(headerValues as Uint8Array[]) - const parentHash = headerData.parentHash as Uint8Array - opts.setHardfork = await this.getTotalDifficulty(parentHash, blockNumber - BIGINT_1) - } + const opts: BlockOptions = { common: this.common, setHardfork: true } return createHeaderFromValuesArray(headerValues as Uint8Array[], opts) } diff --git a/packages/blockchain/src/helpers.ts b/packages/blockchain/src/helpers.ts index f654b314a7..fc21c891fd 100644 --- a/packages/blockchain/src/helpers.ts +++ b/packages/blockchain/src/helpers.ts @@ -24,7 +24,6 @@ export async function genGenesisStateRoot( const genCommon = common.copy() genCommon.setHardforkBy({ blockNumber: 0, - td: BigInt(genCommon.genesis().difficulty), timestamp: genCommon.genesis().timestamp, }) if (genCommon.isActivatedEIP(6800)) { diff --git a/packages/blockchain/test/pos.spec.ts b/packages/blockchain/test/pos.spec.ts deleted file mode 100644 index 7aab347404..0000000000 --- a/packages/blockchain/test/pos.spec.ts +++ /dev/null @@ -1,117 +0,0 @@ -import { createBlock } from '@ethereumjs/block' -import { Common, Hardfork, Mainnet, createCustomCommon } from '@ethereumjs/common' -import { bytesToHex } from '@ethereumjs/util' -import { assert, describe, it } from 'vitest' - -import { createBlockchain } from '../src/index.js' - -import * as testnet from './testdata/testnet.json' - -import type { Blockchain } from '../src/index.js' -import type { Block } from '@ethereumjs/block' - -const buildChain = async (blockchain: Blockchain, common: Common, height: number) => { - const blocks: Block[] = [] - const londonBlockNumber = Number(common.hardforkBlock('london')!) - const genesis = blockchain.genesisBlock - blocks.push(genesis) - for (let number = 1; number <= height; number++) { - let baseFeePerGas = BigInt(0) - if (number === londonBlockNumber) { - baseFeePerGas = BigInt(1000000000) - } else if (number > londonBlockNumber) { - baseFeePerGas = blocks[number - 1].header.calcNextBaseFee() - } - const block = createBlock( - { - header: { - number, - parentHash: blocks[number - 1].hash(), - timestamp: blocks[number - 1].header.timestamp + BigInt(1), - gasLimit: number >= londonBlockNumber ? BigInt(10000) : BigInt(5000), - baseFeePerGas: number >= londonBlockNumber ? baseFeePerGas : undefined, - }, - }, - { - calcDifficultyFromHeader: blocks[number - 1].header, - common, - setHardfork: await blockchain.getTotalDifficulty(blocks[number - 1].hash()), - }, - ) - blocks.push(block) - await blockchain.putBlock(block) - } -} - -describe('Proof of Stake - inserting blocks into blockchain', () => { - const testnetOnlyTD = JSON.parse(JSON.stringify(testnet)) - testnetOnlyTD['hardforks'][11] = { - name: 'paris', - ttd: BigInt(1313600), - block: null, - } - const scenarios = [ - { - // @ts-ignore prefixed string type is too strict here - common: createCustomCommon(testnet.default, Mainnet, { hardfork: Hardfork.Chainstart }), - }, - { - common: createCustomCommon(testnetOnlyTD.default, Mainnet, { hardfork: Hardfork.Chainstart }), - }, - ] - - for (const s of scenarios) { - it('should pass', async () => { - const blockchain = await createBlockchain({ - validateBlocks: true, - common: s.common, - hardforkByHeadBlockNumber: true, - }) - const genesisHeader = await blockchain.getCanonicalHeadHeader() - assert.equal( - bytesToHex(genesisHeader.hash()), - '0x1119dc5ff680bf7b4c3d9cd41168334dee127d46b3626482076025cdd498ed0b', - 'genesis hash matches', - ) - await buildChain(blockchain, s.common, 15) - - const latestHeader = await blockchain.getCanonicalHeadHeader() - assert.equal(latestHeader.number, BigInt(15), 'blockchain is at correct height') - - assert.equal( - (blockchain as any).common.hardfork(), - 'paris', - 'HF should have been correctly updated', - ) - const td = await blockchain.getTotalDifficulty(latestHeader.hash()) - assert.equal( - td, - BigInt(1313601), - 'should have calculated the correct post-Merge total difficulty', - ) - - const common = new Common({ chain: Mainnet, hardfork: Hardfork.London }) - const powBlock = createBlock( - { - header: { - number: 16, - difficulty: BigInt(1), - parentHash: latestHeader.hash(), - timestamp: latestHeader.timestamp + BigInt(1), - gasLimit: BigInt(10000), - }, - }, - { common }, - ) - try { - await blockchain.putBlock(powBlock) - assert.fail('should throw when inserting PoW block') - } catch (err: any) { - assert.ok( - err.message.includes('invalid difficulty'), - 'should throw with invalid difficulty message', - ) - } - }) - } -}) diff --git a/packages/blockchain/test/testdata/geth-genesis-kiln.json b/packages/blockchain/test/testdata/geth-genesis-kiln.json deleted file mode 100644 index 6d99cf2355..0000000000 --- a/packages/blockchain/test/testdata/geth-genesis-kiln.json +++ /dev/null @@ -1,865 +0,0 @@ -{ - "config": { - "chainId": 1337802, - "homesteadBlock": 0, - "eip150Block": 0, - "eip155Block": 0, - "eip158Block": 0, - "byzantiumBlock": 0, - "constantinopleBlock": 0, - "petersburgBlock": 0, - "istanbulBlock": 0, - "berlinBlock": 0, - "londonBlock": 0, - "mergeForkBlock": 1000, - "terminalTotalDifficulty": 20000000000000 - }, - "alloc": { - "0x0000000000000000000000000000000000000000": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000001": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000002": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000003": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000004": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000005": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000006": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000007": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000008": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000009": { - "balance": "1" - }, - "0x000000000000000000000000000000000000000a": { - "balance": "1" - }, - "0x000000000000000000000000000000000000000b": { - "balance": "1" - }, - "0x000000000000000000000000000000000000000c": { - "balance": "1" - }, - "0x000000000000000000000000000000000000000d": { - "balance": "1" - }, - "0x000000000000000000000000000000000000000e": { - "balance": "1" - }, - "0x000000000000000000000000000000000000000f": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000010": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000011": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000012": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000013": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000014": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000015": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000016": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000017": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000018": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000019": { - "balance": "1" - }, - "0x000000000000000000000000000000000000001a": { - "balance": "1" - }, - "0x000000000000000000000000000000000000001b": { - "balance": "1" - }, - "0x000000000000000000000000000000000000001c": { - "balance": "1" - }, - "0x000000000000000000000000000000000000001d": { - "balance": "1" - }, - "0x000000000000000000000000000000000000001e": { - "balance": "1" - }, - "0x000000000000000000000000000000000000001f": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000020": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000021": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000022": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000023": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000024": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000025": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000026": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000027": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000028": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000029": { - "balance": "1" - }, - "0x000000000000000000000000000000000000002a": { - "balance": "1" - }, - "0x000000000000000000000000000000000000002b": { - "balance": "1" - }, - "0x000000000000000000000000000000000000002c": { - "balance": "1" - }, - "0x000000000000000000000000000000000000002d": { - "balance": "1" - }, - "0x000000000000000000000000000000000000002e": { - "balance": "1" - }, - "0x000000000000000000000000000000000000002f": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000030": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000031": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000032": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000033": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000034": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000035": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000036": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000037": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000038": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000039": { - "balance": "1" - }, - "0x000000000000000000000000000000000000003a": { - "balance": "1" - }, - "0x000000000000000000000000000000000000003b": { - "balance": "1" - }, - "0x000000000000000000000000000000000000003c": { - "balance": "1" - }, - "0x000000000000000000000000000000000000003d": { - "balance": "1" - }, - "0x000000000000000000000000000000000000003e": { - "balance": "1" - }, - "0x000000000000000000000000000000000000003f": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000040": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000041": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000042": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000043": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000044": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000045": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000046": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000047": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000048": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000049": { - "balance": "1" - }, - "0x000000000000000000000000000000000000004a": { - "balance": "1" - }, - "0x000000000000000000000000000000000000004b": { - "balance": "1" - }, - "0x000000000000000000000000000000000000004c": { - "balance": "1" - }, - "0x000000000000000000000000000000000000004d": { - "balance": "1" - }, - "0x000000000000000000000000000000000000004e": { - "balance": "1" - }, - "0x000000000000000000000000000000000000004f": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000050": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000051": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000052": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000053": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000054": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000055": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000056": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000057": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000058": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000059": { - "balance": "1" - }, - "0x000000000000000000000000000000000000005a": { - "balance": "1" - }, - "0x000000000000000000000000000000000000005b": { - "balance": "1" - }, - "0x000000000000000000000000000000000000005c": { - "balance": "1" - }, - "0x000000000000000000000000000000000000005d": { - "balance": "1" - }, - "0x000000000000000000000000000000000000005e": { - "balance": "1" - }, - "0x000000000000000000000000000000000000005f": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000060": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000061": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000062": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000063": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000064": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000065": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000066": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000067": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000068": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000069": { - "balance": "1" - }, - "0x000000000000000000000000000000000000006a": { - "balance": "1" - }, - "0x000000000000000000000000000000000000006b": { - "balance": "1" - }, - "0x000000000000000000000000000000000000006c": { - "balance": "1" - }, - "0x000000000000000000000000000000000000006d": { - "balance": "1" - }, - "0x000000000000000000000000000000000000006e": { - "balance": "1" - }, - "0x000000000000000000000000000000000000006f": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000070": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000071": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000072": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000073": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000074": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000075": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000076": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000077": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000078": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000079": { - "balance": "1" - }, - "0x000000000000000000000000000000000000007a": { - "balance": "1" - }, - "0x000000000000000000000000000000000000007b": { - "balance": "1" - }, - "0x000000000000000000000000000000000000007c": { - "balance": "1" - }, - "0x000000000000000000000000000000000000007d": { - "balance": "1" - }, - "0x000000000000000000000000000000000000007e": { - "balance": "1" - }, - "0x000000000000000000000000000000000000007f": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000080": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000081": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000082": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000083": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000084": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000085": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000086": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000087": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000088": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000089": { - "balance": "1" - }, - "0x000000000000000000000000000000000000008a": { - "balance": "1" - }, - "0x000000000000000000000000000000000000008b": { - "balance": "1" - }, - "0x000000000000000000000000000000000000008c": { - "balance": "1" - }, - "0x000000000000000000000000000000000000008d": { - "balance": "1" - }, - "0x000000000000000000000000000000000000008e": { - "balance": "1" - }, - "0x000000000000000000000000000000000000008f": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000090": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000091": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000092": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000093": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000094": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000095": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000096": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000097": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000098": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000099": { - "balance": "1" - }, - "0x000000000000000000000000000000000000009a": { - "balance": "1" - }, - "0x000000000000000000000000000000000000009b": { - "balance": "1" - }, - "0x000000000000000000000000000000000000009c": { - "balance": "1" - }, - "0x000000000000000000000000000000000000009d": { - "balance": "1" - }, - "0x000000000000000000000000000000000000009e": { - "balance": "1" - }, - "0x000000000000000000000000000000000000009f": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000a0": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000a1": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000a2": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000a3": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000a4": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000a5": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000a6": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000a7": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000a8": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000a9": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000aa": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000ab": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000ac": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000ad": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000ae": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000af": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000b0": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000b1": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000b2": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000b3": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000b4": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000b5": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000b6": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000b7": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000b8": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000b9": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000ba": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000bb": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000bc": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000bd": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000be": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000bf": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000c0": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000c1": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000c2": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000c3": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000c4": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000c5": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000c6": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000c7": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000c8": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000c9": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000ca": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000cb": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000cc": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000cd": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000ce": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000cf": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000d0": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000d1": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000d2": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000d3": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000d4": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000d5": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000d6": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000d7": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000d8": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000d9": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000da": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000db": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000dc": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000dd": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000de": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000df": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000e0": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000e1": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000e2": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000e3": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000e4": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000e5": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000e6": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000e7": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000e8": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000e9": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000ea": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000eb": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000ec": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000ed": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000ee": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000ef": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000f0": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000f1": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000f2": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000f3": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000f4": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000f5": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000f6": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000f7": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000f8": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000f9": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000fa": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000fb": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000fc": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000fd": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000fe": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000ff": { - "balance": "1" - }, - "0x4242424242424242424242424242424242424242": { - "balance": "0", - "code": "0x60806040526004361061003f5760003560e01c806301ffc9a71461004457806322895118146100a4578063621fd130146101ba578063c5f2892f14610244575b600080fd5b34801561005057600080fd5b506100906004803603602081101561006757600080fd5b50357fffffffff000000000000000000000000000000000000000000000000000000001661026b565b604080519115158252519081900360200190f35b6101b8600480360360808110156100ba57600080fd5b8101906020810181356401000000008111156100d557600080fd5b8201836020820111156100e757600080fd5b8035906020019184600183028401116401000000008311171561010957600080fd5b91939092909160208101903564010000000081111561012757600080fd5b82018360208201111561013957600080fd5b8035906020019184600183028401116401000000008311171561015b57600080fd5b91939092909160208101903564010000000081111561017957600080fd5b82018360208201111561018b57600080fd5b803590602001918460018302840111640100000000831117156101ad57600080fd5b919350915035610304565b005b3480156101c657600080fd5b506101cf6110b5565b6040805160208082528351818301528351919283929083019185019080838360005b838110156102095781810151838201526020016101f1565b50505050905090810190601f1680156102365780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561025057600080fd5b506102596110c7565b60408051918252519081900360200190f35b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f01ffc9a70000000000000000000000000000000000000000000000000000000014806102fe57507fffffffff0000000000000000000000000000000000000000000000000000000082167f8564090700000000000000000000000000000000000000000000000000000000145b92915050565b6030861461035d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806118056026913960400191505060405180910390fd5b602084146103b6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252603681526020018061179c6036913960400191505060405180910390fd5b6060821461040f576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260298152602001806118786029913960400191505060405180910390fd5b670de0b6b3a7640000341015610470576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806118526026913960400191505060405180910390fd5b633b9aca003406156104cd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260338152602001806117d26033913960400191505060405180910390fd5b633b9aca00340467ffffffffffffffff811115610535576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602781526020018061182b6027913960400191505060405180910390fd5b6060610540826114ba565b90507f649bbc62d0e31342afea4e5cd82d4049e7e1ee912fc0889aa790803be39038c589898989858a8a6105756020546114ba565b6040805160a0808252810189905290819060208201908201606083016080840160c085018e8e80828437600083820152601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01690910187810386528c815260200190508c8c808284376000838201819052601f9091017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01690920188810386528c5181528c51602091820193918e019250908190849084905b83811015610648578181015183820152602001610630565b50505050905090810190601f1680156106755780820380516001836020036101000a031916815260200191505b5086810383528881526020018989808284376000838201819052601f9091017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169092018881038452895181528951602091820193918b019250908190849084905b838110156106ef5781810151838201526020016106d7565b50505050905090810190601f16801561071c5780820380516001836020036101000a031916815260200191505b509d505050505050505050505050505060405180910390a1600060028a8a600060801b604051602001808484808284377fffffffffffffffffffffffffffffffff0000000000000000000000000000000090941691909301908152604080517ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0818403018152601090920190819052815191955093508392506020850191508083835b602083106107fc57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe090920191602091820191016107bf565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610859573d6000803e3d6000fd5b5050506040513d602081101561086e57600080fd5b5051905060006002806108846040848a8c6116fe565b6040516020018083838082843780830192505050925050506040516020818303038152906040526040518082805190602001908083835b602083106108f857805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe090920191602091820191016108bb565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610955573d6000803e3d6000fd5b5050506040513d602081101561096a57600080fd5b5051600261097b896040818d6116fe565b60405160009060200180848480828437919091019283525050604080518083038152602092830191829052805190945090925082918401908083835b602083106109f457805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe090920191602091820191016109b7565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610a51573d6000803e3d6000fd5b5050506040513d6020811015610a6657600080fd5b5051604080516020818101949094528082019290925280518083038201815260609092019081905281519192909182918401908083835b60208310610ada57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610a9d565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610b37573d6000803e3d6000fd5b5050506040513d6020811015610b4c57600080fd5b50516040805160208101858152929350600092600292839287928f928f92018383808284378083019250505093505050506040516020818303038152906040526040518082805190602001908083835b60208310610bd957805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610b9c565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610c36573d6000803e3d6000fd5b5050506040513d6020811015610c4b57600080fd5b50516040518651600291889160009188916020918201918291908601908083835b60208310610ca957805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610c6c565b6001836020036101000a0380198251168184511680821785525050505050509050018367ffffffffffffffff191667ffffffffffffffff1916815260180182815260200193505050506040516020818303038152906040526040518082805190602001908083835b60208310610d4e57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610d11565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610dab573d6000803e3d6000fd5b5050506040513d6020811015610dc057600080fd5b5051604080516020818101949094528082019290925280518083038201815260609092019081905281519192909182918401908083835b60208310610e3457805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610df7565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610e91573d6000803e3d6000fd5b5050506040513d6020811015610ea657600080fd5b50519050858114610f02576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260548152602001806117486054913960600191505060405180910390fd5b60205463ffffffff11610f60576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260218152602001806117276021913960400191505060405180910390fd5b602080546001019081905560005b60208110156110a9578160011660011415610fa0578260008260208110610f9157fe5b0155506110ac95505050505050565b600260008260208110610faf57fe5b01548460405160200180838152602001828152602001925050506040516020818303038152906040526040518082805190602001908083835b6020831061102557805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610fe8565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015611082573d6000803e3d6000fd5b5050506040513d602081101561109757600080fd5b50519250600282049150600101610f6e565b50fe5b50505050505050565b60606110c26020546114ba565b905090565b6020546000908190815b60208110156112f05781600116600114156111e6576002600082602081106110f557fe5b01548460405160200180838152602001828152602001925050506040516020818303038152906040526040518082805190602001908083835b6020831061116b57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0909201916020918201910161112e565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa1580156111c8573d6000803e3d6000fd5b5050506040513d60208110156111dd57600080fd5b505192506112e2565b600283602183602081106111f657fe5b015460405160200180838152602001828152602001925050506040516020818303038152906040526040518082805190602001908083835b6020831061126b57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0909201916020918201910161122e565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa1580156112c8573d6000803e3d6000fd5b5050506040513d60208110156112dd57600080fd5b505192505b6002820491506001016110d1565b506002826112ff6020546114ba565b600060401b6040516020018084815260200183805190602001908083835b6020831061135a57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0909201916020918201910161131d565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790527fffffffffffffffffffffffffffffffffffffffffffffffff000000000000000095909516920191825250604080518083037ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8018152601890920190819052815191955093508392850191508083835b6020831061143f57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101611402565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa15801561149c573d6000803e3d6000fd5b5050506040513d60208110156114b157600080fd5b50519250505090565b60408051600880825281830190925260609160208201818036833701905050905060c082901b8060071a60f81b826000815181106114f457fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060061a60f81b8260018151811061153757fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060051a60f81b8260028151811061157a57fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060041a60f81b826003815181106115bd57fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060031a60f81b8260048151811061160057fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060021a60f81b8260058151811061164357fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060011a60f81b8260068151811061168657fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060001a60f81b826007815181106116c957fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535050919050565b6000808585111561170d578182fd5b83861115611719578182fd5b505082019391909203915056fe4465706f736974436f6e74726163743a206d65726b6c6520747265652066756c6c4465706f736974436f6e74726163743a207265636f6e7374727563746564204465706f7369744461746120646f6573206e6f74206d6174636820737570706c696564206465706f7369745f646174615f726f6f744465706f736974436f6e74726163743a20696e76616c6964207769746864726177616c5f63726564656e7469616c73206c656e6774684465706f736974436f6e74726163743a206465706f7369742076616c7565206e6f74206d756c7469706c65206f6620677765694465706f736974436f6e74726163743a20696e76616c6964207075626b6579206c656e6774684465706f736974436f6e74726163743a206465706f7369742076616c756520746f6f20686967684465706f736974436f6e74726163743a206465706f7369742076616c756520746f6f206c6f774465706f736974436f6e74726163743a20696e76616c6964207369676e6174757265206c656e677468a26469706673582212201dd26f37a621703009abf16e77e69c93dc50c79db7f6cc37543e3e0e3decdc9764736f6c634300060b0033", - "storage": { - "0x0000000000000000000000000000000000000000000000000000000000000022": "0xf5a5fd42d16a20302798ef6ed309979b43003d2320d9f0e8ea9831a92759fb4b", - "0x0000000000000000000000000000000000000000000000000000000000000023": "0xdb56114e00fdd4c1f85c892bf35ac9a89289aaecb1ebd0a96cde606a748b5d71", - "0x0000000000000000000000000000000000000000000000000000000000000024": "0xc78009fdf07fc56a11f122370658a353aaa542ed63e44c4bc15ff4cd105ab33c", - "0x0000000000000000000000000000000000000000000000000000000000000025": "0x536d98837f2dd165a55d5eeae91485954472d56f246df256bf3cae19352a123c", - "0x0000000000000000000000000000000000000000000000000000000000000026": "0x9efde052aa15429fae05bad4d0b1d7c64da64d03d7a1854a588c2cb8430c0d30", - "0x0000000000000000000000000000000000000000000000000000000000000027": "0xd88ddfeed400a8755596b21942c1497e114c302e6118290f91e6772976041fa1", - "0x0000000000000000000000000000000000000000000000000000000000000028": "0x87eb0ddba57e35f6d286673802a4af5975e22506c7cf4c64bb6be5ee11527f2c", - "0x0000000000000000000000000000000000000000000000000000000000000029": "0x26846476fd5fc54a5d43385167c95144f2643f533cc85bb9d16b782f8d7db193", - "0x000000000000000000000000000000000000000000000000000000000000002a": "0x506d86582d252405b840018792cad2bf1259f1ef5aa5f887e13cb2f0094f51e1", - "0x000000000000000000000000000000000000000000000000000000000000002b": "0xffff0ad7e659772f9534c195c815efc4014ef1e1daed4404c06385d11192e92b", - "0x000000000000000000000000000000000000000000000000000000000000002c": "0x6cf04127db05441cd833107a52be852868890e4317e6a02ab47683aa75964220", - "0x000000000000000000000000000000000000000000000000000000000000002d": "0xb7d05f875f140027ef5118a2247bbb84ce8f2f0f1123623085daf7960c329f5f", - "0x000000000000000000000000000000000000000000000000000000000000002e": "0xdf6af5f5bbdb6be9ef8aa618e4bf8073960867171e29676f8b284dea6a08a85e", - "0x000000000000000000000000000000000000000000000000000000000000002f": "0xb58d900f5e182e3c50ef74969ea16c7726c549757cc23523c369587da7293784", - "0x0000000000000000000000000000000000000000000000000000000000000030": "0xd49a7502ffcfb0340b1d7885688500ca308161a7f96b62df9d083b71fcc8f2bb", - "0x0000000000000000000000000000000000000000000000000000000000000031": "0x8fe6b1689256c0d385f42f5bbe2027a22c1996e110ba97c171d3e5948de92beb", - "0x0000000000000000000000000000000000000000000000000000000000000032": "0x8d0d63c39ebade8509e0ae3c9c3876fb5fa112be18f905ecacfecb92057603ab", - "0x0000000000000000000000000000000000000000000000000000000000000033": "0x95eec8b2e541cad4e91de38385f2e046619f54496c2382cb6cacd5b98c26f5a4", - "0x0000000000000000000000000000000000000000000000000000000000000034": "0xf893e908917775b62bff23294dbbe3a1cd8e6cc1c35b4801887b646a6f81f17f", - "0x0000000000000000000000000000000000000000000000000000000000000035": "0xcddba7b592e3133393c16194fac7431abf2f5485ed711db282183c819e08ebaa", - "0x0000000000000000000000000000000000000000000000000000000000000036": "0x8a8d7fe3af8caa085a7639a832001457dfb9128a8061142ad0335629ff23ff9c", - "0x0000000000000000000000000000000000000000000000000000000000000037": "0xfeb3c337d7a51a6fbf00b9e34c52e1c9195c969bd4e7a0bfd51d5c5bed9c1167", - "0x0000000000000000000000000000000000000000000000000000000000000038": "0xe71f0aa83cc32edfbefa9f4d3e0174ca85182eec9f3a09f6a6c0df6377a510d7", - "0x0000000000000000000000000000000000000000000000000000000000000039": "0x31206fa80a50bb6abe29085058f16212212a60eec8f049fecb92d8c8e0a84bc0", - "0x000000000000000000000000000000000000000000000000000000000000003a": "0x21352bfecbeddde993839f614c3dac0a3ee37543f9b412b16199dc158e23b544", - "0x000000000000000000000000000000000000000000000000000000000000003b": "0x619e312724bb6d7c3153ed9de791d764a366b389af13c58bf8a8d90481a46765", - "0x000000000000000000000000000000000000000000000000000000000000003c": "0x7cdd2986268250628d0c10e385c58c6191e6fbe05191bcc04f133f2cea72c1c4", - "0x000000000000000000000000000000000000000000000000000000000000003d": "0x848930bd7ba8cac54661072113fb278869e07bb8587f91392933374d017bcbe1", - "0x000000000000000000000000000000000000000000000000000000000000003e": "0x8869ff2c22b28cc10510d9853292803328be4fb0e80495e8bb8d271f5b889636", - "0x000000000000000000000000000000000000000000000000000000000000003f": "0xb5fe28e79f1b850f8658246ce9b6a1e7b49fc06db7143e8fe0b4f2b0c5523a5c", - "0x0000000000000000000000000000000000000000000000000000000000000040": "0x985e929f70af28d0bdd1a90a808f977f597c7c778c489e98d3bd8910d31ac0f7" - } - }, - "0xf97e180c050e5Ab072211Ad2C213Eb5AEE4DF134": { - "balance": "10000000000000000000000000" - }, - "0x2cA5F489CC1Fd1CEC24747B64E8dE0F4A6A850E1": { - "balance": "10000000000000000000000000" - }, - "0x7203bd333a874D9d329050ecE393820fCD501eaA": { - "balance": "10000000000000000000000000" - }, - "0xA51918aA40D78Ff8be939bf0E8404252875c6aDF": { - "balance": "10000000000000000000000000" - }, - "0xAA81078e6b2121dd7A846690DFdD6b10d7658d8B": { - "balance": "10000000000000000000000000" - }, - "0xFA2d31D8f21c1D1633E9BEB641dF77D21D63ccDd": { - "balance": "10000000000000000000000000" - }, - "0xf751C9c6d60614226fE57D2cAD6e10C856a2ddA3": { - "balance": "10000000000000000000000000" - }, - "0x9cD16887f6A808AEaa65D3c840f059EeA4ca1319": { - "balance": "10000000000000000000000000" - }, - "0x2E07043584F11BFF0AC39c927665DF6c6ebaffFB": { - "balance": "10000000000000000000000000" - }, - "0x60e771E5eCA8E26690920de669520Da210D64A9B": { - "balance": "10000000000000000000000000" - }, - "0xFC4db92C2Cf77CE02fBfd7Da0346d2CbFA66aD59": { - "balance": "10000000000000000000000000" - } - }, - "coinbase": "0x0000000000000000000000000000000000000000", - "difficulty": "0x01", - "extraData": "", - "gasLimit": "0x400000", - "nonce": "0x1234", - "mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000", - "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000", - "timestamp": "0" -} diff --git a/packages/blockchain/test/testdata/post-merge.json b/packages/blockchain/test/testdata/post-merge.json new file mode 100644 index 0000000000..32f5f093d3 --- /dev/null +++ b/packages/blockchain/test/testdata/post-merge.json @@ -0,0 +1,36 @@ +{ + "config": { + "chainId": 1, + "homesteadBlock": 0, + "eip150Block": 0, + "eip155Block": 0, + "eip158Block": 0, + "byzantiumBlock": 0, + "constantinopleBlock": 0, + "petersburgBlock": 0, + "istanbulBlock": 0, + "muirGlacierBlock": 0, + "berlinBlock": 0, + "londonBlock": 0, + "clique": { + "period": 5, + "epoch": 30000 + }, + "terminalTotalDifficulty": 0, + "terminalTotalDifficultyPassed": true + }, + "nonce": "0x42", + "timestamp": "0x0", + "extraData": "0x0000000000000000000000000000000000000000000000000000000000000000a94f5374fce5edbc8e2a8697c15331677e6ebf0b0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "gasLimit": "0x1C9C380", + "difficulty": "0x400000000", + "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000", + "coinbase": "0x0000000000000000000000000000000000000000", + "alloc": { + "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b": { "balance": "0x6d6172697573766477000000" } + }, + "number": "0x0", + "gasUsed": "0x0", + "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000", + "baseFeePerGas": "0x7" +} diff --git a/packages/blockchain/test/utils.spec.ts b/packages/blockchain/test/utils.spec.ts index 073dc314f9..846a5bcab2 100644 --- a/packages/blockchain/test/utils.spec.ts +++ b/packages/blockchain/test/utils.spec.ts @@ -3,10 +3,9 @@ import { genesisStateRoot } from '@ethereumjs/trie' import { bytesToHex, parseGethGenesisState } from '@ethereumjs/util' import { assert, describe, it } from 'vitest' -// kiln genesis with deposit contract storage set import { createBlockchain } from '../src/index.js' -import gethGenesisKilnJSON from './testdata/geth-genesis-kiln.json' +import gethGenesisJSON from './testdata/post-merge.json' import type { Blockchain } from '../src/blockchain.js' @@ -22,23 +21,23 @@ async function getBlockchain(gethGenesis: any): Promise { describe('[Utils/Parse]', () => { it('should properly parse genesis state from gethGenesis', async () => { - const genesisState = parseGethGenesisState(gethGenesisKilnJSON) + const genesisState = parseGethGenesisState(gethGenesisJSON) const stateRoot = await genesisStateRoot(genesisState) assert.equal( bytesToHex(stateRoot), - '0x52e628c7f35996ba5a0402d02b34535993c89ff7fc4c430b2763ada8554bee62', - 'kiln stateRoot matches', + '0xca3149fa9e37db08d1cd49c9061db1002ef1cd58db2210f2115c8c989b2bdf45', + 'stateRoot matches', ) }) it('should initialize blockchain from gethGenesis', async () => { - const blockchain = await getBlockchain(gethGenesisKilnJSON) + const blockchain = await getBlockchain(gethGenesisJSON) const genesisHash = blockchain.genesisBlock.hash() assert.equal( bytesToHex(genesisHash), - '0x51c7fe41be669f69c45c33a56982cbde405313342d9e2b00d7c91a7b284dd4f8', - 'kiln genesis hash matches', + '0x3b8fb240d288781d4aac94d3fd16809ee413bc99294a085798a589dae51ddd4a', + 'genesis hash matches', ) }) }) diff --git a/packages/client/bin/cli.ts b/packages/client/bin/cli.ts index 61637a4de7..4b2d1c1ba1 100755 --- a/packages/client/bin/cli.ts +++ b/packages/client/bin/cli.ts @@ -603,14 +603,9 @@ async function startExecutionFrom(client: EthereumClient) { const startExecutionBlock = await client.chain.getBlock(startExecutionFrom) const startExecutionParent = await client.chain.getBlock(startExecutionBlock.header.parentHash) - const startExecutionParentTd = await client.chain.getTd( - startExecutionParent.hash(), - startExecutionParent.header.number, - ) const startExecutionHardfork = client.config.execCommon.getHardforkBy({ blockNumber: startExecutionBlock.header.number, - td: startExecutionParentTd, timestamp: startExecutionBlock.header.timestamp, }) diff --git a/packages/client/src/blockchain/chain.ts b/packages/client/src/blockchain/chain.ts index cfe4ab01d0..cbc7ff253b 100644 --- a/packages/client/src/blockchain/chain.ts +++ b/packages/client/src/blockchain/chain.ts @@ -1,7 +1,7 @@ import { createBlockFromValuesArray, createHeaderFromValuesArray } from '@ethereumjs/block' import { CliqueConsensus, createBlockchain } from '@ethereumjs/blockchain' import { ConsensusAlgorithm, Hardfork } from '@ethereumjs/common' -import { BIGINT_0, BIGINT_1, equalsBytes } from '@ethereumjs/util' +import { BIGINT_0, equalsBytes } from '@ethereumjs/util' import { LevelDB } from '../execution/level.js' import { Event } from '../types.js' @@ -337,45 +337,11 @@ export class Chain { this._headers = headers this._blocks = blocks - const parentTd = await this.blockchain.getParentTD(headers.latest) this.config.chainCommon.setHardforkBy({ blockNumber: headers.latest.number, - td: parentTd, timestamp: headers.latest.timestamp, }) - // Check and log if this is a terminal block and next block could be merge - if (!this.config.chainCommon.gteHardfork(Hardfork.Paris)) { - const nextBlockHf = this.config.chainCommon.getHardforkBy({ - blockNumber: headers.height + BIGINT_1, - td: headers.td, - }) - if (this.config.chainCommon.hardforkGteHardfork(nextBlockHf, Hardfork.Paris)) { - this.config.logger.info('*'.repeat(85)) - this.config.logger.info( - `Paris (Merge) hardfork reached 🐼 👉 👈 🐼 ! block=${headers.height} td=${headers.td}`, - ) - this.config.logger.info('-'.repeat(85)) - this.config.logger.info(' ') - this.config.logger.info('Consensus layer client (CL) needed for continued sync:') - this.config.logger.info( - 'https://ethereum.org/en/developers/docs/nodes-and-clients/#consensus-clients', - ) - this.config.logger.info(' ') - this.config.logger.info( - 'Make sure to have the JSON RPC (--rpc) and Engine API (--rpcEngine) endpoints exposed', - ) - this.config.logger.info('and JWT authentication configured (see client README).') - this.config.logger.info(' ') - this.config.logger.info('*'.repeat(85)) - this.config.logger.info( - `Transitioning to PoS! First block for CL-framed execution: block=${ - headers.height + BIGINT_1 - }`, - ) - } - } - if (emit) { this.config.events.emit(Event.CHAIN_UPDATED) } @@ -444,11 +410,9 @@ export class Chain { break } - const td = await this.blockchain.getParentTD(b.header) if (b.header.number <= this.headers.height) { await this.blockchain.checkAndTransitionHardForkByNumber( b.header.number, - td, b.header.timestamp, ) await this.blockchain.consensus?.setup({ blockchain: this.blockchain }) @@ -456,7 +420,7 @@ export class Chain { const block = createBlockFromValuesArray(b.raw(), { common: this.config.chainCommon, - setHardfork: td, + setHardfork: true, }) await this.blockchain.putBlock(block) @@ -506,7 +470,7 @@ export class Chain { } const header = createHeaderFromValuesArray(h.raw(), { common: this.config.chainCommon, - setHardfork: this.headers.td, + setHardfork: true, }) await this.blockchain.putHeader(header) numAdded++ diff --git a/packages/client/src/execution/vmexecution.ts b/packages/client/src/execution/vmexecution.ts index f477f7c7b8..8b45786f67 100644 --- a/packages/client/src/execution/vmexecution.ts +++ b/packages/client/src/execution/vmexecution.ts @@ -268,8 +268,7 @@ export class VMExecution extends Execution { if (typeof blockchain.getTotalDifficulty !== 'function') { throw new Error('cannot get iterator head: blockchain has no getTotalDifficulty function') } - const td = await blockchain.getTotalDifficulty(headBlock.header.hash()) - this.config.execCommon.setHardforkBy({ blockNumber: number, td, timestamp }) + this.config.execCommon.setHardforkBy({ blockNumber: number, timestamp }) this.hardfork = this.config.execCommon.hardfork() if (this.config.execCommon.gteHardfork(Hardfork.Osaka)) { @@ -328,13 +327,8 @@ export class VMExecution extends Execution { // there could to be checks here that the resetted head is a parent of the chainStatus // but we can skip it for now trusting the chain reset has been correctly performed - const td = - headBlock.header.number === BIGINT_0 - ? headBlock.header.difficulty - : await this.chain.blockchain.getTotalDifficulty(headBlock.header.parentHash) this.hardfork = this.config.execCommon.setHardforkBy({ blockNumber: number, - td, timestamp, }) if (this.config.execCommon.gteHardfork(Hardfork.Osaka)) { @@ -387,21 +381,8 @@ export class VMExecution extends Execution { const parentState = root ?? prevVMStateRoot const clearCache = !equalsBytes(prevVMStateRoot, parentState) - // merge TTD might not give correct td, but its sufficient for purposes of determining HF and allows - // stateless execution where blockchain mightnot have all the blocks filling upto the block - let td - if (block.common.gteHardfork(Hardfork.Paris)) { - td = this.config.chainCommon.hardforkTTD(Hardfork.Paris) - if (td === null) { - throw Error(`Invalid null paris TTD for the chain`) - } - } else { - td = await this.chain.getTd(block.header.parentHash, block.header.number - BIGINT_1) - } - const hardfork = this.config.execCommon.getHardforkBy({ blockNumber: block.header.number, - td, timestamp: block.header.timestamp, }) @@ -413,10 +394,8 @@ export class VMExecution extends Execution { // see if this is a transition block const parentBlock = opts?.parentBlock ?? (await this.chain.getBlock(block.header.parentHash)) - const parentTd = td - parentBlock.header.difficulty const parentHf = this.config.execCommon.getHardforkBy({ blockNumber: parentBlock.header.number, - td: parentTd, timestamp: parentBlock.header.timestamp, }) @@ -557,13 +536,8 @@ export class VMExecution extends Execution { status: ExecStatus.VALID, } - const td = await this.chain.getTd( - vmHeadBlock.header.parentHash, - vmHeadBlock.header.number - BIGINT_1, - ) const hardfork = this.config.execCommon.setHardforkBy({ blockNumber: vmHeadBlock.header.number, - td, timestamp: vmHeadBlock.header.timestamp, }) if ( @@ -687,11 +661,9 @@ export class VMExecution extends Execution { 'cannot get iterator head: blockchain has no getTotalDifficulty function', ) } - const td = await blockchain.getTotalDifficulty(block.header.parentHash) const hardfork = this.config.execCommon.getHardforkBy({ blockNumber: number, - td, timestamp, }) if (hardfork !== this.hardfork) { @@ -702,7 +674,6 @@ export class VMExecution extends Execution { ) this.hardfork = this.config.execCommon.setHardforkBy({ blockNumber: number, - td, timestamp, }) const isPostOsaka = this.config.execCommon.gteHardfork(Hardfork.Osaka) @@ -1006,12 +977,8 @@ export class VMExecution extends Execution { this.config.logger.info('Preparing for block execution (debug mode, no services started)...') const block = await this.vm.blockchain.getBlock(first) - const parentBlock = await this.vm.blockchain.getBlock(block.header.parentHash) - const startExecutionParentTd = await this.chain.getTd(block.hash(), parentBlock.header.number) - const startExecutionHardfork = this.config.execCommon.getHardforkBy({ blockNumber: block.header.number, - td: startExecutionParentTd, timestamp: block.header.timestamp, }) @@ -1032,10 +999,8 @@ export class VMExecution extends Execution { if (typeof vm.blockchain.getTotalDifficulty !== 'function') { throw new Error('cannot get iterator head: blockchain has no getTotalDifficulty function') } - const td = await vm.blockchain.getTotalDifficulty(block.header.parentHash) vm.common.setHardforkBy({ blockNumber, - td, timestamp: block.header.timestamp, }) diff --git a/packages/client/src/miner/miner.ts b/packages/client/src/miner/miner.ts index 9d6437818a..d337edf29b 100644 --- a/packages/client/src/miner/miner.ts +++ b/packages/client/src/miner/miner.ts @@ -90,7 +90,6 @@ export class Miner { // Check if the new block to be minted isn't PoS const nextBlockHf = this.config.chainCommon.getHardforkBy({ blockNumber: this.service.chain.headers.height + BIGINT_1, - td: this.service.chain.headers.td, }) if (this.config.chainCommon.hardforkGteHardfork(nextBlockHf, Hardfork.Paris)) { this.config.logger.info('Miner: reached merge hardfork - stopping') diff --git a/packages/client/src/miner/pendingBlock.ts b/packages/client/src/miner/pendingBlock.ts index dfb58fad31..8b586f4133 100644 --- a/packages/client/src/miner/pendingBlock.ts +++ b/packages/client/src/miner/pendingBlock.ts @@ -107,10 +107,8 @@ export class PendingBlock { if (typeof vm.blockchain.getTotalDifficulty !== 'function') { throw new Error('cannot get iterator head: blockchain has no getTotalDifficulty function') } - const td = await vm.blockchain.getTotalDifficulty(parentBlock.hash()) vm.common.setHardforkBy({ blockNumber: number, - td, timestamp, }) @@ -189,7 +187,7 @@ export class PendingBlock { withdrawals, blockOpts: { putBlockIntoBlockchain: false, - setHardfork: td, + setHardfork: true, }, }) diff --git a/packages/client/src/net/protocol/ethprotocol.ts b/packages/client/src/net/protocol/ethprotocol.ts index c79ccb6144..d5b2c96144 100644 --- a/packages/client/src/net/protocol/ethprotocol.ts +++ b/packages/client/src/net/protocol/ethprotocol.ts @@ -1,10 +1,4 @@ -import { - createBlockFromValuesArray, - createHeaderFromValuesArray, - getDifficulty, - valuesArrayToHeaderData, -} from '@ethereumjs/block' -import { Hardfork } from '@ethereumjs/common' +import { createBlockFromValuesArray, createHeaderFromValuesArray } from '@ethereumjs/block' import { RLP } from '@ethereumjs/rlp' import { BlobEIP4844Transaction, @@ -43,7 +37,7 @@ import type { } from '@ethereumjs/block' import type { Log } from '@ethereumjs/evm' import type { TypedTransaction } from '@ethereumjs/tx' -import type { BigIntLike, PrefixedHexString } from '@ethereumjs/util' +import type { PrefixedHexString } from '@ethereumjs/util' import type { PostByzantiumTxReceipt, PreByzantiumTxReceipt, TxReceipt } from '@ethereumjs/vm' interface EthProtocolOptions extends ProtocolOptions { @@ -107,7 +101,6 @@ function exhaustiveTypeGuard(_value: never, errorMsg: string): never { export class EthProtocol extends Protocol { private chain: Chain private nextReqId = BIGINT_0 - private chainTTD?: BigIntLike /* eslint-disable no-invalid-this */ private protocolMessages: Message[] = [ @@ -174,15 +167,8 @@ export class EthProtocol extends Protocol { decode: ([reqId, headers]: [Uint8Array, BlockHeaderBytes[]]) => [ bytesToBigInt(reqId), headers.map((h) => { - const headerData = valuesArrayToHeaderData(h) - const difficulty = getDifficulty(headerData)! const common = this.config.chainCommon - // If this is a post merge block, we can still send chainTTD since it would still lead - // to correct hardfork choice - const header = createHeaderFromValuesArray( - h, - difficulty > 0 ? { common, setHardfork: true } : { common, setHardfork: this.chainTTD }, - ) + const header = createHeaderFromValuesArray(h, { common, setHardfork: true }) return header }), ], @@ -368,10 +354,6 @@ export class EthProtocol extends Protocol { super(options) this.chain = options.chain - const chainTTD = this.config.chainCommon.hardforkTTD(Hardfork.Paris) - if (chainTTD !== null && chainTTD !== undefined) { - this.chainTTD = chainTTD - } } /** diff --git a/packages/client/src/rpc/modules/engine/engine.ts b/packages/client/src/rpc/modules/engine/engine.ts index 7eddb70f0c..e99c5e450a 100644 --- a/packages/client/src/rpc/modules/engine/engine.ts +++ b/packages/client/src/rpc/modules/engine/engine.ts @@ -1,6 +1,5 @@ import { Hardfork } from '@ethereumjs/common' import { - BIGINT_0, BIGINT_1, bytesToHex, bytesToUnprefixedHex, @@ -36,7 +35,6 @@ import { validHash, validate4844BlobVersionedHashes, validateHardforkRange, - validateTerminalBlock, } from './util/index.js' import { executionPayloadV1FieldValidators, @@ -68,7 +66,6 @@ import type { PayloadAttributesV1, PayloadAttributesV2, PayloadAttributesV3, - TransitionConfigurationV1, } from './types.js' import type { Block, ExecutionPayload } from '@ethereumjs/block' import type { PrefixedHexString } from '@ethereumjs/util' @@ -292,26 +289,6 @@ export class Engine { () => this.connectionManager.updateStatus(), ) - /** - * exchangeTransitionConfiguration - */ - this.exchangeTransitionConfigurationV1 = cmMiddleware( - middleware( - callWithStackTrace(this.exchangeTransitionConfigurationV1.bind(this), this._rpcDebug), - 1, - [ - [ - validators.object({ - terminalTotalDifficulty: validators.uint256, - terminalBlockHash: validators.bytes32, - terminalBlockNumber: validators.uint64, - }), - ], - ], - ), - () => this.connectionManager.updateStatus(), - ) - /** * exchangeCapabilities */ @@ -463,23 +440,6 @@ export class Engine { this.remoteBlocks.get(parentHash.slice(2)) ?? (await this.chain.getBlock(hexToBytes(parentHash as PrefixedHexString))) - // Validations with parent - if (!parent.common.gteHardfork(Hardfork.Paris)) { - const validTerminalBlock = await validateTerminalBlock(parent, this.chain) - if (!validTerminalBlock) { - const response = { - status: Status.INVALID, - validationError: null, - latestValidHash: bytesToHex(zeros(32)), - } - this.invalidBlocks.set( - blockHash.slice(2), - new Error(response.validationError ?? 'Terminal block validation failed'), - ) - return response - } - } - /** * validate 4844 transactions and fields as these validations generally happen on putBlocks * when parent is confirmed to be in the chain. But we can do it here early @@ -701,7 +661,7 @@ export class Engine { const blockExecuted = await this.execution.runWithoutSetHead({ block, root: blockParent.header.stateRoot, - setHardfork: this.chain.headers.td, + setHardfork: true, parentBlock: blockParent, }) return blockExecuted @@ -1032,27 +992,6 @@ export class Engine { if (reorged) await this.service.beaconSync?.reorged(headBlock) - /** - * Terminal block validation - */ - // Only validate this as terminal block if this block's difficulty is non-zero, - // else this is a PoS block but its hardfork could be indeterminable if the skeleton - // is not yet connected. - if (!headBlock.common.gteHardfork(Hardfork.Paris) && headBlock.header.difficulty > BIGINT_0) { - const validTerminalBlock = await validateTerminalBlock(headBlock, this.chain) - if (!validTerminalBlock) { - const response = { - payloadStatus: { - status: Status.INVALID, - validationError: 'Invalid terminal block', - latestValidHash: bytesToHex(zeros(32)), - }, - payloadId: null, - } - return response - } - } - /** * Check execution status */ @@ -1485,41 +1424,6 @@ export class Engine { async getPayloadV4(params: [Bytes8]) { return this.getPayload(params, 4) } - /** - * Compare transition configuration parameters. - * - * V1 (Paris HF), see: - * https://github.com/ethereum/execution-apis/blob/main/src/engine/paris.md#engine_exchangetransitionconfigurationv1 - * - * Note: This method is deprecated starting with the Cancun HF - * - * @param params An array of one parameter: - * 1. transitionConfiguration: Object - instance of {@link TransitionConfigurationV1} - * @returns Instance of {@link TransitionConfigurationV1} or an error - */ - async exchangeTransitionConfigurationV1( - params: [TransitionConfigurationV1], - ): Promise { - const { terminalTotalDifficulty, terminalBlockHash, terminalBlockNumber } = params[0] - const ttd = this.chain.config.chainCommon.hardforkTTD(Hardfork.Paris) - if (ttd === undefined || ttd === null) { - throw { - code: INTERNAL_ERROR, - message: 'terminalTotalDifficulty not set internally', - } - } - if (ttd !== BigInt(terminalTotalDifficulty)) { - throw { - code: INVALID_PARAMS, - message: `terminalTotalDifficulty set to ${ttd}, received ${parseInt( - terminalTotalDifficulty, - )}`, - } - } - // Note: our client does not yet support block whitelisting (terminalBlockHash/terminalBlockNumber) - // since we are not yet fast enough to run along tip-of-chain mainnet execution - return { terminalTotalDifficulty, terminalBlockHash, terminalBlockNumber } - } /** * Returns a list of engine API endpoints supported by the client diff --git a/packages/client/src/rpc/modules/engine/types.ts b/packages/client/src/rpc/modules/engine/types.ts index c8be49cef5..bfab9b9750 100644 --- a/packages/client/src/rpc/modules/engine/types.ts +++ b/packages/client/src/rpc/modules/engine/types.ts @@ -70,12 +70,6 @@ export type ForkchoiceResponseV1 = { payloadId: Bytes8 | null } -export type TransitionConfigurationV1 = { - terminalTotalDifficulty: Uint256 - terminalBlockHash: Bytes32 - terminalBlockNumber: Uint64 -} - export type BlobsBundleV1 = { commitments: Bytes48[] blobs: Blob[] diff --git a/packages/client/src/rpc/modules/engine/util/generic.ts b/packages/client/src/rpc/modules/engine/util/generic.ts index 618e06434d..ad231ea6dc 100644 --- a/packages/client/src/rpc/modules/engine/util/generic.ts +++ b/packages/client/src/rpc/modules/engine/util/generic.ts @@ -1,12 +1,11 @@ import { Block } from '@ethereumjs/block' -import { Hardfork } from '@ethereumjs/common' -import { BIGINT_1, bytesToHex, bytesToUnprefixedHex, equalsBytes } from '@ethereumjs/util' +import { bytesToHex, bytesToUnprefixedHex, equalsBytes } from '@ethereumjs/util' import { UNSUPPORTED_FORK } from '../../../error-code.js' import { type ChainCache } from '../types.js' import type { Chain } from '../../../../blockchain/index.js' -import type { Common } from '@ethereumjs/common' +import type { Common, Hardfork } from '@ethereumjs/common' import type { PrefixedHexString } from '@ethereumjs/util' /** @@ -115,22 +114,6 @@ export const validHash = async ( return null } -/** - * Validates that the block satisfies post-merge conditions. - */ -export const validateTerminalBlock = async (block: Block, chain: Chain): Promise => { - const ttd = chain.config.chainCommon.hardforkTTD(Hardfork.Paris) - if (ttd === null) return false - const blockTd = await chain.getTd(block.hash(), block.header.number) - - // Block is terminal if its td >= ttd and its parent td < ttd. - // In case the Genesis block has td >= ttd it is the terminal block - if (block.isGenesis()) return blockTd >= ttd - - const parentBlockTd = await chain.getTd(block.header.parentHash, block.header.number - BIGINT_1) - return blockTd >= ttd && parentBlockTd < ttd -} - export function validateHardforkRange( chainCommon: Common, methodVersion: number, diff --git a/packages/client/src/rpc/modules/engine/util/newPayload.ts b/packages/client/src/rpc/modules/engine/util/newPayload.ts index efe07b16c4..05264f2526 100644 --- a/packages/client/src/rpc/modules/engine/util/newPayload.ts +++ b/packages/client/src/rpc/modules/engine/util/newPayload.ts @@ -1,5 +1,4 @@ import { createBlockFromExecutionPayload } from '@ethereumjs/block' -import { Hardfork } from '@ethereumjs/common' import { BlobEIP4844Transaction } from '@ethereumjs/tx' import { equalsBytes, hexToBytes } from '@ethereumjs/util' @@ -26,11 +25,7 @@ export const assembleBlock = async ( const { config } = chain const common = config.chainCommon.copy() - // This is a post merge block, so set its common accordingly - // Can't use setHardfork flag, as the transactions will need to be deserialized - // first before the header can be constucted with their roots - const ttd = common.hardforkTTD(Hardfork.Paris) - common.setHardforkBy({ blockNumber, td: ttd !== null ? ttd : undefined, timestamp }) + common.setHardforkBy({ blockNumber, timestamp }) try { const block = await createBlockFromExecutionPayload(payload, { common }) diff --git a/packages/client/src/sync/beaconsync.ts b/packages/client/src/sync/beaconsync.ts index 372764b640..f419b698b1 100644 --- a/packages/client/src/sync/beaconsync.ts +++ b/packages/client/src/sync/beaconsync.ts @@ -77,7 +77,7 @@ export class BeaconSynchronizer extends Synchronizer { const hash = this.chain.blocks.latest!.hash() this.startingBlock = number const timestamp = this.chain.blocks.latest?.header.timestamp - this.config.chainCommon.setHardforkBy({ blockNumber: number, td, timestamp }) + this.config.chainCommon.setHardforkBy({ blockNumber: number, timestamp }) this.config.logger.info( `Latest local block number=${Number(number)} td=${td} hash=${bytesToHex( diff --git a/packages/client/src/sync/fullsync.ts b/packages/client/src/sync/fullsync.ts index 4f7f5051a5..e08ef25e5c 100644 --- a/packages/client/src/sync/fullsync.ts +++ b/packages/client/src/sync/fullsync.ts @@ -100,7 +100,7 @@ export class FullSynchronizer extends Synchronizer { const hash = this.chain.blocks.latest!.hash() this.startingBlock = number const timestamp = this.chain.blocks.latest?.header.timestamp - this.config.chainCommon.setHardforkBy({ blockNumber: number, td, timestamp }) + this.config.chainCommon.setHardforkBy({ blockNumber: number, timestamp }) this.config.logger.info( `Latest local block number=${Number(number)} td=${td} hash=${short( @@ -240,18 +240,6 @@ export class FullSynchronizer extends Synchronizer { const nextHF = this.config.chainCommon.getHardforkBy({ blockNumber: nextHFBlockNum }) attentionHF = `${nextHF} HF in ${remaining} blocks` } - } else { - if ( - this.config.chainCommon.hardfork() === Hardfork.MergeForkIdTransition && - !this.config.chainCommon.gteHardfork(Hardfork.Paris) - ) { - const mergeTTD = this.config.chainCommon.hardforkTTD(Hardfork.Paris)! - const td = this.chain.blocks.td - const remaining = mergeTTD - td - if (remaining <= mergeTTD / BigInt(10)) { - attentionHF = `Paris (Merge) HF in ${remaining} TD` - } - } } this.config.logger.info( diff --git a/packages/client/test/integration/merge.spec.ts b/packages/client/test/integration/merge.spec.ts deleted file mode 100644 index 782ac0a9ac..0000000000 --- a/packages/client/test/integration/merge.spec.ts +++ /dev/null @@ -1,190 +0,0 @@ -import { BlockHeader } from '@ethereumjs/block' -import { CliqueConsensus, EthashConsensus, createBlockchain } from '@ethereumjs/blockchain' -import { - ConsensusAlgorithm, - ConsensusType, - Goerli, - Hardfork, - Mainnet, - createCustomCommon, -} from '@ethereumjs/common' -import { Ethash } from '@ethereumjs/ethash' -import { Address, hexToBytes } from '@ethereumjs/util' -import { assert, describe, it } from 'vitest' - -import { Chain } from '../../src/blockchain/index.js' -import { Config } from '../../src/config.js' -import { FullEthereumService } from '../../src/service/index.js' -import { Event } from '../../src/types.js' - -import { MockServer } from './mocks/mockserver.js' -import { destroy, setup } from './util.js' - -import type { ConsensusDict } from '@ethereumjs/blockchain' -import type { Common } from '@ethereumjs/common' - -const commonPoA = createCustomCommon( - { - consensus: { - type: ConsensusType.ProofOfAuthority, - algorithm: ConsensusAlgorithm.Clique, - clique: { - period: 1, // use 1s period for quicker test execution - epoch: 30000, - }, - }, - hardforks: [ - { name: 'chainstart', block: 0 }, - { name: 'london', block: 0 }, - { - name: 'paris', - block: null, - forkHash: null, - ttd: BigInt(5), - }, - ], - }, - Goerli, - { hardfork: Hardfork.London }, -) -const commonPoW = createCustomCommon( - { - genesis: { - gasLimit: 16777216, - difficulty: 1, - nonce: '0x0000000000000042', - extraData: '0x3535353535353535353535353535353535353535353535353535353535353535', - }, - hardforks: [ - { name: 'chainstart', block: 0 }, - { name: 'london', block: 0 }, - { - name: 'paris', - block: null, - forkHash: null, - ttd: BigInt(1000), - }, - ], - }, - Mainnet, - { hardfork: Hardfork.London }, -) -const accounts: [Address, Uint8Array][] = [ - [ - new Address(hexToBytes('0x0b90087d864e82a284dca15923f3776de6bb016f')), - hexToBytes('0x64bf9cc30328b0e42387b3c82c614e6386259136235e20c1357bd11cdee86993'), - ], -] -async function minerSetup(common: Common): Promise<[MockServer, FullEthereumService]> { - const config = new Config({ common, accountCache: 10000, storageCache: 1000 }) - const server = new MockServer({ config }) as any - const consensusDict: ConsensusDict = {} - consensusDict[ConsensusAlgorithm.Clique] = new CliqueConsensus() - consensusDict[ConsensusAlgorithm.Ethash] = new EthashConsensus(new Ethash()) - const blockchain = await createBlockchain({ - common, - validateBlocks: false, - validateConsensus: false, - consensusDict, - }) - ;(blockchain.consensus as CliqueConsensus).cliqueActiveSigners = () => [accounts[0][0]] // stub - const serviceConfig = new Config({ - common, - server, - mine: true, - accounts, - }) - const chain = await Chain.create({ config: serviceConfig, blockchain }) - // attach server to centralized event bus - ;(server.config as any).events = serviceConfig.events - const service = new FullEthereumService({ - config: serviceConfig, - chain, - }) - await service.open() - await server.start() - await service.start() - return [server, service] -} - -describe('should mine and stop at the merge (PoA)', async () => { - const [server, service] = await minerSetup(commonPoA) - const [remoteServer, remoteService] = await setup({ - location: '127.0.0.2', - height: 0, - common: commonPoA, - }) - ;(remoteService.chain.blockchain.consensus as CliqueConsensus).cliqueActiveSigners = () => [ - accounts[0][0], - ] // stub - BlockHeader.prototype['_consensusFormatValidation'] = () => {} //stub - await server.discover('remotePeer1', '127.0.0.2') - const targetTTD = BigInt(5) - const _td: Promise = new Promise((resolve) => { - remoteService.config.events.on(Event.SYNC_SYNCHRONIZED, async () => { - resolve(remoteService.chain.headers.td) - }) - }) - await remoteService.synchronizer!.start() - const td: bigint = await _td - it('should sync', async () => { - if (td === targetTTD) { - assert.equal( - remoteService.chain.headers.td, - targetTTD, - 'synced blocks to the merge successfully', - ) - // Make sure the miner has stopped - assert.notOk(service.miner!.running, 'miner should not be running') - } - if (td > targetTTD) { - assert.fail('chain should not exceed merge TTD') - } - assert.ok('synced') - }) - await destroy(server, service) - await destroy(remoteServer, remoteService) -}, 60000) - -describe('should mine and stop at the merge (PoW)', async () => { - const [server, service] = await minerSetup(commonPoW) - const [remoteServer, remoteService] = await setup({ - location: '127.0.0.2', - height: 0, - common: commonPoW, - }) - await server.discover('remotePeer1', '127.0.0.2') - const targetTTD = BigInt(1000) - let terminalHeight: bigint | undefined - const res: Promise<{ height: bigint; td: bigint }> = new Promise((resolve) => { - remoteService.config.events.on(Event.CHAIN_UPDATED, async () => { - const { height, td } = remoteService.chain.headers - resolve({ height, td }) - }) - }) - await remoteService.synchronizer!.start() - const { height, td } = await res - it('should sync', async () => { - if (td > targetTTD) { - if (terminalHeight === undefined || terminalHeight === BigInt(0)) { - terminalHeight = height - } - assert.equal( - remoteService.chain.headers.height, - terminalHeight, - 'synced blocks to the merge successfully', - ) - // Make sure the miner has stopped - assert.notOk(service.miner!.running, 'miner should not be running') - await destroy(server, service) - await destroy(remoteServer, remoteService) - } - if ( - typeof terminalHeight === 'bigint' && - terminalHeight !== BigInt(0) && - terminalHeight < height - ) { - assert.fail('chain should not exceed merge terminal block') - } - }) -}, 120000) diff --git a/packages/client/test/rpc/engine/exchangeTransitionConfigurationV1.spec.ts b/packages/client/test/rpc/engine/exchangeTransitionConfigurationV1.spec.ts deleted file mode 100644 index ba87b658b5..0000000000 --- a/packages/client/test/rpc/engine/exchangeTransitionConfigurationV1.spec.ts +++ /dev/null @@ -1,36 +0,0 @@ -import { assert, describe, it } from 'vitest' - -import { INVALID_PARAMS } from '../../../src/rpc/error-code.js' -import genesisJSON from '../../testdata/geth-genesis/post-merge.json' -import { getRpcClient, setupChain } from '../helpers.js' - -const method = 'engine_exchangeTransitionConfigurationV1' - -const validConfig = { - terminalTotalDifficulty: '0x0', - terminalBlockHash: '0x1d93f244823f80efbd9292a0d0d72a2b03df8cd5a9688c6c3779d26a7cc5009c', - terminalBlockNumber: '0x0', -} - -const invalidConfig = { - terminalTotalDifficulty: '0x100', - terminalBlockHash: '0x1d93f244823f80efbd9292a0d0d72a2b03df8cd5a9688c6c3779d26a7cc5009c', - terminalBlockNumber: '0x0', -} - -describe(method, () => { - it('call with valid config', async () => { - const { server } = await setupChain(genesisJSON, 'post-merge', { engine: true }) - const rpc = getRpcClient(server) - const res = await rpc.request(method, [validConfig]) - assert.deepEqual(res.result, validConfig) - }) - - it('call with invalid config', async () => { - const { server } = await setupChain(genesisJSON, 'post-merge', { engine: true }) - const rpc = getRpcClient(server) - const res = await rpc.request(method, [invalidConfig]) - assert.equal(res.error.code, INVALID_PARAMS) - assert.ok(res.error.message.includes('terminalTotalDifficulty set to 0, received 256')) - }) -}) diff --git a/packages/client/test/rpc/engine/forkchoiceUpdatedV1.spec.ts b/packages/client/test/rpc/engine/forkchoiceUpdatedV1.spec.ts index 6110de757a..3fe206b853 100644 --- a/packages/client/test/rpc/engine/forkchoiceUpdatedV1.spec.ts +++ b/packages/client/test/rpc/engine/forkchoiceUpdatedV1.spec.ts @@ -1,6 +1,6 @@ import { BlockHeader, createBlock } from '@ethereumjs/block' import { Common, Hardfork, Mainnet } from '@ethereumjs/common' -import { bytesToHex, randomBytes, zeros } from '@ethereumjs/util' +import { bytesToHex, randomBytes } from '@ethereumjs/util' import { assert, describe, it, vi } from 'vitest' import { INVALID_PARAMS } from '../../../src/rpc/error-code.js' @@ -9,7 +9,7 @@ import blocks from '../../testdata/blocks/beacon.json' import genesisJSON from '../../testdata/geth-genesis/post-merge.json' import { baseSetup, batchBlocks, getRpcClient, setupChain } from '../helpers.js' -import type { Block, BlockData } from '@ethereumjs/block' +import type { Block } from '@ethereumjs/block' const method = 'engine_forkchoiceUpdatedV1' @@ -133,66 +133,6 @@ describe(method, () => { assert.equal(res.result.payloadId, null) }) - it('invalid terminal block with only genesis block', async () => { - const genesisWithHigherTtd = { - ...genesisJSON, - config: { - ...genesisJSON.config, - terminalTotalDifficulty: 17179869185, - }, - } - - const { server } = await setupChain(genesisWithHigherTtd, 'post-merge', { - engine: true, - }) - const rpc = getRpcClient(server) - const res = await rpc.request(method, [validForkChoiceState, null]) - assert.equal(res.result.payloadStatus.status, 'INVALID') - assert.equal(res.result.payloadStatus.latestValidHash, bytesToHex(zeros(32))) - }) - - it('invalid terminal block with 1+ blocks', async () => { - const genesisWithHigherTtd = { - ...genesisJSON, - config: { - ...genesisJSON.config, - terminalTotalDifficulty: 17179869185, - clique: undefined, - ethash: {}, - }, - } - - const { server, chain, common } = await setupChain(genesisWithHigherTtd, 'post-merge', { - engine: true, - }) - const rpc = getRpcClient(server) - const newBlock = createBlock( - { - header: { - number: blocks[0].blockNumber, - parentHash: blocks[0].parentHash, - difficulty: 1, - extraData: new Uint8Array(97), - }, - } as BlockData, - { common, skipConsensusFormatValidation: true }, - ) - - await chain.putBlocks([newBlock]) - const newBlockHashHex = bytesToHex(newBlock.hash()) - const res = await rpc.request(method, [ - { - safeBlockHash: newBlockHashHex, - finalizedBlockHash: newBlockHashHex, - headBlockHash: newBlockHashHex, - }, - null, - ]) - - assert.equal(res.result.payloadStatus.status, 'INVALID') - assert.equal(res.result.payloadStatus.latestValidHash, bytesToHex(zeros(32))) - }) - it('call with deep parent lookup', async () => { const { server } = await setupChain(genesisJSON, 'post-merge', { engine: true }) const rpc = getRpcClient(server) diff --git a/packages/client/test/rpc/engine/newPayloadV1.spec.ts b/packages/client/test/rpc/engine/newPayloadV1.spec.ts index 6a9402859e..55e123db01 100644 --- a/packages/client/test/rpc/engine/newPayloadV1.spec.ts +++ b/packages/client/test/rpc/engine/newPayloadV1.spec.ts @@ -1,13 +1,11 @@ -import { BlockHeader } from '@ethereumjs/block' import { create1559FeeMarketTx } from '@ethereumjs/tx' import { bytesToHex, createAddressFromPrivateKey, createAddressFromString, hexToBytes, - zeros, } from '@ethereumjs/util' -import { assert, describe, it, vi } from 'vitest' +import { assert, describe, it } from 'vitest' import { INVALID_PARAMS } from '../../../src/rpc/error-code.js' import blocks from '../../testdata/blocks/beacon.json' @@ -105,28 +103,6 @@ describe(method, () => { assert.equal(res.result.status, 'VALID') }) - it('invalid terminal block', async () => { - const genesisWithHigherTtd = { - ...genesisJSON, - config: { - ...genesisJSON.config, - terminalTotalDifficulty: 17179869185, - }, - } - - BlockHeader.prototype['_consensusFormatValidation'] = vi.fn() - vi.doMock('@ethereumjs/block', () => BlockHeader) - - const { server } = await setupChain(genesisWithHigherTtd, 'post-merge', { - engine: true, - }) - const rpc = getRpcClient(server) - const res = await rpc.request(method, [blockData, null]) - - assert.equal(res.result.status, 'INVALID') - assert.equal(res.result.latestValidHash, bytesToHex(zeros(32))) - }) - it('call with valid data', async () => { const { server } = await setupChain(genesisJSON, 'post-merge', { engine: true }) const rpc = getRpcClient(server) diff --git a/packages/client/test/rpc/engine/newPayloadV2.spec.ts b/packages/client/test/rpc/engine/newPayloadV2.spec.ts index 98ea103f73..68f5b916ea 100644 --- a/packages/client/test/rpc/engine/newPayloadV2.spec.ts +++ b/packages/client/test/rpc/engine/newPayloadV2.spec.ts @@ -1,13 +1,11 @@ -import { BlockHeader } from '@ethereumjs/block' import { create1559FeeMarketTx } from '@ethereumjs/tx' import { bytesToHex, createAddressFromPrivateKey, createAddressFromString, hexToBytes, - zeros, } from '@ethereumjs/util' -import { assert, describe, it, vi } from 'vitest' +import { assert, describe, it } from 'vitest' import { INVALID_PARAMS } from '../../../src/rpc/error-code.js' import blocks from '../../testdata/blocks/beacon.json' @@ -104,28 +102,6 @@ describe(`${method}: call with executionPayloadV1`, () => { assert.equal(res.result.status, 'VALID') }) - it('invalid terminal block', async () => { - const genesisWithHigherTtd = { - ...genesisJSON, - config: { - ...genesisJSON.config, - terminalTotalDifficulty: 17179869185, - }, - } - - ;(BlockHeader as any).prototype._consensusFormatValidation = vi.fn() - vi.doMock('@ethereumjs/block', () => BlockHeader) - - const { server } = await setupChain(genesisWithHigherTtd, 'post-merge', { - engine: true, - }) - const rpc = getRpcClient(server) - const res = await rpc.request(method, [blockData, null]) - - assert.equal(res.result.status, 'INVALID') - assert.equal(res.result.latestValidHash, bytesToHex(zeros(32))) - }) - it('call with valid data', async () => { const { server } = await setupChain(genesisJSON, 'post-merge', { engine: true }) const rpc = getRpcClient(server) diff --git a/packages/client/test/rpc/engine/newPayloadV4.spec.ts b/packages/client/test/rpc/engine/newPayloadV4.spec.ts index a46038ebd4..f1b1b39890 100644 --- a/packages/client/test/rpc/engine/newPayloadV4.spec.ts +++ b/packages/client/test/rpc/engine/newPayloadV4.spec.ts @@ -45,7 +45,7 @@ function readyPragueGenesis(genesisJSON: any) { describe(`${method}: call with executionPayloadV4`, () => { it('valid data', async () => { - // get the genesis json with late enougt date with respect to block data in batchBlocks + // get the genesis json with late enough date with respect to block data in batchBlocks const { pragueJson, pragueTime } = readyPragueGenesis(genesisJSON) const { service, server } = await setupChain(pragueJson, 'post-merge', { engine: true }) diff --git a/packages/client/test/rpc/helpers.ts b/packages/client/test/rpc/helpers.ts index 116e6a88dd..453f7c3aca 100644 --- a/packages/client/test/rpc/helpers.ts +++ b/packages/client/test/rpc/helpers.ts @@ -237,7 +237,6 @@ export async function setupChain(genesisFile: any, chainName = 'dev', clientOpts }) common.setHardforkBy({ blockNumber: 0, - td: genesisParams.genesis.difficulty, timestamp: genesisParams.genesis.timestamp, }) diff --git a/packages/client/test/sim/configs/4844-devnet.json b/packages/client/test/sim/configs/4844-devnet.json index 4287403d32..8018d91428 100644 --- a/packages/client/test/sim/configs/4844-devnet.json +++ b/packages/client/test/sim/configs/4844-devnet.json @@ -20,7 +20,7 @@ "period": 5, "epoch": 30000 }, - "terminalTotalDifficulty": 1, + "terminalTotalDifficulty": 0, "terminalTotalDifficultyPassed": true }, "nonce": "0x42", diff --git a/packages/client/test/sim/configs/eof.json b/packages/client/test/sim/configs/eof.json index 874d6faa21..01bd405e7d 100644 --- a/packages/client/test/sim/configs/eof.json +++ b/packages/client/test/sim/configs/eof.json @@ -13,7 +13,8 @@ "londonBlock": 0, "mergeForkBlock": 0, "eofBlock": 0, - "terminalTotalDifficulty": 1 + "terminalTotalDifficulty": 0, + "terminalTotalDifficultyPassed": true }, "alloc": { "0x0000000000000000000000000000000000000000": { diff --git a/packages/client/test/sim/configs/mainnet.json b/packages/client/test/sim/configs/mainnet.json index 321a864e18..33825ee061 100644 --- a/packages/client/test/sim/configs/mainnet.json +++ b/packages/client/test/sim/configs/mainnet.json @@ -13,7 +13,7 @@ "londonBlock": 0, "mergeForkBlock": 0, "shanghaiTime": 0, - "terminalTotalDifficulty": 1, + "terminalTotalDifficulty": 0, "terminalTotalDifficultyPassed": true }, "alloc": { diff --git a/packages/client/test/sync/fetcher/blockfetcher.spec.ts b/packages/client/test/sync/fetcher/blockfetcher.spec.ts index 5bd9dddf6a..830ccdf24e 100644 --- a/packages/client/test/sync/fetcher/blockfetcher.spec.ts +++ b/packages/client/test/sync/fetcher/blockfetcher.spec.ts @@ -188,14 +188,10 @@ describe('[BlockFetcher]', async () => { it('should parse bodies correctly', async () => { const config = new Config({ accountCache: 10000, storageCache: 1000 }) config.chainCommon.getHardforkBy = vi.fn((input) => { - if ( - input['blockNumber'] !== undefined && - input['td'] !== undefined && - input['timestamp'] !== undefined - ) + if (input['blockNumber'] !== undefined && input['timestamp'] !== undefined) return Hardfork.Shanghai - if (input['blockNumber'] !== undefined && input['td'] !== undefined) return Hardfork.Shanghai + if (input['blockNumber'] !== undefined) return Hardfork.Shanghai if (input['blockNumber'] !== undefined && input['timestamp'] !== undefined) return Hardfork.Shanghai diff --git a/packages/client/test/sync/skeleton.spec.ts b/packages/client/test/sync/skeleton.spec.ts index 7c3f4b2c79..e3edb0a0c6 100644 --- a/packages/client/test/sync/skeleton.spec.ts +++ b/packages/client/test/sync/skeleton.spec.ts @@ -1,8 +1,13 @@ -import { BlockHeader, createBlock } from '@ethereumjs/block' -import { Common, Mainnet, createCommonFromGethGenesis } from '@ethereumjs/common' +import { createBlock } from '@ethereumjs/block' +import { + Common, + Mainnet, + createCommonFromGethGenesis, + createCustomCommon, +} from '@ethereumjs/common' import { equalsBytes, utf8ToBytes } from '@ethereumjs/util' import { MemoryLevel } from 'memory-level' -import { assert, describe, it, vi } from 'vitest' +import { assert, describe, it } from 'vitest' import { Chain } from '../../src/blockchain/index.js' import { Config } from '../../src/config.js' @@ -10,6 +15,7 @@ import { getLogger } from '../../src/logging.js' import { Skeleton, errReorgDenied, errSyncMerged } from '../../src/sync/index.js' import { short } from '../../src/util/index.js' import { wait } from '../integration/util.js' +import mergeGenesisParams from '../testdata/common/mergeTestnet.json' import genesisJSON from '../testdata/geth-genesis/post-merge.json' import type { Block } from '@ethereumjs/block' @@ -804,19 +810,9 @@ describe('[Skeleton] / setHead', async () => { }) it('should abort filling the canonical chain if the terminal block is invalid', async () => { - const genesis = { - ...genesisJSON, - config: { - ...genesisJSON.config, - terminalTotalDifficulty: 200, - clique: undefined, - ethash: {}, - }, - extraData: '0x00000000000000000', - difficulty: '0x1', - } - const common = createCommonFromGethGenesis(genesis, { chain: 'post-merge' }) - common.setHardforkBy({ blockNumber: BigInt(0), td: BigInt(0) }) + // @ts-ignore PrefixedHexString type is too strict + const common = createCustomCommon(mergeGenesisParams, Mainnet, { name: 'post-merge' }) + common.setHardforkBy({ blockNumber: BigInt(0) }) const config = new Config({ common, accountCache: 10000, @@ -841,19 +837,19 @@ describe('[Skeleton] / setHead', async () => { ) const block3PoS = createBlock( { header: { number: 3, parentHash: block2.hash(), difficulty: 0 } }, - { common, setHardfork: BigInt(200) }, + { common, setHardfork: true }, ) const block4InvalidPoS = createBlock( { header: { number: 4, parentHash: block3PoW.hash(), difficulty: 0 } }, - { common, setHardfork: BigInt(200) }, + { common, setHardfork: true }, ) const block4PoS = createBlock( { header: { number: 4, parentHash: block3PoS.hash(), difficulty: 0 } }, - { common, setHardfork: BigInt(200) }, + { common, setHardfork: true }, ) const block5 = createBlock( { header: { number: 5, parentHash: block4PoS.hash(), difficulty: 0 } }, - { common, setHardfork: BigInt(200) }, + { common, setHardfork: true }, ) const skeleton = new Skeleton({ chain, config, metaDB: new MemoryLevel() }) @@ -906,157 +902,4 @@ describe('[Skeleton] / setHead', async () => { await wait(200) assert.equal(skeleton.bounds().head, BigInt(5), 'should update to new height') }) - - it('should abort filling the canonical chain and backstep if the terminal block is invalid', async () => { - const genesis = { - ...genesisJSON, - config: { - ...genesisJSON.config, - terminalTotalDifficulty: 200, - clique: undefined, - ethash: {}, - }, - extraData: '0x00000000000000000', - difficulty: '0x1', - } - const common = createCommonFromGethGenesis(genesis, { chain: 'post-merge' }) - common.setHardforkBy({ blockNumber: BigInt(0), td: BigInt(0) }) - const config = new Config({ - common, - accountCache: 10000, - storageCache: 1000, - }) - const chain = await Chain.create({ config }) - ;(chain.blockchain as any)._validateBlocks = false - ;(chain.blockchain as any)._validateConsensus = false - await chain.open() - const genesisBlock = await chain.getBlock(BigInt(0)) - - const block1 = createBlock( - { header: { number: 1, parentHash: genesisBlock.hash(), difficulty: 100 } }, - { common }, - ) - const block2 = createBlock( - { header: { number: 2, parentHash: block1.hash(), difficulty: 100 } }, - { common }, - ) - const block3PoW = createBlock( - { header: { number: 3, parentHash: block2.hash(), difficulty: 100 } }, - { common }, - ) - const block4InvalidPoS = createBlock( - { header: { number: 4, parentHash: block3PoW.hash(), difficulty: 0 } }, - { common, setHardfork: 200 }, - ) - - const skeleton = new Skeleton({ chain, config, metaDB: new MemoryLevel() }) - await skeleton.open() - - await skeleton.initSync(block4InvalidPoS) - await skeleton.putBlocks([block3PoW, block2]) - assert.equal(chain.blocks.height, BigInt(0), 'canonical height should be at genesis') - await skeleton.putBlocks([block1]) - await wait(200) - assert.equal( - chain.blocks.height, - BigInt(2), - 'canonical height should stop at block 2 (valid terminal block), since block 3 is invalid (past ttd)', - ) - assert.equal( - skeleton['status'].progress.subchains[0].tail, - BigInt(1), - `Subchain should have been backstepped to 1`, - ) - }) - - it('should abort filling the canonical chain if a PoS block comes too early without hitting ttd', async () => { - const genesis = { - ...genesisJSON, - config: { - ...genesisJSON.config, - terminalTotalDifficulty: 200, - skeletonFillCanonicalBackStep: 0, - }, - difficulty: '0x1', - } - const common = createCommonFromGethGenesis(genesis, { chain: 'post-merge' }) - common.setHardforkBy({ blockNumber: BigInt(0), td: BigInt(0) }) - const config = new Config({ - common, - logger: getLogger({ logLevel: 'debug' }), - accountCache: 10000, - storageCache: 1000, - }) - - const chain = await Chain.create({ config }) - ;(chain.blockchain as any)._validateConsensus = false - // Only add td validations to the validateBlock - chain.blockchain.validateBlock = async (block: Block) => { - if (!(block.header.common.consensusType() === 'pos') && block.header.difficulty === 0n) { - throw Error( - `Invalid header difficulty=${ - block.header.difficulty - } for consensus=${block.header.common.consensusType()}`, - ) - } - } - - const originalValidate = BlockHeader.prototype['_consensusFormatValidation'] - BlockHeader.prototype['_consensusFormatValidation'] = vi.fn() - vi.doMock('@ethereumjs/block', () => BlockHeader) - await chain.open() - const genesisBlock = await chain.getBlock(BigInt(0)) - - const block1 = createBlock( - { header: { number: 1, parentHash: genesisBlock.hash(), difficulty: 100 } }, - { common }, - ) - const block2 = createBlock( - { header: { number: 2, parentHash: block1.hash(), difficulty: 100 } }, - { common }, - ) - const block2PoS = createBlock( - { header: { number: 2, parentHash: block1.hash(), difficulty: 0 } }, - { common }, - ) - const block3 = createBlock( - { header: { number: 3, parentHash: block2.hash(), difficulty: 0 } }, - { common }, - ) - - const skeleton = new Skeleton({ chain, config, metaDB: new MemoryLevel() }) - await skeleton.open() - - await skeleton.initSync(block2PoS) - await skeleton.putBlocks([block1]) - - await wait(200) - assert.equal( - chain.blocks.height, - BigInt(1), - 'canonical height should stop at block 1 (valid PoW block), since block 2 is invalid (invalid PoS, not past ttd)', - ) - // Put correct chain - await skeleton.initSync(block3) - try { - await skeleton.putBlocks([block2]) - } catch (error: any) { - if (error !== errSyncMerged) { - assert.fail(error) - } - } - await wait(200) - assert.equal( - chain.blocks.height, - BigInt(3), - 'canonical height should now be at head with correct chain', - ) - const latestHash = chain.headers.latest?.hash() - assert.ok( - latestHash !== undefined && equalsBytes(latestHash, block3.hash()), - 'canonical height should now be at head with correct chain', - ) - - BlockHeader.prototype['_consensusFormatValidation'] = originalValidate - }) }) diff --git a/packages/common/test/data/merge/testnetMerge.json b/packages/client/test/testdata/common/mergeTestnet.json similarity index 76% rename from packages/common/test/data/merge/testnetMerge.json rename to packages/client/test/testdata/common/mergeTestnet.json index e6698fa6b3..bdf12be8db 100644 --- a/packages/common/test/data/merge/testnetMerge.json +++ b/packages/client/test/testdata/common/mergeTestnet.json @@ -1,14 +1,10 @@ { - "name": "testnetMerge", - "chainId": 55555, - "defaultHardfork": "istanbul", + "name": "testnet", + "chainId": 12345, + "defaultHardfork": "byzantium", "consensus": { - "type": "poa", - "algorithm": "clique", - "clique": { - "period": 15, - "epoch": 30000 - } + "type": "pow", + "algorithm": "ethash" }, "comment": "Private test network", "url": "[TESTNET_URL]", @@ -25,40 +21,39 @@ }, { "name": "homestead", - "block": 1 + "block": 0 }, { "name": "tangerineWhistle", - "block": 2 + "block": 0 }, { "name": "spuriousDragon", - "block": 3 + "block": 0 }, { - "name": "istanbul", - "block": 8 + "name": "byzantium", + "block": 0 }, { - "name": "muirGlacier", - "block": 10 + "name": "constantinople", + "block": 0 }, { "name": "berlin", - "block": 12 + "block": 0 }, { "name": "london", - "block": 14 + "block": 0 }, { "name": "paris", - "block": null, - "ttd": "5000" + "block": 3 }, { - "name": "shanghai", - "block": null + "name": "mergeForkIdTransition", + "block": 3 } ], "bootstrapNodes": [ diff --git a/packages/client/test/testdata/geth-genesis/debug.json b/packages/client/test/testdata/geth-genesis/debug.json index 8f6da427f0..94660dd079 100644 --- a/packages/client/test/testdata/geth-genesis/debug.json +++ b/packages/client/test/testdata/geth-genesis/debug.json @@ -16,7 +16,8 @@ "period": 5, "epoch": 30000 }, - "terminalTotalDifficulty": 0 + "terminalTotalDifficulty": 0, + "terminalTotalDifficultyPassed": true }, "nonce": "0x42", "timestamp": "0x0", diff --git a/packages/client/test/testdata/geth-genesis/eip4844.json b/packages/client/test/testdata/geth-genesis/eip4844.json index cd5726b939..78cae3c9f0 100644 --- a/packages/client/test/testdata/geth-genesis/eip4844.json +++ b/packages/client/test/testdata/geth-genesis/eip4844.json @@ -18,7 +18,8 @@ "blockperiodseconds": 5, "epochlength": 30000 }, - "terminalTotalDifficulty": 0 + "terminalTotalDifficulty": 0, + "terminalTotalDifficultyPassed": true }, "nonce": "0x42", "timestamp": "0x0", diff --git a/packages/client/test/testdata/geth-genesis/no-extra-data.json b/packages/client/test/testdata/geth-genesis/no-extra-data.json index b9d2f14595..73fc19d02b 100644 --- a/packages/client/test/testdata/geth-genesis/no-extra-data.json +++ b/packages/client/test/testdata/geth-genesis/no-extra-data.json @@ -16,7 +16,8 @@ "period": 5, "epoch": 30000 }, - "terminalTotalDifficulty": 0 + "terminalTotalDifficulty": 0, + "terminalTotalDifficultyPassed": true }, "nonce": "0x42", "timestamp": "16", diff --git a/packages/client/test/testdata/geth-genesis/post-merge.json b/packages/client/test/testdata/geth-genesis/post-merge.json index ffbb465e69..32f5f093d3 100644 --- a/packages/client/test/testdata/geth-genesis/post-merge.json +++ b/packages/client/test/testdata/geth-genesis/post-merge.json @@ -16,7 +16,8 @@ "period": 5, "epoch": 30000 }, - "terminalTotalDifficulty": 0 + "terminalTotalDifficulty": 0, + "terminalTotalDifficultyPassed": true }, "nonce": "0x42", "timestamp": "0x0", diff --git a/packages/client/test/testdata/geth-genesis/withdrawals.json b/packages/client/test/testdata/geth-genesis/withdrawals.json index 10060534e3..7941658039 100644 --- a/packages/client/test/testdata/geth-genesis/withdrawals.json +++ b/packages/client/test/testdata/geth-genesis/withdrawals.json @@ -17,7 +17,8 @@ "blockperiodseconds": 5, "epochlength": 30000 }, - "terminalTotalDifficulty": 0 + "terminalTotalDifficulty": 0, + "terminalTotalDifficultyPassed": true }, "nonce": "0x42", "timestamp": "0x0", diff --git a/packages/common/examples/genesisData/post-merge.json b/packages/common/examples/genesisData/post-merge.json index ffbb465e69..32f5f093d3 100644 --- a/packages/common/examples/genesisData/post-merge.json +++ b/packages/common/examples/genesisData/post-merge.json @@ -16,7 +16,8 @@ "period": 5, "epoch": 30000 }, - "terminalTotalDifficulty": 0 + "terminalTotalDifficulty": 0, + "terminalTotalDifficultyPassed": true }, "nonce": "0x42", "timestamp": "0x0", diff --git a/packages/common/src/chains.ts b/packages/common/src/chains.ts index 1ff1da2d8e..ccbc87718e 100644 --- a/packages/common/src/chains.ts +++ b/packages/common/src/chains.ts @@ -93,7 +93,6 @@ export const Mainnet: ChainConfig = { // The forkHash will remain same as mergeForkIdTransition is post merge // terminal block: https://etherscan.io/block/15537393 name: 'paris', - ttd: '58750000000000000000000', block: 15537394, forkHash: '0xf0afd0e3', }, @@ -231,7 +230,6 @@ export const Goerli: ChainConfig = { // The forkHash will remain same as mergeForkIdTransition is post merge, // terminal block: https://goerli.etherscan.io/block/7382818 name: 'paris', - ttd: '10790000', block: 7382819, forkHash: '0xb8c6299d', }, @@ -394,7 +392,6 @@ export const Sepolia: ChainConfig = { // The forkHash will remain same as mergeForkIdTransition is post merge, // terminal block: https://sepolia.etherscan.io/block/1450408 name: 'paris', - ttd: '17000000000000000', block: 1450409, forkHash: '0xfe3366e7', }, @@ -527,7 +524,6 @@ export const Holesky: ChainConfig = { }, { name: 'paris', - ttd: '0', block: 0, forkHash: '0xc61a6098', }, @@ -630,7 +626,6 @@ export const Kaustinen6: ChainConfig = { }, { name: 'paris', - ttd: '0', block: 0, }, { diff --git a/packages/common/src/common.ts b/packages/common/src/common.ts index d0424b615d..28022d4f01 100644 --- a/packages/common/src/common.ts +++ b/packages/common/src/common.ts @@ -160,35 +160,17 @@ export class Common { * Returns the hardfork either based on block numer (older HFs) or * timestamp (Shanghai upwards). * - * An optional TD takes precedence in case the corresponding HF block - * is set to `null` or otherwise needs to match (if not an error - * will be thrown). - * - * @param Opts Block number, timestamp or TD (all optional) + * @param Opts Block number or timestamp * @returns The name of the HF */ getHardforkBy(opts: HardforkByOpts): string { const blockNumber: bigint | undefined = toType(opts.blockNumber, TypeOutput.BigInt) - const td: bigint | undefined = toType(opts.td, TypeOutput.BigInt) const timestamp: bigint | undefined = toType(opts.timestamp, TypeOutput.BigInt) - // Filter out hardforks with no block number, no ttd or no timestamp (i.e. unapplied hardforks) - const hfs = this.hardforks().filter( - (hf) => - hf.block !== null || - (hf.ttd !== null && hf.ttd !== undefined) || - hf.timestamp !== undefined, - ) - const mergeIndex = hfs.findIndex((hf) => hf.ttd !== null && hf.ttd !== undefined) - const doubleTTDHF = hfs - .slice(mergeIndex + 1) - .findIndex((hf) => hf.ttd !== null && hf.ttd !== undefined) - if (doubleTTDHF >= 0) { - throw Error(`More than one merge hardforks found with ttd specified`) - } + // Filter out hardforks with no block number, no timestamp (i.e. unapplied hardforks) + const hfs = this.hardforks().filter((hf) => hf.block !== null || hf.timestamp !== undefined) // Find the first hardfork that has a block number greater than `blockNumber` - // (skips the merge hardfork since it cannot have a block number specified). // If timestamp is not provided, it also skips timestamps hardforks to continue // discovering/checking number hardforks. let hfIndex = hfs.findIndex( @@ -206,35 +188,17 @@ export class Common { throw Error('Must have at least one hardfork at block 0') } - // If timestamp is not provided, we need to rollback to the last hf with block or ttd + // If timestamp is not provided, we need to rollback to the last hf with block if (timestamp === undefined) { const stepBack = hfs .slice(0, hfIndex) .reverse() - .findIndex((hf) => hf.block !== null || hf.ttd !== undefined) + .findIndex((hf) => hf.block !== null) hfIndex = hfIndex - stepBack } // Move hfIndex one back to arrive at candidate hardfork hfIndex = hfIndex - 1 - // If the timestamp was not provided, we could have skipped timestamp hardforks to look for number - // hardforks. so it will now be needed to rollback - if (hfs[hfIndex].block === null && hfs[hfIndex].timestamp === undefined) { - // We're on the merge hardfork. Let's check the TTD - if (td === undefined || td === null || BigInt(hfs[hfIndex].ttd!) > td) { - // Merge ttd greater than current td so we're on hardfork before merge - hfIndex -= 1 - } - } else { - if (mergeIndex >= 0 && td !== undefined && td !== null) { - if (hfIndex >= mergeIndex && BigInt(hfs[mergeIndex].ttd!) > td) { - throw Error('Maximum HF determined by total difficulty is lower than the block number HF') - } else if (hfIndex < mergeIndex && BigInt(hfs[mergeIndex].ttd!) < td) { - throw Error('HF determined by block number is lower than the minimum total difficulty HF') - } - } - } - const hfStartIndex = hfIndex // Move the hfIndex to the end of the hardforks that might be scheduled on the same block/timestamp // This won't anyway be the case with Merge hfs @@ -256,7 +220,7 @@ export class Common { 0, ) if (minTimeStamp > timestamp) { - throw Error(`Maximum HF determined by timestamp is lower than the block number/ttd HF`) + throw Error(`Maximum HF determined by timestamp is lower than the block number HF`) } const maxTimeStamp = hfs @@ -268,7 +232,7 @@ export class Common { ) if (maxTimeStamp < timestamp) { - throw Error(`Maximum HF determined by block number/ttd is lower than timestamp HF`) + throw Error(`Maximum HF determined by block number is lower than timestamp HF`) } } const hardfork = hfs[hfIndex] @@ -279,11 +243,7 @@ export class Common { * Sets a new hardfork either based on block numer (older HFs) or * timestamp (Shanghai upwards). * - * An optional TD takes precedence in case the corresponding HF block - * is set to `null` or otherwise needs to match (if not an error - * will be thrown). - * - * @param Opts Block number, timestamp or TD (all optional) + * @param Opts Block number or timestamp * @returns The name of the HF set */ setHardforkBy(opts: HardforkByOpts): string { @@ -460,16 +420,10 @@ export class Common { * optional provided total difficulty (Merge HF) * @param name Parameter name * @param blockNumber Block number - * @param td Total difficulty * * @returns The value requested or `BigInt(0)` if not found */ - paramByBlock( - name: string, - blockNumber: BigIntLike, - td?: BigIntLike, - timestamp?: BigIntLike, - ): bigint { - const hardfork = this.getHardforkBy({ blockNumber, td, timestamp }) + paramByBlock(name: string, blockNumber: BigIntLike, timestamp?: BigIntLike): bigint { + const hardfork = this.getHardforkBy({ blockNumber, timestamp }) return this.paramByHardfork(name, hardfork) } @@ -589,7 +543,7 @@ export class Common { /** * Returns the scheduled timestamp of the EIP (if scheduled and scheduled by timestamp) * @param eip EIP number - * @returns Scheduled timestamp. If this EIP is unscheduled, or the EIP is scheduled by block number or ttd, then it returns `null`. + * @returns Scheduled timestamp. If this EIP is unscheduled, or the EIP is scheduled by block number, then it returns `null`. */ eipTimestamp(eip: number): bigint | null { for (const hfChanges of this.HARDFORK_CHANGES) { @@ -604,20 +558,6 @@ export class Common { return null } - /** - * Returns the hardfork change total difficulty (Merge HF) for hardfork provided or set - * @param hardfork Hardfork name, optional if HF set - * @returns Total difficulty or null if no set - */ - hardforkTTD(hardfork?: string | Hardfork): bigint | null { - hardfork = hardfork ?? this._hardfork - const ttd = this._getHardfork(hardfork)?.['ttd'] - if (ttd === undefined || ttd === null) { - return null - } - return BigInt(ttd) - } - /** * Returns the change block for the next hardfork after the hardfork provided or set * @param hardfork Hardfork name, optional if HF set @@ -715,10 +655,7 @@ export class Common { forkHash(hardfork?: string | Hardfork, genesisHash?: Uint8Array): PrefixedHexString { hardfork = hardfork ?? this._hardfork const data = this._getHardfork(hardfork) - if ( - data === null || - (data?.block === null && data?.timestamp === undefined && data?.ttd === undefined) - ) { + if (data === null || (data?.block === null && data?.timestamp === undefined)) { const msg = 'No fork hash calculation possible for future hardfork' throw new Error(msg) } @@ -751,7 +688,8 @@ export class Common { const blockOrTime = hf.timestamp ?? hf.block if ( (hf.forkHash === null || hf.forkHash === undefined) && - ((blockOrTime !== null && blockOrTime !== undefined) || typeof hf.ttd !== 'undefined') + blockOrTime !== null && + blockOrTime !== undefined ) { hf.forkHash = this.forkHash(hf.name, genesisHash) } diff --git a/packages/common/src/constructors.ts b/packages/common/src/constructors.ts index 8ca66fc94a..f5fb13ee0d 100644 --- a/packages/common/src/constructors.ts +++ b/packages/common/src/constructors.ts @@ -40,17 +40,9 @@ export function createCustomCommon( */ export function createCommonFromGethGenesis( genesisJson: any, - { - chain, - eips, - genesisHash, - hardfork, - params, - mergeForkIdPostMerge, - customCrypto, - }: GethConfigOpts, + { chain, eips, genesisHash, hardfork, params, customCrypto }: GethConfigOpts, ): Common { - const genesisParams = parseGethGenesis(genesisJson, chain, mergeForkIdPostMerge) + const genesisParams = parseGethGenesis(genesisJson, chain) const common = new Common({ chain: genesisParams, eips, diff --git a/packages/common/src/types.ts b/packages/common/src/types.ts index ee74ef93b6..c76a264689 100644 --- a/packages/common/src/types.ts +++ b/packages/common/src/types.ts @@ -53,7 +53,6 @@ export interface GenesisBlockConfig { export interface HardforkTransitionConfig { name: Hardfork | string block: number | null // null is used for hardforks that should not be applied -- since `undefined` isn't a valid value in JSON - ttd?: bigint | string timestamp?: number | string forkHash?: PrefixedHexString | null } @@ -154,7 +153,6 @@ export interface GethConfigOpts extends BaseOpts { export interface HardforkByOpts { blockNumber?: BigIntLike timestamp?: BigIntLike - td?: BigIntLike } export type EIPConfig = { diff --git a/packages/common/src/utils.ts b/packages/common/src/utils.ts index c9db1b6f49..55796081eb 100644 --- a/packages/common/src/utils.ts +++ b/packages/common/src/utils.ts @@ -26,12 +26,9 @@ function formatNonce(nonce: string): PrefixedHexString { /** * Converts Geth genesis parameters to an EthereumJS compatible `CommonOpts` object * @param json object representing the Geth genesis file - * @param optional mergeForkIdPostMerge which clarifies the placement of MergeForkIdTransition - * hardfork, which by default is post merge as with the merged eth networks but could also come - * before merge like in kiln genesis * @returns genesis parameters in a `CommonOpts` compliant object */ -function parseGethParams(json: any, mergeForkIdPostMerge: boolean = true) { +function parseGethParams(json: any) { const { name, config, @@ -84,6 +81,15 @@ function parseGethParams(json: any, mergeForkIdPostMerge: boolean = true) { ) } + // Terminal total difficulty logic is not supported any more as the merge has been completed + // so the Merge/Paris hardfork block must be 0 + if ( + config.terminalTotalDifficulty !== undefined && + (config.terminalTotalDifficulty > 0 || config.terminalTotalDifficultyPassed === false) + ) { + throw new Error('nonzero terminal total difficulty is not supported') + } + const params = { name, chainId, @@ -134,7 +140,7 @@ function parseGethParams(json: any, mergeForkIdPostMerge: boolean = true) { [Hardfork.MuirGlacier]: { name: 'muirGlacierBlock' }, [Hardfork.Berlin]: { name: 'berlinBlock' }, [Hardfork.London]: { name: 'londonBlock' }, - [Hardfork.MergeForkIdTransition]: { name: 'mergeForkBlock', postMerge: mergeForkIdPostMerge }, + [Hardfork.MergeForkIdTransition]: { name: 'mergeForkBlock', postMerge: true }, [Hardfork.Shanghai]: { name: 'shanghaiTime', postMerge: true, isTimestamp: true }, [Hardfork.Cancun]: { name: 'cancunTime', postMerge: true, isTimestamp: true }, [Hardfork.Prague]: { name: 'pragueTime', postMerge: true, isTimestamp: true }, @@ -176,7 +182,7 @@ function parseGethParams(json: any, mergeForkIdPostMerge: boolean = true) { return (a.timestamp ?? 0) - (b.timestamp ?? 0) }) - // only set the genesis timestamp forks to zero post the above sort has happended + // only set the genesis timestamp forks to zero post the above sort has happened // to get the correct sorting for (const hf of params.hardforks) { if (hf.timestamp === genesisTimestamp) { @@ -185,15 +191,11 @@ function parseGethParams(json: any, mergeForkIdPostMerge: boolean = true) { } if (config.terminalTotalDifficulty !== undefined) { - // Following points need to be considered for placement of merge hf - // - Merge hardfork can't be placed at genesis - // - Place merge hf before any hardforks that require CL participation for e.g. withdrawals - // - Merge hardfork has to be placed just after genesis if any of the genesis hardforks make CL - // necessary for e.g. withdrawals + // Merge fork must be placed at 0 since ttd logic is no longer supported const mergeConfig = { name: Hardfork.Paris, - ttd: config.terminalTotalDifficulty, - block: null, + block: 0, + timestamp: undefined, } // Merge hardfork has to be placed before first hardfork that is dependent on merge @@ -220,7 +222,7 @@ function parseGethParams(json: any, mergeForkIdPostMerge: boolean = true) { * @param name optional chain name * @returns parsed params */ -export function parseGethGenesis(json: any, name?: string, mergeForkIdPostMerge?: boolean) { +export function parseGethGenesis(json: any, name?: string) { try { const required = ['config', 'difficulty', 'gasLimit', 'nonce', 'alloc'] if (required.some((field) => !(field in json))) { @@ -234,7 +236,7 @@ export function parseGethGenesis(json: any, name?: string, mergeForkIdPostMerge? if (name !== undefined) { finalJson.name = name } - return parseGethParams(finalJson, mergeForkIdPostMerge) + return parseGethParams(finalJson) } catch (e: any) { throw new Error(`Error parsing parameters file: ${e.message}`) } diff --git a/packages/common/test/data/geth-genesis/debug.json b/packages/common/test/data/geth-genesis/debug.json index 8f6da427f0..94660dd079 100644 --- a/packages/common/test/data/geth-genesis/debug.json +++ b/packages/common/test/data/geth-genesis/debug.json @@ -16,7 +16,8 @@ "period": 5, "epoch": 30000 }, - "terminalTotalDifficulty": 0 + "terminalTotalDifficulty": 0, + "terminalTotalDifficultyPassed": true }, "nonce": "0x42", "timestamp": "0x0", diff --git a/packages/common/test/data/geth-genesis/eip4844.json b/packages/common/test/data/geth-genesis/eip4844.json index cd5726b939..78cae3c9f0 100644 --- a/packages/common/test/data/geth-genesis/eip4844.json +++ b/packages/common/test/data/geth-genesis/eip4844.json @@ -18,7 +18,8 @@ "blockperiodseconds": 5, "epochlength": 30000 }, - "terminalTotalDifficulty": 0 + "terminalTotalDifficulty": 0, + "terminalTotalDifficultyPassed": true }, "nonce": "0x42", "timestamp": "0x0", diff --git a/packages/common/test/data/geth-genesis/geth-genesis-kiln.json b/packages/common/test/data/geth-genesis/geth-genesis-kiln.json deleted file mode 100644 index 6d99cf2355..0000000000 --- a/packages/common/test/data/geth-genesis/geth-genesis-kiln.json +++ /dev/null @@ -1,865 +0,0 @@ -{ - "config": { - "chainId": 1337802, - "homesteadBlock": 0, - "eip150Block": 0, - "eip155Block": 0, - "eip158Block": 0, - "byzantiumBlock": 0, - "constantinopleBlock": 0, - "petersburgBlock": 0, - "istanbulBlock": 0, - "berlinBlock": 0, - "londonBlock": 0, - "mergeForkBlock": 1000, - "terminalTotalDifficulty": 20000000000000 - }, - "alloc": { - "0x0000000000000000000000000000000000000000": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000001": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000002": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000003": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000004": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000005": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000006": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000007": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000008": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000009": { - "balance": "1" - }, - "0x000000000000000000000000000000000000000a": { - "balance": "1" - }, - "0x000000000000000000000000000000000000000b": { - "balance": "1" - }, - "0x000000000000000000000000000000000000000c": { - "balance": "1" - }, - "0x000000000000000000000000000000000000000d": { - "balance": "1" - }, - "0x000000000000000000000000000000000000000e": { - "balance": "1" - }, - "0x000000000000000000000000000000000000000f": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000010": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000011": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000012": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000013": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000014": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000015": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000016": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000017": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000018": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000019": { - "balance": "1" - }, - "0x000000000000000000000000000000000000001a": { - "balance": "1" - }, - "0x000000000000000000000000000000000000001b": { - "balance": "1" - }, - "0x000000000000000000000000000000000000001c": { - "balance": "1" - }, - "0x000000000000000000000000000000000000001d": { - "balance": "1" - }, - "0x000000000000000000000000000000000000001e": { - "balance": "1" - }, - "0x000000000000000000000000000000000000001f": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000020": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000021": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000022": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000023": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000024": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000025": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000026": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000027": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000028": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000029": { - "balance": "1" - }, - "0x000000000000000000000000000000000000002a": { - "balance": "1" - }, - "0x000000000000000000000000000000000000002b": { - "balance": "1" - }, - "0x000000000000000000000000000000000000002c": { - "balance": "1" - }, - "0x000000000000000000000000000000000000002d": { - "balance": "1" - }, - "0x000000000000000000000000000000000000002e": { - "balance": "1" - }, - "0x000000000000000000000000000000000000002f": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000030": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000031": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000032": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000033": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000034": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000035": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000036": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000037": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000038": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000039": { - "balance": "1" - }, - "0x000000000000000000000000000000000000003a": { - "balance": "1" - }, - "0x000000000000000000000000000000000000003b": { - "balance": "1" - }, - "0x000000000000000000000000000000000000003c": { - "balance": "1" - }, - "0x000000000000000000000000000000000000003d": { - "balance": "1" - }, - "0x000000000000000000000000000000000000003e": { - "balance": "1" - }, - "0x000000000000000000000000000000000000003f": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000040": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000041": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000042": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000043": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000044": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000045": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000046": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000047": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000048": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000049": { - "balance": "1" - }, - "0x000000000000000000000000000000000000004a": { - "balance": "1" - }, - "0x000000000000000000000000000000000000004b": { - "balance": "1" - }, - "0x000000000000000000000000000000000000004c": { - "balance": "1" - }, - "0x000000000000000000000000000000000000004d": { - "balance": "1" - }, - "0x000000000000000000000000000000000000004e": { - "balance": "1" - }, - "0x000000000000000000000000000000000000004f": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000050": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000051": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000052": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000053": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000054": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000055": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000056": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000057": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000058": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000059": { - "balance": "1" - }, - "0x000000000000000000000000000000000000005a": { - "balance": "1" - }, - "0x000000000000000000000000000000000000005b": { - "balance": "1" - }, - "0x000000000000000000000000000000000000005c": { - "balance": "1" - }, - "0x000000000000000000000000000000000000005d": { - "balance": "1" - }, - "0x000000000000000000000000000000000000005e": { - "balance": "1" - }, - "0x000000000000000000000000000000000000005f": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000060": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000061": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000062": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000063": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000064": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000065": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000066": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000067": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000068": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000069": { - "balance": "1" - }, - "0x000000000000000000000000000000000000006a": { - "balance": "1" - }, - "0x000000000000000000000000000000000000006b": { - "balance": "1" - }, - "0x000000000000000000000000000000000000006c": { - "balance": "1" - }, - "0x000000000000000000000000000000000000006d": { - "balance": "1" - }, - "0x000000000000000000000000000000000000006e": { - "balance": "1" - }, - "0x000000000000000000000000000000000000006f": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000070": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000071": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000072": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000073": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000074": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000075": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000076": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000077": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000078": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000079": { - "balance": "1" - }, - "0x000000000000000000000000000000000000007a": { - "balance": "1" - }, - "0x000000000000000000000000000000000000007b": { - "balance": "1" - }, - "0x000000000000000000000000000000000000007c": { - "balance": "1" - }, - "0x000000000000000000000000000000000000007d": { - "balance": "1" - }, - "0x000000000000000000000000000000000000007e": { - "balance": "1" - }, - "0x000000000000000000000000000000000000007f": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000080": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000081": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000082": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000083": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000084": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000085": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000086": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000087": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000088": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000089": { - "balance": "1" - }, - "0x000000000000000000000000000000000000008a": { - "balance": "1" - }, - "0x000000000000000000000000000000000000008b": { - "balance": "1" - }, - "0x000000000000000000000000000000000000008c": { - "balance": "1" - }, - "0x000000000000000000000000000000000000008d": { - "balance": "1" - }, - "0x000000000000000000000000000000000000008e": { - "balance": "1" - }, - "0x000000000000000000000000000000000000008f": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000090": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000091": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000092": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000093": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000094": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000095": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000096": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000097": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000098": { - "balance": "1" - }, - "0x0000000000000000000000000000000000000099": { - "balance": "1" - }, - "0x000000000000000000000000000000000000009a": { - "balance": "1" - }, - "0x000000000000000000000000000000000000009b": { - "balance": "1" - }, - "0x000000000000000000000000000000000000009c": { - "balance": "1" - }, - "0x000000000000000000000000000000000000009d": { - "balance": "1" - }, - "0x000000000000000000000000000000000000009e": { - "balance": "1" - }, - "0x000000000000000000000000000000000000009f": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000a0": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000a1": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000a2": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000a3": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000a4": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000a5": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000a6": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000a7": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000a8": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000a9": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000aa": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000ab": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000ac": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000ad": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000ae": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000af": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000b0": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000b1": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000b2": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000b3": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000b4": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000b5": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000b6": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000b7": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000b8": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000b9": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000ba": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000bb": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000bc": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000bd": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000be": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000bf": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000c0": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000c1": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000c2": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000c3": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000c4": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000c5": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000c6": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000c7": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000c8": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000c9": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000ca": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000cb": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000cc": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000cd": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000ce": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000cf": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000d0": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000d1": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000d2": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000d3": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000d4": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000d5": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000d6": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000d7": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000d8": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000d9": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000da": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000db": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000dc": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000dd": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000de": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000df": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000e0": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000e1": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000e2": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000e3": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000e4": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000e5": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000e6": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000e7": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000e8": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000e9": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000ea": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000eb": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000ec": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000ed": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000ee": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000ef": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000f0": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000f1": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000f2": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000f3": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000f4": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000f5": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000f6": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000f7": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000f8": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000f9": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000fa": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000fb": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000fc": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000fd": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000fe": { - "balance": "1" - }, - "0x00000000000000000000000000000000000000ff": { - "balance": "1" - }, - "0x4242424242424242424242424242424242424242": { - "balance": "0", - "code": "0x60806040526004361061003f5760003560e01c806301ffc9a71461004457806322895118146100a4578063621fd130146101ba578063c5f2892f14610244575b600080fd5b34801561005057600080fd5b506100906004803603602081101561006757600080fd5b50357fffffffff000000000000000000000000000000000000000000000000000000001661026b565b604080519115158252519081900360200190f35b6101b8600480360360808110156100ba57600080fd5b8101906020810181356401000000008111156100d557600080fd5b8201836020820111156100e757600080fd5b8035906020019184600183028401116401000000008311171561010957600080fd5b91939092909160208101903564010000000081111561012757600080fd5b82018360208201111561013957600080fd5b8035906020019184600183028401116401000000008311171561015b57600080fd5b91939092909160208101903564010000000081111561017957600080fd5b82018360208201111561018b57600080fd5b803590602001918460018302840111640100000000831117156101ad57600080fd5b919350915035610304565b005b3480156101c657600080fd5b506101cf6110b5565b6040805160208082528351818301528351919283929083019185019080838360005b838110156102095781810151838201526020016101f1565b50505050905090810190601f1680156102365780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561025057600080fd5b506102596110c7565b60408051918252519081900360200190f35b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f01ffc9a70000000000000000000000000000000000000000000000000000000014806102fe57507fffffffff0000000000000000000000000000000000000000000000000000000082167f8564090700000000000000000000000000000000000000000000000000000000145b92915050565b6030861461035d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806118056026913960400191505060405180910390fd5b602084146103b6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252603681526020018061179c6036913960400191505060405180910390fd5b6060821461040f576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260298152602001806118786029913960400191505060405180910390fd5b670de0b6b3a7640000341015610470576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806118526026913960400191505060405180910390fd5b633b9aca003406156104cd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260338152602001806117d26033913960400191505060405180910390fd5b633b9aca00340467ffffffffffffffff811115610535576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602781526020018061182b6027913960400191505060405180910390fd5b6060610540826114ba565b90507f649bbc62d0e31342afea4e5cd82d4049e7e1ee912fc0889aa790803be39038c589898989858a8a6105756020546114ba565b6040805160a0808252810189905290819060208201908201606083016080840160c085018e8e80828437600083820152601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01690910187810386528c815260200190508c8c808284376000838201819052601f9091017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01690920188810386528c5181528c51602091820193918e019250908190849084905b83811015610648578181015183820152602001610630565b50505050905090810190601f1680156106755780820380516001836020036101000a031916815260200191505b5086810383528881526020018989808284376000838201819052601f9091017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169092018881038452895181528951602091820193918b019250908190849084905b838110156106ef5781810151838201526020016106d7565b50505050905090810190601f16801561071c5780820380516001836020036101000a031916815260200191505b509d505050505050505050505050505060405180910390a1600060028a8a600060801b604051602001808484808284377fffffffffffffffffffffffffffffffff0000000000000000000000000000000090941691909301908152604080517ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0818403018152601090920190819052815191955093508392506020850191508083835b602083106107fc57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe090920191602091820191016107bf565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610859573d6000803e3d6000fd5b5050506040513d602081101561086e57600080fd5b5051905060006002806108846040848a8c6116fe565b6040516020018083838082843780830192505050925050506040516020818303038152906040526040518082805190602001908083835b602083106108f857805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe090920191602091820191016108bb565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610955573d6000803e3d6000fd5b5050506040513d602081101561096a57600080fd5b5051600261097b896040818d6116fe565b60405160009060200180848480828437919091019283525050604080518083038152602092830191829052805190945090925082918401908083835b602083106109f457805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe090920191602091820191016109b7565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610a51573d6000803e3d6000fd5b5050506040513d6020811015610a6657600080fd5b5051604080516020818101949094528082019290925280518083038201815260609092019081905281519192909182918401908083835b60208310610ada57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610a9d565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610b37573d6000803e3d6000fd5b5050506040513d6020811015610b4c57600080fd5b50516040805160208101858152929350600092600292839287928f928f92018383808284378083019250505093505050506040516020818303038152906040526040518082805190602001908083835b60208310610bd957805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610b9c565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610c36573d6000803e3d6000fd5b5050506040513d6020811015610c4b57600080fd5b50516040518651600291889160009188916020918201918291908601908083835b60208310610ca957805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610c6c565b6001836020036101000a0380198251168184511680821785525050505050509050018367ffffffffffffffff191667ffffffffffffffff1916815260180182815260200193505050506040516020818303038152906040526040518082805190602001908083835b60208310610d4e57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610d11565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610dab573d6000803e3d6000fd5b5050506040513d6020811015610dc057600080fd5b5051604080516020818101949094528082019290925280518083038201815260609092019081905281519192909182918401908083835b60208310610e3457805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610df7565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610e91573d6000803e3d6000fd5b5050506040513d6020811015610ea657600080fd5b50519050858114610f02576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260548152602001806117486054913960600191505060405180910390fd5b60205463ffffffff11610f60576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260218152602001806117276021913960400191505060405180910390fd5b602080546001019081905560005b60208110156110a9578160011660011415610fa0578260008260208110610f9157fe5b0155506110ac95505050505050565b600260008260208110610faf57fe5b01548460405160200180838152602001828152602001925050506040516020818303038152906040526040518082805190602001908083835b6020831061102557805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610fe8565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015611082573d6000803e3d6000fd5b5050506040513d602081101561109757600080fd5b50519250600282049150600101610f6e565b50fe5b50505050505050565b60606110c26020546114ba565b905090565b6020546000908190815b60208110156112f05781600116600114156111e6576002600082602081106110f557fe5b01548460405160200180838152602001828152602001925050506040516020818303038152906040526040518082805190602001908083835b6020831061116b57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0909201916020918201910161112e565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa1580156111c8573d6000803e3d6000fd5b5050506040513d60208110156111dd57600080fd5b505192506112e2565b600283602183602081106111f657fe5b015460405160200180838152602001828152602001925050506040516020818303038152906040526040518082805190602001908083835b6020831061126b57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0909201916020918201910161122e565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa1580156112c8573d6000803e3d6000fd5b5050506040513d60208110156112dd57600080fd5b505192505b6002820491506001016110d1565b506002826112ff6020546114ba565b600060401b6040516020018084815260200183805190602001908083835b6020831061135a57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0909201916020918201910161131d565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790527fffffffffffffffffffffffffffffffffffffffffffffffff000000000000000095909516920191825250604080518083037ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8018152601890920190819052815191955093508392850191508083835b6020831061143f57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101611402565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa15801561149c573d6000803e3d6000fd5b5050506040513d60208110156114b157600080fd5b50519250505090565b60408051600880825281830190925260609160208201818036833701905050905060c082901b8060071a60f81b826000815181106114f457fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060061a60f81b8260018151811061153757fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060051a60f81b8260028151811061157a57fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060041a60f81b826003815181106115bd57fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060031a60f81b8260048151811061160057fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060021a60f81b8260058151811061164357fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060011a60f81b8260068151811061168657fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060001a60f81b826007815181106116c957fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535050919050565b6000808585111561170d578182fd5b83861115611719578182fd5b505082019391909203915056fe4465706f736974436f6e74726163743a206d65726b6c6520747265652066756c6c4465706f736974436f6e74726163743a207265636f6e7374727563746564204465706f7369744461746120646f6573206e6f74206d6174636820737570706c696564206465706f7369745f646174615f726f6f744465706f736974436f6e74726163743a20696e76616c6964207769746864726177616c5f63726564656e7469616c73206c656e6774684465706f736974436f6e74726163743a206465706f7369742076616c7565206e6f74206d756c7469706c65206f6620677765694465706f736974436f6e74726163743a20696e76616c6964207075626b6579206c656e6774684465706f736974436f6e74726163743a206465706f7369742076616c756520746f6f20686967684465706f736974436f6e74726163743a206465706f7369742076616c756520746f6f206c6f774465706f736974436f6e74726163743a20696e76616c6964207369676e6174757265206c656e677468a26469706673582212201dd26f37a621703009abf16e77e69c93dc50c79db7f6cc37543e3e0e3decdc9764736f6c634300060b0033", - "storage": { - "0x0000000000000000000000000000000000000000000000000000000000000022": "0xf5a5fd42d16a20302798ef6ed309979b43003d2320d9f0e8ea9831a92759fb4b", - "0x0000000000000000000000000000000000000000000000000000000000000023": "0xdb56114e00fdd4c1f85c892bf35ac9a89289aaecb1ebd0a96cde606a748b5d71", - "0x0000000000000000000000000000000000000000000000000000000000000024": "0xc78009fdf07fc56a11f122370658a353aaa542ed63e44c4bc15ff4cd105ab33c", - "0x0000000000000000000000000000000000000000000000000000000000000025": "0x536d98837f2dd165a55d5eeae91485954472d56f246df256bf3cae19352a123c", - "0x0000000000000000000000000000000000000000000000000000000000000026": "0x9efde052aa15429fae05bad4d0b1d7c64da64d03d7a1854a588c2cb8430c0d30", - "0x0000000000000000000000000000000000000000000000000000000000000027": "0xd88ddfeed400a8755596b21942c1497e114c302e6118290f91e6772976041fa1", - "0x0000000000000000000000000000000000000000000000000000000000000028": "0x87eb0ddba57e35f6d286673802a4af5975e22506c7cf4c64bb6be5ee11527f2c", - "0x0000000000000000000000000000000000000000000000000000000000000029": "0x26846476fd5fc54a5d43385167c95144f2643f533cc85bb9d16b782f8d7db193", - "0x000000000000000000000000000000000000000000000000000000000000002a": "0x506d86582d252405b840018792cad2bf1259f1ef5aa5f887e13cb2f0094f51e1", - "0x000000000000000000000000000000000000000000000000000000000000002b": "0xffff0ad7e659772f9534c195c815efc4014ef1e1daed4404c06385d11192e92b", - "0x000000000000000000000000000000000000000000000000000000000000002c": "0x6cf04127db05441cd833107a52be852868890e4317e6a02ab47683aa75964220", - "0x000000000000000000000000000000000000000000000000000000000000002d": "0xb7d05f875f140027ef5118a2247bbb84ce8f2f0f1123623085daf7960c329f5f", - "0x000000000000000000000000000000000000000000000000000000000000002e": "0xdf6af5f5bbdb6be9ef8aa618e4bf8073960867171e29676f8b284dea6a08a85e", - "0x000000000000000000000000000000000000000000000000000000000000002f": "0xb58d900f5e182e3c50ef74969ea16c7726c549757cc23523c369587da7293784", - "0x0000000000000000000000000000000000000000000000000000000000000030": "0xd49a7502ffcfb0340b1d7885688500ca308161a7f96b62df9d083b71fcc8f2bb", - "0x0000000000000000000000000000000000000000000000000000000000000031": "0x8fe6b1689256c0d385f42f5bbe2027a22c1996e110ba97c171d3e5948de92beb", - "0x0000000000000000000000000000000000000000000000000000000000000032": "0x8d0d63c39ebade8509e0ae3c9c3876fb5fa112be18f905ecacfecb92057603ab", - "0x0000000000000000000000000000000000000000000000000000000000000033": "0x95eec8b2e541cad4e91de38385f2e046619f54496c2382cb6cacd5b98c26f5a4", - "0x0000000000000000000000000000000000000000000000000000000000000034": "0xf893e908917775b62bff23294dbbe3a1cd8e6cc1c35b4801887b646a6f81f17f", - "0x0000000000000000000000000000000000000000000000000000000000000035": "0xcddba7b592e3133393c16194fac7431abf2f5485ed711db282183c819e08ebaa", - "0x0000000000000000000000000000000000000000000000000000000000000036": "0x8a8d7fe3af8caa085a7639a832001457dfb9128a8061142ad0335629ff23ff9c", - "0x0000000000000000000000000000000000000000000000000000000000000037": "0xfeb3c337d7a51a6fbf00b9e34c52e1c9195c969bd4e7a0bfd51d5c5bed9c1167", - "0x0000000000000000000000000000000000000000000000000000000000000038": "0xe71f0aa83cc32edfbefa9f4d3e0174ca85182eec9f3a09f6a6c0df6377a510d7", - "0x0000000000000000000000000000000000000000000000000000000000000039": "0x31206fa80a50bb6abe29085058f16212212a60eec8f049fecb92d8c8e0a84bc0", - "0x000000000000000000000000000000000000000000000000000000000000003a": "0x21352bfecbeddde993839f614c3dac0a3ee37543f9b412b16199dc158e23b544", - "0x000000000000000000000000000000000000000000000000000000000000003b": "0x619e312724bb6d7c3153ed9de791d764a366b389af13c58bf8a8d90481a46765", - "0x000000000000000000000000000000000000000000000000000000000000003c": "0x7cdd2986268250628d0c10e385c58c6191e6fbe05191bcc04f133f2cea72c1c4", - "0x000000000000000000000000000000000000000000000000000000000000003d": "0x848930bd7ba8cac54661072113fb278869e07bb8587f91392933374d017bcbe1", - "0x000000000000000000000000000000000000000000000000000000000000003e": "0x8869ff2c22b28cc10510d9853292803328be4fb0e80495e8bb8d271f5b889636", - "0x000000000000000000000000000000000000000000000000000000000000003f": "0xb5fe28e79f1b850f8658246ce9b6a1e7b49fc06db7143e8fe0b4f2b0c5523a5c", - "0x0000000000000000000000000000000000000000000000000000000000000040": "0x985e929f70af28d0bdd1a90a808f977f597c7c778c489e98d3bd8910d31ac0f7" - } - }, - "0xf97e180c050e5Ab072211Ad2C213Eb5AEE4DF134": { - "balance": "10000000000000000000000000" - }, - "0x2cA5F489CC1Fd1CEC24747B64E8dE0F4A6A850E1": { - "balance": "10000000000000000000000000" - }, - "0x7203bd333a874D9d329050ecE393820fCD501eaA": { - "balance": "10000000000000000000000000" - }, - "0xA51918aA40D78Ff8be939bf0E8404252875c6aDF": { - "balance": "10000000000000000000000000" - }, - "0xAA81078e6b2121dd7A846690DFdD6b10d7658d8B": { - "balance": "10000000000000000000000000" - }, - "0xFA2d31D8f21c1D1633E9BEB641dF77D21D63ccDd": { - "balance": "10000000000000000000000000" - }, - "0xf751C9c6d60614226fE57D2cAD6e10C856a2ddA3": { - "balance": "10000000000000000000000000" - }, - "0x9cD16887f6A808AEaa65D3c840f059EeA4ca1319": { - "balance": "10000000000000000000000000" - }, - "0x2E07043584F11BFF0AC39c927665DF6c6ebaffFB": { - "balance": "10000000000000000000000000" - }, - "0x60e771E5eCA8E26690920de669520Da210D64A9B": { - "balance": "10000000000000000000000000" - }, - "0xFC4db92C2Cf77CE02fBfd7Da0346d2CbFA66aD59": { - "balance": "10000000000000000000000000" - } - }, - "coinbase": "0x0000000000000000000000000000000000000000", - "difficulty": "0x01", - "extraData": "", - "gasLimit": "0x400000", - "nonce": "0x1234", - "mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000", - "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000", - "timestamp": "0" -} diff --git a/packages/common/test/data/geth-genesis/no-extra-data.json b/packages/common/test/data/geth-genesis/no-extra-data.json index b9d2f14595..73fc19d02b 100644 --- a/packages/common/test/data/geth-genesis/no-extra-data.json +++ b/packages/common/test/data/geth-genesis/no-extra-data.json @@ -16,7 +16,8 @@ "period": 5, "epoch": 30000 }, - "terminalTotalDifficulty": 0 + "terminalTotalDifficulty": 0, + "terminalTotalDifficultyPassed": true }, "nonce": "0x42", "timestamp": "16", diff --git a/packages/common/test/data/geth-genesis/post-merge.json b/packages/common/test/data/geth-genesis/post-merge.json index ffbb465e69..32f5f093d3 100644 --- a/packages/common/test/data/geth-genesis/post-merge.json +++ b/packages/common/test/data/geth-genesis/post-merge.json @@ -16,7 +16,8 @@ "period": 5, "epoch": 30000 }, - "terminalTotalDifficulty": 0 + "terminalTotalDifficulty": 0, + "terminalTotalDifficultyPassed": true }, "nonce": "0x42", "timestamp": "0x0", diff --git a/packages/common/test/data/geth-genesis/withdrawals.json b/packages/common/test/data/geth-genesis/withdrawals.json index 10060534e3..7941658039 100644 --- a/packages/common/test/data/geth-genesis/withdrawals.json +++ b/packages/common/test/data/geth-genesis/withdrawals.json @@ -17,7 +17,8 @@ "blockperiodseconds": 5, "epochlength": 30000 }, - "terminalTotalDifficulty": 0 + "terminalTotalDifficulty": 0, + "terminalTotalDifficultyPassed": true }, "nonce": "0x42", "timestamp": "0x0", diff --git a/packages/common/test/data/merge/testnetPOS.json b/packages/common/test/data/merge/testnetPOS.json deleted file mode 100644 index 325c973033..0000000000 --- a/packages/common/test/data/merge/testnetPOS.json +++ /dev/null @@ -1,45 +0,0 @@ -{ - "name": "testnetPOS", - "chainId": 66666, - "defaultHardfork": "chainstart", - "consensus": { - "type": "pos", - "algorithm": "casper", - "casper": {} - }, - "comment": "Private test network (TODO: genesis block not constructed according to POS block rules yet)", - "url": "[TESTNET_URL]", - "genesis": { - "gasLimit": 1000000, - "difficulty": 1, - "nonce": "0xbb00000000000000", - "extraData": "0xcc000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" - }, - "hardforks": [ - { - "name": "chainstart", - "block": 0, - "ttd": "0" - }, - { - "name": "shanghai", - "block": 5 - } - ], - "bootstrapNodes": [ - { - "ip": "10.0.0.1", - "port": 30303, - "id": "11000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "location": "", - "comment": "" - }, - { - "ip": "10.0.0.2", - "port": 30303, - "id": "22000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "location": "", - "comment": "" - } - ] -} diff --git a/packages/common/test/data/post-merge-hardfork.json b/packages/common/test/data/post-merge-hardfork.json index 9f22e06d1e..71582b9b7d 100644 --- a/packages/common/test/data/post-merge-hardfork.json +++ b/packages/common/test/data/post-merge-hardfork.json @@ -18,7 +18,7 @@ "period": 5, "epoch": 30000 }, - "terminalTotalDifficulty": 2, + "terminalTotalDifficulty": 0, "terminalTotalDifficultyPassed": true }, "nonce": "0x42", diff --git a/packages/common/test/data/shanghai-time.json b/packages/common/test/data/shanghai-time.json index e9ef0adc05..796ede98f5 100644 --- a/packages/common/test/data/shanghai-time.json +++ b/packages/common/test/data/shanghai-time.json @@ -15,7 +15,8 @@ "arrowGlacierBlock": 0, "grayGlacierBlock": 0, "shanghaiTime": 1668699476, - "terminalTotalDifficulty": 9 + "terminalTotalDifficulty": 0, + "terminalTotalDifficultyPassed": true }, "alloc": { "0x0000000000000000000000000000000000000000": { diff --git a/packages/common/test/data/withdrawals-devnet.json b/packages/common/test/data/withdrawals-devnet.json index e9ef0adc05..796ede98f5 100644 --- a/packages/common/test/data/withdrawals-devnet.json +++ b/packages/common/test/data/withdrawals-devnet.json @@ -15,7 +15,8 @@ "arrowGlacierBlock": 0, "grayGlacierBlock": 0, "shanghaiTime": 1668699476, - "terminalTotalDifficulty": 9 + "terminalTotalDifficulty": 0, + "terminalTotalDifficultyPassed": true }, "alloc": { "0x0000000000000000000000000000000000000000": { diff --git a/packages/common/test/hardforks.spec.ts b/packages/common/test/hardforks.spec.ts index d7494e5421..fa929bd752 100644 --- a/packages/common/test/hardforks.spec.ts +++ b/packages/common/test/hardforks.spec.ts @@ -14,8 +14,6 @@ import { createCustomCommon, } from '../src/index.js' -import * as gethGenesisKilnJSON from './data/geth-genesis/geth-genesis-kiln.json' - import type { ChainConfig } from '../src/index.js' describe('[Common]: Hardfork logic', () => { @@ -383,7 +381,7 @@ describe('[Common]: Hardfork logic', () => { it('Should correctly apply hardfork changes', () => { // For sepolia MergeForkIdTransition happens AFTER merge - let c = new Common({ chain: Sepolia, hardfork: Hardfork.London }) + const c = new Common({ chain: Sepolia, hardfork: Hardfork.London }) assert.equal( c['HARDFORK_CHANGES'][11][0], Hardfork.Paris, @@ -413,43 +411,5 @@ describe('[Common]: Hardfork logic', () => { ConsensusType.ProofOfStake, `should stay on ProofOfStake consensus post merge`, ) - - // For kiln MergeForkIdTransition happens BEFORE Merge - c = createCommonFromGethGenesis(gethGenesisKilnJSON, { - chain: 'kiln', - mergeForkIdPostMerge: false, - }) - - // MergeForkIdTransition change should be before Merge - assert.equal( - c['HARDFORK_CHANGES'][10][0], - Hardfork.MergeForkIdTransition, - 'should correctly apply hardfork changes', - ) - assert.equal( - c['HARDFORK_CHANGES'][11][0], - Hardfork.Paris, - 'should correctly apply hardfork changes', - ) - - // Should give correct ConsensusType pre and post merge - c.setHardfork(Hardfork.London) - assert.equal( - c.consensusType(), - ConsensusType.ProofOfWork, - 'should provide the correct initial chain consensus type', - ) - c.setHardfork(Hardfork.Paris) - assert.equal( - c.consensusType(), - ConsensusType.ProofOfStake, - `should switch to ProofOfStake consensus on merge`, - ) - c.setHardfork(Hardfork.MergeForkIdTransition) - assert.equal( - c.consensusType(), - ConsensusType.ProofOfWork, - `should give pow consensus as MergeForkIdTransition is pre-merge`, - ) }) }) diff --git a/packages/common/test/mergePOS.spec.ts b/packages/common/test/mergePOS.spec.ts deleted file mode 100644 index d3255bad7d..0000000000 --- a/packages/common/test/mergePOS.spec.ts +++ /dev/null @@ -1,315 +0,0 @@ -import { assert, describe, it } from 'vitest' - -describe('[Common]: Merge/POS specific logic', () => { - it('hardforkTTD()', () => { - assert.ok('Everything fine, test here will go away anyhow! 🙂') - }) -}) - -/*describe('[Common]: Merge/POS specific logic', () => { - it('hardforkTTD()', () => { - const customChains = [testnetMerge] as ChainConfig[] - const c = new Common({ chain: testnetMerge, hardfork: Hardfork.Istanbul, customChains }) - assert.equal(c.hardforkTTD(Hardfork.Paris), BigInt(5000), 'should get the HF total difficulty') - assert.equal( - c.hardforkTTD('thisHardforkDoesNotExist'), - null, - 'should return null if HF does not exist on chain', - ) - }) - - it('getHardforkBy(), merge block null, with total difficulty', () => { - const customChains = [testnetMerge] as ChainConfig[] - const c = new Common({ chain: 'testnetMerge', hardfork: Hardfork.Istanbul, customChains }) - - let msg = 'block number < last HF block number set, without TD set' - assert.equal(c.getHardforkBy({ blockNumber: 0n }), 'chainstart', msg) - msg = 'block number > last HF block number set, without TD set' - assert.equal(c.getHardforkBy({ blockNumber: 14n }), 'london', msg) - msg = 'block number > last HF block number set, TD set and equal' - assert.equal(c.getHardforkBy({ blockNumber: 15n, td: 5000n }), 'paris', msg) - msg = 'block number > last HF block number set, TD set and higher' - assert.equal(c.getHardforkBy({ blockNumber: 15n, td: 5001n }), 'paris', msg) - msg = 'block number > last HF block number set, TD set and smaller' - assert.equal(c.getHardforkBy({ blockNumber: 15n, td: 4999n }), 'london', msg) - msg = 'block number < last HF block number set, TD set and smaller' - assert.equal(c.getHardforkBy({ blockNumber: 12n, td: 4999n }), 'berlin', msg) - }) - - it('getHardforkBy(), merge block set, with total difficulty', () => { - const testnetMergeWithBlockNumber = JSON.parse(JSON.stringify(testnetMerge)) - // Set Merge block to 15 - testnetMergeWithBlockNumber['hardforks'][8]['block'] = 16 - const customChains = [testnetMergeWithBlockNumber] - const c = new Common({ chain: 'testnetMerge', hardfork: Hardfork.Istanbul, customChains }) - - let msg = 'block number < last HF block number set, without TD set' - assert.equal(c.getHardforkBy({ blockNumber: 0n }), 'chainstart', msg) - msg = 'block number > last HF block number set, without TD set' - assert.equal(c.getHardforkBy({ blockNumber: 16n }), 'paris', msg) - msg = 'block number > last HF block number set, TD set and equal' - assert.equal(c.getHardforkBy({ blockNumber: 16n, td: 5000n }), 'paris', msg) - msg = 'block number > last HF block number set, TD set and higher' - assert.equal(c.getHardforkBy({ blockNumber: 16n, td: 5001n }), 'paris', msg) - msg = 'block number < last HF block number set, TD set and smaller' - assert.equal(c.getHardforkBy({ blockNumber: 12n, td: 4999n }), 'berlin', msg) - - try { - c.getHardforkBy({ blockNumber: 16n, td: 4999n }) - } catch (e: any) { - msg = 'block number > last HF block number set, TD set and smaller (should throw)' - const eMsg = 'Maximum HF determined by total difficulty is lower than the block number HF' - assert.ok(e.message.includes(eMsg), msg) - } - try { - c.getHardforkBy({ blockNumber: 14n, td: 5000n }) - } catch (e: any) { - msg = 'block number < last HF block number set, TD set and higher (should throw)' - const eMsg = 'HF determined by block number is lower than the minimum total difficulty HF' - assert.ok(e.message.includes(eMsg), msg) - } - }) - - it('getHardforkBy(), merge block set + subsequent HF, with total difficulty', () => { - const testnetMergeWithBlockNumber = JSON.parse(JSON.stringify(testnetMerge)) - // Set Merge block to 15 - testnetMergeWithBlockNumber['hardforks'][8]['block'] = 16 - // Set Shanghai block to 18 - testnetMergeWithBlockNumber['hardforks'][9]['block'] = 18 - const customChains = [testnetMergeWithBlockNumber] as ChainConfig[] - const c = new Common({ chain: 'testnetMerge', hardfork: Hardfork.Istanbul, customChains }) - - const msg = 'block number > last HF block number set, TD set and higher' - assert.equal(c.getHardforkBy({ blockNumber: 18n, td: 5001n }), 'shanghai', msg) - }) - - it('setHardforkBy(), merge block null, with total difficulty', () => { - const customChains = [testnetMerge] as ChainConfig[] - const c = new Common({ chain: 'testnetMerge', hardfork: Hardfork.Istanbul, customChains }) - - let msg = 'block number < last HF block number set, without TD set' - assert.equal(c.setHardforkBy({ blockNumber: 0n }), 'chainstart', msg) - msg = 'block number > last HF block number set, without TD set' - assert.equal(c.setHardforkBy({ blockNumber: 14n }), 'london', msg) - msg = 'block number > last HF block number set, TD set and equal' - assert.equal(c.setHardforkBy({ blockNumber: 15n, td: 5000n }), 'paris', msg) - msg = 'block number > last HF block number set, TD set and higher' - assert.equal(c.setHardforkBy({ blockNumber: 15n, td: 5001n }), 'paris', msg) - msg = 'block number > last HF block number set, TD set and smaller' - assert.equal(c.setHardforkBy({ blockNumber: 15n, td: 4999n }), 'london', msg) - msg = 'block number < last HF block number set, TD set and smaller' - assert.equal(c.setHardforkBy({ blockNumber: 12n, td: 4999n }), 'berlin', msg) - }) - - it('setHardforkBy(), merge block set, with total difficulty', () => { - const testnetMergeWithBlockNumber = JSON.parse(JSON.stringify(testnetMerge)) - // Set Merge block to 15 - testnetMergeWithBlockNumber['hardforks'][8]['block'] = 16 - const customChains = [testnetMergeWithBlockNumber] - const c = new Common({ chain: 'testnetMerge', hardfork: Hardfork.Istanbul, customChains }) - - let msg = 'block number < last HF block number set, without TD set' - assert.equal(c.setHardforkBy({ blockNumber: 0n }), 'chainstart', msg) - msg = 'block number > last HF block number set, without TD set' - assert.equal(c.setHardforkBy({ blockNumber: 16n }), 'paris', msg) - msg = 'block number > last HF block number set, TD set and equal' - assert.equal(c.setHardforkBy({ blockNumber: 16n, td: 5000n }), 'paris', msg) - msg = 'block number > last HF block number set, TD set and higher' - assert.equal(c.setHardforkBy({ blockNumber: 16n, td: 5001n }), 'paris', msg) - msg = 'block number < last HF block number set, TD set and smaller' - assert.equal(c.setHardforkBy({ blockNumber: 12n, td: 4999n }), 'berlin', msg) - - try { - c.setHardforkBy({ blockNumber: 16n, td: 4999n }) - assert.fail(`should have thrown td < ttd validation error`) - } catch (e: any) { - msg = 'block number > last HF block number set, TD set and smaller (should throw)' - const eMsg = 'Maximum HF determined by total difficulty is lower than the block number HF' - assert.ok(e.message.includes(eMsg), msg) - } - try { - c.setHardforkBy({ blockNumber: 14n, td: 5001n }) - assert.fail(`should have thrown td > ttd validation error`) - } catch (e: any) { - msg = 'block number < last HF block number set, TD set and higher (should throw)' - const eMsg = 'HF determined by block number is lower than the minimum total difficulty HF' - assert.ok(e.message.includes(eMsg), msg) - } - }) - - it('setHardforkBy(), merge block set + subsequent HF, with total difficulty', () => { - const testnetMergeWithBlockNumber = JSON.parse(JSON.stringify(testnetMerge)) - // Set Merge block to 15 - testnetMergeWithBlockNumber['hardforks'][8]['block'] = 16 - // Set Shanghai block to 18 - testnetMergeWithBlockNumber['hardforks'][9]['block'] = 18 - const customChains = [testnetMergeWithBlockNumber] - const c = new Common({ chain: 'testnetMerge', hardfork: Hardfork.Istanbul, customChains }) - - const msg = 'block number > last HF block number set, TD set and higher' - assert.equal(c.setHardforkBy({ blockNumber: 18n, td: 5001n }), 'shanghai', msg) - }) - - it('Pure POS testnet', () => { - const customChains = [testnetPOS] as ChainConfig[] - const c = new Common({ chain: 'testnetPOS', hardfork: Hardfork.Chainstart, customChains }) - - assert.equal( - c.hardforkTTD(Hardfork.Chainstart), - BigInt(0), - 'should get the HF total difficulty', - ) - - const msg = 'block number > last HF block number set, TD set (0) and equal' - assert.equal(c.getHardforkBy({ blockNumber: 5n, td: 0n }), 'shanghai', msg) - }) - - it('Should fail setting invalid hardfork', () => { - const customChains = [testnetPOS] as ChainConfig[] - const f = () => { - new Common({ chain: 'testnetPOS', hardfork: Hardfork.Istanbul, customChains }) - } - assert.throws(f, undefined, undefined, `failed setting absent hardfork instanbul`) - }) - - it('should get the correct merge hardfork at genesis', async () => { - const c = createCommonFromGethGenesis(postMergeJSON, { chain: 'post-merge' }) - const msg = 'should get HF correctly' - assert.equal(c.getHardforkBy({ blockNumber: 0n }), Hardfork.London, msg) - assert.equal(c.getHardforkBy({ blockNumber: 0n, td: 0n }), Hardfork.Paris, msg) - }) - - it('test post merge hardforks using Sepolia with block null', () => { - const c = new Common({ chain: Sepolia }) - let msg = 'should get HF correctly' - - assert.equal(c.getHardforkBy({ blockNumber: 0n }), Hardfork.London, msg) - // Make it null manually as config could be updated later - const mergeHf = c.hardforks().filter((hf) => hf.ttd !== undefined && hf.ttd !== null)[0] - const prevMergeBlockVal = mergeHf.block - mergeHf.block = null - - // should get Hardfork.London even though happened with 1450408 as terminal as config doesn't have that info - assert.equal(c.getHardforkBy({ blockNumber: 1450409n }), Hardfork.London, msg) - // however with correct td in input it should select merge - assert.equal( - c.getHardforkBy({ blockNumber: 1450409n, td: 17000000000000000n }), - Hardfork.Paris, - msg, - ) - // should select MergeForkIdTransition even without td specified as the block is set for this hardfork - assert.equal(c.getHardforkBy({ blockNumber: 1735371n }), Hardfork.MergeForkIdTransition, msg) - // also with td specified - assert.equal( - c.getHardforkBy({ blockNumber: 1735371n, td: 17000000000000000n }), - Hardfork.MergeForkIdTransition, - msg, - ) - - // Check nextHardforkBlockOrTimestamp should be MergeForkIdTransition's block on london and merge both - assert.equal( - c.nextHardforkBlockOrTimestamp(Hardfork.Berlin), - 1735371n, - `should get nextHardforkBlockOrTimestamp correctly`, - ) - assert.equal( - c.nextHardforkBlockOrTimestamp(Hardfork.London), - 1735371n, - `should get nextHardforkBlockOrTimestamp correctly`, - ) - assert.equal( - c.nextHardforkBlockOrTimestamp(Hardfork.Paris), - 1735371n, - `should get nextHardforkBlockOrTimestamp correctly`, - ) - - let f = () => { - c.getHardforkBy({ blockNumber: 1735371n, td: 15000000000000000n }) - } - assert.throws( - f, - undefined, - undefined, - 'throws error as specified td < merge ttd for a post merge hardfork', - ) - - msg = 'should set HF correctly' - - assert.equal(c.setHardforkBy({ blockNumber: 0n }), Hardfork.London, msg) - assert.equal(c.setHardforkBy({ blockNumber: 1450409n }), Hardfork.London, msg) - assert.equal( - c.setHardforkBy({ blockNumber: 1450409n, td: 17000000000000000n }), - Hardfork.Paris, - msg, - ) - assert.equal(c.setHardforkBy({ blockNumber: 1735371n }), Hardfork.MergeForkIdTransition, msg) - assert.equal( - c.setHardforkBy({ blockNumber: 1735371n, td: 17000000000000000n }), - Hardfork.MergeForkIdTransition, - msg, - ) - f = () => { - c.setHardforkBy({ blockNumber: 1735371n, td: 15000000000000000n }) - } - assert.throws( - f, - undefined, - undefined, - 'throws error as specified td < merge ttd for a post merge hardfork', - ) - - // restore value - mergeHf.block = prevMergeBlockVal - }) - - it('should get correct merge and post merge hf with merge block specified ', () => { - const c = new Common({ chain: Sepolia }) - - const mergeHf = c.hardforks().filter((hf) => hf.ttd !== undefined && hf.ttd !== null)[0] - const prevMergeBlockVal = mergeHf.block - // the terminal block on sepolia is 1450408 - mergeHf.block = 1450409 - const msg = 'should get HF correctly' - - // should get merge even without td supplied as the merge hf now has the block specified - assert.equal(c.setHardforkBy({ blockNumber: 1450409n }), Hardfork.Paris, msg) - assert.equal( - c.setHardforkBy({ blockNumber: 1450409n, td: 17000000000000000n }), - Hardfork.Paris, - msg, - ) - assert.equal(c.setHardforkBy({ blockNumber: 1735371n }), Hardfork.MergeForkIdTransition, msg) - assert.equal( - c.setHardforkBy({ blockNumber: 1735371n, td: 17000000000000000n }), - Hardfork.MergeForkIdTransition, - msg, - ) - - // Check nextHardforkBlockOrTimestamp should be MergeForkIdTransition's block on london and merge both - assert.equal( - c.nextHardforkBlockOrTimestamp(Hardfork.London), - 1735371n, - `should get nextHardforkBlockOrTimestamp correctly`, - ) - assert.equal( - c.nextHardforkBlockOrTimestamp(Hardfork.Paris), - 1735371n, - `should get nextHardforkBlockOrTimestamp correctly`, - ) - - // restore value - mergeHf.block = prevMergeBlockVal - }) - - it('should throw if encounters a double ttd hardfork specification', () => { - const c = new Common({ chain: Sepolia }) - // Add the ttd to mergeForkIdTransition which occurs post merge in sepolia - c.hardforks().filter((hf) => hf.name === 'mergeForkIdTransition')[0]!['ttd'] = - '17000000000000000' - - const f = () => { - c.setHardforkBy({ blockNumber: 1735371n }) - } - assert.throws(f, undefined, undefined, 'throws error as two hardforks with ttd specified') - }) -})*/ diff --git a/packages/common/test/params.spec.ts b/packages/common/test/params.spec.ts index 5612500435..9e0b913c7d 100644 --- a/packages/common/test/params.spec.ts +++ b/packages/common/test/params.spec.ts @@ -93,10 +93,6 @@ describe('[Common]: Parameter access for param(), paramByHardfork()', () => { msg = 'Should correctly translate block numbers into HF states (original value)' assert.equal(c.paramByBlock('minerReward', 4369999), BigInt(5000000000000000000), msg) - - msg = 'Should correctly translate total difficulty into HF states' - const td = BigInt('1196768507891266117779') - assert.equal(c.paramByBlock('minerReward', 4370000, td), BigInt(3000000000000000000), msg) }) it('Access on copied Common instances', () => { diff --git a/packages/common/test/utils.spec.ts b/packages/common/test/utils.spec.ts index 8ec8ef4714..01bdc1704f 100644 --- a/packages/common/test/utils.spec.ts +++ b/packages/common/test/utils.spec.ts @@ -1,4 +1,3 @@ -import { hexToBytes } from '@ethereumjs/util' import { assert, describe, it } from 'vitest' import { Mainnet } from '../src/chains.js' @@ -6,7 +5,6 @@ import { createCommonFromGethGenesis } from '../src/constructors.js' import { Hardfork } from '../src/enums.js' import { parseGethGenesis } from '../src/utils.js' -import * as gethGenesisKilnJSON from './data/geth-genesis/geth-genesis-kiln.json' import * as invalidSpuriousDragonJSON from './data/geth-genesis/invalid-spurious-dragon.json' import * as noExtraDataJSON from './data/geth-genesis/no-extra-data.json' import * as poaJSON from './data/geth-genesis/poa.json' @@ -36,7 +34,7 @@ describe('[Utils/Parse]', () => { 'consensus config matches', ) const poaJSONCopy = Object.assign({}, poaJSON) - poaJSONCopy.nonce = '00' + poaJSONCopy.default.nonce = '00' params = parseGethGenesis(poaJSONCopy, 'poa') assert.equal( params.genesis.nonce, @@ -48,7 +46,7 @@ describe('[Utils/Parse]', () => { it('should generate expected hash with london block zero and base fee per gas defined', async () => { const params = parseGethGenesis(postMergeJSON, 'post-merge') - assert.equal(params.genesis.baseFeePerGas, postMergeJSON.baseFeePerGas) + assert.equal(params.genesis.baseFeePerGas, postMergeJSON.default.baseFeePerGas) }) it('should successfully parse genesis file with no extraData', async () => { @@ -57,122 +55,24 @@ describe('[Utils/Parse]', () => { assert.equal(params.genesis.timestamp, '0x10', 'timestamp parsed correctly') }) - it('should successfully parse kiln genesis and set forkhash', async () => { - const common = createCommonFromGethGenesis(gethGenesisKilnJSON, { - chain: 'customChain', - genesisHash: hexToBytes('0x51c7fe41be669f69c45c33a56982cbde405313342d9e2b00d7c91a7b284dd4f8'), - mergeForkIdPostMerge: false, - }) - assert.deepEqual( - common.hardforks().map((hf) => hf.name), - [ - 'chainstart', - 'homestead', - 'tangerineWhistle', - 'spuriousDragon', - 'byzantium', - 'constantinople', - 'petersburg', - 'istanbul', - 'berlin', - 'london', - 'mergeForkIdTransition', - 'paris', - ], - 'hardfork parse order should be correct', - ) - for (const hf of common.hardforks()) { - /* eslint-disable @typescript-eslint/no-use-before-define */ - assert.equal(hf.forkHash, kilnForkHashes[hf.name], `${hf.name} forkHash should match`) - } - - assert.equal(common.hardfork(), Hardfork.Paris, 'should correctly infer current hardfork') - - // Ok lets schedule shanghai at block 0, this should force merge to be scheduled at just after - // genesis if even mergeForkIdTransition is not confirmed to be post merge - // This will also check if the forks are being correctly sorted based on block - Object.assign(gethGenesisKilnJSON.config, { shanghaiTime: Math.floor(Date.now() / 1000) }) - const common1 = createCommonFromGethGenesis(gethGenesisKilnJSON, { - chain: 'customChain', - }) - // merge hardfork is now scheduled just after shanghai even if mergeForkIdTransition is not confirmed - // to be post merge - assert.deepEqual( - common1.hardforks().map((hf) => hf.name), - [ - 'chainstart', - 'homestead', - 'tangerineWhistle', - 'spuriousDragon', - 'byzantium', - 'constantinople', - 'petersburg', - 'istanbul', - 'berlin', - 'london', - 'paris', - 'mergeForkIdTransition', - 'shanghai', - ], - 'hardfork parse order should be correct', - ) - - assert.equal(common1.hardfork(), Hardfork.Shanghai, 'should correctly infer current hardfork') + it('should set merge to block 0 when terminalTotalDifficultyPassed is true', () => { + const mergeAtGenesisJson = {} as any + Object.assign(mergeAtGenesisJson, postMergeJSON) + mergeAtGenesisJson.config.terminalTotalDifficultyPassed = true + const common = createCommonFromGethGenesis(mergeAtGenesisJson, {}) + assert.equal(common.hardforks().slice(-1)[0].block, 0) }) - it('should successfully parse genesis with hardfork scheduled post merge', async () => { - const common = createCommonFromGethGenesis(postMergeHardforkJSON, { - chain: 'customChain', - }) - assert.deepEqual( - common.hardforks().map((hf) => hf.name), - [ - 'chainstart', - 'homestead', - 'tangerineWhistle', - 'spuriousDragon', - 'byzantium', - 'constantinople', - 'petersburg', - 'istanbul', - 'muirGlacier', - 'berlin', - 'london', - 'paris', - 'shanghai', - ], - 'hardfork parse order should be correct', - ) - - assert.equal(common.getHardforkBy({ blockNumber: 0n }), Hardfork.London, 'london at genesis') - assert.equal( - common.getHardforkBy({ blockNumber: 1n, td: 2n }), - Hardfork.Paris, - 'merge at block 1', - ) - // shanghai is at timestamp 8 - assert.equal( - common.getHardforkBy({ blockNumber: 8n }), - Hardfork.London, - 'without timestamp still london', - ) - assert.equal( - common.getHardforkBy({ blockNumber: 8n, td: 2n }), - Hardfork.Paris, - 'without timestamp at merge', - ) - assert.equal( - common.getHardforkBy({ blockNumber: 8n, timestamp: 8n }), - Hardfork.Shanghai, - 'with timestamp at shanghai', - ) - // should be post merge at shanghai - assert.equal( - common.getHardforkBy({ blockNumber: 8n, td: 2n, timestamp: 8n }), - Hardfork.Shanghai, - 'post merge shanghai', - ) - assert.equal(common.hardfork(), Hardfork.Shanghai, 'should correctly infer common hardfork') + it('should set merge to block 0 when terminalTotalDifficultyPassed is true', () => { + const mergeAtGenesisJson = {} as any + Object.assign(mergeAtGenesisJson, postMergeJSON) + mergeAtGenesisJson.config.terminalTotalDifficultyPassed = false + try { + createCommonFromGethGenesis(mergeAtGenesisJson, {}) + assert.fail('should have thrown') + } catch (err: any) { + assert.ok(err.message.includes('nonzero terminal total difficulty')) + } }) it('should successfully assign mainnet deposit contract address when none provided', async () => { @@ -209,18 +109,3 @@ describe('[Utils/Parse]', () => { ) }) }) - -const kilnForkHashes: any = { - chainstart: '0xbcadf543', - homestead: '0xbcadf543', - tangerineWhistle: '0xbcadf543', - spuriousDragon: '0xbcadf543', - byzantium: '0xbcadf543', - constantinople: '0xbcadf543', - petersburg: '0xbcadf543', - istanbul: '0xbcadf543', - berlin: '0xbcadf543', - london: '0xbcadf543', - mergeForkIdTransition: '0x013fd1b5', - paris: '0x013fd1b5', -} diff --git a/packages/vm/src/runBlock.ts b/packages/vm/src/runBlock.ts index c574a23972..3c637932a6 100644 --- a/packages/vm/src/runBlock.ts +++ b/packages/vm/src/runBlock.ts @@ -113,12 +113,6 @@ export async function runBlock(vm: VM, opts: RunBlockOpts): Promise { if (vm['_opts'].profilerOpts?.reportAfterTx === true) { @@ -107,23 +83,11 @@ export async function runTx(vm: VM, opts: RunTxOpts): Promise { opts.block = opts.block ?? createBlock({}, { common: vm.common }) if (opts.skipHardForkValidation !== true) { - // Find and set preMerge hf for easy access later - const hfs = vm.common.hardforks() - const preMergeIndex = hfs.findIndex((hf) => hf.ttd !== null && hf.ttd !== undefined) - 1 - // If no pre merge hf found, set it to first hf even if its merge - const preMergeHf = preMergeIndex >= 0 ? hfs[preMergeIndex].name : hfs[0].name - // If block and tx don't have a same hardfork, set tx hardfork to block - if ( - execHardfork(opts.tx.common.hardfork(), preMergeHf) !== - execHardfork(opts.block.common.hardfork(), preMergeHf) - ) { + if (opts.tx.common.hardfork() !== opts.block.common.hardfork()) { opts.tx.common.setHardfork(opts.block.common.hardfork()) } - if ( - execHardfork(opts.block.common.hardfork(), preMergeHf) !== - execHardfork(vm.common.hardfork(), preMergeHf) - ) { + if (opts.block.common.hardfork() !== vm.common.hardfork()) { // Block and VM's hardfork should match as well const msg = _errorMsg('block has a different hardfork than the vm', vm, opts.block, opts.tx) throw new Error(msg) diff --git a/packages/vm/src/types.ts b/packages/vm/src/types.ts index 7b35718782..16e59c1bd7 100644 --- a/packages/vm/src/types.ts +++ b/packages/vm/src/types.ts @@ -300,12 +300,9 @@ export interface RunBlockOpts { * Set the hardfork either by timestamp (for HFs from Shanghai onwards) or by block number * for older Hfs. * - * Additionally it is possible to pass in a specific TD value to support live-Merge-HF - * transitions. Note that this should only be needed in very rare and specific scenarios. - * * Default: `false` (HF is set to whatever default HF is set by the {@link Common} instance) */ - setHardfork?: boolean | BigIntLike + setHardfork?: boolean /** * If true, adds a hashedKey -> preimages mapping of all touched accounts diff --git a/packages/vm/test/api/runTx.spec.ts b/packages/vm/test/api/runTx.spec.ts index ca206bcc43..93ba381dff 100644 --- a/packages/vm/test/api/runTx.spec.ts +++ b/packages/vm/test/api/runTx.spec.ts @@ -140,28 +140,6 @@ describe('runTx() -> successful API parameter usage', async () => { assert.ok(true, 'runTx should not fail with mismatching hardforks if validation skipped') }) - it('should ignore merge in hardfork mismatch', async () => { - const common = new Common({ chain: Mainnet, hardfork: Hardfork.Paris }) - const vm = await VM.create({ - common, - blockchain: await createBlockchain({ validateConsensus: false, validateBlocks: false }), - }) - const tx = getTransaction(vm.common, 0, true) - const caller = tx.getSenderAddress() - const acc = createAccountWithDefaults() - await vm.stateManager.putAccount(caller, acc) - const block = createBlock({}, { common: vm.common.copy() }) - - tx.common.setHardfork(Hardfork.GrayGlacier) - block.common.setHardfork(Hardfork.GrayGlacier) - try { - await runTx(vm, { tx, block }) - assert.ok(true, 'successfully ignored merge hf while hf matching in runTx') - } catch (e) { - assert.fail('should have ignored merge hf while matching in runTx') - } - }) - it('should use passed in blockGasUsed to generate tx receipt', async () => { const common = new Common({ chain: Mainnet, hardfork: Hardfork.Istanbul }) const vm = await VM.create({ common }) diff --git a/packages/vm/test/api/tester/tester.config.spec.ts b/packages/vm/test/api/tester/tester.config.spec.ts index e67e7bb56e..7dea44a143 100644 --- a/packages/vm/test/api/tester/tester.config.spec.ts +++ b/packages/vm/test/api/tester/tester.config.spec.ts @@ -42,7 +42,6 @@ describe('test runner config tests', () => { const str = testCase.hf + 'ToMergeAtDiff' + testCase.TTD.toString(16) const common = getCommon(str) assert.ok(common.hardfork() === testCase.hf) - assert.ok(common.hardforkTTD('paris') === BigInt(testCase.TTD)) }) }) it('should throw on a non-existing fork', () => {