-
Notifications
You must be signed in to change notification settings - Fork 2.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
evidence: check evidence hasn't already been stored #4632
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.
cool!
don't forget to add CHANGELOG_PENDING.md entry and maybe write a test
"github.com/tendermint/tendermint/types" | ||
) | ||
|
||
type ErrInvalidEvidence struct { |
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 expose?
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.
Okay, perhaps I need a better understanding of when errors should be exposed or not because almost all the errors in all other packages are exposed, so I have just been copying them
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 think in general it's just good practice. Unless, however, you know with 100% certainty, the error will never be used/needed by the outside (package) world.
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.
If we'll be creating a typed error every time we return an error in public function, we will end up with pile of extra code, which is not needed in reality
Previously the evidence reactor would Also is it okay that |
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.
LGTM 👍
"github.com/tendermint/tendermint/types" | ||
) | ||
|
||
type ErrInvalidEvidence struct { |
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 think in general it's just good practice. Unless, however, you know with 100% certainty, the error will never be used/needed by the outside (package) world.
Codecov Report
@@ Coverage Diff @@
## master #4632 +/- ##
=======================================
Coverage 66.00% 66.01%
=======================================
Files 220 221 +1
Lines 19766 19800 +34
=======================================
+ Hits 13047 13070 +23
- Misses 5676 5686 +10
- Partials 1043 1044 +1
|
evidence/errors.go
Outdated
type ErrEvidenceAlreadyStored struct{} | ||
|
||
func (e ErrEvidenceAlreadyStored) Error() string { | ||
return fmt.Sprint("evidence is already stored") |
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.
return fmt.Sprint("evidence is already stored") | |
return "evidence is already stored" |
Add Has function, create better handling of errors when adding evidence, usage of error types.
3f517ae
to
c69b1f7
Compare
It's not necessary to disconnect, agree. we should ban peers who send us invalid evidence.
probably not |
Closes: #4614
Description
Uses the
Has()
function from the DB store interface to first confirm that a piece of received evidence is not already stored before commencing verificationFor contributor use:
docs/
) and code commentsFiles changed
in the Github PR explorer