7730b6993f
- Create assembly/vm.ts with full RandomX VM implementation
- 256 instructions, 2048 iterations per hash
- Native u64/f64 operations in WebAssembly
- Full mode dataset lookups (2GB pre-computed)
- Update miner to use WASM VM for full mode
- mining-worker-asm.js uses pre-compiled WASM
- ~32 H/s per thread (4x faster than light mode)
- 8 threads achieves ~260 H/s
- Clean up redundant code
- Remove mining-worker-full.js (old JIT approach)
- Consolidate 'asm' mode into 'full' mode
42 lines
1.4 KiB
JavaScript
42 lines
1.4 KiB
JavaScript
/**
|
|
* Debug: Scratchpad initialization test
|
|
*/
|
|
|
|
import { fillAes1Rx4 } from '../src/randomx/aes.js';
|
|
import { blake2b } from '../src/blake2b.js';
|
|
|
|
function bytesToHex(bytes, limit = bytes.length) {
|
|
return Array.from(bytes.slice(0, limit)).map(b => b.toString(16).padStart(2, '0')).join('');
|
|
}
|
|
|
|
console.log('=== Scratchpad Init Test ===\n');
|
|
|
|
// Generate seed from input
|
|
const input = new TextEncoder().encode('This is a test');
|
|
const seed = blake2b(input, 64);
|
|
|
|
console.log(`Seed (64 bytes): ${bytesToHex(seed)}`);
|
|
|
|
// Small scratchpad first
|
|
console.log('\nTesting small scratchpad (2KB)...');
|
|
const startSmall = Date.now();
|
|
const smallOutput = fillAes1Rx4(seed, new Uint8Array(2048));
|
|
console.log(`Time: ${Date.now() - startSmall}ms`);
|
|
console.log(`Output hash: ${bytesToHex(blake2b(smallOutput, 32))}`);
|
|
|
|
// Medium scratchpad
|
|
console.log('\nTesting medium scratchpad (256KB)...');
|
|
const startMed = Date.now();
|
|
const medOutput = fillAes1Rx4(seed, new Uint8Array(262144));
|
|
console.log(`Time: ${Date.now() - startMed}ms`);
|
|
console.log(`Output hash: ${bytesToHex(blake2b(medOutput, 32))}`);
|
|
|
|
// Full scratchpad (2MB)
|
|
console.log('\nTesting full scratchpad (2MB)...');
|
|
const startFull = Date.now();
|
|
const fullOutput = fillAes1Rx4(seed, new Uint8Array(2097152));
|
|
console.log(`Time: ${Date.now() - startFull}ms`);
|
|
console.log(`Output hash: ${bytesToHex(blake2b(fullOutput, 32))}`);
|
|
|
|
console.log('\nDone!');
|