Skip to content

Commit

Permalink
Allow re-registration of previous validator state.
Browse files Browse the repository at this point in the history
  • Loading branch information
mcdee committed Jan 11, 2024
1 parent de37cb9 commit e8baf6d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
dev:
1.8.0-beta.1:
- ensure relay configuration inherits all configuration values as expected
- create strategies for builder bid
- fetch blinded and unblinded proposals in parallel to speed up block production
Expand All @@ -9,6 +9,7 @@ dev:
- implement exclusion list for builders
- add option to attempt unblinding of payloads from all contacted relays
- add "majority" attestation data strategy
- allow MEV relay re-registration of previously registered data

1.7.6:
- add User-Agent header to HTTP requests
Expand Down
5 changes: 4 additions & 1 deletion services/blockrelay/standard/service.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright © 2022, 2023 Attestant Limited.
// Copyright © 2022 - 2024 Attestant Limited.
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
Expand Down Expand Up @@ -53,6 +53,8 @@ type Service struct {
validatorRegistrationSigner signer.ValidatorRegistrationSigner
builderBidsCache map[string]map[string]*builderspec.VersionedSignedBuilderBid
builderBidsCacheMu sync.RWMutex
latestValidatorRegistrations map[phase0.BLSPubKey]phase0.Root
latestValidatorRegistrationsMu sync.RWMutex
signedValidatorRegistrations map[phase0.Root]*apiv1.SignedValidatorRegistration
signedValidatorRegistrationsMu sync.RWMutex
secondaryValidatorRegistrationsSubmitters []consensusclient.ValidatorRegistrationsSubmitter
Expand Down Expand Up @@ -100,6 +102,7 @@ func New(ctx context.Context, params ...Parameter) (*Service, error) {
accountsProvider: parameters.accountsProvider,
validatingAccountsProvider: parameters.validatingAccountsProvider,
validatorRegistrationSigner: parameters.validatorRegistrationSigner,
latestValidatorRegistrations: make(map[phase0.BLSPubKey]phase0.Root),
signedValidatorRegistrations: make(map[phase0.Root]*apiv1.SignedValidatorRegistration),
secondaryValidatorRegistrationsSubmitters: parameters.secondaryValidatorRegistrationsSubmitters,
logResults: parameters.logResults,
Expand Down
16 changes: 13 additions & 3 deletions services/blockrelay/standard/submitvalidatorregistrations.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright © 2022, 2023 Attestant Limited.
// Copyright © 2022 - 2024 Attestant Limited.
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
Expand All @@ -14,6 +14,7 @@
package standard

import (
"bytes"
"context"
"encoding/json"
"fmt"
Expand Down Expand Up @@ -252,10 +253,16 @@ func (s *Service) generateValidatorRegistrationForRelay(ctx context.Context,
s.signedValidatorRegistrationsMu.RLock()
signedRegistration, exists := s.signedValidatorRegistrations[registrationRoot]
s.signedValidatorRegistrationsMu.RUnlock()
if exists {

// See if the latest registration matches this configuration.
s.latestValidatorRegistrationsMu.RLock()
latestRoot := s.latestValidatorRegistrations[pubkey]
s.latestValidatorRegistrationsMu.RUnlock()

if exists && bytes.Equal(latestRoot[:], registrationRoot[:]) {
monitorRegistrationsGeneration("cache")
} else {
log.Trace().Msg("Signing the validator registration")
log.Trace().Msg("Signing a new or updated validator registration")
sig, err := s.validatorRegistrationSigner.SignValidatorRegistration(ctx, account, &builderapi.VersionedValidatorRegistration{
Version: builderspec.BuilderVersionV1,
V1: registration,
Expand All @@ -271,6 +278,9 @@ func (s *Service) generateValidatorRegistrationForRelay(ctx context.Context,
s.signedValidatorRegistrationsMu.Lock()
s.signedValidatorRegistrations[registrationRoot] = signedRegistration
s.signedValidatorRegistrationsMu.Unlock()
s.latestValidatorRegistrationsMu.Lock()
s.latestValidatorRegistrations[pubkey] = registrationRoot
s.latestValidatorRegistrationsMu.Unlock()
monitorRegistrationsGeneration("generation")
}

Expand Down

0 comments on commit e8baf6d

Please sign in to comment.