refac: Implement Per Asset Timestamp Tracking#42
Open
Olowodarey wants to merge 2 commits intoNeko-Protocol:devfrom
Open
refac: Implement Per Asset Timestamp Tracking#42Olowodarey wants to merge 2 commits intoNeko-Protocol:devfrom
Olowodarey wants to merge 2 commits intoNeko-Protocol:devfrom
Conversation
|
@Olowodarey is attempting to deploy a commit to the fabianalejandrosanchezduran-gmailcom's projects Team on Vercel. A member of the Team first needs to authorize it. |
Contributor
|
This issue depends on #25, please wait until I finish merging that milestone so you can validate your PR. |
Contributor
|
Pr #25 merge, you can now continue with your issue. |
- Changed test_same_asset_requires_newer_timestamp to expect panic - Changed test_same_asset_same_timestamp_rejected to expect panic - Both tests now correctly validate that timestamps must be strictly increasing per asset - All 29 tests passing
Author
|
@aguilar1x check now |
Contributor
Can you fix the conflicts in your branch? |
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.
This PR fixes a design issue in the RWA Oracle where a single global
last_timestampwas used to validate price updates for all assets.Because different assets can have independent update frequencies and timelines (e.g. stocks vs crypto, different data providers), a global timestamp caused valid updates to be incorrectly rejected.
This change introduces per-asset timestamp tracking while preserving the global timestamp for SEP-40 compatibility.
Problem
Previously:
last_timestampwas stored globally inRWAOracleStorageUpdating one asset advanced the timestamp for all assets
This caused:
Example:
t = 1000t = 500→ incorrectly rejectedSolution
This PR introduces per-asset timestamp validation:
DataKey::LastTimestamp(Asset)to store timestamps per assetlast_timestampis still updated for backward compatibility (SEP-40)Implementation Details
New Storage Key
Updated Logic
set_asset_price_internalnow:last_timestampfor SEP-40 compatibilityTests Added
A total of 10 unit tests now cover all required scenarios.
Existing / Core Per-Asset Timestamp Tests
test_per_asset_timestamps_independenttest_same_asset_requires_newer_timestamptest_same_asset_same_timestamp_rejectedtest_same_asset_newer_timestamp_acceptedtest_global_timestamp_still_updatedAdditional Coverage & Compatibility Tests
test_independent_timestamps_for_different_assetstest_updating_asset_with_older_timestamp_than_another_assettest_per_asset_timestamp_retrievaltest_global_timestamp_still_updatestest_backward_compatibility_with_sep40All existing tests continue to pass.
Verification
closes #31