Skip to content

Commit

Permalink
rename prepare beacon proposer to fee recipient (#10404)
Browse files Browse the repository at this point in the history
  • Loading branch information
james-prysm authored Mar 22, 2022
1 parent 5550334 commit a060d76
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 28 deletions.
2 changes: 1 addition & 1 deletion validator/client/validator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{})
Expand Down
14 changes: 7 additions & 7 deletions validator/node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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 {
Expand All @@ -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 {
Expand All @@ -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 {
Expand Down
40 changes: 20 additions & 20 deletions validator/node/node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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: "",
Expand All @@ -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: "",
Expand Down Expand Up @@ -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: "",
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -449,7 +449,7 @@ func TestPrepareBeaconProposalConfig(t *testing.T) {
{
name: "Default Fee Recipient",
args: args{
proposalFlagValues: &proposalFlag{
feeRecipientFlagValues: &feeRecipientFlag{
dir: "",
url: "",
defaultfee: "",
Expand All @@ -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: "",
Expand All @@ -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)
Expand All @@ -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
Expand Down

0 comments on commit a060d76

Please sign in to comment.