From bcc5863f99517396521705b22bf57cf0a95c5c1f Mon Sep 17 00:00:00 2001 From: Ardis Lu Date: Mon, 20 May 2024 23:39:47 -0700 Subject: [PATCH] Don't cast block.nonce to number It should've always been a string of hex bytes, it just worked as a number by coincidence. --- calculate.js | 7 +++---- calculate.test.js | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/calculate.js b/calculate.js index 3cc81b3..ae0ecbc 100644 --- a/calculate.js +++ b/calculate.js @@ -23,7 +23,7 @@ function calculate(block) { BigInt(block.timestamp), block.extraData, block.mixHash, - BigInt(block.nonce) + block.nonce ]; // Avalanche Apricot Phase 1 (no specification) @@ -47,9 +47,8 @@ function calculate(block) { // Paris hard fork // https://eips.ethereum.org/EIPS/eip-3675#block-structure - if (block.nonce === '0x0000000000000000') { - header[14] = '0x0000000000000000'; // MUST be string and not a number - } + // Hardcodes block.nonce to '0x0000000000000000'. + // No code change required, just FYI. // Shapella hard fork // https://eips.ethereum.org/EIPS/eip-4895#new-field-in-the-execution-payload-header-withdrawals-root diff --git a/calculate.test.js b/calculate.test.js index 69d3d42..0bcbffe 100644 --- a/calculate.test.js +++ b/calculate.test.js @@ -4,7 +4,7 @@ import { deepStrictEqual } from 'node:assert/strict'; import { calculate } from './calculate.js'; suite('Ethereum', { concurrency: true }, () => { - test('Block number 0', { skip: true, concurrency: true }, () => { + test('Block number 0', { concurrency: true }, () => { const { hash } = calculate({ "difficulty": "0x400000000", "extraData": "0x11bbe8db4e347b4e8c937c1c8370e4b5ed33adb3db69cbdb7a38e1e50b1b82fa", -- 2.47.3