-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove half-written test
validator/accounts/testing/mock.go
Outdated
@@ -90,6 +91,7 @@ func (_ *Wallet) InitializeKeymanager(_ context.Context, _ iface.InitKeymanagerC | |||
type Validator struct { | |||
Km keymanager.IKeymanager | |||
proposerSettings *validatorserviceconfig.ProposerSettings | |||
Graffiti string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The field should not be exported because we have a setter.
validator/accounts/testing/mock.go
Outdated
if m.Graffiti == "" { | ||
return nil, errors.New("graffiti is missing ") | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why would not having a graffiti produce an error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
was just for the mock, but i'll think of a better way to represent
@@ -429,3 +446,34 @@ func (v *validator) getGraffiti(ctx context.Context, pubKey [fieldparams.BLSPubk | |||
|
|||
return []byte{}, nil | |||
} | |||
|
|||
func (v *validator) SetGraffiti(ctx context.Context, pubKey [fieldparams.BLSPubkeyLength]byte, graffiti []byte) error { | |||
if v.proposerSettings != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We usually handle error conditions first. I would rewrite the code as
if v.proposerSettings == nil {
// error
}
if v.proposerSettings.ProposeConfig == nil {
// error
}
ps := v.proposerSettings.Clone()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops yeah i should do it this way
validator/client/propose.go
Outdated
} | ||
|
||
func (v *validator) DeleteGraffiti(ctx context.Context, pubKey [fieldparams.BLSPubkeyLength]byte) error { | ||
if v.proposerSettings != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
@@ -55,6 +55,7 @@ type FakeValidator struct { | |||
proposerSettings *validatorserviceconfig.ProposerSettings | |||
ProposerSettingWait time.Duration | |||
Km keymanager.IKeymanager | |||
Graffiti string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to export
Co-authored-by: Radosław Kapka <[email protected]>
Co-authored-by: Radosław Kapka <[email protected]>
validator/client/propose.go
Outdated
return v.SetProposerSettings(ctx, settings) | ||
} | ||
ps := settings.Clone() | ||
var option *proposer.Option |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line can be removed.
validator/client/propose.go
Outdated
option.GraffitiConfig = &proposer.GraffitiConfig{ | ||
Graffiti: string(graffiti), | ||
} | ||
ps.ProposeConfig[pubkey] = option |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing this line does not break any test.
validator/node/node.go
Outdated
@@ -264,6 +264,7 @@ func (c *ValidatorClient) initializeFromCLI(cliCtx *cli.Context, router *mux.Rou | |||
if isWeb3SignerURLFlagSet { | |||
c.wallet = wallet.NewWalletForWeb3Signer() | |||
} else { | |||
fmt.Println("initializeFromCLI asking for wallet") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why a fmt.Println
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's a mistake from debugging , should remove
Co-authored-by: Manu NALEPA <[email protected]>
What type of PR is this?
Feature
What does this PR do? Why is it needed?
https://ethereum.github.io/keymanager-APIs/?urls.primaryName=dev#/Graffiti
this PR introduces the graffiti keymanager API endpoints ( GET,POST,DELETE ). The approach taken here is adding graffiti to the proposer settings to persist. This also means that only the proposer settings will be saved, if a graffiti is passed via flag it will continue even if the keymanager API is called to delete. That being said the proposer settings now take priority and you will be able to see that in the
GetGraffiti
function.tests
curl -X POST "http://localhost:7500/eth/v1/validator/0x82f4fca8aacccd676beebda99d662d2e346adcd4f89acb142671f30ded77dda64fc760ef8ed6e62b7bf8cb53dc285778/graffiti" -H "Content-Type: application/json" -d '{"graffiti":"plain text here"}' -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.e30.1cIoNTAywQNDzFT4_f285omZXuzvSnxLozjtDKxqx-E"
curl -X GET "http://localhost:7500/eth/v1/validator/0x82f4fca8aacccd676beebda99d662d2e346adcd4f89acb142671f30ded77dda64fc760ef8ed6e62b7bf8cb53dc285778/graffiti" -H "accept: application/json" -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.e30.1cIoNTAywQNDzFT4_f285omZXuzvSnxLozjtDKxqx-E"
{"data":{"pubkey":"0x82f4fca8aacccd676beebda99d662d2e346adcd4f89acb142671f30ded77dda64fc760ef8ed6e62b7bf8cb53dc285778","graffiti":"plain text here"}}
Which issues(s) does this PR fix?
Fixes #13188
Other notes for review