Repository navigation
stratum: login parses as p2pool get_user_details; "/N" sizes the LTC share target - #2354
Merged
Merged
Conversation
…user_details
p2pool work.py get_user_details splits the login with re.split('([+/])'):
the text before the first '+' or '/' is the user, each "+X" or "/X" after
it one parameter, in any order; of each kind the last one float() and
difficulty_to_target take wins. The worker is cut from the user, '_'
winning over '.': user.split(sep)[0] is the address, user.split(sep)[1]
the worker. c2pool took everything after the LAST '+' as the "+N" value
and cut the worker at the LAST separator, so "ADDR+N/M" lost both
suffixes and a worker name with two separators left a primary that is no
address.
core/stratum_username.hpp parse_login, which handle_authorize now uses:
- every "+X" parameter is removed wherever it stands; the "/X" tokens
stay in order;
- a "+N" or "/N" value is taken only when p2pool's difficulty_to_target
takes it (finite (0xffff0000 * 2**192 + 1) / N: N above ~1e-241); one
it does not take is skipped, an earlier value stays;
- the worker comes from the user part only (before the first '+' or
'/'); '_' wins over '.'; the address is the text before the first
separator, cut at a '.' too (no address has one);
- the comma form "PRIMARY,MERGED" (p2pool-merged-v36 splits the comma
first): each address loses its own worker suffix, the merged one's
worker first. When PRIMARY had a suffix, p2pool tests the swapped
order on PRIMARY with it, which is never an address, so it never
swaps: resolve_merged_login takes the second address as a merged
chain's or ignores it (second_may_swap);
- the two-address split is decided once, by parse_login, on the login as
typed (Login::merged_sep), and parse_address_separators splits there: a
first address cut by its suffix to index 20 or before (".|D1,D2") keeps
its second address named, as before;
- a '|', ';' or ' ' after a worker suffix is part of the worker, as in
p2pool; c2pool's '|', ';', ' ' forms without a suffix before the
separator ("L|D", "L|D.rig") are unchanged;
- a merged token "CHAIN_ID:ADDR.worker" loses its worker;
- a "/" token no longer stops the two-address split;
- "/N" is set or cleared by every authorize (an earlier login's was
kept).
Changed logins (A an address, L and D an LTC and a DOGE address):
A+1024/512 was: no "+N", no "/N" now: +1024 /512
A.a.b was: primary "A.a", worker b now: A, worker a
A_a_b was: primary "A_a", worker b now: A, worker a
A_a.b was: worker b now: worker a.b
A.a_b was: worker a_b now: worker b
A.rig+1024/512 was: no "+N", no "/N" now: +1024 /512
A_rig/512+16 was: worker "rig/512", no "/N" now: worker rig, /512
A.a.b/64+8 was: primary "A.a" now: A, worker a
A+512+abc was: primary "A+512" now: A, +512
A+ was: primary "A+" now: A
A/2/x+4+y was: no "+N" now: +4
A/1024.rig was: /1024, worker rig now: neither
A/1.5.rig was: /1.5, worker rig now: neither
A/0.5.rig/2 was: worker rig now: no worker
A/512/1e-300 was: /1e-300 now: /512
A+1e-300 was: fixed difficulty 1e-300 now: none (vardiff)
L.rig,D was: D lost now: L, D, worker rig
L.a,D.b was: primary "L.a" now: L, D, worker b
L,D.a.b was: worker b now: worker a.b
L,D/512 was: primary "L,D" now: L, D, /512
L+1024/98:D/512 was: D, "+N" and "/N" lost now: all three
L/98:D+1024/512 was: no "+N", no "/N" now: both
Unchanged: "L.rig|D", "L.rig D", "L_rig;D" (L, the rest the worker's,
DOGE from L's key), "L.my rig", "D.rig,L" (case 5: LTC to hash160(D),
DOGE to D), "D,L" (swapped, auto-corrected), "L|D".
The same on every coin's stratum. Where this change departs from p2pool:
- "0", "inf" (1e309 is one), "nan", hex and whitespace-padded values are
ignored and do not override an earlier value: "L/512/0" stays 512,
where p2pool takes "0" as the easiest share (pre_target3);
- "A.a_b" pays A, where p2pool's user is "A.a", no address;
- "L.a,D.b" and "L_a,D.b" pay L, where p2pool-merged-v36 keeps the user
"L.a" / "L_a" and pays the LTC share to hash160(D) (case 4).
Known departures from p2pool, pre-existing (unchanged policy); each pays
only an address the miner typed:
- "D1,D2" (also "D1.,D2.", "D1.my rig,D2."): LTC to hash160(D1);
p2pool's case 4 pays it to hash160(D2);
- "L1,L2": DOGE to hash160(L2); p2pool derives it from L1;
- "junk,L1" (junk longer than 20 characters): pays L1; p2pool
redistributes it.
c2pool extensions, unchanged: '|', ';' and ' ' as two-address separators
when no worker suffix comes before them ("L|D"); "/CHAIN_ID:ADDR" tokens
(the last one per chain wins; "/98:<an LTC address>" pays DOGE to its
hash160; a worker is taken from "/CHAIN_ID:ADDR.worker"); a separator at
index 20 or before does not split the login (a comma inside a short
first address is kept in it).
…red_share_target) p2pool get_user_details turns "ADDR/N" into desired_share_target = difficulty_to_target(float(N)); get_work then runs neither per-miner cap (both sit under `if desired_share_target is None`) and the share target is clipped into [pre_target3/30, pre_target3] as any desired target. c2pool parsed "/N" (share_difficulty_override_) but no lane read it. Core: - IWorkSource::build_connection_coinbase_for takes an optional desired_share_difficulty; the default ignores it, so a work source that does not override it builds what it built before. - StratumSession reads the login's "/N" once per job and passes it with the build; the job's frozen share bits carry it, so a re-authorize changes the jobs built after it only. - MiningInterface hands it to ref_hash_fn (a new last parameter). - chain::difficulty_to_target: p2pool's difficulty_to_target, evaluated as python does (the numerator rounded to a double, one IEEE division, int() of the double); none where python raises (N below ~1e-241). The login parser takes "+N" / "/N" exactly where it has a value. LTC: with "/N", job_desired_share_target is difficulty_to_target(N) in place of Cap 1 (1.67% of pool shares) and Cap 2 (dust); compute_share_target clips it as before. N is in p2pool's units, as "+N" is (difficulty 1 = 0x00000000ffff...); DUMB_SCRYPT_DIFF scales only the set_difficulty sent. Without "/N" the caps are unchanged. Not wired (these lanes do not take "/N" yet; no override exists): - BTC, BCH, BIP110: no per-miner desired target. Every job's desired target is the block target (bits_to_target(block_bits)) clipped into the band, so there is no cap for "/N" to replace. - DASH does not take it: DASHWorkSource does not override build_connection_coinbase_for. Its desired target is computed in main_dash.cpp's producer-job lambda -> dash::mint::build_producer_job -> mint_runloop.hpp desired_share_target -> stratum/work_target.hpp modulate_desired_share_target; wiring it means overriding build_connection_coinbase_for and passing the value to the producer job. - DGB does not take it: DGBWorkSource overrides only build_connection_coinbase; wiring it means overriding build_connection_coinbase_for. KATs: core_test ShareDifficultySuffix.* (it reaches ref_hash_fn; the coinbase is unchanged where it is ignored); share_test ShareDifficultySuffix.* (the LTC desired target, the band clip, the rate cap replaced, no "/N" unchanged) and ShareDifficultyStratumSession.* (over TCP: "+N/M" in either order, the two-address and merged forms); test_ltc_work_target (difficulty_to_target against python's values, both caps replaced; the parser and difficulty_to_target take exactly the values python takes, the boundary pair 1.4996739303382901e-241 / ...902e-241 included); test_stratum_interim_hardening StratumShareDifficulty.* (every job, "+N" alone unchanged, a re-authorize clears it). The main_ltc.cpp source pin (RedistributeSplit) pins the ref_hash lambda's new signature and the "/N" it sizes the share target with.
frstrtr
added a commit
that referenced
this pull request
Nov 28, 2026
master adds IWorkSource::build_connection_coinbase_for(..., desired_share_difficulty) (#2354, the login's "/N"). The DGB override takes the parameter and does not use it yet: its share target stays the per-login cap.
frstrtr
added a commit
that referenced
this pull request
Nov 28, 2026
master's ref_hash_fn_t gained a trailing const std::optional<double>& (#2354); the AuxRig lambda in submit_scrypt_once_test.cpp takes it too.
This was referenced Nov 29, 2026
Closed
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.
Two commits: the stratum login parser follows p2pool's
get_user_details, and the login's/Nsizes the LTC job's share target as p2pool'sdesired_share_targetdoes.core(stratum): login "+N", "/N" and worker names parse as p2pool get_user_details (37864cc)
parse_login()follows p2pool'sre.split('([+/])'):+X//Xparameter is removed wherever it stands; the last valid+N//Nwins;+or/), with_taking precedence over..Login::merged_sep). The per-address worker cut applies to the comma form only.D.rig,Ldoes not swap (p2pool checks the swap onD.rig).+N//Nvalue is accepted only whendifficulty_to_target(N)is finite.0,inf(incl.1e309),nan, hex and whitespace-padded values are ignored and do not override an earlier value.D1,D2;L1,L2;junk,L1with junk longer than 20 characters;/CHAIN_ID:ADDRextensions..|D1,D2), pays the LTC share to hash160(DOGE) as in case 4; p2pool redistributes the LTC share.core, ltc: the login's "/N" sizes its jobs' share target (9804563)
IWorkSource::build_connection_coinbase_fortakesdesired_share_difficulty; the default ignores it.StratumSessionreads the login's/Nonce per job; the job's frozen share bits carry it.chain::difficulty_to_target(N)follows p2pool's value:0xffff·2^208 / Nas one IEEE division,-1 + 0.5, then int(). It is none where p2pool raises (N < 1.4996739303382902e-241, or N ≤ 0 / not finite)./N, the job's desired share target isdifficulty_to_target(N)in place of the rate cap (~1.67%) and the dust cap, then clipped into [pre3/30, pre3] as before. N is in p2pool's internal difficulty units, the same as+N./Nyet. Their coinbase and targets are unchanged.Tests (vm905)
test_stratum_username 28, test_stratum_interim_hardening 46, core_test 870, share_test 850, test_ltc_work_target 7, test_stratum_extensions 44, test_dash_stratum_work_source 172, test_dash_work_source 98, test_dash_work_target 14, test_dash_work_job_targets 9, test_dash_stratum_binding 6, test_dash_job_notify_roundtrip 6, test_dash_get_work 4: all PASSED. The first commit builds on its own.
KATs:
StratumUsernamePython.*is a table taken from p2pool's ownget_user_detailsoutput.DifficultyToTargetIsPythonsandLoginDiffParseAcceptsWhatDifficultyToTargetDoesare checked against p2pool values, including the boundary pair 1.4996739303382901e-241 / …902e-241./Nreaches the LTC job build over TCP.