Repository navigation
3.x.x: mining.authorize is bounded by default: 32 attempts per session, one node validation per payout address and at most four at once per frontend (#823) - #828
Conversation
…n, one node validation per payout address and at most four at once per frontend (#823) PRISM_STRATUM_MAX_AUTHORIZE_ATTEMPTS_PER_INTERVAL defaulted to 0, so a session could authorize without limit, and the identity cache was keyed by the whole username, so every new worker suffix cost a validateaddress call. Usernames are not authenticated. - The budget now defaults to 32 per interval in the code, compose.yaml and .env.example, the value docs/prism-b4-stratum-admission.md recommends; 0 still disables it. StratumConfig::default() holds the code default and from_env starts from it. - Resolved identities are cached by the address before the first '.', so a new worker suffix on a known address costs no node call. A failed validation is still never cached. - Sessions naming the same new address share one validation, and a frontend runs at most four validations at once. A session waits at most five seconds in all, behind another session's validation of its address and then for a slot, before it is refused with backend-rpc-unavailable and may retry. Only authorization waits on this bound; share submission, getblocktemplate and submitblock never do. - A full cache drops the entries of addresses the node refused, which resolved to the configured fallback, before the others, so a run of them cannot push out the addresses that pay as typed. - PRISM_STRATUM_MAX_CONNECTIONS_PER_IP stays 0 by default: with no PROXY-protocol support, every miner behind a balancer that sends no PROXY header shares the balancer's addresses. The configuration docs now say so. Two username-capacity tests poll mining.authorize every 20 ms on one connection; they now disable the budget, which they do not measure. Refs #823 Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Found 1 test failure on Blacksmith runners: Failure
|
|
@codex review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex Review: Didn't find any major issues. Breezy! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
There was a problem hiding this comment.
3 findings posted inline.
Findings without an inline location
1 nit
2. [low · nit] Fallback validation reuses the spent deadline, so a definitive refusal can end as busy and is not cached
crates/qbit-prism-server/src/coordinator.rs:4240
EP-ERRORS. deadline is set once at coordinator.rs:4186. resolve() takes validation_slot(deadline) at 4196 and frees the slot at 4198. The fallback resolve at 4240 then needs a new slot under the same deadline. Suppose all 4 slots are busy: the session waits about 5 s, and the node answers isvalid:false. The fallback slot wait then times out right away with busy(). The node's definitive answer is thrown away, remember() at 4255 is never reached, and each retry repeats both waits and RPCs. This only happens when the frontend is saturated, and a retry that gets a slot early succeeds, so the cost is worse odds and wasted node calls, not a wrong payout.
…orize doc (#823) check_prism_pool_acquires.py requires every acquire-shaped call in the server to carry a counted classification. The validation slot added for #823 acquires a tokio semaphore, not a database connection, so it is listed as non-database, as the stratum job-limit semaphores are. docs/prism-configuration.md said share submission never waits on the validation bound. A session handles its requests in order, so shares it sends while its own mining.authorize waits are answered after it. Other sessions' shares never wait on it. Refs #823 Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
@codex review |
|
Codex Review: Didn't find any major issues. More of your lovely PRs please. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
…it was validated in, and a full identity cache drops expired entries first (#823) authorize took a validation slot for the address, released it after the node call, then waited for a second slot under the same five-second deadline to resolve the configured fallback. With every slot in use and other validations queued, a session that got its first slot late lost the node's definitive refusal to that second wait: it was refused as busy, nothing was cached, and each retry repeated both waits and both calls. One slot now covers both node calls of an authorization. The wait bound is unchanged: a session waits at most five seconds in all, behind another session's validation of its address and then for one slot. When the identity cache was full, remember() first dropped every entry that resolved to the fallback, however fresh, and kept address entries past the hour that cached() already reads as misses. It now drops expired entries first, then fallback entries, then, as before, entries older than five minutes and finally the rest. docs/prism-configuration.md says so. The payout_identity module comment now says, as the configuration doc does, that other sessions' share submission never waits on these. Refs #823 Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
qbit-reviewer #2 (the fallback validation reused the spent deadline) is fixed in 0a3724f. Checks on this head: |
|
@codex review |
|
Codex Review: Didn't find any major issues. More of your lovely PRs please. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
![Fix with [code]smith](https://pr-comments-assets.blacksmith.sh/codesmith/fix-with-codesmith-light-3x.png)
mining.authorizeis now bounded by default: 32 attempts per session per interval, one nodevalidateaddressper payout address, and at most four validations at once per frontend.The problem (#823)
PRISM_STRATUM_MAX_AUTHORIZE_ATTEMPTS_PER_INTERVALdefaulted to 0 instratum.rs,compose.yamland.env.example, andSessionBudget::chargetreats 0 as unlimited..suffixcost avalidateaddresscall. Usernames are not authenticated.getblocktemplateandsubmitblock.The change
DEFAULT_MAX_AUTHORIZE_ATTEMPTS_PER_INTERVAL = 32is used byStratumConfig::default(), andfrom_envstarts from it.compose.yamluses:-32and.env.examplesets=32. 0 still disables the budget.docs/prism-b4-stratum-admission.mdalready recommended.., exactly as typed, so ledgerminer_idlabels are unchanged.coordinator/payout_identity.rs.MAX_CONCURRENT_VALIDATIONS = 4run at once.VALIDATION_WAIT(5 s) in all, first behind another session's validation of its address and then for a slot. After that it is refused with the retryablebackend-rpc-unavailable, and its connection stays open.authorizetakes this path. Share submission,getblocktemplateandsubmitblocknever wait on it. Permits and locks are released by RAII on error and on cancellation.PRISM_USERNAME_FALLBACK_ADDRESS, before the others. A run of such addresses cannot push out addresses that pay as typed.PRISM_STRATUM_MAX_CONNECTIONS_PER_IPstays 0 by default. With no PROXY-protocol support, every miner behind a balancer that sends no PROXY header shares the balancer's addresses.docs/prism-configuration.mdnow says so.docs/prism-configuration.mdanddocs/prism-b4-stratum-admission.mdare updated.Tests
New tests in
coordinator::miner_tests::authorize, against the realCoordinator::authorizewith the mock node, which now answersvalidateaddress:worker_suffixes_on_one_address_share_one_validation. On the base this made 101 calls instead of 1.concurrent_sessions_naming_a_new_address_share_its_validation. On the base this made 16 calls instead of 1.validations_wait_for_a_slot_and_a_full_wait_is_a_retryable_refusala_session_behind_another_validation_waits_within_the_same_bounda_full_cache_drops_fallback_entries_before_addressesNew test in
tests/stratum_protocol.rs:the_default_authorize_budget_bounds_username_cycling. On the base it fails, because the budget is 0 instead of 32.Updated tests:
reauthorization_retains_original_username_capacity_until_timer_expiryandreauthorization_disconnect_reclaims_current_and_retained_username_capacitypollmining.authorizeevery 20 ms on one connection. They now set the budget to 0, because the budget is not what they measure.Mutation checks: each of these mutants fails its test.
Run at this head (
d2541106) withCARGO_BUILD_JOBS=6and--test-threads=4:cargo test -p qbit-prism-server --libcargo test -p qbit-prism-server --test stratum_protocol--test stratum_admission / stratum_admission_gate / stratum_codec / stratum_properties / stratum_rebuild_lane--test observability / landing_metrics / vardiff_convergence / work_refresh_metricPRISM_TEST_REQUIRE_INTEGRATION=1 PRISM_TEST_DATABASE_URL=<disposable PostgreSQL 16> cargo test -p qbit-prism-server --test authorization_rpccargo clippy --locked -p qbit-prism-server --all-targets -- -D warningssqlx-corewarningscargo fmt -p qbit-prism-server -- --checkpython3 scripts/check_prism_settings.py,check_deleted_test_map.py,check_gate_env_reads.py, andpython3 -m unittest tests.test_check_prism_settings tests.test_mainnet_compose_contract tests.test_mining_compose_profilesThis branch and #822's touch disjoint files. With both applied,
cargo test -p qbit-prism-server --libpassed 890, with 3 ignored.The branch is based on
987027feand merges cleanly with the current3.x.x(d0c649b4). CI tests the merge result.Rollout
Release-note text:
Before deploying:
compose.yaml. The qbit-toolsgroup_varsfor mainnet and testnet4 set noPRISM_STRATUM_MAX_AUTHORIZE_ATTEMPTS_PER_INTERVAL, so both get 32.mining.authorizefor more than 32 downstream workers over one upstream connection within an interval needs a higher value, or 0.Follow-ups in qbit-tools, not in this PR:
group_varsshould pinPRISM_STRATUM_MAX_CONNECTIONS_PER_IP: "0"explicitly, as mainnet'sprism_pair.ymldoes, rather than inherit it.Review notes
tests/authorization_rpc.rsasserts that contract, and changing it is a separate decision.validateaddresstakes about 1 ms. A cold-cache herd of many new addresses arriving while the node is slow would get retryable refusals after 5 s. This was not load-tested against a real qbitd.Refs #823
🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need.