vibehash 0.4.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. vibehash-0.4.0/PKG-INFO +367 -0
  2. vibehash-0.4.0/README.md +352 -0
  3. vibehash-0.4.0/pyproject.toml +28 -0
  4. vibehash-0.4.0/setup.cfg +4 -0
  5. vibehash-0.4.0/tests/test_consensus.py +329 -0
  6. vibehash-0.4.0/tests/test_core.py +547 -0
  7. vibehash-0.4.0/tests/test_gpu.py +133 -0
  8. vibehash-0.4.0/tests/test_hardening.py +745 -0
  9. vibehash-0.4.0/tests/test_minerui.py +78 -0
  10. vibehash-0.4.0/tests/test_network.py +380 -0
  11. vibehash-0.4.0/tests/test_setup.py +216 -0
  12. vibehash-0.4.0/tests/test_validators.py +229 -0
  13. vibehash-0.4.0/vibehash/__init__.py +1 -0
  14. vibehash-0.4.0/vibehash/__main__.py +3 -0
  15. vibehash-0.4.0/vibehash/blobs.py +157 -0
  16. vibehash-0.4.0/vibehash/cli.py +1256 -0
  17. vibehash-0.4.0/vibehash/client.py +476 -0
  18. vibehash-0.4.0/vibehash/compute.py +208 -0
  19. vibehash-0.4.0/vibehash/consensus.py +432 -0
  20. vibehash-0.4.0/vibehash/coordinator.py +791 -0
  21. vibehash-0.4.0/vibehash/crypto.py +248 -0
  22. vibehash-0.4.0/vibehash/data/bip39-english.txt +2048 -0
  23. vibehash-0.4.0/vibehash/data/fruit-new.csv +13 -0
  24. vibehash-0.4.0/vibehash/data/fruit.csv +321 -0
  25. vibehash-0.4.0/vibehash/economics.py +159 -0
  26. vibehash-0.4.0/vibehash/fees.py +71 -0
  27. vibehash-0.4.0/vibehash/gpusetup.py +222 -0
  28. vibehash-0.4.0/vibehash/hardware.py +52 -0
  29. vibehash-0.4.0/vibehash/ledger.py +551 -0
  30. vibehash-0.4.0/vibehash/minerui.py +400 -0
  31. vibehash-0.4.0/vibehash/mnemonic.py +137 -0
  32. vibehash-0.4.0/vibehash/model.py +181 -0
  33. vibehash-0.4.0/vibehash/node.py +764 -0
  34. vibehash-0.4.0/vibehash/p2p.py +69 -0
  35. vibehash-0.4.0/vibehash/protocol.py +139 -0
  36. vibehash-0.4.0/vibehash/ratelimit.py +295 -0
  37. vibehash-0.4.0/vibehash/receipts.py +68 -0
  38. vibehash-0.4.0/vibehash/replay.py +79 -0
  39. vibehash-0.4.0/vibehash/settings.py +63 -0
  40. vibehash-0.4.0/vibehash/storage.py +176 -0
  41. vibehash-0.4.0/vibehash/tabular.py +166 -0
  42. vibehash-0.4.0/vibehash/tasks.py +215 -0
  43. vibehash-0.4.0/vibehash/tls.py +194 -0
  44. vibehash-0.4.0/vibehash/verification.py +114 -0
  45. vibehash-0.4.0/vibehash/wallet.py +88 -0
  46. vibehash-0.4.0/vibehash/wire.py +115 -0
  47. vibehash-0.4.0/vibehash/worker.py +127 -0
  48. vibehash-0.4.0/vibehash.egg-info/PKG-INFO +367 -0
  49. vibehash-0.4.0/vibehash.egg-info/SOURCES.txt +51 -0
  50. vibehash-0.4.0/vibehash.egg-info/dependency_links.txt +1 -0
  51. vibehash-0.4.0/vibehash.egg-info/entry_points.txt +2 -0
  52. vibehash-0.4.0/vibehash.egg-info/requires.txt +2 -0
  53. vibehash-0.4.0/vibehash.egg-info/top_level.txt +1 -0
@@ -0,0 +1,367 @@
1
+ Metadata-Version: 2.4
2
+ Name: vibehash
3
+ Version: 0.4.0
4
+ Summary: Vibe Hash: earn VIBE by training AI models on everyday computers (testnet)
5
+ Keywords: proof-of-useful-work,distributed-training,cryptocurrency,testnet
6
+ Classifier: Development Status :: 3 - Alpha
7
+ Classifier: Environment :: Console
8
+ Classifier: Operating System :: OS Independent
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
11
+ Requires-Python: >=3.10
12
+ Description-Content-Type: text/markdown
13
+ Requires-Dist: numpy>=1.26
14
+ Requires-Dist: cryptography>=42
15
+
16
+ # Vibe Hash (VIBE)
17
+
18
+ A proof-of-useful-work cryptocurrency. Instead of hashing, "miners" train AI
19
+ models in small, verifiable chunks sized for mid- and low-end hardware. Every
20
+ verified chunk is paid pro rata. There's no lottery, so an old laptop earns the
21
+ same rate per FLOP as a gaming rig.
22
+
23
+ This is a **testnet implementation**: validator nodes that take turns leading
24
+ rounds and vote on every block (BFT consensus, so no single node is in charge),
25
+ real worker clients that talk to them over HTTP, wallets, and a persistent
26
+ chain that anyone can audit.
27
+ See [DESIGN.md](DESIGN.md) for the protocol, economics, threat model, and
28
+ what's still needed before a mainnet (§9).
29
+
30
+ ## Install
31
+
32
+ Python 3.10+. Vibe Hash **isn't on PyPI yet**, so `pip install vibehash`
33
+ says "No matching distribution found" until a release is published (see
34
+ "Publishing a release" below). Until then, build a wheel with
35
+ `python -m build` in the project folder and install the file it writes to
36
+ `dist/`, which you can send to anyone. Run this in the folder where the file
37
+ is:
38
+
39
+ ```bash
40
+ python -m pip install --upgrade vibehash-0.4.0-py3-none-any.whl
41
+ ```
42
+
43
+ Or, to work on the source, install the project folder in editable mode so
44
+ your changes apply without reinstalling. Run this in the project folder:
45
+
46
+ ```bash
47
+ python -m pip install -e .
48
+ ```
49
+
50
+ Once it's published, anyone can install it with:
51
+
52
+ ```bash
53
+ python -m pip install --upgrade vibehash
54
+ ```
55
+
56
+ Each adds a `vibehash` command (also available as `python -m vibehash`) and
57
+ pulls in NumPy and `cryptography`.
58
+
59
+ ## Quick start
60
+
61
+ Try a whole network on one computer: a node, two workers and a training job.
62
+ It needs no wallets, files or flags, prints what the workers earn each round,
63
+ and carries on where it stopped the next time you run it:
64
+
65
+ ```bash
66
+ python -m vibehash testnet
67
+ ```
68
+
69
+ To watch validators run it instead of one node, give it more validators. Each
70
+ gets its own port, they take turns leading rounds, and every block needs votes
71
+ from validators holding more than two thirds of the stake. Add `--reset` if
72
+ you've run a testnet before, since the number of validators is fixed when the
73
+ testnet is first made:
74
+
75
+ ```bash
76
+ python -m vibehash testnet --validators 4
77
+ ```
78
+
79
+ To join someone else's network as a worker, run the guided setup with their
80
+ node's address, then start working:
81
+
82
+ ```bash
83
+ python -m vibehash setup --node 192.168.1.20
84
+ ```
85
+ ```bash
86
+ python -m vibehash worker
87
+ ```
88
+
89
+ To train a model, save your examples as a CSV file (a header row, numeric
90
+ input columns, and the column to predict last), then:
91
+
92
+ ```bash
93
+ python -m vibehash train my-data.csv --budget 100
94
+ ```
95
+ ```bash
96
+ python -m vibehash job status
97
+ ```
98
+ ```bash
99
+ python -m vibehash job download
100
+ ```
101
+ ```bash
102
+ python -m vibehash predict new-rows.csv
103
+ ```
104
+
105
+ `train` sizes a model to the data, scales the inputs, holds back a fifth of
106
+ the rows to measure accuracy, and prints what it will train and what it
107
+ costs before posting. `job status` shows the accuracy climbing round by round,
108
+ `job download` saves the model as one file (`my-data-model.npz`), and
109
+ `predict` labels new rows (`--out predictions.csv` saves them all).
110
+ `python -m vibehash example` writes a sample, `fruit.csv`, to try first. On
111
+ your own testnet, pay with its requester wallet by adding
112
+ `--node http://127.0.0.1:8545 --wallet ~/.vibehash/testnet/requester.json` to
113
+ `train`. Jobs take turns a round at a time, so a new one starts at the next
114
+ round.
115
+
116
+ In a terminal, `worker` and `testnet` show a live mining dashboard: a drill
117
+ boring through rock while you train, the round and phase, your speed, units
118
+ mined, and VIBE earned as it lands. Add `--plain` for the classic log lines
119
+ (piped output and services get those automatically; `NO_COLOR` turns colours
120
+ off).
121
+
122
+ `setup` saves the node address, creates your wallet (encrypted with a password
123
+ you choose, in `~/.vibehash/wallet.json`), finds your GPU and offers to install
124
+ the PyTorch build for it, and offers to stake once you hold VIBE. Every
125
+ command after that uses the saved node and wallet, so `--node` and `--wallet`
126
+ are only needed to override them. Re-running `setup` keeps what's done.
127
+
128
+ The new wallet comes with **24 recovery words**, shown once. Write them down
129
+ and keep them offline: they bring the wallet back if the file or its password
130
+ is lost, and anyone who sees them can take its coins:
131
+
132
+ ```bash
133
+ python -m vibehash wallet restore
134
+ ```
135
+
136
+ `wallet restore` asks for the words (the first four letters of each are
137
+ enough) and a new password. Add `--passphrase` if you gave the words one, and
138
+ `--out FILE` to restore somewhere other than the default wallet.
139
+
140
+ **GPUs.** `vibehash install-gpu` does the GPU step on its own. It reads the
141
+ card and driver (NVIDIA through `nvidia-smi`, Intel Arc, Apple silicon, AMD
142
+ with ROCm on Linux), checks which PyTorch builds are currently published for
143
+ your driver and Python version, installs the newest one that fits, and
144
+ self-tests it. `vibehash devices` shows what's usable. Workers use the first
145
+ GPU they find; `--device cpu|cuda|xpu|mps` overrides it.
146
+
147
+ ## Publishing a release
148
+
149
+ Releases publish themselves from GitHub. `.github/workflows/publish.yml` runs
150
+ when a version tag is pushed: it checks the tag matches `pyproject.toml`, runs
151
+ the fast tests, builds the wheel and source archive, and uploads them to PyPI
152
+ through a **trusted publisher**, so no API token is stored anywhere. PyPI's
153
+ trusted publisher for `vibehash` names owner `AlphaChad5000`, repository
154
+ `vibehash`, workflow `publish.yml` and environment `pypi`.
155
+
156
+ 1. Bump `version` in `pyproject.toml` (PyPI never accepts the same version
157
+ twice), commit it, and push.
158
+ 2. Tag the commit with that version and push the tag. This publishes it:
159
+
160
+ ```bash
161
+ git tag v0.4.0
162
+ ```
163
+ ```bash
164
+ git push origin v0.4.0
165
+ ```
166
+
167
+ Follow the run under the repository's Actions tab. To try a build locally
168
+ first, `python -m build` writes the packages to `dist/`.
169
+
170
+ ## Run a network for other people
171
+
172
+ `vibehash testnet --host 0.0.0.0` is the quick way: other computers on your
173
+ network can join it with `setup --node YOUR-IP`, and it prints how to send
174
+ them VIBE to stake. Its wallets are unencrypted test keys, so for anything
175
+ longer-lived, set the network up by hand:
176
+
177
+ The commands below use bash syntax; on PowerShell set environment variables
178
+ with `$env:VIBEHASH_PASSWORD = "..."` instead.
179
+
180
+ 1. Make wallets: one for the node operator, one per worker, one for whoever posts jobs. Each prints its 24 recovery words once.
181
+
182
+ ```bash
183
+ python -m vibehash wallet create --out node.json
184
+ ```
185
+ ```bash
186
+ python -m vibehash wallet create --out alice.json
187
+ ```
188
+ ```bash
189
+ python -m vibehash wallet create --out requester.json
190
+ ```
191
+
192
+ 2. Write a genesis file that funds and stakes them (use the addresses printed above). `--validator` names the node as a validator, with the address other machines reach it at. `--economics mainnet` picks the long issuance schedule (3.125 VIBE a round, halving about every 4 years, 21M VIBE at most) instead of the fast testnet one. The genesis hash commits to it.
193
+
194
+ ```bash
195
+ python -m vibehash genesis create --chain-id my-testnet-1 --out genesis.json --stake NODE_ADDR=10 --validator NODE_ADDR=http://192.168.1.20:8545 --alloc ALICE_ADDR=20 --alloc REQUESTER_ADDR=500
196
+ ```
197
+
198
+ 3. Start the node. Use `--host 0.0.0.0` to accept workers from other machines.
199
+
200
+ ```bash
201
+ python -m vibehash node --genesis genesis.json --wallet node.json --data-dir node-data --host 0.0.0.0
202
+ ```
203
+
204
+ For more validators, give each its own staked wallet and its own `--validator ADDR=URL` in the genesis, and start one node per wallet on its own machine, all with the same `genesis.json`. They find each other from the addresses in it. A staked account can also join a running network as a validator. Its node announces the address where other machines can reach it:
205
+
206
+ ```bash
207
+ python -m vibehash validator join --url http://203.0.113.7:8545 --wallet bob.json
208
+ ```
209
+ ```bash
210
+ python -m vibehash node --genesis genesis.json --wallet bob.json --data-dir bob-data --host 0.0.0.0 --announce http://203.0.113.7:8545 --peer http://192.168.1.20:8545
211
+ ```
212
+
213
+ A node whose wallet isn't a validator, started with `--peer`, follows the chain: it checks and serves every block, and points workers at whichever validator is leading. `vibehash validator list` shows the validators and their share of the votes.
214
+
215
+ 4. Each worker runs setup with the node's address and their wallet, staking from the VIBE genesis gave them, then starts contributing.
216
+
217
+ ```bash
218
+ python -m vibehash setup --node http://127.0.0.1:8545 --wallet alice.json --stake 10
219
+ ```
220
+ ```bash
221
+ python -m vibehash worker
222
+ ```
223
+
224
+ 5. Post a training job: from a CSV with `train`, or with full control over every setting from a job file and a prepared `.npz` dataset.
225
+
226
+ ```bash
227
+ python -m vibehash train my-data.csv --node http://127.0.0.1:8545 --wallet requester.json --budget 150
228
+ ```
229
+ ```bash
230
+ python -m vibehash post-job --node http://127.0.0.1:8545 --wallet requester.json --spec examples/job.json --budget 150 --dataset examples/demo-dataset.npz
231
+ ```
232
+
233
+ 6. Check balances and independently audit the whole chain. `chain verify` re-checks every block from genesis, checks each block's commit certificate (the validators' signatures that made it final), and replays every round from the record its block commits to, so it catches a node that favoured a worker, invented a registration or forged a verdict, not just bad arithmetic. It also checks the signed receipts workers on this computer received for their messages (or any receipts file with `--receipts FILE`), which prove a node that accepted a message and then left it out of the round. For the most recent rounds (the node keeps their checkpoints for `--keep-rounds`, 10 by default) it downloads the checkpoints and re-runs every check that needs the model weights, so it catches a node that misreported a sanity check or sided with a false accusation.
234
+
235
+ ```bash
236
+ python -m vibehash balance --node http://127.0.0.1:8545 --wallet alice.json
237
+ ```
238
+ ```bash
239
+ python -m vibehash chain verify --node http://127.0.0.1:8545 --genesis genesis.json
240
+ ```
241
+
242
+ A dataset is an `.npz` with `x_train`, `y_train`, `x_val`, `y_val`. It's never
243
+ unpickled, and workers check its sha256 against the job before using it.
244
+
245
+ ### Fees, HTTPS and rate limits
246
+
247
+ **Fees.** Every transaction pays a small fee to the validator that proposes
248
+ its block. A node relays transactions paying at least `--min-fee` (0.0001 VIBE
249
+ by default; `--min-fee 0` relays free ones). `send`, `stake`, `unstake`,
250
+ `post-job` and `cancel-job` pay the node's minimum unless you give `--fee`,
251
+ and `balance` shows it. The fee comes out of your spendable balance, so keep
252
+ a little unstaked VIBE to unstake with. Worker messages are free. When the
253
+ mempool is full, higher fees get in first.
254
+
255
+ **HTTPS.** A node can serve HTTPS itself. For a testnet, make a self-signed
256
+ certificate for the names and addresses workers will use, and start the node
257
+ with it:
258
+
259
+ ```bash
260
+ python -m vibehash tls cert --host 192.168.1.20
261
+ ```
262
+ ```bash
263
+ python -m vibehash node --genesis genesis.json --wallet node.json --data-dir node-data --host 0.0.0.0 --tls-cert node-cert.pem --tls-key node-key.pem
264
+ ```
265
+
266
+ Both print the certificate's fingerprint (`vibehash tls fingerprint
267
+ node-cert.pem` shows it again). Workers pin it in setup, and every later
268
+ command then trusts that exact certificate from that node and nothing else:
269
+
270
+ ```bash
271
+ python -m vibehash setup --node 192.168.1.20 --tls-fingerprint FINGERPRINT
272
+ ```
273
+
274
+ With a certificate from a real CA, plain `setup --node https://...` works.
275
+ `--tls-ca FILE` trusts a private CA instead, and `$VIBEHASH_TLS_FINGERPRINT`
276
+ or `$VIBEHASH_TLS_CA` set the trust without setup. Without the `cryptography`
277
+ package, `tls cert` prints the openssl command to run instead.
278
+
279
+ **Rate limits.** Each client address gets its own budget of reads, worker
280
+ messages, transactions and uploads, at most 32 connections (256 in all), and
281
+ socket timeouts that cut off slow-loris clients. Over budget, a node answers
282
+ 429, and clients wait and retry. Clients on the node's own computer are
283
+ never limited, so a local testnet is never throttled. Behind a reverse proxy
284
+ every client looks local, so limit at the proxy or add `--rate-limit-local`.
285
+ `--rate-limit off` turns the budgets off, `--rate-limit tx=1/10,read=100`
286
+ changes some (requests a second and burst; the buckets are read, worker, tx,
287
+ upload and other), and `--max-connections N` sets the overall cap. DESIGN.md
288
+ §10 has the numbers.
289
+
290
+ ## Simulate the economics
291
+
292
+ Runs the same round logic as a real node, with 14 simulated rigs (7 of them
293
+ cheating), in a few seconds:
294
+
295
+ ```bash
296
+ python simulate.py --rounds 20
297
+ ```
298
+
299
+ ## Tests
300
+
301
+ ```bash
302
+ python -m unittest discover -s tests -t .
303
+ ```
304
+
305
+ `tests/test_network.py` starts a real node on localhost with four worker
306
+ clients (one cheating), uploads a dataset, runs three rounds, audits the chain
307
+ from the outside, and restarts the node from disk.
308
+ `tests/test_validators.py` runs four validators on localhost:
309
+ - they take turns leading rounds and outvote a leader that pays itself;
310
+ - they carry on without one that goes offline, and it catches up when it's back;
311
+ - a new node syncs the whole chain and refuses a block whose certificate is
312
+ short of two thirds of the stake.
313
+
314
+ `tests/test_consensus.py` puts the voting itself through crashed, lying and
315
+ double-voting validators, lost messages and a split network, on a simulated
316
+ clock. `tests/test_hardening.py` covers fees, issuance schedules, HTTPS
317
+ nodes, rate limits and recovery words, including the official BIP39 and
318
+ SLIP-0010 test vectors.
319
+
320
+ ## Layout
321
+
322
+ | File | What it does |
323
+ |---|---|
324
+ | `vibehash/crypto.py` | Ed25519 (OpenSSL, or RFC 8032 pure-Python fallback), hashing, Merkle trees |
325
+ | `vibehash/model.py` | Reference workload: multi-layer MLP with deterministic, replayable SGD (float32 or float64); dataset loading |
326
+ | `vibehash/compute.py` | Compute backends: NumPy on CPU, PyTorch on NVIDIA / Intel / Apple / AMD GPUs; device detection |
327
+ | `vibehash/tasks.py` | Job specs (validated, stored on chain), work units, commitments, reveals, verdicts |
328
+ | `vibehash/verification.py` | Commit–reveal, Merkle openings, sanity checks, replay spot-checks |
329
+ | `vibehash/economics.py` | Issuance schedules (testnet, mainnet), reward split, reputation, slashing |
330
+ | `vibehash/ledger.py` | Transactions, blocks, state, unbonding; derives rewards/slashes from round summaries |
331
+ | `vibehash/fees.py` | Transaction fees: the relay minimum, the fee-ordered mempool, eviction |
332
+ | `vibehash/coordinator.py` | The round state machine, shared by the node and the simulator |
333
+ | `vibehash/worker.py` | Training, committing, revealing, verifying (plus cheat modes for tests) |
334
+ | `vibehash/node.py` | HTTP node: API, wall-clock round driver, leading rounds and committing blocks validators agree on |
335
+ | `vibehash/consensus.py` | Tendermint-style BFT voting among validators; commit certificates |
336
+ | `vibehash/p2p.py` | Peers: gossiping votes and transactions between nodes |
337
+ | `vibehash/replay.py` | Re-runs a block's round from its record: how validators check a proposal |
338
+ | `vibehash/receipts.py` | Signed receipts that prove a node dropped a message it accepted |
339
+ | `vibehash/ratelimit.py` | Per-client rate limits, connection caps and timeouts for the node's server |
340
+ | `vibehash/tls.py` | HTTPS: server contexts, self-signed certificates, certificate pinning for clients |
341
+ | `vibehash/client.py` | HTTP client and the worker loop, with live `WorkerStats` |
342
+ | `vibehash/minerui.py` | The terminal mining dashboard (plain ANSI, ASCII fallback) |
343
+ | `vibehash/tabular.py` | CSV files to training datasets, and downloaded models to predictions |
344
+ | `vibehash/data/` | The `fruit.csv` sample `vibehash example` writes, and the BIP39 word list |
345
+ | `vibehash/storage.py` | SQLite chain and weights, content-addressed datasets |
346
+ | `vibehash/blobs.py` | Content-addressed, chunked, resumable binary storage for checkpoints and datasets |
347
+ | `vibehash/wire.py` | JSON wire format and signed message envelopes |
348
+ | `vibehash/wallet.py` | Key files: scrypt + AES-256-GCM |
349
+ | `vibehash/mnemonic.py` | Recovery words: BIP39 mnemonics and SLIP-0010 Ed25519 key derivation |
350
+ | `vibehash/hardware.py` | RAM detection and a workload benchmark |
351
+ | `vibehash/cli.py` | The `vibehash` command, including `setup` and `testnet` |
352
+ | `vibehash/settings.py` | `~/.vibehash`: the default wallet, and the node address and its TLS trust that `setup` saves |
353
+ | `vibehash/gpusetup.py` | GPU detection before PyTorch is installed; picks and installs the PyTorch build for the card |
354
+ | `vibehash/protocol.py` | In-process driver for simulations |
355
+
356
+ ## Status
357
+
358
+ Unaudited testnet software. Don't attach real value to it. DESIGN.md §9 lists
359
+ the remaining work:
360
+ - validators rechecking weight-based results before voting, with on-chain
361
+ disputes;
362
+ - slashing double-signing validators;
363
+ - replicating fraud evidence;
364
+ - model types beyond MLPs.
365
+
366
+ §10 covers what's been hardened: fees, the issuance schedule, TLS, rate limits
367
+ and recovery words.