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

Feat: Mark invalid shares #1313

Open
wants to merge 10 commits into
base: stage
Choose a base branch
from

Conversation

AKorpusenko
Copy link
Contributor

No description provided.

@AKorpusenko AKorpusenko added enhancement New feature or request DO NOT MERGE labels Feb 13, 2024
@AKorpusenko AKorpusenko self-assigned this Feb 13, 2024
MatusKysel
MatusKysel previously approved these changes Feb 14, 2024
Comment on lines 212 to 215
if isOperatorShare && !validatorShare.InvalidSecret {
eh.metrics.ValidatorInactive(event.PublicKey)
ownShare = validatorShare
logger = logger.With(zap.Bool("own_validator", isOperatorShare))
Copy link
Contributor

Choose a reason for hiding this comment

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

we can log that its our validator regardless of invalid secret, and also we should probably log if its an invalid secret (so its hard to miss in Kibana)

Suggested change
if isOperatorShare && !validatorShare.InvalidSecret {
eh.metrics.ValidatorInactive(event.PublicKey)
ownShare = validatorShare
logger = logger.With(zap.Bool("own_validator", isOperatorShare))
if isOperatorShare {
eh.metrics.ValidatorInactive(event.PublicKey)
logger = logger.With(zap.Bool("own_validator", isOperatorShare))
if validatorShare.InvalidSecret {
logger = logger.With(zap.Bool("invalid_secret", true))
logger.Debug("registered validator has an invalid share secret, it will not be started")
} else {
ownShare = validatorShare
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agree. Added this

if err != nil {
return nil, fmt.Errorf("could not extract validator share from event: %w", err)

if err != nil && !share.Metadata.InvalidSecret {
Copy link
Contributor

Choose a reason for hiding this comment

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

is the 2nd check needed? as far as i can see that method returns no error when the secret is invalid

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@moshe-blox, No we can't remove the 2nd check because we have to check that there is no error and share is valid.
Next, in case the share contains invalid secret, then we have to save it and mark as invalid what we do on this line

Copy link
Contributor

Choose a reason for hiding this comment

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

oh sry, i thought that we're not returning error in validatorAddedEventToShare when only the share is invalid, thats what i previously meant in my comment there

can we try this?

i'm interested to see how it would look, we can just log the reason for invalid secret instead of returning it as error (for example logger.Debug("invalid secret error: could not decrypt share private"))

then this check becomes just a simple err != nil and naturally theres no error that keeps going upstream (back to high level funcs who called us)

MatusKysel
MatusKysel previously approved these changes Feb 14, 2024

publicKey, err := ssvtypes.DeserializeBLSPublicKey(event.PublicKey)
if err != nil {
return nil, nil, &MalformedEventError{
return validatorShare, nil, &MalformedEventError{
Copy link
Contributor

Choose a reason for hiding this comment

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

why did we do this change? is returning an empty share anything better or different than returning nil?

…-shares-stage-fix

# Conflicts:
#	eth/eventhandler/handlers.go
#	operator/validator/controller.go
Copy link

codecov bot commented Mar 28, 2024

Codecov Report

Attention: Patch coverage is 53.84615% with 24 lines in your changes are missing coverage. Please review.

Project coverage is 48.6%. Comparing base (ef80171) to head (be64685).

Files Patch % Lines
operator/validator/controller.go 45.0% 10 Missing and 1 partial ⚠️
eth/eventhandler/handlers.go 67.8% 6 Missing and 3 partials ⚠️
registry/storage/shares.go 0.0% 4 Missing ⚠️
Additional details and impacted files

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

MatusKysel
MatusKysel previously approved these changes Mar 28, 2024
@AKorpusenko AKorpusenko requested a review from y0sher March 28, 2024 07:29
…-shares-stage-fix

# Conflicts:
#	eth/eventhandler/handlers.go
Copy link
Contributor

@y0sher y0sher left a comment

Choose a reason for hiding this comment

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

@moshe-blox lets decide if we still want to have this.

@zippoxer
Copy link

hey @MatusKysel @y0sher

yes, and i think we ended up saying my suggestion did not work out well, and this PR would be better in the original form where it returned an error on invalid share (rather than only setting the field and not returning error)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants