Skip to content

Commit b670d10

Browse files
Add files via upload
1 parent da491d5 commit b670d10

File tree

17 files changed

+1315
-0
lines changed

17 files changed

+1315
-0
lines changed

README.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
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.

eslint.config.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import js from '@eslint/js'
2+
import globals from 'globals'
3+
import reactHooks from 'eslint-plugin-react-hooks'
4+
import reactRefresh from 'eslint-plugin-react-refresh'
5+
import tseslint from 'typescript-eslint'
6+
import { defineConfig, globalIgnores } from 'eslint/config'
7+
8+
export default defineConfig([
9+
globalIgnores(['dist']),
10+
{
11+
files: ['**/*.{ts,tsx}'],
12+
extends: [
13+
js.configs.recommended,
14+
tseslint.configs.recommended,
15+
reactHooks.configs.flat.recommended,
16+
reactRefresh.configs.vite,
17+
],
18+
languageOptions: {
19+
ecmaVersion: 2020,
20+
globals: globals.browser,
21+
},
22+
},
23+
])

package.json

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"name": "web-toy",
3+
"private": true,
4+
"version": "0.0.0",
5+
"type": "module",
6+
"scripts": {
7+
"dev": "vite",
8+
"build": "tsc -b && vite build",
9+
"lint": "eslint .",
10+
"test": "vitest",
11+
"preview": "vite preview"
12+
},
13+
"dependencies": {
14+
"react": "^19.2.0",
15+
"react-dom": "^19.2.0"
16+
},
17+
"devDependencies": {
18+
"@eslint/js": "^9.39.1",
19+
"@types/node": "^24.10.1",
20+
"@types/react": "^19.2.5",
21+
"@types/react-dom": "^19.2.3",
22+
"@vitejs/plugin-react": "^5.1.1",
23+
"@vitest/coverage-v8": "^4.0.13",
24+
"eslint": "^9.39.1",
25+
"eslint-plugin-react-hooks": "^7.0.1",
26+
"eslint-plugin-react-refresh": "^0.4.24",
27+
"globals": "^16.5.0",
28+
"jsdom": "^27.2.0",
29+
"typescript": "~5.9.3",
30+
"typescript-eslint": "^8.46.4",
31+
"vite": "^7.2.4",
32+
"vitest": "^4.0.13"
33+
}
34+
}

public/vite.svg

Lines changed: 1 addition & 0 deletions
Loading

0 commit comments

Comments
 (0)