Merge pull request #2085 from tendermint/master

Merge 0.23.8 back into develop
This commit is contained in:
Alexander Simmerl 2018-07-27 04:21:34 +02:00 committed by GitHub
commit 4be6395ee0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 105 additions and 26 deletions

View File

@ -1,5 +1,22 @@
# Changelog
## 0.22.8
*July 26th, 2018*
BUG FIXES
- [consensus, blockchain] Fix 0.22.7 below.
## 0.22.7
*July 26th, 2018*
BUG FIXES
- [consensus, blockchain] Register the Evidence interface so it can be
marshalled/unmarshalled by the blockchain and consensus reactors
## 0.22.6
*July 24th, 2018*

View File

@ -2,12 +2,12 @@ package blockchain
import (
"github.com/tendermint/go-amino"
cryptoAmino "github.com/tendermint/tendermint/crypto/encoding/amino"
"github.com/tendermint/tendermint/types"
)
var cdc = amino.NewCodec()
func init() {
RegisterBlockchainMessages(cdc)
cryptoAmino.RegisterAmino(cdc)
types.RegisterBlockAmino(cdc)
}

View File

@ -13,6 +13,7 @@ import (
"github.com/tendermint/tendermint/abci/example/kvstore"
cmn "github.com/tendermint/tendermint/libs/common"
"github.com/tendermint/tendermint/libs/log"
sm "github.com/tendermint/tendermint/state"
cfg "github.com/tendermint/tendermint/config"
"github.com/tendermint/tendermint/p2p"
@ -91,6 +92,51 @@ func TestReactorBasic(t *testing.T) {
}, css)
}
// Ensure we can process blocks with evidence
func TestReactorWithEvidence(t *testing.T) {
N := 4
css := randConsensusNet(N, "consensus_reactor_test", newMockTickerFunc(true), newCounter)
evpool := mockEvidencePool{
t: t,
ev: []types.Evidence{types.NewMockGoodEvidence(1, 1, []byte("somone"))},
}
for i := 0; i < N; i++ {
css[i].evpool = evpool
}
reactors, eventChans, eventBuses := startConsensusNet(t, css, N)
defer stopConsensusNet(log.TestingLogger(), reactors, eventBuses)
// wait till everyone makes the first new block
timeoutWaitGroup(t, N, func(j int) {
<-eventChans[j]
}, css)
// second block should have evidence
timeoutWaitGroup(t, N, func(j int) {
<-eventChans[j]
}, css)
}
type mockEvidencePool struct {
height int
ev []types.Evidence
t *testing.T
}
func (m mockEvidencePool) PendingEvidence() []types.Evidence {
if m.height > 0 {
return m.ev
}
return nil
}
func (m mockEvidencePool) AddEvidence(types.Evidence) error { return nil }
func (m mockEvidencePool) Update(block *types.Block, state sm.State) {
m.height += 1
if m.height > 0 {
require.True(m.t, len(block.Evidence.Evidence) > 0)
}
}
// Ensure a testnet sends proposal heartbeats and makes blocks when there are txs
func TestReactorProposalHeartbeats(t *testing.T) {
N := 4

View File

@ -2,11 +2,11 @@ package types
import (
"github.com/tendermint/go-amino"
cryptoAmino "github.com/tendermint/tendermint/crypto/encoding/amino"
"github.com/tendermint/tendermint/types"
)
var cdc = amino.NewCodec()
func init() {
cryptoAmino.RegisterAmino(cdc)
types.RegisterBlockAmino(cdc)
}

View File

@ -2,7 +2,7 @@ package consensus
import (
"github.com/tendermint/go-amino"
cryptoAmino "github.com/tendermint/tendermint/crypto/encoding/amino"
"github.com/tendermint/tendermint/types"
)
var cdc = amino.NewCodec()
@ -10,5 +10,5 @@ var cdc = amino.NewCodec()
func init() {
RegisterConsensusMessages(cdc)
RegisterWALMessages(cdc)
cryptoAmino.RegisterAmino(cdc)
types.RegisterBlockAmino(cdc)
}

View File

@ -12,14 +12,4 @@ func init() {
RegisterEvidenceMessages(cdc)
cryptoAmino.RegisterAmino(cdc)
types.RegisterEvidences(cdc)
RegisterMockEvidences(cdc) // For testing
}
//-------------------------------------------
func RegisterMockEvidences(cdc *amino.Codec) {
cdc.RegisterConcrete(types.MockGoodEvidence{},
"tendermint/MockGoodEvidence", nil)
cdc.RegisterConcrete(types.MockBadEvidence{},
"tendermint/MockBadEvidence", nil)
}

View File

@ -2,11 +2,11 @@ package files
import (
"github.com/tendermint/go-amino"
cryptoAmino "github.com/tendermint/tendermint/crypto/encoding/amino"
"github.com/tendermint/tendermint/types"
)
var cdc = amino.NewCodec()
func init() {
cryptoAmino.RegisterAmino(cdc)
types.RegisterBlockAmino(cdc)
}

View File

@ -2,12 +2,10 @@ package core_types
import (
"github.com/tendermint/go-amino"
cryptoAmino "github.com/tendermint/tendermint/crypto/encoding/amino"
"github.com/tendermint/tendermint/types"
)
func RegisterAmino(cdc *amino.Codec) {
types.RegisterEventDatas(cdc)
types.RegisterEvidences(cdc)
cryptoAmino.RegisterAmino(cdc)
types.RegisterBlockAmino(cdc)
}

View File

@ -6,7 +6,7 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
crypto "github.com/tendermint/tendermint/crypto"
"github.com/tendermint/tendermint/crypto"
cmn "github.com/tendermint/tendermint/libs/common"
)
@ -101,6 +101,25 @@ func TestBlockMakePartSet(t *testing.T) {
assert.Equal(t, 1, partSet.Total())
}
func TestBlockMakePartSetWithEvidence(t *testing.T) {
assert.Nil(t, (*Block)(nil).MakePartSet(2))
txs := []Tx{Tx("foo"), Tx("bar")}
lastID := makeBlockIDRandom()
h := int64(3)
voteSet, valSet, vals := randVoteSet(h-1, 1, VoteTypePrecommit, 10, 1)
commit, err := MakeCommit(lastID, h-1, 1, voteSet, vals)
require.NoError(t, err)
ev := NewMockGoodEvidence(h, 0, valSet.Validators[0].Address)
evList := []Evidence{ev}
partSet := MakeBlock(h, txs, commit, evList).MakePartSet(1024)
assert.NotNil(t, partSet)
assert.Equal(t, 3, partSet.Total())
}
func TestBlockHashesTo(t *testing.T) {
assert.False(t, (*Block)(nil).HashesTo(nil))

View File

@ -41,6 +41,10 @@ type Evidence interface {
func RegisterEvidences(cdc *amino.Codec) {
cdc.RegisterInterface((*Evidence)(nil), nil)
cdc.RegisterConcrete(&DuplicateVoteEvidence{}, "tendermint/DuplicateVoteEvidence", nil)
// mocks
cdc.RegisterConcrete(MockGoodEvidence{}, "tendermint/MockGoodEvidence", nil)
cdc.RegisterConcrete(MockBadEvidence{}, "tendermint/MockBadEvidence", nil)
}
//-------------------------------------------

View File

@ -2,11 +2,16 @@ package types
import (
"github.com/tendermint/go-amino"
cryptoAmino "github.com/tendermint/tendermint/crypto/encoding/amino"
"github.com/tendermint/tendermint/crypto/encoding/amino"
)
var cdc = amino.NewCodec()
func init() {
cryptoAmino.RegisterAmino(cdc)
RegisterBlockAmino(cdc)
}
func RegisterBlockAmino(cdc *amino.Codec) {
cryptoAmino.RegisterAmino(cdc)
RegisterEvidences(cdc)
}

View File

@ -4,13 +4,13 @@ package version
const (
Maj = "0"
Min = "22"
Fix = "6"
Fix = "8"
)
var (
// Version is the current version of Tendermint
// Must be a string because scripts like dist.sh read this file.
Version = "0.22.6"
Version = "0.22.8"
// GitCommit is the current HEAD set using ldflags.
GitCommit string