|
| 1 | +# Blockspace Conservation Toy |
| 2 | + |
| 3 | +Interactive web UI for experimenting with the Law of Conservation of Blockspace from |
| 4 | +`cred10.tex`. It exposes the key variables—efficiency coefficient rho, usable window `W'`, and |
| 5 | +per-user enforcement weight `e`—and visualizes the lower bound on simultaneous unilateral exits. |
| 6 | + |
| 7 | +## Features |
| 8 | + |
| 9 | +- Preset scenarios mirroring the paper (Retail Panic, Quiet Exit, Mixed Economy, Institutional, |
| 10 | + Ark). |
| 11 | +- Direct manipulation of `rho`, `W'`, `e`, and coinbase overhead with immediate capacity feedback. |
| 12 | +- Table + sparkline showing how `N_max` scales with the window length at the chosen efficiency. |
| 13 | +- Operational notes that document how to estimate `rho`, how HTLC jamming inflates `e`, and why the |
| 14 | + model is a static bound. |
| 15 | +- Shareable URLs and JSON export for saving/sharing scenarios. |
| 16 | +- Deterministic math helpers with Vitest coverage (Lightning per-state weights, Ark lower bounds, |
| 17 | + security zone classifier). |
| 18 | + |
| 19 | +## Getting Started |
| 20 | + |
| 21 | +```bash |
| 22 | +# install once |
| 23 | +npm install |
| 24 | + |
| 25 | +# run locally |
| 26 | +npm run dev |
| 27 | + |
| 28 | +# unit tests (math + scenarios) |
| 29 | +npm run test |
| 30 | + |
| 31 | +# production build |
| 32 | +npm run build |
| 33 | +npm run preview # optional local preview of /dist |
| 34 | +``` |
| 35 | + |
| 36 | +Tests live in `src/lib/*.test.ts` and exercise the published figures (e.g., the 83,060 and 94,926 |
| 37 | +Lightning bounds). The Vitest environment is configured in `vite.config.ts`. |
| 38 | + |
| 39 | +## Project Layout |
| 40 | + |
| 41 | +``` |
| 42 | +src/ |
| 43 | + App.tsx # main UI |
| 44 | + App.css # glassmorphism styling + responsive grid |
| 45 | + lib/math.ts # reusable equations: C_max, rho losses, N_max, zone classifier |
| 46 | + lib/scenarios.ts # preset catalog, query-string serializer, blended cohorts |
| 47 | +``` |
| 48 | + |
| 49 | +## Estimating rho (field method) |
| 50 | + |
| 51 | +1. Choose a window `[b, b+W')` and compute `C_max = (4_000_000 - w_cb) * W'`. |
| 52 | +2. For each block or mempool diff in the window, sum the serialized weight of: |
| 53 | + - replaced transactions (RBF evictions) |
| 54 | + - orphaned blocks' unique weight |
| 55 | + - transactions stranded as dust |
| 56 | + - policy-filtered packages (ancestor/descendant and package limits) |
| 57 | +3. Let `rho = 1 - (losses / C_max)`. The congestion sample from 5 Oct 2025 had total losses |
| 58 | + `160,200,000` wu over `W' = 137` blocks, so `rho ≈ 0.71`. |
| 59 | + |
| 60 | +Lower `rho` collapses `N_max` linearly; HTLC jamming also raises per-user `e`, so the interactive |
| 61 | +toy should be interpreted as an optimistic (necessary) bound. |
| 62 | + |
| 63 | +## Sharing & Export |
| 64 | + |
| 65 | +- **Share current setup** copies a permalink with the full scenario embedded in the query string. |
| 66 | +- **Download JSON** saves `{ scenario, metrics }` for reproducibility or offline calculations. |
0 commit comments