From 1ed66555def8636653f8fe4cb2e3356ef494fb29 Mon Sep 17 00:00:00 2001 From: james-prysm Date: Fri, 28 Apr 2023 15:58:32 -0500 Subject: [PATCH 01/33] WIP --- validator/db/kv/proposer_settings.go | 21 +++++++++++++++++++++ validator/db/kv/schema.go | 3 +++ 2 files changed, 24 insertions(+) create mode 100644 validator/db/kv/proposer_settings.go diff --git a/validator/db/kv/proposer_settings.go b/validator/db/kv/proposer_settings.go new file mode 100644 index 000000000000..29e1aa43e84b --- /dev/null +++ b/validator/db/kv/proposer_settings.go @@ -0,0 +1,21 @@ +package kv + +// UpdateProposerSettings +func (s *Store) UpdateProposerSettings(_ context.Context, genValRoot []byte) error { + err := s.db.Update(func(tx *bolt.Tx) error { + bkt := tx.Bucket(genesisInfoBucket) + enc := bkt.Get(genesisValidatorsRootKey) + if len(enc) != 0 { + return fmt.Errorf("cannot overwite existing genesis validators root: %#x", enc) + } + return bkt.Put(genesisValidatorsRootKey, genValRoot) + }) + return err +} + +// + +// ProposerSettings +func (s *Store) ProposerSettings(_ context.Context, genValRoot []byte) error { + +} diff --git a/validator/db/kv/schema.go b/validator/db/kv/schema.go index 1fb1b36482bd..3e0bc92ce414 100644 --- a/validator/db/kv/schema.go +++ b/validator/db/kv/schema.go @@ -37,4 +37,7 @@ var ( // Graffiti ordered index and hash keys graffitiOrderedIndexKey = []byte("graffiti-ordered-index") graffitiFileHashKey = []byte("graffiti-file-hash") + + // ProposerSettings stores the encoded proposer settings file + proposerSettingsBucket = []byte("proposer-settings") ) From 7b73e87aba156c241fb2c93e5d3d4ae2c22ca527 Mon Sep 17 00:00:00 2001 From: james-prysm Date: Fri, 28 Apr 2023 17:20:35 -0500 Subject: [PATCH 02/33] improving proposer settings store --- validator/db/kv/proposer_settings.go | 53 ++++++++++++++++++++++++---- validator/db/kv/schema.go | 3 +- 2 files changed, 48 insertions(+), 8 deletions(-) diff --git a/validator/db/kv/proposer_settings.go b/validator/db/kv/proposer_settings.go index 29e1aa43e84b..e9eddccd25b4 100644 --- a/validator/db/kv/proposer_settings.go +++ b/validator/db/kv/proposer_settings.go @@ -1,14 +1,41 @@ package kv +import ( + "context" + "encoding/json" + "fmt" + + "github.com/pkg/errors" + validator_service_config "github.com/prysmaticlabs/prysm/v4/config/validator/service" + bolt "go.etcd.io/bbolt" +) + // UpdateProposerSettings -func (s *Store) UpdateProposerSettings(_ context.Context, genValRoot []byte) error { +func (s *Store) UpdateProposerSettings(_ context.Context, pubkey string, options *validator_service_config.ProposerOptionPayload) error { err := s.db.Update(func(tx *bolt.Tx) error { - bkt := tx.Bucket(genesisInfoBucket) - enc := bkt.Get(genesisValidatorsRootKey) - if len(enc) != 0 { - return fmt.Errorf("cannot overwite existing genesis validators root: %#x", enc) + bkt := tx.Bucket(proposerSettingsBucket) + if bkt == nil { + if _, err := tx.CreateBucketIfNotExists(proposerSettingsBucket); err != nil { + return err + } + } + b := bkt.Get(proposerSettingsKey) + if len(b) != 0 { + return fmt.Errorf("no proposer settings found in bucket") + } + to := &validator_service_config.ProposerSettingsPayload{} + if err := json.Unmarshal(b, to); err != nil { + return errors.Wrap(err, "failed to unmarshal proposer settings") + } + if to.ProposerConfig == nil { + to.ProposerConfig = make(map[string]*validator_service_config.ProposerOptionPayload) } - return bkt.Put(genesisValidatorsRootKey, genValRoot) + to.ProposerConfig[pubkey] = options + m, err := json.Marshal(to) + if err != nil { + return errors.Wrap(err, "failed to marshal proposer settings") + } + return bkt.Put(proposerSettingsKey, m) }) return err } @@ -16,6 +43,18 @@ func (s *Store) UpdateProposerSettings(_ context.Context, genValRoot []byte) err // // ProposerSettings -func (s *Store) ProposerSettings(_ context.Context, genValRoot []byte) error { +func (s *Store) ProposerSettings(ctx context.Context) (*validator_service_config.ProposerSettingsPayload, error) { + return nil, nil +} +// SaveProposerSettings +func (s *Store) SaveProposerSettings(ctx context.Context, settings *validator_service_config.ProposerSettingsPayload) error { + return s.db.Update(func(tx *bolt.Tx) error { + bkt := tx.Bucket(genesisInfoBucket) + enc := bkt.Get(genesisValidatorsRootKey) + if len(enc) == 0 { + return nil + } + return nil + }) } diff --git a/validator/db/kv/schema.go b/validator/db/kv/schema.go index 3e0bc92ce414..ab083e8f7cd4 100644 --- a/validator/db/kv/schema.go +++ b/validator/db/kv/schema.go @@ -39,5 +39,6 @@ var ( graffitiFileHashKey = []byte("graffiti-file-hash") // ProposerSettings stores the encoded proposer settings file - proposerSettingsBucket = []byte("proposer-settings") + proposerSettingsBucket = []byte("proposer-settings-bucket") + proposerSettingsKey = []byte("proposer-settings") ) From 53a4b2fe06bea237ebac6ca3719afd0966705017 Mon Sep 17 00:00:00 2001 From: james-prysm Date: Mon, 1 May 2023 22:05:50 -0500 Subject: [PATCH 03/33] WIP persistent validator settings --- validator/client/runner.go | 7 ++ validator/db/iface/interface.go | 8 +++ validator/db/kv/db.go | 1 + validator/db/kv/proposer_settings.go | 97 +++++++++++++++++++++------- validator/node/node.go | 31 +++++++-- 5 files changed, 116 insertions(+), 28 deletions(-) diff --git a/validator/client/runner.go b/validator/client/runner.go index 1805b174c308..3dba1f3f7976 100644 --- a/validator/client/runner.go +++ b/validator/client/runner.go @@ -53,6 +53,13 @@ func run(ctx context.Context, v iface.Validator) { log.WithError(err).Fatal("Could not get keymanager") } sub := km.SubscribeAccountChanges(accountsChangedChan) + // checks db if proposer settings exist if none is provided. + if v.ProposerSettings() == nil { + + // check if existing db exists and set proposer settings from that + // attempt to migrate persistent fee recipient data from beacon node + } + // check if proposer settings is still nil // Set properties on the beacon node like the fee recipient for validators that are being used & active. if v.ProposerSettings() != nil { log.Infof("Validator client started with provided proposer settings that sets options such as fee recipient"+ diff --git a/validator/db/iface/interface.go b/validator/db/iface/interface.go index 228d0a02dbc4..f2180af4de93 100644 --- a/validator/db/iface/interface.go +++ b/validator/db/iface/interface.go @@ -6,6 +6,7 @@ import ( "io" fieldparams "github.com/prysmaticlabs/prysm/v4/config/fieldparams" + validatorServiceConfig "github.com/prysmaticlabs/prysm/v4/config/validator/service" "github.com/prysmaticlabs/prysm/v4/consensus-types/primitives" "github.com/prysmaticlabs/prysm/v4/monitoring/backup" ethpb "github.com/prysmaticlabs/prysm/v4/proto/prysm/v1alpha1" @@ -62,4 +63,11 @@ type ValidatorDB interface { // Graffiti ordered index related methods SaveGraffitiOrderedIndex(ctx context.Context, index uint64) error GraffitiOrderedIndex(ctx context.Context, fileHash [32]byte) (uint64, error) + + // ProposerSettings related methods + ProposerSettings(context.Context) (*validatorServiceConfig.ProposerSettings, error) + ProposerSettingsExists(ctx context.Context) (bool, error) + UpdateProposerSettingsDefault(context.Context, *validatorServiceConfig.ProposerOption) error + UpdateProposerSettingsForPubkey(context.Context, [fieldparams.BLSPubkeyLength]byte, *validatorServiceConfig.ProposerOption) error + SaveProposerSettings(ctx context.Context, settings *validatorServiceConfig.ProposerSettings) error } diff --git a/validator/db/kv/db.go b/validator/db/kv/db.go index 3fb3a06ea540..4d153f51508e 100644 --- a/validator/db/kv/db.go +++ b/validator/db/kv/db.go @@ -152,6 +152,7 @@ func NewKVStore(ctx context.Context, dirPath string, config *Config) (*Store, er pubKeysBucket, migrationsBucket, graffitiBucket, + proposerSettingsBucket, ) }); err != nil { return nil, err diff --git a/validator/db/kv/proposer_settings.go b/validator/db/kv/proposer_settings.go index e9eddccd25b4..9892f89bc17d 100644 --- a/validator/db/kv/proposer_settings.go +++ b/validator/db/kv/proposer_settings.go @@ -6,31 +6,29 @@ import ( "fmt" "github.com/pkg/errors" - validator_service_config "github.com/prysmaticlabs/prysm/v4/config/validator/service" + fieldparams "github.com/prysmaticlabs/prysm/v4/config/fieldparams" + validatorServiceConfig "github.com/prysmaticlabs/prysm/v4/config/validator/service" bolt "go.etcd.io/bbolt" ) -// UpdateProposerSettings -func (s *Store) UpdateProposerSettings(_ context.Context, pubkey string, options *validator_service_config.ProposerOptionPayload) error { +var NoProposerSettingsFound = errors.New("no proposer settings found in bucket") + +// UpdateProposerSettingsForPubkey updates the existing settings for an internal representation of the proposers settings file at a particular public key +func (s *Store) UpdateProposerSettingsForPubkey(_ context.Context, pubkey [fieldparams.BLSPubkeyLength]byte, options *validatorServiceConfig.ProposerOption) error { err := s.db.Update(func(tx *bolt.Tx) error { bkt := tx.Bucket(proposerSettingsBucket) - if bkt == nil { - if _, err := tx.CreateBucketIfNotExists(proposerSettingsBucket); err != nil { - return err - } - } b := bkt.Get(proposerSettingsKey) if len(b) != 0 { return fmt.Errorf("no proposer settings found in bucket") } - to := &validator_service_config.ProposerSettingsPayload{} + to := &validatorServiceConfig.ProposerSettings{} if err := json.Unmarshal(b, to); err != nil { return errors.Wrap(err, "failed to unmarshal proposer settings") } - if to.ProposerConfig == nil { - to.ProposerConfig = make(map[string]*validator_service_config.ProposerOptionPayload) + if to.ProposeConfig == nil { + to.ProposeConfig = make(map[[fieldparams.BLSPubkeyLength]byte]*validatorServiceConfig.ProposerOption) } - to.ProposerConfig[pubkey] = options + to.ProposeConfig[pubkey] = options m, err := json.Marshal(to) if err != nil { return errors.Wrap(err, "failed to marshal proposer settings") @@ -40,21 +38,74 @@ func (s *Store) UpdateProposerSettings(_ context.Context, pubkey string, options return err } -// +// UpdateProposerSettingsDefault updates the existing default settings for proposer settings +func (s *Store) UpdateProposerSettingsDefault(_ context.Context, options *validatorServiceConfig.ProposerOption) error { + if options == nil { + return errors.New("proposer settings option was empty") + } + if options.FeeRecipientConfig == nil { + return errors.New("fee recipient cannot be empty") + } + err := s.db.Update(func(tx *bolt.Tx) error { + bkt := tx.Bucket(proposerSettingsBucket) + b := bkt.Get(proposerSettingsKey) + if len(b) != 0 { + return NoProposerSettingsFound + } + to := &validatorServiceConfig.ProposerSettings{} + if err := json.Unmarshal(b, to); err != nil { + return errors.Wrap(err, "failed to unmarshal proposer settings") + } + to.DefaultConfig = options + m, err := json.Marshal(to) + if err != nil { + return errors.Wrap(err, "failed to marshal proposer settings") + } + return bkt.Put(proposerSettingsKey, m) + }) + return err +} -// ProposerSettings -func (s *Store) ProposerSettings(ctx context.Context) (*validator_service_config.ProposerSettingsPayload, error) { - return nil, nil +// ProposerSettings gets the current proposer settings +func (s *Store) ProposerSettings(ctx context.Context) (*validatorServiceConfig.ProposerSettings, error) { + to := &validatorServiceConfig.ProposerSettings{} + err := s.db.View(func(tx *bolt.Tx) error { + bkt := tx.Bucket(proposerSettingsBucket) + b := bkt.Get(proposerSettingsKey) + if len(b) != 0 { + return NoProposerSettingsFound + } + if err := json.Unmarshal(b, to); err != nil { + return errors.Wrap(err, "failed to unmarshal proposer settings") + } + return nil + }) + return to, err } -// SaveProposerSettings -func (s *Store) SaveProposerSettings(ctx context.Context, settings *validator_service_config.ProposerSettingsPayload) error { +// ProposerSettingsExists +func (s *Store) ProposerSettingsExists(ctx context.Context) (bool, error) { + ps, err := s.ProposerSettings(ctx) + if err != nil { + if errors.Is(err, NoProposerSettingsFound) { + return false, nil + } + return false, err + } + if ps == nil { + return false, nil + } + return true, nil +} + +// SaveProposerSettings saves the entire proposer setting overriding the existing settings +func (s *Store) SaveProposerSettings(ctx context.Context, settings *validatorServiceConfig.ProposerSettings) error { return s.db.Update(func(tx *bolt.Tx) error { - bkt := tx.Bucket(genesisInfoBucket) - enc := bkt.Get(genesisValidatorsRootKey) - if len(enc) == 0 { - return nil + bkt := tx.Bucket(proposerSettingsBucket) + m, err := json.Marshal(settings) + if err != nil { + return errors.Wrap(err, "failed to marshal proposer settings") } - return nil + return bkt.Put(proposerSettingsKey, m) }) } diff --git a/validator/node/node.go b/validator/node/node.go index be71dcd4fe96..ac6a4b15ab76 100644 --- a/validator/node/node.go +++ b/validator/node/node.go @@ -50,6 +50,7 @@ import ( "github.com/prysmaticlabs/prysm/v4/runtime/version" "github.com/prysmaticlabs/prysm/v4/validator/accounts/wallet" "github.com/prysmaticlabs/prysm/v4/validator/client" + "github.com/prysmaticlabs/prysm/v4/validator/db/iface" "github.com/prysmaticlabs/prysm/v4/validator/db/kv" g "github.com/prysmaticlabs/prysm/v4/validator/graffiti" "github.com/prysmaticlabs/prysm/v4/validator/keymanager/local" @@ -406,7 +407,7 @@ func (c *ValidatorClient) registerValidatorService(cliCtx *cli.Context) error { return err } - bpc, err := proposerSettings(c.cliCtx) + bpc, err := proposerSettings(c.cliCtx, c.db) if err != nil { return err } @@ -488,7 +489,7 @@ func Web3SignerConfig(cliCtx *cli.Context) (*remoteweb3signer.SetupConfig, error return web3signerConfig, nil } -func proposerSettings(cliCtx *cli.Context) (*validatorServiceConfig.ProposerSettings, error) { +func proposerSettings(cliCtx *cli.Context, db iface.ValidatorDB) (*validatorServiceConfig.ProposerSettings, error) { var fileConfig *validatorServiceConfig.ProposerSettingsPayload if cliCtx.IsSet(flags.ProposerSettingsFlag.Name) && cliCtx.IsSet(flags.ProposerSettingsURLFlag.Name) { @@ -541,7 +542,10 @@ func proposerSettings(cliCtx *cli.Context) (*validatorServiceConfig.ProposerSett if !common.IsHexAddress(fileConfig.DefaultConfig.FeeRecipient) { return nil, errors.New("default fileConfig fee recipient is not a valid eth1 address") } - + psExists, err := db.ProposerSettingsExists(cliCtx.Context) + if err != nil { + return nil, err + } if err := warnNonChecksummedAddress(fileConfig.DefaultConfig.FeeRecipient); err != nil { return nil, err } @@ -563,6 +567,12 @@ func proposerSettings(cliCtx *cli.Context) (*validatorServiceConfig.ProposerSett vpSettings.DefaultConfig.BuilderConfig.GasLimit = reviewGasLimit(vpSettings.DefaultConfig.BuilderConfig.GasLimit) } + if psExists { + if err := db.UpdateProposerSettingsDefault(cliCtx.Context, vpSettings.DefaultConfig); err != nil { + return nil, err + } + } + if fileConfig.ProposerConfig != nil { vpSettings.ProposeConfig = make(map[[fieldparams.BLSPubkeyLength]byte]*validatorServiceConfig.ProposerOption) for key, option := range fileConfig.ProposerConfig { @@ -591,15 +601,26 @@ func proposerSettings(cliCtx *cli.Context) (*validatorServiceConfig.ProposerSett } option.BuilderConfig = builderConfig } - vpSettings.ProposeConfig[bytesutil.ToBytes48(decodedKey)] = &validatorServiceConfig.ProposerOption{ + o := &validatorServiceConfig.ProposerOption{ FeeRecipientConfig: &validatorServiceConfig.FeeRecipientConfig{ FeeRecipient: common.HexToAddress(option.FeeRecipient), }, BuilderConfig: option.BuilderConfig, } + pubkeyB := bytesutil.ToBytes48(decodedKey) + if psExists { + if err := db.UpdateProposerSettingsForPubkey(cliCtx.Context, pubkeyB, o); err != nil { + return nil, err + } + } + vpSettings.ProposeConfig[pubkeyB] = o + } + } + if !psExists { + if err := db.SaveProposerSettings(cliCtx.Context, vpSettings); err != nil { + return nil, err } } - return vpSettings, nil } From 2677b989a6848f2ec270435e8ec9bc2a7623d964 Mon Sep 17 00:00:00 2001 From: james-prysm Date: Tue, 2 May 2023 21:41:53 -0500 Subject: [PATCH 04/33] WIP persistent validator settings --- config/validator/service/proposer-settings.go | 36 ++++++ validator/client/runner.go | 6 - validator/client/service.go | 27 +++- validator/db/iface/BUILD.bazel | 1 + validator/db/kv/BUILD.bazel | 2 + validator/node/BUILD.bazel | 1 + validator/rpc/standard_api.go | 115 +++++++----------- 7 files changed, 110 insertions(+), 78 deletions(-) diff --git a/config/validator/service/proposer-settings.go b/config/validator/service/proposer-settings.go index feff58a75796..c6298258223a 100644 --- a/config/validator/service/proposer-settings.go +++ b/config/validator/service/proposer-settings.go @@ -77,3 +77,39 @@ type ProposerOption struct { FeeRecipientConfig *FeeRecipientConfig BuilderConfig *BuilderConfig } + +// Clone creates a deep copy of the proposer settings +func (ps *ProposerSettings) Clone() *ProposerSettings { + clone := &ProposerSettings{ + ProposeConfig: make(map[[fieldparams.BLSPubkeyLength]byte]*ProposerOption), + DefaultConfig: ps.DefaultConfig.Clone(), + } + for k, v := range ps.ProposeConfig { + keyCopy := k + valCopy := v.Clone() + clone.ProposeConfig[keyCopy] = valCopy + } + return clone +} + +// Clone creates a deep copy of fee recipient config +func (fo *FeeRecipientConfig) Clone() *FeeRecipientConfig { + return &FeeRecipientConfig{fo.FeeRecipient} +} + +// Clone creates a deep copy of builder config +func (bc *BuilderConfig) Clone() *BuilderConfig { + relays := make([]string, len(bc.Relays)) + for i, s := range bc.Relays { + relays[i] = s + } + return &BuilderConfig{bc.Enabled, bc.GasLimit, relays} +} + +// Clone creates a deep copy of proposer option +func (po *ProposerOption) Clone() *ProposerOption { + return &ProposerOption{ + FeeRecipientConfig: po.FeeRecipientConfig.Clone(), + BuilderConfig: po.BuilderConfig.Clone(), + } +} diff --git a/validator/client/runner.go b/validator/client/runner.go index 3dba1f3f7976..2ac0050e842c 100644 --- a/validator/client/runner.go +++ b/validator/client/runner.go @@ -53,12 +53,6 @@ func run(ctx context.Context, v iface.Validator) { log.WithError(err).Fatal("Could not get keymanager") } sub := km.SubscribeAccountChanges(accountsChangedChan) - // checks db if proposer settings exist if none is provided. - if v.ProposerSettings() == nil { - - // check if existing db exists and set proposer settings from that - // attempt to migrate persistent fee recipient data from beacon node - } // check if proposer settings is still nil // Set properties on the beacon node like the fee recipient for validators that are being used & active. if v.ProposerSettings() != nil { diff --git a/validator/client/service.go b/validator/client/service.go index 756cda2be167..dbd5ac1226dd 100644 --- a/validator/client/service.go +++ b/validator/client/service.go @@ -188,10 +188,21 @@ func (v *ValidatorService) Start() { return } + // checks db if proposer settings exist if none is provided. + if v.proposerSettings == nil { + settings, err := v.db.ProposerSettings(v.ctx) + if err == nil { + v.proposerSettings = settings + } + } + + validatorClient := validatorClientFactory.NewValidatorClient(v.conn) + beaconClient := beaconChainClientFactory.NewBeaconChainClient(v.conn) + valStruct := &validator{ db: v.db, - validatorClient: validatorClientFactory.NewValidatorClient(v.conn), - beaconClient: beaconChainClientFactory.NewBeaconChainClient(v.conn), + validatorClient: validatorClient, + beaconClient: beaconClient, slashingProtectionClient: slasherClientFactory.NewSlasherClient(v.conn), node: nodeClientFactory.NewNodeClient(v.conn), graffiti: v.graffiti, @@ -218,6 +229,7 @@ func (v *ValidatorService) Start() { proposerSettings: v.proposerSettings, walletInitializedChannel: make(chan *wallet.Wallet, 1), } + // To resolve a race condition at startup due to the interface // nature of the abstracted block type. We initialize // the inner type of the feed before hand. So that @@ -255,17 +267,24 @@ func (v *ValidatorService) InteropKeysConfig() *local.InteropKeymanagerConfig { return v.interopKeysConfig } +// Keymanager returns the underlying keymanager in the validator func (v *ValidatorService) Keymanager() (keymanager.IKeymanager, error) { return v.validator.Keymanager() } +// ProposerSettings returns a deep copy of the underlying proposer settings in the validator func (v *ValidatorService) ProposerSettings() *validatorserviceconfig.ProposerSettings { - return v.validator.ProposerSettings() + return v.validator.ProposerSettings().Clone() } -func (v *ValidatorService) SetProposerSettings(settings *validatorserviceconfig.ProposerSettings) { +// SetProposerSettings sets the proposer settings on the validator service as well as the underlying validator +func (v *ValidatorService) SetProposerSettings(ctx context.Context, settings *validatorserviceconfig.ProposerSettings) error { + if err := v.db.SaveProposerSettings(ctx, settings); err != nil { + return err + } v.proposerSettings = settings v.validator.SetProposerSettings(settings) + return nil } // ConstructDialOptions constructs a list of grpc dial options diff --git a/validator/db/iface/BUILD.bazel b/validator/db/iface/BUILD.bazel index fe4e2d1cc7f5..710d0db68225 100644 --- a/validator/db/iface/BUILD.bazel +++ b/validator/db/iface/BUILD.bazel @@ -8,6 +8,7 @@ go_library( visibility = ["//validator/db:__subpackages__"], deps = [ "//config/fieldparams:go_default_library", + "//config/validator/service:go_default_library", "//consensus-types/primitives:go_default_library", "//monitoring/backup:go_default_library", "//proto/prysm/v1alpha1:go_default_library", diff --git a/validator/db/kv/BUILD.bazel b/validator/db/kv/BUILD.bazel index 6944dd1ee857..426ed3305276 100644 --- a/validator/db/kv/BUILD.bazel +++ b/validator/db/kv/BUILD.bazel @@ -15,6 +15,7 @@ go_library( "migration_optimal_attester_protection.go", "migration_source_target_epochs_bucket.go", "proposer_protection.go", + "proposer_settings.go", "prune_attester_protection.go", "schema.go", ], @@ -29,6 +30,7 @@ go_library( "//config/features:go_default_library", "//config/fieldparams:go_default_library", "//config/params:go_default_library", + "//config/validator/service:go_default_library", "//consensus-types/primitives:go_default_library", "//encoding/bytesutil:go_default_library", "//io/file:go_default_library", diff --git a/validator/node/BUILD.bazel b/validator/node/BUILD.bazel index 06c7bf5c723e..438621de5125 100644 --- a/validator/node/BUILD.bazel +++ b/validator/node/BUILD.bazel @@ -60,6 +60,7 @@ go_library( "//runtime/version:go_default_library", "//validator/accounts/wallet:go_default_library", "//validator/client:go_default_library", + "//validator/db/iface:go_default_library", "//validator/db/kv:go_default_library", "//validator/graffiti:go_default_library", "//validator/keymanager/local:go_default_library", diff --git a/validator/rpc/standard_api.go b/validator/rpc/standard_api.go index 29473fb34eba..4c1d7641e1bf 100644 --- a/validator/rpc/standard_api.go +++ b/validator/rpc/standard_api.go @@ -403,14 +403,15 @@ func (s *Server) GetGasLimit(_ context.Context, req *ethpbservice.PubkeyRequest) Pubkey: validatorKey, }, } - if s.validatorService.ProposerSettings() != nil { - proposerOption, found := s.validatorService.ProposerSettings().ProposeConfig[bytesutil.ToBytes48(validatorKey)] + settings := s.validatorService.ProposerSettings() + if settings != nil { + proposerOption, found := settings.ProposeConfig[bytesutil.ToBytes48(validatorKey)] if found { if proposerOption.BuilderConfig != nil { resp.Data.GasLimit = uint64(proposerOption.BuilderConfig.GasLimit) return resp, nil } - } else if s.validatorService.ProposerSettings().DefaultConfig != nil && s.validatorService.ProposerSettings().DefaultConfig.BuilderConfig != nil { + } else if settings.DefaultConfig != nil && settings.DefaultConfig.BuilderConfig != nil { resp.Data.GasLimit = uint64(s.validatorService.ProposerSettings().DefaultConfig.BuilderConfig.GasLimit) return resp, nil } @@ -424,63 +425,40 @@ func (s *Server) SetGasLimit(ctx context.Context, req *ethpbservice.SetGasLimitR if s.validatorService == nil { return nil, status.Error(codes.FailedPrecondition, "Validator service not ready") } - validatorKey := req.Pubkey if err := validatePublicKey(validatorKey); err != nil { return nil, status.Error(codes.FailedPrecondition, err.Error()) } - - var pBuilderConfig *validatorServiceConfig.BuilderConfig - - if s.validatorService.ProposerSettings() != nil && - s.validatorService.ProposerSettings().DefaultConfig != nil && - s.validatorService.ProposerSettings().DefaultConfig.BuilderConfig != nil { - // Make a copy of BuilderConfig from DefaultConfig (thus "*" then "&"), so when we change GasLimit, we do not mess up with - // "DefaultConfig.BuilderConfig". - bo := *s.validatorService.ProposerSettings().DefaultConfig.BuilderConfig - pBuilderConfig = &bo - pBuilderConfig.GasLimit = validatorServiceConfig.Uint64(req.GasLimit) - } else { - // No default BuilderConfig to copy from, just create one and set "GasLimit", but keep "Enabled" to "false". - pBuilderConfig = &validatorServiceConfig.BuilderConfig{ - Enabled: false, - GasLimit: validatorServiceConfig.Uint64(req.GasLimit), - Relays: []string{}, + settings := s.validatorService.ProposerSettings() + if settings == nil { + return &empty.Empty{}, status.Errorf(codes.FailedPrecondition, "no proposer settings were found to update") + } else if settings.ProposeConfig == nil { + if settings.DefaultConfig.BuilderConfig == nil || settings.DefaultConfig.BuilderConfig.Enabled == false { + return &empty.Empty{}, status.Errorf(codes.FailedPrecondition, "gas limit changes only apply when builder is enabled") } - } - - pOption := validatorServiceConfig.ProposerOption{ - FeeRecipientConfig: nil, - BuilderConfig: pBuilderConfig, - } - - if s.validatorService.ProposerSettings() == nil { - s.validatorService.SetProposerSettings(&validatorServiceConfig.ProposerSettings{ - ProposeConfig: map[[fieldparams.BLSPubkeyLength]byte]*validatorServiceConfig.ProposerOption{ - bytesutil.ToBytes48(validatorKey): &pOption, - }, - DefaultConfig: nil, - }) - } else if s.validatorService.ProposerSettings().ProposeConfig == nil { - settings := s.validatorService.ProposerSettings() settings.ProposeConfig = make(map[[fieldparams.BLSPubkeyLength]byte]*validatorServiceConfig.ProposerOption) - settings.ProposeConfig[bytesutil.ToBytes48(validatorKey)] = &pOption - s.validatorService.SetProposerSettings(settings) + option := settings.DefaultConfig.Clone() + option.BuilderConfig.GasLimit = validatorServiceConfig.Uint64(req.GasLimit) + settings.ProposeConfig[bytesutil.ToBytes48(validatorKey)] = option } else { - proposerOption, found := s.validatorService.ProposerSettings().ProposeConfig[bytesutil.ToBytes48(validatorKey)] - + proposerOption, found := settings.ProposeConfig[bytesutil.ToBytes48(validatorKey)] if found { - if proposerOption.BuilderConfig == nil { - proposerOption.BuilderConfig = pBuilderConfig + if proposerOption.BuilderConfig == nil || proposerOption.BuilderConfig.Enabled == false { + return &empty.Empty{}, status.Errorf(codes.FailedPrecondition, "gas limit changes only apply when builder is enabled") } else { proposerOption.BuilderConfig.GasLimit = validatorServiceConfig.Uint64(req.GasLimit) } } else { - s.validatorService.ProposerSettings().ProposeConfig[bytesutil.ToBytes48(validatorKey)] = &pOption + option := settings.DefaultConfig.Clone() + option.BuilderConfig.GasLimit = validatorServiceConfig.Uint64(req.GasLimit) + settings.ProposeConfig[bytesutil.ToBytes48(validatorKey)] = option } } - + // save the settings + if err := s.validatorService.SetProposerSettings(ctx, settings); err != nil { + return &empty.Empty{}, status.Errorf(codes.Internal, "Could not set proposer settings: %v", err) + } // override the 200 success with 202 according to the specs if err := grpc.SetHeader(ctx, metadata.Pairs("x-http-code", "202")); err != nil { return &empty.Empty{}, status.Errorf(codes.Internal, "Could not set custom success code header: %v", err) @@ -509,6 +487,10 @@ func (s *Server) DeleteGasLimit(ctx context.Context, req *ethpbservice.DeleteGas // Fallback to using global default. proposerOption.BuilderConfig.GasLimit = validatorServiceConfig.Uint64(params.BeaconConfig().DefaultBuilderGasLimit) } + // save the settings + if err := s.validatorService.SetProposerSettings(ctx, proposerSettings); err != nil { + return &empty.Empty{}, status.Errorf(codes.Internal, "Could not set proposer settings: %v", err) + } // Successfully deleted gas limit (reset to proposer config default or global default). // Return with success http code "204". if err := grpc.SetHeader(ctx, metadata.Pairs("x-http-code", "204")); err != nil { @@ -553,11 +535,11 @@ func (s *Server) ListFeeRecipientByPubkey(ctx context.Context, req *ethpbservice // If fee recipient is defined in default configuration, use it if proposerSettings != nil && proposerSettings.DefaultConfig != nil && proposerSettings.DefaultConfig.FeeRecipientConfig != nil { - finalResp.Data.Ethaddress = s.validatorService.ProposerSettings().DefaultConfig.FeeRecipientConfig.FeeRecipient.Bytes() + finalResp.Data.Ethaddress = proposerSettings.DefaultConfig.FeeRecipientConfig.FeeRecipient.Bytes() return finalResp, nil } - // Else, use the one defined in beacon node + // Else, use the one defined in beacon node TODO: remove this with db removal resp, err := s.beaconNodeValidatorClient.GetFeeRecipientByPubKey(ctx, ð.FeeRecipientByPubKeyRequest{ PublicKey: validatorKey, }) @@ -593,10 +575,10 @@ func (s *Server) SetFeeRecipientByPubkey(ctx context.Context, req *ethpbservice. return nil, status.Error( codes.InvalidArgument, "Fee recipient is not a valid Ethereum address") } - + settings := s.validatorService.ProposerSettings() switch { - case s.validatorService.ProposerSettings() == nil: - s.validatorService.SetProposerSettings(&validatorServiceConfig.ProposerSettings{ + case settings == nil: + settings = &validatorServiceConfig.ProposerSettings{ ProposeConfig: map[[fieldparams.BLSPubkeyLength]byte]*validatorServiceConfig.ProposerOption{ bytesutil.ToBytes48(validatorKey): { FeeRecipientConfig: &validatorServiceConfig.FeeRecipientConfig{ @@ -606,15 +588,12 @@ func (s *Server) SetFeeRecipientByPubkey(ctx context.Context, req *ethpbservice. }, }, DefaultConfig: nil, - }) - case s.validatorService.ProposerSettings().ProposeConfig == nil: - builderConfig := &validatorServiceConfig.BuilderConfig{} - settings := s.validatorService.ProposerSettings() - + } + case settings.ProposeConfig == nil: + var builderConfig *validatorServiceConfig.BuilderConfig if settings.DefaultConfig != nil { - builderConfig = settings.DefaultConfig.BuilderConfig + builderConfig = settings.DefaultConfig.BuilderConfig.Clone() } - settings.ProposeConfig = map[[fieldparams.BLSPubkeyLength]byte]*validatorServiceConfig.ProposerOption{ bytesutil.ToBytes48(validatorKey): { FeeRecipientConfig: &validatorServiceConfig.FeeRecipientConfig{ @@ -623,34 +602,29 @@ func (s *Server) SetFeeRecipientByPubkey(ctx context.Context, req *ethpbservice. BuilderConfig: builderConfig, }, } - - s.validatorService.SetProposerSettings(settings) default: - proposerOption, found := s.validatorService.ProposerSettings().ProposeConfig[bytesutil.ToBytes48(validatorKey)] - + proposerOption, found := settings.ProposeConfig[bytesutil.ToBytes48(validatorKey)] if found && proposerOption != nil { proposerOption.FeeRecipientConfig = &validatorServiceConfig.FeeRecipientConfig{ FeeRecipient: feeRecipient, } } else { - settings := s.validatorService.ProposerSettings() - var builderConfig = &validatorServiceConfig.BuilderConfig{} - if settings.DefaultConfig != nil { - builderConfig = settings.DefaultConfig.BuilderConfig + builderConfig = settings.DefaultConfig.BuilderConfig.Clone() } - settings.ProposeConfig[bytesutil.ToBytes48(validatorKey)] = &validatorServiceConfig.ProposerOption{ FeeRecipientConfig: &validatorServiceConfig.FeeRecipientConfig{ FeeRecipient: feeRecipient, }, BuilderConfig: builderConfig, } - - s.validatorService.SetProposerSettings(settings) } } + // save the settings + if err := s.validatorService.SetProposerSettings(ctx, settings); err != nil { + return &empty.Empty{}, status.Errorf(codes.Internal, "Could not set proposer settings: %v", err) + } // override the 200 success with 202 according to the specs if err := grpc.SetHeader(ctx, metadata.Pairs("x-http-code", "202")); err != nil { return &empty.Empty{}, status.Errorf(codes.Internal, "Could not set custom success code header: %v", err) @@ -679,6 +653,11 @@ func (s *Server) DeleteFeeRecipientByPubkey(ctx context.Context, req *ethpbservi } } + // save the settings + if err := s.validatorService.SetProposerSettings(ctx, settings); err != nil { + return &empty.Empty{}, status.Errorf(codes.Internal, "Could not set proposer settings: %v", err) + } + // override the 200 success with 204 according to the specs if err := grpc.SetHeader(ctx, metadata.Pairs("x-http-code", "204")); err != nil { return &empty.Empty{}, status.Errorf(codes.Internal, "Could not set custom success code header: %v", err) From 05ceecc734f5f5166d5a467d2392343f5660f2cd Mon Sep 17 00:00:00 2001 From: james-prysm Date: Tue, 2 May 2023 21:48:24 -0500 Subject: [PATCH 05/33] changing visibility level --- validator/db/iface/BUILD.bazel | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/validator/db/iface/BUILD.bazel b/validator/db/iface/BUILD.bazel index 710d0db68225..ccde0b704498 100644 --- a/validator/db/iface/BUILD.bazel +++ b/validator/db/iface/BUILD.bazel @@ -5,7 +5,7 @@ go_library( srcs = ["interface.go"], importpath = "github.com/prysmaticlabs/prysm/v4/validator/db/iface", # Other packages must use github.com/prysmaticlabs/prysm/v4/validator/db.Database alias. - visibility = ["//validator/db:__subpackages__"], + visibility = ["//validator:__subpackages__"], deps = [ "//config/fieldparams:go_default_library", "//config/validator/service:go_default_library", From 02b08560e5f98e4f26bd2068cd51e78235ab94c2 Mon Sep 17 00:00:00 2001 From: james-prysm Date: Tue, 2 May 2023 22:04:40 -0500 Subject: [PATCH 06/33] fixing some deepsource issues --- config/validator/service/proposer-settings.go | 14 ++++++-------- validator/rpc/standard_api.go | 4 ++-- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/config/validator/service/proposer-settings.go b/config/validator/service/proposer-settings.go index c6298258223a..e3ffe25aafbd 100644 --- a/config/validator/service/proposer-settings.go +++ b/config/validator/service/proposer-settings.go @@ -64,18 +64,18 @@ func (u *Uint64) UnmarshalYAML(unmarshal func(interface{}) error) error { // ProposerSettings is a Prysm internal representation of the fee recipient config on the validator client. // ProposerSettingsPayload maps to ProposerSettings on import through the CLI. type ProposerSettings struct { - ProposeConfig map[[fieldparams.BLSPubkeyLength]byte]*ProposerOption - DefaultConfig *ProposerOption + ProposeConfig map[[fieldparams.BLSPubkeyLength]byte]*ProposerOption `json:"proposer_config"` + DefaultConfig *ProposerOption `json:"default_config"` } type FeeRecipientConfig struct { - FeeRecipient common.Address + FeeRecipient common.Address `json:"fee_recipient"` } // ProposerOption is a Prysm internal representation of the ProposerOptionPayload on the validator client in bytes format instead of hex. type ProposerOption struct { - FeeRecipientConfig *FeeRecipientConfig - BuilderConfig *BuilderConfig + FeeRecipientConfig *FeeRecipientConfig `json:"fee_recipient_config"` + BuilderConfig *BuilderConfig `json:"builder_config"` } // Clone creates a deep copy of the proposer settings @@ -100,9 +100,7 @@ func (fo *FeeRecipientConfig) Clone() *FeeRecipientConfig { // Clone creates a deep copy of builder config func (bc *BuilderConfig) Clone() *BuilderConfig { relays := make([]string, len(bc.Relays)) - for i, s := range bc.Relays { - relays[i] = s - } + copy(relays, bc.Relays) return &BuilderConfig{bc.Enabled, bc.GasLimit, relays} } diff --git a/validator/rpc/standard_api.go b/validator/rpc/standard_api.go index 4c1d7641e1bf..6f0dcb8fb4cf 100644 --- a/validator/rpc/standard_api.go +++ b/validator/rpc/standard_api.go @@ -434,7 +434,7 @@ func (s *Server) SetGasLimit(ctx context.Context, req *ethpbservice.SetGasLimitR if settings == nil { return &empty.Empty{}, status.Errorf(codes.FailedPrecondition, "no proposer settings were found to update") } else if settings.ProposeConfig == nil { - if settings.DefaultConfig.BuilderConfig == nil || settings.DefaultConfig.BuilderConfig.Enabled == false { + if settings.DefaultConfig.BuilderConfig == nil || !settings.DefaultConfig.BuilderConfig.Enabled { return &empty.Empty{}, status.Errorf(codes.FailedPrecondition, "gas limit changes only apply when builder is enabled") } settings.ProposeConfig = make(map[[fieldparams.BLSPubkeyLength]byte]*validatorServiceConfig.ProposerOption) @@ -444,7 +444,7 @@ func (s *Server) SetGasLimit(ctx context.Context, req *ethpbservice.SetGasLimitR } else { proposerOption, found := settings.ProposeConfig[bytesutil.ToBytes48(validatorKey)] if found { - if proposerOption.BuilderConfig == nil || proposerOption.BuilderConfig.Enabled == false { + if proposerOption.BuilderConfig == nil || !proposerOption.BuilderConfig.Enabled { return &empty.Empty{}, status.Errorf(codes.FailedPrecondition, "gas limit changes only apply when builder is enabled") } else { proposerOption.BuilderConfig.GasLimit = validatorServiceConfig.Uint64(req.GasLimit) From 9be0bf6e4b263a9dc96e9c65e978c71772e9ebc9 Mon Sep 17 00:00:00 2001 From: james-prysm Date: Tue, 2 May 2023 22:28:48 -0500 Subject: [PATCH 07/33] fixing more deepsource issues --- config/validator/service/proposer-settings.go | 4 ++++ validator/db/kv/proposer_settings.go | 15 ++++++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/config/validator/service/proposer-settings.go b/config/validator/service/proposer-settings.go index e3ffe25aafbd..2180f383250b 100644 --- a/config/validator/service/proposer-settings.go +++ b/config/validator/service/proposer-settings.go @@ -30,8 +30,10 @@ type BuilderConfig struct { Relays []string `json:"relays" yaml:"relays"` } +// Uint64 custom uint64 to be unmarshallable type Uint64 uint64 +// UnmarshalJSON custom unmarshal function for json func (u *Uint64) UnmarshalJSON(bs []byte) error { str := string(bs) // Parse plain numbers directly. if bs[0] == '"' && bs[len(bs)-1] == '"' { @@ -46,6 +48,7 @@ func (u *Uint64) UnmarshalJSON(bs []byte) error { return nil } +// UnmarshalYAML custom unmarshal function for yaml func (u *Uint64) UnmarshalYAML(unmarshal func(interface{}) error) error { var str string err := unmarshal(&str) @@ -68,6 +71,7 @@ type ProposerSettings struct { DefaultConfig *ProposerOption `json:"default_config"` } +// FeeRecipientConfig is a prysm internal representation to see if the fee recipient was set. type FeeRecipientConfig struct { FeeRecipient common.Address `json:"fee_recipient"` } diff --git a/validator/db/kv/proposer_settings.go b/validator/db/kv/proposer_settings.go index 9892f89bc17d..8c73989573f8 100644 --- a/validator/db/kv/proposer_settings.go +++ b/validator/db/kv/proposer_settings.go @@ -9,12 +9,15 @@ import ( fieldparams "github.com/prysmaticlabs/prysm/v4/config/fieldparams" validatorServiceConfig "github.com/prysmaticlabs/prysm/v4/config/validator/service" bolt "go.etcd.io/bbolt" + "go.opencensus.io/trace" ) var NoProposerSettingsFound = errors.New("no proposer settings found in bucket") // UpdateProposerSettingsForPubkey updates the existing settings for an internal representation of the proposers settings file at a particular public key -func (s *Store) UpdateProposerSettingsForPubkey(_ context.Context, pubkey [fieldparams.BLSPubkeyLength]byte, options *validatorServiceConfig.ProposerOption) error { +func (s *Store) UpdateProposerSettingsForPubkey(ctx context.Context, pubkey [fieldparams.BLSPubkeyLength]byte, options *validatorServiceConfig.ProposerOption) error { + _, span := trace.StartSpan(ctx, "validator.db.UpdateProposerSettingsDefault") + defer span.End() err := s.db.Update(func(tx *bolt.Tx) error { bkt := tx.Bucket(proposerSettingsBucket) b := bkt.Get(proposerSettingsKey) @@ -39,7 +42,9 @@ func (s *Store) UpdateProposerSettingsForPubkey(_ context.Context, pubkey [field } // UpdateProposerSettingsDefault updates the existing default settings for proposer settings -func (s *Store) UpdateProposerSettingsDefault(_ context.Context, options *validatorServiceConfig.ProposerOption) error { +func (s *Store) UpdateProposerSettingsDefault(ctx context.Context, options *validatorServiceConfig.ProposerOption) error { + _, span := trace.StartSpan(ctx, "validator.db.UpdateProposerSettingsDefault") + defer span.End() if options == nil { return errors.New("proposer settings option was empty") } @@ -68,6 +73,8 @@ func (s *Store) UpdateProposerSettingsDefault(_ context.Context, options *valida // ProposerSettings gets the current proposer settings func (s *Store) ProposerSettings(ctx context.Context) (*validatorServiceConfig.ProposerSettings, error) { + _, span := trace.StartSpan(ctx, "validator.db.ProposerSettings") + defer span.End() to := &validatorServiceConfig.ProposerSettings{} err := s.db.View(func(tx *bolt.Tx) error { bkt := tx.Bucket(proposerSettingsBucket) @@ -83,7 +90,7 @@ func (s *Store) ProposerSettings(ctx context.Context) (*validatorServiceConfig.P return to, err } -// ProposerSettingsExists +// ProposerSettingsExists returns true or false if the settings exist or not func (s *Store) ProposerSettingsExists(ctx context.Context) (bool, error) { ps, err := s.ProposerSettings(ctx) if err != nil { @@ -100,6 +107,8 @@ func (s *Store) ProposerSettingsExists(ctx context.Context) (bool, error) { // SaveProposerSettings saves the entire proposer setting overriding the existing settings func (s *Store) SaveProposerSettings(ctx context.Context, settings *validatorServiceConfig.ProposerSettings) error { + _, span := trace.StartSpan(ctx, "validator.db.SaveProposerSettings") + defer span.End() return s.db.Update(func(tx *bolt.Tx) error { bkt := tx.Bucket(proposerSettingsBucket) m, err := json.Marshal(settings) From 8327663be9f511579c8c54f4110715523ee97a0d Mon Sep 17 00:00:00 2001 From: james-prysm Date: Wed, 3 May 2023 10:33:19 -0500 Subject: [PATCH 08/33] fixing json marshalling --- config/validator/service/proposer-settings.go | 63 +++++++++++++++++-- validator/db/kv/proposer_settings.go | 36 +++++++---- 2 files changed, 81 insertions(+), 18 deletions(-) diff --git a/config/validator/service/proposer-settings.go b/config/validator/service/proposer-settings.go index 2180f383250b..0d3786bb2fd5 100644 --- a/config/validator/service/proposer-settings.go +++ b/config/validator/service/proposer-settings.go @@ -4,7 +4,10 @@ import ( "strconv" "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/common/hexutil" + "github.com/pkg/errors" fieldparams "github.com/prysmaticlabs/prysm/v4/config/fieldparams" + "github.com/prysmaticlabs/prysm/v4/encoding/bytesutil" ) // ProposerSettingsPayload is the struct representation of the JSON or YAML payload set in the validator through the CLI. @@ -15,6 +18,36 @@ type ProposerSettingsPayload struct { DefaultConfig *ProposerOptionPayload `json:"default_config" yaml:"default_config"` } +// ToSettings converts struct to ProposerSettings +func (ps *ProposerSettingsPayload) ToSettings() (*ProposerSettings, error) { + if ps.DefaultConfig == nil || ps.DefaultConfig.FeeRecipient == "" { + return nil, errors.New("payload default config is missing or default fee recipient is missing") + } + settings := &ProposerSettings{} + if ps.ProposerConfig != nil { + settings.ProposeConfig = make(map[[fieldparams.BLSPubkeyLength]byte]*ProposerOption) + for key, optionPayload := range ps.ProposerConfig { + b, err := hexutil.Decode(key) + if err != nil { + return nil, err + } + settings.ProposeConfig[bytesutil.ToBytes48(b)] = &ProposerOption{ + FeeRecipientConfig: &FeeRecipientConfig{ + FeeRecipient: common.HexToAddress(optionPayload.FeeRecipient), + }, + BuilderConfig: optionPayload.BuilderConfig.Clone(), + } + } + } + settings.DefaultConfig = &ProposerOption{ + FeeRecipientConfig: &FeeRecipientConfig{ + FeeRecipient: common.HexToAddress(ps.DefaultConfig.FeeRecipient), + }, + BuilderConfig: ps.DefaultConfig.BuilderConfig.Clone(), + } + return settings, nil +} + // ProposerOptionPayload is the struct representation of the JSON config file set in the validator through the CLI. // FeeRecipient is set to an eth address in hex string format with 0x prefix. type ProposerOptionPayload struct { @@ -67,19 +100,39 @@ func (u *Uint64) UnmarshalYAML(unmarshal func(interface{}) error) error { // ProposerSettings is a Prysm internal representation of the fee recipient config on the validator client. // ProposerSettingsPayload maps to ProposerSettings on import through the CLI. type ProposerSettings struct { - ProposeConfig map[[fieldparams.BLSPubkeyLength]byte]*ProposerOption `json:"proposer_config"` - DefaultConfig *ProposerOption `json:"default_config"` + ProposeConfig map[[fieldparams.BLSPubkeyLength]byte]*ProposerOption + DefaultConfig *ProposerOption +} + +// ToPayload converts struct to ProposerSettingsPayload +func (ps *ProposerSettings) ToPayload() *ProposerSettingsPayload { + payload := &ProposerSettingsPayload{ + ProposerConfig: make(map[string]*ProposerOptionPayload), + } + for key, option := range ps.ProposeConfig { + payload.ProposerConfig[hexutil.Encode(key[:])] = &ProposerOptionPayload{ + FeeRecipient: option.FeeRecipientConfig.FeeRecipient.Hex(), + BuilderConfig: option.BuilderConfig.Clone(), + } + } + if ps.DefaultConfig != nil { + payload.DefaultConfig = &ProposerOptionPayload{ + FeeRecipient: ps.DefaultConfig.FeeRecipientConfig.FeeRecipient.Hex(), + BuilderConfig: ps.DefaultConfig.BuilderConfig.Clone(), + } + } + return payload } // FeeRecipientConfig is a prysm internal representation to see if the fee recipient was set. type FeeRecipientConfig struct { - FeeRecipient common.Address `json:"fee_recipient"` + FeeRecipient common.Address } // ProposerOption is a Prysm internal representation of the ProposerOptionPayload on the validator client in bytes format instead of hex. type ProposerOption struct { - FeeRecipientConfig *FeeRecipientConfig `json:"fee_recipient_config"` - BuilderConfig *BuilderConfig `json:"builder_config"` + FeeRecipientConfig *FeeRecipientConfig + BuilderConfig *BuilderConfig } // Clone creates a deep copy of the proposer settings diff --git a/validator/db/kv/proposer_settings.go b/validator/db/kv/proposer_settings.go index 8c73989573f8..92cf22fe422d 100644 --- a/validator/db/kv/proposer_settings.go +++ b/validator/db/kv/proposer_settings.go @@ -24,15 +24,19 @@ func (s *Store) UpdateProposerSettingsForPubkey(ctx context.Context, pubkey [fie if len(b) != 0 { return fmt.Errorf("no proposer settings found in bucket") } - to := &validatorServiceConfig.ProposerSettings{} + to := &validatorServiceConfig.ProposerSettingsPayload{} if err := json.Unmarshal(b, to); err != nil { return errors.Wrap(err, "failed to unmarshal proposer settings") } - if to.ProposeConfig == nil { - to.ProposeConfig = make(map[[fieldparams.BLSPubkeyLength]byte]*validatorServiceConfig.ProposerOption) + settings, err := to.ToSettings() + if err != nil { + return errors.Wrap(err, "failed to convert payload to proposer settings") + } + if settings.ProposeConfig == nil { + settings.ProposeConfig = make(map[[fieldparams.BLSPubkeyLength]byte]*validatorServiceConfig.ProposerOption) } - to.ProposeConfig[pubkey] = options - m, err := json.Marshal(to) + settings.ProposeConfig[pubkey] = options + m, err := json.Marshal(settings.ToPayload()) if err != nil { return errors.Wrap(err, "failed to marshal proposer settings") } @@ -57,12 +61,16 @@ func (s *Store) UpdateProposerSettingsDefault(ctx context.Context, options *vali if len(b) != 0 { return NoProposerSettingsFound } - to := &validatorServiceConfig.ProposerSettings{} + to := &validatorServiceConfig.ProposerSettingsPayload{} if err := json.Unmarshal(b, to); err != nil { return errors.Wrap(err, "failed to unmarshal proposer settings") } - to.DefaultConfig = options - m, err := json.Marshal(to) + settings, err := to.ToSettings() + if err != nil { + return errors.Wrap(err, "failed to convert payload to proposer settings") + } + settings.DefaultConfig = options + m, err := json.Marshal(settings.ToPayload()) if err != nil { return errors.Wrap(err, "failed to marshal proposer settings") } @@ -75,8 +83,8 @@ func (s *Store) UpdateProposerSettingsDefault(ctx context.Context, options *vali func (s *Store) ProposerSettings(ctx context.Context) (*validatorServiceConfig.ProposerSettings, error) { _, span := trace.StartSpan(ctx, "validator.db.ProposerSettings") defer span.End() - to := &validatorServiceConfig.ProposerSettings{} - err := s.db.View(func(tx *bolt.Tx) error { + to := &validatorServiceConfig.ProposerSettingsPayload{} + if err := s.db.View(func(tx *bolt.Tx) error { bkt := tx.Bucket(proposerSettingsBucket) b := bkt.Get(proposerSettingsKey) if len(b) != 0 { @@ -86,8 +94,10 @@ func (s *Store) ProposerSettings(ctx context.Context) (*validatorServiceConfig.P return errors.Wrap(err, "failed to unmarshal proposer settings") } return nil - }) - return to, err + }); err != nil { + return nil, err + } + return to.ToSettings() } // ProposerSettingsExists returns true or false if the settings exist or not @@ -111,7 +121,7 @@ func (s *Store) SaveProposerSettings(ctx context.Context, settings *validatorSer defer span.End() return s.db.Update(func(tx *bolt.Tx) error { bkt := tx.Bucket(proposerSettingsBucket) - m, err := json.Marshal(settings) + m, err := json.Marshal(settings.ToPayload()) if err != nil { return errors.Wrap(err, "failed to marshal proposer settings") } From 3614ea8868c4ec594f66360821a66ab17b0ad146 Mon Sep 17 00:00:00 2001 From: james-prysm Date: Wed, 3 May 2023 10:55:49 -0500 Subject: [PATCH 09/33] fix linting --- config/validator/service/BUILD.bazel | 3 +++ 1 file changed, 3 insertions(+) diff --git a/config/validator/service/BUILD.bazel b/config/validator/service/BUILD.bazel index 1422a7cb3a43..570cb6f843ac 100644 --- a/config/validator/service/BUILD.bazel +++ b/config/validator/service/BUILD.bazel @@ -7,6 +7,9 @@ go_library( visibility = ["//visibility:public"], deps = [ "//config/fieldparams:go_default_library", + "//encoding/bytesutil:go_default_library", "@com_github_ethereum_go_ethereum//common:go_default_library", + "@com_github_ethereum_go_ethereum//common/hexutil:go_default_library", + "@com_github_pkg_errors//:go_default_library", ], ) From 915defbc27a27cdf72b492901a9641da652f6c90 Mon Sep 17 00:00:00 2001 From: james-prysm Date: Wed, 3 May 2023 13:20:59 -0500 Subject: [PATCH 10/33] fixing tests --- config/validator/service/proposer-settings.go | 32 +++++++++++++------ validator/db/kv/proposer_settings.go | 4 +-- validator/node/BUILD.bazel | 1 + validator/node/node_test.go | 7 ++-- 4 files changed, 30 insertions(+), 14 deletions(-) diff --git a/config/validator/service/proposer-settings.go b/config/validator/service/proposer-settings.go index 0d3786bb2fd5..185ad1e23f8f 100644 --- a/config/validator/service/proposer-settings.go +++ b/config/validator/service/proposer-settings.go @@ -31,20 +31,26 @@ func (ps *ProposerSettingsPayload) ToSettings() (*ProposerSettings, error) { if err != nil { return nil, err } - settings.ProposeConfig[bytesutil.ToBytes48(b)] = &ProposerOption{ + p := &ProposerOption{ FeeRecipientConfig: &FeeRecipientConfig{ FeeRecipient: common.HexToAddress(optionPayload.FeeRecipient), }, - BuilderConfig: optionPayload.BuilderConfig.Clone(), } + if optionPayload.BuilderConfig != nil { + p.BuilderConfig = optionPayload.BuilderConfig.Clone() + } + settings.ProposeConfig[bytesutil.ToBytes48(b)] = p } } - settings.DefaultConfig = &ProposerOption{ + d := &ProposerOption{ FeeRecipientConfig: &FeeRecipientConfig{ FeeRecipient: common.HexToAddress(ps.DefaultConfig.FeeRecipient), }, - BuilderConfig: ps.DefaultConfig.BuilderConfig.Clone(), } + if ps.DefaultConfig.BuilderConfig != nil { + d.BuilderConfig = ps.DefaultConfig.BuilderConfig.Clone() + } + settings.DefaultConfig = d return settings, nil } @@ -110,16 +116,22 @@ func (ps *ProposerSettings) ToPayload() *ProposerSettingsPayload { ProposerConfig: make(map[string]*ProposerOptionPayload), } for key, option := range ps.ProposeConfig { - payload.ProposerConfig[hexutil.Encode(key[:])] = &ProposerOptionPayload{ - FeeRecipient: option.FeeRecipientConfig.FeeRecipient.Hex(), - BuilderConfig: option.BuilderConfig.Clone(), + p := &ProposerOptionPayload{ + FeeRecipient: option.FeeRecipientConfig.FeeRecipient.Hex(), } + if option.BuilderConfig != nil { + p.BuilderConfig = option.BuilderConfig.Clone() + } + payload.ProposerConfig[hexutil.Encode(key[:])] = p } if ps.DefaultConfig != nil { - payload.DefaultConfig = &ProposerOptionPayload{ - FeeRecipient: ps.DefaultConfig.FeeRecipientConfig.FeeRecipient.Hex(), - BuilderConfig: ps.DefaultConfig.BuilderConfig.Clone(), + p := &ProposerOptionPayload{ + FeeRecipient: ps.DefaultConfig.FeeRecipientConfig.FeeRecipient.Hex(), + } + if ps.DefaultConfig.BuilderConfig != nil { + p.BuilderConfig = ps.DefaultConfig.BuilderConfig.Clone() } + payload.DefaultConfig = p } return payload } diff --git a/validator/db/kv/proposer_settings.go b/validator/db/kv/proposer_settings.go index 92cf22fe422d..9d7394568036 100644 --- a/validator/db/kv/proposer_settings.go +++ b/validator/db/kv/proposer_settings.go @@ -58,7 +58,7 @@ func (s *Store) UpdateProposerSettingsDefault(ctx context.Context, options *vali err := s.db.Update(func(tx *bolt.Tx) error { bkt := tx.Bucket(proposerSettingsBucket) b := bkt.Get(proposerSettingsKey) - if len(b) != 0 { + if len(b) == 0 { return NoProposerSettingsFound } to := &validatorServiceConfig.ProposerSettingsPayload{} @@ -87,7 +87,7 @@ func (s *Store) ProposerSettings(ctx context.Context) (*validatorServiceConfig.P if err := s.db.View(func(tx *bolt.Tx) error { bkt := tx.Bucket(proposerSettingsBucket) b := bkt.Get(proposerSettingsKey) - if len(b) != 0 { + if len(b) == 0 { return NoProposerSettingsFound } if err := json.Unmarshal(b, to); err != nil { diff --git a/validator/node/BUILD.bazel b/validator/node/BUILD.bazel index 438621de5125..b9ad63e264e6 100644 --- a/validator/node/BUILD.bazel +++ b/validator/node/BUILD.bazel @@ -15,6 +15,7 @@ go_test( "//testing/assert:go_default_library", "//testing/require:go_default_library", "//validator/accounts:go_default_library", + "//validator/db/testing:go_default_library", "//validator/keymanager:go_default_library", "//validator/keymanager/remote-web3signer:go_default_library", "@com_github_ethereum_go_ethereum//common:go_default_library", diff --git a/validator/node/node_test.go b/validator/node/node_test.go index 966546eee09b..c03b365a64f4 100644 --- a/validator/node/node_test.go +++ b/validator/node/node_test.go @@ -20,6 +20,7 @@ import ( "github.com/prysmaticlabs/prysm/v4/testing/assert" "github.com/prysmaticlabs/prysm/v4/testing/require" "github.com/prysmaticlabs/prysm/v4/validator/accounts" + dbTest "github.com/prysmaticlabs/prysm/v4/validator/db/testing" "github.com/prysmaticlabs/prysm/v4/validator/keymanager" remoteweb3signer "github.com/prysmaticlabs/prysm/v4/validator/keymanager/remote-web3signer" logtest "github.com/sirupsen/logrus/hooks/test" @@ -677,7 +678,8 @@ func TestProposerSettings(t *testing.T) { set.Bool(flags.EnableBuilderFlag.Name, true, "") } cliCtx := cli.NewContext(&app, set, nil) - got, err := proposerSettings(cliCtx) + validatorDB := dbTest.SetupDB(t, [][fieldparams.BLSPubkeyLength]byte{}) + got, err := proposerSettings(cliCtx, validatorDB) if tt.wantErr != "" { require.ErrorContains(t, tt.wantErr, err) return @@ -695,10 +697,11 @@ func TestProposerSettings(t *testing.T) { // return an error if the user is using builder settings without any default fee recipient func TestProposerSettings_EnableBuilder_noFeeRecipient(t *testing.T) { + validatorDB := dbTest.SetupDB(t, [][fieldparams.BLSPubkeyLength]byte{}) app := cli.App{} set := flag.NewFlagSet("test", 0) set.Bool(flags.EnableBuilderFlag.Name, true, "") cliCtx := cli.NewContext(&app, set, nil) - _, err := proposerSettings(cliCtx) + _, err := proposerSettings(cliCtx, validatorDB) require.ErrorContains(t, "can only be used when a default fee recipient is present on the validator client", err) } From 7594faa1e705b2b2e9f66629c809f51fa9819aef Mon Sep 17 00:00:00 2001 From: james-prysm Date: Wed, 3 May 2023 13:46:26 -0500 Subject: [PATCH 11/33] fixing more tests --- config/validator/service/proposer-settings.go | 7 +++++-- validator/db/kv/proposer_settings_test.go | 10 ++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 validator/db/kv/proposer_settings_test.go diff --git a/config/validator/service/proposer-settings.go b/config/validator/service/proposer-settings.go index 185ad1e23f8f..1c560fd043f8 100644 --- a/config/validator/service/proposer-settings.go +++ b/config/validator/service/proposer-settings.go @@ -175,8 +175,11 @@ func (bc *BuilderConfig) Clone() *BuilderConfig { // Clone creates a deep copy of proposer option func (po *ProposerOption) Clone() *ProposerOption { - return &ProposerOption{ + p := &ProposerOption{ FeeRecipientConfig: po.FeeRecipientConfig.Clone(), - BuilderConfig: po.BuilderConfig.Clone(), } + if po.BuilderConfig != nil { + p.BuilderConfig = po.BuilderConfig.Clone() + } + return p } diff --git a/validator/db/kv/proposer_settings_test.go b/validator/db/kv/proposer_settings_test.go new file mode 100644 index 000000000000..b70b315e6b59 --- /dev/null +++ b/validator/db/kv/proposer_settings_test.go @@ -0,0 +1,10 @@ +package kv + +import ( + "testing" +) + +func TestStore_ProposerSettings_ReadAndWrite(t *testing.T) { + //ctx := context.Background() + //db := setupDB(t, [][fieldparams.BLSPubkeyLength]byte{}) +} From 60b5724b79b3ce8581f66a8a7928c35c9d69a5eb Mon Sep 17 00:00:00 2001 From: james-prysm Date: Wed, 3 May 2023 15:16:02 -0500 Subject: [PATCH 12/33] fixing more tests --- config/validator/service/proposer-settings.go | 26 +++++++++---------- validator/client/service.go | 9 ++++++- validator/rpc/standard_api_test.go | 5 ++++ 3 files changed, 26 insertions(+), 14 deletions(-) diff --git a/config/validator/service/proposer-settings.go b/config/validator/service/proposer-settings.go index 1c560fd043f8..0c3b715d9347 100644 --- a/config/validator/service/proposer-settings.go +++ b/config/validator/service/proposer-settings.go @@ -5,7 +5,6 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" - "github.com/pkg/errors" fieldparams "github.com/prysmaticlabs/prysm/v4/config/fieldparams" "github.com/prysmaticlabs/prysm/v4/encoding/bytesutil" ) @@ -20,9 +19,6 @@ type ProposerSettingsPayload struct { // ToSettings converts struct to ProposerSettings func (ps *ProposerSettingsPayload) ToSettings() (*ProposerSettings, error) { - if ps.DefaultConfig == nil || ps.DefaultConfig.FeeRecipient == "" { - return nil, errors.New("payload default config is missing or default fee recipient is missing") - } settings := &ProposerSettings{} if ps.ProposerConfig != nil { settings.ProposeConfig = make(map[[fieldparams.BLSPubkeyLength]byte]*ProposerOption) @@ -42,15 +38,17 @@ func (ps *ProposerSettingsPayload) ToSettings() (*ProposerSettings, error) { settings.ProposeConfig[bytesutil.ToBytes48(b)] = p } } - d := &ProposerOption{ - FeeRecipientConfig: &FeeRecipientConfig{ - FeeRecipient: common.HexToAddress(ps.DefaultConfig.FeeRecipient), - }, - } - if ps.DefaultConfig.BuilderConfig != nil { - d.BuilderConfig = ps.DefaultConfig.BuilderConfig.Clone() + if ps.DefaultConfig != nil { + d := &ProposerOption{ + FeeRecipientConfig: &FeeRecipientConfig{ + FeeRecipient: common.HexToAddress(ps.DefaultConfig.FeeRecipient), + }, + } + if ps.DefaultConfig.BuilderConfig != nil { + d.BuilderConfig = ps.DefaultConfig.BuilderConfig.Clone() + } + settings.DefaultConfig = d } - settings.DefaultConfig = d return settings, nil } @@ -151,7 +149,9 @@ type ProposerOption struct { func (ps *ProposerSettings) Clone() *ProposerSettings { clone := &ProposerSettings{ ProposeConfig: make(map[[fieldparams.BLSPubkeyLength]byte]*ProposerOption), - DefaultConfig: ps.DefaultConfig.Clone(), + } + if ps.DefaultConfig != nil { + clone.DefaultConfig = ps.DefaultConfig.Clone() } for k, v := range ps.ProposeConfig { keyCopy := k diff --git a/validator/client/service.go b/validator/client/service.go index dbd5ac1226dd..bdb0570653fa 100644 --- a/validator/client/service.go +++ b/validator/client/service.go @@ -274,11 +274,18 @@ func (v *ValidatorService) Keymanager() (keymanager.IKeymanager, error) { // ProposerSettings returns a deep copy of the underlying proposer settings in the validator func (v *ValidatorService) ProposerSettings() *validatorserviceconfig.ProposerSettings { - return v.validator.ProposerSettings().Clone() + settings := v.validator.ProposerSettings() + if settings != nil { + return settings.Clone() + } + return nil } // SetProposerSettings sets the proposer settings on the validator service as well as the underlying validator func (v *ValidatorService) SetProposerSettings(ctx context.Context, settings *validatorserviceconfig.ProposerSettings) error { + if v.db == nil { + return errors.New("db is not set") + } if err := v.db.SaveProposerSettings(ctx, settings); err != nil { return err } diff --git a/validator/rpc/standard_api_test.go b/validator/rpc/standard_api_test.go index af866f544069..5a154df41107 100644 --- a/validator/rpc/standard_api_test.go +++ b/validator/rpc/standard_api_test.go @@ -998,15 +998,20 @@ func TestServer_FeeRecipientByPubkey(t *testing.T) { t.Run(tt.name, func(t *testing.T) { m := &mock.MockValidator{} m.SetProposerSettings(tt.proposerSettings) + validatorDB, err := kv.NewKVStore(ctx, defaultWalletPath, &kv.Config{}) + require.NoError(t, err) + // save a default here vs, err := client.NewValidatorService(ctx, &client.Config{ Validator: m, + ValDB: validatorDB, }) require.NoError(t, err) s := &Server{ validatorService: vs, beaconNodeValidatorClient: beaconClient, + valDB: validatorDB, } _, err = s.SetFeeRecipientByPubkey(ctx, ðpbservice.SetFeeRecipientByPubkeyRequest{Pubkey: byteval, Ethaddress: common.HexToAddress(tt.args).Bytes()}) From b068077739378aed20dc1bc7c5db58121a202cd1 Mon Sep 17 00:00:00 2001 From: james-prysm Date: Wed, 3 May 2023 17:36:17 -0500 Subject: [PATCH 13/33] fixing more tests --- config/validator/service/proposer-settings.go | 54 +++++++++++++------ validator/client/runner.go | 2 +- validator/rpc/standard_api_test.go | 9 ++-- 3 files changed, 46 insertions(+), 19 deletions(-) diff --git a/config/validator/service/proposer-settings.go b/config/validator/service/proposer-settings.go index 0c3b715d9347..cdcb04eb92cd 100644 --- a/config/validator/service/proposer-settings.go +++ b/config/validator/service/proposer-settings.go @@ -23,6 +23,9 @@ func (ps *ProposerSettingsPayload) ToSettings() (*ProposerSettings, error) { if ps.ProposerConfig != nil { settings.ProposeConfig = make(map[[fieldparams.BLSPubkeyLength]byte]*ProposerOption) for key, optionPayload := range ps.ProposerConfig { + if optionPayload.FeeRecipient == "" { + continue + } b, err := hexutil.Decode(key) if err != nil { return nil, err @@ -39,10 +42,11 @@ func (ps *ProposerSettingsPayload) ToSettings() (*ProposerSettings, error) { } } if ps.DefaultConfig != nil { - d := &ProposerOption{ - FeeRecipientConfig: &FeeRecipientConfig{ + d := &ProposerOption{} + if ps.DefaultConfig.FeeRecipient != "" { + d.FeeRecipientConfig = &FeeRecipientConfig{ FeeRecipient: common.HexToAddress(ps.DefaultConfig.FeeRecipient), - }, + } } if ps.DefaultConfig.BuilderConfig != nil { d.BuilderConfig = ps.DefaultConfig.BuilderConfig.Clone() @@ -110,12 +114,16 @@ type ProposerSettings struct { // ToPayload converts struct to ProposerSettingsPayload func (ps *ProposerSettings) ToPayload() *ProposerSettingsPayload { + if ps == nil { + return nil + } payload := &ProposerSettingsPayload{ ProposerConfig: make(map[string]*ProposerOptionPayload), } for key, option := range ps.ProposeConfig { - p := &ProposerOptionPayload{ - FeeRecipient: option.FeeRecipientConfig.FeeRecipient.Hex(), + p := &ProposerOptionPayload{} + if option.FeeRecipientConfig != nil { + p.FeeRecipient = option.FeeRecipientConfig.FeeRecipient.Hex() } if option.BuilderConfig != nil { p.BuilderConfig = option.BuilderConfig.Clone() @@ -123,8 +131,9 @@ func (ps *ProposerSettings) ToPayload() *ProposerSettingsPayload { payload.ProposerConfig[hexutil.Encode(key[:])] = p } if ps.DefaultConfig != nil { - p := &ProposerOptionPayload{ - FeeRecipient: ps.DefaultConfig.FeeRecipientConfig.FeeRecipient.Hex(), + p := &ProposerOptionPayload{} + if ps.DefaultConfig.FeeRecipientConfig != nil { + p.FeeRecipient = ps.DefaultConfig.FeeRecipientConfig.FeeRecipient.Hex() } if ps.DefaultConfig.BuilderConfig != nil { p.BuilderConfig = ps.DefaultConfig.BuilderConfig.Clone() @@ -147,27 +156,38 @@ type ProposerOption struct { // Clone creates a deep copy of the proposer settings func (ps *ProposerSettings) Clone() *ProposerSettings { - clone := &ProposerSettings{ - ProposeConfig: make(map[[fieldparams.BLSPubkeyLength]byte]*ProposerOption), + if ps == nil { + return nil } + clone := &ProposerSettings{} if ps.DefaultConfig != nil { clone.DefaultConfig = ps.DefaultConfig.Clone() } - for k, v := range ps.ProposeConfig { - keyCopy := k - valCopy := v.Clone() - clone.ProposeConfig[keyCopy] = valCopy + if ps.ProposeConfig != nil { + clone.ProposeConfig = make(map[[fieldparams.BLSPubkeyLength]byte]*ProposerOption) + for k, v := range ps.ProposeConfig { + keyCopy := k + valCopy := v.Clone() + clone.ProposeConfig[keyCopy] = valCopy + } } + return clone } // Clone creates a deep copy of fee recipient config func (fo *FeeRecipientConfig) Clone() *FeeRecipientConfig { + if fo == nil { + return nil + } return &FeeRecipientConfig{fo.FeeRecipient} } // Clone creates a deep copy of builder config func (bc *BuilderConfig) Clone() *BuilderConfig { + if bc == nil { + return nil + } relays := make([]string, len(bc.Relays)) copy(relays, bc.Relays) return &BuilderConfig{bc.Enabled, bc.GasLimit, relays} @@ -175,8 +195,12 @@ func (bc *BuilderConfig) Clone() *BuilderConfig { // Clone creates a deep copy of proposer option func (po *ProposerOption) Clone() *ProposerOption { - p := &ProposerOption{ - FeeRecipientConfig: po.FeeRecipientConfig.Clone(), + if po == nil { + return nil + } + p := &ProposerOption{} + if po.FeeRecipientConfig != nil { + p.FeeRecipientConfig = po.FeeRecipientConfig.Clone() } if po.BuilderConfig != nil { p.BuilderConfig = po.BuilderConfig.Clone() diff --git a/validator/client/runner.go b/validator/client/runner.go index 2ac0050e842c..03ee231944af 100644 --- a/validator/client/runner.go +++ b/validator/client/runner.go @@ -118,7 +118,7 @@ func run(ctx context.Context, v iface.Validator) { if slots.IsEpochStart(slot) && v.ProposerSettings() != nil { go func() { - //deadline set for end of epoch + // deadline set for end of epoch epochDeadline := v.SlotDeadline(slot + params.BeaconConfig().SlotsPerEpoch - 1) if err := v.PushProposerSettings(ctx, km, epochDeadline); err != nil { log.WithError(err).Warn("Failed to update proposer settings") diff --git a/validator/rpc/standard_api_test.go b/validator/rpc/standard_api_test.go index 5a154df41107..8050f1da57b6 100644 --- a/validator/rpc/standard_api_test.go +++ b/validator/rpc/standard_api_test.go @@ -31,6 +31,7 @@ import ( "github.com/prysmaticlabs/prysm/v4/validator/accounts/wallet" "github.com/prysmaticlabs/prysm/v4/validator/client" "github.com/prysmaticlabs/prysm/v4/validator/db/kv" + dbtest "github.com/prysmaticlabs/prysm/v4/validator/db/testing" "github.com/prysmaticlabs/prysm/v4/validator/keymanager" "github.com/prysmaticlabs/prysm/v4/validator/keymanager/derived" remoteweb3signer "github.com/prysmaticlabs/prysm/v4/validator/keymanager/remote-web3signer" @@ -998,15 +999,13 @@ func TestServer_FeeRecipientByPubkey(t *testing.T) { t.Run(tt.name, func(t *testing.T) { m := &mock.MockValidator{} m.SetProposerSettings(tt.proposerSettings) - validatorDB, err := kv.NewKVStore(ctx, defaultWalletPath, &kv.Config{}) - require.NoError(t, err) + validatorDB := dbtest.SetupDB(t, [][fieldparams.BLSPubkeyLength]byte{}) // save a default here vs, err := client.NewValidatorService(ctx, &client.Config{ Validator: m, ValDB: validatorDB, }) - require.NoError(t, err) s := &Server{ validatorService: vs, @@ -1102,12 +1101,16 @@ func TestServer_DeleteFeeRecipientByPubkey(t *testing.T) { t.Run(tt.name, func(t *testing.T) { m := &mock.MockValidator{} m.SetProposerSettings(tt.proposerSettings) + validatorDB, err := kv.NewKVStore(ctx, defaultWalletPath, &kv.Config{}) + require.NoError(t, err) vs, err := client.NewValidatorService(ctx, &client.Config{ Validator: m, + ValDB: validatorDB, }) require.NoError(t, err) s := &Server{ validatorService: vs, + valDB: validatorDB, } _, err = s.DeleteFeeRecipientByPubkey(ctx, ðpbservice.PubkeyRequest{Pubkey: byteval}) require.NoError(t, err) From 465ea7de298b1f0916437db0c62c0acb6ea99f53 Mon Sep 17 00:00:00 2001 From: james-prysm Date: Wed, 3 May 2023 19:47:00 -0500 Subject: [PATCH 14/33] fixing linting --- config/validator/service/BUILD.bazel | 1 - validator/db/kv/BUILD.bazel | 1 + validator/rpc/BUILD.bazel | 1 + 3 files changed, 2 insertions(+), 1 deletion(-) diff --git a/config/validator/service/BUILD.bazel b/config/validator/service/BUILD.bazel index 570cb6f843ac..6d807e1ca4f9 100644 --- a/config/validator/service/BUILD.bazel +++ b/config/validator/service/BUILD.bazel @@ -10,6 +10,5 @@ go_library( "//encoding/bytesutil:go_default_library", "@com_github_ethereum_go_ethereum//common:go_default_library", "@com_github_ethereum_go_ethereum//common/hexutil:go_default_library", - "@com_github_pkg_errors//:go_default_library", ], ) diff --git a/validator/db/kv/BUILD.bazel b/validator/db/kv/BUILD.bazel index 426ed3305276..777664d448f4 100644 --- a/validator/db/kv/BUILD.bazel +++ b/validator/db/kv/BUILD.bazel @@ -61,6 +61,7 @@ go_test( "migration_optimal_attester_protection_test.go", "migration_source_target_epochs_bucket_test.go", "proposer_protection_test.go", + "proposer_settings_test.go", "prune_attester_protection_test.go", ], embed = [":go_default_library"], diff --git a/validator/rpc/BUILD.bazel b/validator/rpc/BUILD.bazel index 96efc62a40c8..a14f010bf470 100644 --- a/validator/rpc/BUILD.bazel +++ b/validator/rpc/BUILD.bazel @@ -117,6 +117,7 @@ go_test( "//validator/accounts/wallet:go_default_library", "//validator/client:go_default_library", "//validator/db/kv:go_default_library", + "//validator/db/testing:go_default_library", "//validator/keymanager:go_default_library", "//validator/keymanager/derived:go_default_library", "//validator/keymanager/remote-web3signer:go_default_library", From fd37664571bc23790ed005b53e45860f56962e12 Mon Sep 17 00:00:00 2001 From: james-prysm Date: Wed, 3 May 2023 21:01:48 -0500 Subject: [PATCH 15/33] WIP fixing unit tests --- validator/rpc/standard_api.go | 5 +- validator/rpc/standard_api_test.go | 73 ++++++++---------------------- 2 files changed, 24 insertions(+), 54 deletions(-) diff --git a/validator/rpc/standard_api.go b/validator/rpc/standard_api.go index 6f0dcb8fb4cf..632003f6889e 100644 --- a/validator/rpc/standard_api.go +++ b/validator/rpc/standard_api.go @@ -434,7 +434,7 @@ func (s *Server) SetGasLimit(ctx context.Context, req *ethpbservice.SetGasLimitR if settings == nil { return &empty.Empty{}, status.Errorf(codes.FailedPrecondition, "no proposer settings were found to update") } else if settings.ProposeConfig == nil { - if settings.DefaultConfig.BuilderConfig == nil || !settings.DefaultConfig.BuilderConfig.Enabled { + if settings.DefaultConfig == nil || settings.DefaultConfig.BuilderConfig == nil || !settings.DefaultConfig.BuilderConfig.Enabled { return &empty.Empty{}, status.Errorf(codes.FailedPrecondition, "gas limit changes only apply when builder is enabled") } settings.ProposeConfig = make(map[[fieldparams.BLSPubkeyLength]byte]*validatorServiceConfig.ProposerOption) @@ -450,6 +450,9 @@ func (s *Server) SetGasLimit(ctx context.Context, req *ethpbservice.SetGasLimitR proposerOption.BuilderConfig.GasLimit = validatorServiceConfig.Uint64(req.GasLimit) } } else { + if settings.DefaultConfig == nil { + return &empty.Empty{}, status.Errorf(codes.FailedPrecondition, "gas limit changes only apply when builder is enabled") + } option := settings.DefaultConfig.Clone() option.BuilderConfig.GasLimit = validatorServiceConfig.Uint64(req.GasLimit) settings.ProposeConfig[bytesutil.ToBytes48(validatorKey)] = option diff --git a/validator/rpc/standard_api_test.go b/validator/rpc/standard_api_test.go index 8050f1da57b6..2a8c1b4de77e 100644 --- a/validator/rpc/standard_api_test.go +++ b/validator/rpc/standard_api_test.go @@ -1215,7 +1215,6 @@ func TestServer_GetGasLimit(t *testing.T) { func TestServer_SetGasLimit(t *testing.T) { ctrl := gomock.NewController(t) defer ctrl.Finish() - beaconClient := validatormock.NewMockValidatorClient(ctrl) ctx := grpc.NewContextWithServerTransportStream(context.Background(), &runtime.ServerTransportStream{}) @@ -1241,18 +1240,14 @@ func TestServer_SetGasLimit(t *testing.T) { proposerSettings *validatorserviceconfig.ProposerSettings w []want beaconReturn *beaconResp + wantErr string }{ { name: "ProposerSettings is nil", pubkey: pubkey1, newGasLimit: 9999, proposerSettings: nil, - w: []want{ - { - pubkey: pubkey1, - gaslimit: 9999, - }, - }, + wantErr: "no proposer settings were found to update", }, { name: "ProposerSettings.ProposeConfig is nil AND ProposerSettings.DefaultConfig is nil", @@ -1262,12 +1257,7 @@ func TestServer_SetGasLimit(t *testing.T) { ProposeConfig: nil, DefaultConfig: nil, }, - w: []want{ - { - pubkey: pubkey1, - gaslimit: 9999, - }, - }, + wantErr: "gas limit changes only apply when builder is enabled", }, { name: "ProposerSettings.ProposeConfig is nil AND ProposerSettings.DefaultConfig.BuilderConfig is nil", @@ -1279,12 +1269,7 @@ func TestServer_SetGasLimit(t *testing.T) { BuilderConfig: nil, }, }, - w: []want{ - { - pubkey: pubkey1, - gaslimit: 9999, - }, - }, + wantErr: "gas limit changes only apply when builder is enabled", }, { name: "ProposerSettings.ProposeConfig is defined for pubkey, BuilderConfig is nil AND ProposerSettings.DefaultConfig is nil", @@ -1298,12 +1283,7 @@ func TestServer_SetGasLimit(t *testing.T) { }, DefaultConfig: nil, }, - w: []want{ - { - pubkey: pubkey1, - gaslimit: 9999, - }, - }, + wantErr: "gas limit changes only apply when builder is enabled", }, { name: "ProposerSettings.ProposeConfig is defined for pubkey, BuilderConfig is defined AND ProposerSettings.DefaultConfig is nil", @@ -1317,12 +1297,7 @@ func TestServer_SetGasLimit(t *testing.T) { }, DefaultConfig: nil, }, - w: []want{ - { - pubkey: pubkey1, - gaslimit: 9999, - }, - }, + wantErr: "gas limit changes only apply when builder is enabled", }, { name: "ProposerSettings.ProposeConfig is NOT defined for pubkey, BuilderConfig is defined AND ProposerSettings.DefaultConfig is nil", @@ -1330,24 +1305,16 @@ func TestServer_SetGasLimit(t *testing.T) { newGasLimit: 9999, proposerSettings: &validatorserviceconfig.ProposerSettings{ ProposeConfig: map[[48]byte]*validatorserviceconfig.ProposerOption{ - bytesutil.ToBytes48(pubkey1): { + bytesutil.ToBytes48(pubkey2): { BuilderConfig: &validatorserviceconfig.BuilderConfig{ + Enabled: true, GasLimit: 12345, }, }, }, DefaultConfig: nil, }, - w: []want{ - { - pubkey: pubkey1, - gaslimit: 12345, - }, - { - pubkey: pubkey2, - gaslimit: 9999, - }, - }, + wantErr: "gas limit changes only apply when builder is enabled", }, { name: "ProposerSettings.ProposeConfig is defined for pubkey, BuilderConfig is nil AND ProposerSettings.DefaultConfig.BuilderConfig is defined", @@ -1360,15 +1327,12 @@ func TestServer_SetGasLimit(t *testing.T) { }, }, DefaultConfig: &validatorserviceconfig.ProposerOption{ - BuilderConfig: &validatorserviceconfig.BuilderConfig{}, - }, - }, - w: []want{ - { - pubkey: pubkey1, - gaslimit: 9999, + BuilderConfig: &validatorserviceconfig.BuilderConfig{ + Enabled: true, + }, }, }, + wantErr: "gas limit changes only apply when builder is enabled", }, } for _, tt := range tests { @@ -1394,10 +1358,13 @@ func TestServer_SetGasLimit(t *testing.T) { } _, err = s.SetGasLimit(ctx, ðpbservice.SetGasLimitRequest{Pubkey: tt.pubkey, GasLimit: tt.newGasLimit}) - require.NoError(t, err) - - for _, w := range tt.w { - assert.Equal(t, w.gaslimit, uint64(s.validatorService.ProposerSettings().ProposeConfig[bytesutil.ToBytes48(w.pubkey)].BuilderConfig.GasLimit)) + if tt.wantErr != "" { + require.ErrorContains(t, tt.wantErr, err) + } else { + require.NoError(t, err) + for _, w := range tt.w { + assert.Equal(t, w.gaslimit, uint64(s.validatorService.ProposerSettings().ProposeConfig[bytesutil.ToBytes48(w.pubkey)].BuilderConfig.GasLimit)) + } } }) } From 3eb463d6be875c988beb1d1f45f91e534444fc5c Mon Sep 17 00:00:00 2001 From: james-prysm Date: Wed, 3 May 2023 23:31:57 -0500 Subject: [PATCH 16/33] fixing remaining db tests --- validator/rpc/standard_api_test.go | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/validator/rpc/standard_api_test.go b/validator/rpc/standard_api_test.go index 2a8c1b4de77e..a7d82c63a0d1 100644 --- a/validator/rpc/standard_api_test.go +++ b/validator/rpc/standard_api_test.go @@ -1101,8 +1101,7 @@ func TestServer_DeleteFeeRecipientByPubkey(t *testing.T) { t.Run(tt.name, func(t *testing.T) { m := &mock.MockValidator{} m.SetProposerSettings(tt.proposerSettings) - validatorDB, err := kv.NewKVStore(ctx, defaultWalletPath, &kv.Config{}) - require.NoError(t, err) + validatorDB := dbtest.SetupDB(t, [][fieldparams.BLSPubkeyLength]byte{}) vs, err := client.NewValidatorService(ctx, &client.Config{ Validator: m, ValDB: validatorDB, @@ -1238,7 +1237,7 @@ func TestServer_SetGasLimit(t *testing.T) { pubkey []byte newGasLimit uint64 proposerSettings *validatorserviceconfig.ProposerSettings - w []want + w []*want beaconReturn *beaconResp wantErr string }{ @@ -1314,7 +1313,11 @@ func TestServer_SetGasLimit(t *testing.T) { }, DefaultConfig: nil, }, - wantErr: "gas limit changes only apply when builder is enabled", + w: []*want{{ + pubkey2, + 9999, + }, + }, }, { name: "ProposerSettings.ProposeConfig is defined for pubkey, BuilderConfig is nil AND ProposerSettings.DefaultConfig.BuilderConfig is defined", @@ -1322,7 +1325,7 @@ func TestServer_SetGasLimit(t *testing.T) { newGasLimit: 9999, proposerSettings: &validatorserviceconfig.ProposerSettings{ ProposeConfig: map[[48]byte]*validatorserviceconfig.ProposerOption{ - bytesutil.ToBytes48(pubkey1): { + bytesutil.ToBytes48(pubkey2): { BuilderConfig: nil, }, }, @@ -1332,22 +1335,28 @@ func TestServer_SetGasLimit(t *testing.T) { }, }, }, - wantErr: "gas limit changes only apply when builder is enabled", + w: []*want{{ + pubkey1, + 9999, + }, + }, }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { m := &mock.MockValidator{} m.SetProposerSettings(tt.proposerSettings) - + validatorDB := dbtest.SetupDB(t, [][fieldparams.BLSPubkeyLength]byte{}) vs, err := client.NewValidatorService(ctx, &client.Config{ Validator: m, + ValDB: validatorDB, }) require.NoError(t, err) s := &Server{ validatorService: vs, beaconNodeValidatorClient: beaconClient, + valDB: validatorDB, } if tt.beaconReturn != nil { @@ -1506,12 +1515,15 @@ func TestServer_DeleteGasLimit(t *testing.T) { t.Run(tt.name, func(t *testing.T) { m := &mock.MockValidator{} m.SetProposerSettings(tt.proposerSettings) + validatorDB := dbtest.SetupDB(t, [][fieldparams.BLSPubkeyLength]byte{}) vs, err := client.NewValidatorService(ctx, &client.Config{ Validator: m, + ValDB: validatorDB, }) require.NoError(t, err) s := &Server{ validatorService: vs, + valDB: validatorDB, } // Set up global default value for builder gas limit. params.BeaconConfig().DefaultBuilderGasLimit = uint64(globalDefaultGasLimit) From d40fdd4ab38f973adaad809b6d57f1576635377f Mon Sep 17 00:00:00 2001 From: james-prysm Date: Fri, 5 May 2023 16:12:33 -0500 Subject: [PATCH 17/33] converting json to protobuf --- config/validator/service/BUILD.bazel | 2 + config/validator/service/proposer-settings.go | 123 +++--- consensus-types/validator/BUILD.bazel | 8 + consensus-types/validator/custom_types.go | 37 ++ .../v1alpha1/validator-client/BUILD.bazel | 1 + .../validator-client/keymanager.pb.go | 397 +++++++++++++++--- .../validator-client/keymanager.proto | 16 + validator/db/kv/BUILD.bazel | 1 + validator/db/kv/proposer_settings.go | 13 +- validator/node/BUILD.bazel | 4 +- validator/node/node.go | 31 +- validator/node/node_test.go | 23 +- validator/rpc/BUILD.bazel | 1 + validator/rpc/standard_api.go | 9 +- 14 files changed, 494 insertions(+), 172 deletions(-) create mode 100644 consensus-types/validator/BUILD.bazel create mode 100644 consensus-types/validator/custom_types.go diff --git a/config/validator/service/BUILD.bazel b/config/validator/service/BUILD.bazel index 6d807e1ca4f9..6b02d92c18c4 100644 --- a/config/validator/service/BUILD.bazel +++ b/config/validator/service/BUILD.bazel @@ -7,7 +7,9 @@ go_library( visibility = ["//visibility:public"], deps = [ "//config/fieldparams:go_default_library", + "//consensus-types/validator:go_default_library", "//encoding/bytesutil:go_default_library", + "//proto/prysm/v1alpha1/validator-client:go_default_library", "@com_github_ethereum_go_ethereum//common:go_default_library", "@com_github_ethereum_go_ethereum//common/hexutil:go_default_library", ], diff --git a/config/validator/service/proposer-settings.go b/config/validator/service/proposer-settings.go index cdcb04eb92cd..d0b666947028 100644 --- a/config/validator/service/proposer-settings.go +++ b/config/validator/service/proposer-settings.go @@ -1,24 +1,16 @@ package validator_service_config import ( - "strconv" - "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" fieldparams "github.com/prysmaticlabs/prysm/v4/config/fieldparams" + "github.com/prysmaticlabs/prysm/v4/consensus-types/validator" "github.com/prysmaticlabs/prysm/v4/encoding/bytesutil" + validatorpb "github.com/prysmaticlabs/prysm/v4/proto/prysm/v1alpha1/validator-client" ) -// ProposerSettingsPayload is the struct representation of the JSON or YAML payload set in the validator through the CLI. -// ProposerConfig is the map of validator address to fee recipient options all in hex format. -// DefaultConfig is the default fee recipient address for all validators unless otherwise specified in the propose config.required. -type ProposerSettingsPayload struct { - ProposerConfig map[string]*ProposerOptionPayload `json:"proposer_config" yaml:"proposer_config"` - DefaultConfig *ProposerOptionPayload `json:"default_config" yaml:"default_config"` -} - // ToSettings converts struct to ProposerSettings -func (ps *ProposerSettingsPayload) ToSettings() (*ProposerSettings, error) { +func ToSettings(ps *validatorpb.ProposerSettingsPayload) (*ProposerSettings, error) { settings := &ProposerSettings{} if ps.ProposerConfig != nil { settings.ProposeConfig = make(map[[fieldparams.BLSPubkeyLength]byte]*ProposerOption) @@ -35,8 +27,8 @@ func (ps *ProposerSettingsPayload) ToSettings() (*ProposerSettings, error) { FeeRecipient: common.HexToAddress(optionPayload.FeeRecipient), }, } - if optionPayload.BuilderConfig != nil { - p.BuilderConfig = optionPayload.BuilderConfig.Clone() + if optionPayload.Builder != nil { + p.BuilderConfig = ToBuilderConfig(optionPayload.Builder) } settings.ProposeConfig[bytesutil.ToBytes48(b)] = p } @@ -48,61 +40,37 @@ func (ps *ProposerSettingsPayload) ToSettings() (*ProposerSettings, error) { FeeRecipient: common.HexToAddress(ps.DefaultConfig.FeeRecipient), } } - if ps.DefaultConfig.BuilderConfig != nil { - d.BuilderConfig = ps.DefaultConfig.BuilderConfig.Clone() + if ps.DefaultConfig.Builder != nil { + d.BuilderConfig = ToBuilderConfig(ps.DefaultConfig.Builder) } settings.DefaultConfig = d } return settings, nil } -// ProposerOptionPayload is the struct representation of the JSON config file set in the validator through the CLI. -// FeeRecipient is set to an eth address in hex string format with 0x prefix. -type ProposerOptionPayload struct { - FeeRecipient string `json:"fee_recipient" yaml:"fee_recipient"` - BuilderConfig *BuilderConfig `json:"builder" yaml:"builder"` -} - // BuilderConfig is the struct representation of the JSON config file set in the validator through the CLI. // GasLimit is a number set to help the network decide on the maximum gas in each block. type BuilderConfig struct { - Enabled bool `json:"enabled" yaml:"enabled"` - GasLimit Uint64 `json:"gas_limit,omitempty" yaml:"gas_limit,omitempty"` - Relays []string `json:"relays" yaml:"relays"` + Enabled bool `json:"enabled" yaml:"enabled"` + GasLimit validator.Uint64 `json:"gas_limit,omitempty" yaml:"gas_limit,omitempty"` + Relays []string `json:"relays,omitempty" yaml:"relays,omitempty"` } -// Uint64 custom uint64 to be unmarshallable -type Uint64 uint64 - -// UnmarshalJSON custom unmarshal function for json -func (u *Uint64) UnmarshalJSON(bs []byte) error { - str := string(bs) // Parse plain numbers directly. - if bs[0] == '"' && bs[len(bs)-1] == '"' { - // Unwrap the quotes from string numbers. - str = string(bs[1 : len(bs)-1]) - } - x, err := strconv.ParseUint(str, 10, 64) - if err != nil { - return err - } - *u = Uint64(x) - return nil -} - -// UnmarshalYAML custom unmarshal function for yaml -func (u *Uint64) UnmarshalYAML(unmarshal func(interface{}) error) error { - var str string - err := unmarshal(&str) - if err != nil { - return err - } - x, err := strconv.ParseUint(str, 10, 64) - if err != nil { - return err - } - *u = Uint64(x) +func ToBuilderConfig(from *validatorpb.BuilderConfig) *BuilderConfig { + if from == nil { + return nil + } + config := &BuilderConfig{ + Enabled: from.Enabled, + GasLimit: from.GasLimit, + } + if from.Relays != nil { + relays := make([]string, len(from.Relays)) + copy(relays, from.Relays) + config.Relays = relays + } - return nil + return config } // ProposerSettings is a Prysm internal representation of the fee recipient config on the validator client. @@ -113,30 +81,30 @@ type ProposerSettings struct { } // ToPayload converts struct to ProposerSettingsPayload -func (ps *ProposerSettings) ToPayload() *ProposerSettingsPayload { +func (ps *ProposerSettings) ToPayload() *validatorpb.ProposerSettingsPayload { if ps == nil { return nil } - payload := &ProposerSettingsPayload{ - ProposerConfig: make(map[string]*ProposerOptionPayload), + payload := &validatorpb.ProposerSettingsPayload{ + ProposerConfig: make(map[string]*validatorpb.ProposerOptionPayload), } for key, option := range ps.ProposeConfig { - p := &ProposerOptionPayload{} + p := &validatorpb.ProposerOptionPayload{} if option.FeeRecipientConfig != nil { p.FeeRecipient = option.FeeRecipientConfig.FeeRecipient.Hex() } if option.BuilderConfig != nil { - p.BuilderConfig = option.BuilderConfig.Clone() + p.Builder = option.BuilderConfig.ToPayload() } payload.ProposerConfig[hexutil.Encode(key[:])] = p } if ps.DefaultConfig != nil { - p := &ProposerOptionPayload{} + p := &validatorpb.ProposerOptionPayload{} if ps.DefaultConfig.FeeRecipientConfig != nil { p.FeeRecipient = ps.DefaultConfig.FeeRecipientConfig.FeeRecipient.Hex() } if ps.DefaultConfig.BuilderConfig != nil { - p.BuilderConfig = ps.DefaultConfig.BuilderConfig.Clone() + p.Builder = ps.DefaultConfig.BuilderConfig.ToPayload() } payload.DefaultConfig = p } @@ -188,9 +156,32 @@ func (bc *BuilderConfig) Clone() *BuilderConfig { if bc == nil { return nil } - relays := make([]string, len(bc.Relays)) - copy(relays, bc.Relays) - return &BuilderConfig{bc.Enabled, bc.GasLimit, relays} + config := &BuilderConfig{} + config.Enabled = bc.Enabled + config.GasLimit = bc.GasLimit + var relays []string + if bc.Relays != nil { + relays = make([]string, len(bc.Relays)) + copy(relays, bc.Relays) + config.Relays = relays + } + return config +} + +func (bc *BuilderConfig) ToPayload() *validatorpb.BuilderConfig { + if bc == nil { + return nil + } + config := &validatorpb.BuilderConfig{} + config.Enabled = bc.Enabled + var relays []string + if bc.Relays != nil { + relays = make([]string, len(bc.Relays)) + copy(relays, bc.Relays) + config.Relays = relays + } + config.GasLimit = bc.GasLimit + return config } // Clone creates a deep copy of proposer option diff --git a/consensus-types/validator/BUILD.bazel b/consensus-types/validator/BUILD.bazel new file mode 100644 index 000000000000..f0396aef7a11 --- /dev/null +++ b/consensus-types/validator/BUILD.bazel @@ -0,0 +1,8 @@ +load("@prysm//tools/go:def.bzl", "go_library") + +go_library( + name = "go_default_library", + srcs = ["custom_types.go"], + importpath = "github.com/prysmaticlabs/prysm/v4/consensus-types/validator", + visibility = ["//visibility:public"], +) diff --git a/consensus-types/validator/custom_types.go b/consensus-types/validator/custom_types.go new file mode 100644 index 000000000000..92d873db5bf9 --- /dev/null +++ b/consensus-types/validator/custom_types.go @@ -0,0 +1,37 @@ +package validator + +import "strconv" + +// Uint64 custom uint64 to be unmarshallable +type Uint64 uint64 + +// UnmarshalJSON custom unmarshal function for json +func (u *Uint64) UnmarshalJSON(bs []byte) error { + str := string(bs) // Parse plain numbers directly. + if bs[0] == '"' && bs[len(bs)-1] == '"' { + // Unwrap the quotes from string numbers. + str = string(bs[1 : len(bs)-1]) + } + x, err := strconv.ParseUint(str, 10, 64) + if err != nil { + return err + } + *u = Uint64(x) + return nil +} + +// UnmarshalYAML custom unmarshal function for yaml +func (u *Uint64) UnmarshalYAML(unmarshal func(interface{}) error) error { + var str string + err := unmarshal(&str) + if err != nil { + return err + } + x, err := strconv.ParseUint(str, 10, 64) + if err != nil { + return err + } + *u = Uint64(x) + + return nil +} diff --git a/proto/prysm/v1alpha1/validator-client/BUILD.bazel b/proto/prysm/v1alpha1/validator-client/BUILD.bazel index 52cf3f598c69..3b30e118bdf2 100644 --- a/proto/prysm/v1alpha1/validator-client/BUILD.bazel +++ b/proto/prysm/v1alpha1/validator-client/BUILD.bazel @@ -54,6 +54,7 @@ go_proto_library( "@com_github_grpc_ecosystem_grpc_gateway_v2//protoc-gen-openapiv2/options:options_go_proto", "@com_github_prysmaticlabs_go_bitfield//:go_default_library", "//consensus-types/primitives:go_default_library", + "//consensus-types/validator:go_default_library", "@go_googleapis//google/api:annotations_go_proto", "@org_golang_google_protobuf//reflect/protoreflect:go_default_library", "@org_golang_google_protobuf//runtime/protoimpl:go_default_library", diff --git a/proto/prysm/v1alpha1/validator-client/keymanager.pb.go b/proto/prysm/v1alpha1/validator-client/keymanager.pb.go index 7772fd1b0be7..23913c7ed4d3 100755 --- a/proto/prysm/v1alpha1/validator-client/keymanager.pb.go +++ b/proto/prysm/v1alpha1/validator-client/keymanager.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.1 +// protoc-gen-go v1.30.0 // protoc v3.15.8 // source: proto/prysm/v1alpha1/validator-client/keymanager.proto @@ -13,6 +13,7 @@ import ( empty "github.com/golang/protobuf/ptypes/empty" github_com_prysmaticlabs_prysm_v4_consensus_types_primitives "github.com/prysmaticlabs/prysm/v4/consensus-types/primitives" + github_com_prysmaticlabs_prysm_v4_consensus_types_validator "github.com/prysmaticlabs/prysm/v4/consensus-types/validator" _ "github.com/prysmaticlabs/prysm/v4/proto/eth/ext" v1alpha1 "github.com/prysmaticlabs/prysm/v4/proto/prysm/v1alpha1" _ "google.golang.org/genproto/googleapis/api/annotations" @@ -479,6 +480,179 @@ func (x *SignResponse) GetStatus() SignResponse_Status { return SignResponse_UNKNOWN } +type ProposerOptionPayload struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + FeeRecipient string `protobuf:"bytes,1,opt,name=fee_recipient,json=feeRecipient,proto3" json:"fee_recipient,omitempty"` + Builder *BuilderConfig `protobuf:"bytes,2,opt,name=builder,proto3" json:"builder,omitempty"` +} + +func (x *ProposerOptionPayload) Reset() { + *x = ProposerOptionPayload{} + if protoimpl.UnsafeEnabled { + mi := &file_proto_prysm_v1alpha1_validator_client_keymanager_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ProposerOptionPayload) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ProposerOptionPayload) ProtoMessage() {} + +func (x *ProposerOptionPayload) ProtoReflect() protoreflect.Message { + mi := &file_proto_prysm_v1alpha1_validator_client_keymanager_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ProposerOptionPayload.ProtoReflect.Descriptor instead. +func (*ProposerOptionPayload) Descriptor() ([]byte, []int) { + return file_proto_prysm_v1alpha1_validator_client_keymanager_proto_rawDescGZIP(), []int{3} +} + +func (x *ProposerOptionPayload) GetFeeRecipient() string { + if x != nil { + return x.FeeRecipient + } + return "" +} + +func (x *ProposerOptionPayload) GetBuilder() *BuilderConfig { + if x != nil { + return x.Builder + } + return nil +} + +type BuilderConfig struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Enabled bool `protobuf:"varint,1,opt,name=enabled,proto3" json:"enabled,omitempty"` + GasLimit github_com_prysmaticlabs_prysm_v4_consensus_types_validator.Uint64 `protobuf:"varint,2,opt,name=gas_limit,json=gasLimit,proto3" json:"gas_limit,omitempty" cast-type:"github.com/prysmaticlabs/prysm/v4/consensus-types/validator.Uint64"` + Relays []string `protobuf:"bytes,3,rep,name=relays,proto3" json:"relays,omitempty"` +} + +func (x *BuilderConfig) Reset() { + *x = BuilderConfig{} + if protoimpl.UnsafeEnabled { + mi := &file_proto_prysm_v1alpha1_validator_client_keymanager_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *BuilderConfig) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*BuilderConfig) ProtoMessage() {} + +func (x *BuilderConfig) ProtoReflect() protoreflect.Message { + mi := &file_proto_prysm_v1alpha1_validator_client_keymanager_proto_msgTypes[4] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use BuilderConfig.ProtoReflect.Descriptor instead. +func (*BuilderConfig) Descriptor() ([]byte, []int) { + return file_proto_prysm_v1alpha1_validator_client_keymanager_proto_rawDescGZIP(), []int{4} +} + +func (x *BuilderConfig) GetEnabled() bool { + if x != nil { + return x.Enabled + } + return false +} + +func (x *BuilderConfig) GetGasLimit() github_com_prysmaticlabs_prysm_v4_consensus_types_validator.Uint64 { + if x != nil { + return x.GasLimit + } + return github_com_prysmaticlabs_prysm_v4_consensus_types_validator.Uint64(0) +} + +func (x *BuilderConfig) GetRelays() []string { + if x != nil { + return x.Relays + } + return nil +} + +type ProposerSettingsPayload struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + ProposerConfig map[string]*ProposerOptionPayload `protobuf:"bytes,1,rep,name=proposer_config,json=proposerConfig,proto3" json:"proposer_config,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + DefaultConfig *ProposerOptionPayload `protobuf:"bytes,2,opt,name=default_config,json=defaultConfig,proto3" json:"default_config,omitempty"` +} + +func (x *ProposerSettingsPayload) Reset() { + *x = ProposerSettingsPayload{} + if protoimpl.UnsafeEnabled { + mi := &file_proto_prysm_v1alpha1_validator_client_keymanager_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ProposerSettingsPayload) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ProposerSettingsPayload) ProtoMessage() {} + +func (x *ProposerSettingsPayload) ProtoReflect() protoreflect.Message { + mi := &file_proto_prysm_v1alpha1_validator_client_keymanager_proto_msgTypes[5] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ProposerSettingsPayload.ProtoReflect.Descriptor instead. +func (*ProposerSettingsPayload) Descriptor() ([]byte, []int) { + return file_proto_prysm_v1alpha1_validator_client_keymanager_proto_rawDescGZIP(), []int{5} +} + +func (x *ProposerSettingsPayload) GetProposerConfig() map[string]*ProposerOptionPayload { + if x != nil { + return x.ProposerConfig + } + return nil +} + +func (x *ProposerSettingsPayload) GetDefaultConfig() *ProposerOptionPayload { + if x != nil { + return x.DefaultConfig + } + return nil +} + var File_proto_prysm_v1alpha1_validator_client_keymanager_proto protoreflect.FileDescriptor var file_proto_prysm_v1alpha1_validator_client_keymanager_proto_rawDesc = []byte{ @@ -620,39 +794,80 @@ var file_proto_prysm_v1alpha1_validator_client_keymanager_proto_rawDesc = []byte 0x0a, 0x07, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x0d, 0x0a, 0x09, 0x53, 0x55, 0x43, 0x43, 0x45, 0x45, 0x44, 0x45, 0x44, 0x10, 0x01, 0x12, 0x0a, 0x0a, 0x06, 0x44, 0x45, 0x4e, 0x49, 0x45, 0x44, 0x10, 0x02, 0x12, 0x0a, 0x0a, 0x06, 0x46, 0x41, 0x49, 0x4c, 0x45, 0x44, - 0x10, 0x03, 0x32, 0xa7, 0x02, 0x0a, 0x0c, 0x52, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x53, 0x69, 0x67, - 0x6e, 0x65, 0x72, 0x12, 0x90, 0x01, 0x0a, 0x18, 0x4c, 0x69, 0x73, 0x74, 0x56, 0x61, 0x6c, 0x69, - 0x64, 0x61, 0x74, 0x69, 0x6e, 0x67, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x4b, 0x65, 0x79, 0x73, - 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, - 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x36, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, - 0x65, 0x75, 0x6d, 0x2e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x2e, 0x61, 0x63, - 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x2e, 0x76, 0x32, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x75, - 0x62, 0x6c, 0x69, 0x63, 0x4b, 0x65, 0x79, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x22, 0x24, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x1e, 0x12, 0x1c, 0x2f, 0x61, 0x63, 0x63, 0x6f, 0x75, - 0x6e, 0x74, 0x73, 0x2f, 0x76, 0x32, 0x2f, 0x72, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x2f, 0x61, 0x63, - 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x12, 0x83, 0x01, 0x0a, 0x04, 0x53, 0x69, 0x67, 0x6e, 0x12, - 0x2b, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x76, 0x61, 0x6c, 0x69, 0x64, - 0x61, 0x74, 0x6f, 0x72, 0x2e, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x2e, 0x76, 0x32, - 0x2e, 0x53, 0x69, 0x67, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2c, 0x2e, 0x65, - 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, - 0x72, 0x2e, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x2e, 0x76, 0x32, 0x2e, 0x53, 0x69, - 0x67, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x20, 0x82, 0xd3, 0xe4, 0x93, - 0x02, 0x1a, 0x22, 0x18, 0x2f, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x2f, 0x76, 0x32, - 0x2f, 0x72, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x2f, 0x73, 0x69, 0x67, 0x6e, 0x42, 0xce, 0x01, 0x0a, - 0x22, 0x6f, 0x72, 0x67, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x76, 0x61, + 0x10, 0x03, 0x22, 0x85, 0x01, 0x0a, 0x15, 0x50, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x65, 0x72, 0x4f, + 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x50, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x12, 0x23, 0x0a, 0x0d, + 0x66, 0x65, 0x65, 0x5f, 0x72, 0x65, 0x63, 0x69, 0x70, 0x69, 0x65, 0x6e, 0x74, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x0c, 0x66, 0x65, 0x65, 0x52, 0x65, 0x63, 0x69, 0x70, 0x69, 0x65, 0x6e, + 0x74, 0x12, 0x47, 0x0a, 0x07, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x2d, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x2e, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, - 0x2e, 0x76, 0x32, 0x42, 0x0f, 0x4b, 0x65, 0x79, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x50, - 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x53, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, - 0x6f, 0x6d, 0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d, 0x61, 0x74, 0x69, 0x63, 0x6c, 0x61, 0x62, 0x73, - 0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d, 0x2f, 0x76, 0x34, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, - 0x70, 0x72, 0x79, 0x73, 0x6d, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2f, 0x76, - 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x2d, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x3b, - 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x70, 0x62, 0xaa, 0x02, 0x1e, 0x45, 0x74, - 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, - 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x2e, 0x56, 0x32, 0xca, 0x02, 0x1e, 0x45, - 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x5c, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, - 0x72, 0x5c, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x5c, 0x56, 0x32, 0x62, 0x06, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x2e, 0x76, 0x32, 0x2e, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x66, 0x69, + 0x67, 0x52, 0x07, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x65, 0x72, 0x22, 0xa6, 0x01, 0x0a, 0x0d, 0x42, + 0x75, 0x69, 0x6c, 0x64, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x18, 0x0a, 0x07, + 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x65, + 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x12, 0x63, 0x0a, 0x09, 0x67, 0x61, 0x73, 0x5f, 0x6c, 0x69, + 0x6d, 0x69, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x42, 0x46, 0x82, 0xb5, 0x18, 0x42, 0x67, + 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d, 0x61, + 0x74, 0x69, 0x63, 0x6c, 0x61, 0x62, 0x73, 0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d, 0x2f, 0x76, 0x34, + 0x2f, 0x63, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x73, + 0x2f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x2e, 0x55, 0x69, 0x6e, 0x74, 0x36, + 0x34, 0x52, 0x08, 0x67, 0x61, 0x73, 0x4c, 0x69, 0x6d, 0x69, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x72, + 0x65, 0x6c, 0x61, 0x79, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x06, 0x72, 0x65, 0x6c, + 0x61, 0x79, 0x73, 0x22, 0xe7, 0x02, 0x0a, 0x17, 0x50, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x65, 0x72, + 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x50, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x12, + 0x74, 0x0a, 0x0f, 0x70, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x65, 0x72, 0x5f, 0x63, 0x6f, 0x6e, 0x66, + 0x69, 0x67, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x4b, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, + 0x65, 0x75, 0x6d, 0x2e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x2e, 0x61, 0x63, + 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x2e, 0x76, 0x32, 0x2e, 0x50, 0x72, 0x6f, 0x70, 0x6f, 0x73, + 0x65, 0x72, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x50, 0x61, 0x79, 0x6c, 0x6f, 0x61, + 0x64, 0x2e, 0x50, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, + 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x0e, 0x70, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x65, 0x72, 0x43, + 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x5c, 0x0a, 0x0e, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, + 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x35, 0x2e, + 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, + 0x6f, 0x72, 0x2e, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x2e, 0x76, 0x32, 0x2e, 0x50, + 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x65, 0x72, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x50, 0x61, 0x79, + 0x6c, 0x6f, 0x61, 0x64, 0x52, 0x0d, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x43, 0x6f, 0x6e, + 0x66, 0x69, 0x67, 0x1a, 0x78, 0x0a, 0x13, 0x50, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x65, 0x72, 0x43, + 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, + 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x4b, 0x0a, 0x05, + 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x35, 0x2e, 0x65, 0x74, + 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, + 0x2e, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x2e, 0x76, 0x32, 0x2e, 0x50, 0x72, 0x6f, + 0x70, 0x6f, 0x73, 0x65, 0x72, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x50, 0x61, 0x79, 0x6c, 0x6f, + 0x61, 0x64, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x32, 0xa7, 0x02, + 0x0a, 0x0c, 0x52, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x53, 0x69, 0x67, 0x6e, 0x65, 0x72, 0x12, 0x90, + 0x01, 0x0a, 0x18, 0x4c, 0x69, 0x73, 0x74, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6e, + 0x67, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x4b, 0x65, 0x79, 0x73, 0x12, 0x16, 0x2e, 0x67, 0x6f, + 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, + 0x70, 0x74, 0x79, 0x1a, 0x36, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x76, + 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x2e, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, + 0x73, 0x2e, 0x76, 0x32, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x4b, + 0x65, 0x79, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x24, 0x82, 0xd3, 0xe4, + 0x93, 0x02, 0x1e, 0x12, 0x1c, 0x2f, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x2f, 0x76, + 0x32, 0x2f, 0x72, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x2f, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, + 0x73, 0x12, 0x83, 0x01, 0x0a, 0x04, 0x53, 0x69, 0x67, 0x6e, 0x12, 0x2b, 0x2e, 0x65, 0x74, 0x68, + 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x2e, + 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x2e, 0x76, 0x32, 0x2e, 0x53, 0x69, 0x67, 0x6e, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2c, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, + 0x75, 0x6d, 0x2e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x2e, 0x61, 0x63, 0x63, + 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x2e, 0x76, 0x32, 0x2e, 0x53, 0x69, 0x67, 0x6e, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x20, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x1a, 0x22, 0x18, 0x2f, + 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x2f, 0x76, 0x32, 0x2f, 0x72, 0x65, 0x6d, 0x6f, + 0x74, 0x65, 0x2f, 0x73, 0x69, 0x67, 0x6e, 0x42, 0xce, 0x01, 0x0a, 0x22, 0x6f, 0x72, 0x67, 0x2e, + 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, + 0x6f, 0x72, 0x2e, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x2e, 0x76, 0x32, 0x42, 0x0f, + 0x4b, 0x65, 0x79, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, + 0x01, 0x5a, 0x53, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x70, 0x72, + 0x79, 0x73, 0x6d, 0x61, 0x74, 0x69, 0x63, 0x6c, 0x61, 0x62, 0x73, 0x2f, 0x70, 0x72, 0x79, 0x73, + 0x6d, 0x2f, 0x76, 0x34, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d, + 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, + 0x74, 0x6f, 0x72, 0x2d, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x3b, 0x76, 0x61, 0x6c, 0x69, 0x64, + 0x61, 0x74, 0x6f, 0x72, 0x70, 0x62, 0xaa, 0x02, 0x1e, 0x45, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, + 0x6d, 0x2e, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x2e, 0x41, 0x63, 0x63, 0x6f, + 0x75, 0x6e, 0x74, 0x73, 0x2e, 0x56, 0x32, 0xca, 0x02, 0x1e, 0x45, 0x74, 0x68, 0x65, 0x72, 0x65, + 0x75, 0x6d, 0x5c, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x5c, 0x41, 0x63, 0x63, + 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x5c, 0x56, 0x32, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -668,49 +883,57 @@ func file_proto_prysm_v1alpha1_validator_client_keymanager_proto_rawDescGZIP() [ } var file_proto_prysm_v1alpha1_validator_client_keymanager_proto_enumTypes = make([]protoimpl.EnumInfo, 1) -var file_proto_prysm_v1alpha1_validator_client_keymanager_proto_msgTypes = make([]protoimpl.MessageInfo, 3) +var file_proto_prysm_v1alpha1_validator_client_keymanager_proto_msgTypes = make([]protoimpl.MessageInfo, 7) var file_proto_prysm_v1alpha1_validator_client_keymanager_proto_goTypes = []interface{}{ (SignResponse_Status)(0), // 0: ethereum.validator.accounts.v2.SignResponse.Status (*ListPublicKeysResponse)(nil), // 1: ethereum.validator.accounts.v2.ListPublicKeysResponse (*SignRequest)(nil), // 2: ethereum.validator.accounts.v2.SignRequest (*SignResponse)(nil), // 3: ethereum.validator.accounts.v2.SignResponse - (*v1alpha1.BeaconBlock)(nil), // 4: ethereum.eth.v1alpha1.BeaconBlock - (*v1alpha1.AttestationData)(nil), // 5: ethereum.eth.v1alpha1.AttestationData - (*v1alpha1.AggregateAttestationAndProof)(nil), // 6: ethereum.eth.v1alpha1.AggregateAttestationAndProof - (*v1alpha1.VoluntaryExit)(nil), // 7: ethereum.eth.v1alpha1.VoluntaryExit - (*v1alpha1.BeaconBlockAltair)(nil), // 8: ethereum.eth.v1alpha1.BeaconBlockAltair - (*v1alpha1.SyncAggregatorSelectionData)(nil), // 9: ethereum.eth.v1alpha1.SyncAggregatorSelectionData - (*v1alpha1.ContributionAndProof)(nil), // 10: ethereum.eth.v1alpha1.ContributionAndProof - (*v1alpha1.BeaconBlockBellatrix)(nil), // 11: ethereum.eth.v1alpha1.BeaconBlockBellatrix - (*v1alpha1.BlindedBeaconBlockBellatrix)(nil), // 12: ethereum.eth.v1alpha1.BlindedBeaconBlockBellatrix - (*v1alpha1.ValidatorRegistrationV1)(nil), // 13: ethereum.eth.v1alpha1.ValidatorRegistrationV1 - (*v1alpha1.BeaconBlockCapella)(nil), // 14: ethereum.eth.v1alpha1.BeaconBlockCapella - (*v1alpha1.BlindedBeaconBlockCapella)(nil), // 15: ethereum.eth.v1alpha1.BlindedBeaconBlockCapella - (*empty.Empty)(nil), // 16: google.protobuf.Empty + (*ProposerOptionPayload)(nil), // 4: ethereum.validator.accounts.v2.ProposerOptionPayload + (*BuilderConfig)(nil), // 5: ethereum.validator.accounts.v2.BuilderConfig + (*ProposerSettingsPayload)(nil), // 6: ethereum.validator.accounts.v2.ProposerSettingsPayload + nil, // 7: ethereum.validator.accounts.v2.ProposerSettingsPayload.ProposerConfigEntry + (*v1alpha1.BeaconBlock)(nil), // 8: ethereum.eth.v1alpha1.BeaconBlock + (*v1alpha1.AttestationData)(nil), // 9: ethereum.eth.v1alpha1.AttestationData + (*v1alpha1.AggregateAttestationAndProof)(nil), // 10: ethereum.eth.v1alpha1.AggregateAttestationAndProof + (*v1alpha1.VoluntaryExit)(nil), // 11: ethereum.eth.v1alpha1.VoluntaryExit + (*v1alpha1.BeaconBlockAltair)(nil), // 12: ethereum.eth.v1alpha1.BeaconBlockAltair + (*v1alpha1.SyncAggregatorSelectionData)(nil), // 13: ethereum.eth.v1alpha1.SyncAggregatorSelectionData + (*v1alpha1.ContributionAndProof)(nil), // 14: ethereum.eth.v1alpha1.ContributionAndProof + (*v1alpha1.BeaconBlockBellatrix)(nil), // 15: ethereum.eth.v1alpha1.BeaconBlockBellatrix + (*v1alpha1.BlindedBeaconBlockBellatrix)(nil), // 16: ethereum.eth.v1alpha1.BlindedBeaconBlockBellatrix + (*v1alpha1.ValidatorRegistrationV1)(nil), // 17: ethereum.eth.v1alpha1.ValidatorRegistrationV1 + (*v1alpha1.BeaconBlockCapella)(nil), // 18: ethereum.eth.v1alpha1.BeaconBlockCapella + (*v1alpha1.BlindedBeaconBlockCapella)(nil), // 19: ethereum.eth.v1alpha1.BlindedBeaconBlockCapella + (*empty.Empty)(nil), // 20: google.protobuf.Empty } var file_proto_prysm_v1alpha1_validator_client_keymanager_proto_depIdxs = []int32{ - 4, // 0: ethereum.validator.accounts.v2.SignRequest.block:type_name -> ethereum.eth.v1alpha1.BeaconBlock - 5, // 1: ethereum.validator.accounts.v2.SignRequest.attestation_data:type_name -> ethereum.eth.v1alpha1.AttestationData - 6, // 2: ethereum.validator.accounts.v2.SignRequest.aggregate_attestation_and_proof:type_name -> ethereum.eth.v1alpha1.AggregateAttestationAndProof - 7, // 3: ethereum.validator.accounts.v2.SignRequest.exit:type_name -> ethereum.eth.v1alpha1.VoluntaryExit - 8, // 4: ethereum.validator.accounts.v2.SignRequest.block_altair:type_name -> ethereum.eth.v1alpha1.BeaconBlockAltair - 9, // 5: ethereum.validator.accounts.v2.SignRequest.sync_aggregator_selection_data:type_name -> ethereum.eth.v1alpha1.SyncAggregatorSelectionData - 10, // 6: ethereum.validator.accounts.v2.SignRequest.contribution_and_proof:type_name -> ethereum.eth.v1alpha1.ContributionAndProof - 11, // 7: ethereum.validator.accounts.v2.SignRequest.block_bellatrix:type_name -> ethereum.eth.v1alpha1.BeaconBlockBellatrix - 12, // 8: ethereum.validator.accounts.v2.SignRequest.blinded_block_bellatrix:type_name -> ethereum.eth.v1alpha1.BlindedBeaconBlockBellatrix - 13, // 9: ethereum.validator.accounts.v2.SignRequest.registration:type_name -> ethereum.eth.v1alpha1.ValidatorRegistrationV1 - 14, // 10: ethereum.validator.accounts.v2.SignRequest.block_capella:type_name -> ethereum.eth.v1alpha1.BeaconBlockCapella - 15, // 11: ethereum.validator.accounts.v2.SignRequest.blinded_block_capella:type_name -> ethereum.eth.v1alpha1.BlindedBeaconBlockCapella + 8, // 0: ethereum.validator.accounts.v2.SignRequest.block:type_name -> ethereum.eth.v1alpha1.BeaconBlock + 9, // 1: ethereum.validator.accounts.v2.SignRequest.attestation_data:type_name -> ethereum.eth.v1alpha1.AttestationData + 10, // 2: ethereum.validator.accounts.v2.SignRequest.aggregate_attestation_and_proof:type_name -> ethereum.eth.v1alpha1.AggregateAttestationAndProof + 11, // 3: ethereum.validator.accounts.v2.SignRequest.exit:type_name -> ethereum.eth.v1alpha1.VoluntaryExit + 12, // 4: ethereum.validator.accounts.v2.SignRequest.block_altair:type_name -> ethereum.eth.v1alpha1.BeaconBlockAltair + 13, // 5: ethereum.validator.accounts.v2.SignRequest.sync_aggregator_selection_data:type_name -> ethereum.eth.v1alpha1.SyncAggregatorSelectionData + 14, // 6: ethereum.validator.accounts.v2.SignRequest.contribution_and_proof:type_name -> ethereum.eth.v1alpha1.ContributionAndProof + 15, // 7: ethereum.validator.accounts.v2.SignRequest.block_bellatrix:type_name -> ethereum.eth.v1alpha1.BeaconBlockBellatrix + 16, // 8: ethereum.validator.accounts.v2.SignRequest.blinded_block_bellatrix:type_name -> ethereum.eth.v1alpha1.BlindedBeaconBlockBellatrix + 17, // 9: ethereum.validator.accounts.v2.SignRequest.registration:type_name -> ethereum.eth.v1alpha1.ValidatorRegistrationV1 + 18, // 10: ethereum.validator.accounts.v2.SignRequest.block_capella:type_name -> ethereum.eth.v1alpha1.BeaconBlockCapella + 19, // 11: ethereum.validator.accounts.v2.SignRequest.blinded_block_capella:type_name -> ethereum.eth.v1alpha1.BlindedBeaconBlockCapella 0, // 12: ethereum.validator.accounts.v2.SignResponse.status:type_name -> ethereum.validator.accounts.v2.SignResponse.Status - 16, // 13: ethereum.validator.accounts.v2.RemoteSigner.ListValidatingPublicKeys:input_type -> google.protobuf.Empty - 2, // 14: ethereum.validator.accounts.v2.RemoteSigner.Sign:input_type -> ethereum.validator.accounts.v2.SignRequest - 1, // 15: ethereum.validator.accounts.v2.RemoteSigner.ListValidatingPublicKeys:output_type -> ethereum.validator.accounts.v2.ListPublicKeysResponse - 3, // 16: ethereum.validator.accounts.v2.RemoteSigner.Sign:output_type -> ethereum.validator.accounts.v2.SignResponse - 15, // [15:17] is the sub-list for method output_type - 13, // [13:15] is the sub-list for method input_type - 13, // [13:13] is the sub-list for extension type_name - 13, // [13:13] is the sub-list for extension extendee - 0, // [0:13] is the sub-list for field type_name + 5, // 13: ethereum.validator.accounts.v2.ProposerOptionPayload.builder:type_name -> ethereum.validator.accounts.v2.BuilderConfig + 7, // 14: ethereum.validator.accounts.v2.ProposerSettingsPayload.proposer_config:type_name -> ethereum.validator.accounts.v2.ProposerSettingsPayload.ProposerConfigEntry + 4, // 15: ethereum.validator.accounts.v2.ProposerSettingsPayload.default_config:type_name -> ethereum.validator.accounts.v2.ProposerOptionPayload + 4, // 16: ethereum.validator.accounts.v2.ProposerSettingsPayload.ProposerConfigEntry.value:type_name -> ethereum.validator.accounts.v2.ProposerOptionPayload + 20, // 17: ethereum.validator.accounts.v2.RemoteSigner.ListValidatingPublicKeys:input_type -> google.protobuf.Empty + 2, // 18: ethereum.validator.accounts.v2.RemoteSigner.Sign:input_type -> ethereum.validator.accounts.v2.SignRequest + 1, // 19: ethereum.validator.accounts.v2.RemoteSigner.ListValidatingPublicKeys:output_type -> ethereum.validator.accounts.v2.ListPublicKeysResponse + 3, // 20: ethereum.validator.accounts.v2.RemoteSigner.Sign:output_type -> ethereum.validator.accounts.v2.SignResponse + 19, // [19:21] is the sub-list for method output_type + 17, // [17:19] is the sub-list for method input_type + 17, // [17:17] is the sub-list for extension type_name + 17, // [17:17] is the sub-list for extension extendee + 0, // [0:17] is the sub-list for field type_name } func init() { file_proto_prysm_v1alpha1_validator_client_keymanager_proto_init() } @@ -755,6 +978,42 @@ func file_proto_prysm_v1alpha1_validator_client_keymanager_proto_init() { return nil } } + file_proto_prysm_v1alpha1_validator_client_keymanager_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ProposerOptionPayload); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_proto_prysm_v1alpha1_validator_client_keymanager_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*BuilderConfig); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_proto_prysm_v1alpha1_validator_client_keymanager_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ProposerSettingsPayload); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } } file_proto_prysm_v1alpha1_validator_client_keymanager_proto_msgTypes[1].OneofWrappers = []interface{}{ (*SignRequest_Block)(nil), @@ -779,7 +1038,7 @@ func file_proto_prysm_v1alpha1_validator_client_keymanager_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_proto_prysm_v1alpha1_validator_client_keymanager_proto_rawDesc, NumEnums: 1, - NumMessages: 3, + NumMessages: 7, NumExtensions: 0, NumServices: 1, }, diff --git a/proto/prysm/v1alpha1/validator-client/keymanager.proto b/proto/prysm/v1alpha1/validator-client/keymanager.proto index 135a3789cfbc..c7d41e932a4d 100644 --- a/proto/prysm/v1alpha1/validator-client/keymanager.proto +++ b/proto/prysm/v1alpha1/validator-client/keymanager.proto @@ -107,3 +107,19 @@ message SignResponse { // same conventions. Status status = 2; } + +message ProposerOptionPayload { + string fee_recipient = 1; + BuilderConfig builder = 2; +} + +message BuilderConfig { + bool enabled = 1; + uint64 gas_limit = 2 [(ethereum.eth.ext.cast_type) = "github.com/prysmaticlabs/prysm/v4/consensus-types/validator.Uint64"]; + repeated string relays = 3; +} + +message ProposerSettingsPayload { + map proposer_config = 1; + ProposerOptionPayload default_config = 2; +} \ No newline at end of file diff --git a/validator/db/kv/BUILD.bazel b/validator/db/kv/BUILD.bazel index 777664d448f4..c6166753e495 100644 --- a/validator/db/kv/BUILD.bazel +++ b/validator/db/kv/BUILD.bazel @@ -38,6 +38,7 @@ go_library( "//monitoring/tracing:go_default_library", "//proto/prysm/v1alpha1:go_default_library", "//proto/prysm/v1alpha1/slashings:go_default_library", + "//proto/prysm/v1alpha1/validator-client:go_default_library", "//time/slots:go_default_library", "@com_github_pkg_errors//:go_default_library", "@com_github_prometheus_client_golang//prometheus:go_default_library", diff --git a/validator/db/kv/proposer_settings.go b/validator/db/kv/proposer_settings.go index 9d7394568036..d94815b605d3 100644 --- a/validator/db/kv/proposer_settings.go +++ b/validator/db/kv/proposer_settings.go @@ -8,6 +8,7 @@ import ( "github.com/pkg/errors" fieldparams "github.com/prysmaticlabs/prysm/v4/config/fieldparams" validatorServiceConfig "github.com/prysmaticlabs/prysm/v4/config/validator/service" + validatorpb "github.com/prysmaticlabs/prysm/v4/proto/prysm/v1alpha1/validator-client" bolt "go.etcd.io/bbolt" "go.opencensus.io/trace" ) @@ -24,11 +25,11 @@ func (s *Store) UpdateProposerSettingsForPubkey(ctx context.Context, pubkey [fie if len(b) != 0 { return fmt.Errorf("no proposer settings found in bucket") } - to := &validatorServiceConfig.ProposerSettingsPayload{} + to := &validatorpb.ProposerSettingsPayload{} if err := json.Unmarshal(b, to); err != nil { return errors.Wrap(err, "failed to unmarshal proposer settings") } - settings, err := to.ToSettings() + settings, err := validatorServiceConfig.ToSettings(to) if err != nil { return errors.Wrap(err, "failed to convert payload to proposer settings") } @@ -61,11 +62,11 @@ func (s *Store) UpdateProposerSettingsDefault(ctx context.Context, options *vali if len(b) == 0 { return NoProposerSettingsFound } - to := &validatorServiceConfig.ProposerSettingsPayload{} + to := &validatorpb.ProposerSettingsPayload{} if err := json.Unmarshal(b, to); err != nil { return errors.Wrap(err, "failed to unmarshal proposer settings") } - settings, err := to.ToSettings() + settings, err := validatorServiceConfig.ToSettings(to) if err != nil { return errors.Wrap(err, "failed to convert payload to proposer settings") } @@ -83,7 +84,7 @@ func (s *Store) UpdateProposerSettingsDefault(ctx context.Context, options *vali func (s *Store) ProposerSettings(ctx context.Context) (*validatorServiceConfig.ProposerSettings, error) { _, span := trace.StartSpan(ctx, "validator.db.ProposerSettings") defer span.End() - to := &validatorServiceConfig.ProposerSettingsPayload{} + to := &validatorpb.ProposerSettingsPayload{} if err := s.db.View(func(tx *bolt.Tx) error { bkt := tx.Bucket(proposerSettingsBucket) b := bkt.Get(proposerSettingsKey) @@ -97,7 +98,7 @@ func (s *Store) ProposerSettings(ctx context.Context) (*validatorServiceConfig.P }); err != nil { return nil, err } - return to.ToSettings() + return validatorServiceConfig.ToSettings(to) } // ProposerSettingsExists returns true or false if the settings exist or not diff --git a/validator/node/BUILD.bazel b/validator/node/BUILD.bazel index b9ad63e264e6..c5cce69b22fd 100644 --- a/validator/node/BUILD.bazel +++ b/validator/node/BUILD.bazel @@ -11,6 +11,7 @@ go_test( "//config/fieldparams:go_default_library", "//config/params:go_default_library", "//config/validator/service:go_default_library", + "//consensus-types/validator:go_default_library", "//encoding/bytesutil:go_default_library", "//testing/assert:go_default_library", "//testing/require:go_default_library", @@ -46,6 +47,7 @@ go_library( "//config/fieldparams:go_default_library", "//config/params:go_default_library", "//config/validator/service:go_default_library", + "//consensus-types/validator:go_default_library", "//container/slice:go_default_library", "//encoding/bytesutil:go_default_library", "//io/file:go_default_library", @@ -77,7 +79,7 @@ go_library( "@com_github_prysmaticlabs_fastssz//:go_default_library", "@com_github_sirupsen_logrus//:go_default_library", "@com_github_urfave_cli_v2//:go_default_library", - "@in_gopkg_yaml_v2//:go_default_library", + "@io_k8s_apimachinery//pkg/util/yaml:go_default_library", "@org_golang_google_protobuf//encoding/protojson:go_default_library", ], ) diff --git a/validator/node/node.go b/validator/node/node.go index ac6a4b15ab76..a44d92f0f112 100644 --- a/validator/node/node.go +++ b/validator/node/node.go @@ -35,6 +35,7 @@ import ( fieldparams "github.com/prysmaticlabs/prysm/v4/config/fieldparams" "github.com/prysmaticlabs/prysm/v4/config/params" validatorServiceConfig "github.com/prysmaticlabs/prysm/v4/config/validator/service" + "github.com/prysmaticlabs/prysm/v4/consensus-types/validator" "github.com/prysmaticlabs/prysm/v4/container/slice" "github.com/prysmaticlabs/prysm/v4/encoding/bytesutil" "github.com/prysmaticlabs/prysm/v4/io/file" @@ -61,7 +62,7 @@ import ( "github.com/sirupsen/logrus" "github.com/urfave/cli/v2" "google.golang.org/protobuf/encoding/protojson" - "gopkg.in/yaml.v2" + "k8s.io/apimachinery/pkg/util/yaml" ) // ValidatorClient defines an instance of an Ethereum validator that manages @@ -490,7 +491,7 @@ func Web3SignerConfig(cliCtx *cli.Context) (*remoteweb3signer.SetupConfig, error } func proposerSettings(cliCtx *cli.Context, db iface.ValidatorDB) (*validatorServiceConfig.ProposerSettings, error) { - var fileConfig *validatorServiceConfig.ProposerSettingsPayload + var fileConfig *validatorpb.ProposerSettingsPayload if cliCtx.IsSet(flags.ProposerSettingsFlag.Name) && cliCtx.IsSet(flags.ProposerSettingsURLFlag.Name) { return nil, errors.New("cannot specify both " + flags.ProposerSettingsFlag.Name + " and " + flags.ProposerSettingsURLFlag.Name) @@ -505,11 +506,11 @@ func proposerSettings(cliCtx *cli.Context, db iface.ValidatorDB) (*validatorServ if err != nil { return nil, err } - fileConfig = &validatorServiceConfig.ProposerSettingsPayload{ + fileConfig = &validatorpb.ProposerSettingsPayload{ ProposerConfig: nil, - DefaultConfig: &validatorServiceConfig.ProposerOptionPayload{ - FeeRecipient: suggestedFee, - BuilderConfig: builderConfig, + DefaultConfig: &validatorpb.ProposerOptionPayload{ + FeeRecipient: suggestedFee, + Builder: builderConfig.ToPayload(), }, } } @@ -553,7 +554,7 @@ func proposerSettings(cliCtx *cli.Context, db iface.ValidatorDB) (*validatorServ FeeRecipientConfig: &validatorServiceConfig.FeeRecipientConfig{ FeeRecipient: common.HexToAddress(fileConfig.DefaultConfig.FeeRecipient), }, - BuilderConfig: fileConfig.DefaultConfig.BuilderConfig, + BuilderConfig: validatorServiceConfig.ToBuilderConfig(fileConfig.DefaultConfig.Builder), } if vpSettings.DefaultConfig.BuilderConfig == nil { builderConfig, err := BuilderSettingsFromFlags(cliCtx) @@ -592,20 +593,20 @@ func proposerSettings(cliCtx *cli.Context, db iface.ValidatorDB) (*validatorServ if err := warnNonChecksummedAddress(option.FeeRecipient); err != nil { return nil, err } - if option.BuilderConfig != nil { - option.BuilderConfig.GasLimit = reviewGasLimit(option.BuilderConfig.GasLimit) + if option.Builder != nil { + option.Builder.GasLimit = reviewGasLimit(option.Builder.GasLimit) } else { builderConfig, err := BuilderSettingsFromFlags(cliCtx) if err != nil { return nil, err } - option.BuilderConfig = builderConfig + option.Builder = builderConfig.ToPayload() } o := &validatorServiceConfig.ProposerOption{ FeeRecipientConfig: &validatorServiceConfig.FeeRecipientConfig{ FeeRecipient: common.HexToAddress(option.FeeRecipient), }, - BuilderConfig: option.BuilderConfig, + BuilderConfig: validatorServiceConfig.ToBuilderConfig(option.Builder), } pubkeyB := bytesutil.ToBytes48(decodedKey) if psExists { @@ -626,7 +627,7 @@ func proposerSettings(cliCtx *cli.Context, db iface.ValidatorDB) (*validatorServ func BuilderSettingsFromFlags(cliCtx *cli.Context) (*validatorServiceConfig.BuilderConfig, error) { if cliCtx.Bool(flags.EnableBuilderFlag.Name) { - gasLimit := validatorServiceConfig.Uint64(params.BeaconConfig().DefaultBuilderGasLimit) + gasLimit := validator.Uint64(params.BeaconConfig().DefaultBuilderGasLimit) sgl := cliCtx.String(flags.BuilderGasLimitFlag.Name) if sgl != "" { @@ -634,7 +635,7 @@ func BuilderSettingsFromFlags(cliCtx *cli.Context) (*validatorServiceConfig.Buil if err != nil { return nil, errors.New("Gas Limit is not a uint64") } - gasLimit = reviewGasLimit(validatorServiceConfig.Uint64(gl)) + gasLimit = reviewGasLimit(validator.Uint64(gl)) } return &validatorServiceConfig.BuilderConfig{ Enabled: true, @@ -658,10 +659,10 @@ func warnNonChecksummedAddress(feeRecipient string) error { return nil } -func reviewGasLimit(gasLimit validatorServiceConfig.Uint64) validatorServiceConfig.Uint64 { +func reviewGasLimit(gasLimit validator.Uint64) validator.Uint64 { // sets gas limit to default if not defined or set to 0 if gasLimit == 0 { - return validatorServiceConfig.Uint64(params.BeaconConfig().DefaultBuilderGasLimit) + return validator.Uint64(params.BeaconConfig().DefaultBuilderGasLimit) } // TODO(10810): add in warning for ranges return gasLimit diff --git a/validator/node/node_test.go b/validator/node/node_test.go index c03b365a64f4..c35245046e87 100644 --- a/validator/node/node_test.go +++ b/validator/node/node_test.go @@ -16,6 +16,7 @@ import ( fieldparams "github.com/prysmaticlabs/prysm/v4/config/fieldparams" "github.com/prysmaticlabs/prysm/v4/config/params" validatorserviceconfig "github.com/prysmaticlabs/prysm/v4/config/validator/service" + "github.com/prysmaticlabs/prysm/v4/consensus-types/validator" "github.com/prysmaticlabs/prysm/v4/encoding/bytesutil" "github.com/prysmaticlabs/prysm/v4/testing/assert" "github.com/prysmaticlabs/prysm/v4/testing/require" @@ -280,7 +281,7 @@ func TestProposerSettings(t *testing.T) { }, BuilderConfig: &validatorserviceconfig.BuilderConfig{ Enabled: true, - GasLimit: validatorserviceconfig.Uint64(params.BeaconConfig().DefaultBuilderGasLimit), + GasLimit: validator.Uint64(params.BeaconConfig().DefaultBuilderGasLimit), }, }, bytesutil.ToBytes48(key2): { @@ -289,7 +290,7 @@ func TestProposerSettings(t *testing.T) { }, BuilderConfig: &validatorserviceconfig.BuilderConfig{ Enabled: true, - GasLimit: validatorserviceconfig.Uint64(35000000), + GasLimit: validator.Uint64(35000000), }, }, }, @@ -299,7 +300,7 @@ func TestProposerSettings(t *testing.T) { }, BuilderConfig: &validatorserviceconfig.BuilderConfig{ Enabled: true, - GasLimit: validatorserviceconfig.Uint64(40000000), + GasLimit: validator.Uint64(40000000), }, }, } @@ -365,7 +366,7 @@ func TestProposerSettings(t *testing.T) { }, BuilderConfig: &validatorserviceconfig.BuilderConfig{ Enabled: false, - GasLimit: validatorserviceconfig.Uint64(params.BeaconConfig().DefaultBuilderGasLimit), + GasLimit: validator.Uint64(params.BeaconConfig().DefaultBuilderGasLimit), }, }, } @@ -411,7 +412,7 @@ func TestProposerSettings(t *testing.T) { }, BuilderConfig: &validatorserviceconfig.BuilderConfig{ Enabled: true, - GasLimit: validatorserviceconfig.Uint64(params.BeaconConfig().DefaultBuilderGasLimit), + GasLimit: validator.Uint64(params.BeaconConfig().DefaultBuilderGasLimit), }, }, } @@ -495,7 +496,7 @@ func TestProposerSettings(t *testing.T) { }, BuilderConfig: &validatorserviceconfig.BuilderConfig{ Enabled: true, - GasLimit: validatorserviceconfig.Uint64(params.BeaconConfig().DefaultBuilderGasLimit), + GasLimit: validator.Uint64(params.BeaconConfig().DefaultBuilderGasLimit), }, }, }, @@ -505,7 +506,7 @@ func TestProposerSettings(t *testing.T) { }, BuilderConfig: &validatorserviceconfig.BuilderConfig{ Enabled: true, - GasLimit: validatorserviceconfig.Uint64(params.BeaconConfig().DefaultBuilderGasLimit), + GasLimit: validator.Uint64(params.BeaconConfig().DefaultBuilderGasLimit), }, }, } @@ -533,7 +534,7 @@ func TestProposerSettings(t *testing.T) { }, BuilderConfig: &validatorserviceconfig.BuilderConfig{ Enabled: true, - GasLimit: validatorserviceconfig.Uint64(params.BeaconConfig().DefaultBuilderGasLimit), + GasLimit: validator.Uint64(params.BeaconConfig().DefaultBuilderGasLimit), }, }, }, @@ -543,7 +544,7 @@ func TestProposerSettings(t *testing.T) { }, BuilderConfig: &validatorserviceconfig.BuilderConfig{ Enabled: true, - GasLimit: validatorserviceconfig.Uint64(params.BeaconConfig().DefaultBuilderGasLimit), + GasLimit: validator.Uint64(params.BeaconConfig().DefaultBuilderGasLimit), }, }, } @@ -570,7 +571,7 @@ func TestProposerSettings(t *testing.T) { }, BuilderConfig: &validatorserviceconfig.BuilderConfig{ Enabled: true, - GasLimit: validatorserviceconfig.Uint64(40000000), + GasLimit: validator.Uint64(40000000), }, }, }, @@ -580,7 +581,7 @@ func TestProposerSettings(t *testing.T) { }, BuilderConfig: &validatorserviceconfig.BuilderConfig{ Enabled: false, - GasLimit: validatorserviceconfig.Uint64(params.BeaconConfig().DefaultBuilderGasLimit), + GasLimit: validator.Uint64(params.BeaconConfig().DefaultBuilderGasLimit), }, }, } diff --git a/validator/rpc/BUILD.bazel b/validator/rpc/BUILD.bazel index a14f010bf470..d596a87b6bc9 100644 --- a/validator/rpc/BUILD.bazel +++ b/validator/rpc/BUILD.bazel @@ -28,6 +28,7 @@ go_library( "//config/fieldparams:go_default_library", "//config/params:go_default_library", "//config/validator/service:go_default_library", + "//consensus-types/validator:go_default_library", "//crypto/bls:go_default_library", "//crypto/rand:go_default_library", "//encoding/bytesutil:go_default_library", diff --git a/validator/rpc/standard_api.go b/validator/rpc/standard_api.go index 632003f6889e..dccc22897ae9 100644 --- a/validator/rpc/standard_api.go +++ b/validator/rpc/standard_api.go @@ -12,6 +12,7 @@ import ( fieldparams "github.com/prysmaticlabs/prysm/v4/config/fieldparams" "github.com/prysmaticlabs/prysm/v4/config/params" validatorServiceConfig "github.com/prysmaticlabs/prysm/v4/config/validator/service" + "github.com/prysmaticlabs/prysm/v4/consensus-types/validator" "github.com/prysmaticlabs/prysm/v4/encoding/bytesutil" ethpbservice "github.com/prysmaticlabs/prysm/v4/proto/eth/service" eth "github.com/prysmaticlabs/prysm/v4/proto/prysm/v1alpha1" @@ -439,7 +440,7 @@ func (s *Server) SetGasLimit(ctx context.Context, req *ethpbservice.SetGasLimitR } settings.ProposeConfig = make(map[[fieldparams.BLSPubkeyLength]byte]*validatorServiceConfig.ProposerOption) option := settings.DefaultConfig.Clone() - option.BuilderConfig.GasLimit = validatorServiceConfig.Uint64(req.GasLimit) + option.BuilderConfig.GasLimit = validator.Uint64(req.GasLimit) settings.ProposeConfig[bytesutil.ToBytes48(validatorKey)] = option } else { proposerOption, found := settings.ProposeConfig[bytesutil.ToBytes48(validatorKey)] @@ -447,14 +448,14 @@ func (s *Server) SetGasLimit(ctx context.Context, req *ethpbservice.SetGasLimitR if proposerOption.BuilderConfig == nil || !proposerOption.BuilderConfig.Enabled { return &empty.Empty{}, status.Errorf(codes.FailedPrecondition, "gas limit changes only apply when builder is enabled") } else { - proposerOption.BuilderConfig.GasLimit = validatorServiceConfig.Uint64(req.GasLimit) + proposerOption.BuilderConfig.GasLimit = validator.Uint64(req.GasLimit) } } else { if settings.DefaultConfig == nil { return &empty.Empty{}, status.Errorf(codes.FailedPrecondition, "gas limit changes only apply when builder is enabled") } option := settings.DefaultConfig.Clone() - option.BuilderConfig.GasLimit = validatorServiceConfig.Uint64(req.GasLimit) + option.BuilderConfig.GasLimit = validator.Uint64(req.GasLimit) settings.ProposeConfig[bytesutil.ToBytes48(validatorKey)] = option } } @@ -488,7 +489,7 @@ func (s *Server) DeleteGasLimit(ctx context.Context, req *ethpbservice.DeleteGas proposerOption.BuilderConfig.GasLimit = proposerSettings.DefaultConfig.BuilderConfig.GasLimit } else { // Fallback to using global default. - proposerOption.BuilderConfig.GasLimit = validatorServiceConfig.Uint64(params.BeaconConfig().DefaultBuilderGasLimit) + proposerOption.BuilderConfig.GasLimit = validator.Uint64(params.BeaconConfig().DefaultBuilderGasLimit) } // save the settings if err := s.validatorService.SetProposerSettings(ctx, proposerSettings); err != nil { From 9af83d560304e0501b0e850242032206462e7f07 Mon Sep 17 00:00:00 2001 From: james-prysm Date: Fri, 5 May 2023 16:28:14 -0500 Subject: [PATCH 18/33] fixing e2e --- config/validator/service/proposer-settings.go | 23 ++-- testing/endtoend/components/validator.go | 18 ++-- validator/db/kv/BUILD.bazel | 5 + validator/db/kv/proposer_settings.go | 16 +-- validator/db/kv/proposer_settings_test.go | 100 +++++++++++++++++- validator/rpc/BUILD.bazel | 1 + validator/rpc/standard_api_test.go | 25 ++--- 7 files changed, 146 insertions(+), 42 deletions(-) diff --git a/config/validator/service/proposer-settings.go b/config/validator/service/proposer-settings.go index d0b666947028..a87d2bbd5dfb 100644 --- a/config/validator/service/proposer-settings.go +++ b/config/validator/service/proposer-settings.go @@ -85,18 +85,19 @@ func (ps *ProposerSettings) ToPayload() *validatorpb.ProposerSettingsPayload { if ps == nil { return nil } - payload := &validatorpb.ProposerSettingsPayload{ - ProposerConfig: make(map[string]*validatorpb.ProposerOptionPayload), - } - for key, option := range ps.ProposeConfig { - p := &validatorpb.ProposerOptionPayload{} - if option.FeeRecipientConfig != nil { - p.FeeRecipient = option.FeeRecipientConfig.FeeRecipient.Hex() - } - if option.BuilderConfig != nil { - p.Builder = option.BuilderConfig.ToPayload() + payload := &validatorpb.ProposerSettingsPayload{} + if ps.ProposeConfig != nil { + payload.ProposerConfig = make(map[string]*validatorpb.ProposerOptionPayload) + for key, option := range ps.ProposeConfig { + p := &validatorpb.ProposerOptionPayload{} + if option.FeeRecipientConfig != nil { + p.FeeRecipient = option.FeeRecipientConfig.FeeRecipient.Hex() + } + if option.BuilderConfig != nil { + p.Builder = option.BuilderConfig.ToPayload() + } + payload.ProposerConfig[hexutil.Encode(key[:])] = p } - payload.ProposerConfig[hexutil.Encode(key[:])] = p } if ps.DefaultConfig != nil { p := &validatorpb.ProposerOptionPayload{} diff --git a/testing/endtoend/components/validator.go b/testing/endtoend/components/validator.go index d14121467356..8531f15f58a9 100644 --- a/testing/endtoend/components/validator.go +++ b/testing/endtoend/components/validator.go @@ -2,7 +2,6 @@ package components import ( "context" - "encoding/json" "fmt" "os" "os/exec" @@ -20,12 +19,13 @@ import ( "github.com/prysmaticlabs/prysm/v4/config/features" fieldparams "github.com/prysmaticlabs/prysm/v4/config/fieldparams" "github.com/prysmaticlabs/prysm/v4/config/params" - validator_service_config "github.com/prysmaticlabs/prysm/v4/config/validator/service" "github.com/prysmaticlabs/prysm/v4/io/file" + validatorpb "github.com/prysmaticlabs/prysm/v4/proto/prysm/v1alpha1/validator-client" "github.com/prysmaticlabs/prysm/v4/runtime/interop" "github.com/prysmaticlabs/prysm/v4/testing/endtoend/helpers" e2e "github.com/prysmaticlabs/prysm/v4/testing/endtoend/params" e2etypes "github.com/prysmaticlabs/prysm/v4/testing/endtoend/types" + "google.golang.org/protobuf/proto" ) const DefaultFeeRecipientAddress = "0x099FB65722e7b2455043bfebF6177f1D2E9738d9" @@ -335,28 +335,28 @@ func createProposerSettingsPath(pubkeys []string, nodeIdx int) (string, error) { if len(pubkeys) == 0 { return "", errors.New("number of validators must be greater than 0") } - var proposerSettingsPayload validator_service_config.ProposerSettingsPayload - config := make(map[string]*validator_service_config.ProposerOptionPayload) + var proposerSettingsPayload *validatorpb.ProposerSettingsPayload + config := make(map[string]*validatorpb.ProposerOptionPayload) for i, pubkey := range pubkeys { - config[pubkeys[i]] = &validator_service_config.ProposerOptionPayload{ + config[pubkeys[i]] = &validatorpb.ProposerOptionPayload{ FeeRecipient: FeeRecipientFromPubkey(pubkey), } } - proposerSettingsPayload = validator_service_config.ProposerSettingsPayload{ + proposerSettingsPayload = &validatorpb.ProposerSettingsPayload{ ProposerConfig: config, - DefaultConfig: &validator_service_config.ProposerOptionPayload{ + DefaultConfig: &validatorpb.ProposerOptionPayload{ FeeRecipient: DefaultFeeRecipientAddress, }, } - jsonBytes, err := json.Marshal(proposerSettingsPayload) + protoBytes, err := proto.Marshal(proposerSettingsPayload) if err != nil { return "", err } if err := file.MkdirAll(testNetDir); err != nil { return "", err } - if err := file.WriteFile(configPath, jsonBytes); err != nil { + if err := file.WriteFile(configPath, protoBytes); err != nil { return "", err } return configPath, nil diff --git a/validator/db/kv/BUILD.bazel b/validator/db/kv/BUILD.bazel index c6166753e495..bab488b47e37 100644 --- a/validator/db/kv/BUILD.bazel +++ b/validator/db/kv/BUILD.bazel @@ -46,6 +46,7 @@ go_library( "@com_github_sirupsen_logrus//:go_default_library", "@io_etcd_go_bbolt//:go_default_library", "@io_opencensus_go//trace:go_default_library", + "@org_golang_google_protobuf//proto:go_default_library", ], ) @@ -69,12 +70,16 @@ go_test( deps = [ "//config/fieldparams:go_default_library", "//config/params:go_default_library", + "//config/validator/service:go_default_library", "//consensus-types/primitives:go_default_library", + "//consensus-types/validator:go_default_library", "//crypto/hash:go_default_library", "//encoding/bytesutil:go_default_library", "//proto/prysm/v1alpha1:go_default_library", "//testing/assert:go_default_library", "//testing/require:go_default_library", + "@com_github_ethereum_go_ethereum//common:go_default_library", + "@com_github_ethereum_go_ethereum//common/hexutil:go_default_library", "@com_github_sirupsen_logrus//:go_default_library", "@com_github_sirupsen_logrus//hooks/test:go_default_library", "@io_etcd_go_bbolt//:go_default_library", diff --git a/validator/db/kv/proposer_settings.go b/validator/db/kv/proposer_settings.go index d94815b605d3..e1ebd0222d94 100644 --- a/validator/db/kv/proposer_settings.go +++ b/validator/db/kv/proposer_settings.go @@ -2,7 +2,6 @@ package kv import ( "context" - "encoding/json" "fmt" "github.com/pkg/errors" @@ -11,6 +10,7 @@ import ( validatorpb "github.com/prysmaticlabs/prysm/v4/proto/prysm/v1alpha1/validator-client" bolt "go.etcd.io/bbolt" "go.opencensus.io/trace" + "google.golang.org/protobuf/proto" ) var NoProposerSettingsFound = errors.New("no proposer settings found in bucket") @@ -22,11 +22,11 @@ func (s *Store) UpdateProposerSettingsForPubkey(ctx context.Context, pubkey [fie err := s.db.Update(func(tx *bolt.Tx) error { bkt := tx.Bucket(proposerSettingsBucket) b := bkt.Get(proposerSettingsKey) - if len(b) != 0 { + if len(b) == 0 { return fmt.Errorf("no proposer settings found in bucket") } to := &validatorpb.ProposerSettingsPayload{} - if err := json.Unmarshal(b, to); err != nil { + if err := proto.Unmarshal(b, to); err != nil { return errors.Wrap(err, "failed to unmarshal proposer settings") } settings, err := validatorServiceConfig.ToSettings(to) @@ -37,7 +37,7 @@ func (s *Store) UpdateProposerSettingsForPubkey(ctx context.Context, pubkey [fie settings.ProposeConfig = make(map[[fieldparams.BLSPubkeyLength]byte]*validatorServiceConfig.ProposerOption) } settings.ProposeConfig[pubkey] = options - m, err := json.Marshal(settings.ToPayload()) + m, err := proto.Marshal(settings.ToPayload()) if err != nil { return errors.Wrap(err, "failed to marshal proposer settings") } @@ -63,7 +63,7 @@ func (s *Store) UpdateProposerSettingsDefault(ctx context.Context, options *vali return NoProposerSettingsFound } to := &validatorpb.ProposerSettingsPayload{} - if err := json.Unmarshal(b, to); err != nil { + if err := proto.Unmarshal(b, to); err != nil { return errors.Wrap(err, "failed to unmarshal proposer settings") } settings, err := validatorServiceConfig.ToSettings(to) @@ -71,7 +71,7 @@ func (s *Store) UpdateProposerSettingsDefault(ctx context.Context, options *vali return errors.Wrap(err, "failed to convert payload to proposer settings") } settings.DefaultConfig = options - m, err := json.Marshal(settings.ToPayload()) + m, err := proto.Marshal(settings.ToPayload()) if err != nil { return errors.Wrap(err, "failed to marshal proposer settings") } @@ -91,7 +91,7 @@ func (s *Store) ProposerSettings(ctx context.Context) (*validatorServiceConfig.P if len(b) == 0 { return NoProposerSettingsFound } - if err := json.Unmarshal(b, to); err != nil { + if err := proto.Unmarshal(b, to); err != nil { return errors.Wrap(err, "failed to unmarshal proposer settings") } return nil @@ -122,7 +122,7 @@ func (s *Store) SaveProposerSettings(ctx context.Context, settings *validatorSer defer span.End() return s.db.Update(func(tx *bolt.Tx) error { bkt := tx.Bucket(proposerSettingsBucket) - m, err := json.Marshal(settings.ToPayload()) + m, err := proto.Marshal(settings.ToPayload()) if err != nil { return errors.Wrap(err, "failed to marshal proposer settings") } diff --git a/validator/db/kv/proposer_settings_test.go b/validator/db/kv/proposer_settings_test.go index b70b315e6b59..83901df40129 100644 --- a/validator/db/kv/proposer_settings_test.go +++ b/validator/db/kv/proposer_settings_test.go @@ -1,10 +1,106 @@ package kv import ( + "context" "testing" + + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/common/hexutil" + fieldparams "github.com/prysmaticlabs/prysm/v4/config/fieldparams" + "github.com/prysmaticlabs/prysm/v4/config/params" + validatorServiceConfig "github.com/prysmaticlabs/prysm/v4/config/validator/service" + "github.com/prysmaticlabs/prysm/v4/consensus-types/validator" + "github.com/prysmaticlabs/prysm/v4/encoding/bytesutil" + "github.com/prysmaticlabs/prysm/v4/testing/require" ) func TestStore_ProposerSettings_ReadAndWrite(t *testing.T) { - //ctx := context.Background() - //db := setupDB(t, [][fieldparams.BLSPubkeyLength]byte{}) + t.Run("save to db in full", func(t *testing.T) { + ctx := context.Background() + db := setupDB(t, [][fieldparams.BLSPubkeyLength]byte{}) + key1, err := hexutil.Decode("0xa057816155ad77931185101128655c0191bd0214c201ca48ed887f6c4c6adf334070efcd75140eada5ac83a92506dd7a") + require.NoError(t, err) + settings := &validatorServiceConfig.ProposerSettings{ + ProposeConfig: map[[fieldparams.BLSPubkeyLength]byte]*validatorServiceConfig.ProposerOption{ + bytesutil.ToBytes48(key1): { + FeeRecipientConfig: &validatorServiceConfig.FeeRecipientConfig{ + FeeRecipient: common.HexToAddress("0x50155530FCE8a85ec7055A5F8b2bE214B3DaeFd3"), + }, + BuilderConfig: &validatorServiceConfig.BuilderConfig{ + Enabled: true, + GasLimit: validator.Uint64(40000000), + }, + }, + }, + DefaultConfig: &validatorServiceConfig.ProposerOption{ + FeeRecipientConfig: &validatorServiceConfig.FeeRecipientConfig{ + FeeRecipient: common.HexToAddress("0x6e35733c5af9B61374A128e6F85f553aF09ff89A"), + }, + BuilderConfig: &validatorServiceConfig.BuilderConfig{ + Enabled: false, + GasLimit: validator.Uint64(params.BeaconConfig().DefaultBuilderGasLimit), + }, + }, + } + err = db.SaveProposerSettings(ctx, settings) + require.NoError(t, err) + + dbSettings, err := db.ProposerSettings(ctx) + require.NoError(t, err) + require.DeepEqual(t, settings, dbSettings) + }) + t.Run("update default settings then update at specific key", func(t *testing.T) { + ctx := context.Background() + db := setupDB(t, [][fieldparams.BLSPubkeyLength]byte{}) + key1, err := hexutil.Decode("0xa057816155ad77931185101128655c0191bd0214c201ca48ed887f6c4c6adf334070efcd75140eada5ac83a92506dd7a") + require.NoError(t, err) + settings := &validatorServiceConfig.ProposerSettings{ + DefaultConfig: &validatorServiceConfig.ProposerOption{ + FeeRecipientConfig: &validatorServiceConfig.FeeRecipientConfig{ + FeeRecipient: common.HexToAddress("0x6e35733c5af9B61374A128e6F85f553aF09ff89A"), + }, + BuilderConfig: &validatorServiceConfig.BuilderConfig{ + Enabled: false, + GasLimit: validator.Uint64(params.BeaconConfig().DefaultBuilderGasLimit), + }, + }, + } + err = db.SaveProposerSettings(ctx, settings) + require.NoError(t, err) + upatedDefault := &validatorServiceConfig.ProposerOption{ + FeeRecipientConfig: &validatorServiceConfig.FeeRecipientConfig{ + FeeRecipient: common.HexToAddress("0x9995733c5af9B61374A128e6F85f553aF09ff89B"), + }, + BuilderConfig: &validatorServiceConfig.BuilderConfig{ + Enabled: true, + GasLimit: validator.Uint64(params.BeaconConfig().DefaultBuilderGasLimit), + }, + } + err = db.UpdateProposerSettingsDefault(ctx, upatedDefault) + require.NoError(t, err) + + dbSettings, err := db.ProposerSettings(ctx) + require.NoError(t, err) + require.NotNil(t, dbSettings) + require.DeepEqual(t, dbSettings.DefaultConfig, upatedDefault) + option := &validatorServiceConfig.ProposerOption{ + FeeRecipientConfig: &validatorServiceConfig.FeeRecipientConfig{ + FeeRecipient: common.HexToAddress("0x50155530FCE8a85ec7055A5F8b2bE214B3DaeFd3"), + }, + BuilderConfig: &validatorServiceConfig.BuilderConfig{ + Enabled: true, + GasLimit: validator.Uint64(40000000), + }, + } + err = db.UpdateProposerSettingsForPubkey(ctx, bytesutil.ToBytes48(key1), option) + require.NoError(t, err) + + newSettings, err := db.ProposerSettings(ctx) + require.NoError(t, err) + require.NotNil(t, newSettings) + require.DeepEqual(t, newSettings.DefaultConfig, upatedDefault) + op, ok := newSettings.ProposeConfig[bytesutil.ToBytes48(key1)] + require.Equal(t, ok, true) + require.DeepEqual(t, op, option) + }) } diff --git a/validator/rpc/BUILD.bazel b/validator/rpc/BUILD.bazel index d596a87b6bc9..180a298a2468 100644 --- a/validator/rpc/BUILD.bazel +++ b/validator/rpc/BUILD.bazel @@ -102,6 +102,7 @@ go_test( "//config/fieldparams:go_default_library", "//config/params:go_default_library", "//config/validator/service:go_default_library", + "//consensus-types/validator:go_default_library", "//crypto/bls:go_default_library", "//crypto/rand:go_default_library", "//encoding/bytesutil:go_default_library", diff --git a/validator/rpc/standard_api_test.go b/validator/rpc/standard_api_test.go index a7d82c63a0d1..4453f23d7835 100644 --- a/validator/rpc/standard_api_test.go +++ b/validator/rpc/standard_api_test.go @@ -17,6 +17,7 @@ import ( fieldparams "github.com/prysmaticlabs/prysm/v4/config/fieldparams" "github.com/prysmaticlabs/prysm/v4/config/params" validatorserviceconfig "github.com/prysmaticlabs/prysm/v4/config/validator/service" + "github.com/prysmaticlabs/prysm/v4/consensus-types/validator" "github.com/prysmaticlabs/prysm/v4/crypto/bls" "github.com/prysmaticlabs/prysm/v4/encoding/bytesutil" ethpbservice "github.com/prysmaticlabs/prysm/v4/proto/eth/service" @@ -1416,11 +1417,11 @@ func TestServer_DeleteGasLimit(t *testing.T) { params.BeaconConfig().DefaultBuilderGasLimit = originBeaconChainGasLimit }() - globalDefaultGasLimit := validatorserviceconfig.Uint64(0xbbdd) + globalDefaultGasLimit := validator.Uint64(0xbbdd) type want struct { pubkey []byte - gaslimit validatorserviceconfig.Uint64 + gaslimit validator.Uint64 } tests := []struct { @@ -1436,14 +1437,14 @@ func TestServer_DeleteGasLimit(t *testing.T) { proposerSettings: &validatorserviceconfig.ProposerSettings{ ProposeConfig: map[[48]byte]*validatorserviceconfig.ProposerOption{ bytesutil.ToBytes48(pubkey1): { - BuilderConfig: &validatorserviceconfig.BuilderConfig{GasLimit: validatorserviceconfig.Uint64(987654321)}, + BuilderConfig: &validatorserviceconfig.BuilderConfig{GasLimit: validator.Uint64(987654321)}, }, bytesutil.ToBytes48(pubkey2): { - BuilderConfig: &validatorserviceconfig.BuilderConfig{GasLimit: validatorserviceconfig.Uint64(123456789)}, + BuilderConfig: &validatorserviceconfig.BuilderConfig{GasLimit: validator.Uint64(123456789)}, }, }, DefaultConfig: &validatorserviceconfig.ProposerOption{ - BuilderConfig: &validatorserviceconfig.BuilderConfig{GasLimit: validatorserviceconfig.Uint64(5555)}, + BuilderConfig: &validatorserviceconfig.BuilderConfig{GasLimit: validator.Uint64(5555)}, }, }, wantError: nil, @@ -1451,11 +1452,11 @@ func TestServer_DeleteGasLimit(t *testing.T) { { pubkey: pubkey1, // After deletion, use DefaultConfig.BuilderConfig.GasLimit. - gaslimit: validatorserviceconfig.Uint64(5555), + gaslimit: validator.Uint64(5555), }, { pubkey: pubkey2, - gaslimit: validatorserviceconfig.Uint64(123456789), + gaslimit: validator.Uint64(123456789), }, }, }, @@ -1465,10 +1466,10 @@ func TestServer_DeleteGasLimit(t *testing.T) { proposerSettings: &validatorserviceconfig.ProposerSettings{ ProposeConfig: map[[48]byte]*validatorserviceconfig.ProposerOption{ bytesutil.ToBytes48(pubkey1): { - BuilderConfig: &validatorserviceconfig.BuilderConfig{GasLimit: validatorserviceconfig.Uint64(987654321)}, + BuilderConfig: &validatorserviceconfig.BuilderConfig{GasLimit: validator.Uint64(987654321)}, }, bytesutil.ToBytes48(pubkey2): { - BuilderConfig: &validatorserviceconfig.BuilderConfig{GasLimit: validatorserviceconfig.Uint64(123456789)}, + BuilderConfig: &validatorserviceconfig.BuilderConfig{GasLimit: validator.Uint64(123456789)}, }, }, }, @@ -1481,7 +1482,7 @@ func TestServer_DeleteGasLimit(t *testing.T) { }, { pubkey: pubkey2, - gaslimit: validatorserviceconfig.Uint64(123456789), + gaslimit: validator.Uint64(123456789), }, }, }, @@ -1491,7 +1492,7 @@ func TestServer_DeleteGasLimit(t *testing.T) { proposerSettings: &validatorserviceconfig.ProposerSettings{ ProposeConfig: map[[48]byte]*validatorserviceconfig.ProposerOption{ bytesutil.ToBytes48(pubkey1): { - BuilderConfig: &validatorserviceconfig.BuilderConfig{GasLimit: validatorserviceconfig.Uint64(987654321)}, + BuilderConfig: &validatorserviceconfig.BuilderConfig{GasLimit: validator.Uint64(987654321)}, }, }, }, @@ -1500,7 +1501,7 @@ func TestServer_DeleteGasLimit(t *testing.T) { // pubkey1's gaslimit is unaffected { pubkey: pubkey1, - gaslimit: validatorserviceconfig.Uint64(987654321), + gaslimit: validator.Uint64(987654321), }, }, }, From aef3998b38afd189ca0abda97ce5283133413381 Mon Sep 17 00:00:00 2001 From: james-prysm Date: Fri, 5 May 2023 16:33:24 -0500 Subject: [PATCH 19/33] k8s yaml library is used directly --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 3d707d70060b..583105ce8543 100644 --- a/go.mod +++ b/go.mod @@ -91,6 +91,7 @@ require ( gopkg.in/d4l3k/messagediff.v1 v1.2.1 gopkg.in/yaml.v2 v2.4.0 gopkg.in/yaml.v3 v3.0.1 + k8s.io/apimachinery v0.20.0 k8s.io/client-go v0.20.0 ) @@ -233,7 +234,6 @@ require ( gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect - k8s.io/apimachinery v0.20.0 // indirect lukechampine.com/blake3 v1.1.7 // indirect nhooyr.io/websocket v1.8.7 // indirect sigs.k8s.io/structured-merge-diff/v4 v4.0.2 // indirect From ca80b84111706d358f9af4a180fc1da4a730b888 Mon Sep 17 00:00:00 2001 From: james-prysm Date: Fri, 5 May 2023 16:36:26 -0500 Subject: [PATCH 20/33] fixing linting --- testing/endtoend/components/BUILD.bazel | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/testing/endtoend/components/BUILD.bazel b/testing/endtoend/components/BUILD.bazel index a778d9e9fb93..2acf366de909 100644 --- a/testing/endtoend/components/BUILD.bazel +++ b/testing/endtoend/components/BUILD.bazel @@ -28,9 +28,9 @@ go_library( "//config/features:go_default_library", "//config/fieldparams:go_default_library", "//config/params:go_default_library", - "//config/validator/service:go_default_library", "//crypto/bls:go_default_library", "//io/file:go_default_library", + "//proto/prysm/v1alpha1/validator-client:go_default_library", "//runtime/interop:go_default_library", "//testing/endtoend/helpers:go_default_library", "//testing/endtoend/params:go_default_library", @@ -44,6 +44,7 @@ go_library( "@com_github_wealdtech_go_eth2_wallet_encryptor_keystorev4//:go_default_library", "@in_gopkg_yaml_v2//:go_default_library", "@io_bazel_rules_go//go/tools/bazel:go_default_library", + "@org_golang_google_protobuf//proto:go_default_library", "@org_golang_x_sync//errgroup:go_default_library", ], ) From 250fdf2a84f7124cd0f4a68d4b66cc33cbf5ee08 Mon Sep 17 00:00:00 2001 From: james-prysm Date: Fri, 5 May 2023 17:07:27 -0500 Subject: [PATCH 21/33] fixing broken unit test --- validator/client/BUILD.bazel | 1 + validator/client/validator_test.go | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/validator/client/BUILD.bazel b/validator/client/BUILD.bazel index cc03b50bcfc5..46930c7ac3c2 100644 --- a/validator/client/BUILD.bazel +++ b/validator/client/BUILD.bazel @@ -128,6 +128,7 @@ go_test( "//consensus-types/blocks/testing:go_default_library", "//consensus-types/interfaces:go_default_library", "//consensus-types/primitives:go_default_library", + "//consensus-types/validator:go_default_library", "//crypto/bls:go_default_library", "//crypto/bls/common/mock:go_default_library", "//encoding/bytesutil:go_default_library", diff --git a/validator/client/validator_test.go b/validator/client/validator_test.go index 67922cddb9f7..33559536f3b9 100644 --- a/validator/client/validator_test.go +++ b/validator/client/validator_test.go @@ -22,6 +22,7 @@ import ( "github.com/prysmaticlabs/prysm/v4/config/params" validatorserviceconfig "github.com/prysmaticlabs/prysm/v4/config/validator/service" "github.com/prysmaticlabs/prysm/v4/consensus-types/primitives" + validatorType "github.com/prysmaticlabs/prysm/v4/consensus-types/validator" "github.com/prysmaticlabs/prysm/v4/crypto/bls" blsmock "github.com/prysmaticlabs/prysm/v4/crypto/bls/common/mock" "github.com/prysmaticlabs/prysm/v4/encoding/bytesutil" @@ -1672,7 +1673,7 @@ func TestValidator_PushProposerSettings(t *testing.T) { }, BuilderConfig: &validatorserviceconfig.BuilderConfig{ Enabled: true, - GasLimit: validatorserviceconfig.Uint64(params.BeaconConfig().DefaultBuilderGasLimit), + GasLimit: validatorType.Uint64(params.BeaconConfig().DefaultBuilderGasLimit), }, }, }) From 75329be42e0173a9187eacb28714b3fe6d7f6b97 Mon Sep 17 00:00:00 2001 From: james-prysm Date: Fri, 5 May 2023 17:26:38 -0500 Subject: [PATCH 22/33] reverting changes on e2e --- testing/endtoend/components/validator.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/testing/endtoend/components/validator.go b/testing/endtoend/components/validator.go index 8531f15f58a9..d2bb9df10ab0 100644 --- a/testing/endtoend/components/validator.go +++ b/testing/endtoend/components/validator.go @@ -2,6 +2,7 @@ package components import ( "context" + "encoding/json" "fmt" "os" "os/exec" @@ -25,7 +26,6 @@ import ( "github.com/prysmaticlabs/prysm/v4/testing/endtoend/helpers" e2e "github.com/prysmaticlabs/prysm/v4/testing/endtoend/params" e2etypes "github.com/prysmaticlabs/prysm/v4/testing/endtoend/types" - "google.golang.org/protobuf/proto" ) const DefaultFeeRecipientAddress = "0x099FB65722e7b2455043bfebF6177f1D2E9738d9" @@ -335,7 +335,6 @@ func createProposerSettingsPath(pubkeys []string, nodeIdx int) (string, error) { if len(pubkeys) == 0 { return "", errors.New("number of validators must be greater than 0") } - var proposerSettingsPayload *validatorpb.ProposerSettingsPayload config := make(map[string]*validatorpb.ProposerOptionPayload) for i, pubkey := range pubkeys { @@ -343,20 +342,20 @@ func createProposerSettingsPath(pubkeys []string, nodeIdx int) (string, error) { FeeRecipient: FeeRecipientFromPubkey(pubkey), } } - proposerSettingsPayload = &validatorpb.ProposerSettingsPayload{ + proposerSettingsPayload := &validatorpb.ProposerSettingsPayload{ ProposerConfig: config, DefaultConfig: &validatorpb.ProposerOptionPayload{ FeeRecipient: DefaultFeeRecipientAddress, }, } - protoBytes, err := proto.Marshal(proposerSettingsPayload) + jsonBytes, err := json.Marshal(proposerSettingsPayload) if err != nil { return "", err } if err := file.MkdirAll(testNetDir); err != nil { return "", err } - if err := file.WriteFile(configPath, protoBytes); err != nil { + if err := file.WriteFile(configPath, jsonBytes); err != nil { return "", err } return configPath, nil From f099fa768ff99faa449405cb71048991864fc951 Mon Sep 17 00:00:00 2001 From: james-prysm Date: Fri, 5 May 2023 17:35:36 -0500 Subject: [PATCH 23/33] fixing linting --- testing/endtoend/components/BUILD.bazel | 1 - 1 file changed, 1 deletion(-) diff --git a/testing/endtoend/components/BUILD.bazel b/testing/endtoend/components/BUILD.bazel index 2acf366de909..f4639a2d28d4 100644 --- a/testing/endtoend/components/BUILD.bazel +++ b/testing/endtoend/components/BUILD.bazel @@ -44,7 +44,6 @@ go_library( "@com_github_wealdtech_go_eth2_wallet_encryptor_keystorev4//:go_default_library", "@in_gopkg_yaml_v2//:go_default_library", "@io_bazel_rules_go//go/tools/bazel:go_default_library", - "@org_golang_google_protobuf//proto:go_default_library", "@org_golang_x_sync//errgroup:go_default_library", ], ) From 20b6b6937a8d34241d6e1b5d222a92f9e49ed933 Mon Sep 17 00:00:00 2001 From: james-prysm Date: Fri, 5 May 2023 17:57:02 -0500 Subject: [PATCH 24/33] fixing deepsource issue --- testing/endtoend/components/validator.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/testing/endtoend/components/validator.go b/testing/endtoend/components/validator.go index d2bb9df10ab0..b6a057ac792d 100644 --- a/testing/endtoend/components/validator.go +++ b/testing/endtoend/components/validator.go @@ -244,8 +244,9 @@ func (v *ValidatorNode) Start(ctx context.Context) error { beaconRestApiPort = e2e.TestParams.Ports.PrysmBeaconNodeGatewayPort } - args = append(args, fmt.Sprintf("--%s=http://localhost:%d", flags.BeaconRESTApiProviderFlag.Name, beaconRestApiPort)) - args = append(args, fmt.Sprintf("--%s", features.EnableBeaconRESTApi.Name)) + args = append(args, + fmt.Sprintf("--%s=http://localhost:%d", flags.BeaconRESTApiProviderFlag.Name, beaconRestApiPort), + fmt.Sprintf("--%s", features.EnableBeaconRESTApi.Name)) } // Only apply e2e flags to the current branch. New flags may not exist in previous release. @@ -253,10 +254,11 @@ func (v *ValidatorNode) Start(ctx context.Context) error { args = append(args, features.E2EValidatorFlags...) } if v.config.UseWeb3RemoteSigner { - args = append(args, fmt.Sprintf("--%s=http://localhost:%d", flags.Web3SignerURLFlag.Name, Web3RemoteSignerPort)) // Write the pubkeys as comma separated hex strings with 0x prefix. // See: https://docs.teku.consensys.net/en/latest/HowTo/External-Signer/Use-External-Signer/ - args = append(args, fmt.Sprintf("--%s=%s", flags.Web3SignerPublicValidatorKeysFlag.Name, strings.Join(validatorHexPubKeys, ","))) + args = append(args, + fmt.Sprintf("--%s=http://localhost:%d", flags.Web3SignerURLFlag.Name, Web3RemoteSignerPort), + fmt.Sprintf("--%s=%s", flags.Web3SignerPublicValidatorKeysFlag.Name, strings.Join(validatorHexPubKeys, ","))) } else { // When not using remote key signer, use interop keys. args = append(args, From 44c7aea5f2ed6c9869d8471430a1e66bd00f31c4 Mon Sep 17 00:00:00 2001 From: james-prysm Date: Mon, 8 May 2023 11:21:49 -0500 Subject: [PATCH 25/33] resolving some internal comments --- config/validator/service/proposer-settings.go | 4 +++- .../v1alpha1/validator-client/keymanager.proto | 3 +++ validator/db/kv/proposer_settings.go | 1 + validator/node/node.go | 13 ++++++++----- 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/config/validator/service/proposer-settings.go b/config/validator/service/proposer-settings.go index a87d2bbd5dfb..34e9f69cecc3 100644 --- a/config/validator/service/proposer-settings.go +++ b/config/validator/service/proposer-settings.go @@ -56,6 +56,7 @@ type BuilderConfig struct { Relays []string `json:"relays,omitempty" yaml:"relays,omitempty"` } +// ToBuilderConfig converts protobuf to a builder config used in inmemory storage func ToBuilderConfig(from *validatorpb.BuilderConfig) *BuilderConfig { if from == nil { return nil @@ -74,7 +75,7 @@ func ToBuilderConfig(from *validatorpb.BuilderConfig) *BuilderConfig { } // ProposerSettings is a Prysm internal representation of the fee recipient config on the validator client. -// ProposerSettingsPayload maps to ProposerSettings on import through the CLI. +// validatorpb.ProposerSettingsPayload maps to ProposerSettings on import through the CLI. type ProposerSettings struct { ProposeConfig map[[fieldparams.BLSPubkeyLength]byte]*ProposerOption DefaultConfig *ProposerOption @@ -169,6 +170,7 @@ func (bc *BuilderConfig) Clone() *BuilderConfig { return config } +// ToPayload converts Builder Config to the protobuf object func (bc *BuilderConfig) ToPayload() *validatorpb.BuilderConfig { if bc == nil { return nil diff --git a/proto/prysm/v1alpha1/validator-client/keymanager.proto b/proto/prysm/v1alpha1/validator-client/keymanager.proto index c7d41e932a4d..1116b637b639 100644 --- a/proto/prysm/v1alpha1/validator-client/keymanager.proto +++ b/proto/prysm/v1alpha1/validator-client/keymanager.proto @@ -108,17 +108,20 @@ message SignResponse { Status status = 2; } +// ProposerOptionPayload is a property of ProposerSettingsPayload message ProposerOptionPayload { string fee_recipient = 1; BuilderConfig builder = 2; } +// BuilderConfig is a property of ProposerOptionPayload message BuilderConfig { bool enabled = 1; uint64 gas_limit = 2 [(ethereum.eth.ext.cast_type) = "github.com/prysmaticlabs/prysm/v4/consensus-types/validator.Uint64"]; repeated string relays = 3; } +// ProposerSettingsPayload is used to unmarshal files sent from the validator flag as well as safe to bolt db bucket message ProposerSettingsPayload { map proposer_config = 1; ProposerOptionPayload default_config = 2; diff --git a/validator/db/kv/proposer_settings.go b/validator/db/kv/proposer_settings.go index e1ebd0222d94..46cd94fb035c 100644 --- a/validator/db/kv/proposer_settings.go +++ b/validator/db/kv/proposer_settings.go @@ -13,6 +13,7 @@ import ( "google.golang.org/protobuf/proto" ) +// NoProposerSettingsFound is an error thrown when no settings are found in bucket var NoProposerSettingsFound = errors.New("no proposer settings found in bucket") // UpdateProposerSettingsForPubkey updates the existing settings for an internal representation of the proposers settings file at a particular public key diff --git a/validator/node/node.go b/validator/node/node.go index a44d92f0f112..439c34be14d5 100644 --- a/validator/node/node.go +++ b/validator/node/node.go @@ -569,6 +569,7 @@ func proposerSettings(cliCtx *cli.Context, db iface.ValidatorDB) (*validatorServ } if psExists { + // if settings exist update the default if err := db.UpdateProposerSettingsDefault(cliCtx.Context, vpSettings.DefaultConfig); err != nil { return nil, err } @@ -609,15 +610,17 @@ func proposerSettings(cliCtx *cli.Context, db iface.ValidatorDB) (*validatorServ BuilderConfig: validatorServiceConfig.ToBuilderConfig(option.Builder), } pubkeyB := bytesutil.ToBytes48(decodedKey) - if psExists { - if err := db.UpdateProposerSettingsForPubkey(cliCtx.Context, pubkeyB, o); err != nil { - return nil, err - } - } vpSettings.ProposeConfig[pubkeyB] = o } + if psExists { + // override the existing saved settings if providing values via fileConfig.ProposerConfig + if err := db.SaveProposerSettings(cliCtx.Context, vpSettings); err != nil { + return nil, err + } + } } if !psExists { + // if no proposer settings ever existed in the db just save the settings if err := db.SaveProposerSettings(cliCtx.Context, vpSettings); err != nil { return nil, err } From c5c1cb4fb699cc17a439a7cf603972eb757a5b12 Mon Sep 17 00:00:00 2001 From: james-prysm Date: Wed, 10 May 2023 20:45:41 -0500 Subject: [PATCH 26/33] resolving some comments and adding more tests --- ...poser-settings.go => proposer_settings.go} | 0 .../service/proposer_settings_test.go | 54 +++++++++++++++++ consensus-types/validator/custom_types.go | 6 +- .../validator/custom_types_test.go | 58 +++++++++++++++++++ validator/db/kv/proposer_settings.go | 2 +- validator/node/testdata/someotherfile.json | 3 + 6 files changed, 121 insertions(+), 2 deletions(-) rename config/validator/service/{proposer-settings.go => proposer_settings.go} (100%) create mode 100644 config/validator/service/proposer_settings_test.go create mode 100644 consensus-types/validator/custom_types_test.go create mode 100644 validator/node/testdata/someotherfile.json diff --git a/config/validator/service/proposer-settings.go b/config/validator/service/proposer_settings.go similarity index 100% rename from config/validator/service/proposer-settings.go rename to config/validator/service/proposer_settings.go diff --git a/config/validator/service/proposer_settings_test.go b/config/validator/service/proposer_settings_test.go new file mode 100644 index 000000000000..8b87ab9867c7 --- /dev/null +++ b/config/validator/service/proposer_settings_test.go @@ -0,0 +1,54 @@ +package validator_service_config + +import ( + "testing" + + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/common/hexutil" + fieldparams "github.com/prysmaticlabs/prysm/v4/config/fieldparams" + "github.com/prysmaticlabs/prysm/v4/config/params" + "github.com/prysmaticlabs/prysm/v4/consensus-types/validator" + "github.com/prysmaticlabs/prysm/v4/encoding/bytesutil" + "github.com/prysmaticlabs/prysm/v4/testing/require" +) + +func Test_Proposer_Setting_Cloning(t *testing.T) { + key1, err := hexutil.Decode("0xa057816155ad77931185101128655c0191bd0214c201ca48ed887f6c4c6adf334070efcd75140eada5ac83a92506dd7a") + require.NoError(t, err) + settings := &ProposerSettings{ + ProposeConfig: map[[fieldparams.BLSPubkeyLength]byte]*ProposerOption{ + bytesutil.ToBytes48(key1): { + FeeRecipientConfig: &FeeRecipientConfig{ + FeeRecipient: common.HexToAddress("0x50155530FCE8a85ec7055A5F8b2bE214B3DaeFd3"), + }, + BuilderConfig: &BuilderConfig{ + Enabled: true, + GasLimit: validator.Uint64(40000000), + Relays: []string{"https://example-relay.com"}, + }, + }, + }, + DefaultConfig: &ProposerOption{ + FeeRecipientConfig: &FeeRecipientConfig{ + FeeRecipient: common.HexToAddress("0x6e35733c5af9B61374A128e6F85f553aF09ff89A"), + }, + BuilderConfig: &BuilderConfig{ + Enabled: false, + GasLimit: validator.Uint64(params.BeaconConfig().DefaultBuilderGasLimit), + Relays: []string{"https://example-relay.com"}, + }, + }, + } + t.Run("Happy Path Cloning", func(t *testing.T) { + clone := settings.Clone() + require.DeepEqual(t, settings, clone) + option, ok := settings.ProposeConfig[bytesutil.ToBytes48(key1)] + require.Equal(t, true, ok) + newFeeRecipient := "0x44455530FCE8a85ec7055A5F8b2bE214B3DaeFd3" + option.FeeRecipientConfig.FeeRecipient = common.HexToAddress(newFeeRecipient) + coption, k := clone.ProposeConfig[bytesutil.ToBytes48(key1)] + require.Equal(t, true, k) + require.NotEqual(t, option.FeeRecipientConfig.FeeRecipient.Hex(), coption.FeeRecipientConfig.FeeRecipient.Hex()) + require.Equal(t, "0x50155530FCE8a85ec7055A5F8b2bE214B3DaeFd3", coption.FeeRecipientConfig.FeeRecipient.Hex()) + }) +} diff --git a/consensus-types/validator/custom_types.go b/consensus-types/validator/custom_types.go index 92d873db5bf9..e94c3481b44e 100644 --- a/consensus-types/validator/custom_types.go +++ b/consensus-types/validator/custom_types.go @@ -8,7 +8,11 @@ type Uint64 uint64 // UnmarshalJSON custom unmarshal function for json func (u *Uint64) UnmarshalJSON(bs []byte) error { str := string(bs) // Parse plain numbers directly. - if bs[0] == '"' && bs[len(bs)-1] == '"' { + if len(str) == 0 { + *u = Uint64(0) + return nil + } + if len(bs) >= 3 && bs[0] == '"' && bs[len(bs)-1] == '"' { // Unwrap the quotes from string numbers. str = string(bs[1 : len(bs)-1]) } diff --git a/consensus-types/validator/custom_types_test.go b/consensus-types/validator/custom_types_test.go new file mode 100644 index 000000000000..ed889f5b5944 --- /dev/null +++ b/consensus-types/validator/custom_types_test.go @@ -0,0 +1,58 @@ +package validator + +import ( + "testing" + + "github.com/prysmaticlabs/prysm/v4/testing/require" + "k8s.io/apimachinery/pkg/util/yaml" +) + +func Test_customUint_UnmarshalJSON(t *testing.T) { + type Custom struct { + Test Uint64 `json:"test"` + } + tests := []struct { + name string + jsonString string + number uint64 + wantUnmarshalErr string + }{ + { + name: "Happy Path string", + jsonString: `{"test": "123441"}`, + number: 123441, + }, + { + name: "Happy Path number", + jsonString: `{"test": 123441}`, + number: 123441, + }, + { + name: "empty", + jsonString: `{"test":""}`, + wantUnmarshalErr: "error unmarshaling JSON", + }, + { + name: "digits more than uint64", + jsonString: `{"test":"8888888888888888888888888888888888888888888888888888888888888"}`, + wantUnmarshalErr: "error unmarshaling JSON", + }, + { + name: "not a uint64", + jsonString: `{"test":"one hundred"}`, + wantUnmarshalErr: "error unmarshaling JSON", + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + var to Custom + err := yaml.Unmarshal([]byte(tt.jsonString), &to) + if tt.wantUnmarshalErr != "" { + require.ErrorContains(t, tt.wantUnmarshalErr, err) + } else { + require.NoError(t, err) + } + require.Equal(t, tt.number, uint64(to.Test)) + }) + } +} diff --git a/validator/db/kv/proposer_settings.go b/validator/db/kv/proposer_settings.go index 46cd94fb035c..bfce246e0fc7 100644 --- a/validator/db/kv/proposer_settings.go +++ b/validator/db/kv/proposer_settings.go @@ -18,7 +18,7 @@ var NoProposerSettingsFound = errors.New("no proposer settings found in bucket") // UpdateProposerSettingsForPubkey updates the existing settings for an internal representation of the proposers settings file at a particular public key func (s *Store) UpdateProposerSettingsForPubkey(ctx context.Context, pubkey [fieldparams.BLSPubkeyLength]byte, options *validatorServiceConfig.ProposerOption) error { - _, span := trace.StartSpan(ctx, "validator.db.UpdateProposerSettingsDefault") + _, span := trace.StartSpan(ctx, "validator.db.UpdateProposerSettingsForPubkey") defer span.End() err := s.db.Update(func(tx *bolt.Tx) error { bkt := tx.Bucket(proposerSettingsBucket) diff --git a/validator/node/testdata/someotherfile.json b/validator/node/testdata/someotherfile.json new file mode 100644 index 000000000000..249aff70282e --- /dev/null +++ b/validator/node/testdata/someotherfile.json @@ -0,0 +1,3 @@ +{ + "test": "123441" +} \ No newline at end of file From 659087c2c5dbb5c3d3ec3a37fe1035ab799ee56d Mon Sep 17 00:00:00 2001 From: james-prysm Date: Wed, 10 May 2023 21:13:16 -0500 Subject: [PATCH 27/33] adding more unit tests --- .../service/proposer_settings_test.go | 45 ++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/config/validator/service/proposer_settings_test.go b/config/validator/service/proposer_settings_test.go index 8b87ab9867c7..c33321edb7bd 100644 --- a/config/validator/service/proposer_settings_test.go +++ b/config/validator/service/proposer_settings_test.go @@ -13,7 +13,8 @@ import ( ) func Test_Proposer_Setting_Cloning(t *testing.T) { - key1, err := hexutil.Decode("0xa057816155ad77931185101128655c0191bd0214c201ca48ed887f6c4c6adf334070efcd75140eada5ac83a92506dd7a") + key1hex := "0xa057816155ad77931185101128655c0191bd0214c201ca48ed887f6c4c6adf334070efcd75140eada5ac83a92506dd7a" + key1, err := hexutil.Decode(key1hex) require.NoError(t, err) settings := &ProposerSettings{ ProposeConfig: map[[fieldparams.BLSPubkeyLength]byte]*ProposerOption{ @@ -51,4 +52,46 @@ func Test_Proposer_Setting_Cloning(t *testing.T) { require.NotEqual(t, option.FeeRecipientConfig.FeeRecipient.Hex(), coption.FeeRecipientConfig.FeeRecipient.Hex()) require.Equal(t, "0x50155530FCE8a85ec7055A5F8b2bE214B3DaeFd3", coption.FeeRecipientConfig.FeeRecipient.Hex()) }) + t.Run("Happy Path Cloning Builder config", func(t *testing.T) { + clone := settings.DefaultConfig.BuilderConfig.Clone() + require.DeepEqual(t, settings.DefaultConfig.BuilderConfig, clone) + settings.DefaultConfig.BuilderConfig.GasLimit = 1 + require.NotEqual(t, settings.DefaultConfig.BuilderConfig.GasLimit, clone.GasLimit) + }) + + t.Run("Happy Path ToBuilderConfig", func(t *testing.T) { + clone := settings.DefaultConfig.BuilderConfig.Clone() + config := ToBuilderConfig(clone.ToPayload()) + require.DeepEqual(t, config.Relays, clone.Relays) + require.Equal(t, config.Enabled, clone.Enabled) + require.Equal(t, config.GasLimit, clone.GasLimit) + }) + t.Run("To Payload and ToSettings", func(t *testing.T) { + payload := settings.ToPayload() + option, ok := settings.ProposeConfig[bytesutil.ToBytes48(key1)] + require.Equal(t, true, ok) + potion, pok := payload.ProposerConfig[key1hex] + require.Equal(t, true, pok) + require.Equal(t, option.FeeRecipientConfig.FeeRecipient.Hex(), potion.FeeRecipient) + require.Equal(t, settings.DefaultConfig.FeeRecipientConfig.FeeRecipient.Hex(), payload.DefaultConfig.FeeRecipient) + require.Equal(t, settings.DefaultConfig.BuilderConfig.Enabled, payload.DefaultConfig.Builder.Enabled) + potion.FeeRecipient = "" + newSettings, err := ToSettings(payload) + require.NoError(t, err) + + // when converting to settings if a fee recipient is empty string then it will be skipped + noption, ok := newSettings.ProposeConfig[bytesutil.ToBytes48(key1)] + require.Equal(t, false, ok) + require.Equal(t, true, noption == nil) + require.DeepEqual(t, newSettings.DefaultConfig, settings.DefaultConfig) + + // if fee recipient is set it will not skip + potion.FeeRecipient = "0x50155530FCE8a85ec7055A5F8b2bE214B3DaeFd3" + newSettings, err = ToSettings(payload) + require.NoError(t, err) + noption, ok = newSettings.ProposeConfig[bytesutil.ToBytes48(key1)] + require.Equal(t, true, ok) + require.DeepEqual(t, option, noption) + + }) } From cb3ac2a04f66976ff28652015e1cb3ad726b644b Mon Sep 17 00:00:00 2001 From: james-prysm Date: Wed, 10 May 2023 21:14:22 -0500 Subject: [PATCH 28/33] gaz --- config/validator/service/BUILD.bazel | 19 +++++++++++++++++-- consensus-types/validator/BUILD.bazel | 12 +++++++++++- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/config/validator/service/BUILD.bazel b/config/validator/service/BUILD.bazel index 6b02d92c18c4..047e84f7d46d 100644 --- a/config/validator/service/BUILD.bazel +++ b/config/validator/service/BUILD.bazel @@ -1,8 +1,8 @@ -load("@prysm//tools/go:def.bzl", "go_library") +load("@prysm//tools/go:def.bzl", "go_library", "go_test") go_library( name = "go_default_library", - srcs = ["proposer-settings.go"], + srcs = ["proposer_settings.go"], importpath = "github.com/prysmaticlabs/prysm/v4/config/validator/service", visibility = ["//visibility:public"], deps = [ @@ -14,3 +14,18 @@ go_library( "@com_github_ethereum_go_ethereum//common/hexutil:go_default_library", ], ) + +go_test( + name = "go_default_test", + srcs = ["proposer_settings_test.go"], + embed = [":go_default_library"], + deps = [ + "//config/fieldparams:go_default_library", + "//config/params:go_default_library", + "//consensus-types/validator:go_default_library", + "//encoding/bytesutil:go_default_library", + "//testing/require:go_default_library", + "@com_github_ethereum_go_ethereum//common:go_default_library", + "@com_github_ethereum_go_ethereum//common/hexutil:go_default_library", + ], +) diff --git a/consensus-types/validator/BUILD.bazel b/consensus-types/validator/BUILD.bazel index f0396aef7a11..0ad698433683 100644 --- a/consensus-types/validator/BUILD.bazel +++ b/consensus-types/validator/BUILD.bazel @@ -1,4 +1,4 @@ -load("@prysm//tools/go:def.bzl", "go_library") +load("@prysm//tools/go:def.bzl", "go_library", "go_test") go_library( name = "go_default_library", @@ -6,3 +6,13 @@ go_library( importpath = "github.com/prysmaticlabs/prysm/v4/consensus-types/validator", visibility = ["//visibility:public"], ) + +go_test( + name = "go_default_test", + srcs = ["custom_types_test.go"], + embed = [":go_default_library"], + deps = [ + "//testing/require:go_default_library", + "@io_k8s_apimachinery//pkg/util/yaml:go_default_library", + ], +) From 5429807ec371e923d6c8107f6556b56d2ca5fac5 Mon Sep 17 00:00:00 2001 From: james-prysm Date: Wed, 10 May 2023 21:35:50 -0500 Subject: [PATCH 29/33] fixing flaking test --- config/validator/service/proposer_settings_test.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/config/validator/service/proposer_settings_test.go b/config/validator/service/proposer_settings_test.go index c33321edb7bd..1ac16ab7c01e 100644 --- a/config/validator/service/proposer_settings_test.go +++ b/config/validator/service/proposer_settings_test.go @@ -91,7 +91,9 @@ func Test_Proposer_Setting_Cloning(t *testing.T) { require.NoError(t, err) noption, ok = newSettings.ProposeConfig[bytesutil.ToBytes48(key1)] require.Equal(t, true, ok) - require.DeepEqual(t, option, noption) + require.Equal(t, option.FeeRecipientConfig.FeeRecipient.Hex(), noption.FeeRecipientConfig.FeeRecipient.Hex()) + require.Equal(t, option.BuilderConfig.GasLimit, option.BuilderConfig.GasLimit) + require.Equal(t, option.BuilderConfig.Enabled, option.BuilderConfig.Enabled) }) } From 3e8a773af933a9bd99e6a1385bb95f681dd2b2bd Mon Sep 17 00:00:00 2001 From: james-prysm Date: Wed, 10 May 2023 22:17:06 -0500 Subject: [PATCH 30/33] fixing unit test contamination --- config/validator/service/proposer_settings_test.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/config/validator/service/proposer_settings_test.go b/config/validator/service/proposer_settings_test.go index 1ac16ab7c01e..50981128a298 100644 --- a/config/validator/service/proposer_settings_test.go +++ b/config/validator/service/proposer_settings_test.go @@ -70,6 +70,7 @@ func Test_Proposer_Setting_Cloning(t *testing.T) { payload := settings.ToPayload() option, ok := settings.ProposeConfig[bytesutil.ToBytes48(key1)] require.Equal(t, true, ok) + fee := option.FeeRecipientConfig.FeeRecipient.Hex() potion, pok := payload.ProposerConfig[key1hex] require.Equal(t, true, pok) require.Equal(t, option.FeeRecipientConfig.FeeRecipient.Hex(), potion.FeeRecipient) @@ -86,7 +87,7 @@ func Test_Proposer_Setting_Cloning(t *testing.T) { require.DeepEqual(t, newSettings.DefaultConfig, settings.DefaultConfig) // if fee recipient is set it will not skip - potion.FeeRecipient = "0x50155530FCE8a85ec7055A5F8b2bE214B3DaeFd3" + potion.FeeRecipient = fee newSettings, err = ToSettings(payload) require.NoError(t, err) noption, ok = newSettings.ProposeConfig[bytesutil.ToBytes48(key1)] From 3ec92f7de4fe1b0c79b64e5124ddbc6ec5258fdc Mon Sep 17 00:00:00 2001 From: james-prysm Date: Wed, 10 May 2023 23:20:28 -0500 Subject: [PATCH 31/33] fixing deepsource issue --- consensus-types/validator/custom_types.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/consensus-types/validator/custom_types.go b/consensus-types/validator/custom_types.go index e94c3481b44e..8f00ed95836c 100644 --- a/consensus-types/validator/custom_types.go +++ b/consensus-types/validator/custom_types.go @@ -8,7 +8,7 @@ type Uint64 uint64 // UnmarshalJSON custom unmarshal function for json func (u *Uint64) UnmarshalJSON(bs []byte) error { str := string(bs) // Parse plain numbers directly. - if len(str) == 0 { + if str == "" { *u = Uint64(0) return nil } From 51a6a3d192bac668ff8c6dc5f6e08483d500f676 Mon Sep 17 00:00:00 2001 From: james-prysm Date: Tue, 16 May 2023 12:28:43 -0500 Subject: [PATCH 32/33] resolving review item --- config/validator/service/proposer_settings.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/config/validator/service/proposer_settings.go b/config/validator/service/proposer_settings.go index 34e9f69cecc3..110c4f032f96 100644 --- a/config/validator/service/proposer_settings.go +++ b/config/validator/service/proposer_settings.go @@ -1,8 +1,11 @@ package validator_service_config import ( + "fmt" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" + "github.com/pkg/errors" fieldparams "github.com/prysmaticlabs/prysm/v4/config/fieldparams" "github.com/prysmaticlabs/prysm/v4/consensus-types/validator" "github.com/prysmaticlabs/prysm/v4/encoding/bytesutil" @@ -20,7 +23,7 @@ func ToSettings(ps *validatorpb.ProposerSettingsPayload) (*ProposerSettings, err } b, err := hexutil.Decode(key) if err != nil { - return nil, err + return nil, errors.Wrap(err, fmt.Sprintf("cannot decode public key %s", key)) } p := &ProposerOption{ FeeRecipientConfig: &FeeRecipientConfig{ From 23f52e1e9c344060319cf6a1fc5018e0995a63a2 Mon Sep 17 00:00:00 2001 From: james-prysm Date: Tue, 16 May 2023 12:29:44 -0500 Subject: [PATCH 33/33] gaz --- config/validator/service/BUILD.bazel | 1 + 1 file changed, 1 insertion(+) diff --git a/config/validator/service/BUILD.bazel b/config/validator/service/BUILD.bazel index 047e84f7d46d..198de3a1a1a1 100644 --- a/config/validator/service/BUILD.bazel +++ b/config/validator/service/BUILD.bazel @@ -12,6 +12,7 @@ go_library( "//proto/prysm/v1alpha1/validator-client:go_default_library", "@com_github_ethereum_go_ethereum//common:go_default_library", "@com_github_ethereum_go_ethereum//common/hexutil:go_default_library", + "@com_github_pkg_errors//:go_default_library", ], )