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

adding builder boost factor to proposer settings #13422

Closed
wants to merge 39 commits into from
Closed
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
8ce7287
wip
james-prysm Jan 5, 2024
ba73f17
proposer settings wip
james-prysm Jan 8, 2024
6741223
Merge branch 'develop' into builder-boost-settings
james-prysm Jan 18, 2024
5d50550
adding builder boost factor to builder settings
james-prysm Jan 18, 2024
86bc39d
adding tests for builder boost
james-prysm Jan 19, 2024
91c9bc4
Merge branch 'develop' into builder-boost-settings
james-prysm Jan 19, 2024
c880301
adding another unit test and gaz
james-prysm Jan 19, 2024
f3eb41d
Merge branch 'develop' into builder-boost-settings
james-prysm Jan 19, 2024
414a463
Merge branch 'develop' into builder-boost-settings
james-prysm Jan 22, 2024
e9b6193
fixing getBeaconBlock rest API
james-prysm Jan 22, 2024
8749e54
fixing linting
james-prysm Jan 22, 2024
26ba7aa
Merge branch 'develop' into builder-boost-settings
james-prysm Jan 22, 2024
36ade7b
Merge branch 'develop' into builder-boost-settings
james-prysm Feb 14, 2024
4e430a5
fixing some conflicts but wip to fix branch
james-prysm Mar 21, 2024
ad942a8
fixing branch
james-prysm Mar 21, 2024
996192f
Merge branch 'develop' into builder-boost-settings
james-prysm Mar 21, 2024
75038e4
fixing linting, and wip adding a builder boost factor flag
james-prysm Mar 21, 2024
ae3be20
Merge branch 'develop' into builder-boost-settings
james-prysm Mar 21, 2024
2291865
Merge branch 'develop' into builder-boost-settings
james-prysm Mar 22, 2024
bea4620
fixing logic and adding tests
james-prysm Mar 22, 2024
b0be7ca
renaming test
james-prysm Mar 22, 2024
1bf7b44
Merge branch 'develop' into builder-boost-settings
james-prysm Mar 22, 2024
f8c4a94
adding more tests
james-prysm Mar 22, 2024
5492018
Update config/proposer/settings.go
james-prysm Mar 25, 2024
bdb2158
Update config/proposer/settings.go
james-prysm Mar 25, 2024
421f967
Update validator/client/propose.go
james-prysm Mar 25, 2024
8aa5f73
Merge branch 'develop' into builder-boost-settings
james-prysm Mar 25, 2024
062518b
addressing comments
james-prysm Mar 25, 2024
c8181ad
Merge branch 'develop' into builder-boost-settings
james-prysm Mar 25, 2024
3086d0e
Merge branch 'develop' into builder-boost-settings
james-prysm Mar 26, 2024
ee5703d
Merge branch 'develop' into builder-boost-settings
james-prysm Mar 26, 2024
041b077
Merge branch 'develop' into builder-boost-settings
james-prysm Mar 28, 2024
4680af1
Merge branch 'develop' into builder-boost-settings
james-prysm Mar 29, 2024
fd7df55
ignore builder boost if local boost is set
james-prysm Mar 29, 2024
749cb98
adding test based on review change
james-prysm Mar 29, 2024
099d393
Merge branch 'develop' into builder-boost-settings
james-prysm Mar 29, 2024
85772bf
small update to use the builder boost if it's below the default of 100
james-prysm Apr 1, 2024
fb09cc5
Merge branch 'develop' into builder-boost-settings
james-prysm Apr 1, 2024
719c4aa
Merge branch 'develop' into builder-boost-settings
james-prysm Apr 17, 2024
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 config/validator/service/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ go_library(
"@com_github_ethereum_go_ethereum//common:go_default_library",
"@com_github_ethereum_go_ethereum//common/hexutil:go_default_library",
"@com_github_pkg_errors//:go_default_library",
"@org_golang_google_protobuf//types/known/wrapperspb:go_default_library",
],
)

Expand Down
22 changes: 17 additions & 5 deletions config/validator/service/proposer_settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/prysmaticlabs/prysm/v4/consensus-types/validator"
"github.com/prysmaticlabs/prysm/v4/encoding/bytesutil"
validatorpb "github.com/prysmaticlabs/prysm/v4/proto/prysm/v1alpha1/validator-client"
"google.golang.org/protobuf/types/known/wrapperspb"
)

// ToSettings converts struct to ProposerSettings
Expand Down Expand Up @@ -54,19 +55,25 @@ func ToSettings(ps *validatorpb.ProposerSettingsPayload) (*ProposerSettings, err
// BuilderConfig is the struct representation of the JSON config file set in the validator through the CLI.
// GasLimit is a number set to help the network decide on the maximum gas in each block.
type BuilderConfig struct {
Enabled bool `json:"enabled" yaml:"enabled"`
GasLimit validator.Uint64 `json:"gas_limit,omitempty" yaml:"gas_limit,omitempty"`
Relays []string `json:"relays,omitempty" yaml:"relays,omitempty"`
Enabled bool `json:"enabled" yaml:"enabled"`
GasLimit validator.Uint64 `json:"gas_limit,omitempty" yaml:"gas_limit,omitempty"`
Relays []string `json:"relays,omitempty" yaml:"relays,omitempty"`
BuilderBoostFactor *uint64 `json:"builder_boost_factor,omitempty" yaml:"builder_boost_factor,omitempty"`
}

// ToBuilderConfig converts protobuf to a builder config used in inmemory storage
func ToBuilderConfig(from *validatorpb.BuilderConfig) *BuilderConfig {
if from == nil {
return nil
}
var bbf *uint64
if from.BuilderBoostFactor != nil {
bbf = &from.BuilderBoostFactor.Value
}
config := &BuilderConfig{
Enabled: from.Enabled,
GasLimit: from.GasLimit,
Enabled: from.Enabled,
GasLimit: from.GasLimit,
BuilderBoostFactor: bbf,
}
if from.Relays != nil {
relays := make([]string, len(from.Relays))
Expand Down Expand Up @@ -173,6 +180,7 @@ func (bc *BuilderConfig) Clone() *BuilderConfig {
config := &BuilderConfig{}
config.Enabled = bc.Enabled
config.GasLimit = bc.GasLimit
config.BuilderBoostFactor = bc.BuilderBoostFactor
var relays []string
if bc.Relays != nil {
relays = make([]string, len(bc.Relays))
Expand All @@ -196,6 +204,10 @@ func (bc *BuilderConfig) ToPayload() *validatorpb.BuilderConfig {
config.Relays = relays
}
config.GasLimit = bc.GasLimit
if bc.BuilderBoostFactor != nil {
config.BuilderBoostFactor = &wrapperspb.UInt64Value{Value: *bc.BuilderBoostFactor}
}

return config
}

Expand Down
3 changes: 3 additions & 0 deletions proto/prysm/v1alpha1/validator-client/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ proto_library(
"@com_google_protobuf//:any_proto",
"@com_google_protobuf//:descriptor_proto",
"@com_google_protobuf//:empty_proto",
"@com_google_protobuf//:wrappers_proto",
"@com_google_protobuf//:timestamp_proto",
"@googleapis//google/api:annotations_proto",
],
Expand All @@ -53,6 +54,7 @@ go_proto_library(
"@googleapis//google/api:annotations_go_proto",
"@io_bazel_rules_go//proto/wkt:descriptor_go_proto",
"@io_bazel_rules_go//proto/wkt:empty_go_proto",
"@org_golang_google_protobuf//types/known/wrapperspb:go_default_library",
"@io_bazel_rules_go//proto/wkt:timestamp_go_proto",
"@org_golang_google_protobuf//reflect/protoreflect:go_default_library",
"@org_golang_google_protobuf//runtime/protoimpl:go_default_library",
Expand All @@ -78,6 +80,7 @@ go_proto_library(
"@googleapis//google/api:annotations_go_proto",
"@io_bazel_rules_go//proto/wkt:descriptor_go_proto",
"@io_bazel_rules_go//proto/wkt:empty_go_proto",
"@io_bazel_rules_go//proto/wkt:wrappers_go_proto",
"@io_bazel_rules_go//proto/wkt:timestamp_go_proto",
],
)
Expand Down
46 changes: 32 additions & 14 deletions proto/prysm/v1alpha1/validator-client/keymanager.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions proto/prysm/v1alpha1/validator-client/keymanager.proto
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import "proto/prysm/v1alpha1/attestation.proto";
import "proto/prysm/v1alpha1/beacon_block.proto";
import "proto/prysm/v1alpha1/beacon_state.proto";
import "proto/prysm/v1alpha1/sync_committee.proto";
import "google/protobuf/wrappers.proto";

option csharp_namespace = "Ethereum.Validator.Accounts.V2";
option go_package = "github.com/prysmaticlabs/prysm/v4/proto/prysm/v1alpha1/validator-client;validatorpb";
Expand Down Expand Up @@ -94,6 +95,7 @@ message BuilderConfig {
bool enabled = 1;
uint64 gas_limit = 2 [(ethereum.eth.ext.cast_type) = "github.com/prysmaticlabs/prysm/v4/consensus-types/validator.Uint64"];
repeated string relays = 3;
google.protobuf.UInt64Value builder_boost_factor = 4;
}

// ProposerSettingsPayload is used to unmarshal files sent from the validator flag as well as safe to bolt db bucket
Expand Down
2 changes: 2 additions & 0 deletions validator/client/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ go_library(
"@org_golang_google_grpc//status:go_default_library",
"@org_golang_google_protobuf//proto:go_default_library",
"@org_golang_google_protobuf//types/known/emptypb:go_default_library",
"@org_golang_google_protobuf//types/known/wrapperspb:go_default_library",
],
)

Expand Down Expand Up @@ -176,5 +177,6 @@ go_test(
"@org_golang_google_grpc//metadata:go_default_library",
"@org_golang_google_grpc//status:go_default_library",
"@org_golang_google_protobuf//types/known/emptypb:go_default_library",
"@org_golang_google_protobuf//types/known/wrapperspb:go_default_library",
],
)
30 changes: 27 additions & 3 deletions validator/client/propose.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/prysmaticlabs/prysm/v4/beacon-chain/core/signing"
fieldparams "github.com/prysmaticlabs/prysm/v4/config/fieldparams"
"github.com/prysmaticlabs/prysm/v4/config/params"
validatorserviceconfig "github.com/prysmaticlabs/prysm/v4/config/validator/service"
"github.com/prysmaticlabs/prysm/v4/consensus-types/blocks"
"github.com/prysmaticlabs/prysm/v4/consensus-types/interfaces"
"github.com/prysmaticlabs/prysm/v4/consensus-types/primitives"
Expand All @@ -26,6 +27,7 @@ import (
"github.com/prysmaticlabs/prysm/v4/validator/client/iface"
"github.com/sirupsen/logrus"
"go.opencensus.io/trace"
"google.golang.org/protobuf/types/known/wrapperspb"
)

const domainDataErr = "could not get domain data"
Expand Down Expand Up @@ -74,9 +76,10 @@ func (v *validator) ProposeBlock(ctx context.Context, slot primitives.Slot, pubK

// Request block from beacon node
b, err := v.validatorClient.GetBeaconBlock(ctx, &ethpb.BlockRequest{
Slot: slot,
RandaoReveal: randaoReveal,
Graffiti: g,
Slot: slot,
RandaoReveal: randaoReveal,
Graffiti: g,
BuilderBoostFactor: findBuilderBoost(pubKey, v.proposerSettings),
})
if err != nil {
log.WithField("blockSlot", slot).WithError(err).Error("Failed to request block from beacon node")
Expand Down Expand Up @@ -220,6 +223,27 @@ func (v *validator) ProposeBlock(ctx context.Context, slot primitives.Slot, pubK
}
}

func findBuilderBoost(pubKey [fieldparams.BLSPubkeyLength]byte, proposerSettings *validatorserviceconfig.ProposerSettings) *wrapperspb.UInt64Value {
if proposerSettings != nil {
if proposerSettings.ProposeConfig != nil {
option, ok := proposerSettings.ProposeConfig[pubKey]
if ok && option.BuilderConfig != nil && option.BuilderConfig.BuilderBoostFactor != nil {
return &wrapperspb.UInt64Value{
Value: *option.BuilderConfig.BuilderBoostFactor,
}
}
}
if proposerSettings.DefaultConfig != nil &&
proposerSettings.DefaultConfig.BuilderConfig != nil &&
proposerSettings.DefaultConfig.BuilderConfig.BuilderBoostFactor != nil {
return &wrapperspb.UInt64Value{
Value: *proposerSettings.DefaultConfig.BuilderConfig.BuilderBoostFactor,
}
}
}
return nil
james-prysm marked this conversation as resolved.
Show resolved Hide resolved
}

// ProposeExit performs a voluntary exit on a validator.
// The exit is signed by the validator before being sent to the beacon node for broadcasting.
func ProposeExit(
Expand Down
Loading
Loading