Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggested Fee Recipient : bug fix #10555

Merged
merged 5 commits into from
Apr 21, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions validator/client/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -986,14 +986,19 @@ func (v *validator) feeRecipients(ctx context.Context, pubkeys [][fieldparams.BL
validatorIndex = ind
v.pubkeyToValidatorIndex[key] = validatorIndex
}
if v.feeRecipientConfig.DefaultConfig != nil {
feeRecipient = v.feeRecipientConfig.DefaultConfig.FeeRecipient
}
if v.feeRecipientConfig.ProposeConfig != nil {
option, ok := v.feeRecipientConfig.ProposeConfig[key]
if option != nil && ok {
james-prysm marked this conversation as resolved.
Show resolved Hide resolved
// override the default if a proposeconfig is set
feeRecipient = option.FeeRecipient
} else {
feeRecipient = v.feeRecipientConfig.DefaultConfig.FeeRecipient
}
}
if hexutil.Encode(feeRecipient.Bytes()) == fieldparams.EthBurnAddressHex {
log.Warnln("Fee recipient is set to the burn address. You will not be rewarded transaction fees on this setting. Please set a different fee recipient.")
}
validatorToFeeRecipientArray = append(validatorToFeeRecipientArray, &ethpb.PrepareBeaconProposerRequest_FeeRecipientContainer{
ValidatorIndex: validatorIndex,
FeeRecipient: feeRecipient[:],
Expand Down
23 changes: 23 additions & 0 deletions validator/client/validator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"
"io"
"math"
"strings"
"sync"
"testing"
"time"
Expand Down Expand Up @@ -1460,6 +1461,7 @@ func TestValidator_UdpateFeeRecipient(t *testing.T) {
tests := []struct {
name string
validatorSetter func(t *testing.T) *validator
feeRecipientMap map[types.ValidatorIndex]string
err string
}{
{
Expand Down Expand Up @@ -1498,6 +1500,9 @@ func TestValidator_UdpateFeeRecipient(t *testing.T) {

return &v
},
feeRecipientMap: map[types.ValidatorIndex]string{
1: "0x046Fb65722E7b2455043BFEBf6177F1D2e9738D9",
},
},
{
name: " Skip if no config",
Expand Down Expand Up @@ -1552,6 +1557,9 @@ func TestValidator_UdpateFeeRecipient(t *testing.T) {
}, nil)
return &v
},
feeRecipientMap: map[types.ValidatorIndex]string{
1: "0x046Fb65722E7b2455043BFEBf6177F1D2e9738D9",
},
},
{
name: " Happy Path proposer config not nil",
Expand Down Expand Up @@ -1591,6 +1599,9 @@ func TestValidator_UdpateFeeRecipient(t *testing.T) {
}
return &v
},
feeRecipientMap: map[types.ValidatorIndex]string{
1: "0x046Fb65722E7b2455043BFEBf6177F1D2e9738D9",
},
},
{
name: " proposer config not nil but fee recipient empty ",
Expand Down Expand Up @@ -1628,6 +1639,7 @@ func TestValidator_UdpateFeeRecipient(t *testing.T) {
FeeRecipient: common.HexToAddress("0x046Fb65722E7b2455043BFEBf6177F1D2e9738D9"),
},
}

return &v
},
},
Expand Down Expand Up @@ -1674,9 +1686,20 @@ func TestValidator_UdpateFeeRecipient(t *testing.T) {
v := tt.validatorSetter(t)
km, err := v.Keymanager()
require.NoError(t, err)
pubkeys, err := km.FetchValidatingPublicKeys(ctx)
require.NoError(t, err)
if tt.feeRecipientMap != nil {
feeRecipients, err := v.feeRecipients(ctx, pubkeys)
require.NoError(t, err)
for _, recipient := range feeRecipients {
require.Equal(t, strings.ToLower(tt.feeRecipientMap[recipient.ValidatorIndex]), strings.ToLower(hexutil.Encode(recipient.FeeRecipient)))
}
}

if err := v.UpdateFeeRecipient(ctx, km); tt.err != "" {
assert.ErrorContains(t, tt.err, err)
}

})
}
}