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

Keymanager APIs - get,post,delete graffiti #13474

Merged
merged 57 commits into from
Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from 47 commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
02d99b2
wip
james-prysm Jan 9, 2024
b3f2d52
adding set and delete graffiti
james-prysm Jan 16, 2024
6954e6c
Merge branch 'develop' into graffiti-keymanager-api
james-prysm Jan 16, 2024
a619275
fixing mock
james-prysm Jan 17, 2024
3a67b18
Merge branch 'develop' into graffiti-keymanager-api
james-prysm Jan 17, 2024
c4a68de
fixing mock linting and putting in scaffolds for unit tests
james-prysm Jan 17, 2024
9d09686
Merge branch 'develop' into graffiti-keymanager-api
james-prysm Jan 17, 2024
6163564
adding some tests
james-prysm Jan 18, 2024
8fa12b4
gaz
james-prysm Jan 18, 2024
33fbd8f
Merge branch 'develop' into graffiti-keymanager-api
james-prysm Jan 18, 2024
4fb7c0a
adding tests
james-prysm Jan 18, 2024
30204c1
Merge branch 'develop' into graffiti-keymanager-api
james-prysm Jan 18, 2024
2ba1d90
updating missing unit test
james-prysm Jan 18, 2024
357ecb2
fixing unit test
james-prysm Jan 18, 2024
77c2329
Update validator/rpc/handlers_keymanager.go
james-prysm Jan 18, 2024
4a82c2d
Merge branch 'develop' into graffiti-keymanager-api
james-prysm Jan 19, 2024
ab1ec5d
Merge branch 'develop' into graffiti-keymanager-api
james-prysm Jan 19, 2024
aa34ba5
Merge branch 'develop' into graffiti-keymanager-api
james-prysm Jan 22, 2024
a58f927
Update validator/client/propose.go
james-prysm Jan 22, 2024
5f28c9c
Update validator/rpc/handlers_keymanager.go
james-prysm Jan 22, 2024
feb1a98
Update validator/client/propose.go
james-prysm Jan 22, 2024
f01b04c
Merge branch 'develop' into graffiti-keymanager-api
james-prysm Jan 22, 2024
558fbee
radek's feedback
james-prysm Jan 22, 2024
ba26d89
fixing tests
james-prysm Jan 22, 2024
2df8437
Merge branch 'develop' into graffiti-keymanager-api
james-prysm Jan 23, 2024
0ef666f
Merge branch 'develop' into graffiti-keymanager-api
james-prysm Jan 23, 2024
b83a12b
Merge branch 'develop' into graffiti-keymanager-api
james-prysm Feb 15, 2024
e9d26e3
using wrapper for graffiti
james-prysm Feb 15, 2024
e9af279
fixing linting
james-prysm Feb 15, 2024
ec61a61
wip
james-prysm Feb 16, 2024
41e6cfb
Merge branch 'develop' into graffiti-keymanager-api
james-prysm Feb 16, 2024
cafc2bc
fixing setting proposer settings
james-prysm Feb 16, 2024
0a76ad9
Merge branch 'develop' into graffiti-keymanager-api
james-prysm Feb 29, 2024
74e2a01
partial fix to merging
james-prysm Mar 4, 2024
499b2bd
Merge branch 'develop' into graffiti-keymanager-api
james-prysm Mar 5, 2024
352cf4c
more partial fixes to tests
james-prysm Mar 6, 2024
0472a99
Merge branch 'develop' into graffiti-keymanager-api
james-prysm Mar 6, 2024
8fe24d6
gaz
james-prysm Mar 6, 2024
021ccdb
fixing tests and setting logic
james-prysm Mar 7, 2024
6a47352
changing keymanager
james-prysm Mar 7, 2024
94eb5d7
fixing tests and making graffiti optional in the proposer file
james-prysm Mar 8, 2024
0ff6520
Merge branch 'develop' into graffiti-keymanager-api
james-prysm Mar 8, 2024
8cff0ac
remove unneeded lines
james-prysm Mar 8, 2024
2e51b34
reverting unintended changes
james-prysm Mar 8, 2024
2d50abf
Merge branch 'develop' into graffiti-keymanager-api
james-prysm Mar 11, 2024
98b3712
Merge branch 'develop' into graffiti-keymanager-api
james-prysm Mar 11, 2024
9ad18fa
Merge branch 'develop' into graffiti-keymanager-api
james-prysm Mar 11, 2024
44b37db
Update validator/client/propose.go
james-prysm Mar 12, 2024
ca16050
addressing feedback
james-prysm Mar 12, 2024
d5e1f6d
Merge branch 'develop' into graffiti-keymanager-api
james-prysm Mar 12, 2024
0aaeea0
Merge branch 'develop' into graffiti-keymanager-api
james-prysm Mar 12, 2024
3341883
removing uneeded line
james-prysm Mar 12, 2024
46ec87c
Merge branch 'develop' into graffiti-keymanager-api
james-prysm Mar 12, 2024
c03f501
Merge branch 'develop' into graffiti-keymanager-api
james-prysm Mar 13, 2024
ebb136c
fixing bad merge resolution
james-prysm Mar 13, 2024
01278b1
gofmt
james-prysm Mar 13, 2024
752af27
gaz
james-prysm Mar 13, 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
78 changes: 78 additions & 0 deletions config/proposer/loader/loader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,82 @@ func TestProposerSettingsLoader(t *testing.T) {
validatorRegistrationEnabled bool
skipDBSavedCheck bool
}{
{
name: "graffiti in db without fee recipient",
args: args{
proposerSettingsFlagValues: &proposerSettingsFlag{
dir: "",
url: "",
defaultfee: "",
},
},
want: func() *proposer.Settings {
key1, err := hexutil.Decode("0xa057816155ad77931185101128655c0191bd0214c201ca48ed887f6c4c6adf334070efcd75140eada5ac83a92506dd7a")
require.NoError(t, err)
return &proposer.Settings{
ProposeConfig: map[[fieldparams.BLSPubkeyLength]byte]*proposer.Option{
bytesutil.ToBytes48(key1): {
GraffitiConfig: &proposer.GraffitiConfig{
Graffiti: "specific graffiti",
},
},
},
}
},
withdb: func(db iface.ValidatorDB) error {
key1, err := hexutil.Decode("0xa057816155ad77931185101128655c0191bd0214c201ca48ed887f6c4c6adf334070efcd75140eada5ac83a92506dd7a")
require.NoError(t, err)
settings := &proposer.Settings{
ProposeConfig: map[[fieldparams.BLSPubkeyLength]byte]*proposer.Option{
bytesutil.ToBytes48(key1): {
GraffitiConfig: &proposer.GraffitiConfig{
Graffiti: "specific graffiti",
},
},
},
}
return db.SaveProposerSettings(context.Background(), settings)
},
},
{
name: "graffiti from file",
args: args{
proposerSettingsFlagValues: &proposerSettingsFlag{
dir: "./testdata/good-graffiti-settings.json",
url: "",
defaultfee: "",
},
},
want: func() *proposer.Settings {
key1, err := hexutil.Decode("0xa057816155ad77931185101128655c0191bd0214c201ca48ed887f6c4c6adf334070efcd75140eada5ac83a92506dd7a")
require.NoError(t, err)
return &proposer.Settings{
ProposeConfig: map[[fieldparams.BLSPubkeyLength]byte]*proposer.Option{
bytesutil.ToBytes48(key1): {
FeeRecipientConfig: &proposer.FeeRecipientConfig{
FeeRecipient: common.HexToAddress("0x50155530FCE8a85ec7055A5F8b2bE214B3DaeFd3"),
},
GraffitiConfig: &proposer.GraffitiConfig{
Graffiti: "some graffiti",
},
BuilderConfig: &proposer.BuilderConfig{
Enabled: true,
GasLimit: validator.Uint64(30000000),
},
},
},
DefaultConfig: &proposer.Option{
FeeRecipientConfig: &proposer.FeeRecipientConfig{
FeeRecipient: common.HexToAddress("0x6e35733c5af9B61374A128e6F85f553aF09ff89A"),
},
BuilderConfig: &proposer.BuilderConfig{
Enabled: true,
GasLimit: validator.Uint64(40000000),
},
},
}
},
},
{
name: "db settings override file settings if file default config is missing",
args: args{
Expand Down Expand Up @@ -875,6 +951,8 @@ func TestProposerSettingsLoader(t *testing.T) {
if tt.wantErr != "" {
require.ErrorContains(t, tt.wantErr, err)
return
} else {
require.NoError(t, err)
}
if tt.wantLog != "" {
assert.LogsContain(t, hook,
Expand Down
19 changes: 19 additions & 0 deletions config/proposer/loader/testdata/good-graffiti-settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"proposer_config": {
"0xa057816155ad77931185101128655c0191bd0214c201ca48ed887f6c4c6adf334070efcd75140eada5ac83a92506dd7a": {
"fee_recipient": "0x50155530FCE8a85ec7055A5F8b2bE214B3DaeFd3",
"graffiti": "some graffiti",
"builder": {
"enabled": true,
"gas_limit": "30000000"
}
}
},
"default_config": {
"fee_recipient": "0x6e35733c5af9B61374A128e6F85f553aF09ff89A",
"builder": {
"enabled": true,
"gas_limit": 40000000
}
}
}
37 changes: 28 additions & 9 deletions config/proposer/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,22 @@ func SettingFromConsensus(ps *validatorpb.ProposerSettingsPayload) (*Settings, e
if ps.ProposerConfig != nil && len(ps.ProposerConfig) != 0 {
settings.ProposeConfig = make(map[[fieldparams.BLSPubkeyLength]byte]*Option)
for key, optionPayload := range ps.ProposerConfig {
if optionPayload.FeeRecipient == "" {
continue
}
decodedKey, err := hexutil.Decode(key)
if err != nil {
return nil, errors.Wrap(err, fmt.Sprintf("cannot decode public key %s", key))
}
if len(decodedKey) != fieldparams.BLSPubkeyLength {
return nil, fmt.Errorf("%v is not a bls public key", key)
}
if err := verifyOption(key, optionPayload); err != nil {
return nil, err
p := &Option{}
if optionPayload.Graffiti != nil {
p.GraffitiConfig = &GraffitiConfig{*optionPayload.Graffiti}
}
p := &Option{
FeeRecipientConfig: &FeeRecipientConfig{
FeeRecipient: common.HexToAddress(optionPayload.FeeRecipient),
},
if optionPayload.FeeRecipient != "" {
if err := verifyOption(key, optionPayload); err != nil {
return nil, err
}
p.FeeRecipientConfig = &FeeRecipientConfig{FeeRecipient: common.HexToAddress(optionPayload.FeeRecipient)}
}
if optionPayload.Builder != nil {
p.BuilderConfig = BuilderConfigFromConsensus(optionPayload.Builder)
Expand Down Expand Up @@ -141,10 +140,16 @@ type FeeRecipientConfig struct {
FeeRecipient common.Address
}

// GraffitiConfig is a prysm internal representation to see if the graffiti was set.
type GraffitiConfig struct {
Graffiti string
}

// Option is a Prysm internal representation of the ProposerOptionPayload on the validator client in bytes format instead of hex.
type Option struct {
FeeRecipientConfig *FeeRecipientConfig
BuilderConfig *BuilderConfig
GraffitiConfig *GraffitiConfig
}

// Clone creates a deep copy of proposer option
Expand All @@ -159,6 +164,9 @@ func (po *Option) Clone() *Option {
if po.BuilderConfig != nil {
p.BuilderConfig = po.BuilderConfig.Clone()
}
if po.GraffitiConfig != nil {
p.GraffitiConfig = po.GraffitiConfig.Clone()
}
return p
}

Expand All @@ -173,6 +181,9 @@ func (po *Option) ToConsensus() *validatorpb.ProposerOptionPayload {
if po.BuilderConfig != nil {
p.Builder = po.BuilderConfig.ToConsensus()
}
if po.GraffitiConfig != nil {
p.Graffiti = &po.GraffitiConfig.Graffiti
}
return p
}

Expand Down Expand Up @@ -222,6 +233,14 @@ func (bc *BuilderConfig) Clone() *BuilderConfig {
return c
}

// Clone creates a deep copy of graffiti config
func (gc *GraffitiConfig) Clone() *GraffitiConfig {
if gc == nil {
return nil
}
return &GraffitiConfig{gc.Graffiti}
}

// ToConsensus converts Builder Config to the protobuf object
func (bc *BuilderConfig) ToConsensus() *validatorpb.BuilderConfig {
if bc == nil {
Expand Down
14 changes: 1 addition & 13 deletions config/proposer/settings_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,26 +76,14 @@ func Test_Proposer_Setting_Cloning(t *testing.T) {
require.Equal(t, option.FeeRecipientConfig.FeeRecipient.Hex(), potion.FeeRecipient)
require.Equal(t, settings.DefaultConfig.FeeRecipientConfig.FeeRecipient.Hex(), payload.DefaultConfig.FeeRecipient)
require.Equal(t, settings.DefaultConfig.BuilderConfig.Enabled, payload.DefaultConfig.Builder.Enabled)
potion.FeeRecipient = ""
potion.FeeRecipient = fee
newSettings, err := SettingFromConsensus(payload)
require.NoError(t, err)

// when converting to settings if a fee recipient is empty string then it will be skipped
noption, ok := newSettings.ProposeConfig[bytesutil.ToBytes48(key1)]
require.Equal(t, false, ok)
require.Equal(t, true, noption == nil)
require.DeepEqual(t, newSettings.DefaultConfig, settings.DefaultConfig)

// if fee recipient is set it will not skip
potion.FeeRecipient = fee
newSettings, err = SettingFromConsensus(payload)
require.NoError(t, err)
noption, ok = newSettings.ProposeConfig[bytesutil.ToBytes48(key1)]
require.Equal(t, true, ok)
require.Equal(t, option.FeeRecipientConfig.FeeRecipient.Hex(), noption.FeeRecipientConfig.FeeRecipient.Hex())
require.Equal(t, option.BuilderConfig.GasLimit, option.BuilderConfig.GasLimit)
require.Equal(t, option.BuilderConfig.Enabled, option.BuilderConfig.Enabled)

})
}

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