Repository navigation
feat(script): check a serialized witness-data byte cap - #317
Conversation
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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 41d0f09078
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
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".
| "bip-144", | ||
| "bitcoin-core-v30.3-regtest", | ||
| "bitcoin-script-locked", | ||
| "bitcoin-scriptexec-locked" |
There was a problem hiding this comment.
Reference the interpreter actually used for the new measurements
The new tests resolve the patched interpreter at a09e87af (Cargo.lock:312–314), but this source ID points to historical ba96bc2 in knowledge/references/sources.json:111–115. That version is documented in NR-043 as missing witness-entry and transient-push resource checks exercised by this primitive's boundary tests, so it is not valid provenance for the reported strict-stack evidence. Replace it with the existing bitcoin-scriptexec-csv-20260920 reference to meet AGENTS.md's immutable-source recording requirement.
AGENTS.md reference: AGENTS.md:L52-L52
Useful? React with 👍 / 👎.
Result
Adds
support::witness_data_size::verify_data_witness_size_at_most(items, cap). It measures a fixed opaque data suffix as a standalone serialized witness vector and preserves both caller stacks. If the public cap is belowCompactSizeWidth(items) + items + 253, every accepted item must have a one-byte length prefix, so the generated script can omit all long-prefix checks.All leaves include the cap check and identical cleanup. Witness bytes exclude the leaf, control block, annex and transaction. Executed non-push counts include visited branch delimiters. The evidence is locally reproduced with unclassified execution.
The weak short-prefix-only schedule accepts a 258-byte vector at cap 256. The final exact schedule rejects it at 256 and 257. The tests also pin the 997-item tight and 996-item exact combined-stack frontiers.
Verification
python3 tools/kb.py validate,cargo fmt --all -- --check, andgit diff --checkcargo test --locked -- --skip fields::