]> git.ardis.lu - block-hash-calculator/commitdiff
Don't cast block.nonce to number
authorArdis Lu <ardisglu@gmail.com>
Tue, 21 May 2024 06:39:47 +0000 (23:39 -0700)
committerArdis Lu <ardisglu@gmail.com>
Tue, 21 May 2024 06:39:47 +0000 (23:39 -0700)
It should've always been a string of hex bytes, it just worked as a number by coincidence.

calculate.js
calculate.test.js

index 3cc81b3d566aa0ad58bdccc63bcbc090dc28ff4d..ae0ecbce3f6ca4314f955d6b87d09b68c47d6ba2 100644 (file)
@@ -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
index 69d3d42984e029d600b16f529b0e3dc74af6e085..0bcbffef44a5ccc99c6b4a94d94fd8ed33c75c11 100644 (file)
@@ -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",
This page took 0.034467 seconds and 4 git commands to generate.