Browse Source

Merge pull request #2076 from tendermint/hotfix/0.22.7

Hotfix/0.22.7
pull/2082/head v0.22.7
Ethan Buchman 6 years ago
committed by GitHub
parent
commit
18acd77e40
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 87 additions and 14 deletions
  1. +9
    -0
      CHANGELOG.md
  2. +2
    -0
      blockchain/wire.go
  3. +46
    -0
      consensus/reactor_test.go
  4. +2
    -0
      consensus/types/wire.go
  5. +0
    -10
      evidence/wire.go
  6. +20
    -1
      types/block_test.go
  7. +4
    -0
      types/evidence.go
  8. +2
    -1
      types/wire.go
  9. +2
    -2
      version/version.go

+ 9
- 0
CHANGELOG.md View File

@ -1,5 +1,14 @@
# Changelog
## 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*


+ 2
- 0
blockchain/wire.go View File

@ -3,6 +3,7 @@ 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()
@ -10,4 +11,5 @@ var cdc = amino.NewCodec()
func init() {
RegisterBlockchainMessages(cdc)
cryptoAmino.RegisterAmino(cdc)
types.RegisterEvidences(cdc)
}

+ 46
- 0
consensus/reactor_test.go 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


+ 2
- 0
consensus/types/wire.go View File

@ -3,10 +3,12 @@ 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.RegisterEvidences(cdc)
}

+ 0
- 10
evidence/wire.go 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)
}

+ 20
- 1
types/block_test.go 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))


+ 4
- 0
types/evidence.go 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)
}
//-------------------------------------------


+ 2
- 1
types/wire.go View File

@ -2,11 +2,12 @@ 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)
RegisterEvidences(cdc)
}

+ 2
- 2
version/version.go View File

@ -4,13 +4,13 @@ package version
const (
Maj = "0"
Min = "22"
Fix = "6"
Fix = "7"
)
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.7"
// GitCommit is the current HEAD set using ldflags.
GitCommit string


Loading…
Cancel
Save