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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
38b4212
send proposer data to config
james-prysm Mar 4, 2022
0e1cabe
Merge branch 'develop' into fee-recipient
james-prysm Mar 4, 2022
b81afaa
wip implementation with file and url based config import
james-prysm Mar 8, 2022
f0e6270
improving logic on get validator index
james-prysm Mar 8, 2022
f368ec6
Merge branch 'develop' into fee-recipient
james-prysm Mar 8, 2022
3ce8ab4
fix function
james-prysm Mar 8, 2022
5e9d583
optimizing function for map and address bug
james-prysm Mar 9, 2022
3b1c9f5
fixing log
james-prysm Mar 9, 2022
3566a8b
Merge branch 'develop' into fee-recipient
james-prysm Mar 9, 2022
6fdc281
update cache if it doesn't exist
james-prysm Mar 10, 2022
b03c3a6
Merge branch 'develop' into fee-recipient
james-prysm Mar 10, 2022
6ba2897
Merge branch 'develop' into fee-recipient
james-prysm Mar 10, 2022
c675514
updating flags
james-prysm Mar 10, 2022
16098c5
initial unit test scaffold
james-prysm Mar 10, 2022
8736e40
Merge branch 'develop' into fee-recipient
james-prysm Mar 11, 2022
38864d2
fixing validator to call rpc call, removed temporary dependency
james-prysm Mar 11, 2022
ec87ea5
adding the API calls for the runner
james-prysm Mar 11, 2022
089fc19
fixing broken build
james-prysm Mar 11, 2022
c3242c0
fixing deepsource
james-prysm Mar 11, 2022
f0b1db0
fixing interface
james-prysm Mar 11, 2022
a9ed460
fixing fatal
james-prysm Mar 11, 2022
7a81615
fixing more deepsource issues
james-prysm Mar 11, 2022
29826cd
adding test placeholders
james-prysm Mar 11, 2022
a880c64
updating proposer config to add validation
james-prysm Mar 14, 2022
6d78340
Merge branch 'develop' into fee-recipient
james-prysm Mar 14, 2022
38cf604
changing how if statement throws error
james-prysm Mar 14, 2022
bd62186
removing unneeded validation, validating in a different way
james-prysm Mar 14, 2022
511cc8d
wip improving tests
james-prysm Mar 15, 2022
6b88e7b
more unit test work
james-prysm Mar 15, 2022
6acc746
fixing unit test
james-prysm Mar 16, 2022
a71622e
fixing unit tests and edge cases
james-prysm Mar 16, 2022
7d97970
Merge branch 'develop' into fee-recipient
james-prysm Mar 16, 2022
fa1f0cd
Merge branch 'develop' into fee-recipient
james-prysm Mar 17, 2022
da65f45
adding unit tests and adjusting how the config is created
james-prysm Mar 17, 2022
a91df04
Merge branch 'develop' into fee-recipient
james-prysm Mar 17, 2022
3c32213
fixing bazel builds
james-prysm Mar 17, 2022
8310e55
fixing proto generation
james-prysm Mar 17, 2022
460bea6
Merge branch 'develop' into fee-recipient
james-prysm Mar 17, 2022
ae88f51
fixing imports
james-prysm Mar 17, 2022
c5276d5
fixing unit tests
james-prysm Mar 17, 2022
a5fca40
Update cmd/validator/flags/flags.go
james-prysm Mar 17, 2022
3cc4f17
updating flags based on comments, fixing unit tests
james-prysm Mar 17, 2022
6c3445d
fixing bazel
james-prysm Mar 17, 2022
1450190
removing unneeded function
james-prysm Mar 17, 2022
35e4a41
fixing unit tests
james-prysm Mar 18, 2022
c549219
Merge branch 'develop' into fee-recipient
james-prysm Mar 18, 2022
6d67832
refactors and unit test fixes based on comments
james-prysm Mar 18, 2022
b02cb93
fixing bazel build
james-prysm Mar 18, 2022
acf7ea1
refactor the cache out fo the fee recipient function
james-prysm Mar 18, 2022
661cf01
adding usecase for multiple fee recipient
james-prysm Mar 18, 2022
962ceeb
refactor burn name
james-prysm Mar 18, 2022
96b5773
Update validator/client/validator.go
james-prysm Mar 18, 2022
4a6340e
Update validator/client/validator.go
james-prysm Mar 18, 2022
b2b20b7
Update validator/client/validator.go
james-prysm Mar 18, 2022
6a14d50
fixing bug with validator index based on code review
james-prysm Mar 18, 2022
b744e70
edited flag descriptions to better communicate usage
james-prysm Mar 18, 2022
5a8861f
fixing manual reference to flag name
james-prysm Mar 18, 2022
5e71149
Merge branch 'develop' into fee-recipient
james-prysm Mar 21, 2022
9a1e20a
fixing code review comments
james-prysm Mar 21, 2022
4463783
fixing linting
james-prysm Mar 21, 2022
000f385
Update validator/client/validator.go
james-prysm Mar 21, 2022
b40ea0a
addressing comments and renaming functions
james-prysm Mar 21, 2022
d243449
fixing linting
james-prysm Mar 21, 2022
dd41a61
Update cmd/validator/flags/flags.go
rauljordan Mar 21, 2022
eed1068
Update cmd/validator/flags/flags.go
rauljordan Mar 21, 2022
1cc55ca
Update cmd/validator/flags/flags.go
rauljordan Mar 21, 2022
513b12e
Merge branch 'develop' into fee-recipient
rauljordan Mar 21, 2022
3818f16
improving comments
james-prysm Mar 21, 2022
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
1 change: 1 addition & 0 deletions cmd/validator/flags/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ go_library(
"//validator:__subpackages__",
],
deps = [
"//config/fieldparams:go_default_library",
"//io/file:go_default_library",
"@com_github_urfave_cli_v2//:go_default_library",
],
Expand Down
21 changes: 21 additions & 0 deletions cmd/validator/flags/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"runtime"
"time"

field_params "github.com/prysmaticlabs/prysm/config/fieldparams"
"github.com/prysmaticlabs/prysm/io/file"
"github.com/urfave/cli/v2"
)
Expand Down Expand Up @@ -322,6 +323,26 @@ var (
Usage: "Enables more verbose logging for counting down to duty",
Value: false,
}

// FeeRecipientConfigFileFlag defines the path or URL to a file with proposer config.
FeeRecipientConfigFileFlag = &cli.StringFlag{
Name: "fee-recipient-config-file",
Usage: "Set path to a JSON file containing validator mappings to ETH addresses for receiving transaction fees when proposing blocks (i.e. --fee-recipient-config-file=/path/to/proposer.json). File format found in docs",
Value: "",
}
// FeeRecipientConfigURLFlag defines the path or URL to a file with proposer config.
FeeRecipientConfigURLFlag = &cli.StringFlag{
Name: "fee-recipient-config-url",
Usage: "Set URL to a REST endpoint containing validator mappings to ETH addresses for receiving transaction fees when proposing blocks (i.e. --fee-recipient-config-url=https://example.com/api/getConfig). File format found in docs",
Value: "",
}

// 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",
Value: field_params.EthBurnAddressHex,
}
)

// DefaultValidatorDir returns OS-specific default validator directory.
Expand Down
3 changes: 3 additions & 0 deletions cmd/validator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ var appFlags = []cli.Flag{
// Consensys' Web3Signer flags
flags.Web3SignerURLFlag,
flags.Web3SignerPublicValidatorKeysFlag,
flags.FeeRecipientConfigFileFlag,
flags.FeeRecipientConfigURLFlag,
flags.SuggestedFeeRecipientFlag,
////////////////////
cmd.DisableMonitoringFlag,
cmd.MonitoringHostFlag,
Expand Down
3 changes: 3 additions & 0 deletions cmd/validator/usage.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ var appHelpFlagGroups = []flagGroup{
flags.EnableDutyCountDown,
flags.Web3SignerURLFlag,
flags.Web3SignerPublicValidatorKeysFlag,
flags.FeeRecipientConfigFileFlag,
flags.FeeRecipientConfigURLFlag,
flags.SuggestedFeeRecipientFlag,
},
},
{
Expand Down
35 changes: 18 additions & 17 deletions config/fieldparams/mainnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,22 @@ package field_params

const (
Preset = "mainnet"
BlockRootsLength = 8192 // SLOTS_PER_HISTORICAL_ROOT
StateRootsLength = 8192 // SLOTS_PER_HISTORICAL_ROOT
RandaoMixesLength = 65536 // EPOCHS_PER_HISTORICAL_VECTOR
HistoricalRootsLength = 16777216 // HISTORICAL_ROOTS_LIMIT
ValidatorRegistryLimit = 1099511627776 // VALIDATOR_REGISTRY_LIMIT
Eth1DataVotesLength = 2048 // SLOTS_PER_ETH1_VOTING_PERIOD
PreviousEpochAttestationsLength = 4096 // MAX_ATTESTATIONS * SLOTS_PER_EPOCH
CurrentEpochAttestationsLength = 4096 // MAX_ATTESTATIONS * SLOTS_PER_EPOCH
SlashingsLength = 8192 // EPOCHS_PER_SLASHINGS_VECTOR
SyncCommitteeLength = 512 // SYNC_COMMITTEE_SIZE
RootLength = 32 // RootLength defines the byte length of a Merkle root.
BLSSignatureLength = 96 // BLSSignatureLength defines the byte length of a BLSSignature.
BLSPubkeyLength = 48 // BLSPubkeyLength defines the byte length of a BLSSignature.
MaxTxsPerPayloadLength = 1048576 // MaxTxsPerPayloadLength defines the maximum number of transactions that can be included in a payload.
MaxBytesPerTxLength = 1073741824 // MaxBytesPerTxLength defines the maximum number of bytes that can be included in a transaction.
FeeRecipientLength = 20 // FeeRecipientLength defines the byte length of a fee recipient.
LogsBloomLength = 256 // LogsBloomLength defines the byte length of a logs bloom.
BlockRootsLength = 8192 // SLOTS_PER_HISTORICAL_ROOT
StateRootsLength = 8192 // SLOTS_PER_HISTORICAL_ROOT
RandaoMixesLength = 65536 // EPOCHS_PER_HISTORICAL_VECTOR
HistoricalRootsLength = 16777216 // HISTORICAL_ROOTS_LIMIT
ValidatorRegistryLimit = 1099511627776 // VALIDATOR_REGISTRY_LIMIT
Eth1DataVotesLength = 2048 // SLOTS_PER_ETH1_VOTING_PERIOD
PreviousEpochAttestationsLength = 4096 // MAX_ATTESTATIONS * SLOTS_PER_EPOCH
CurrentEpochAttestationsLength = 4096 // MAX_ATTESTATIONS * SLOTS_PER_EPOCH
SlashingsLength = 8192 // EPOCHS_PER_SLASHINGS_VECTOR
SyncCommitteeLength = 512 // SYNC_COMMITTEE_SIZE
RootLength = 32 // RootLength defines the byte length of a Merkle root.
BLSSignatureLength = 96 // BLSSignatureLength defines the byte length of a BLSSignature.
BLSPubkeyLength = 48 // BLSPubkeyLength defines the byte length of a BLSSignature.
MaxTxsPerPayloadLength = 1048576 // MaxTxsPerPayloadLength defines the maximum number of transactions that can be included in a payload.
MaxBytesPerTxLength = 1073741824 // MaxBytesPerTxLength defines the maximum number of bytes that can be included in a transaction.
FeeRecipientLength = 20 // FeeRecipientLength defines the byte length of a fee recipient.
LogsBloomLength = 256 // LogsBloomLength defines the byte length of a logs bloom.
EthBurnAddressHex = "0x0000000000000000000000000000000000000000" // EthBurnAddressHex defines the hex encoded address of the eth1.0 burn contract.
)
35 changes: 18 additions & 17 deletions config/fieldparams/minimal.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,22 @@ package field_params

const (
Preset = "minimal"
BlockRootsLength = 64 // SLOTS_PER_HISTORICAL_ROOT
StateRootsLength = 64 // SLOTS_PER_HISTORICAL_ROOT
RandaoMixesLength = 64 // EPOCHS_PER_HISTORICAL_VECTOR
HistoricalRootsLength = 16777216 // HISTORICAL_ROOTS_LIMIT
ValidatorRegistryLimit = 1099511627776 // VALIDATOR_REGISTRY_LIMIT
Eth1DataVotesLength = 32 // SLOTS_PER_ETH1_VOTING_PERIOD
PreviousEpochAttestationsLength = 1024 // MAX_ATTESTATIONS * SLOTS_PER_EPOCH
CurrentEpochAttestationsLength = 1024 // MAX_ATTESTATIONS * SLOTS_PER_EPOCH
SlashingsLength = 64 // EPOCHS_PER_SLASHINGS_VECTOR
SyncCommitteeLength = 32 // SYNC_COMMITTEE_SIZE
RootLength = 32 // RootLength defines the byte length of a Merkle root.
BLSSignatureLength = 96 // BLSSignatureLength defines the byte length of a BLSSignature.
BLSPubkeyLength = 48 // BLSPubkeyLength defines the byte length of a BLSSignature.
MaxTxsPerPayloadLength = 1048576 // MaxTxsPerPayloadLength defines the maximum number of transactions that can be included in a payload.
MaxBytesPerTxLength = 1073741824 // MaxBytesPerTxLength defines the maximum number of bytes that can be included in a transaction.
FeeRecipientLength = 20 // FeeRecipientLength defines the byte length of a fee recipient.
LogsBloomLength = 256 // LogsBloomLength defines the byte length of a logs bloom.
BlockRootsLength = 64 // SLOTS_PER_HISTORICAL_ROOT
StateRootsLength = 64 // SLOTS_PER_HISTORICAL_ROOT
RandaoMixesLength = 64 // EPOCHS_PER_HISTORICAL_VECTOR
HistoricalRootsLength = 16777216 // HISTORICAL_ROOTS_LIMIT
ValidatorRegistryLimit = 1099511627776 // VALIDATOR_REGISTRY_LIMIT
Eth1DataVotesLength = 32 // SLOTS_PER_ETH1_VOTING_PERIOD
PreviousEpochAttestationsLength = 1024 // MAX_ATTESTATIONS * SLOTS_PER_EPOCH
CurrentEpochAttestationsLength = 1024 // MAX_ATTESTATIONS * SLOTS_PER_EPOCH
SlashingsLength = 64 // EPOCHS_PER_SLASHINGS_VECTOR
SyncCommitteeLength = 32 // SYNC_COMMITTEE_SIZE
RootLength = 32 // RootLength defines the byte length of a Merkle root.
BLSSignatureLength = 96 // BLSSignatureLength defines the byte length of a BLSSignature.
BLSPubkeyLength = 48 // BLSPubkeyLength defines the byte length of a BLSSignature.
MaxTxsPerPayloadLength = 1048576 // MaxTxsPerPayloadLength defines the maximum number of transactions that can be included in a payload.
MaxBytesPerTxLength = 1073741824 // MaxBytesPerTxLength defines the maximum number of bytes that can be included in a transaction.
FeeRecipientLength = 20 // FeeRecipientLength defines the byte length of a fee recipient.
LogsBloomLength = 256 // LogsBloomLength defines the byte length of a logs bloom.
EthBurnAddressHex = "0x0000000000000000000000000000000000000000" // EthBurnAddressHex defines the hex encoded address of the eth1.0 burn contract.
)
12 changes: 12 additions & 0 deletions config/validator/service/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
load("@prysm//tools/go:def.bzl", "go_library")

go_library(
name = "go_default_library",
srcs = ["fee-recipient-config.go"],
importpath = "github.com/prysmaticlabs/prysm/config/validator/service",
visibility = ["//visibility:public"],
deps = [
"//config/fieldparams:go_default_library",
"@com_github_ethereum_go_ethereum//common:go_default_library",
],
)
32 changes: 32 additions & 0 deletions config/validator/service/fee-recipient-config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package validator_service_config

import (
"github.com/ethereum/go-ethereum/common"
field_params "github.com/prysmaticlabs/prysm/config/fieldparams"
)

// FeeRecipientFileConfig is the struct representation of the JSON config file set in the validator through the CLI.
// ProposeConfig is the map of validator address to fee recipient options all in hex format.
// DefaultConfig is the default fee recipient address for all validators unless otherwise specified in the propose config.required.
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

ProposeConfig map[string]*FeeRecipientFileOptions `json:"proposer_config"`
DefaultConfig *FeeRecipientFileOptions `json:"default_config"`
}

// FeeRecipientFileOptions is the struct representation of the JSON config file set in the validator through the CLI.
// FeeRecipient is set to an eth address in hex string format with 0x prefix.
type FeeRecipientFileOptions struct {
FeeRecipient string `json:"fee_recipient"`
}

// FeeRecipientConfig is a Prysm internal representation of the fee recipient config on the validator client.
// FeeRecipientFileConfig maps to FeeRecipientConfig on import through the CLI.
type FeeRecipientConfig struct {
ProposeConfig map[[field_params.BLSPubkeyLength]byte]*FeeRecipientOptions
DefaultConfig *FeeRecipientOptions
}

// FeeRecipientOptions is a Prysm internal representation of the FeeRecipientFileOptions on the validator client in bytes format instead of hex.
type FeeRecipientOptions struct {
FeeRecipient common.Address
}
Loading