Chris Duncan [Wed, 18 Jun 2025 20:21:44 +0000 (13:21 -0700)]
Unblock CPU loop.
CPU work_generate now returns a promise and iterates a limited loop before re-calling itself on the next animation frame. This unblocks the main thread and allows the environment to reload properly, i.e. refresh the browser tab.
Chris Duncan [Wed, 18 Jun 2025 14:29:42 +0000 (07:29 -0700)]
Move server execution into npm script.
This simplifies the bash script. It also allows the example systemd service to use a Type of "simple" and eliminates the PIDFile requirement. The console output is unnecessary when using systemd since the expectation is that logs go to the journal only.
Chris Duncan [Wed, 18 Jun 2025 14:29:42 +0000 (07:29 -0700)]
Move server execution into npm script.
This simplifies the bash script. It also allows the example systemd service to use a Type of "simple" and eliminates the PIDFile requirement. The console output is unnecessary when using systemd since the expectation is that logs go to the journal only.
Chris Duncan [Sat, 14 Jun 2025 18:41:48 +0000 (11:41 -0700)]
Add and update available APIs.
Add WASM and CPU implementations.
Add API options parameter.
Add scripts to generate shaders and AssemblyScript.
Add sample systemd service for server.
Add Logger and Queue utility classes.
Fix CLI and server IPC.
Add WorkErrorResponse type.
Improve type checking and config checking.
Move generate APIs into their own directory.
Chris Duncan [Tue, 6 May 2025 21:41:36 +0000 (14:41 -0700)]
Extract some basic shared code into utils file and bundle it. Simplify lib exports. Introduce new typings for server config and PoW results. Clean up CLI and fix some minor issues. Limit Node heap to improve CLI and server performance. Refactor server to extract code into manageable helper functions, improve organization, and fix some minor issues. Restrict difficulty to maximum of network difficulty to mitigate DoS attacks. Merge shared code in work calls in GPU implementation and extract it into modular functions. Implement work queue to better manage inbound requests. Fix nonce check in compute shader. Fix test page benchmark results from not being sorted properly. Update server test script.
Chris Duncan [Tue, 22 Apr 2025 21:52:14 +0000 (14:52 -0700)]
In CLI, capture logging from spawned server process. In compute shader, fix difficulty comparison of low bits, reduce workgroup size to 64, and update doc comments. In GPU, fix bug in load loop that checks for the GPU device, share bind group as static variable between pipelines, dispatch once on setup to compile and cache shader prior to actual work calls, save compute results in static variable to reduce memory footprint, lower timeout when tool is busy, allow difficulty of zero, eliminate a Math.random() call by implementing a sliding randomness value for the search seed, and throw an error if work to validate does not match nonce returned by compute result. In launch script, add max HTTP header size limit to protect server process. In test script, check more generate calls. In package, reduce run size of benchmark. In server, replace temp file for puppeteer page with intercepted HTTPS request to gain secure context for WebGPU, send logs over IPC to CLI, implement more constants for attack vector protection, add rate limiter using tokens per IP address, tweak error messaging, cache NanoPow library in puppeteer handle, split work calls by action for puppeteer evaluation, tweak puppeteer browser launch flags, and explicitly listen on localhost.
Chris Duncan [Mon, 14 Apr 2025 16:32:52 +0000 (09:32 -0700)]
Save server logs by day instead of by execution. Display server process ID on every log entry instead of just once when starting server. Adjust log timestamp formatting.
Chris Duncan [Mon, 14 Apr 2025 15:27:45 +0000 (08:27 -0700)]
Use SIGHUP to reload config except PORT which requires relaunching the server. Refactor CLI to spawn server as child process and get port from OS dynamically using IPC. Fix fast exit by handling SIGINT and SIGTERM ourselves.
Chris Duncan [Sun, 13 Apr 2025 04:59:01 +0000 (21:59 -0700)]
Print server error if it does not launch, typically due to puppeteer issue. Reset on error reading from GPU instead of trying an infinite dispatch loop. Reduce interval for checking that GPU is not busy to half a second. Reset initialization flag when resetting NanoPowGpu. Fix abort call on timeout in cli. Extend CLI abort timeout to a full minute to accomodate low-power devices. Fix whitespace for inline help.
Chris Duncan [Sat, 12 Apr 2025 05:13:42 +0000 (22:13 -0700)]
Simplify GPU compute by reverting to vec2 and implementing G function since performance difference is almost nonexistent and the real benefit comes from native u64 types which do not yet exist in WGSL. Increase workgroup size to best value 96 found during testing on RTX 3070. Create --benchmark CLI argument. Store seed and blockhash in fast shared workgroup memory. Add benchmark convenience npm script. Fix documentation in inline help and manual page. Fix CLI default port collision with server default port. Change timestamp on server log files. Test concurrent curl requests to server. Fix action listed in server response error message. Update puppeteer and test page HTML with blank favicon to prevent unnecessary load.
Chris Duncan [Thu, 27 Mar 2025 21:03:44 +0000 (14:03 -0700)]
Overhaul server to consolidate work methods into one function. Overhaul CLI to spin up server and request work instead of using its own puppeteer instance since testing found the server overhead to be negligible in comparison to puppeteer. Remove size getter from GL. Fix types and related imports. Add more environment variables to control server behavior. Add tests to server test script. Update package configuration files.
Chris Duncan [Wed, 26 Mar 2025 15:04:11 +0000 (08:04 -0700)]
Ignore all arguments when starting server and use envvars instead. Read NANO_POW_EFFORT from environment when starting server. Update test script to use port 3001 to test custom value. Pass NanoPowOptions object into puppeteer evaluate calls. Update README to use destructuring assignment for output clarity and to use new method names. Add more command line guidance to README. Fix default effort used by server to match the actual implementation and fix README accordingly. Add --server documentation to manual. Fix threshold/difficulty ranges throughout documentation and remove mention of u32 threshold workaround from README. Whitespace.
Chris Duncan [Fri, 21 Mar 2025 16:40:23 +0000 (09:40 -0700)]
Implement server.
Add executable start a Node server, accept POST requests in same JSON format as Nano node specs, and process similarly to CLI using puppeteer. Remove migration compatibility layer introduced in v3.2.0. Extract help text to separate documentation file. Write basic test script to check server. Refactor threshold to expect 64-bit values only. Fix Typescript types.