rust-simplicity icon indicating copy to clipboard operation
rust-simplicity copied to clipboard

Issue with traiiling bytes ( RPC error -26 Trailing bytes after final byte of witness) after

Open ikripaka opened this issue 1 month ago • 3 comments

When I was migrating the simplicityhl-std repo to an up-to-date version of Simplex to implement fuzz tests, I encountered this error

    Error: Broadcast failed with HTTP 400 for http://127.0.0.1:52982/tx: sendrawtransaction RPC error -26: non-mandatory-script-verify-flag (Trailing bytes after final byte of witness)

Nearly all tests with a running local node fail, while in the previous version everything was fine. After some investigation, I found that SimplicityHL 0.8.0 bumped simplicity-lang to version 0.9.0. This PR introduced this bug: https://github.com/BlockstreamResearch/rust-simplicity/pull/379.

This bug can be reproduced in version 0.1.0 of Simplex, and error was introduced in https://github.com/BlockstreamResearch/smplx/pull/166 after the SimplicityHL version bump to 0.8.0 a2d0c4e.

Here is a minimal working example that can be reproduced in the simplicity-std https://github.com/BlockstreamResearch/simplicityhl-std/commit/2cff7de76d9637bfe3aadcf3ff643160b735fc81 version and via these paths.

Simplex - 0.1.0 version proptest - 0.11.0 version

dev-witness-reproduction.patch - directly applies to the dev branch

witness-encoding-regression.patch is a minimal example with a test (this path is included in a previous one. It just requires changes in the Simplex API to reproduce it).

git apply dev-witness-reproduction.patch
simplex clean
simplex build
cargo test --test assert_eq_128_witness_encoding_roundtrip -- --nocapture

The problem occurs before Elements validates the transaction. Pruning retains unused witness data, producing extra bytes in the serialised witness. The reproducer executes and prunes the actual stdlib assertion contract, serialises the result, then confirms that Rust’s own RedeemNode::decode rejects it. No Elements or electrs process is needed to reproduce the failure.

Pruning conversion Program bytes Witness bytes Rust decode result
MaxSharing<Redeem> (released 0.9.0) 980 129 bitstream had trailing bytes 0x00...
InternalSharing (with revert) 980 34 Success

ikripaka avatar Oct 12 '26 13:10 ikripaka

Why is this issue on rust-simplicity? This crate has no HTTP support.

apoelstra avatar Oct 13 '26 12:10 apoelstra

If there is some issue with pruning then please describe the actual bug and ideally provide some sort of reproduction. Also, please do not post LLM-generated textwalls.

apoelstra avatar Oct 13 '26 12:10 apoelstra

Ok, I'll redo it soon

ikripaka avatar Oct 13 '26 14:10 ikripaka