-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
perf: better caching of current round details #147
Merged
Merged
Conversation
This file contains 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
- Store meridian contract address and round index in `spark_rounds`. - Rework `getMeridianRoundDetails` to use these new columns for lookup - Rework `getMeridianRoundDetails` to enable long caching for immutable content (the round details) Signed-off-by: Miroslav Bajtoš <[email protected]>
Rework the implementation of `GET /rounds/current` to redirect to a permalink `GET /rounds/meridian/{addr}/{round}`. This allows us to better cache the data queried from our database. 1. The redirection logic does not need the database, it builds the new location using in-memory data. In the future, we can rework spark-checker to determine the current round locally by querying the on-chain state of the Meridian contract. 2. The response for the permalink for a given meridian round is immutable and therefore can be cached forever. If all works out as expected, we should see only one request per each round, and the CDN cache will take care of the rest. Signed-off-by: Miroslav Bajtoš <[email protected]>
Signed-off-by: Miroslav Bajtoš <[email protected]>
juliangruber
approved these changes
Nov 22, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great work!
Co-authored-by: Julian Gruber <[email protected]>
bajtos
added a commit
that referenced
this pull request
Nov 22, 2023
Deployment of #147 is failing because at startup, we are updating `spark_rounds` table with `meridian_contract` and `meridian_round` before running the database schema migration. This commit changes the initialisation order: db migrations first and everything else afterwards. Signed-off-by: Miroslav Bajtoš <[email protected]>
This was referenced Nov 22, 2023
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.
Rework the implementation of
GET /rounds/current
to redirect to a permalinkGET /rounds/meridian/{addr}/{round}
. This allows us to cache better the data queried from our database.The redirection logic does not need the database; it builds the new location using in-memory data.
In the future, we can rework spark-checker to determine the current round locally by querying the on-chain state of the Meridian contract.
The response for the permalink for a given meridian round is immutable and, therefore, can be cached forever. If all works out as expected, we should see only one request per round, and the CDN cache will take care of the rest.
I have also improved the database schema to store the meridian contract address and round index in
spark_rounds
in order to enable fast lookup of Spark rounds from Meridian rounds,This PR supersedes and closes #143
Links: