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

Substantial VC cleanup #13593

Merged
merged 13 commits into from
May 21, 2024
Merged

Substantial VC cleanup #13593

merged 13 commits into from
May 21, 2024

Conversation

rkapka
Copy link
Contributor

@rkapka rkapka commented Feb 7, 2024

What type of PR is this?

Cleanup

What does this PR do? Why is it needed?

Certain parts of the validator client's code have not been for a long time. The code is messy, non-elegant and oftentimes hard to update. This PR is the first one in a series of PRs that aim to improve the overall code quality of the module.

Changes overview:

  • Renamed ValidatorClient interface to Coordinator. Given that Validator Client is the name for the whole component of Prysm, it is confusing that the interface has the same name. The main reason for choosing this particular name is that functions defined on this interface define the behavior of the VC and actions performed on managed keys.
  • Removed the Beacon part from BeaconChainClient and PrysmBeaconChainClient because it's obvious we mean the beacon chain, not some other chain.
  • Organized, renamed and cleaned up fields in service/config structs.
  • Removed unused SyncChecker and GenesisFetcher interfaces and their implementations.
  • Removed TLS support from the RPC server. The certificate flags that we have are used for values regarding the connection from the VC to the BN, and there is no way to currently define a certificate for the VC server (the fields that we check are never set to anything). Nobody ever complained about it and I think such a requirement would be very niche.

@rkapka rkapka requested a review from a team as a code owner February 7, 2024 15:58
@rkapka rkapka requested review from nalepae, saolyn and potuz February 7, 2024 15:58
@rkapka rkapka added the Blocked Blocked by research or external factors label Feb 7, 2024
@@ -62,7 +62,7 @@ func (b *BeaconCommitteeSelection) UnmarshalJSON(input []byte) error {
return nil
}

type ValidatorClient interface {
type Coordinator interface {
Copy link
Contributor

@james-prysm james-prysm Feb 7, 2024

Choose a reason for hiding this comment

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

I'm not sold on the word coordinator, to me coordinator would also define when these are called as well.
Most of these functions are actions for participating in consensus, what about ConsensusToolkit or ConsensusAgent or ConsensusOperator or RoleOperator/DutyOperator - ( since the validator gets the duties first to perform the tasks in it.) there's probably some design pattern to enforce that the duties are up to date in the state to perform the actions inside.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I reverted this change. We should probably split the interface into a few smaller interfaces, each responsible for its own this. Mixing GetDuties with EventStreamIsRunning doesn't feel right.

log.Info("Established secure gRPC connection")
}
s.beaconNodeHealthClient = ethpb.NewHealthClient(grpcConn)
s.healthClient = ethpb.NewHealthClient(grpcConn)
Copy link
Contributor

Choose a reason for hiding this comment

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

we need a todo to get rid of this thing i think

@CLAassistant
Copy link

CLAassistant commented Feb 12, 2024

CLA assistant check
All committers have signed the CLA.

rkapka and others added 2 commits February 12, 2024 13:01
# Conflicts:
#	validator/client/service.go
#	validator/client/validator.go
#	validator/rpc/server.go
genesisTime uint64
highestValidSlot primitives.Slot
Copy link
Contributor

Choose a reason for hiding this comment

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

why did we move some of these fields around? is it a linting issue?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I moved fields so that they are grouped together by functionality

@@ -414,7 +414,7 @@ func (s *Server) ListRemoteKeys(w http.ResponseWriter, r *http.Request) {
for i := 0; i < len(pubKeys); i++ {
keystoreResponse[i] = &RemoteKey{
Pubkey: hexutil.Encode(pubKeys[i][:]),
Url: s.validatorService.Web3SignerConfig.BaseEndpoint,
Url: s.validatorService.SignerConfig().BaseEndpoint,
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe it makes more sense as RemoteSignerConfig()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -270,5 +240,5 @@ func (s *Server) Stop() error {

// Status returns nil or credentialError.
func (s *Server) Status() error {
return s.credentialError
return nil
Copy link
Contributor

Choose a reason for hiding this comment

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

does this function do anything? lol is there a reason to keep it or at least add some log?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is part of the Service interface contract. It returns an error when something is wrong with the service. Which means that currently we always treat the service as healthy. If we want to add some logic here, it would be better to do it in another PR.

rkapka added 3 commits May 21, 2024 13:08
# Conflicts:
#	testing/validator-mock/chain_client_mock.go
#	testing/validator-mock/prysm_beacon_chain_client_mock.go
#	validator/client/attest_test.go
#	validator/client/beacon-api/beacon_api_validator_client.go
#	validator/client/beacon-api/duties_test.go
#	validator/client/propose_test.go
#	validator/client/service.go
#	validator/client/validator.go
#	validator/client/validator_test.go
#	validator/node/node.go
#	validator/rpc/auth_token.go
#	validator/rpc/beacon.go
#	validator/rpc/handlers_keymanager.go
#	validator/rpc/handlers_keymanager_test.go
#	validator/rpc/handlers_slashing.go
#	validator/rpc/handlers_slashing_test.go
#	validator/rpc/server.go
@rkapka rkapka removed the Blocked Blocked by research or external factors label May 21, 2024
@@ -109,7 +110,7 @@ func NewServer(ctx context.Context, cfg *Config) *Server {
if err := server.initializeAuthToken(); err != nil {
log.WithError(err).Error("Could not initialize web auth token")
}
validatorWebAddr := fmt.Sprintf("%s:%d", server.validatorGatewayHost, server.validatorGatewayPort)
validatorWebAddr := fmt.Sprintf("%s:%d", server.grpcGatewayHost, server.grpcGatewayPort)
Copy link
Contributor

Choose a reason for hiding this comment

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

we should look at changing this naming again in the future. we want to get rid of gateway asap

@@ -268,6 +240,11 @@ func (v *ValidatorService) Keymanager() (keymanager.IKeymanager, error) {
return v.validator.Keymanager()
}

// RemoteSignerConfig returns the web3signer configuration
func (v *ValidatorService) RemoteSignerConfig() *remoteweb3signer.SetupConfig {
return v.web3SignerConfig
Copy link
Contributor

Choose a reason for hiding this comment

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

should we change this name too?

@rkapka rkapka added this pull request to the merge queue May 21, 2024
Merged via the queue into develop with commit 30cc23c May 21, 2024
16 of 17 checks passed
@rkapka rkapka deleted the simplify-vc branch May 21, 2024 16:46
@james-prysm james-prysm mentioned this pull request May 22, 2024
1 task
prestonvanloon pushed a commit that referenced this pull request May 31, 2024
* Cleanup part 1

* Cleanup part 2

* Cleanup part 3

* remove lock field init

* doc for SignerConfig

* remove vars

* use full Keymanager word in function

* revert interface rename

* linter

* fix build issues

* review

(cherry picked from commit 30cc23c)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants