diff --git a/CHANGELOG.md b/CHANGELOG.md index fce7d6ee..b2bda54c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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* diff --git a/blockchain/wire.go b/blockchain/wire.go index ff02d58c..91156fa8 100644 --- a/blockchain/wire.go +++ b/blockchain/wire.go @@ -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) } diff --git a/consensus/reactor_test.go b/consensus/reactor_test.go index 9e2aa0a0..90def612 100644 --- a/consensus/reactor_test.go +++ b/consensus/reactor_test.go @@ -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 diff --git a/consensus/types/wire.go b/consensus/types/wire.go index 9221de96..db674816 100644 --- a/consensus/types/wire.go +++ b/consensus/types/wire.go @@ -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) } diff --git a/consensus/wire.go b/consensus/wire.go index cc172bea..567e6095 100644 --- a/consensus/wire.go +++ b/consensus/wire.go @@ -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) } diff --git a/evidence/wire.go b/evidence/wire.go index c61b8618..73ff33b2 100644 --- a/evidence/wire.go +++ b/evidence/wire.go @@ -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) } diff --git a/lite/files/wire.go b/lite/files/wire.go index f45e4c63..e7864831 100644 --- a/lite/files/wire.go +++ b/lite/files/wire.go @@ -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) } diff --git a/rpc/core/types/wire.go b/rpc/core/types/wire.go index d49b977e..ef1fa800 100644 --- a/rpc/core/types/wire.go +++ b/rpc/core/types/wire.go @@ -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) } diff --git a/types/block_test.go b/types/block_test.go index 714029bf..50695c84 100644 --- a/types/block_test.go +++ b/types/block_test.go @@ -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)) diff --git a/types/evidence.go b/types/evidence.go index 6313f43a..92675868 100644 --- a/types/evidence.go +++ b/types/evidence.go @@ -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) } //------------------------------------------- diff --git a/types/wire.go b/types/wire.go index 9221de96..c5608998 100644 --- a/types/wire.go +++ b/types/wire.go @@ -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) } diff --git a/version/version.go b/version/version.go index 5ef4aadb..85b1f191 100644 --- a/version/version.go +++ b/version/version.go @@ -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