# Changelog
-## v5.1.15
+## v5.2.0
### Notable Changes
-Fix cache corruption by deleting cached work if it fails validation.
+#### Updated exports
+
+For those projects which import from a CDN link and targeted the
+`dist/main.min.js`
+file _directly_, the bundle is now named `dist/index.js`. The `work_generate`
+and `work_validate` functions are now exported directly in addition to the
+default `NanoPow` wrapper object. There is also a new export for NanoPow utility
+functions at `dist/utils.index.js`.
+
+#### Improved seeding
+
+Each `work_generate` call uses a random seed to begin computation. Previously,
+this seed was generated separately for each thread according to the API being
+used. Now, seeds for all threads are randomly generated per generate-and-check
+loop at the same time which reduces the number of expensive calls to
+`crypto.getRandomValues()`.
-Fix test webpage crashing on load in certain browsers.
+#### Stricter input validation
-Replace some slow operators with bitshifts.
+Input parsing has been refactored to be more legible and reduce the supported
+space of string values. Specifically, only `0x` hexadecimal inputs are allowed
+now when passing strings; previously binary `0b` and octal `0o` strings were
+also supported as input strings. Inputs can still be passed as bigint values
+instead of strings.
+
+### Other Changes
+
+- Fix issue where WASM worker could erroneously respond to unrelated requests.
+- Fix issue where WASM would produce invalid results for small blockhash values.
+- Return cached work values immediately instead of being queued.
+- WebGPU support improved with additional checks.
+- Update the CLI server to respond to `HEAD` requests and return `Content-Type`,
+ respond to known unsupported HTTP methods with 405, and respond to all other
+ HTTP methods with 501.
+- Test caching behavior when duplicate hash is encountered.
+- Refactor testing web page to improve run execution.
+- Improve WASM performance with better AssemblyScript config.
+- Update dependencies and TypeScript configuration.
+- Improve markdown format of this README.
+
+## v5.1.15
+
+### Notable Changes
+
+- Fix cache corruption by deleting cached work if it fails validation.
+- Fix test webpage crashing on load in certain browsers.
+- Replace some slow operators with bitshifts.
## v5.1.14
### Notable Changes
-Update sub-dependency to resolve vulnerability notice.
+- Update sub-dependency to resolve vulnerability notice.
## v5.1.13
### Notable Changes
-Test WebGL availability by additionally checking for immediate context loss.
+- Test WebGL availability by additionally checking for immediate context loss.
## v5.1.12
### Notable Changes
-Fix invalid WebGL canvas due to iOS Safari regression.
+- Fix invalid WebGL canvas due to iOS Safari regression.
## v5.1.11
### Notable Changes
-Pin build targets for compatibility on systems missing built-in base64 support.
+- Pin build targets for compatibility on systems missing built-in base64 support.
## v5.1.10
### Notable Changes
-Update domain name references, including `git clone` URL.
-
-Apply automatic formatting of Markdown files.
-
-Update dependencies.
+- Update domain name references, including `git clone` URL.
+- Apply automatic formatting of Markdown files.
+- Update dependencies.
## v5.1.9
### Notable Changes
-Fix CLI input parsing.
-
-Update dependencies.
+- Fix CLI input parsing.
+- Update dependencies.
## v5.1.8
### Notable Changes
-Update dependencies.
+- Update dependencies.
## v5.1.7
### Notable Changes
-Eliminate self-references to allow esbuild to generate anonymous classes.
+- Eliminate self-references to allow esbuild to generate anonymous classes.
## v5.1.6
### Notable Changes
-Export utility method to clear work cache.
-
-Update optional `puppeteer` dependency.
+- Export utility method to clear work cache.
+- Update optional `puppeteer` dependency.
## v5.1.5
### Notable Changes
-Specify backing buffer types where needed as required by new TypeScript built-in
-type definitions.
-
-Remove `browser` field from `package.json` due to causing issues with Webpack
-bundlers.
-
-Update dev dependencies.
+- Specify backing buffer types where needed as required by new TypeScript built-in
+ type definitions.
+- Remove `browser` field from `package.json` due to causing issues with Webpack
+ bundlers.
+- Update dev dependencies.
## v5.1.4
### Notable Changes
-Adjust types for API support and fix optional options parameter types.
+- Adjust types for API support and fix optional options parameter types.
## v5.1.3
### Notable Changes
-Fix types for optional properties of NanoPowOptions object.
+- Fix types for optional properties of NanoPowOptions object.
## v5.1.2
### Notable Changes
-Untrack AssemblyScript build artifacts.
-
-Add missing license headers for REUSE compliance.
+- Untrack AssemblyScript build artifacts.
+- Add missing license headers for REUSE compliance.
## v5.1.1
### Notable Changes
-Fix test page CDN URL.
+- Fix test page CDN URL.
## v5.1.0
### Other Changes
-Added utility functions for hex string validation.
-
-Expanded list of test blockhashes for longer testing.
-
-Consolidated npm scripts.
+- Added utility functions for hex string validation.
+- Expanded list of test blockhashes for longer testing.
+- Consolidated npm scripts.
## v5.0.5
### Notable Changes
-Fixed missing required CSP directives in puppeteer browser instance for WASM
-compilation and `blob:` Web Workers.
-
-Reverted reduced WASM iteration count since it seems to be a Firefox issue.
+- Fixed missing required CSP directives in puppeteer browser instance for WASM
+ compilation and `blob:` Web Workers.
+- Reverted reduced WASM iteration count since it seems to be a Firefox issue.
## v5.0.4
### Notable Changes
-Fix bug in WASM workers causing it to stop listening after first result.
-
-Reduce WASM module hash iterations to check results more often.
+- Fix bug in WASM workers causing it to stop listening after first result.
+- Reduce WASM module hash iterations to check results more often.
## v5.0.3
### Notable Changes
-Bump version due to npm publishing issue.
+- Bump version due to npm publishing issue.
## v5.0.2
### Notable Changes
-Fix loop in CPU `work_generate` that would block the main thread.
-
-Remove additional logger statements from production builds.
+- Fix loop in CPU `work_generate` that would block the main thread.
+- Remove additional logger statements from production builds.
## v5.0.1
### Notable Changes
-Update scripts to work better with systemd services.
-
-Update test webpage import URLs.
+- Update scripts to work better with systemd services.
+- Update test webpage import URLs.
## v5.0.0
### Other Changes
-WebGL implementation now uses quadruple buffering to optimize for frame latency.
-
-New `Logger` and `Queue` classes improve logging and request handling.
-
-Fixed bug in IPC implementation which communicates between CLI and server.
-
-Server requests that throw an error will now return an error object to the user.
-
-Fixed issue with server puppeteer launching NanoPow before GPU was ready.
-
-Shaders now generated with scripts for more robust algorithm implementations.
-
-Improved configuration checks with NanoPowConfig class.
-
-Defer loading of APIs until requested.
-
-Improved type checking and removed unnecessary type exports.
-
-Reorganized project structure.
+- WebGL implementation now uses quadruple buffering to optimize for frame latency.
+- New `Logger` and `Queue` classes improve logging and request handling.
+- Fixed bug in IPC implementation which communicates between CLI and server.
+- Server requests that throw an error will now return an error object to the user.
+- Fixed issue with server puppeteer launching NanoPow before GPU was ready.
+- Shaders now generated with scripts for more robust algorithm implementations.
+- Improved configuration checks with NanoPowConfig class.
+- Defer loading of APIs until requested.
+- Improved type checking and removed unnecessary type exports.
+- Reorganized project structure.
## v4.1.9
### Notable Changes
-Test WebGL availability by additionally checking for immediate context loss.
+- Test WebGL availability by additionally checking for immediate context loss.
## v4.1.8
### Notable Changes
-Pin published package versions from CDNs on testing page.
-
-Update domain name.
+- Pin published package versions from CDNs on testing page.
+- Update domain name.
## v4.1.7
### Notable Changes
-Update dependencies.
+- Update dependencies.
## v4.1.6
### Other Changes
-Refactor server to extract code into manageable helper functions, improve
+- Refactor server to extract code into manageable helper functions, improve
organization, and fix some minor issues.
-
-Merge shared code in GPU implementation work calls and extract it into modular
+- Merge shared code in GPU implementation work calls and extract it into modular
functions.
-
-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.
-
-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.
+- 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.
+- 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.
## v4.1.5
### Other Changes
-Reduce workgroup size to 64 to improve portability between GPU vendors.
-
-Capture logging over IPC from server process spawned by CLI.
-
-Lower timeout duration when tool is busy.
-
-Allow difficulty of zero.
-
-Throw an error if work to be validated does not match the nonce returned by the
-compute result.
-
-Add max HTTP header size limit to launch script to protect server process.
-
-Check more generate calls in test script, and reduce run size of benchmark.
-
-Tweak error messaging.
+- Reduce workgroup size to 64 to improve portability between GPU vendors.
+- Capture logging over IPC from server process spawned by CLI.
+- Lower timeout duration when tool is busy.
+- Allow difficulty of zero.
+- Throw an error if work to be validated does not match the nonce returned by
+the compute result.
+- Add max HTTP header size limit to launch script to protect server process.
+- Check more generate calls in test script, and reduce run size of benchmark.
+- Tweak error messaging.
## v4.1.4
### Notable Changes
-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.
+- 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.
## v4.1.3
### Notable Changes
-Use SIGHUP to reload configuration values (except PORT which requires
+- Use SIGHUP to reload configuration values (except PORT which requires
relaunching the server).
-
-Refactor CLI to spawn the server as a child process so that it can be assigned a
+- Refactor CLI to spawn the server as a child process so that it can be assigned a
port from the operating system dynamically, avoiding port collisions with other
processes and subsequent failure, and communicate it to the CLI using IPC.
-
-Fix fast exit failing to clean up resources by handling SIGINT and SIGTERM.
+- Fix fast exit failing to clean up resources by handling SIGINT and SIGTERM.
## v4.1.2
### Notable Changes
-Load configuration from file (`$HOME/.nano-pow/config`) and use it to set
+- Load configuration from file (`$HOME/.nano-pow/config`) and use it to set
execution options if relevant environment variables are not present.
## v4.1.1
### Notable Changes
-Print server error if it does not launch, typically due to puppeteer issue.
-
-Improve reset process on errors and timeouts.
+- Print server error if it does not launch, typically due to puppeteer issue.
+- Improve reset process on errors and timeouts.
## v4.1.0
### Other Changes
-Store seed and blockhash in fast shared workgroup memory.
-
-Fix documentation in inline help and manual page.
-
-Fix CLI default port collision with server default port.
-
-Change timestamp on server log files to something more user-friendly.
-
-Test concurrent curl requests to NanoPow server.
-
-Fix action listed in server response error message.
-
-Prevent unnecessary favicon load in puppeteer source and in test webpage.
+- Store seed and blockhash in fast shared workgroup memory.
+- Fix documentation in inline help and manual page.
+- Fix CLI default port collision with server default port.
+- Change timestamp on server log files to something more user-friendly.
+- Test concurrent curl requests to NanoPow server.
+- Fix action listed in server response error message.
+- Prevent unnecessary favicon load in puppeteer source and in test webpage.
## v4.0.11
### Notable Changes
-Change default port to 5040 to reduce collisions with other projects which
+- Change default port to 5040 to reduce collisions with other projects which
commonly specify a default port of 3000.
-
-Improve formatting of environment variable documentation.
+- Improve formatting of environment variable documentation.
## v4.0.10
### Notable Changes
-Complete conversion from `threshold` terminology and parameters to `difficulty`
+- Complete conversion from `threshold` terminology and parameters to `difficulty`
to align with official Nano node specifications.
-
-Update documentation.
-
-Remove deprecated functions from type definition file.
+- Update documentation.
+- Remove deprecated functions from type definition file.
## v4.0.9
### Notable Changes
-Fix missing crypto module used to compute source hash for CSP.
+- Fix missing crypto module used to compute source hash for CSP.
## v4.0.8
### Other Changes
-Remove size getter from GL.
-
-Fix types and related imports.
-
-Add tests to server test script.
-
-Update package configuration files.
+- Remove size getter from GL.
+- Fix types and related imports.
+- Add tests to server test script.
+- Update package configuration files.
## v4.0.7
### Notable Changes
-Read NANO_POW_EFFORT from environment when starting server to set GPU demand.
-
-Ignore command line arguments when starting server and use environment variables instead.
-
-Fix default effort used by server to match the underlying implementation.
-
-Update README and manual for clarity, completeness, and accuracy.
+- Read NANO_POW_EFFORT from environment when starting server to set GPU demand.
+- Ignore command line arguments when starting server and use environment variables instead.
+- Fix default effort used by server to match the underlying implementation.
+- Update README and manual for clarity, completeness, and accuracy.
## v4.0.6
### Notable Changes
-Initialize upon first method execution instead of upon import in order to avoid
+- Initialize upon first method execution instead of upon import in order to avoid
conflicts with GPU.
-
-Fix file paths in server test.
+- Fix file paths in server test.
## v4.0.5
### Notable Changes
-Use `npm prepare` script to ensure build artifacts are up-to-date before
+- Use `npm prepare` script to ensure build artifacts are up-to-date before
installing locally or publishing.
## v4.0.4
### Notable Changes
-Fix CLI file paths for older versions of Node that do not have
+- Fix CLI file paths for older versions of Node that do not have
`import.meta.dirname` available.
## v4.0.3
### Notable Changes
-Import `node:crypto` module for older versions of Node which require it to be
+- Import `node:crypto` module for older versions of Node which require it to be
specified explicitly.
-
-Fix warning in shell script when no arguments are present.
-
-Log IP address instead of static 'http://localhost' value from testing.
+- Fix warning in shell script when no arguments are present.
+- Log IP address instead of static <http://localhost> value from testing.
## v4.0.2
### Notable Changes
-Fix server file paths for older versions of Node that do not have
+- Fix server file paths for older versions of Node that do not have
`import.meta.dirname` available.
## v4.0.1
### Notable Changes
-Update `nano-pow` command to call shell script which subsequently calls
+- Update `nano-pow` command to call shell script which subsequently calls
`server.js` if called with `nano-pow --server` or `cli.js` as usual if not.
## v4.0.0
#### Other Changes
-Write basic test script to check server.
-
-Extract help text to separate documentation file.
-
-Fix Typescript types.
+- Write basic test script to check server.
+- Extract help text to separate documentation file.
+- Fix Typescript types.
## v3.2.2
### Notable Changes
-Implement lazy initialization of both APIs.
-
-Parse CLI output with regular expression and try to print as JSON before falling
+- Implement lazy initialization of both APIs.
+- Parse CLI output with regular expression and try to print as JSON before falling
back to text.
-
-Fix CLI statements that were causing issues with older versions of node.
-
-Fix getter type.
+- Fix CLI statements that were causing issues with older versions of node.
+- Fix getter type.
## v3.2.1
### Notable Changes
-Implement hash-based Content Security Policy (CSP) in CLI puppeteer page.
+- Implement hash-based Content Security Policy (CSP) in CLI puppeteer page.
## v3.2.0
#### Other Changes
-Indicate a more specific `threshold` by passing a full 16-character string to
+- Indicate a more specific `threshold` by passing a full 16-character string to
the new `work_` methods.
-
-Changed `NanoPowGl.size` property to return total pixel count.
-
-Add typings for request and response objects consumed by new `work_` methods.
-
-Add more tests for receive threshold edge cases.
-
-Improve build process.
-
-Expand documentation.
+- Changed `NanoPowGl.size` property to return total pixel count.
+- Add typings for request and response objects consumed by new `work_` methods.
+- Add more tests for receive threshold edge cases.
+- Improve build process.
+- Expand documentation.
## v3.1.4
### Notable Changes
-#### Reorganize source directory structure.
+#### Reorganize source directory structure
As the project expands in scope, a better directory structure is necessary to
keep files organized. Documentation and test files are now in top-level folders.
#### Other Changes
-Updated CLI documentation for new input/output features.
-
-Refactored WebGL draw shader to align with WebGPU compute shader on BLAKE2b
+- Updated CLI documentation for new input/output features.
+- Refactored WebGL draw shader to align with WebGPU compute shader on BLAKE2b
initialization.
-
-Rename file of test blockhashes since they are not seeds.
-
-Update README license section.
+- Rename file of test blockhashes since they are not seeds.
+- Update README license section.
## v3.1.2
### Notable Changes
-Made minor changes to CLI inline help and manual.
-
-Added file of blockhashes used in `test.html`.
+- Made minor changes to CLI inline help and manual.
+- Added file of blockhashes used in `test.html`.
## v3.1.1
### Notable Changes
-Fixed minor issues with CLI inline help and manual.
+- Fixed minor issues with CLI inline help and manual.
## v3.1.0
### Other Changes
-Fixed a bug in the compute shader where the final 64-bit addition missed a carry
+- Fixed a bug in the compute shader where the final 64-bit addition missed a carry
bit and resulted in a slightly different, though still valid, work value than
expected, which only came to light when testing a custom max-value threshold
(0xFFFFFFFF) well beyond Nano requirements.
-
-Fixed a bug in the final hash digest and subsequent threshold comparison which
+- Fixed a bug in the final hash digest and subsequent threshold comparison which
used the original blake2b_IV[0] value instead of the value modified by the
parameter block.
-
-Fixed types.d.ts parameter definitions.
-
-Delayed canvas setup in WebGL implementation to allow for a cleaner
+- Fixed types.d.ts parameter definitions.
+- Delayed canvas setup in WebGL implementation to allow for a cleaner
initialization.
-
-Added more comprehensive documentation of BLAKE2b configuration and
+- Added more comprehensive documentation of BLAKE2b configuration and
initialization in compute shader, for those who are interested in learning how
it works.
-
-Add more logging when the debug option is used.
-
-Updated dependencies.
+- Add more logging when the debug option is used.
+- Updated dependencies.
## v3.0.1
### Notable Changes
-Implemented `esbuild` legal comment retention.
+- Implemented `esbuild` legal comment retention.
## v3.0.0
### Other Changes
-Simplify the WebGL pixel-coordinate-based nonce variation.
-
-Unroll WebGL main G mix function loop for improved performance.
-
-Add input to WebGL draw shader to better differentiate between search and
+- Simplify the WebGL pixel-coordinate-based nonce variation.
+- Unroll WebGL main G mix function loop for improved performance.
+- Add input to WebGL draw shader to better differentiate between search and
validate processes.
-
-Simplify WebGL vertex shader now that it is only required for drawing the
+- Simplify WebGL vertex shader now that it is only required for drawing the
fullscreen quad and not for pixel coordinates.
-
-Maintain WebGL canvas between draw calls, unless level-of-effort has changed, to
+- Maintain WebGL canvas between draw calls, unless level-of-effort has changed, to
reduce overhead of executing a search.
-
-Attempt to handle WebGL context loss, with improved reset function, by
+- Attempt to handle WebGL context loss, with improved reset function, by
reinitializing class.
-
-Reduce promise stack buildup when waiting for WebGL query result.
-
-Fix WebGL color buffer clearing by using correct API function.
-
-Improve nonce seed generation in both WebGL and WebGPU by switching from
+- Reduce promise stack buildup when waiting for WebGL query result.
+- Fix WebGL color buffer clearing by using correct API function.
+- Improve nonce seed generation in both WebGL and WebGPU by switching from
`crypto.getRandomValues()` to insecure `Math.random()` which is justified by the
fact that NanoPow generates proof-of-work, not keys.
-
-Reduce garbage collection by reusing static variables.
-
-Add debug logging that obeys user-provided debug flag which is now stored as a
+- Reduce garbage collection by reusing static variables.
+- Add debug logging that obeys user-provided debug flag which is now stored as a
static variable as well.
-
-Add Typescript typings for new WebGL types.
-
-Fix minor issues with test page.
-
-Add benchmark results table.
+- Add Typescript typings for new WebGL types.
+- Fix minor issues with test page.
+- Add benchmark results table.
## v2.0.0
```
**This is a breaking change.** Integrations already using the optional threshold
-parameter should update calls to pass { threshold: <value> } instead.
+parameter should update calls to pass `{ threshold: value }` instead.
#### Align with reference implementation of BLAKE2b
### Other Changes
-Expand the options available on the sample testing page.
-
-Fix a bug with the validate function where a valid but different nonce would be
+- Expand the options available on the sample testing page.
+- Fix a bug with the validate function where a valid but different nonce would be
reported as a match to the input nonce.
-
-Fix a bug with the truncated average benchmark calculation.
+- Fix a bug with the truncated average benchmark calculation.
## v1.2.4
### Notable Changes
-Fix duplicate code on testing page due to bad merge commit.
-
-Increase WebGPU dispatch size.
+- Fix duplicate code on testing page due to bad merge commit.
+- Increase WebGPU dispatch size.
## v1.2.3
### Notable Changes
-Add bespoke TypeScript definition file.
-
-Remove usage of package `imports` property and use regular relative paths.
+- Add bespoke TypeScript definition file.
+- Remove usage of package `imports` property and use regular relative paths.
## v1.2.2
### Notable Changes
-Compile to `dist/` instead of `build/`.
+- Compile to `dist/` instead of `build/`.
## v1.2.1
### Notable Changes
-Rename bundle output file.
+- Rename bundle output file.
## v1.2.0
### Other Changes
-Clarify the README with better instructions.
-
-Provide additional context about test progress on the testing webpage.
+- Clarify the README with better instructions.
+- Provide additional context about test progress on the testing webpage.
## v1.1.0
#### Other Changes
-Fix packaging bugs to eliminate npm errors about imports and types.
-
-Fix repo cloning so that `git clone https://codecow.com/nano-pow.git` works as
+- Fix packaging bugs to eliminate npm errors about imports and types.
+- Fix repo cloning so that `git clone https://codecow.com/nano-pow.git` works as
expected (thanks to u/the_azarian for helping track this down).
## v1.0.0
### Notable Changes
-#### NanoPow released!
+#### NanoPow Initial Release
Written in Javascript and WGSL, NanoPow leverages the cutting edge WebGPU API to
achieve massively increased proof-of-work speed for supported devices directly
compute shaders.
- Released under the GPLv3 license to promote user freedom and FOSS principles.
-Full announcement: https://www.reddit.com/r/nanocurrency/comments/1hz841f/announcing_nanopow_local_proofofwork_at/
+Full announcement: <https://www.reddit.com/r/nanocurrency/comments/1hz841f/announcing_nanopow_local_proofofwork_at/>