bestarch-ae / cacherpc Goto Github PK
View Code? Open in Web Editor NEWSolana JSON-RPC caching server
License: MIT License
Solana JSON-RPC caching server
License: MIT License
Add command like cacherpd reload waf
or something
When requesting getProgramAccounts(Stake11111...) without filters via the cache I get a gateway timeout error, however it works without the cache.
In logs I can see the following error:
Sep 15 12:39:24.950 WARN cache_rpc::rpc: request: Request { jsonrpc: "2.0", id: Num(1), method: "getProgramAccounts", params: Some((Pubkey([6, 161, 216, 23, 145, 55, 84, 42, 152, 52, 55, 189, 254, 42, 122, 178, 85, 127, 83, 92, 138, 120, 114, 43, 104, 164, 157, 192, 0, 0, 0, 0]), ProgramAccountsConfig { encoding: Base64, commitment: None, data_slice: None, filters: None, with_context: Some(true) })) } error: Overflow
Sep 15 12:39:24.950 INFO cache_rpc::rpc: reporting gateway timeout req.id=Num(1)
This is the RPC request:
curl api.mainnet-beta.solana.com -X POST -H Content-Type: application/json -d
{"jsonrpc":"2.0","id":1, "method":"getProgramAccounts", "params":["Stake11111111111111111111111111111111111111", { "encoding": "base64" }]}
Cacher relies on the fact that cache entries have corresponding active ws subscriptions, in order to detect whether the cache entry might be stale or not. But sometimes it may be that subscription exists but no updates are being received from it, which possibly may indicate that the cache entry became stale.
There's a need for a way to detect such situations and not to serve request from cache, if it happens.
Make ExponentialBackoff max_elapsed_time infinite with max_interval = 10sec.
Allow monitoring caching performance by keeping metrics and printing them in Prometheus (and/or other) format
It's been reported that getAccountInfo
occasionally returns
Error: failed to get info about account 2CSEjyDtAtgCjTKyXHZyfUVe7EERtL7rjYjJSgcBPYLf: Invalid params: invalid type: map, expected string at line 1 column 34
Gist to reproduce here https://gist.github.com/barry-the-sender/d877a87f23d8d52d32fdd71c01f71481.
Sometimes, some worker threads, that manager webosket connections, go into infinite loop trying to establish working websocket connection to validator. Need to figure out the reason, why it happens, and implement detection and correction for such cases.
There're some nice backoff libraries on crates.io.
Currently filter::tests::tree_matches_overall
can randomly panic with 'Uniform::new called with `low >= high`'
message, which probably means that proptest generates x..x
strategy at some point. My guess is that this is related to arb_non_matching_filters
strategy.
This is not a critical issue since the panic is not caused by the test logic, but is annoying. For the time being, broken CI can be fixed with a restart.
HTTP/rpc code has metrics, websocket/pubsub has none.
For the purposes of convenient management of dynamic settings of the application, there's a proposal to implement unix socket listener, which will listen for external commands, and to dynamically change the settings accordingly. It will be quite flexible alternative for signal handling.
Add metric to count reconnect attempts
The problem:
We use subscription_active method to check whether we can retrieve the value from cache for a particular key. Currently it's implemented by checking AtomicBool flag for a websocket connection to which this key is routed. This flag is updated in update_status by comparing number of active subscriptions to the number of desired subscriptions, which means that if one of subscription confirmations is delayed, all keys routed to this worker are considered not active, and are not retrievable from cache, which is obviously not desirable.
Proposed solution:
Track subscription status by key.
It should be pretty easy to do, basically the same as getAccountInfo
We're seeing 415 errors when the content-type header specifies a charset. This happens on requests where the content-type reads:
application/json;charset=โฆ.
We should find out how to get the latest slot for commitment via pubsub (preferably).
2.If we have account A cached with slot = N, commitment = Processed, and later we receive an update for account B with slot N+1, commitment = Finalized, it seems like it means that slot N is also Finalized, which in turn, means that we can return account A's data for a request with Finalized commitment requirement.
It seems like filters are kinda popular, so we should find a way to cache requests with filters.
One possible solution would be to make an additional request without filter and cache the result (using a queue and a background worker, probably).
thread 'actix-rt:worker:3' panicked at 'actor is dead: MailboxError(Mailbox has closed)
1.when config is reloaded, log new config
2.when config is applied, log new values (limits are already being logged)
SLOT_DISTANCE threshold is currently hardcoded at 150 (same as default for validator). Make it configurable via command-line option.
Currently cacher doesn't preprocess batch requests, simply forwarding them to validator cluster.
There's a requirement to support batch requests in WAF rules evaluation, so that the rules will apply to all requests, regardless of their type and composition.
To follow the behaviour of the solana validator and be as transparent as possible the cache should accept any path "/" component of the URL. I have seen some applications use this in the wild and it is supported by the validator.
There are also special URL paths in the validator that get translated into non RPC requests like "/health".
Currently cacherpc returns 404 on any path a part from "/". We work around it in our proxy by just overwriting the path component to any request we pass to zubr cache.
It's basically the same code, could be refactored into a function.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.