Skip to content

Commit

Permalink
Merge pull request #104 from irisnet/develop
Browse files Browse the repository at this point in the history
R4R: Release v0.32.0
  • Loading branch information
zhangyelong authored Nov 4, 2019
2 parents 680942e + 674a6c0 commit 1030bc7
Show file tree
Hide file tree
Showing 113 changed files with 1,939 additions and 6,580 deletions.
416 changes: 0 additions & 416 deletions Gopkg.lock

This file was deleted.

109 changes: 0 additions & 109 deletions Gopkg.toml

This file was deleted.

2 changes: 1 addition & 1 deletion abci/example/kvstore/kvstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (
"github.com/tendermint/tendermint/abci/example/code"
"github.com/tendermint/tendermint/abci/types"
cmn "github.com/tendermint/tendermint/libs/common"
dbm "github.com/tendermint/tendermint/libs/db"
"github.com/tendermint/tendermint/version"
dbm "github.com/tendermint/tm-db"
)

var (
Expand Down
2 changes: 1 addition & 1 deletion abci/example/kvstore/persistent_kvstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (

"github.com/tendermint/tendermint/abci/example/code"
"github.com/tendermint/tendermint/abci/types"
dbm "github.com/tendermint/tendermint/libs/db"
"github.com/tendermint/tendermint/libs/log"
dbm "github.com/tendermint/tm-db"
)

const (
Expand Down
3 changes: 1 addition & 2 deletions blockchain/reactor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,16 @@ import (
"time"

"github.com/stretchr/testify/assert"

abci "github.com/tendermint/tendermint/abci/types"
cfg "github.com/tendermint/tendermint/config"
cmn "github.com/tendermint/tendermint/libs/common"
dbm "github.com/tendermint/tendermint/libs/db"
"github.com/tendermint/tendermint/libs/log"
"github.com/tendermint/tendermint/p2p"
"github.com/tendermint/tendermint/proxy"
sm "github.com/tendermint/tendermint/state"
"github.com/tendermint/tendermint/types"
tmtime "github.com/tendermint/tendermint/types/time"
dbm "github.com/tendermint/tm-db"
)

var config *cfg.Config
Expand Down
7 changes: 3 additions & 4 deletions blockchain/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ import (
"sync"

cmn "github.com/tendermint/tendermint/libs/common"
dbm "github.com/tendermint/tendermint/libs/db"

"github.com/tendermint/tendermint/types"
dbm "github.com/tendermint/tm-db"
)

/*
Expand Down Expand Up @@ -189,9 +188,9 @@ func (bs *BlockStore) SaveBlock(block *types.Block, blockParts *types.PartSet, s
func (bs *BlockStore) RetreatLastBlock() {
height := bs.height
bs.db.Delete(calcBlockMetaKey(height))
bs.db.Delete(calcBlockCommitKey(height-1))
bs.db.Delete(calcBlockCommitKey(height - 1))
bs.db.Delete(calcSeenCommitKey(height))
BlockStoreStateJSON{Height: height-1 }.Save(bs.db)
BlockStoreStateJSON{Height: height - 1}.Save(bs.db)
// Done!
bs.mtx.Lock()
bs.height = height
Expand Down
12 changes: 5 additions & 7 deletions blockchain/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,11 @@ import (
"github.com/stretchr/testify/require"
cfg "github.com/tendermint/tendermint/config"
cmn "github.com/tendermint/tendermint/libs/common"
"github.com/tendermint/tendermint/libs/db"
dbm "github.com/tendermint/tendermint/libs/db"
"github.com/tendermint/tendermint/libs/log"
sm "github.com/tendermint/tendermint/state"

"github.com/tendermint/tendermint/types"
tmtime "github.com/tendermint/tendermint/types/time"
dbm "github.com/tendermint/tm-db"
)

func makeStateAndBlockStore(logger log.Logger) (sm.State, *BlockStore) {
Expand All @@ -34,7 +32,7 @@ func makeStateAndBlockStore(logger log.Logger) (sm.State, *BlockStore) {
}

func TestLoadBlockStoreStateJSON(t *testing.T) {
db := db.NewMemDB()
db := dbm.NewMemDB()

bsj := &BlockStoreStateJSON{Height: 1000}
bsj.Save(db)
Expand All @@ -45,7 +43,7 @@ func TestLoadBlockStoreStateJSON(t *testing.T) {
}

func TestNewBlockStore(t *testing.T) {
db := db.NewMemDB()
db := dbm.NewMemDB()
db.Set(blockStoreKey, []byte(`{"height": "10000"}`))
bs := NewBlockStore(db)
require.Equal(t, int64(10000), bs.Height(), "failed to properly parse blockstore")
Expand Down Expand Up @@ -74,8 +72,8 @@ func TestNewBlockStore(t *testing.T) {
assert.Equal(t, bs.Height(), int64(0), "expecting nil bytes to be unmarshaled alright")
}

func freshBlockStore() (*BlockStore, db.DB) {
db := db.NewMemDB()
func freshBlockStore() (*BlockStore, dbm.DB) {
db := dbm.NewMemDB()
return NewBlockStore(db), db
}

Expand Down
15 changes: 13 additions & 2 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,18 @@ type BaseConfig struct {

ReplayHeight int64 `mapstructure:"replay_height"`

// Database backend: leveldb | memdb | cleveldb
// Database backend: goleveldb | cleveldb | boltdb
// * goleveldb (github.com/syndtr/goleveldb - most popular implementation)
// - pure go
// - stable
// * cleveldb (uses levigo wrapper)
// - fast
// - requires gcc
// - use cleveldb build tag (go build -tags cleveldb)
// * boltdb (uses etcd's fork of bolt - github.com/etcd-io/bbolt)
// - EXPERIMENTAL
// - may be faster is some use-cases (random reads - indexer)
// - use boltdb build tag (go build -tags boltdb)
DBBackend string `mapstructure:"db_backend"`

// Database directory
Expand Down Expand Up @@ -203,7 +214,7 @@ func DefaultBaseConfig() BaseConfig {
Deprecated: false,
ReplayHeight: -1,
FilterPeers: false,
DBBackend: "leveldb",
DBBackend: "goleveldb",
DBPath: "data",
}
}
Expand Down
13 changes: 12 additions & 1 deletion config/toml.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,18 @@ fast_sync = {{ .BaseConfig.FastSync }}
# shutdown
deprecated = {{ .BaseConfig.Deprecated }}
# Database backend: leveldb | memdb | cleveldb
# Database backend: goleveldb | cleveldb | boltdb
# * goleveldb (github.com/syndtr/goleveldb - most popular implementation)
# - pure go
# - stable
# * cleveldb (uses levigo wrapper)
# - fast
# - requires gcc
# - use cleveldb build tag (go build -tags cleveldb)
# * boltdb (uses etcd's fork of bolt - github.com/etcd-io/bbolt)
# - EXPERIMENTAL
# - may be faster is some use-cases (random reads - indexer)
# - use boltdb build tag (go build -tags boltdb)
db_backend = "{{ .BaseConfig.DBBackend }}"
# Database directory
Expand Down
4 changes: 4 additions & 0 deletions consensus/byzantine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,10 @@ type ByzantineReactor struct {
reactor *ConsensusReactor
}

func (br *ByzantineReactor) InitPeer(peer p2p.Peer) p2p.Peer {
return peer
}

func NewByzantineReactor(conR *ConsensusReactor) *ByzantineReactor {
return &ByzantineReactor{
Service: conR,
Expand Down
10 changes: 4 additions & 6 deletions consensus/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,23 @@ import (
"testing"
"time"

"github.com/go-kit/kit/log/term"
abcicli "github.com/tendermint/tendermint/abci/client"
"github.com/tendermint/tendermint/abci/example/counter"
"github.com/tendermint/tendermint/abci/example/kvstore"
abci "github.com/tendermint/tendermint/abci/types"
bc "github.com/tendermint/tendermint/blockchain"
cfg "github.com/tendermint/tendermint/config"
cstypes "github.com/tendermint/tendermint/consensus/types"
cmn "github.com/tendermint/tendermint/libs/common"
dbm "github.com/tendermint/tendermint/libs/db"
"github.com/tendermint/tendermint/libs/log"
mempl "github.com/tendermint/tendermint/mempool"
"github.com/tendermint/tendermint/p2p"
"github.com/tendermint/tendermint/privval"
sm "github.com/tendermint/tendermint/state"
"github.com/tendermint/tendermint/types"
tmtime "github.com/tendermint/tendermint/types/time"

"github.com/tendermint/tendermint/abci/example/counter"
"github.com/tendermint/tendermint/abci/example/kvstore"

"github.com/go-kit/kit/log/term"
dbm "github.com/tendermint/tm-db"
)

const (
Expand Down
34 changes: 24 additions & 10 deletions consensus/reactor.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,13 @@ func (conR *ConsensusReactor) SwitchToConsensus(state sm.State, blocksSynced int
}
err := conR.conS.Start()
if err != nil {
conR.Logger.Error("Error starting conS", "err", err)
return
panic(fmt.Sprintf(`Failed to start consensus state: %v
conS:
%+v
conR:
%+v`, err, conR.conS, conR))
}
}

Expand Down Expand Up @@ -155,15 +160,24 @@ func (conR *ConsensusReactor) GetChannels() []*p2p.ChannelDescriptor {
}
}

// AddPeer implements Reactor
// InitPeer implements Reactor by creating a state for the peer.
func (conR *ConsensusReactor) InitPeer(peer p2p.Peer) p2p.Peer {
peerState := NewPeerState(peer).SetLogger(conR.Logger)
peer.Set(types.PeerStateKey, peerState)
return peer
}

// AddPeer implements Reactor by spawning multiple gossiping goroutines for the
// peer.
func (conR *ConsensusReactor) AddPeer(peer p2p.Peer) {
if !conR.IsRunning() {
return
}

// Create peerState for peer
peerState := NewPeerState(peer).SetLogger(conR.Logger)
peer.Set(types.PeerStateKey, peerState)
peerState, ok := peer.Get(types.PeerStateKey).(*PeerState)
if !ok {
panic(fmt.Sprintf("peer %v has no state", peer))
}

// Begin routines for this peer.
go conR.gossipDataRoutine(peer, peerState)
Expand All @@ -177,7 +191,7 @@ func (conR *ConsensusReactor) AddPeer(peer p2p.Peer) {
}
}

// RemovePeer implements Reactor
// RemovePeer is a noop.
func (conR *ConsensusReactor) RemovePeer(peer p2p.Peer, reason interface{}) {
if !conR.IsRunning() {
return
Expand Down Expand Up @@ -438,9 +452,9 @@ func (conR *ConsensusReactor) broadcastHasVoteMessage(vote *types.Vote) {

func makeRoundStepMessage(rs *cstypes.RoundState) (nrsMsg *NewRoundStepMessage) {
nrsMsg = &NewRoundStepMessage{
Height: rs.Height,
Round: rs.Round,
Step: rs.Step,
Height: rs.Height,
Round: rs.Round,
Step: rs.Step,
SecondsSinceStartTime: int(time.Since(rs.StartTime).Seconds()),
LastCommitRound: rs.LastCommit.Round(),
}
Expand Down
2 changes: 1 addition & 1 deletion consensus/reactor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ import (
cstypes "github.com/tendermint/tendermint/consensus/types"
"github.com/tendermint/tendermint/crypto/tmhash"
cmn "github.com/tendermint/tendermint/libs/common"
dbm "github.com/tendermint/tendermint/libs/db"
"github.com/tendermint/tendermint/libs/log"
mempl "github.com/tendermint/tendermint/mempool"
"github.com/tendermint/tendermint/p2p"
sm "github.com/tendermint/tendermint/state"
"github.com/tendermint/tendermint/types"
dbm "github.com/tendermint/tm-db"
)

func init() {
Expand Down
Loading

0 comments on commit 1030bc7

Please sign in to comment.