Skip to content

Conversation

@danielj86
Copy link
Collaborator

Summary

Implements upstream difficulty filtering to prevent share rejections when pool VarDiff exceeds worker difficulty.

Problem

When operating a proxy with fixed low-difficulty workers connecting to a VarDiff-enabled pool:

  1. Workers submit shares at their assigned difficulty (e.g., 50,000)
  2. Pool VarDiff algorithm increases difficulty over time (e.g., to 5,000,000)
  3. Proxy forwards all worker shares that pass worker-level validation
  4. Pool rejects shares below its current difficulty threshold
  5. Results in mass "low difficulty share" rejections and wasted bandwidth

Solution

New --fixed-diff=N configuration option that:

  • Sets a minimum difficulty threshold for upstream pool submission
  • Filters shares below this threshold before forwarding to pool
  • Returns "OK" to workers for filtered shares (transparent operation)
  • Preserves donation share flow (filtering only applies to user pool)

Usage

CLI:

./xmrig-proxy -o pool:3333 -u wallet --custom-diff=50000 --fixed-diff=500000

JSON Config:

{
    "custom-diff": 50000,
    "fixed-diff": 500000
}

Behavior

Setting Effect
--custom-diff=50000 Workers receive 50k difficulty jobs
--fixed-diff=500000 Only shares ≥500k forwarded to pool
  • Workers receive "OK" for all valid shares (including filtered ones)
  • Pool only receives high-difficulty shares
  • No VarDiff ramp-up from low-diff share flood
  • Zero "low difficulty share" rejections

Implementation Details

  • Validation: Minimum 100, maximum INT_MAX
  • Filtering location: SimpleMapper::submit() after strategy selection
  • Donation bypass: Filtering skipped when donate strategy is active
  • Logging: Filtered shares logged at DEBUG level only

Files Changed

File Change
src/base/kernel/interfaces/IConfig.h FixedDiffKey = 1118
src/core/config/Config.h Member variable and accessor
src/core/config/Config.cpp Parser and serializer
src/core/config/Config_platform.h CLI option registration
src/core/config/ConfigTransform.cpp CLI-to-JSON transform
src/core/config/usage.h Help text
src/proxy/splitters/simple/SimpleMapper.cpp Core filtering logic
src/Summary.cpp Startup configuration display

Test Plan

  • Verify --fixed-diff appears in --help output
  • Confirm startup displays fixed-diff value when configured
  • Test share filtering with DEBUG logging enabled
  • Validate workers receive "OK" for filtered shares
  • Confirm pool receives only shares meeting threshold

Implements a new configuration option that filters shares before
forwarding them to the upstream pool. This addresses the issue where
pool VarDiff ramps aggressively, causing mass "low difficulty share"
rejections when workers operate at fixed low difficulty.

Problem:
- Workers connect with low difficulty (e.g., 50k)
- Pool VarDiff increases difficulty to millions
- Proxy forwards all worker shares meeting worker difficulty
- Pool rejects shares below its current difficulty threshold
- Result: Wasted bandwidth, rejected shares, unstable mining

Solution:
- New --fixed-diff=N option sets minimum difficulty for upstream
- Shares below threshold are filtered before pool submission
- Workers receive "OK" response (transparent to miners)
- Only qualifying shares are forwarded to pool
- Donation shares bypass filtering (preserves dev donation flow)

Configuration:
- CLI: --fixed-diff=N
- JSON: "fixed-diff": N
- Valid range: 100 to INT_MAX
- Default: 0 (disabled)

Files modified:
- IConfig.h: Add FixedDiffKey constant
- Config.h/cpp: Add member, accessor, parser, serializer
- Config_platform.h: Register CLI option
- ConfigTransform.cpp: CLI to JSON transformation
- usage.h: Help text documentation
- SimpleMapper.cpp: Core filtering logic
- Summary.cpp: Startup display of configuration
@danielj86 danielj86 merged commit 3d3f15b into master Dec 12, 2025
8 checks passed
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.

2 participants