diff --git a/validator/client/validator_test.go b/validator/client/validator_test.go index ac897425bc1a..a438ff426cfb 100644 --- a/validator/client/validator_test.go +++ b/validator/client/validator_test.go @@ -1446,7 +1446,7 @@ func TestValidator_WaitForKeymanagerInitialization_Interop(t *testing.T) { require.NotNil(t, km) } -func TestValidator_PrepareBeaconProposer(t *testing.T) { +func TestValidator_UdpateFeeRecipient(t *testing.T) { ctrl := gomock.NewController(t) ctx := context.Background() db := dbTest.SetupDB(t, [][fieldparams.BLSPubkeyLength]byte{}) diff --git a/validator/node/node.go b/validator/node/node.go index 3ba134fc3850..d056579af22b 100644 --- a/validator/node/node.go +++ b/validator/node/node.go @@ -404,7 +404,7 @@ func (c *ValidatorClient) registerValidatorService(cliCtx *cli.Context) error { return err } - bpc, err := prepareBeaconProposalConfig(c.cliCtx) + bpc, err := feeRecipientConfig(c.cliCtx) if err != nil { return err } @@ -471,7 +471,7 @@ func web3SignerConfig(cliCtx *cli.Context) (*remote_web3signer.SetupConfig, erro return web3signerConfig, nil } -func prepareBeaconProposalConfig(cliCtx *cli.Context) (*validatorServiceConfig.FeeRecipientConfig, error) { +func feeRecipientConfig(cliCtx *cli.Context) (*validatorServiceConfig.FeeRecipientConfig, error) { var fileConfig *validatorServiceConfig.FeeRecipientFileConfig if cliCtx.IsSet(flags.FeeRecipientConfigFileFlag.Name) && cliCtx.IsSet(flags.FeeRecipientConfigURLFlag.Name) { return nil, errors.New("cannot specify both --validators-proposer-fileConfig-dir and --validators-proposer-fileConfig-url") @@ -508,7 +508,7 @@ func prepareBeaconProposalConfig(cliCtx *cli.Context) (*validatorServiceConfig.F } } //convert file config to proposer config for internal use - proposerConfig := &validatorServiceConfig.FeeRecipientConfig{} + frConfig := &validatorServiceConfig.FeeRecipientConfig{} // default fileConfig is mandatory if fileConfig.DefaultConfig == nil { @@ -521,12 +521,12 @@ func prepareBeaconProposalConfig(cliCtx *cli.Context) (*validatorServiceConfig.F if !common.IsHexAddress(fileConfig.DefaultConfig.FeeRecipient) { return nil, errors.New("default fileConfig fee recipient is not a valid eth1 address") } - proposerConfig.DefaultConfig = &validatorServiceConfig.FeeRecipientOptions{ + frConfig.DefaultConfig = &validatorServiceConfig.FeeRecipientOptions{ FeeRecipient: common.BytesToAddress(bytes), } if fileConfig.ProposeConfig != nil { - proposerConfig.ProposeConfig = make(map[[fieldparams.BLSPubkeyLength]byte]*validatorServiceConfig.FeeRecipientOptions) + frConfig.ProposeConfig = make(map[[fieldparams.BLSPubkeyLength]byte]*validatorServiceConfig.FeeRecipientOptions) for key, option := range fileConfig.ProposeConfig { decodedKey, err := hexutil.Decode(key) if err != nil { @@ -545,13 +545,13 @@ func prepareBeaconProposalConfig(cliCtx *cli.Context) (*validatorServiceConfig.F if !common.IsHexAddress(option.FeeRecipient) { return nil, errors.New("fee recipient is not a valid eth1 address") } - proposerConfig.ProposeConfig[bytesutil.ToBytes48(decodedKey)] = &validatorServiceConfig.FeeRecipientOptions{ + frConfig.ProposeConfig[bytesutil.ToBytes48(decodedKey)] = &validatorServiceConfig.FeeRecipientOptions{ FeeRecipient: common.BytesToAddress(feebytes), } } } - return proposerConfig, nil + return frConfig, nil } func (c *ValidatorClient) registerRPCService(cliCtx *cli.Context) error { diff --git a/validator/node/node_test.go b/validator/node/node_test.go index b0ffe5d9d557..0a5a38bd4b65 100644 --- a/validator/node/node_test.go +++ b/validator/node/node_test.go @@ -312,14 +312,14 @@ func TestUnmarshalFromURL(t *testing.T) { } } -func TestPrepareBeaconProposalConfig(t *testing.T) { - type proposalFlag struct { +func TestFeeRecipientConfig(t *testing.T) { + type feeRecipientFlag struct { dir string url string defaultfee string } type args struct { - proposalFlagValues *proposalFlag + feeRecipientFlagValues *feeRecipientFlag } tests := []struct { name string @@ -331,7 +331,7 @@ func TestPrepareBeaconProposalConfig(t *testing.T) { { name: "Happy Path Config file File", args: args{ - proposalFlagValues: &proposalFlag{ + feeRecipientFlagValues: &feeRecipientFlag{ dir: "./testdata/good-prepare-beacon-proposer-config.json", url: "", defaultfee: "", @@ -356,7 +356,7 @@ func TestPrepareBeaconProposalConfig(t *testing.T) { { name: "Happy Path Config file File multiple fee recipients", args: args{ - proposalFlagValues: &proposalFlag{ + feeRecipientFlagValues: &feeRecipientFlag{ dir: "./testdata/good-prepare-beacon-proposer-config-multiple.json", url: "", defaultfee: "", @@ -386,7 +386,7 @@ func TestPrepareBeaconProposalConfig(t *testing.T) { { name: "Happy Path Config URL File", args: args{ - proposalFlagValues: &proposalFlag{ + feeRecipientFlagValues: &feeRecipientFlag{ dir: "", url: "./testdata/good-prepare-beacon-proposer-config.json", defaultfee: "", @@ -411,7 +411,7 @@ func TestPrepareBeaconProposalConfig(t *testing.T) { { name: "Happy Path Suggested Fee File", args: args{ - proposalFlagValues: &proposalFlag{ + feeRecipientFlagValues: &feeRecipientFlag{ dir: "", url: "", defaultfee: "0x6e35733c5af9B61374A128e6F85f553aF09ff89A", @@ -430,7 +430,7 @@ func TestPrepareBeaconProposalConfig(t *testing.T) { { name: "Suggested Fee Override Config", args: args{ - proposalFlagValues: &proposalFlag{ + feeRecipientFlagValues: &feeRecipientFlag{ dir: "./testdata/good-prepare-beacon-proposer-config.json", url: "", defaultfee: "0x6e35733c5af9B61374A128e6F85f553aF09ff89B", @@ -449,7 +449,7 @@ func TestPrepareBeaconProposalConfig(t *testing.T) { { name: "Default Fee Recipient", args: args{ - proposalFlagValues: &proposalFlag{ + feeRecipientFlagValues: &feeRecipientFlag{ dir: "", url: "", defaultfee: "", @@ -468,7 +468,7 @@ func TestPrepareBeaconProposalConfig(t *testing.T) { { name: "Both URL and Dir flags used resulting in error", args: args{ - proposalFlagValues: &proposalFlag{ + feeRecipientFlagValues: &feeRecipientFlag{ dir: "./testdata/good-prepare-beacon-proposer-config.json", url: "./testdata/good-prepare-beacon-proposer-config.json", defaultfee: "", @@ -484,12 +484,12 @@ func TestPrepareBeaconProposalConfig(t *testing.T) { t.Run(tt.name, func(t *testing.T) { app := cli.App{} set := flag.NewFlagSet("test", 0) - if tt.args.proposalFlagValues.dir != "" { - set.String(flags.FeeRecipientConfigFileFlag.Name, tt.args.proposalFlagValues.dir, "") - require.NoError(t, set.Set(flags.FeeRecipientConfigFileFlag.Name, tt.args.proposalFlagValues.dir)) + if tt.args.feeRecipientFlagValues.dir != "" { + set.String(flags.FeeRecipientConfigFileFlag.Name, tt.args.feeRecipientFlagValues.dir, "") + require.NoError(t, set.Set(flags.FeeRecipientConfigFileFlag.Name, tt.args.feeRecipientFlagValues.dir)) } - if tt.args.proposalFlagValues.url != "" { - content, err := ioutil.ReadFile(tt.args.proposalFlagValues.url) + if tt.args.feeRecipientFlagValues.url != "" { + content, err := ioutil.ReadFile(tt.args.feeRecipientFlagValues.url) require.NoError(t, err) srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(200) @@ -499,15 +499,15 @@ func TestPrepareBeaconProposalConfig(t *testing.T) { })) defer srv.Close() - set.String(flags.FeeRecipientConfigURLFlag.Name, tt.args.proposalFlagValues.url, "") + set.String(flags.FeeRecipientConfigURLFlag.Name, tt.args.feeRecipientFlagValues.url, "") require.NoError(t, set.Set(flags.FeeRecipientConfigURLFlag.Name, srv.URL)) } - if tt.args.proposalFlagValues.defaultfee != "" { - set.String(flags.SuggestedFeeRecipientFlag.Name, tt.args.proposalFlagValues.defaultfee, "") - require.NoError(t, set.Set(flags.SuggestedFeeRecipientFlag.Name, tt.args.proposalFlagValues.defaultfee)) + if tt.args.feeRecipientFlagValues.defaultfee != "" { + set.String(flags.SuggestedFeeRecipientFlag.Name, tt.args.feeRecipientFlagValues.defaultfee, "") + require.NoError(t, set.Set(flags.SuggestedFeeRecipientFlag.Name, tt.args.feeRecipientFlagValues.defaultfee)) } cliCtx := cli.NewContext(&app, set, nil) - got, err := prepareBeaconProposalConfig(cliCtx) + got, err := feeRecipientConfig(cliCtx) if tt.wantErr != "" { require.ErrorContains(t, tt.wantErr, err) return