feat(lazer/stellar): reject non-newer prices in example consumer#130
Merged
Conversation
Enforce a monotonic freshness check in the Stellar example consumer: update_price now rejects an update unless its feed timestamp is strictly greater than the currently stored price's timestamp, returning the new Error::PriceOutdated and leaving the stored price untouched otherwise. This prevents an out-of-order update that still passes the age-based freshness threshold from clobbering a newer stored price.
aditya520
approved these changes
Jul 8, 2026
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.
The Stellar example consumer contract now enforces a monotonic freshness check when updating the price: an update is rejected unless its feed timestamp is strictly greater than the currently stored price's timestamp.
Previously
update_pricewould overwrite the stored price with any update that passed the age-based freshness threshold, so an out-of-order update carrying an older feed timestamp could clobber a newer stored price. The new check reads the currently stored price and returns a newError::PriceOutdated(code 9) if the incoming feed timestamp is not strictly newer, leaving the stored price untouched.lazer/stellar/src/lib.rs: added the strictly-newer-timestamp guard before storing.lazer/stellar/src/error.rs: added thePriceOutdatederror variant.lazer/stellar/README.md: documented the monotonic-update guarantee.Verified from
lazer/stellar/:cargo fmt --all --check,cargo clippy --all-targets -- -D warnings, andcargo build --release --target wasm32v1-noneall pass.