feat: v0.3.0 — mid-state SHA-256 + deep audit (9 fixes, 64 tests)#3
Merged
devAsmodeus merged 1 commit intomainfrom Apr 30, 2026
Merged
feat: v0.3.0 — mid-state SHA-256 + deep audit (9 fixes, 64 tests)#3devAsmodeus merged 1 commit intomainfrom
devAsmodeus merged 1 commit intomainfrom
Conversation
Performance: - Mid-state SHA-256 via hashlib.copy() in parallel.worker: ≈×1.5-2 hashrate - time.perf_counter() for EMA/alive-check (was time.time(), NTP-sensitive) Correctness fixes: - store.record_share(accepted=False) — records as pending, updated via on_share_result callback when pool confirms (req_id → share_db_id mapping) - client.difficulty protected by job_lock (writer in _handle_message, reader in mine() — consistent pair with current_job) - mining.authorize response verified; raises ConnectionError on rejection - _submit_req_ids cleared on reconnect (req_id counter resets to 0) - notify_share_accepted moved to pool-confirmed callback (was firing on submit) - block.py: difficulty_to_target(<=0) and swap_words(non-mult-of-4) raise ValueError - except queue.Empty instead of bare except Exception in tight loops New features: - demo.py: offline demo mode (--demo --demo-diff --workers) - stratum.py: suggest_difficulty() + --suggest-diff CLI flag - Prometheus: hopehash_shares_accepted_total + hopehash_shares_rejected_total - storage.py: update_share_accepted(share_id, accepted) Docs: - CLAUDE.md: META section (self-improvement rules), updated package list - learnings.md: live self-learning log (new file) - CHANGELOG.md, ROADMAP.md updated Tests: 59 → 64 (+5 new tests) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
parallel.py):hashlib.sha256().copy()после первых 64 байт header — ≈×1.5–2 к хешрейту, zero depsdemo.py):hope-hash --demo— offline майнинг без пулаstratum.py):--suggest-diff FLOAT→mining.suggest_difficultyAudit fixes
record_share(accepted=True)до ответа пула → теперьaccepted=False, обновляется черезreq_id → share_idcallbackminer.py,storage.py,stratum.pyclient.difficultyбез lock → читается подjob_lockвместе сcurrent_jobminer.py,stratum.pymining.authorizeответ не проверялся → цикл читает доid==auth_id, бросаетConnectionErrorприresult=Falsestratum.py_submit_req_idsне сбрасывался при reconnect →req_id=0reset +_submit_req_ids.clear()miner.pyhopehash_shares_accepted_total+hopehash_shares_rejected_totalminer.pynotify_share_acceptedдо ответа пула → перенесено в_on_share_result(accepted=True)miner.pydifficulty_to_target(0)→ZeroDivisionError;swap_wordsс не-кратной-4 длиной → тихий багblock.pyexcept Exception: passнаQueue.get_nowait()→except queue.Empty:miner.py,parallel.pytime.time()для EMA/intervals →time.perf_counter()miner.py,parallel.pyDocs
CLAUDE.md: META-секция (self-improvement rules) + обновлён список модулейlearnings.md: живой self-learning log (новый файл)Test plan
py -3.11 -m unittest discover -s tests -v— 64 тесты, все зелёные (было 59)TestMidstateSha256(3),test_update_share_accepted_*(2), граничные случаиblock.py(3)🤖 Generated with Claude Code