alloy icon indicating copy to clipboard operation
alloy copied to clipboard

refactor: Refactor ChainStreamPoller

Open popzxc opened this issue 7 months ago • 5 comments

Fixes #1053

This PR turned out a bit larger than I wanted it to be, but I don't think it makes much sense to split it into several ones. Here's what changed:

  • TransportErrorKind::recoverable marked as deprecated, because there already is a more advanced is_retry_err method. The deprecation message suggests using it, or RetryBackoffLayer for HTTP.
  • Retries were removed from PollerBuilder and ChainStreamPoller. The logic there was pretty basic and it wouldn't solve most problems that can realistically occur. IMHO, recovering belongs to the transport domain; otherwise, there will be one recovery implementation per client user, and a good solution is already present in the project - RetryBackoffLayer. I guess something like this is needed for WebSocket as well.
  • ChainPollerStream was split into two parts. One handles initialization (works like a tiny builder), and one actually stores the stream state. It allowed us to get rid of NO_BLOCK_NUMBER used as a placeholder.
  • Dedicated error type was added to simplify implementation.
  • Finally, batches are now requested via JSON RPC batch request instead of sequential single requests.

popzxc avatar Jul 16 '24 11:07 popzxc