From 5d950ffaebd588da159f2c8f77ad03bf4d0ea854 Mon Sep 17 00:00:00 2001 From: Jochem Brouwer Date: Sun, 21 May 2023 09:34:22 +0200 Subject: [PATCH 1/3] block: swap withdrawal/opts in constructor --- packages/block/src/block.ts | 8 ++++---- packages/block/test/mergeBlock.spec.ts | 14 ++++++++++---- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/packages/block/src/block.ts b/packages/block/src/block.ts index 659a1c55d5..4067e73401 100644 --- a/packages/block/src/block.ts +++ b/packages/block/src/block.ts @@ -136,7 +136,7 @@ export class Block { const withdrawals = withdrawalsData?.map(Withdrawal.fromWithdrawalData) - return new Block(header, transactions, uncleHeaders, opts, withdrawals) + return new Block(header, transactions, uncleHeaders, withdrawals, opts) } /** @@ -221,7 +221,7 @@ export class Block { })) ?.map(Withdrawal.fromWithdrawalData) - return new Block(header, transactions, uncleHeaders, opts, withdrawals) + return new Block(header, transactions, uncleHeaders, withdrawals, opts) } /** @@ -379,8 +379,8 @@ export class Block { header?: BlockHeader, transactions: TypedTransaction[] = [], uncleHeaders: BlockHeader[] = [], - opts: BlockOptions = {}, - withdrawals?: Withdrawal[] + withdrawals?: Withdrawal[], + opts: BlockOptions = {} ) { this.header = header ?? BlockHeader.fromHeaderData({}, opts) this._common = this.header._common diff --git a/packages/block/test/mergeBlock.spec.ts b/packages/block/test/mergeBlock.spec.ts index 085ac6962b..36666fb2eb 100644 --- a/packages/block/test/mergeBlock.spec.ts +++ b/packages/block/test/mergeBlock.spec.ts @@ -40,7 +40,7 @@ tape('[Header]: Casper PoS / The Merge Functionality', function (t) { const header = BlockHeader.fromHeaderData({}, { common }) validateMergeHeader(st, header) - const block = new Block(undefined, undefined, undefined, { common }) + const block = new Block(undefined, undefined, undefined, undefined, { common }) validateMergeHeader(st, block.header) st.end() @@ -106,9 +106,15 @@ tape('[Header]: Casper PoS / The Merge Functionality', function (t) { t.test('test that a PoS block with uncles cannot be produced', function (st) { try { - new Block(undefined, undefined, [BlockHeader.fromHeaderData(undefined, { common })], { - common, - }) + new Block( + undefined, + undefined, + [BlockHeader.fromHeaderData(undefined, { common })], + undefined, + { + common, + } + ) st.fail('should have thrown') } catch (e: any) { st.pass('should throw') From fad65f4589ce13d894591e2ee28f6c0b75199b48 Mon Sep 17 00:00:00 2001 From: Jochem Brouwer Date: Sun, 21 May 2023 09:59:04 +0200 Subject: [PATCH 2/3] blockchain: fix pkg --- packages/blockchain/src/blockchain.ts | 2 +- packages/blockchain/test/util.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/blockchain/src/blockchain.ts b/packages/blockchain/src/blockchain.ts index a97864e325..ac506081ca 100644 --- a/packages/blockchain/src/blockchain.ts +++ b/packages/blockchain/src/blockchain.ts @@ -418,7 +418,7 @@ export class Blockchain implements BlockchainInterface { try { const block = item instanceof BlockHeader - ? new Block(item, undefined, undefined, { + ? new Block(item, undefined, undefined, undefined, { common: item._common, }) : item diff --git a/packages/blockchain/test/util.ts b/packages/blockchain/test/util.ts index 0f303811d0..a280c90105 100644 --- a/packages/blockchain/test/util.ts +++ b/packages/blockchain/test/util.ts @@ -98,7 +98,7 @@ export const generateConsecutiveBlock = ( } ) - const block = new Block(header, undefined, undefined, { common }) + const block = new Block(header, undefined, undefined, undefined, { common }) return block } From 5a3fe6617dacb85c4d412975aa259500e076f0e5 Mon Sep 17 00:00:00 2001 From: Jochem Brouwer Date: Tue, 23 May 2023 17:24:44 +0200 Subject: [PATCH 3/3] vm: fix test runner --- packages/vm/test/tester/runners/GeneralStateTestsRunner.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/vm/test/tester/runners/GeneralStateTestsRunner.ts b/packages/vm/test/tester/runners/GeneralStateTestsRunner.ts index e6bc82ed4d..3c630868a0 100644 --- a/packages/vm/test/tester/runners/GeneralStateTestsRunner.ts +++ b/packages/vm/test/tester/runners/GeneralStateTestsRunner.ts @@ -79,7 +79,7 @@ async function runTestCase(options: any, testData: any, t: tape.Test) { // Have to create a blockchain with empty block as genesisBlock for Merge // Otherwise mainnet genesis will throw since this has difficulty nonzero - const genesisBlock = new Block(undefined, undefined, undefined, { common }) + const genesisBlock = new Block(undefined, undefined, undefined, undefined, { common }) const blockchain = await Blockchain.create({ genesisBlock, common }) const state = new Trie({ useKeyHashing: true }) const stateManager = new DefaultStateManager({