Repository navigation
policy: P2MR stack-byte limit error code, spec, and oracle cases - #271
Merged
kiwidream merged 3 commits intoOct 30, 2026
Merged
Conversation
SCRIPT_VERIFY_P2MR_STACK_BYTES failed with SCRIPT_ERR_STACK_SIZE, the error of the consensus 1,000-item stack limit. A mempool rejection then read "Stack size limit exceeded" whether the spend broke the policy byte limit or the consensus item limit. Add SCRIPT_ERR_P2MR_STACK_BYTES, "Standard P2MR stack byte limit exceeded", and return it when the byte limit is exceeded. The consensus item limit is checked first after each opcode, so a spend that breaks both on the same opcode still reports SCRIPT_ERR_STACK_SIZE. Refs #257 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The conformance oracle derived each resource case's policy result from its consensus result, so it could not express a policy-only limit, and the corpus had no case for the 1 MiB runtime stack-byte limit. Teach the oracle's evaluator OP_DUP, OP_DROP and an optional limit on stack bytes after each opcode. Add a runtime-stack-bytes resource kind that the oracle evaluates under consensus and policy separately, with boundary cases at exactly 1 MiB (standard) and 1 MiB plus one byte (consensus-valid, nonstandard with SCRIPT_ERR_P2MR_STACK_BYTES). Regenerate the boundary corpus and the manifest. The C++ consumer builds the same spend and checks both cases under consensus and standard flags. Refs #257 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Section 11 said a known leaf over any runtime resource limit is consensus-invalid, which does not hold for the policy-only 1 MiB stack-byte limit. Narrow that row to consensus limits, add a row for otherwise valid spends over the byte limit, and describe the policy check and its error in section 10. Refs #257 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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. |
Member
Author
|
@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". |
djh58
self-requested a review
October 30, 2026 16:16
djh58
approved these changes
Oct 30, 2026
This was referenced Oct 30, 2026
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.
Summary
Stacked on #263 (base
djh58/p2mr-stack-bytes-policy). It closes three policy gaps in that PR. Refs #257.1. Its own error code.
SCRIPT_VERIFY_P2MR_STACK_BYTESfailed withSCRIPT_ERR_STACK_SIZE, the error of the consensus 1,000-item limit, so a mempool rejection readStack size limit exceededfor either limit. It now fails withSCRIPT_ERR_P2MR_STACK_BYTES:SCRIPT_ERR_STACK_SIZE.2. Spec (
doc/consensus/p2mr-v1.md).3. Conformance oracle and corpus.
OP_DUP,OP_DROP, and an optional stack-byte limit after each opcode (evaluate_policy). It recomputes the full total each time, independently of the C++ incremental window accounting.runtime-stack-bytesresource kind. The oracle evaluates it under consensus and policy separately, instead of copying the consensus result into policy as it does for the other resource kinds.1048576: standard.1048577: consensus-valid, policySCRIPT_ERR_P2MR_STACK_BYTES.Testing
Built with
cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DBUILD_GUI=OFF(targetstest_qbit qbitd qbit-cli). Results are at the PR head.build/bin/test_qbit --run_test='script_p2mr_tests:script_tests:transaction_tests:txvalidationcache_tests:pqc_sigcache_tests:p2mr_datapqchash_tests:descriptor_p2mr_tests:psbt_p2mr_tests:script_standard_tests:sigopcount_tests:miniscript_tests:script_p2sh_tests:script_segwit_tests:txpackage_tests:mempool_tests:feebumper_tests:pqc_tests': no errors. This runs all 53 boundary cases under both consensus and standard flags.test/functional/test_runner.py feature_p2mr.pypassed, with the new reject reason.cargo fmt -- --checkandcargo test --locked --offline: 38 tests passed.check-manifestandverifyagainstsrc/test/data/p2mr_v1_manifest.json: 80 cases passed.1048577case's policy expectation to accepted in a scratch copy and re-digested the manifest. The oracle then failed withresource-runtime-stack-bytes-1048577: independently observed policy result mismatch.contrib/devtools/check-p2mr-v1-corpus-reproducible.shpasses.lint-qbit-public-docs,lint-files,lint-tests,lint-locale-dependenceandlint-python-utf8-encodingpass.lint-spellingandlint-pythonwere skipped locally becausecodespellandliefare not installed.script_p2mr_testsandfeature_p2mr.pypass at it. The last commit only changes docs.Target Branch
mainor a maintainer-requested release branch such as0.1.x.This PR is stacked on #263 and targets its branch,
djh58/p2mr-stack-bytes-policy. Retarget it to1.x.xonce #263 merges.Risk / Review Notes
Notes:
MANDATORY_SCRIPT_VERIFY_FLAGS,GetBlockScriptFlagsand every consensus expectation in the corpus are unchanged.ScriptErrornumbering. The new value sits afterSCRIPT_ERR_P2MR_CHECKSIG, which shifts the values after it. Nothing persists or exposes them numerically.schema_versionstays 1 because the case shape is unchanged. Strict consumers fail closed on the newkindby design, and both in-repo consumers are updated here.Stack size limit exceededtext was never released, so no released behavior changes.Docs / Process Impact
Choose exactly one:
Updated sections 10 and 11 of
doc/consensus/p2mr-v1.mdand the oracle README. The v1.0.1 release notes (#181) should quote the new reject reason together with the standardness rule from #263.🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need.