Skip to content

Fix stale-template timeout assignment during block template rotation - #143

Merged
MoneroOcean merged 1 commit into
masterfrom
codex/fix-stale-block-template-share-logic
May 20, 2026
Merged

MoneroOcean merged 1 commit into
masterfrom
codex/fix-stale-block-template-share-logic

Conversation

@MoneroOcean

Copy link
Copy Markdown
Owner

Motivation

  • The pool must penalize miners who continue mining a previous block more than 4 seconds after it is replaced by stamping the outgoing active template with a timeoutTime so submit-path decay/rejection logic can run.
  • A prior change accidentally assigned timeoutTime to pastBlockTemplates[coin].get(0) (an already-past entry) instead of the template being retired, allowing the just-replaced template to be enqueued without timeoutTime and bypass stale-share handling.

Description

  • Assign timeoutTime on the outgoing template itself via previousTemplate.timeoutTime = Date.now() + 4 * 1000 before enqueueing it into pastBlockTemplates.
  • Preserve existing circular buffer initialization by creating pastBlockTemplates[coin] when missing and then calling pastBlockTemplates[coin].enq(previousTemplate).
  • This change is implemented in lib/pool/templates.js and restores the intended 4-second grace window for the just-staled template so submit logic that checks blockTemplate.timeoutTime will trigger correctly.

Testing

  • Ran the project test runner with npm -s test, which could not complete in this environment due to a missing dependency (protocol-buffers), so the full automated test-suite did not run successfully.

Codex Task

@MoneroOcean MoneroOcean removed the codex label May 20, 2026
@MoneroOcean
MoneroOcean merged commit 7124ddd into master May 20, 2026
2 checks passed
@MoneroOcean
MoneroOcean deleted the codex/fix-stale-block-template-share-logic branch May 20, 2026 21:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant