Repository navigation
Conversation
ExtendedChannel::on_set_custom_mining_job_success built the coinbase scriptSig from the job's coinbase_prefix and the full extranonce without checking it against the 100-byte consensus limit. An oversized prefix activated a job for a consensus-invalid coinbase, and from 253 bytes the scriptSig length takes three bytes, so the prefix/suffix split, which counts it as one, landed two bytes early. Reject such a job with a new ExtendedChannelError::ScriptSigSizeTooLarge before touching the channel, as the server JobFactory already does for SetCustomMiningJob, and document why the split can count the length as one byte. MAX_SCRIPT_SIG_SIZE moves from server::jobs::factory to the crate root, since the server module is not built with no_std and the client needs it there. stratum-mining#2398
channels_sv2 breaks its API, so it takes a major bump. stratum_translation exposes channels_sv2::bip141::StripBip141Error in StratumTranslationError, and stratum-core re-exports both, so taking channels_sv2 10 breaks them too.
Jolah1
force-pushed
the
fix-client-custom-job-script-sig-size
branch
from
November 13, 2026 03:19
bb0f57a to
574dd73
Compare
Contributor
Author
|
Rebased on main, conflicts are gone. Added a commit bumping channels_sv2 to 10.0.0 since 9.0.0 is published now, plus stratum_translation and stratum-core which expose it. Ready for review |
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.
close #2398
close https://github.com/project-loupe/audit-stratum/issues/245
ExtendedChannel::on_set_custom_mining_job_successbuilt the coinbase scriptSig from the job'scoinbase_prefixand the full extranonce without checking the 100-byte consensus limit. With a 32-byte extranonce, any prefix from69 bytes up activated a job for a consensus-invalid coinbase, and from 221 bytes the scriptSig length takes three bytes, so the prefix/suffix split, which counts it as one, landed two bytes early.
It now returns a new
ExtendedChannelError::ScriptSigSizeTooLargewhencoinbase_prefix.len() + full_extranonce_size > MAX_SCRIPT_SIG_SIZE, before touching the channel, same as the server'sJobFactorycheck forSetCustomMiningJob. The+ 1 // bytes in scriptterm gets the same comment the server has.MAX_SCRIPT_SIG_SIZEmoves fromserver::jobs::factoryto the crate root, sinceserverisn't built withno_stdand the client needs it there.Tests:
test_custom_job_success_rejects_oversized_script_sig: a prefix that fills the 100 bytes exactly is accepted, one byte over and the issue's 252 + 32 case are rejected, and the rejected jobs leave the active and past jobsuntouched. It fails without the check.
Side effects:
JobFactory::new_custom_job, which already enforces the budget with the same channel's full extranonce size, so its behaviour doesn't change. If the check ever fires there, theJDC's
_arm treats it as a fallback error.ExtendedChannelError, andMAX_SCRIPT_SIG_SIZEchanges path. channels_sv2 goes 9.0.0 -> 10.0.0. stratum_translation exposes a channels_sv2 error type and stratum-core re-exports both, so they go to 0.7.0 and 0.8.0.MAX_SCRIPT_SIG_SIZE, and its match on the client error has a_arm. sv2-apps main builds against this branch.