fix(txscript): allocate fresh slice in opcodeInvert to avoid aliasing#777
fix(txscript): allocate fresh slice in opcodeInvert to avoid aliasing#777ordishs wants to merge 2 commits intobsv-blockchain:mainfrom
Conversation
|
🤖 Claude Code Review Status: Complete Current Review: No issues found. The fix correctly addresses the aliasing bug in
|
Benchmark Comparison ReportBaseline: Current: Summary
All benchmark results (sec/op)
Threshold: >10% with p < 0.05 | Generated: 2026-05-04 13:46 UTC |
Closes #4576.
Summary
opcodeInvertusedPeekByteArray(0)and XOR'd bytes in place. AfterOP_DUP(which copies only the slice header), both stack items share the same backing array — soOP_DUP … OP_INVERTmutates the duplicate as well. This diverges from Bitcoin Core / SV Node script semantics.Fix
Pop, allocate a fresh slice, invert into the new slice, push. Stack transformation
a -> ~ais unchanged; the result is now an independent slice with no aliasing.Test plan
go test -race ./services/legacy/txscript/...passes.