Repository navigation
Correct Binohash FindAndDelete boundary semantics - #293
adrienlacombe wants to merge 3 commits into
Conversation
Codex Review Summary: ✅ CompletedThis 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: 62f4a4348f
ℹ️ 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".
| `49faec4f87f5cd19c88db01a82e5c68b087c8227`; malformed trailing-push coverage | ||
| checks parser parity only and is not consensus-valid Script evidence. |
There was a problem hiding this comment.
Stop scanning incomplete PUSHDATA length fields
When a malformed script ends partway through an OP_PUSHDATA2/OP_PUSHDATA4 length field, this parity claim does not hold: next_sop falls through after only the opcode and then treats the remaining length bytes as new opcode boundaries, while Core's GetOp fails and stops scanning. For example, with script bytes [0x4d, 0x00] and an empty selected signature (canonical target [0x00]), the helper deletes the final byte and returns [0x4d], but Core leaves the malformed script untouched; the new test only truncates a payload after a complete PUSHDATA1 header. Make incomplete length fields terminate scanning (and add that regression) before stating malformed parser parity.
AGENTS.md reference: AGENTS.md:L53-L54
Useful? React with 👍 / 👎.
|
Leaving this open: the new malformed-tail test covers a truncated payload, but not a truncated PUSHDATA2/PUSHDATA4 length header. The helper still disagrees with Core's stop-on-GetOp-failure behavior on those inputs. Reproducer at current head let script = ScriptBuf::from_bytes(vec![0x4d, 0x00]);
assert_eq!(find_and_delete(&script, &[vec![]]), script);Expected: unchanged Please stop scanning when any push length header is incomplete and add these empty-signature regression cases, alongside the existing truncated-payload test. This is a pre-existing helper defect, but this PR's parser-parity coverage and documentation should not leave that boundary untested. It does not imply that malformed scripts are consensus-valid. |
The Bitcoin Script reference currently says legacy
FindAndDeletecan remove matching signature bytes from the middle of an unrelated push. Pinned Bitcoin Core v30.3 instead compares at parsed opcode boundaries. This corrects that consensus-mechanics description and separatesOP_CODESEPARATORstripping, which occurs during legacy sighash serialization.Focused tests cover canonical direct, PUSHDATA1 and PUSHDATA2 pushes; duplicate signature pushes; identical bytes embedded inside another push; nonminimal push encodings; and a malformed trailing push. The malformed case checks host-parser parity only and is explicitly excluded from consensus-valid claims. The implementation behavior is linked to exact Core source lines and catalog/documentation evidence is updated.
Validation: seven focused Binohash library tests;
python3 tools/kb.py validate;cargo fmt --all -- --check;git diff --check; andCARGO_PROFILE_TEST_OPT_LEVEL=1 cargo test --locked -- --skip 'fields::'(all non-field library, integration and doc tests passed).