Skip to content

Commit

Permalink
Merge pull request #366 from tendermint/release-0.8.0
Browse files Browse the repository at this point in the history
Release 0.8.0
  • Loading branch information
jaekwon committed Jan 13, 2017
2 parents c3a3cc7 + ab1fa4d commit 764091d
Show file tree
Hide file tree
Showing 116 changed files with 5,254 additions and 2,062 deletions.
3 changes: 0 additions & 3 deletions .codecov.yml
Expand Up @@ -14,9 +14,6 @@ coverage:
project:
default:
threshold: 1% # allow this much decrease on project
patch:
default:
threshold: 50% # allow this much decrease on patch
changes: false

comment:
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -10,3 +10,5 @@ rpc/test/.tendermint
remote_dump
.revision
vendor
.vagrant
test/p2p/data/
9 changes: 5 additions & 4 deletions Makefile
Expand Up @@ -12,19 +12,19 @@ NOVENDOR = go list github.com/tendermint/tendermint/... | grep -v /vendor/
install: get_deps
go install github.com/tendermint/tendermint/cmd/tendermint

build:
build:
go build -o build/tendermint github.com/tendermint/tendermint/cmd/tendermint

build_race:
build_race:
go build -race -o build/tendermint github.com/tendermint/tendermint/cmd/tendermint

test: build
go test `${NOVENDOR}`

test_race: build
go test -race `${NOVENDOR}`

test_integrations:
test_integrations:
bash ./test/test.sh

test100: build
Expand All @@ -48,6 +48,7 @@ get_deps:

get_vendor_deps:
go get github.com/Masterminds/glide
rm -rf vendor/
glide install

update_deps:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -45,7 +45,7 @@ Yay open source! Please see our [contributing guidelines](https://tendermint.com

### Sub-projects

* [TMSP](http://github.com/tendermint/tmsp)
* [ABCI](http://github.com/tendermint/abci)
* [Mintnet](http://github.com/tendermint/mintnet)
* [Go-Wire](http://github.com/tendermint/go-wire)
* [Go-P2P](http://github.com/tendermint/go-p2p)
Expand Down
44 changes: 26 additions & 18 deletions Vagrantfile
@@ -1,25 +1,33 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :

# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/trusty64"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "phusion-open-ubuntu-14.04-amd64"
config.vm.box_url = "https://oss-binaries.phusionpassenger.com/vagrant/boxes/latest/ubuntu-14.04-amd64-vbox.box"
# Or, for Ubuntu 12.04:

config.vm.provider :vmware_fusion do |f, override|
override.vm.box_url = "https://oss-binaries.phusionpassenger.com/vagrant/boxes/latest/ubuntu-14.04-amd64-vmwarefusion.box"
config.vm.provider "virtualbox" do |v|
v.memory = 2048
v.cpus = 2
end

if Dir.glob("#{File.dirname(__FILE__)}/.vagrant/machines/default/*/id").empty?
# Install Docker
pkg_cmd = "wget -q -O - https://get.docker.io/gpg | apt-key add -;" \
"echo deb http://get.docker.io/ubuntu docker main > /etc/apt/sources.list.d/docker.list;" \
"apt-get update -qq; apt-get install -q -y --force-yes lxc-docker; "
# Add vagrant user to the docker group
pkg_cmd << "usermod -a -G docker vagrant; "
config.vm.provision :shell, :inline => pkg_cmd
end
config.vm.provision "shell", inline: <<-SHELL
apt-get update
apt-get install -y --no-install-recommends wget curl jq shellcheck bsdmainutils psmisc
wget -qO- https://get.docker.com/ | sh
usermod -a -G docker vagrant
curl -O https://storage.googleapis.com/golang/go1.6.linux-amd64.tar.gz
tar -xvf go1.7.linux-amd64.tar.gz
mv go /usr/local
echo 'export PATH=$PATH:/usr/local/go/bin' >> /home/vagrant/.profile
mkdir -p /home/vagrant/go/bin
chown -R vagrant:vagrant /home/vagrant/go
echo 'export GOPATH=/home/vagrant/go' >> /home/vagrant/.profile
mkdir -p /home/vagrant/go/src/github.com/tendermint
ln -s /vagrant /home/vagrant/go/src/github.com/tendermint/tendermint
su - vagrant -c 'curl https://glide.sh/get | sh'
su - vagrant -c 'cd /vagrant/ && glide install && make test'
SHELL
end
14 changes: 7 additions & 7 deletions blockchain/pool.go
Expand Up @@ -32,7 +32,7 @@ var peerTimeoutSeconds = time.Duration(15) // not const so we can override with
*/

type BlockPool struct {
QuitService
BaseService
startTime time.Time

mtx sync.Mutex
Expand All @@ -58,19 +58,19 @@ func NewBlockPool(start int, requestsCh chan<- BlockRequest, timeoutsCh chan<- s
requestsCh: requestsCh,
timeoutsCh: timeoutsCh,
}
bp.QuitService = *NewQuitService(log, "BlockPool", bp)
bp.BaseService = *NewBaseService(log, "BlockPool", bp)
return bp
}

func (pool *BlockPool) OnStart() error {
pool.QuitService.OnStart()
pool.BaseService.OnStart()
go pool.makeRequestersRoutine()
pool.startTime = time.Now()
return nil
}

func (pool *BlockPool) OnStop() {
pool.QuitService.OnStop()
pool.BaseService.OnStop()
}

// Run spawns requesters as needed.
Expand Down Expand Up @@ -383,7 +383,7 @@ func (peer *bpPeer) onTimeout() {
//-------------------------------------

type bpRequester struct {
QuitService
BaseService
pool *BlockPool
height int
gotBlockCh chan struct{}
Expand All @@ -404,12 +404,12 @@ func newBPRequester(pool *BlockPool, height int) *bpRequester {
peerID: "",
block: nil,
}
bpr.QuitService = *NewQuitService(nil, "bpRequester", bpr)
bpr.BaseService = *NewBaseService(nil, "bpRequester", bpr)
return bpr
}

func (bpr *bpRequester) OnStart() error {
bpr.QuitService.OnStart()
bpr.BaseService.OnStart()
go bpr.requestRoutine()
return nil
}
Expand Down
33 changes: 17 additions & 16 deletions blockchain/reactor.go
Expand Up @@ -8,6 +8,7 @@ import (
"time"

. "github.com/tendermint/go-common"
cfg "github.com/tendermint/go-config"
"github.com/tendermint/go-p2p"
"github.com/tendermint/go-wire"
"github.com/tendermint/tendermint/proxy"
Expand Down Expand Up @@ -41,7 +42,7 @@ type consensusReactor interface {
type BlockchainReactor struct {
p2p.BaseReactor

sw *p2p.Switch
config cfg.Config
state *sm.State
proxyAppConn proxy.AppConnConsensus // same as consensus.proxyAppConn
store *BlockStore
Expand All @@ -54,7 +55,7 @@ type BlockchainReactor struct {
evsw types.EventSwitch
}

func NewBlockchainReactor(state *sm.State, proxyAppConn proxy.AppConnConsensus, store *BlockStore, fastSync bool) *BlockchainReactor {
func NewBlockchainReactor(config cfg.Config, state *sm.State, proxyAppConn proxy.AppConnConsensus, store *BlockStore, fastSync bool) *BlockchainReactor {
if state.LastBlockHeight == store.Height()-1 {
store.height -= 1 // XXX HACK, make this better
}
Expand All @@ -69,6 +70,7 @@ func NewBlockchainReactor(state *sm.State, proxyAppConn proxy.AppConnConsensus,
timeoutsCh,
)
bcR := &BlockchainReactor{
config: config,
state: state,
proxyAppConn: proxyAppConn,
store: store,
Expand Down Expand Up @@ -219,33 +221,32 @@ FOR_LOOP:
// We need both to sync the first block.
break SYNC_LOOP
}
firstParts := first.MakePartSet()
firstParts := first.MakePartSet(bcR.config.GetInt("block_part_size")) // TODO: put part size in parts header?
firstPartsHeader := firstParts.Header()
// Finally, verify the first block using the second's commit
// NOTE: we can probably make this more efficient, but note that calling
// first.Hash() doesn't verify the tx contents, so MakePartSet() is
// currently necessary.
err := bcR.state.Validators.VerifyCommit(
bcR.state.ChainID, first.Hash(), firstPartsHeader, first.Height, second.LastCommit)
bcR.state.ChainID, types.BlockID{first.Hash(), firstPartsHeader}, first.Height, second.LastCommit)
if err != nil {
log.Info("error in validation", "error", err)
bcR.pool.RedoRequest(first.Height)
break SYNC_LOOP
} else {
bcR.pool.PopRequest()
// TODO: use ApplyBlock instead of Exec/Commit/SetAppHash/Save
err := bcR.state.ExecBlock(bcR.evsw, bcR.proxyAppConn, first, firstPartsHeader)
if err != nil {
// TODO This is bad, are we zombie?
PanicQ(Fmt("Failed to process committed block (%d:%X): %v", first.Height, first.Hash(), err))
}

bcR.store.SaveBlock(first, firstParts, second.LastCommit)

// TODO: should we be firing events? need to fire NewBlock events manually ...
// NOTE: we could improve performance if we
// didn't make the app commit to disk every block
// ... but we would need a way to get the hash without it persisting
res := bcR.proxyAppConn.CommitSync()
if res.IsErr() {
// TODO Handle gracefully.
PanicQ(Fmt("Failed to commit block at application: %v", res))
err := bcR.state.ApplyBlock(bcR.evsw, bcR.proxyAppConn, first, firstPartsHeader, sm.MockMempool{})
if err != nil {
// TODO This is bad, are we zombie?
PanicQ(Fmt("Failed to process committed block (%d:%X): %v", first.Height, first.Hash(), err))
}
bcR.store.SaveBlock(first, firstParts, second.LastCommit)
bcR.state.AppHash = res.Data
bcR.state.Save()
}
}
Expand Down
23 changes: 17 additions & 6 deletions blockchain/store.go
Expand Up @@ -5,6 +5,7 @@ import (
"encoding/json"
"fmt"
"io"
"sync"

. "github.com/tendermint/go-common"
dbm "github.com/tendermint/go-db"
Expand All @@ -27,8 +28,10 @@ the Commit data outside the Block.
Panics indicate probable corruption in the data
*/
type BlockStore struct {
db dbm.DB

mtx sync.RWMutex
height int
db dbm.DB
}

func NewBlockStore(db dbm.DB) *BlockStore {
Expand All @@ -41,6 +44,8 @@ func NewBlockStore(db dbm.DB) *BlockStore {

// Height() returns the last known contiguous block height.
func (bs *BlockStore) Height() int {
bs.mtx.RLock()
defer bs.mtx.RUnlock()
return bs.height
}

Expand Down Expand Up @@ -141,8 +146,8 @@ func (bs *BlockStore) LoadSeenCommit(height int) *types.Commit {
// most recent height. Otherwise they'd stall at H-1.
func (bs *BlockStore) SaveBlock(block *types.Block, blockParts *types.PartSet, seenCommit *types.Commit) {
height := block.Height
if height != bs.height+1 {
PanicSanity(Fmt("BlockStore can only save contiguous blocks. Wanted %v, got %v", bs.height+1, height))
if height != bs.Height()+1 {
PanicSanity(Fmt("BlockStore can only save contiguous blocks. Wanted %v, got %v", bs.Height()+1, height))
}
if !blockParts.IsComplete() {
PanicSanity(Fmt("BlockStore can only save complete block part sets"))
Expand All @@ -163,19 +168,25 @@ func (bs *BlockStore) SaveBlock(block *types.Block, blockParts *types.PartSet, s
bs.db.Set(calcBlockCommitKey(height-1), blockCommitBytes)

// Save seen commit (seen +2/3 precommits for block)
// NOTE: we can delete this at a later height
seenCommitBytes := wire.BinaryBytes(seenCommit)
bs.db.Set(calcSeenCommitKey(height), seenCommitBytes)

// Save new BlockStoreStateJSON descriptor
BlockStoreStateJSON{Height: height}.Save(bs.db)

// Done!
bs.mtx.Lock()
bs.height = height
bs.mtx.Unlock()

// Flush
bs.db.SetSync(nil, nil)
}

func (bs *BlockStore) saveBlockPart(height int, index int, part *types.Part) {
if height != bs.height+1 {
PanicSanity(Fmt("BlockStore can only save contiguous blocks. Wanted %v, got %v", bs.height+1, height))
if height != bs.Height()+1 {
PanicSanity(Fmt("BlockStore can only save contiguous blocks. Wanted %v, got %v", bs.Height()+1, height))
}
partBytes := wire.BinaryBytes(part)
bs.db.Set(calcBlockPartKey(height, index), partBytes)
Expand Down Expand Up @@ -212,7 +223,7 @@ func (bsj BlockStoreStateJSON) Save(db dbm.DB) {
if err != nil {
PanicSanity(Fmt("Could not marshal state bytes: %v", err))
}
db.Set(blockStoreKey, bytes)
db.SetSync(blockStoreKey, bytes)
}

func LoadBlockStoreStateJSON(db dbm.DB) BlockStoreStateJSON {
Expand Down
4 changes: 3 additions & 1 deletion circle.yml
Expand Up @@ -29,7 +29,9 @@ dependencies:

test:
override:
- "cd $REPO && make test_integrations"
- "cd $REPO && set -o pipefail && make test_integrations | tee ~/test_integrations.log":
timeout: 1800
- "cp ~/test_integrations.log $CIRCLE_ARTIFACTS"
post:
- "cd $REPO && bash <(curl -s https://codecov.io/bash)"

Expand Down
9 changes: 6 additions & 3 deletions cmd/tendermint/flags.go
Expand Up @@ -16,9 +16,10 @@ func parseFlags(config cfg.Config, args []string) {
fastSync bool
skipUPNP bool
rpcLaddr string
grpcLaddr string
logLevel string
proxyApp string
tmspTransport string
abciTransport string

pex bool
)
Expand All @@ -34,10 +35,11 @@ func parseFlags(config cfg.Config, args []string) {
flags.BoolVar(&fastSync, "fast_sync", config.GetBool("fast_sync"), "Fast blockchain syncing")
flags.BoolVar(&skipUPNP, "skip_upnp", config.GetBool("skip_upnp"), "Skip UPNP configuration")
flags.StringVar(&rpcLaddr, "rpc_laddr", config.GetString("rpc_laddr"), "RPC listen address. Port required")
flags.StringVar(&grpcLaddr, "grpc_laddr", config.GetString("grpc_laddr"), "GRPC listen address (BroadcastTx only). Port required")
flags.StringVar(&logLevel, "log_level", config.GetString("log_level"), "Log level")
flags.StringVar(&proxyApp, "proxy_app", config.GetString("proxy_app"),
"Proxy app address, or 'nilapp' or 'dummy' for local testing.")
flags.StringVar(&tmspTransport, "tmsp", config.GetString("tmsp"), "Specify tmsp transport (socket | grpc)")
flags.StringVar(&abciTransport, "abci", config.GetString("abci"), "Specify abci transport (socket | grpc)")

// feature flags
flags.BoolVar(&pex, "pex", config.GetBool("pex_reactor"), "Enable Peer-Exchange (dev feature)")
Expand All @@ -55,9 +57,10 @@ func parseFlags(config cfg.Config, args []string) {
config.Set("fast_sync", fastSync)
config.Set("skip_upnp", skipUPNP)
config.Set("rpc_laddr", rpcLaddr)
config.Set("grpc_laddr", grpcLaddr)
config.Set("log_level", logLevel)
config.Set("proxy_app", proxyApp)
config.Set("tmsp", tmspTransport)
config.Set("abci", abciTransport)

config.Set("pex_reactor", pex)
}
6 changes: 3 additions & 3 deletions cmd/tendermint/main.go
Expand Up @@ -41,10 +41,10 @@ Commands:
case "node":
node.RunNode(config)
case "replay":
if len(args) > 1 && args[1] == "console" {
node.RunReplayConsole(config)
if len(args) > 2 && args[1] == "console" {
node.RunReplayConsole(config, args[2])
} else {
node.RunReplay(config)
node.RunReplay(config, args[1])
}
case "init":
init_files()
Expand Down
2 changes: 1 addition & 1 deletion cmd/tendermint/reset_priv_validator.go
Expand Up @@ -11,7 +11,7 @@ import (
func reset_all() {
reset_priv_validator()
os.RemoveAll(config.GetString("db_dir"))
os.Remove(config.GetString("cswal"))
os.RemoveAll(config.GetString("cs_wal_dir"))
}

// NOTE: this is totally unsafe.
Expand Down

0 comments on commit 764091d

Please sign in to comment.