]> zoso.dev Git - nano-pow.git/commitdiff
Extend random input to shader to accomodate validation of nonces.
authorChris Duncan <chris@zoso.dev>
Sun, 12 Jan 2025 06:11:10 +0000 (22:11 -0800)
committerChris Duncan <chris@zoso.dev>
Sun, 12 Jan 2025 06:11:10 +0000 (22:11 -0800)
src/classes/gpu.ts
src/shaders/compute.wgsl

index 85d907b7b4675c580872ce4941da39247614ab06..7b825f3942de6e7b43c591679d4dbd18b293ac0a 100644 (file)
@@ -141,7 +141,8 @@ export class NanoPowGpu {
                        }
                        const random = Math.floor((Math.random() * 0xffffffff))
                        uboView.setUint32(32, random, true)
-                       uboView.setUint32(36, threshold, true)
+                       uboView.setUint32(36, random, true)
+                       uboView.setUint32(40, threshold, true)
                        this.#device.queue.writeBuffer(this.#uboBuffer, 0, uboView)
 
                        // Reset `nonce` and `found` to 0u in WORK before each calculation
index 8036a7d5d65e7ac52496c5cb1f0c99b0033e251d..354b65fb931a2eafd70a4c687750f08330c4ce9e 100644 (file)
@@ -3,7 +3,7 @@
 
 struct UBO {
        blockhash: array<vec4<u32>, 2>,
-       random: u32,
+       random: vec2<u32>,
        threshold: u32
 };
 @group(0) @binding(0) var<uniform> ubo: UBO;
@@ -35,8 +35,8 @@ fn main(@builtin(global_invocation_id) id: vec3<u32>) {
        /**
        * Initialize (nonce||blockhash) concatenation
        */
-       var m0: u32 = ubo.random ^ id.x;
-       var m1: u32 = ubo.random ^ id.y;
+       var m0: u32 = ubo.random.x ^ id.x;
+       var m1: u32 = ubo.random.y ^ id.y;
        var m2: u32 = ubo.blockhash[0u].x;
        var m3: u32 = ubo.blockhash[0u].y;
        var m4: u32 = ubo.blockhash[0u].z;