feat: add round-relative oracle timestamp window - #323
Merged
josephchimebuka merged 4 commits intoAug 8, 2026
Merged
Conversation
Replace the absolute 300s freshness check with a round-relative timestamp window that requires oracle payload timestamps to fall within [round_start - skew, round_end_estimate + skew]. Changes: - Add start_timestamp to Round struct, recorded at round creation - Replace absolute staleness check (300s) with round-relative lower/upper bounds - Add configurable OracleTimestampSkew (0-86400s, default 300s) via timelock - Add OracleTimestampOutsideWindow error - Add boundary tests (before window, after window, at lower/upper edge) - Update ORACLE_OPERATOR_RUNBOOK.md with new validation order and playbook
Contributor
|
@owohdora-stack Pls can you fix Conflicts and send a message in the group saying you've fixed them so I can merge |
3 tasks
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.
Summary
Closes #265
Replace the absolute 300-second oracle data freshness check with a round-relative timestamp window that requires oracle payload timestamps to fall within the round's economic activity period.
Why
The old absolute-freshness check (
now - timestamp ≤ 300s) could accept wrong-phase prices — a price from well after the round ended could still be "fresh" relative to the current ledger time. The new window anchors around the round's start and estimated end:where
round_end_estimate = round_start + (end_ledger - start_ledger) × 5s.What changed
types.rsstart_timestamp: u64toRound; addedOracleTimestampSkewtoConfigChangeKind/ConfigChangePayloadbetting.rsenv.ledger().timestamp()when creating a roundcommon.rsSECONDS_PER_LEDGER,DEFAULT_ORACLE_TIMESTAMP_SKEW,MIN/MAX_ORACLE_TIMESTAMP_SKEWerrors.rsOracleTimestampOutsideWindow = 66settlement.rsconfig.rsschedule_oracle_timestamp_skew,get_oracle_timestamp_skew, validation, and_apply_config_payload/_current_config_payloadhandlingcontract.rsschedule_oracle_timestamp_skewandget_oracle_timestamp_skewpubliclysecurity.rsevent_coverage.rsOracleTimestampOutsideWindowORACLE_OPERATOR_RUNBOOK.mdAcceptance criteria
test_resolve_round_timestamp_before_round_window)test_resolve_round_valid_payload, boundary tests)test_resolve_round_timestamp_after_round_window)test_resolve_round_future_timestamp)schedule_oracle_timestamp_skew)Testing
The codebase has a pre-existing
LengthExceedsMaxissue in theDataKeyenum (51 variants exceed Soroban's contracttype limit) which prevents compilation of bothmainand this branch. The changes are structurally sound — all new code avoids adding DataKey variants by using instance storage withSymbolkeys.