-
Notifications
You must be signed in to change notification settings - Fork 2
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
feat: fork detection #6
Conversation
0665b22
to
afb168b
Compare
afb168b
to
acd484d
Compare
src/providers/consensus/client.py
Outdated
@@ -117,6 +125,16 @@ def get_validators_stream(self, slot_number: SlotNumber) -> Response: | |||
) | |||
return stream | |||
|
|||
def get_chain_reorg_stream(self) -> Response: | |||
"""Spec: https://consensys.github.io/teku/#tag/Events/operation/getEvents""" | |||
special_client = copy(self) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't get the reason for this approach.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change the default values. For the events handling, we should keep the connection alive. Maybe there is sense to placing the event request method to parent class
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks too complex and not obvious imo
could you just add arguments to the provider functions and override default constants if they're present
I think it will be ok to use kwargs
here and pass it deeply up to _get_stream_without_fallbacks
src/providers/consensus/client.py
Outdated
"""Spec: https://ethereum.github.io/beacon-APIs/#/Beacon/getBlockV2""" | ||
# Set special timeout and retry params for this method. | ||
# It is used for `head` request | ||
special_client = copy(self) | ||
special_client.HTTP_REQUEST_TIMEOUT = 2 | ||
special_client.HTTP_REQUEST_TIMEOUT = 1.5 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why so precise?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have to keep a balance between catching a new head and quickly changing host URL in case of an error. This value is just the result of N dev runs
src/providers/consensus/client.py
Outdated
@@ -117,6 +125,16 @@ def get_validators_stream(self, slot_number: SlotNumber) -> Response: | |||
) | |||
return stream | |||
|
|||
def get_chain_reorg_stream(self) -> Response: | |||
"""Spec: https://consensys.github.io/teku/#tag/Events/operation/getEvents""" | |||
special_client = copy(self) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks too complex and not obvious imo
could you just add arguments to the provider functions and override default constants if they're present
I think it will be ok to use kwargs
here and pass it deeply up to _get_stream_without_fallbacks
* CODEOWNERS * feat: fork detection (#6) * feat: fork detection * feat: add unhandled head parent alert * fix: unhandled slot alert * fix: decrease timeouts and retries * fix: linter * fix: review * fix: type * fix: add `threading.Lock` * fix: update dependencies * chore(deps): bump docker/build-push-action from 3 to 4 (#5) Bumps [docker/build-push-action](https://github.com/docker/build-push-action) from 3 to 4. - [Release notes](https://github.com/docker/build-push-action/releases) - [Commits](docker/build-push-action@v3...v4) --- updated-dependencies: - dependency-name: docker/build-push-action dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: Vladimir Gorkavenko <32727352+vgorkavenko@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Fix/errors handling (#8) * fix: unhandled errors * chore: labels for prometheus jobs * fix: remove useless `del` * fix: review * fix: alerts (#10) * fix: parse validators (#11) * feat: tests and polish (#12) * feat: tests and polish * fix: mypy * chore: fix workflow * refactor: add thread_as_daemon decorator * chore: add isort * fix: review --------- Co-authored-by: madlabman <10616301+madlabman@users.noreply.github.com> * fix: workflow (#13) --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: madlabman <10616301+madlabman@users.noreply.github.com>
No description provided.