Repository navigation
Add relative timelock enforcement functions - #45
Merged
Merged
Conversation
This was referenced Aug 15, 2026
schoen
force-pushed
the
feat/timelocks
branch
from
November 19, 2026 06:21
8609758 to
f8fbc54
Compare
Hrom131
reviewed
Nov 20, 2026
Hrom131
reviewed
Nov 20, 2026
Hrom131
reviewed
Nov 20, 2026
Hrom131
reviewed
Nov 20, 2026
Hrom131
reviewed
Nov 20, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Move function comments into `///` doc comments matching the library style. - Factor the shared version check and sequence parsing into a private helper. - Trim test comments that restated the code. - Make tx_version_below_2_fails declare a sufficient timelock, so the version check is the only thing that can reject it. - Explain what's wrong with the deprecated jets in stdlib.json. - Fix the timelocks.md link in WISHLIST.md. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
schoen
force-pushed
the
feat/timelocks
branch
from
November 20, 2026 22:36
dad63ce to
3a1932d
Compare
Contributor
Author
|
I think this CI failure is still spurious. It failed at the Simplex startup stage, with no actual tests failed. I'll rerun the CI. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add
timelocks.simfwith relative timelock enforcement functionsenforce_relative_distanceandenforce_relative_duration. These are replacements for the deprecated jetsjet::check_lock_distanceandjet::check_lock_duration, whose version of this functionality is significantly incorrect (see BlockstreamResearch/simplicity@fc466a8). You can learn more about how to use these at https://docs.simplicity-lang.org/documentation/timelocks (which currently includes a more verbose version of these same functions, which I plan to trim there once they're part of the standard library!).I wrote these functions based on conversations with @apoelstra and @roconnor-blockstream about how these jets were supposed to work, and I've also tested
enforce_relative_durationa bit in contracts.There are 11 Simplex test cases created by Claude. I asked Claude for each individual test case, and I'm satisfied that they test most of the most important cases and that they work properly. The remaining gap is that Simplex currently can't simulate the passage of realtime effectively (see BlockstreamResearch/smplx#126), so we lack tests for the happy path of
enforce_relative_duration, and for its failure cases where sufficient realtime has actually passed but is not correctly asserted in the transaction.Since Simplex can ask
elementsdto simulate mining blocks, we have valid tests forDistancecases (enforcing that a certain number of blocks have been mined on top of the original transaction containing the input UTXO). This is handled viablocks_to_minein therun_with_sequencefunction added totests/stdlib/common/core.rs.(
tx_version_below_2_failsnow uses a version 1 transaction whose input declares a sufficient timelock.)[PR description updated on 2026-11-20 based on feedback from @Hrom131.]