Skip to content
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

Handle cache misses and RPC methods that are not in the config file #16

Merged
merged 33 commits into from Oct 3, 2021

Conversation

TomLisankie
Copy link
Contributor

Adds the much-needed ability to be able to handle cache misses and not just work with RPC methods specified in the config file.

@TomLisankie
Copy link
Contributor Author

Major changes:

  • The reader and the writer have test suites written for them now
  • Everything is dockerified (aka it now uses Docker Compose). This now makes running it far more manageable and consistent.
  • Cache misses are now handled properly. If the reader can't find the information requested, it sends a message to the writer. The writer then fetches this data from a Solana RPC endpoint, returns it to the reader, and writes it to Redis so that cache misses on that data don't happen in the future.
  • Pre-caching has been removed. The reason for this is that it added a lot of unnecessary complexity to the code for the sake of saving the first user who requests data some time. Now what happens is when the first user asks for some piece of data that hasn't been queried yet, a cache miss will happen, the data will get cached, and the data will be seen as cached from there on out.
  • Functions that were written specifically for dealing with specific RPCs (and in the last version it was just getProgramAccounts) have been removed. This is just due to the fact that it handles all RPCs in the same way now and caches them in Redis like method name : stringified params : value of running the method with the specified params.

Things that still need to happen in the future:

  • Documentation (README) needs to be updated with instructions for running locally with Docker.
  • Cloud deployment should be revamped. The reason is it currently only works with AWS CloudFormation whereas if it was rewritten with Terraform, it could be deployed to any cloud (and if not, it requires far fewer changes). And once all of this gets updated, the README will need to be updated as well.
  • Cache invalidation needs to be added. In the previous version this was handled with WebSockets (and only for getProgramAccounts) but I didn't get around to adding a cache invalidation mechanism for this implementation. The reason I didn't just use WebSockets is because only a subset of the RPC methods in the Solana JSON RPC API have a corresponding method for subscribing to changes. My idea on what would make most sense here is to have users of this repo (so not clients who are just sending an RPC) pass in some config file with functions that each describe an eviction policy for calls to that RPC method. For example, getProgramAccounts might just have a function that says "evict every 30 mins" and getTokenAccountBalance might have a function that does use a WebSocket to watch for changes in realtime, etc. If no function is provided, it just uses some default (say, evict every 10 minutes and run the call again)

@TomLisankie TomLisankie marked this pull request as ready for review October 1, 2021 17:46
@TomLisankie TomLisankie merged commit 1c257af into main Oct 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant