fix: correct inverted native script timelock comparisons#778
Conversation
`eval_native_script` evaluated both timelock opcodes with inverted comparisons. `InvalidBefore(n)` was satisfied when the validity interval started before slot `n` (should be at or after), and `InvalidHereafter(n)` when it ended after `n` (should be at or before), per mary-ledger.pdf p.20. Adds unit tests covering both opcodes and nested combinators. Fixes #718 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThis PR inverts the comparison logic for ShelleyMA native-script timelocks ( ChangesShelleyMA Timelock Semantics
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Summary
eval_native_scriptinpallas-validate/src/phase1/shelley_ma.rsevaluated both native-script timelock opcodes with inverted comparisons:InvalidBefore(n)was satisfied when the transaction's validity interval started before slotn— it should be satisfied when it starts at or aftern.InvalidHereafter(n)was satisfied when the validity interval ended after slotn— it should be satisfied when it ends at or beforen.This matches
evalTimelockin the Mary/Allegra ledger spec (mary-ledger.pdf p.20). The result was consensus-relevant validation that both accepts invalid transactions and rejects valid ones.The issue reporter spotted
InvalidBefore;InvalidHereafterwas inverted the same way and is fixed here too. TheNone(unbounded) arms were already correct and are unchanged.Changes
eval_native_script.#[cfg(test)] mod testsexercising the previously untested timelock branches:invalid_before,invalid_hereafter(after / exactly-at / before the lock, plus the missing-bound case), andnested_timelocks(ScriptAll/ScriptAnyrecursion).Verification
shelley_maintegration tests: 25 passed — no regressionFixes #718
🤖 Generated with Claude Code
Summary by CodeRabbit
Bug Fixes
Tests