Skip to content

NAP-POW: NIP-13 proof-of-work miner interface - #39

Open
dskvr wants to merge 4 commits into
masterfrom
nap-pow
Open

NAP-POW: NIP-13 proof-of-work miner interface#39
dskvr wants to merge 4 commits into
masterfrom
nap-pow

Conversation

@dskvr

@dskvr dskvr commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Summary: A shell-mediated NIP-13 proof-of-work miner. Napplets submit an event template and a target difficulty; the runtime spreads the nonce search across 1..n web workers (web binding) and returns the mined event. Mining is modeled as an observable, queued, cancellable, pausable job.

Namespace: window.napplet.pow · discovery shell.supports("pow")

Status: draft

Surface:

  • minesubmit a job; returns a PowJob handle immediately. The job is enqueued and may sit at state: "queued" (with a position) before mining; job.started resolves when mining begins, job.completed with the mined (unsigned) note.
  • mineAndPublish — same lifecycle; on success the shell signs and publishes via outbox-aware fanout (no relay argument; relay selection is shell policy).
  • queue — inspect tracked jobs, with priority and queue position
  • job / pow.progress — per-job and per-worker progress (target, best PoW, hashes, hash rate)
  • pow.state — lifecycle push (queued → mining → paused/done/cancelled/error) so queue transitions are observable without polling
  • hashrate — live miner-wide rate, per-worker and per-job breakdown
  • cancel, pause/resume — per job or whole-miner

Queue semantics (refined):

  • created_at and pubkey are committed at mining start, not at submit, so a job that waited in the queue never bakes a stale timestamp.
  • PowOptions.timeoutMs bounds mining time only and excludes queue wait.
  • PowOptions.priority is an ordering hint the shell MAY honor but MUST NOT let one napplet use to starve another's jobs.

Notes:

  • Difficulty is NIP-13 leading-zero bits; the shell stamps committed fields and (re)writes the nonce tag before searching.
  • mine returns an unsigned event; the shell must sign committed mined events verbatim at publish time or the PoW is invalidated.
  • Raw H/s on the wire; scaling to kH/s…GH/s is a display concern (formatHashRate SDK sugar).

Web binding: NIP-5D.

Changelog

  • f01fb31 - Introduced NAP-POW as a runtime-owned NIP-13 proof-of-work miner surface.

dskvr added a commit that referenced this pull request Jun 16, 2026
README rework and projections/web.md now live on master (committed directly).
This branch keeps only naps/NAP-POW.md so PR #39 is the NAP-POW interface spec
alone; the NAP-POW registry row is already on master.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@dskvr dskvr added the DRAFT label Jun 17, 2026
Rebased onto current master; spec only.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
dskvr added 3 commits June 21, 2026 18:43
Proof-of-work operations, job state, progress, hashrate, result, publish result, queue summary, and error schemas now use operation tables plus CDDL-style records instead of TypeScript declarations.

Constraint: Keep this branch scoped to NAP-POW.
Confidence: high
Scope-risk: narrow
Tested: git diff --check
Tested: rg found no TypeScript code fences or declarations in naps/NAP-POW.md
The miner state, progress, hash-rate, result, publish, summary, and error shapes now use Markdown tables instead of a CDDL-style block. Job lifecycle semantics and NIP-13 behavior remain unchanged.

Constraint: PR #39 owns NAP-POW; keep this change scoped to that spec file.

Confidence: high

Scope-risk: narrow

Tested: rg for cddl/typescript schema fences and type assignment patterns in NAP-POW

Tested: git diff --check -- naps/NAP-POW.md
Open NAP proposal branches need reader-visible changelogs that track semantic spec changes without recording formatting-only migrations.

Constraint: Changelog entries are one bullet per semantic commit-change.
Rejected: Include schema-table or formatting-only commits | they do not change the spec contract or boundary.
Confidence: high
Scope-risk: narrow
Directive: Keep future changelog entries semantic; omit changelog-only and formatting-only commits.
Tested: git diff --check
Not-tested: Rendered Markdown
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant