From f0403afb251404520f6cc8a6b26da0cffd0964a4 Mon Sep 17 00:00:00 2001 From: james-prysm <90280386+james-prysm@users.noreply.github.com> Date: Mon, 6 Jun 2022 12:58:52 -0400 Subject: [PATCH] Suggested-Fee-Recipient flag should not override (#10804) * initial commit * fixing unit test * fixing gofmt * updating usage language * updating flag description Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com> --- cmd/validator/flags/flags.go | 2 +- validator/node/node.go | 22 ++++++++++++---------- validator/node/node_test.go | 12 +++++++++--- 3 files changed, 22 insertions(+), 14 deletions(-) diff --git a/cmd/validator/flags/flags.go b/cmd/validator/flags/flags.go index 647285f1a..1f2959dc5 100644 --- a/cmd/validator/flags/flags.go +++ b/cmd/validator/flags/flags.go @@ -340,7 +340,7 @@ var ( // SuggestedFeeRecipientFlag defines the address of the fee recipient. SuggestedFeeRecipientFlag = &cli.StringFlag{ Name: "suggested-fee-recipient", - Usage: "Sets ALL validators' mapping to a suggested an eth address to receive gas fees when proposing a block. Overrides the --fee-recipient-config-file flag if set", + Usage: "Sets ALL validators' mapping to a suggested an eth address to receive gas fees when proposing a block. This is a fall back setting and will be overridden by other flags that update the proposer settings. ", Value: field_params.EthBurnAddressHex, } ) diff --git a/validator/node/node.go b/validator/node/node.go index 7cd634ce8..0786477ee 100644 --- a/validator/node/node.go +++ b/validator/node/node.go @@ -475,6 +475,17 @@ func feeRecipientConfig(cliCtx *cli.Context) (*validatorServiceConfig.FeeRecipie if cliCtx.IsSet(flags.FeeRecipientConfigFileFlag.Name) && cliCtx.IsSet(flags.FeeRecipientConfigURLFlag.Name) { return nil, fmt.Errorf("cannot specify both --%s and --%s", flags.FeeRecipientConfigFileFlag.Name, flags.FeeRecipientConfigURLFlag.Name) } + // is overridden by file and URL flags + if cliCtx.IsSet(flags.SuggestedFeeRecipientFlag.Name) { + suggestedFee := cliCtx.String(flags.SuggestedFeeRecipientFlag.Name) + fileConfig = &validatorServiceConfig.FeeRecipientFileConfig{ + ProposeConfig: nil, + DefaultConfig: &validatorServiceConfig.FeeRecipientFileOptions{ + FeeRecipient: suggestedFee, + }, + } + } + if cliCtx.IsSet(flags.FeeRecipientConfigFileFlag.Name) { if err := unmarshalFromFile(cliCtx.Context, cliCtx.String(flags.FeeRecipientConfigFileFlag.Name), &fileConfig); err != nil { return nil, err @@ -485,16 +496,7 @@ func feeRecipientConfig(cliCtx *cli.Context) (*validatorServiceConfig.FeeRecipie return nil, err } } - // override the default fileConfig with the fileConfig from the command line - if cliCtx.IsSet(flags.SuggestedFeeRecipientFlag.Name) { - suggestedFee := cliCtx.String(flags.SuggestedFeeRecipientFlag.Name) - fileConfig = &validatorServiceConfig.FeeRecipientFileConfig{ - ProposeConfig: nil, - DefaultConfig: &validatorServiceConfig.FeeRecipientFileOptions{ - FeeRecipient: suggestedFee, - }, - } - } + // nothing is set, so just return nil if fileConfig == nil { return nil, nil diff --git a/validator/node/node_test.go b/validator/node/node_test.go index 5c7b048c5..f8c814d03 100644 --- a/validator/node/node_test.go +++ b/validator/node/node_test.go @@ -432,7 +432,7 @@ func TestFeeRecipientConfig(t *testing.T) { wantErr: "", }, { - name: "Suggested Fee Override Config", + name: "Suggested Fee does not Override Config", args: args{ feeRecipientFlagValues: &feeRecipientFlag{ dir: "./testdata/good-prepare-beacon-proposer-config.json", @@ -441,10 +441,16 @@ func TestFeeRecipientConfig(t *testing.T) { }, }, want: func() *validator_service_config.FeeRecipientConfig { + key1, err := hexutil.Decode("0xa057816155ad77931185101128655c0191bd0214c201ca48ed887f6c4c6adf334070efcd75140eada5ac83a92506dd7a") + require.NoError(t, err) return &validator_service_config.FeeRecipientConfig{ - ProposeConfig: nil, + ProposeConfig: map[[fieldparams.BLSPubkeyLength]byte]*validator_service_config.FeeRecipientOptions{ + bytesutil.ToBytes48(key1): { + FeeRecipient: common.HexToAddress("0x50155530FCE8a85ec7055A5F8b2bE214B3DaeFd3"), + }, + }, DefaultConfig: &validator_service_config.FeeRecipientOptions{ - FeeRecipient: common.HexToAddress("0x6e35733c5af9B61374A128e6F85f553aF09ff89B"), + FeeRecipient: common.HexToAddress("0x6e35733c5af9B61374A128e6F85f553aF09ff89A"), }, } },