diff --git a/README.md b/README.md index 807b9531c..aa49a704f 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,8 @@ # Tendermint -Simple, Secure, Scalable Blockchain Platform + +[Byzantine-Fault Tolerant](https://en.wikipedia.org/wiki/Byzantine_fault_tolerance) +[State Machine Replication](https://en.wikipedia.org/wiki/State_machine_replication). +Or [Blockchain](https://en.wikipedia.org/wiki/Blockchain_(database)) for short. [![version](https://img.shields.io/github/tag/tendermint/tendermint.svg)](https://github.com/tendermint/tendermint/releases/latest) [![API Reference]( @@ -16,26 +19,29 @@ master | [![CircleCI](https://circleci.com/gh/tendermint/tendermint/tree/mast _NOTE: This is yet pre-alpha non-production-quality software._ Tendermint Core is Byzantine Fault Tolerant (BFT) middleware that takes a state transition machine, written in any programming language, -and replicates it on many machines. -See the [application developers guide](https://github.com/tendermint/tendermint/wiki/Application-Developers) to get started. +and securely replicates it on many machines. + +For more background, see the [introduction](https://tendermint.com/intro). + +To get started developing applications, see the [application developers guide](https://tendermint.com/docs/guides/app-development). + +## Install + +`go get -u github.com/tendermint/tendermint/cmd/tendermint` + +For more details (or if it fails), see the [install guide](https://tendermint.com/intro/getting-started/install). ## Contributing -Yay open source! Please see our [contributing guidelines](https://github.com/tendermint/tendermint/wiki/Contributing). +Yay open source! Please see our [contributing guidelines](https://tendermint.com/guides/contributing). ## Resources ### Tendermint Core -- [Introduction](https://github.com/tendermint/tendermint/wiki/Introduction) -- [Validators](https://github.com/tendermint/tendermint/wiki/Validators) -- [Byzantine Consensus Algorithm](https://github.com/tendermint/tendermint/wiki/Byzantine-Consensus-Algorithm) -- [Block Structure](https://github.com/tendermint/tendermint/wiki/Block-Structure) -- [RPC](https://github.com/tendermint/tendermint/wiki/RPC) -- [Genesis](https://github.com/tendermint/tendermint/wiki/Genesis) -- [Configuration](https://github.com/tendermint/tendermint/wiki/Configuration) -- [Light Client Protocol](https://github.com/tendermint/tendermint/wiki/Light-Client-Protocol) -- [Roadmap for V2](https://github.com/tendermint/tendermint/wiki/Roadmap-for-V2) +- [Introduction](https://tendermint.com/intro) +- [Docs](https://tendermint.com/docs) +- [Software using Tendermint](https://tendermint.com/ecosystem) ### Sub-projects @@ -45,8 +51,15 @@ Yay open source! Please see our [contributing guidelines](https://github.com/ten * [Go-P2P](http://github.com/tendermint/go-p2p) * [Go-Merkle](http://github.com/tendermint/go-merkle) -## Install +### Applications -`go get -u github.com/tendermint/tendermint/cmd/tendermint` +* [Ethermint](http://github.com/tendermint/ethermint) +* [Basecoin](http://github.com/tendermint/basecoin) + +### More + +* [Tendermint Blog](https://tendermint.com/blog) +* [Cosmos Blog](https://cosmos.network/blog) +* [Original Whitepaper (out-of-date)](http://www.the-blockchain.com/docs/Tendermint%20Consensus%20without%20Mining.pdf) +* [Master's Thesis on Tendermint](https://atrium.lib.uoguelph.ca/xmlui/handle/10214/9769) -For more details, see the [install guide](https://github.com/tendermint/tendermint/wiki/Installation). diff --git a/blockchain/pool.go b/blockchain/pool.go index 86f67296d..d528e052a 100644 --- a/blockchain/pool.go +++ b/blockchain/pool.go @@ -5,8 +5,8 @@ import ( "sync" "time" - flow "github.com/tendermint/flowcontrol" . "github.com/tendermint/go-common" + flow "github.com/tendermint/go-flowrate/flowrate" "github.com/tendermint/tendermint/types" ) diff --git a/cmd/tendermint/flags.go b/cmd/tendermint/flags.go index 1765cc545..707917920 100644 --- a/cmd/tendermint/flags.go +++ b/cmd/tendermint/flags.go @@ -19,11 +19,15 @@ func parseFlags(config cfg.Config, args []string) { logLevel string proxyApp string tmspTransport string + + pex bool ) // Declare flags var flags = flag.NewFlagSet("main", flag.ExitOnError) flags.BoolVar(&printHelp, "help", false, "Print this help message.") + + // configuration options flags.StringVar(&moniker, "moniker", config.GetString("moniker"), "Node Name") flags.StringVar(&nodeLaddr, "node_laddr", config.GetString("node_laddr"), "Node listen address. (0.0.0.0:0 means any interface, any port)") flags.StringVar(&seeds, "seeds", config.GetString("seeds"), "Comma delimited host:port seed nodes") @@ -34,6 +38,10 @@ func parseFlags(config cfg.Config, args []string) { 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)") + + // feature flags + flags.BoolVar(&pex, "pex", config.GetBool("pex_reactor"), "Enable Peer-Exchange (dev feature)") + flags.Parse(args) if printHelp { flags.PrintDefaults() @@ -50,4 +58,6 @@ func parseFlags(config cfg.Config, args []string) { config.Set("log_level", logLevel) config.Set("proxy_app", proxyApp) config.Set("tmsp", tmspTransport) + + config.Set("pex_reactor", pex) } diff --git a/config/tendermint/config.go b/config/tendermint/config.go index 465297ba3..2b22f232e 100644 --- a/config/tendermint/config.go +++ b/config/tendermint/config.go @@ -61,6 +61,8 @@ func GetConfig(rootDir string) cfg.Config { mapConfig.SetDefault("fast_sync", true) mapConfig.SetDefault("skip_upnp", false) mapConfig.SetDefault("addrbook_file", rootDir+"/addrbook.json") + mapConfig.SetDefault("addrbook_strict", true) // disable to allow connections locally + mapConfig.SetDefault("pex_reactor", false) // enable for peer exchange mapConfig.SetDefault("priv_validator_file", rootDir+"/priv_validator.json") mapConfig.SetDefault("db_backend", "leveldb") mapConfig.SetDefault("db_dir", rootDir+"/data") diff --git a/config/tendermint_test/config.go b/config/tendermint_test/config.go index 6f3217475..a14c6b058 100644 --- a/config/tendermint_test/config.go +++ b/config/tendermint_test/config.go @@ -74,6 +74,8 @@ func ResetConfig(localPath string) cfg.Config { mapConfig.SetDefault("fast_sync", false) mapConfig.SetDefault("skip_upnp", true) mapConfig.SetDefault("addrbook_file", rootDir+"/addrbook.json") + mapConfig.SetDefault("addrbook_strict", true) // disable to allow connections locally + mapConfig.SetDefault("pex_reactor", false) // enable for peer exchange mapConfig.SetDefault("priv_validator_file", rootDir+"/priv_validator.json") mapConfig.SetDefault("db_backend", "memdb") mapConfig.SetDefault("db_dir", rootDir+"/data") diff --git a/glide.lock b/glide.lock index 39ead0864..40f3b45d9 100644 --- a/glide.lock +++ b/glide.lock @@ -49,8 +49,8 @@ imports: subpackages: - edwards25519 - extra25519 -- name: github.com/tendermint/flowcontrol - version: 84d9671090430e8ec80e35b339907e0579b999eb +- name: github.com/tendermint/go-flowrate + version: a20c98e61957faa93b4014fbd902f20ab9317a6a - name: github.com/tendermint/go-clist version: 3baa390bbaf7634251c42ad69a8682e7e3990552 - name: github.com/tendermint/go-common @@ -70,7 +70,7 @@ imports: - name: github.com/tendermint/go-merkle version: 05042c6ab9cad51d12e4cecf717ae68e3b1409a8 - name: github.com/tendermint/go-p2p - version: 1eb390680d33299ba0e3334490eca587efd18414 + version: eab2baa363de01b052b88c559e803776cd2c7dd6 subpackages: - upnp - name: github.com/tendermint/go-rpc diff --git a/glide.yaml b/glide.yaml index 0b11807a3..a24fe80d6 100644 --- a/glide.yaml +++ b/glide.yaml @@ -6,7 +6,6 @@ import: - package: github.com/gorilla/websocket - package: github.com/spf13/pflag - package: github.com/tendermint/ed25519 -- package: github.com/tendermint/flowcontrol - package: github.com/tendermint/go-clist - package: github.com/tendermint/go-common - package: github.com/tendermint/go-config @@ -34,3 +33,6 @@ import: - package: golang.org/x/crypto subpackages: - ripemd160 +- package: github.com/tendermint/go-flowrate + subpackages: + - flowrate diff --git a/node/node.go b/node/node.go index bb191b55e..1f75b5725 100644 --- a/node/node.go +++ b/node/node.go @@ -115,6 +115,15 @@ func NewNode(config cfg.Config, privValidator *types.PrivValidator, clientCreato sw.AddReactor("BLOCKCHAIN", bcReactor) sw.AddReactor("CONSENSUS", consensusReactor) + // Optionally, start the pex reactor + // TODO: this is a dev feature, it needs some love + if config.GetBool("pex_reactor") { + addrBook := p2p.NewAddrBook(config.GetString("addrbook_file"), config.GetBool("addrbook_strict")) + addrBook.Start() + pexReactor := p2p.NewPEXReactor(addrBook) + sw.AddReactor("PEX", pexReactor) + } + // filter peers by addr or pubkey with a tmsp query. // if the query return code is OK, add peer // XXX: query format subject to change diff --git a/rpc/core/blocks.go b/rpc/core/blocks.go index 92ed7bc7e..115ca2a9c 100644 --- a/rpc/core/blocks.go +++ b/rpc/core/blocks.go @@ -9,6 +9,7 @@ import ( //----------------------------------------------------------------------------- +// TODO: limit/permission on (max - min) func BlockchainInfo(minHeight, maxHeight int) (*ctypes.ResultBlockchainInfo, error) { if maxHeight == 0 { maxHeight = blockStore.Height() diff --git a/rpc/core/net.go b/rpc/core/net.go index 3cf1fd9e3..9e9f027ea 100644 --- a/rpc/core/net.go +++ b/rpc/core/net.go @@ -1,8 +1,6 @@ package core import ( - "fmt" - ctypes "github.com/tendermint/tendermint/rpc/core/types" ) @@ -31,12 +29,8 @@ func NetInfo() (*ctypes.ResultNetInfo, error) { //----------------------------------------------------------------------------- -// Dial given list of seeds if we have no outbound peers -func DialSeeds(seeds []string) (*ctypes.ResultDialSeeds, error) { - outbound, _, _ := p2pSwitch.NumPeers() - if outbound != 0 { - return nil, fmt.Errorf("Already have some outbound peers") - } +// Dial given list of seeds +func UnsafeDialSeeds(seeds []string) (*ctypes.ResultDialSeeds, error) { // starts go routines to dial each seed after random delays p2pSwitch.DialSeeds(seeds) return &ctypes.ResultDialSeeds{}, nil diff --git a/rpc/core/routes.go b/rpc/core/routes.go index 97c013ab7..8a9728aa9 100644 --- a/rpc/core/routes.go +++ b/rpc/core/routes.go @@ -6,30 +6,38 @@ import ( ctypes "github.com/tendermint/tendermint/rpc/core/types" ) +// TODO: better system than "unsafe" prefix var Routes = map[string]*rpc.RPCFunc{ // subscribe/unsubscribe are reserved for websocket events. "subscribe": rpc.NewWSRPCFunc(SubscribeResult, "event"), "unsubscribe": rpc.NewWSRPCFunc(UnsubscribeResult, "event"), + // info API "status": rpc.NewRPCFunc(StatusResult, ""), "net_info": rpc.NewRPCFunc(NetInfoResult, ""), - "dial_seeds": rpc.NewRPCFunc(DialSeedsResult, "seeds"), "blockchain": rpc.NewRPCFunc(BlockchainInfoResult, "minHeight,maxHeight"), "genesis": rpc.NewRPCFunc(GenesisResult, ""), "block": rpc.NewRPCFunc(BlockResult, "height"), "validators": rpc.NewRPCFunc(ValidatorsResult, ""), "dump_consensus_state": rpc.NewRPCFunc(DumpConsensusStateResult, ""), - "broadcast_tx_commit": rpc.NewRPCFunc(BroadcastTxCommitResult, "tx"), - "broadcast_tx_sync": rpc.NewRPCFunc(BroadcastTxSyncResult, "tx"), - "broadcast_tx_async": rpc.NewRPCFunc(BroadcastTxAsyncResult, "tx"), "unconfirmed_txs": rpc.NewRPCFunc(UnconfirmedTxsResult, ""), "num_unconfirmed_txs": rpc.NewRPCFunc(NumUnconfirmedTxsResult, ""), + // broadcast API + "broadcast_tx_commit": rpc.NewRPCFunc(BroadcastTxCommitResult, "tx"), + "broadcast_tx_sync": rpc.NewRPCFunc(BroadcastTxSyncResult, "tx"), + "broadcast_tx_async": rpc.NewRPCFunc(BroadcastTxAsyncResult, "tx"), + + // tmsp API "tmsp_query": rpc.NewRPCFunc(TMSPQueryResult, "query"), "tmsp_info": rpc.NewRPCFunc(TMSPInfoResult, ""), - "unsafe_flush_mempool": rpc.NewRPCFunc(UnsafeFlushMempool, ""), - "unsafe_set_config": rpc.NewRPCFunc(UnsafeSetConfigResult, "type,key,value"), + // control API + "dial_seeds": rpc.NewRPCFunc(UnsafeDialSeedsResult, "seeds"), + "unsafe_flush_mempool": rpc.NewRPCFunc(UnsafeFlushMempool, ""), + "unsafe_set_config": rpc.NewRPCFunc(UnsafeSetConfigResult, "type,key,value"), + + // profiler API "unsafe_start_cpu_profiler": rpc.NewRPCFunc(UnsafeStartCPUProfilerResult, "filename"), "unsafe_stop_cpu_profiler": rpc.NewRPCFunc(UnsafeStopCPUProfilerResult, ""), "unsafe_write_heap_profile": rpc.NewRPCFunc(UnsafeWriteHeapProfileResult, "filename"), @@ -67,8 +75,8 @@ func NetInfoResult() (ctypes.TMResult, error) { } } -func DialSeedsResult(seeds []string) (ctypes.TMResult, error) { - if r, err := DialSeeds(seeds); err != nil { +func UnsafeDialSeedsResult(seeds []string) (ctypes.TMResult, error) { + if r, err := UnsafeDialSeeds(seeds); err != nil { return nil, err } else { return r, nil diff --git a/scripts/glide/parse.sh b/scripts/glide/parse.sh index 86b5567b7..8e8ed1779 100644 --- a/scripts/glide/parse.sh +++ b/scripts/glide/parse.sh @@ -1,10 +1,11 @@ #! /bin/bash -set -euo pipefail - -LIB=$1 if [[ "$GLIDE" == "" ]]; then GLIDE=$GOPATH/src/github.com/tendermint/tendermint/glide.lock fi +set -euo pipefail + +LIB=$1 + cat $GLIDE | grep -A1 $LIB | grep -v $LIB | awk '{print $2}' diff --git a/test/test_libs.sh b/test/test_libs.sh index 9f601f788..b0599256e 100644 --- a/test/test_libs.sh +++ b/test/test_libs.sh @@ -1,4 +1,5 @@ #! /bin/bash +set -e # set glide.lock path if [[ "$GLIDE" == "" ]]; then @@ -28,10 +29,11 @@ for lib in "${LIBS_GO_TEST[@]}"; do done for lib in "${LIBS_MAKE_TEST[@]}"; do - getDep $lib + + # checkout vendored version of lib + bash scripts/glide/checkout.sh $GLIDE $lib echo "Testing $lib ..." - cd $GOPATH/src/github.com/tendermint/$lib make test if [[ "$?" != 0 ]]; then echo "FAIL"