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

Fix buffer issues with async IPC; add tests #3492

Merged
merged 3 commits into from
Sep 20, 2024

Conversation

fselmo
Copy link
Collaborator

@fselmo fselmo commented Sep 19, 2024

What was wrong?

Closes #3485

How was it fixed?

  • Move to a readline() approach on the stream reader for IPC. The older implementation for the original IPC would read in chunks but this isn't ideal and, it turns out, opting for readline while allowing control of the buffer limit lends itself quite nicely to plucking well-formed responses from the socket.

Todo:

  • Clean up commit history / elaborate on commit message
  • Add or update documentation related to these changes
  • Add entry to the release notes

Cute Animal Picture

ezgif com-animated-gif-maker

@fselmo fselmo force-pushed the fix-issues-with-ipc-socket-read branch 4 times, most recently from 800b091 to 751dd72 Compare September 19, 2024 22:59
- Move to a readline() approach on the stream
  reader for IPC. The older implementation for
  the original IPC would read in chunks but this
  isn't ideal and, it turns out, opting for
  readline while allowing control of the buffer
  limit lends itself quite nicely to plucking
  well-formed responses from the socket.
@fselmo fselmo force-pushed the fix-issues-with-ipc-socket-read branch from 751dd72 to 91cb2d5 Compare September 19, 2024 23:38
@raxhvl
Copy link

raxhvl commented Sep 20, 2024

I wonder if chunks can arrive in arbitrary order. Also this thread discusses possible solutions.

@fselmo fselmo force-pushed the fix-issues-with-ipc-socket-read branch from dfc96b0 to 4ee81d3 Compare September 20, 2024 16:16
- Document ``read_buffer_limit`` on the ``AsyncIPCProvider`` class.

- Add ``ReadBufferLimitReached`` exception to be raised when the read buffer
  limit is reached, prompting the user to increase the limit.

- Add a base ``PersistentConnectionError`` exception class for persistent
  connection errors to inherit from.
@fselmo fselmo force-pushed the fix-issues-with-ipc-socket-read branch from 4ee81d3 to 8504dd9 Compare September 20, 2024 16:25
@fselmo fselmo marked this pull request as ready for review September 20, 2024 16:26
@fselmo
Copy link
Collaborator Author

fselmo commented Sep 20, 2024

@raxhvl thanks for reporting. I believe this will be a more straightforward approach that can give control to the user to configure the read buffer limit if needs to be even larger than the default of 20MB. This should resolve your issues and I added a test to test this limit.

Copy link
Collaborator

@kclowes kclowes left a comment

Choose a reason for hiding this comment

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

I left a couple questions to take or leave, but generally looks good to me! Much cleaner! 🧹

web3/providers/persistent/async_ipc.py Show resolved Hide resolved
tests/core/providers/test_async_ipc_provider.py Outdated Show resolved Hide resolved
- Also inherit from ``Web3ValueError`` for ``ReadBufferLimitReached``.

- Properly assert the response for configured read limit test.
@fselmo fselmo merged commit 9baae32 into ethereum:main Sep 20, 2024
71 checks passed
@fselmo fselmo deleted the fix-issues-with-ipc-socket-read branch September 20, 2024 20:36
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.

IPC Provider throws timeout error for large responses
3 participants