Skip to content

Independent per-chain target checking and AuxPoW proof submission#105

Open
Boblepointu wants to merge 33 commits into
doged-io:masterfrom
FrenchBTC:pr/perchain-targets
Open

Independent per-chain target checking and AuxPoW proof submission#105
Boblepointu wants to merge 33 commits into
doged-io:masterfrom
FrenchBTC:pr/perchain-targets

Conversation

@Boblepointu
Copy link
Copy Markdown

@Boblepointu Boblepointu commented Apr 16, 2026

Summary

When a miner submits a share, compare the PoW hash against each configured external chain's difficulty target independently. A share can solve LTC without meeting DOGE difficulty, or vice versa — standard multi-chain merged mining behavior.

Depends on PR #104 (Multi-chain merge-mine manager).

What's included

Component Files Description
ShareValidationResult stratumsubmit.{h,cpp} Replaces simple ShareResult enum; flags dogeBlockFound, shareAccepted, plus auxChainsSolved vector
ValidateShareEx stratumsubmit.cpp Computes PoW hash once, tests against DOGE target + each external chain's nBits independently
NBitsToTarget stratumsubmit.cpp Compact nBits → arith_uint256 conversion
BuildAuxPowForChain stratumsubmit.cpp Constructs serialized CAuxPow proof for a specific solved external chain
MergeMineCommitment stratumjob.h Struct holding aux tree root, tree size, nonce embedded in the parent coinbase
AuxChainTarget stratumjob.h Per-chain nBits snapshot stored in each StratumJob
CreateJob stratumjob.cpp Injects fabe6d6d merge-mine commitment into coinbase scriptSig
HandleSubmit stratum.cpp Iterates auxChainsSolved and submits AuxPoW proofs per chain
OnExternalWorkUpdate stratum.{h,cpp} Triggers new job broadcast when external chain work changes
Init wiring init.cpp GlobalAuxManager lifecycle, MergeMineManager start/stop, work callback, startup banner

How it works

Miner submits share
    │
    ├── hash < DOGE target? → submitblock to doged
    ├── hash < LTC target?  → build CAuxPow, submit to LTC via RPC
    ├── hash < BELLS target? → build CAuxPow, submit to BELLS via RPC
    └── hash ≥ worker diff?  → accept share for hashrate accounting

Each chain is checked independently — a single share can solve multiple chains simultaneously.

Test plan

  • ninja check-stratum — all unit tests pass
  • Integration: mine against doged with 2 external chains at low regtest difficulty, verify blocks appear on all chains
  • Verify startup banner and summary log show configured chains

Add stratum protocol, config, worker, job, submit, stats and server
modules to the server library, and wire the stratum unit test suite.
- Remove unrelated copyright header from src/rpc/mining.cpp
- Replace flaky time.sleep(1) with wait_until on debug log in stratum test
- Move stratum config log from AppInitServers to InitStratumServer call site
- Add AssertLockHeld(m_cs) in HandleSubmit for thread-safety sanity
- Add WIN32 compat for evthread (match httpserver.cpp pattern)
- Replace POSIX socket headers with compat.h for cross-platform builds

Made-with: Cursor
- Introduced a new HTML file for visualizing the dependency graph of pull requests.
- Implemented a responsive design with SVG elements to represent PR statuses (open, ready, queued, draft).
- Added a legend to explain the color coding of PR states.

This visualization aids in understanding the current state of pull requests in the project.
Wire stratumaux.cpp into the server library and stratumaux_tests.cpp
into the stratum unit test suite.

Made-with: Cursor
…rface

Introduce MergeMineManager, ExternalChainClient and the IAuxChainModule
abstract interface that allow doged's stratum server to poll and submit
work to an arbitrary number of external PoW chains via RPC.

- mergemine.h/cpp: IAuxChainModule interface, ExternalChainClient
  implementation, MergeMineManager with sorted work snapshots
- stratumconfig.h/cpp: parse -mergemine=name:host:port:user:pass:chainid[:poll_ms]
- logging.h/cpp: add BCLog::MERGEMINE category
Improve the StratumAuxManager work cache with FIFO eviction,
optional GetWork/RemoveWork helpers, and move MergeMineCommitment
to stratumjob.h for shared use.

Update createauxblock, submitauxblock and getmergemineinfo RPCs
to surface external chain data and handle multi-block stress.

Add stratumaux unit tests for the cache improvements.
Replace the simple ShareResult enum with ShareValidationResult, which
tracks per-chain solved status independently.  ValidateShareEx compares
the miner's PoW hash against each configured external chain's nBits
target, so a share can solve one aux chain without needing to meet
DOGE difficulty.

- stratumjob.h/cpp: add MergeMineCommitment, AuxChainTarget to StratumJob;
  inject fabe6d6d commitment into coinbase scriptSig during CreateJob
- stratumsubmit.h/cpp: ShareValidationResult, ValidateShareEx,
  NBitsToTarget, BuildAuxPowForChain
- stratum.h/cpp: rewrite HandleSubmit to iterate auxChainsSolved and
  submit AuxPoW proofs per chain; add OnExternalWorkUpdate

Made-with: Cursor
- Start/stop MergeMineManager and GlobalAuxManager in the init sequence
- Wire MergeMineManager work callback to trigger fresh stratum jobs
  when external chain work updates
- Add doged ASCII startup banner and summary log block
- Add -coinbasetag CLI argument for custom coinbase inscription

Made-with: Cursor
@Boblepointu Boblepointu force-pushed the pr/perchain-targets branch from 9bd0ac0 to a361224 Compare April 17, 2026 14:24
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