Skip to content

Commit

Permalink
Merge pull request #97 from ethstorage/task_summary
Browse files Browse the repository at this point in the history
Task summary output to log
  • Loading branch information
syntrust authored Nov 24, 2023
2 parents 454b19a + 0959f80 commit 02607a0
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions ethstorage/miner/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ func (w *worker) assignTasks(task task, block eth.L1BlockRef, reqDiff *big.Int)
w.lg.Debug("Mining task queued", "shard", ti.shardIdx, "thread", ti.thread, "block", ti.blockNumber, "blockTime", block.Time, "now", uint64(time.Now().Unix()))
}
}
w.lg.Info("Mining tasks assigned", "shard", task.shardIdx, "threads", w.config.ThreadsPerShard, "block", block.Number, "nonces", w.config.NonceLimit)
}

func (w *worker) updateDifficulty(shardIdx, blockTime uint64) (*big.Int, error) {
Expand Down Expand Up @@ -352,13 +353,16 @@ func (w *worker) checkTxStatus(txHash common.Hash, miner common.Address) {
func (w *worker) mineTask(t *taskItem) (bool, error) {
startTime := time.Now()
nonce := t.nonceStart
if t.thread == 0 {
w.lg.Info("Mining tasks started", "shard", t.shardIdx, "threads", w.config.ThreadsPerShard, "block", t.blockNumber, "nonces", fmt.Sprintf("%d~%d", 0, w.config.NonceLimit))
}
w.lg.Debug("Mining task started", "shard", t.shardIdx, "thread", t.thread, "block", t.blockNumber, "nonces", fmt.Sprintf("%d~%d", t.nonceStart, t.nonceEnd))
for w.isRunning() {
if time.Since(startTime).Seconds() > mineTimeOut {
w.lg.Warn("Mining task timed out", "shard", t.shardIdx, "thread", t.thread, "block", t.blockNumber, "noncesTried", nonce-t.nonceStart)
if t.thread == 0 {
nonceTriedTotal := (nonce - t.nonceStart) * w.config.ThreadsPerShard
w.lg.Warn("Mining tasks timed out", "shard", t.shardIdx, "block", t.blockNumber,
"noncesTried", fmt.Sprintf("%d(%.1f%%)", nonceTriedTotal, float64(nonceTriedTotal*100)/float64(w.config.NonceLimit)),
)
}
w.lg.Debug("Mining task timed out", "shard", t.shardIdx, "thread", t.thread, "block", t.blockNumber, "noncesTried", nonce-t.nonceStart)
break
}
if nonce >= t.nonceEnd {
Expand All @@ -368,7 +372,7 @@ func (w *worker) mineTask(t *taskItem) (bool, error) {
}
w.lg.Debug("The nonces are exhausted in this slot, waiting for the next block",
"samplingTime", fmt.Sprintf("%.1fs", time.Since(startTime).Seconds()),
"shard", t.shardIdx, "thread", t.thread, "block", t.blockNumber, "nonce", nonce)
"shard", t.shardIdx, "thread", t.thread, "block", t.blockNumber, "nonceEnd", nonce)
break
}
hash0 := initHash(t.miner, t.blockHash, nonce)
Expand Down

0 comments on commit 02607a0

Please sign in to comment.