-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Add support for non-mainnet request cache validation thresholds #3508
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
fselmo
force-pushed
the
non-pos-request-caching
branch
2 times, most recently
from
October 11, 2024 16:40
9dcbf30
to
b5b26de
Compare
fselmo
force-pushed
the
non-pos-request-caching
branch
2 times, most recently
from
October 11, 2024 16:50
9fcd38f
to
84d3234
Compare
pacrob
reviewed
Oct 14, 2024
fselmo
added a commit
to fselmo/web3.py
that referenced
this pull request
Oct 14, 2024
kclowes
approved these changes
Oct 14, 2024
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.
Mostly left lazy questions and small things, but looks good otherwise!
- If non-mainnet ethereum, allow the use of an integer value for the request cache validation threshold. Pre-configure "safe" default values for some common non-mainnet chain ids based on their varied finality mechanisms. - This integer value represents the number of seconds from time.now() that the request cache deems as a safe enough time window to allow the request to be cached. - Update the tests to reflect these changes. Bonus: - Add a note to the ``request_mocker`` to make sure that mocked results are of the correct expected types based on JSON-RPC spec (e.g. hex strings instead of ints for numbers, etc.)
- In order to prevent recursion, we need to turn off caching while we make internal calls to get the block information we need. Turn it back on via a ``finally`` so we are sure to turn it back on. - Add some comprehensive tests for the now complex request caching functionality due to multi-chain support and internal-based caching threshold configuration.
fselmo
added a commit
to fselmo/web3.py
that referenced
this pull request
Oct 14, 2024
- Fix typo in docs. - Fix test check, be more precise and check cache == 1. - Remove validation for threshold with chain_id == 1 since more chains than mainnet Ethereum can make use of ``finalized`` and ``safe`` thresholds.
fselmo
force-pushed
the
non-pos-request-caching
branch
3 times, most recently
from
October 15, 2024 15:54
9852a39
to
688ae86
Compare
- Fix typo in docs. - Fix test check, be more precise and check cache == 1. - Remove validation for threshold with chain_id == 1 since more chains than mainnet Ethereum can make use of ``finalized`` and ``safe`` thresholds. - Store and reset the current value of ``cache_allowed_requests`` rather than assuming ``True`` / ``False``
fselmo
force-pushed
the
non-pos-request-caching
branch
from
October 15, 2024 16:00
688ae86
to
90a4c3e
Compare
pacrob
reviewed
Oct 15, 2024
pacrob
approved these changes
Oct 15, 2024
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.
just one q, otherwise lgtm!
- Base providers don't implement ``make_request`` and so can't cache requests. Remove the request caching decorator from the base provider classes. - Fix typing in the request caching utils, which should now be tighter, expecting an ``RPCEndpoint`` instead of a generic ``str``.
fselmo
force-pushed
the
non-pos-request-caching
branch
from
October 15, 2024 17:17
90a4c3e
to
aa695d4
Compare
fselmo
added a commit
that referenced
this pull request
Oct 15, 2024
- Fix typo in docs. - Fix test check, be more precise and check cache == 1. - Remove validation for threshold with chain_id == 1 since more chains than mainnet Ethereum can make use of ``finalized`` and ``safe`` thresholds. - Store and reset the current value of ``cache_allowed_requests`` rather than assuming ``True`` / ``False``
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.
What was wrong?
closes #3506
How was it fixed?
Unrelated:
request_mocker
to make sure that mocked resultsare of the correct expected types based on JSON-RPC spec (e.g. hex
strings instead of ints for numbers, etc.)
make_request
. This makes typing tighter around the code base as well.Todo:
Add or update documentation related to these changes. This documentation should detail the underlying mechanism of how (and why) to check certain endpoints against a validation threshold so that users know:
None
to cache any and all requests)Add entry to the release notes
Clean up commit history
Cute Animal Picture