Skip to content

Check minimal push encoding only when executed - #20

Open
adrienlacombe wants to merge 1 commit into
BitVM:masterfrom
adrienlacombe:codex/check-minimal-pushes-when-executed
Open

adrienlacombe wants to merge 1 commit into
BitVM:masterfrom
adrienlacombe:codex/check-minimal-pushes-when-executed

Conversation

@adrienlacombe

Copy link
Copy Markdown

require_minimal=true currently rejects nonminimal pushes while constructing the executor, including pushes in skipped branches. For example, OP_0 OP_IF <nonminimal push of 1> OP_ENDIF OP_TRUE should succeed with minimal-data policy enabled, but returns InvalidScript(NonMinimalPush).

Parse script syntax independently of policy, then check minimal push encoding only when the push executes. Executed nonminimal pushes now return ExecError::MinimalData before changing the stack. The check reuses rust-bitcoin's instruction decoder; numeric minimality, tapscript MINIMALIF, default options, and the preceding 520-byte push check remain intact. This follows Bitcoin Core v30.3's executed-push check.

Validation: seven grouped regressions cover executed and skipped pushes (including nested conditionals and ELSE), minimal encoding boundaries, malformed syntax, numeric minimality, tapscript MINIMALIF, and oversized-push error precedence. Applicable cases run in Legacy, SegwitV0, and Tapscript contexts with both require_minimal values. Against ba96bc2, 3 groups passed and 4 failed; after the fix, cargo test --locked --all-features -- --skip fields:: passes all 19 tests (11 existing unit, 7 regression, 1 documentation). Cargo.lock was retained locally for reproducibility, following the repository's existing ignore rule.

Independent of related resource-limit #18 and stack-index #19.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant