fix(miner): initialize RandomX SuperScalar programs - mining was never hashing. Critical: Randomx_init_cache only populates Argon2d blocks; Programs[] stayed nil causing nil-ptr crash in every hash. Fix: build all 8 SuperScalar programs after cache init. Validator confirms 1.7 MH/s live. Also: blob fix, stratum job-timeout rotation, hashrate watchdog.
This commit is contained in:
@@ -10,15 +10,15 @@ import (
|
||||
const nonceOffset = 39
|
||||
const nonceSize = 4
|
||||
|
||||
// RandomX JIT + hardware AES for best hashrate on supported CPUs.
|
||||
const randomxFlags = 10 // RANDOMX_FLAG_HARD_AES (2) | RANDOMX_FLAG_JIT (8)
|
||||
// go-randomx is a pure-Go implementation; hardware flags are ignored internally.
|
||||
const randomxFlags = 0
|
||||
|
||||
type Engine struct {
|
||||
mu sync.RWMutex
|
||||
cache *randomx.Randomx_Cache
|
||||
vm *randomx.VM
|
||||
seedHex string
|
||||
blob []byte
|
||||
mu sync.RWMutex
|
||||
cache *randomx.Randomx_Cache
|
||||
vm *randomx.VM
|
||||
seedHex string
|
||||
blob []byte
|
||||
}
|
||||
|
||||
func NewEngine() *Engine {
|
||||
@@ -41,6 +41,13 @@ func (e *Engine) SetJob(seedHex, blobHex string) error {
|
||||
|
||||
if e.seedHex != seedHex {
|
||||
e.cache.Randomx_init_cache(seed)
|
||||
// go-randomx requires SuperScalar programs to be built separately after
|
||||
// seeding the cache; Randomx_init_cache only populates the Argon2d blocks.
|
||||
// Without this step every CalculateHash call crashes with a nil-pointer.
|
||||
gen := randomx.Init_Blake2Generator(seed, 0)
|
||||
for i := range e.cache.Programs {
|
||||
e.cache.Programs[i] = randomx.Build_SuperScalar_Program(gen)
|
||||
}
|
||||
e.vm = e.cache.VM_Initialize()
|
||||
e.seedHex = seedHex
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user