Skip to content

refactor: validator's naive N GenServer and Supervisor removal #1218

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

Merged
merged 10 commits into from
Jul 18, 2024

Conversation

rodrigo-o
Copy link
Collaborator

@rodrigo-o rodrigo-o commented Jul 12, 2024

Motivation

This is part of the effort for removing all GenServers and redesign the concurrency architecture from scratch

Description
In this PR I'll tackle the most basic way for the GenServer removal, it doesn't deal with some well-needed refactors (like sharing duties and avoid duplicated work), it just starts to manage state at the ValidatorManager level. After going through some issues regarding the attestation and block proposal it wasn't posible to execute the notification for Validators Synchronously inside the Clock as it was done. Temporarily reintroduce one GenServer instead of the previous N, for the ValidatorManager.

Important issues to tackle in future PRs

This is not an exhaustive list but could point int the right direction.

  • Right now the get_current_time was a Genserver.call in the Clock. This is generating locks when the validators are executed syncroneously in the tick. The Clock will be removed later but in the meantime getting rid of the get_current_time will free the next issue to be taken
  • Remove the GenServer from the ValidatorManager after solving the previous issue
  • Do an in-depth refactor of the Validators & ValidatorManager state management. This PR didn't deal with those, it maintained the previous way of managing it and just moved the validators state to the ValidatorManager.
    • slot and root should be shared
    • duties should be shared and calculated once per epoch (updated just when needed)
    • better handle what information we have of each validator at the ValidatorManager level, for example regarding if they are or not setup
  • Do an in-depth refactor of the Validator and Validator Manager Logic
    • Check for duplicated block procesing
    • Just execute the ticks for the validators which have duties on those slots

Issues

Solves #1178

@rodrigo-o rodrigo-o changed the title refactor: Validator's naive GenServer and Supervisor removal refactor: validator's naive GenServer and Supervisor removal Jul 12, 2024
Copy link
Collaborator

@Arkenan Arkenan left a comment

Choose a reason for hiding this comment

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

LGTM! Some comments that may be for next PRs:

  • A validator's state has a head_slot and head_root, which are shared by all. We might want to have them in the validator manager instead, and add those to the function calls. Not sure if that simplifies or complicates the code, but it deduplicates the variables.
  • Maybe we should have the uninitialized validators in a separate variable instead of having them mixed and notifying them all. This is completely up to discussion and opinionated, but I do find it a bit weird to have a try_setup on every notification instead of trying that in the manager each time there's a change of target state.

@rodrigo-o rodrigo-o changed the title refactor: validator's naive GenServer and Supervisor removal refactor: validator's naive N GenServer and Supervisor removal Jul 16, 2024
@rodrigo-o
Copy link
Collaborator Author

A validator's state has a head_slot and head_root, which are shared by all. We might want to have them in the validator manager instead, and add those to the function calls. Not sure if that simplifies or complicates the code, but it deduplicates the variables.

Yes, totally agree, I'll be more explicit in the PR description about this, I'll gathered it upon the "it doesn't deal with some well-needed refactors", but yes, both head and slot as well as duty management should be shared. I didn't know either if it simplifies things or not but also agreed that's not the place for it. I just tried to touch ligic as fewer as possible in this PR, and add more logging.

Maybe we should have the uninitialized validators in a separate variable instead of having them mixed and notifying them all. This is completely up to discussion and opinionated, but I do find it a bit weird to have a try_setup on every notification instead of trying that in the manager each time there's a change of target state.

Also agree, they are hard to track, up until now it wasn't an issue except for the validators just being there doing nothing, and as far as i could see the condition for them not being able to initialize is the lack of the public key in the validators set. I just ignore the calls in those cases for now instead of retrying the setup which wouldn't work in the new schema, holding all the validators until this ones correctly set up. I also think this is part of the deeper refactor.

@rodrigo-o rodrigo-o marked this pull request as ready for review July 16, 2024 17:56
@rodrigo-o rodrigo-o requested a review from a team as a code owner July 16, 2024 17:56
@rodrigo-o rodrigo-o marked this pull request as draft July 17, 2024 11:34
@rodrigo-o rodrigo-o marked this pull request as ready for review July 17, 2024 12:22
Copy link
Collaborator

@Arkenan Arkenan left a comment

Choose a reason for hiding this comment

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

LGTM!

@rodrigo-o rodrigo-o merged commit ad6bb31 into main Jul 18, 2024
13 checks passed
@rodrigo-o rodrigo-o deleted the validator-initial-refactor branch July 18, 2024 14:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging this pull request may close these issues.

2 participants