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

feat: fork detection #6

Merged
merged 9 commits into from
Jun 15, 2023
Merged

feat: fork detection #6

merged 9 commits into from
Jun 15, 2023

Conversation

vgorkavenko
Copy link
Contributor

No description provided.

@vgorkavenko vgorkavenko requested a review from a team as a code owner June 9, 2023 14:08
@vgorkavenko vgorkavenko requested review from madlabman and dgusakov June 9, 2023 14:08
@vgorkavenko vgorkavenko force-pushed the feat/fork-detection branch from 0665b22 to afb168b Compare June 12, 2023 11:41
@vgorkavenko vgorkavenko force-pushed the feat/fork-detection branch from afb168b to acd484d Compare June 12, 2023 11:41
@@ -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)
Copy link
Contributor

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.

Copy link
Contributor Author

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

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

"""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
Copy link
Contributor

Choose a reason for hiding this comment

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

Why so precise?

Copy link
Contributor Author

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

@vgorkavenko vgorkavenko requested a review from madlabman June 13, 2023 06:21
@@ -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)

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 Show resolved Hide resolved
src/watcher.py Outdated Show resolved Hide resolved
src/watcher.py Outdated Show resolved Hide resolved
src/handlers/fork.py Outdated Show resolved Hide resolved
src/handlers/fork.py Outdated Show resolved Hide resolved
@vgorkavenko vgorkavenko requested a review from skhomuti June 13, 2023 14:39
skhomuti
skhomuti previously approved these changes Jun 14, 2023
src/watcher.py Outdated Show resolved Hide resolved
@vgorkavenko vgorkavenko merged commit 2d9ff46 into develop Jun 15, 2023
@vgorkavenko vgorkavenko deleted the feat/fork-detection branch June 20, 2023 06:17
vgorkavenko added a commit that referenced this pull request Jun 23, 2023
* 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>
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.

3 participants