-
Notifications
You must be signed in to change notification settings - Fork 332
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
[context] tolerate empty candidate name #4562
Conversation
7b2b201
to
6365554
Compare
blockchain/block/validator.go
Outdated
fCtx := protocol.MustGetFeatureCtx(ctx) | ||
for err := range errChan { | ||
return errors.Wrap(err, "failed to validate action") | ||
if !fCtx.Tolerate(err) { | ||
return errors.Wrap(err, "failed to validate action") | ||
} |
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.
it is inexplicit to handle the error here.
if err = selp.Envelope.SanityCheck(); err != 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.
fixed
func (fCtx *FeatureCtx) Tolerate(err error) bool { | ||
if fCtx.TolerateEmptyCandidateName && errors.Cause(err) == action.ErrInvalidCanName { | ||
return true | ||
} | ||
return false | ||
} |
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.
error type shouldn't not be included in a function which doesn't name it's functionality.
if err = selp.Envelope.SanityCheck(); err != 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.
fixed
6365554
to
08ca196
Compare
08ca196
to
326adf9
Compare
|
@@ -58,7 +58,8 @@ func (v *GenericValidator) Validate(ctx context.Context, selp *action.SealedEnve | |||
if caller == nil { | |||
return errors.New("failed to get address") | |||
} | |||
if err = selp.Envelope.SanityCheck(); err != nil { | |||
featureCtx := MustGetFeatureCtx(ctx) | |||
if err = selp.Envelope.SanityCheck(); err != nil && !featureCtx.Tolerate(err) { |
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.
featureCtx.TolerateEmptyCandidateName && errors.Cause(err) == action.ErrInvalidCanName
shouldn't be hidden in a function of FeatureCtx
.
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.
I see, I was thinking in the future may have similar case again, so add a Tolerate
for this kind of special case
Description
as title, fix the following bug.
Fixes #4561
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
Test Configuration:
Checklist: