trac-msb 0.2.27 → 0.2.28

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.
package/README.md CHANGED
@@ -37,6 +37,40 @@ cd main_settlement_bus
37
37
  npm install
38
38
  ```
39
39
 
40
+ ## HyperDHT LAN compatibility (0.2.28)
41
+
42
+ HyperDHT 6.29.x calls `bogon.isReserved` when connecting peers through a relay on
43
+ one host or LAN. Bogon 1.1.0 lacks that export; 1.2.0 first supplies it. This
44
+ release requires `bogon ^1.2.0` and checks the Bogon actually resolved by every
45
+ reachable HyperDHT copy during `postinstall`. This applies to regular peers as
46
+ well as validators.
47
+
48
+ A package lockfile or `overrides` in a dependency does not protect an application's
49
+ installation. Applications should update their own lockfiles and run
50
+ `node node_modules/trac-msb/scripts/check-hyperdht-bogon.cjs` after installation.
51
+ If lifecycle scripts are disabled, also run
52
+ `node node_modules/trac-msb/scripts/hypercore-stallfix/apply.mjs` and then repeat
53
+ it with `--check`. Both checks must succeed before starting the application.
54
+ The check reports an incompatible nested Bogon instead of modifying dependencies.
55
+
56
+ From this repository, run `npm run check:dependencies` and
57
+ `npm run test:hyperdht-bogon`. The regression uses only a local bootstrap and
58
+ throwaway keys, binds to loopback ports 59100–59199, and does not join a Trac
59
+ network. Start the application with `npm start` (there is no `prod` script).
60
+
61
+ ## Upgrading from releases started with `npm run prod`
62
+
63
+ Early 0.2.x releases started with `npm run prod --store=<name>` (through `pear run`). Current releases have no
64
+ `prod` script; start a mainnet node with:
65
+
66
+ ```sh
67
+ npm run start -- --stores-directory stores/<name> --network mainnet
68
+ ```
69
+
70
+ The node reads its key from `stores/<name>/db/keypair.json`. A store created by an older release may live in a
71
+ different location, in which case the key file is not found. Copy that store's `db/keypair.json` to the new path
72
+ before the first start, or restore the wallet from its mnemonic.
73
+
40
74
  ## Post-install checklist
41
75
 
42
76
  Before running tests, install bare globally:
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "trac-msb",
3
3
  "main": "msb.mjs",
4
- "version": "0.2.27",
4
+ "version": "0.2.28",
5
5
  "pear": {
6
6
  "name": "trac-msb",
7
7
  "type": "terminal"
@@ -13,12 +13,13 @@
13
13
  "NOTICE",
14
14
  "rpc/",
15
15
  "SECURITY.md",
16
+ "scripts/check-hyperdht-bogon.cjs",
16
17
  "scripts/hypercore-stallfix/",
17
18
  "scripts/pear-runner.js",
18
19
  "src/"
19
20
  ],
20
21
  "scripts": {
21
- "postinstall": "node scripts/hypercore-stallfix/apply.mjs",
22
+ "postinstall": "node scripts/check-hyperdht-bogon.cjs && node scripts/hypercore-stallfix/apply.mjs",
22
23
  "start": "NODE_OPTIONS='--max-old-space-size=4096' node scripts/pear-runner.js",
23
24
  "rpc": "NODE_OPTIONS='--max-old-space-size=4096' node scripts/pear-runner.js --rpc --host ${npm_config_host} --port ${npm_config_port}",
24
25
  "env": "if [ -f .env ]; then set -a; . ./.env; set +a; fi; NODE_OPTIONS='--max-old-space-size=4096' node scripts/pear-runner.js --stores-directory ${STORES_DIRECTORY:-stores} --network ${NETWORK:-mainnet}",
@@ -35,8 +36,10 @@
35
36
  "test:unit:bare": "brittle-bare -t 60000 tests/unit/unit.test.js",
36
37
  "test:unit:pear": "BRITTLE='-t 60000' brittle-pear tests/unit/unit.test.js",
37
38
  "test:pear-runner": "node --test tests/runner/pear-runner.test.js",
38
- "test:unit:all": "(npm run test:unit:prepare && npm run test:unit:node && npm run test:unit:bare && npm run test:pear-runner) || exit 1",
39
- "test:unit:node:cov": "brittle-node -c -t 60000 tests/unit/unit.test.js"
39
+ "test:unit:all": "(npm run test:unit:prepare && npm run test:hyperdht-bogon && npm run test:unit:node && npm run test:unit:bare && npm run test:pear-runner) || exit 1",
40
+ "test:unit:node:cov": "brittle-node -c -t 60000 tests/unit/unit.test.js",
41
+ "check:dependencies": "node scripts/check-hyperdht-bogon.cjs",
42
+ "test:hyperdht-bogon": "node --test tests/hyperdht-bogon-check.test.cjs && node tests/hyperdht-lan-repro.cjs"
40
43
  },
41
44
  "dependencies": {
42
45
  "autobase": "7.20.1",
@@ -48,6 +51,7 @@
48
51
  "bare-tty": "5.0.2",
49
52
  "bare-utils": "1.5.1",
50
53
  "bech32": "2.0.0",
54
+ "bogon": "^1.2.0",
51
55
  "compact-encoding": "2.18.0",
52
56
  "corestore": "7.5.0",
53
57
  "crypto": "npm:bare-node-crypto",
@@ -58,8 +62,8 @@
58
62
  "hypercore": "11.18.3",
59
63
  "hypercore-crypto": "3.6.1",
60
64
  "hyperdht": "6.29.6",
61
- "hyperswarm": "4.14.2",
62
65
  "hyperschema": "1.17.1",
66
+ "hyperswarm": "4.14.2",
63
67
  "lodash": "^4.18.1",
64
68
  "p-queue": "^9.1.0",
65
69
  "pear-runtime": "1.3.1",
@@ -0,0 +1,50 @@
1
+ #!/usr/bin/env node
2
+ // Check the actual Bogon seen by each reachable HyperDHT, including nested copies.
3
+ // A dependency's overrides and package-lock.json do not constrain its consumers.
4
+ const fs = require('node:fs')
5
+ const path = require('node:path')
6
+ const { createRequire } = require('node:module')
7
+
8
+ function check(root = path.resolve(__dirname, '..')) {
9
+ const pending = [path.join(root, 'package.json')]
10
+ const seen = new Set()
11
+ let checked = 0
12
+ while (pending.length) {
13
+ const manifest = pending.pop()
14
+ if (seen.has(manifest)) continue
15
+ seen.add(manifest)
16
+ const pkg = JSON.parse(fs.readFileSync(manifest, 'utf8'))
17
+ const requireFrom = createRequire(manifest)
18
+ if (pkg.name === 'hyperdht') {
19
+ checked++
20
+ const [major, minor] = pkg.version.split('.').map(Number)
21
+ if (major < 6 || (major === 6 && minor < 29)) continue
22
+ const bogon = requireFrom('bogon')
23
+ if (typeof bogon.isReserved !== 'function' || typeof bogon.isBogon !== 'function') {
24
+ throw new Error(`HyperDHT ${pkg.version} resolves incompatible Bogon at ${requireFrom.resolve('bogon')}. Update the consumer lockfile to bogon >=1.2.0 and reinstall; same-host or LAN peer connections can otherwise crash.`)
25
+ }
26
+ }
27
+ for (const name of Object.keys({ ...pkg.dependencies, ...pkg.optionalDependencies })) {
28
+ // Resolve physical manifests even when package exports hide package.json.
29
+ const paths = requireFrom.resolve.paths(`${name}/package.json`) || []
30
+ const resolved = paths.map(dir => path.join(dir, name, 'package.json')).find(file => fs.existsSync(file))
31
+ if (!resolved) {
32
+ if (pkg.optionalDependencies?.[name]) continue
33
+ throw new Error(`Missing dependency ${name} required by ${pkg.name}`)
34
+ }
35
+ pending.push(fs.realpathSync(resolved))
36
+ }
37
+ }
38
+ if (checked === 0) throw new Error('No HyperDHT found; dependency installation is incomplete.')
39
+ return checked
40
+ }
41
+
42
+ module.exports = { check }
43
+ if (require.main === module) {
44
+ try {
45
+ console.log(`HyperDHT/Bogon compatibility: ${check()} copies checked`)
46
+ } catch (error) {
47
+ console.error(error.message)
48
+ process.exitCode = 1
49
+ }
50
+ }