Make /client/:address/block-template mode-aware#121
Closed
warioishere wants to merge 1 commit into
Closed
Conversation
Previously returned a solo-shaped coinbase (miner at 100%, or fee+miner with dev-fee config) regardless of the miner's actual mode. For PPLNS and group-solo users that's misleading — the real coinbase is a multi-output distribution across pool/group members, not a solo payout. Now picks payoutInformation to match the real coinbase the pool would produce: - solo: unchanged (miner address, optionally fee + miner) - pplns: PplnsService.getPayoutDistribution(coinbasevalue) - group-solo: GroupSoloService.getPayoutDistribution(groupId, coinbasevalue) Response now also includes `mode` and `payoutInformation` fields so the UI can show the right coinbase shape without guessing, plus `groupId` when mode is group-solo. Falls back to solo if the PPLNS/group distribution is empty (e.g. fresh pool with no shares yet) — matches StratumV1Client behavior on an empty PPLNS port. ## Refactor Extracted mode detection into a dedicated `MiningModeService`. Both PplnsController.getMiningMode (REST endpoint) and the block-template endpoint in AppController now delegate to it instead of duplicating the group-then-pplns lookup logic. Moves the detailed mode-detection test cases to mining-mode.service.spec.ts where the logic now lives; PplnsController's spec is simplified to a delegation check. ## Impact on existing specs AppController's constructor gained three new deps (MiningModeService, PplnsService, GroupSoloService). All four spec files that instantiate AppController for HTTP-integration tests are updated to provide the new deps as simple mocks — no existing assertions change.
2 tasks
warioishere
added a commit
that referenced
this pull request
Apr 22, 2026
All of the following features were originally stacked as separate PRs on top of PPLNS: #119 feature/group-solo-mining group-solo engine + API #120 feature/mining-mode-endpoint GET /pplns/mode/:address #121 feature/block-template-mode-aware mode-aware block-template #122 feature/group-chart-endpoint chart + all security hardening + regtests Landing them as separate PRs would have exposed master to intermediate vulnerable states (selfLeave DoS, silent-add token leak, pending-out- of-coinbase math bug, etc.) until #122 closed the stack. All security and regtest work lived exclusively on #122, so merging the lower PRs first would ship a group-solo surface without its hardening. Rolling everything into #118 means the whole feature lands atomically on master with its full test + security story. PR #115 (JDP integration) stays separate, still upstream-blocked. # Conflicts: # src/controllers/pplns/pplns.controller.spec.ts # src/controllers/pplns/pplns.controller.ts
Owner
Author
6 tasks
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
`GET /api/client/:address/block-template` previously returned a solo-shaped coinbase (miner at 100%, or fee+miner with dev-fee config) regardless of the miner's actual mode. For PPLNS and group-solo users that's misleading — the real coinbase is a multi-output distribution across pool/group members, not a solo payout.
Now picks `payoutInformation` to match the real coinbase the pool would produce:
Response shape gained three fields so the UI can render the right coinbase view without re-running detection:
Falls back to solo if the PPLNS/group distribution is empty (e.g. fresh pool with no shares yet) — matches what StratumV1Client does on an empty PPLNS port.
Refactor
Extracted mode detection into a dedicated `MiningModeService`. Both `PplnsController.getMiningMode` (REST endpoint from #120) and the block-template endpoint in `AppController` now delegate to it instead of duplicating the group-then-pplns lookup logic.
Detailed mode-detection test cases moved to `mining-mode.service.spec.ts`; `pplns.controller.spec.ts` is simplified to a delegation check.
Test plan