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

Implement Fee Recipient: CLI flags and Calling Beacon API #10312

Merged
merged 68 commits into from
Mar 21, 2022

Conversation

james-prysm
Copy link
Contributor

What type of PR is this?

Feature

relates to #10292
What does this PR do? Why is it needed?

This PR focuses on allowing the user to set fee recipients for their validator keys whether through a file location or a url to send to the beacon node to be cached.

@james-prysm james-prysm added Enhancement New feature or request API Api related tasks Merge PRs related to the great milestone the merge labels Mar 4, 2022
@james-prysm james-prysm self-assigned this Mar 4, 2022
@@ -322,6 +323,26 @@ var (
Usage: "Enables more verbose logging for counting down to duty",
Value: false,
}

// ValidatorsProposerConfigDirFlag defines the path or URL to a file with proposer config.
ValidatorsProposerConfigDirFlag = &cli.StringFlag{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a file path and not a dir path so we should rename the flag and clarify the usage to say it is a path to a JSON file containing validator mappings to ETH addresses for receiving transaction fees when proposing blocks

// ValidatorsProposerConfigFlag defines the path or URL to a file with proposer config.
ValidatorsProposerConfigURLFlag = &cli.StringFlag{
Name: "validators-proposer-config-url",
Usage: "Set URL to load proposer config (.json) for per validator mapping to an eth address to receive gas fees when proposing block (i.e. --validators-proposer-config-url=https://example.com/api/getConfig). File format found in docs",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 as above

validator/client/validator.go Outdated Show resolved Hide resolved
validator/client/validator.go Outdated Show resolved Hide resolved
validator/client/validator.go Outdated Show resolved Hide resolved
validator/client/validator.go Outdated Show resolved Hide resolved
validator/client/validator.go Show resolved Hide resolved
@@ -186,6 +189,7 @@ func (v *ValidatorService) Start() {
emitAccountMetrics: v.emitAccountMetrics,
startBalances: make(map[[fieldparams.BLSPubkeyLength]byte]uint64),
prevBalance: make(map[[fieldparams.BLSPubkeyLength]byte]uint64),
pubkeyHexToValidatorIndex: make(map[[fieldparams.BLSPubkeyLength]byte]types.ValidatorIndex),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
pubkeyHexToValidatorIndex: make(map[[fieldparams.BLSPubkeyLength]byte]types.ValidatorIndex),
pubkeyToValidatorIndex: make(map[[fieldparams.BLSPubkeyLength]byte]types.ValidatorIndex),

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch

var validatorToFeeRecipientArray []*ethpb.PrepareBeaconProposerRequest_FeeRecipientContainer
// need to check for pubkey to validator index mappings
for _, key := range pubkeys {
feeRecipient := common.HexToAddress(fieldparams.EthBurnAddressHex)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move this to L992 and change it to v.prepareBeaconProposalConfig.DefaultConfig.FeeRecipient as default. Then you can get rid of the else to just

if option != nil {
				feeRecipient = option.FeeRecipient
			}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh i do need to fix something ( whether option as found or not) there but the default config fee recipient might not be the same as the burn address so that's why it was there.

@@ -0,0 +1,10 @@
package validator_service_config
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add some comments to these structs to explain what they are for. Maybe name the file to fee_recipients_config.go. We want to make it clear this is about fee recipients and not about something else proposer-related

@@ -57,4 +57,5 @@ type Validator interface {
ReceiveBlocks(ctx context.Context, connectionErrorChannel chan<- error)
HandleKeyReload(ctx context.Context, newKeys [][fieldparams.BLSPubkeyLength]byte) (bool, error)
CheckDoppelGanger(ctx context.Context) error
PrepareBeaconProposer(ctx context.Context, km keymanager.IKeymanager) error
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From the interface, this feels like it is about preparing proposer duties, which is unclear. We should probably rename this to prepare fee recipients

Comment on lines 106 to 113
type PrepareBeaconProposalConfig struct {
ProposeConfig map[[fieldparams.BLSPubkeyLength]byte]*ValidatorProposerOptions
DefaultConfig *ValidatorProposerOptions
}

type ValidatorProposerOptions struct {
FeeRecipient common.Address
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already have these in the config.go file in the same package, right? If so, could we move those there or use the types that were defined over there?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

very similar but not the same these uses the byte versions for easier use in our go code. I'll move them together then.

validator/client/validator.go Outdated Show resolved Hide resolved
@@ -368,6 +372,8 @@ func (c *ValidatorClient) registerPrometheusService(cliCtx *cli.Context) error {
}

func (c *ValidatorClient) registerValidatorService(cliCtx *cli.Context) error {
jsonValidator := validator.New()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

validator.New() sounds like a big conflict with the concept of an eth2 validator. Maybe we should alias the package to jsonValidation, so you can do jsonValidator := jsonValidation.New()

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can probably move this to right above where it is used, above line 413

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i am doing validations in a different way now so thinking of just removing for now

cmd/validator/flags/flags.go Outdated Show resolved Hide resolved
cmd/validator/flags/flags.go Outdated Show resolved Hide resolved
cmd/validator/flags/flags.go Outdated Show resolved Hide resolved
field_params "github.com/prysmaticlabs/prysm/config/fieldparams"
)

type FeeRecipientFileConfig struct {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add comments to these structs about how they are used

@james-prysm james-prysm merged commit df8da80 into develop Mar 21, 2022
@delete-merged-branch delete-merged-branch bot deleted the fee-recipient branch March 21, 2022 18:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Api related tasks Enhancement New feature or request Merge PRs related to the great milestone the merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants