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: handle service restarts #400

Merged
merged 7 commits into from Sep 11, 2023
Merged

Conversation

MicaiahReid
Copy link
Collaborator

@MicaiahReid MicaiahReid commented Aug 29, 2023

Description

Improves how we handle a restart of chainhook service while predicates are scanning/streaming. Here are the cases we now handle:

  1. Predicates that were in scanning status when Chainhook was terminated will resume scanning starting from their last_evaluated_block_height. Note: because we only save predicate status every 10 scans, we could end up re-emiting matches on a resetart
  2. Predicates that were in new status when Chainhook was terminated will start scanning at the predicate's start_block
  3. Predicates that were in streaming status will return to a scanning status, starting at last_evaluated_block_height to catch up on the missed blocks. Note, the number_of_blocks_to_scan is set to 0 for this temporary catch-up, as it's difficult to compute the number of remaining blocks in the context of this change
  4. If predicates were passed in at startup, we also register those to begin scanning, which previously didn't happen
  5. We now allow passing in a predicate at startup and registering additional predicates with the predicate registration server. This means that if you use the same startup predicate repeatedly, it will already be saved in redis and not be reloaded.

Fixes: #298, fixes #390, fixes #402, fixes #403


Checklist

  • All tests pass
  • Tests added in this PR (if applicable)

@MicaiahReid MicaiahReid changed the title pick up where scanning left off on restarted scan fix: handle service restarts Aug 30, 2023
@MicaiahReid MicaiahReid marked this pull request as ready for review September 11, 2023 18:01
@MicaiahReid MicaiahReid merged commit 55298f3 into augment-get-chainhooks Sep 11, 2023
1 check passed
@MicaiahReid MicaiahReid deleted the allow-scan-restart branch September 11, 2023 18:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

None yet

1 participant