[price-service] Make gap metrics more accurate #426
Merged
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 aims to make the gap metric more accurate. It might slightly improve the latency of prices as described below.
The problem is that multiple attesters might attest the same price that results in the same batch information but on different VAAs. This PR will use sequence number to store the most recent one. As in one second there are multiple slots, doing so will allow price service to pick a slightly more recent price to serve (if such a thing happens).
Why is it important for metrics? Because we often compare the trens of the attestation gap metric with the vaa received metrics. After doing this change, the trend difference of these two will show how many out of order VAAs we do have and is a useful information.
Why sequence number alone is not used? Because we might have multiple sources of data (Pythnet/Solana) and each have their own increasing sequence number. Using sequence number alone will make the switch between them difficult. The current solution will have no impact on switch.