Repository navigation
collect_submit: refuse mistyped endpoints and oversized PoW asks - #748
Merged
joshuaswarren merged 1 commit intoNov 23, 2026
Merged
Conversation
A --submit URL without a scheme, or with an unclosed IPv6 bracket, made urllib raise ValueError while building the request, outside the SubmitError the collectors catch, so the contributor saw a traceback. Validate the endpoint once (http or https, a host, a valid port, no whitespace, control character, query or fragment) and raise SubmitError before any request. A pow_invalid answer could ask for any difficulty, and solve_pow would then spin forever. Cap the ask at MAX_POW_DIFFICULTY (24 bits) and refuse a higher one with the server's answer in the error.
Owner
|
GREEN at 6536f2c |
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Files Reviewed (2 files)
Reviewed by free · Input: 160.2K · Output: 1.2K · Cached: 50.4K |
Owner
|
GREEN at 6536f2c |
Owner
|
Thanks @only21mil — the submit endpoint now reports a clean FAILED + exit 4 on a bad endpoint instead of letting a ValueError escape. Merged at 3a2ca65. |
Contributor
Author
|
You're welcome my friend |
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.
Problem
When
--submithas no scheme, or the endpoint answerspow_invalidwith a hugemin_difficulty, both collectors exit with aValueErrortraceback or hang, instead of printing[submit] FAILEDand exiting 4.submit()andsubmit_payload()build theRequestoutside_request'stry, so urllib'sValueErrorfor no scheme or an unclosed[escapes the collectors'except SubmitError.min_difficultyto pure-Pythonsolve_pow(about 2^bits hashes); an ask of 1000000 never returns.Change
_endpoint_base()accepts onlyhttporhttpswith a host, a valid port and no whitespace, control character,?or#, or raisesSubmitErrorbefore any request.MAX_POW_DIFFICULTY = 24, client-only (server floor 18, limit 64). At 24 bitssolve_powaveraged 5.0 s, worst 21.3 s, over 8 digests on one core.Verification
Tested by: AI agent.
vulkaninfoinstalled.collect_quick.py --submitwith no scheme →collect_deep.py --submita loopback server answering 404 to the probe and403 pow_invalid(min_difficulty1000000) to each initiate.Before (
5ef30346c, main):After (
6536f2ce8):6536f2ce8is on2aef87273and merges cleanly into5ef30346c; the merge gives the same output.Links
collect_submit.pytest_collect.pyNot shown
collectors.yml.Checks run by AI agent
_retry_difficulty()replaces_min_difficulty()and the check both retry loops repeated; asks up to the cap retry as before.scripts/test_collect.pyadds five tests toSubmitProtocol, each coveringsubmitandsubmit_payload:SubmitErrorand send no request;SubmitErrorwithout callingsolve_powabove the cap;collect_quick.maybe_submitandcollect_deep.maybe_submitreturn 4 and print[submit] FAILED: invalid submit endpoint.Against the base code (
2aef87273;collect_submit.pyis unchanged on5ef30346c) on Python 3.11.18 and 3.14.4 they give 26 failures and 10 errors across subtests: the malformed-endpoint and collector tests fail on behavior, and both PoW tests stop at the missingMAX_POW_DIFFICULTY. With that constant added to base, the above-cap test still fails (base callssolve_powwith 25 and 1000000 bits); the at-cap and accepted-endpoint tests are boundary guards that pass on base. All five pass on the candidate.The other collector gives the same result and exit code for each endpoint (
collect_deep.pywith no scheme,collect_quick.pyagainst the loopback server), on5ef30346c,6536f2ce8and a local merge of the two.collectors.ymlLinux steps on6536f2ce8, run in sequence:scripts/test_collect.pyscripts/test_collect_macos.pyunittest discover -s tests -p test_mlx_provenance.pyscripts/bench_matrix.py --self-testpytest -q qualification-kit/...pytest tests -qpytest -q tests/coreml/test_import_contract.py--no-depsclosure (3.14 leg only)Generated with Claude Opus 5.5 in T3 Code Nightly