-
Notifications
You must be signed in to change notification settings - Fork 28
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
Apply tendermint v0.33.6 #112
Merged
+432
−67
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
5e52a6e
types: verify commit fully
melekes 8ccfdb9
consensus: Do not allow signatures for a wrong block in commits
melekes cefeab0
update changelog and bump version
melekes 606d0a8
changelog: tweak 0.33.6 entry
tessr 52d8794
Merge tag 'v0.33.6' into apply_v0.33.6
shiki-tak File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
package consensus | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/tendermint/tendermint/libs/bytes" | ||
"github.com/tendermint/tendermint/libs/log" | ||
tmrand "github.com/tendermint/tendermint/libs/rand" | ||
"github.com/tendermint/tendermint/p2p" | ||
"github.com/tendermint/tendermint/types" | ||
) | ||
|
||
//---------------------------------------------- | ||
// byzantine failures | ||
|
||
// one byz val sends a precommit for a random block at each height | ||
// Ensure a testnet makes blocks | ||
func TestReactorInvalidPrecommit(t *testing.T) { | ||
N := 4 | ||
css, cleanup := randConsensusNet(N, "consensus_reactor_test", newMockTickerFunc(true), newCounter) | ||
defer cleanup() | ||
|
||
for i := 0; i < 4; i++ { | ||
ticker := NewTimeoutTicker() | ||
ticker.SetLogger(css[i].Logger) | ||
css[i].SetTimeoutTicker(ticker) | ||
|
||
} | ||
|
||
reactors, blocksSubs, eventBuses := startConsensusNet(t, css, N) | ||
|
||
// this val sends a random precommit at each height | ||
byzValIdx := 0 | ||
byzVal := css[byzValIdx] | ||
byzR := reactors[byzValIdx] | ||
|
||
// update the doPrevote function to just send a valid precommit for a random block | ||
// and otherwise disable the priv validator | ||
byzVal.mtx.Lock() | ||
pv := byzVal.privValidator | ||
byzVal.doPrevote = func(height int64, round int) { | ||
invalidDoPrevoteFunc(t, height, round, byzVal, byzR.Switch, pv) | ||
} | ||
byzVal.mtx.Unlock() | ||
defer stopConsensusNet(log.TestingLogger(), reactors, eventBuses) | ||
|
||
// wait for a bunch of blocks | ||
// TODO: make this tighter by ensuring the halt happens by block 2 | ||
for i := 0; i < 10; i++ { | ||
timeoutWaitGroup(t, N, func(j int) { | ||
<-blocksSubs[j].Out() | ||
}, css) | ||
} | ||
} | ||
|
||
func invalidDoPrevoteFunc(t *testing.T, height int64, round int, cs *State, sw *p2p.Switch, pv types.PrivValidator) { | ||
// routine to: | ||
// - precommit for a random block | ||
// - send precommit to all peers | ||
// - disable privValidator (so we don't do normal precommits) | ||
go func() { | ||
cs.mtx.Lock() | ||
cs.privValidator = pv | ||
pubKey, err := cs.privValidator.GetPubKey() | ||
if err != nil { | ||
panic(err) | ||
} | ||
addr := pubKey.Address() | ||
valIndex, _ := cs.Validators.GetByAddress(addr) | ||
|
||
// precommit a random block | ||
blockHash := bytes.HexBytes(tmrand.Bytes(32)) | ||
precommit := &types.Vote{ | ||
ValidatorAddress: addr, | ||
ValidatorIndex: valIndex, | ||
Height: cs.Height, | ||
Round: cs.Round, | ||
Timestamp: cs.voteTime(), | ||
Type: types.PrecommitType, | ||
BlockID: types.BlockID{ | ||
Hash: blockHash, | ||
PartsHeader: types.PartSetHeader{Total: 1, Hash: tmrand.Bytes(32)}}, | ||
} | ||
cs.privValidator.SignVote(cs.state.ChainID, precommit) | ||
cs.privValidator = nil // disable priv val so we don't do normal votes | ||
cs.mtx.Unlock() | ||
|
||
peers := sw.Peers().List() | ||
for _, peer := range peers { | ||
cs.Logger.Info("Sending bad vote", "block", blockHash, "peer", peer) | ||
peer.Send(VoteChannel, cdc.MustMarshalBinaryBare(&VoteMessage{precommit})) | ||
} | ||
}() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 that the contents after this line have already been merged.
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.
Yes, a change log of v0.33.5 or lower has been added. please check https://github.com/line/tendermint/pull/112/files#diff-0cb6e2622f498ffc624167ff88fc1000L3
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.
Oh... I fixed it.