Comments (3)
fully agreed. nearly all historical queries would be significantly optimized by this type of cache, at least in the case of using a remote archive node as you mention. ive actually been planning out how to implement this type of cache for a while now, and spending a lot of time on db infra to make it easy+robust to integrate supplementary caches
i have a pretty good idea of how the first pass will look but there remain a few implementation questions:
- what will the exact db schema look like?
- how to designate which contracts and/or functions should have their outputs cached? or should all outputs be cached indiscriminately?
- ctc already has a custom caching system for many protocols. should this new caching system replace those systems, or should it be disabled for those protocols?
package-wise, this cache will exist above rpc
in the evm
module. this will keep the rpc client lean and robust
from checkthechain.
- I will need to dig deeper into the code to suggest something meaningful but I would say it should be at the lowest level.
- I would prefer that everything is cached indiscriminately and you could flag something like
no_cache=True
in some cases. - If the implementation is at the lowest level, the apps above should only benefit from it and not even be aware of it
What about starting to implement cache with decorators in some specific functions on rpc
or evm
?
from checkthechain.
(2) I agree with this for the default setting. and once an alpha version is ready it will become more obvious whether this is a good idea. if some things need to be excluded for performance/storage reasons then we could come up with some exclusion heuristics and add in some configurability
(3) the way things are designed so far is that ctc.evm
has the high level functions that end users should be using, and ctc.rpc
+ ctc.db
have low level functions only needed by advanced users. keeping rpc
client separate from the db
cache simplifies implementation of each and keeps things more modular. for now end users still have to do certain things like eth_call's using rpc
, but for most things like events/blocks/txs and various other datatypes, users can stick to evm
. apps built on top of ctc should generally use evm
unless theyre doing advanced stuff. evm
could have other backends besides rpc in the future like bigquery/thegraph/others. so for example if you want data of a transaction and you don't care where it comes from, you would use evm
. rpc
is for when you are specifically interested in using an rpc client to obtain the data
at least that is the intention behind how things have been built so far. open to suggestions.
for the currently existing caches in ctc, some would probably be made obsolete by a generic eth_call cache, whereas others would still be faster with their current bespoke solutions. and if the bespoke solution is faster, it could be even faster to keep the generic cache disabled for those calls. but a lot of this is empirical and unknowable until it is actually tested irl
if you need a cache ASAP you could do it using something like toolcache:
from ctc import rpc
import toolcache
@toolcache.cache('disk')
async def get_code(address):
return await rpc.async_eth_get_code(address)
(but this will use files on disk rather than a nice db so it won't have optimal performance)
from checkthechain.
Related Issues (20)
- Setup error when not using default ctc_data location HOT 1
- ctc setup fails with non-default data root directory HOT 1
- ctc setup fails on Polygon, `table not found in db: network_1__erc20_metadata` HOT 1
- cg graphs not working on windows HOT 1
- Installation failure from source code
- Error: `(sqlite3.OperationalError) near "ON": syntax error` HOT 1
- `ctc ens` not successful HOT 2
- Specify network HOT 1
- a lot of my `ctc ascii 0x...` queries come back with only `utf-8`
- I run the python sample and get "Exception: no default network specified"
- RPC ERROR: query returned more than 10000 results HOT 1
- NameError: name 'ctc' is not defined HOT 1
- A very grateful stranger
- Add support for `eth_feeHistory` HOT 1
- Issue with the erc20 transfers cli command HOT 1
- feature: add localised ABIs for frequently queried contracts to speed up querying
- UPDATE syntax error on setup
- KeyError 'id' in chunk HOT 1
- Downloading blocks fails
- Issue: KeyError: 'status' in convert_rpc_transaction_to_db_transaction for Older Transactions
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from checkthechain.