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>
This commit is contained in:
james-prysm 2022-06-06 12:58:52 -04:00 committed by GitHub
parent 3f309968d4
commit f0403afb25
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 14 deletions

View File

@ -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,
}
)

View File

@ -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

View File

@ -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"),
},
}
},