Skip to content

Make /client/:address/block-template mode-aware#121

Closed
warioishere wants to merge 1 commit into
feature/mining-mode-endpointfrom
feature/block-template-mode-aware
Closed

Make /client/:address/block-template mode-aware#121
warioishere wants to merge 1 commit into
feature/mining-mode-endpointfrom
feature/block-template-mode-aware

Conversation

@warioishere
Copy link
Copy Markdown
Owner

Stacks on #120. Merge order: #118#119#120 → this PR.

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:

Mode payoutInformation source
solo unchanged (miner address, optionally fee + miner)
pplns `PplnsService.getPayoutDistribution(coinbasevalue)`
group-solo `GroupSoloService.getPayoutDistribution(groupId, coinbasevalue)`

Response shape gained three fields so the UI can render the right coinbase view without re-running detection:

  • `mode`: `'solo' | 'pplns' | 'group-solo'`
  • `payoutInformation`: the array used to build the coinbase
  • `groupId`: only when `mode === 'group-solo'`

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

  • Full Jest suite green (510 tests, 60 suites)
  • Build clean
  • Existing block-template/peer-info/core-info integration tests updated to provide the new constructor deps as mocks

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.
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
@warioishere
Copy link
Copy Markdown
Owner Author

Superseded by #118 — all commits from this branch were rolled into feature/pplns-pool-support in the Collapse-Stack merge commit 75987d4 on 2026-04-22. The branch on origin is preserved (not deleted) so the history is recoverable if needed. See #118 for the consolidated diff and atomic merge.

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