forked from WikiDeck/wikideck
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9c53445ae3 |
@@ -104,7 +104,7 @@ Mining uses the native CPU RandomX engine. First build the engine, download an e
|
||||
npm run miner:testnet -- --wallet "path/to/encrypted-backup.json" --consent --node http://127.0.0.1:3101 --blocks 3
|
||||
```
|
||||
|
||||
The example is intentionally testnet-only and uses node-a; the dedicated command pins that profile and its fixed genesis. For mainnet, use `npm run miner` with a chain-bound mainnet backup and the configured HTTPS node origin after satisfying the mainnet launch gates. The miner defaults to one worker, light mode, and one block; `--blocks 3` requests up to three accepted blocks. Press **Ctrl+C** to stop it. Do not put the backup password in a command, environment variable, or repository file. The backup and password are decrypted locally and are not sent to the node.
|
||||
The example is intentionally testnet-only and uses node-a; the dedicated command pins that profile and its fixed genesis. For mainnet, use `npm run miner` with a chain-bound mainnet backup after satisfying the mainnet launch gates. On mainnet `--node` defaults to the official node, **https://wikideck.eom.dev**; on testnet it defaults to `http://127.0.0.1:3001`. Pass `--node` to use another HTTPS node origin. The miner defaults to one worker, light mode, and one block; `--blocks 3` requests up to three accepted blocks. Press **Ctrl+C** to stop it. Do not put the backup password in a command, environment variable, or repository file. The backup and password are decrypted locally and are not sent to the node.
|
||||
|
||||
Each template request asks English Wikipedia for up to ten random pages and retries at most three times to find one with an image and readable extract. The same page may be selected again. The node also captures page size, language-link count, revision, pageviews, and derived scores for the mint-time snapshot. If Wikipedia cannot supply the article or its metadata, template creation returns an error; there is no fixed-article fallback. Validators check and commit the included snapshot without contacting Wikipedia during consensus validation.
|
||||
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
import type { NetworkProfile } from '../../shared/network.ts';
|
||||
|
||||
/** The official public Wikideck node. Mainnet miners use it unless --node says otherwise. */
|
||||
export const OFFICIAL_NODE = 'https://wikideck.eom.dev';
|
||||
/** The testnet is private, so testnet miners default to a local node. */
|
||||
export const LOCAL_NODE = 'http://127.0.0.1:3001';
|
||||
|
||||
export function defaultNode(profile: NetworkProfile): string {
|
||||
return profile === 'mainnet' ? OFFICIAL_NODE : LOCAL_NODE;
|
||||
}
|
||||
@@ -7,17 +7,19 @@ import { blockClaimMessage, CONSENSUS, NETWORK, type MiningTemplate, type Testne
|
||||
import { CHAIN_ID, sha256, miningBlob, mintId, blockSchema } from './consensus.ts';
|
||||
import { RandomX } from './randomx.ts';
|
||||
import { assertLaunchAllowed } from '../launch.ts';
|
||||
import { PROFILE } from '../../shared/network.ts';
|
||||
import { defaultNode } from './miner-config.ts';
|
||||
|
||||
assertLaunchAllowed();
|
||||
|
||||
const args = process.argv.slice(2);
|
||||
const arg = (key: string) => { const i = args.indexOf(key); return i < 0 ? undefined : args[i+1]; };
|
||||
if (!args.includes('--consent') || !arg('--wallet')) {
|
||||
console.error('Usage: npm run miner -- --wallet <encrypted-backup.json> --consent [--node http://127.0.0.1:3001] [--fast] [--blocks 1]');
|
||||
console.error(`Usage: npm run miner -- --wallet <encrypted-backup.json> --consent [--node ${defaultNode(PROFILE)}] [--fast] [--blocks 1]`);
|
||||
console.error('Native RandomX mining uses CPU, energy and 256 MiB (light) or roughly 2.1 GiB (fast). Ctrl+C stops mining.');
|
||||
process.exit(1);
|
||||
}
|
||||
const endpoint = new URL(arg('--node') ?? 'http://127.0.0.1:3001');
|
||||
const endpoint = new URL(arg('--node') ?? defaultNode(PROFILE));
|
||||
if (!['http:', 'https:'].includes(endpoint.protocol) || endpoint.username || endpoint.password || endpoint.search || endpoint.hash || endpoint.pathname !== '/') throw new Error('Node must be an HTTP(S) origin');
|
||||
if (endpoint.protocol !== 'https:' && !['localhost','127.0.0.1','[::1]'].includes(endpoint.hostname) && !args.includes('--allow-insecure-node')) throw new Error('Non-loopback HTTP requires --allow-insecure-node');
|
||||
const limit = Number(arg('--blocks') ?? 1);
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { readFile } from 'node:fs/promises';
|
||||
import { defaultNode, OFFICIAL_NODE } from '../server/testnet/miner-config.ts';
|
||||
|
||||
test('mainnet miners default to the official node, testnet stays on loopback', async () => {
|
||||
assert.equal(defaultNode('mainnet'), 'https://wikideck.eom.dev');
|
||||
assert.equal(OFFICIAL_NODE, 'https://wikideck.eom.dev');
|
||||
assert.equal(new URL(defaultNode('testnet')).hostname, '127.0.0.1');
|
||||
const miner = await readFile(new URL('../server/testnet/miner.ts', import.meta.url), 'utf8');
|
||||
assert.match(miner, /arg\('--node'\) \?\? defaultNode\(PROFILE\)/);
|
||||
});
|
||||
Reference in New Issue
Block a user