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

Cache eth.chain_id in simple_cache_middleware #2425

Merged
merged 4 commits into from
Apr 13, 2022

Conversation

kclowes
Copy link
Collaborator

@kclowes kclowes commented Apr 13, 2022

What was wrong?

It was not ideal to have to set _default_chain_id=None to make the chain_id request again. Added the sync chain_id to the simple_cache_middleware instead. Our benchmarking suite shows times of ~.003s after chain_id is cached, which is down from ~.017s.

How was it fixed?

Added eth_chainId to the simple_cache_middleware. Had to take out the async _default_chain_id flow for consistency between the two modules, and will add caching for async chain_id after the simple_cache_middleware gets asyncified.

Todo:

Cute Animal Picture

Put a link to a cute animal picture inside the parenthesis-->

kclowes added 3 commits April 13, 2022 10:26
Will add async chainId to the cache once the simple_cache_middleware is available on async
@kclowes kclowes requested review from fselmo, wolovim and pacrob April 13, 2022 18:16
@kclowes kclowes changed the title [WIP] Cache chainId Cache eth.chain_id in simple_cache_middleware Apr 13, 2022
Copy link
Collaborator

@fselmo fselmo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm! I think it just needs a 2425 newsfragment but this is great. Good to know on the performance improvement too 👌

@kclowes kclowes merged commit 482ff94 into ethereum:v5 Apr 13, 2022
@kclowes kclowes deleted the cache-chain-id branch April 13, 2022 20:57
kclowes added a commit to kclowes/web3.py that referenced this pull request Apr 13, 2022
* Add caching for sync chain_id

* Remove async chainId setter

Will add async chainId to the cache once the simple_cache_middleware is available on async

* Add docs

* Add newsfragment for simple_cache_middleware, take out old, confusing newsfragment
@kclowes kclowes mentioned this pull request Apr 13, 2022
1 task
kclowes added a commit that referenced this pull request Apr 27, 2022
* Cache eth.chain_id in simple_cache_middleware (#2425)

* Add caching for sync chain_id

* Remove async chainId setter

Will add async chainId to the cache once the simple_cache_middleware is available on async

* Add docs

* Add newsfragment for simple_cache_middleware, take out old, confusing newsfragment
pacrob pushed a commit that referenced this pull request May 23, 2022
* Cache eth.chain_id in simple_cache_middleware (#2425)

* Add caching for sync chain_id

* Remove async chainId setter

Will add async chainId to the cache once the simple_cache_middleware is available on async

* Add docs

* Add newsfragment for simple_cache_middleware, take out old, confusing newsfragment
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.

2 participants