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

Refactor listener; add flush #58

Merged
merged 15 commits into from
Mar 21, 2024
Merged

Refactor listener; add flush #58

merged 15 commits into from
Mar 21, 2024

Conversation

boojamya
Copy link
Member

@boojamya boojamya commented Mar 13, 2024

This PR solves several issues.

Introduce reoccurring flush

The start command not accepts a --flush-interval or -i flag and takes a duration.

The relayer now tracks the "last-flushed-block".

When a flush interval is set:
The relayer will continuously look back last-flushed-block - lookback period up to the latest block and perform a flush.

(last-flushed-block - lookback period may be overkill? Potentially just flush last-flushed-block up to latest block ?)

Handle disconnected ETH web sockets

Prior to this PR, if an ETH/L2 web socket was disconnected, the relayer would crash. We relied on the infrastructure the relayer was deployed in to restart it. We now handle disconnections gracefully picking up where it left off.

This will also:

  • help with reviewing logs in a remote infrastructure as the logs were reset after each crash.
  • enable more accurate future metrics

Allow for larger ETH/L2 history queries

Depending on your ETH/L2 node or provider, you are only able to query a certain amount of history at once (we were running into this issue specifically with Avalanche). Now all ETH/L2 history queries are blocked in chunks of 100 blocks at a time.

Better handling of Clients and Cosmos Providers

This PR introduces InitializeClients() and CloseClients() to the chain interface. This allows for better handling of clients/providers and allows for an organized cleanup in the event of a termination.

@boojamya boojamya marked this pull request as ready for review March 20, 2024 15:45
cmd/process.go Outdated Show resolved Hide resolved
cmd/process.go Outdated Show resolved Hide resolved
stream, sub, history, err = etherReader.QueryWithHistory(ctx, &query)
if err != nil {
logger.Error("Unable to subscribe to logs", "attempt", queryAttempt, "err", err)
queryAttempt++
Copy link
Contributor

Choose a reason for hiding this comment

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

if queryAttempt gets above a certain number should this ever panic? or just a descriptor for logging?

Copy link
Member Author

Choose a reason for hiding this comment

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

My thinking here is that if for some reason the websocket is offline and it was unable to subscribe to logs, we should continue relaying and flushing other paths.

This would be a good place to add prometheus metrics so that an infra team can be notified about these errors.

ethereum/listener.go Outdated Show resolved Hide resolved
@boojamya boojamya merged commit 0c4a797 into main Mar 21, 2024
3 checks passed
@boojamya boojamya deleted the dan/flush branch March 21, 2024 15:12
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