-
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
types: Cap evidence in block validation #2560
Conversation
2359e85
to
dc0c77b
Compare
Codecov Report
@@ Coverage Diff @@
## develop #2560 +/- ##
==========================================
+ Coverage 61.23% 61.4% +0.16%
==========================================
Files 202 202
Lines 16733 16747 +14
==========================================
+ Hits 10246 10283 +37
+ Misses 5617 5593 -24
- Partials 870 871 +1
|
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.
🍰 🌮 🍉
@ebuchman Does this mean this PR is WIP? |
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, just needs a test case!
Updated the block validation tests - made them table-driven, opened an issue to write more of them (#2589), and added a test for the evidence cap :) |
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.
🥗 🔥 🌯
state/validation_test.go
Outdated
require.Error(t, err) | ||
{"EvidenceHash", func(block *types.Block) { block.EvidenceHash = wrongHash }}, // wrong evidence hash | ||
{"Proposer wrong", func(block *types.Block) { block.ProposerAddress = ed25519.GenPrivKey().PubKey().Address() }}, // wrong proposer | ||
{"Proposer invalid", func(block *types.Block) { block.ProposerAddress = []byte("wrong size") }}, // invalid proposer |
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 in // invalid proposer
comment if we already have "Proposer invalid" as a test name
state/validation_test.go
Outdated
// Manipulation of any header field causes failure. | ||
testCases := []struct { | ||
name string | ||
f func(block *types.Block) |
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.
tendermint/types/block_test.go
Line 58 in 3fcb62b
malleateBlock func(*Block) |
Refs #2587: ``` We only start validating block.Time when Height > 1, because there is no commit to compute the median timestamp from for the first block. This means a faulty proposer could make the first block with whatever time they want. Instead, we should require the timestamp of block 1 to match the genesis time. I discovered this while refactoring the ValidateBlock tests to be table-driven while working on tests for #2560. ```
* require block.Time of the fist block to be genesis time Refs #2587: ``` We only start validating block.Time when Height > 1, because there is no commit to compute the median timestamp from for the first block. This means a faulty proposer could make the first block with whatever time they want. Instead, we should require the timestamp of block 1 to match the genesis time. I discovered this while refactoring the ValidateBlock tests to be table-driven while working on tests for #2560. ``` * do not accept blocks with negative height * update changelog and spec * nanos precision for test genesis time * Fix failing test (#2607)
Closes #1637
Still need to write tests
EDIT: wrote tests!