cow-venue: add valid_to and valid_for order expiry setters - #592
Merged
Conversation
mfw78
force-pushed
the
cow/585-expiry-setters
branch
from
July 24, 2026 23:54
b7ae439 to
c0506a9
Compare
The builder gains an absolute valid_to setter and a relative valid_for(now, duration) that computes valid_to = now.saturating_add(duration), so a caller writing "expire in N seconds" does not hand-roll the arithmetic. Duration is u32 seconds to match the wire validTo and the dispatch tick epoch_s; a wasm guest has no ambient clock, so valid_for takes now explicitly. The twap-monitor valid_to_in helper now routes through valid_for instead of adding by hand.
mfw78
force-pushed
the
cow/585-expiry-setters
branch
from
July 25, 2026 00:38
c0506a9 to
a9d08dc
Compare
mfw78
added a commit
that referenced
this pull request
Jul 27, 2026
cow-venue: add valid_to and valid_for order expiry setters (#585) The builder gains an absolute valid_to setter and a relative valid_for(now, duration) that computes valid_to = now.saturating_add(duration), so a caller writing "expire in N seconds" does not hand-roll the arithmetic. Duration is u32 seconds to match the wire validTo and the dispatch tick epoch_s; a wasm guest has no ambient clock, so valid_for takes now explicitly. The twap-monitor valid_to_in helper now routes through valid_for instead of adding by hand.
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.
What
Adds two expiry setters to the CoW
OrderBuilderincrates/cow-venue/src/order.rs:valid_to(secs)sets the absolutevalidTounix timestamp, overriding the constructor argument, andvalid_for(now, duration)setsvalid_to = now.saturating_add(duration). Duration isu32seconds to match the wirevalidToand the dispatch tickepoch_s;nowis an explicit argument because a wasm guest has no ambient wall clock. The twap-monitorvalid_to_inhelper now routes throughvalid_forinstead of hand-rolling the addition.Closes #585
Why
Every caller wanting a relative expiry recomputed
now + nby hand.valid_formakes "valid for N seconds from now" a one-liner, saturates rather than wraps on overflow, and keeps the arithmetic in one place. The requiredvalid_toconstructor argument from #581 is kept unchanged (least churn); the setters override it.Testing
nix develop --command just cipassed (fmt, clippy-D warnings, doc, module wasms, workspace tests).nix develop --command just check-venue-agnosticpassed andnix develop --command just check-cow-orderbook-onlypassed.nix develop --command just build-cow-venuepassed, and the workspace test suite (cargo test --workspace --all-features --no-fail-fastwithRUSTFLAGS="-D warnings") was re-run after it in CI's build order with the two cow platform e2e tests exercised (not skipped) and green.Maintainer note: re-running
just ciafterjust build-cow-venuefailsvidere-host --test platformon any branch, because the module-wasm build step regenerates a featurelesstarget/wasm32-wasip2/release/cow_venue.wasmthat clobbers the adapter build, and the platform e2e tests then find a component without theinitexport. GitHub CI is unaffected (it builds the adapter wasm after the module wasms, before tests); pre-existing local-ordering quirk, not introduced here. Also flagging: the migratedvalid_to_intest helper builds a throwaway zeroed order to reachvalid_for, since the builder method is the single home of the arithmetic; happy to reshape if you would rather expose a free function.AI Assistance
Implemented with Claude Code.
Notes for review
The issue's acceptance names "at least one production caller uses
valid_for", but there is no production site that hand-rolls relative expiry: the onlynow + nhelper in the tree wasvalid_to_ininside twap-monitor's#[cfg(test)]tests. Thevalid_toandvalid_forbuilder methods are delivered and exercised by their own unit tests (override, add-duration, saturate-on-overflow); the test helper computes the same saturatingnow + secondsinline rather than being forced through a throwaway order. A future order-building caller that wants relative expiry can usevalid_fordirectly.The
valid_toconstructor argument is kept (least churn per the issue), with the two methods overriding it.