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

Add support for non-mainnet request cache validation thresholds #3508

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

fselmo
Copy link
Collaborator

@fselmo fselmo commented Oct 10, 2024

What was wrong?

closes #3506

How was it fixed?

  • 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.
  • Added comprehensive testing around the mechanism and all affected endpoints.

Unrelated:

  • 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.)

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:

    1. When to reach for caching in the first place
    2. If they reach for caching, clarify internal calls can be made to get the necessary validation data
    3. Know how they can tweak the validation threshold to lower the number of internal calls made (or set it to None to cache any and all requests)
  • Add entry to the release notes

  • Clean up commit history

Cute Animal Picture

     __      __
    /  \____/  \
   (    o  o    )
    \    ∇     /
     \  \___/  /
      \_______/
        |   |

- 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 fselmo marked this pull request as ready for review October 11, 2024 16:40
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.

get_transaction failed when cache_allowed_requests is set to True.
1 participant