From 179d6062e4c385b67af414129d6c3cd9b09cb79a Mon Sep 17 00:00:00 2001 From: Anton Kaliaev Date: Wed, 27 Dec 2017 14:16:49 -0600 Subject: [PATCH 01/10] try to connect through addrbook before requesting peers from seeds MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit we only use seeds if we can’t connect to peers in the addrbook. Refs #864 --- node/node.go | 38 +++++++++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 7 deletions(-) diff --git a/node/node.go b/node/node.go index fde8e1e0a..f8164955d 100644 --- a/node/node.go +++ b/node/node.go @@ -8,6 +8,7 @@ import ( "net" "net/http" "strings" + "time" abci "github.com/tendermint/abci/types" crypto "github.com/tendermint/go-crypto" @@ -379,19 +380,42 @@ func (n *Node) OnStart() error { return err } - // If seeds exist, add them to the address book and dial out - if n.config.P2P.Seeds != "" { - // dial out - seeds := strings.Split(n.config.P2P.Seeds, ",") - if err := n.DialSeeds(seeds); err != nil { - return err - } + err = n.dialSeedsIfAddrBookIsEmptyOrPEXFailedToConnect() + if err != nil { + return err } // start tx indexer return n.indexerService.Start() } +func (n *Node) dialSeedsIfAddrBookIsEmptyOrPEXFailedToConnect() error { + if n.config.P2P.Seeds == "" { + return nil + } + + seeds := strings.Split(n.config.P2P.Seeds, ",") + + // prefer peers from address book + if n.config.P2P.PexReactor && n.addrBook.Size() > 0 { + // give some time to PexReactor to connect us to other peers + const fallbackToSeedsAfterSec = 30 * time.Second + go func() { + time.Sleep(fallbackToSeedsAfterSec) + // fallback to dialing seeds if for some reason we can't connect to any + // peers + outbound, inbound, _ := n.sw.NumPeers() + if n.IsRunning() && outbound+inbound == 0 { + n.DialSeeds(seeds) + } + }() + return nil + } + + // add seeds to the address book and dial out + return n.DialSeeds(seeds) +} + // OnStop stops the Node. It implements cmn.Service. func (n *Node) OnStop() { n.BaseService.OnStop() From 28fc15028a16ed866354ca8f4be853effda14ca6 Mon Sep 17 00:00:00 2001 From: Anton Kaliaev Date: Thu, 28 Dec 2017 12:54:39 -0600 Subject: [PATCH 02/10] distinguish between seeds and manual peers in the config/flags MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - we only use seeds if we can’t connect to peers in the addrbook. - we always connect to nodes given in config/flags Refs #864 --- benchmarks/blockchain/localsync.sh | 2 +- cmd/tendermint/commands/run_node.go | 1 + config/config.go | 7 +++- config/toml.go | 2 + docs/deploy-testnets.rst | 6 +-- docs/specification/configuration.rst | 2 + docs/specification/rpc.rst | 2 +- docs/using-tendermint.rst | 10 ++--- node/node.go | 41 +++++++++---------- p2p/pex_reactor.go | 2 +- p2p/switch.go | 28 ++++++------- rpc/client/localclient.go | 4 +- rpc/client/mock/client.go | 4 +- rpc/core/doc.go | 2 +- rpc/core/net.go | 16 ++++---- rpc/core/pipe.go | 2 +- rpc/core/routes.go | 2 +- rpc/core/types/responses.go | 2 +- test/p2p/README.md | 2 +- test/p2p/fast_sync/test_peer.sh | 6 +-- test/p2p/local_testnet_start.sh | 10 ++--- test/p2p/manual_peers.sh | 12 ++++++ .../{dial_seeds.sh => dial_manual_peers.sh} | 12 +++--- test/p2p/pex/test.sh | 4 +- test/p2p/pex/test_addrbook.sh | 8 ++-- ...ial_seeds.sh => test_dial_manual_peers.sh} | 14 +++---- test/p2p/seeds.sh | 12 ------ test/p2p/test.sh | 4 +- 28 files changed, 112 insertions(+), 107 deletions(-) create mode 100644 test/p2p/manual_peers.sh rename test/p2p/pex/{dial_seeds.sh => dial_manual_peers.sh} (60%) rename test/p2p/pex/{test_dial_seeds.sh => test_dial_manual_peers.sh} (75%) delete mode 100644 test/p2p/seeds.sh diff --git a/benchmarks/blockchain/localsync.sh b/benchmarks/blockchain/localsync.sh index e181c5655..18afaee82 100755 --- a/benchmarks/blockchain/localsync.sh +++ b/benchmarks/blockchain/localsync.sh @@ -51,7 +51,7 @@ tendermint node \ --proxy_app dummy \ --p2p.laddr tcp://127.0.0.1:56666 \ --rpc.laddr tcp://127.0.0.1:56667 \ - --p2p.seeds 127.0.0.1:56656 \ + --p2p.manual_peers 127.0.0.1:56656 \ --log_level error & # wait for node to start up so we only count time where we are actually syncing diff --git a/cmd/tendermint/commands/run_node.go b/cmd/tendermint/commands/run_node.go index 0f37bb319..5b87a4b82 100644 --- a/cmd/tendermint/commands/run_node.go +++ b/cmd/tendermint/commands/run_node.go @@ -29,6 +29,7 @@ func AddNodeFlags(cmd *cobra.Command) { // p2p flags cmd.Flags().String("p2p.laddr", config.P2P.ListenAddress, "Node listen address. (0.0.0.0:0 means any interface, any port)") cmd.Flags().String("p2p.seeds", config.P2P.Seeds, "Comma delimited host:port seed nodes") + cmd.Flags().String("p2p.manual_peers", config.P2P.ManualPeers, "Comma delimited host:port manual peers") cmd.Flags().Bool("p2p.skip_upnp", config.P2P.SkipUPNP, "Skip UPNP configuration") cmd.Flags().Bool("p2p.pex", config.P2P.PexReactor, "Enable/disable Peer-Exchange") diff --git a/config/config.go b/config/config.go index 5d4a8ef65..2d38ed916 100644 --- a/config/config.go +++ b/config/config.go @@ -170,7 +170,7 @@ type RPCConfig struct { // NOTE: This server only supports /broadcast_tx_commit GRPCListenAddress string `mapstructure:"grpc_laddr"` - // Activate unsafe RPC commands like /dial_seeds and /unsafe_flush_mempool + // Activate unsafe RPC commands like /dial_manual_peers and /unsafe_flush_mempool Unsafe bool `mapstructure:"unsafe"` } @@ -203,8 +203,13 @@ type P2PConfig struct { ListenAddress string `mapstructure:"laddr"` // Comma separated list of seed nodes to connect to + // We only use these if we can’t connect to peers in the addrbook Seeds string `mapstructure:"seeds"` + // Comma separated list of manual peers to connect to + // We always connect to these + ManualPeers string `mapstructure:"manual_peers"` + // Skip UPNP port forwarding SkipUPNP bool `mapstructure:"skip_upnp"` diff --git a/config/toml.go b/config/toml.go index 735f45c12..59fc46dcf 100644 --- a/config/toml.go +++ b/config/toml.go @@ -42,6 +42,7 @@ laddr = "tcp://0.0.0.0:46657" [p2p] laddr = "tcp://0.0.0.0:46656" seeds = "" +manual_peers = "" ` func defaultConfig(moniker string) string { @@ -106,6 +107,7 @@ laddr = "tcp://0.0.0.0:36657" [p2p] laddr = "tcp://0.0.0.0:36656" seeds = "" +manual_peers = "" ` func testConfig(moniker string) (testConfig string) { diff --git a/docs/deploy-testnets.rst b/docs/deploy-testnets.rst index 89fa4b799..8c66c4b34 100644 --- a/docs/deploy-testnets.rst +++ b/docs/deploy-testnets.rst @@ -24,13 +24,13 @@ Here are the steps to setting up a testnet manually: ``tendermint gen_validator`` 4) Compile a list of public keys for each validator into a ``genesis.json`` file. -5) Run ``tendermint node --p2p.seeds=< seed addresses >`` on each node, - where ``< seed addresses >`` is a comma separated list of the IP:PORT +5) Run ``tendermint node --p2p.manual_peers=< peer addresses >`` on each node, + where ``< peer addresses >`` is a comma separated list of the IP:PORT combination for each node. The default port for Tendermint is ``46656``. Thus, if the IP addresses of your nodes were ``192.168.0.1, 192.168.0.2, 192.168.0.3, 192.168.0.4``, the command would look like: - ``tendermint node --p2p.seeds=192.168.0.1:46656,192.168.0.2:46656,192.168.0.3:46656,192.168.0.4:46656``. + ``tendermint node --p2p.manual_peers=192.168.0.1:46656,192.168.0.2:46656,192.168.0.3:46656,192.168.0.4:46656``. After a few seconds, all the nodes should connect to eachother and start making blocks! For more information, see the Tendermint Networks section diff --git a/docs/specification/configuration.rst b/docs/specification/configuration.rst index 74b41d09d..3271cd59d 100644 --- a/docs/specification/configuration.rst +++ b/docs/specification/configuration.rst @@ -49,6 +49,8 @@ The main config parameters are defined - ``p2p.pex``: Enable Peer-Exchange (dev feature). *Default*: ``false`` - ``p2p.seeds``: Comma delimited host:port seed nodes. *Default*: ``""`` +- ``p2p.manual_peers``: Comma delimited host:port manual peers. *Default*: + ``""`` - ``p2p.skip_upnp``: Skip UPNP detection. *Default*: ``false`` - ``rpc.grpc_laddr``: GRPC listen address (BroadcastTx only). Port diff --git a/docs/specification/rpc.rst b/docs/specification/rpc.rst index 33173d196..f637c1717 100644 --- a/docs/specification/rpc.rst +++ b/docs/specification/rpc.rst @@ -111,7 +111,7 @@ An HTTP Get request to the root RPC endpoint (e.g. http://localhost:46657/broadcast_tx_commit?tx=_ http://localhost:46657/broadcast_tx_sync?tx=_ http://localhost:46657/commit?height=_ - http://localhost:46657/dial_seeds?seeds=_ + http://localhost:46657/dial_manual_peers?manual_peers=_ http://localhost:46657/subscribe?event=_ http://localhost:46657/tx?hash=_&prove=_ http://localhost:46657/unsafe_start_cpu_profiler?filename=_ diff --git a/docs/using-tendermint.rst b/docs/using-tendermint.rst index 9076230ea..2ec5624ec 100644 --- a/docs/using-tendermint.rst +++ b/docs/using-tendermint.rst @@ -270,14 +270,14 @@ For instance, :: - tendermint node --p2p.seeds "1.2.3.4:46656,5.6.7.8:46656" + tendermint node --p2p.manual_peers "1.2.3.4:46656,5.6.7.8:46656" -Alternatively, you can use the ``/dial_seeds`` endpoint of the RPC to +Alternatively, you can use the ``/dial_manual_peers`` endpoint of the RPC to specify peers for a running node to connect to: :: - curl --data-urlencode "seeds=[\"1.2.3.4:46656\",\"5.6.7.8:46656\"]" localhost:46657/dial_seeds + curl --data-urlencode "manual_peers=[\"1.2.3.4:46656\",\"5.6.7.8:46656\"]" localhost:46657/dial_manual_peers Additionally, the peer-exchange protocol can be enabled using the ``--pex`` flag, though this feature is `still under @@ -290,7 +290,7 @@ Adding a Non-Validator Adding a non-validator is simple. Just copy the original ``genesis.json`` to ``~/.tendermint`` on the new machine and start the -node, specifying seeds as necessary. If no seeds are specified, the node +node, specifying manual_peers as necessary. If no manual_peers are specified, the node won't make any blocks, because it's not a validator, and it won't hear about any blocks, because it's not connected to the other peer. @@ -363,7 +363,7 @@ and the new ``priv_validator.json`` to the ``~/.tendermint`` on a new machine. Now run ``tendermint node`` on both machines, and use either -``--p2p.seeds`` or the ``/dial_seeds`` to get them to peer up. They +``--p2p.manual_peers`` or the ``/dial_manual_peers`` to get them to peer up. They should start making blocks, and will only continue to do so as long as both of them are online. diff --git a/node/node.go b/node/node.go index f8164955d..1970bb88e 100644 --- a/node/node.go +++ b/node/node.go @@ -380,40 +380,44 @@ func (n *Node) OnStart() error { return err } - err = n.dialSeedsIfAddrBookIsEmptyOrPEXFailedToConnect() - if err != nil { - return err + // Always connect to manual peers + if n.config.P2P.ManualPeers != "" { + err = n.sw.DialPeersAsync(n.addrBook, strings.Split(n.config.P2P.ManualPeers, ","), true) + if err != nil { + return err + } + } + + if n.config.P2P.Seeds != "" { + err = n.dialSeedsIfAddrBookIsEmptyOrPEXFailedToConnect(strings.Split(n.config.P2P.Seeds, ",")) + if err != nil { + return err + } } // start tx indexer return n.indexerService.Start() } -func (n *Node) dialSeedsIfAddrBookIsEmptyOrPEXFailedToConnect() error { - if n.config.P2P.Seeds == "" { - return nil - } - - seeds := strings.Split(n.config.P2P.Seeds, ",") - +func (n *Node) dialSeedsIfAddrBookIsEmptyOrPEXFailedToConnect(seeds []string) error { // prefer peers from address book if n.config.P2P.PexReactor && n.addrBook.Size() > 0 { - // give some time to PexReactor to connect us to other peers - const fallbackToSeedsAfterSec = 30 * time.Second + // give some time for PexReactor to connect us to other peers + const fallbackToSeedsAfter = 30 * time.Second go func() { - time.Sleep(fallbackToSeedsAfterSec) + time.Sleep(fallbackToSeedsAfter) // fallback to dialing seeds if for some reason we can't connect to any // peers outbound, inbound, _ := n.sw.NumPeers() if n.IsRunning() && outbound+inbound == 0 { - n.DialSeeds(seeds) + // TODO: ignore error? + n.sw.DialPeersAsync(n.addrBook, seeds, false) } }() return nil } - // add seeds to the address book and dial out - return n.DialSeeds(seeds) + return n.sw.DialPeersAsync(n.addrBook, seeds, false) } // OnStop stops the Node. It implements cmn.Service. @@ -599,11 +603,6 @@ func (n *Node) NodeInfo() *p2p.NodeInfo { return n.sw.NodeInfo() } -// DialSeeds dials the given seeds on the Switch. -func (n *Node) DialSeeds(seeds []string) error { - return n.sw.DialSeeds(n.addrBook, seeds) -} - //------------------------------------------------------------------------------ var ( diff --git a/p2p/pex_reactor.go b/p2p/pex_reactor.go index 2bfe7dcab..d4a8cbf18 100644 --- a/p2p/pex_reactor.go +++ b/p2p/pex_reactor.go @@ -100,7 +100,7 @@ func (r *PEXReactor) GetChannels() []*ChannelDescriptor { func (r *PEXReactor) AddPeer(p Peer) { if p.IsOutbound() { // For outbound peers, the address is already in the books. - // Either it was added in DialSeeds or when we + // Either it was added in DialManualPeers or when we // received the peer's address in r.Receive if r.book.NeedMoreAddrs() { r.RequestPEX(p) diff --git a/p2p/switch.go b/p2p/switch.go index 76b019806..4deee63d4 100644 --- a/p2p/switch.go +++ b/p2p/switch.go @@ -16,7 +16,7 @@ import ( const ( // wait a random amount of time from this interval - // before dialing seeds or reconnecting to help prevent DoS + // before dialing peers or reconnecting to help prevent DoS dialRandomizerIntervalMilliseconds = 3000 // repeatedly try to reconnect for a few minutes @@ -315,15 +315,15 @@ func (sw *Switch) startInitPeer(peer *peer) { } } -// DialSeeds dials a list of seeds asynchronously in random order. -func (sw *Switch) DialSeeds(addrBook *AddrBook, seeds []string) error { - netAddrs, errs := NewNetAddressStrings(seeds) +// DialPeersAsync dials a list of peers asynchronously in random order (optionally, making them persistent). +func (sw *Switch) DialPeersAsync(addrBook *AddrBook, peers []string, persistent bool) error { + netAddrs, errs := NewNetAddressStrings(peers) for _, err := range errs { - sw.Logger.Error("Error in seed's address", "err", err) + sw.Logger.Error("Error in peer's address", "err", err) } if addrBook != nil { - // add seeds to `addrBook` + // add manual peers to `addrBook` ourAddrS := sw.nodeInfo.ListenAddr ourAddr, _ := NewNetAddressString(ourAddrS) for _, netAddr := range netAddrs { @@ -342,7 +342,12 @@ func (sw *Switch) DialSeeds(addrBook *AddrBook, seeds []string) error { go func(i int) { sw.randomSleep(0) j := perm[i] - sw.dialSeed(netAddrs[j]) + peer, err := sw.DialPeerWithAddress(netAddrs[j], persistent) + if err != nil { + sw.Logger.Error("Error dialing peer", "err", err) + } else { + sw.Logger.Info("Connected to peer", "peer", peer) + } }(i) } return nil @@ -354,15 +359,6 @@ func (sw *Switch) randomSleep(interval time.Duration) { time.Sleep(r + interval) } -func (sw *Switch) dialSeed(addr *NetAddress) { - peer, err := sw.DialPeerWithAddress(addr, true) - if err != nil { - sw.Logger.Error("Error dialing seed", "err", err) - } else { - sw.Logger.Info("Connected to seed", "peer", peer) - } -} - // DialPeerWithAddress dials the given peer and runs sw.addPeer if it connects successfully. // If `persistent == true`, the switch will always try to reconnect to this peer if the connection ever fails. func (sw *Switch) DialPeerWithAddress(addr *NetAddress, persistent bool) (Peer, error) { diff --git a/rpc/client/localclient.go b/rpc/client/localclient.go index 71f25ef23..d30f7543c 100644 --- a/rpc/client/localclient.go +++ b/rpc/client/localclient.go @@ -84,8 +84,8 @@ func (Local) DumpConsensusState() (*ctypes.ResultDumpConsensusState, error) { return core.DumpConsensusState() } -func (Local) DialSeeds(seeds []string) (*ctypes.ResultDialSeeds, error) { - return core.UnsafeDialSeeds(seeds) +func (Local) DialManualPeers(manual_peers []string) (*ctypes.ResultDialManualPeers, error) { + return core.UnsafeDialManualPeers(manual_peers) } func (Local) BlockchainInfo(minHeight, maxHeight int64) (*ctypes.ResultBlockchainInfo, error) { diff --git a/rpc/client/mock/client.go b/rpc/client/mock/client.go index dc75e04cb..84f6aa2d7 100644 --- a/rpc/client/mock/client.go +++ b/rpc/client/mock/client.go @@ -107,8 +107,8 @@ func (c Client) NetInfo() (*ctypes.ResultNetInfo, error) { return core.NetInfo() } -func (c Client) DialSeeds(seeds []string) (*ctypes.ResultDialSeeds, error) { - return core.UnsafeDialSeeds(seeds) +func (c Client) DialManualPeers(manual_peers []string) (*ctypes.ResultDialManualPeers, error) { + return core.UnsafeDialManualPeers(manual_peers) } func (c Client) BlockchainInfo(minHeight, maxHeight int64) (*ctypes.ResultBlockchainInfo, error) { diff --git a/rpc/core/doc.go b/rpc/core/doc.go index a72cec020..1a59459dd 100644 --- a/rpc/core/doc.go +++ b/rpc/core/doc.go @@ -94,7 +94,7 @@ Endpoints that require arguments: /broadcast_tx_commit?tx=_ /broadcast_tx_sync?tx=_ /commit?height=_ -/dial_seeds?seeds=_ +/dial_manual_peers?manual_peers=_ /subscribe?event=_ /tx?hash=_&prove=_ /unsafe_start_cpu_profiler?filename=_ diff --git a/rpc/core/net.go b/rpc/core/net.go index b3f1c7ce5..845cda646 100644 --- a/rpc/core/net.go +++ b/rpc/core/net.go @@ -54,18 +54,18 @@ func NetInfo() (*ctypes.ResultNetInfo, error) { }, nil } -func UnsafeDialSeeds(seeds []string) (*ctypes.ResultDialSeeds, error) { +func UnsafeDialManualPeers(manual_peers []string) (*ctypes.ResultDialManualPeers, error) { - if len(seeds) == 0 { - return &ctypes.ResultDialSeeds{}, fmt.Errorf("No seeds provided") + if len(manual_peers) == 0 { + return &ctypes.ResultDialManualPeers{}, fmt.Errorf("No manual peers provided") } - // starts go routines to dial each seed after random delays - logger.Info("DialSeeds", "addrBook", addrBook, "seeds", seeds) - err := p2pSwitch.DialSeeds(addrBook, seeds) + // starts go routines to dial each peer after random delays + logger.Info("DialManualPeers", "addrBook", addrBook, "manual_peers", manual_peers) + err := p2pSwitch.DialPeersAsync(addrBook, manual_peers, true) if err != nil { - return &ctypes.ResultDialSeeds{}, err + return &ctypes.ResultDialManualPeers{}, err } - return &ctypes.ResultDialSeeds{"Dialing seeds in progress. See /net_info for details"}, nil + return &ctypes.ResultDialManualPeers{"Dialing manual peers in progress. See /net_info for details"}, nil } // Get genesis file. diff --git a/rpc/core/pipe.go b/rpc/core/pipe.go index 927d7ccad..6d67fd898 100644 --- a/rpc/core/pipe.go +++ b/rpc/core/pipe.go @@ -32,7 +32,7 @@ type P2P interface { NumPeers() (outbound, inbound, dialig int) NodeInfo() *p2p.NodeInfo IsListening() bool - DialSeeds(*p2p.AddrBook, []string) error + DialPeersAsync(*p2p.AddrBook, []string, bool) error } //---------------------------------------------- diff --git a/rpc/core/routes.go b/rpc/core/routes.go index fb5a1fd36..84d405ac6 100644 --- a/rpc/core/routes.go +++ b/rpc/core/routes.go @@ -38,7 +38,7 @@ var Routes = map[string]*rpc.RPCFunc{ func AddUnsafeRoutes() { // control API - Routes["dial_seeds"] = rpc.NewRPCFunc(UnsafeDialSeeds, "seeds") + Routes["dial_manual_peers"] = rpc.NewRPCFunc(UnsafeDialManualPeers, "manual_peers") Routes["unsafe_flush_mempool"] = rpc.NewRPCFunc(UnsafeFlushMempool, "") // profiler API diff --git a/rpc/core/types/responses.go b/rpc/core/types/responses.go index dae7c0046..4d8e79469 100644 --- a/rpc/core/types/responses.go +++ b/rpc/core/types/responses.go @@ -82,7 +82,7 @@ type ResultNetInfo struct { Peers []Peer `json:"peers"` } -type ResultDialSeeds struct { +type ResultDialManualPeers struct { Log string `json:"log"` } diff --git a/test/p2p/README.md b/test/p2p/README.md index e2a577cfa..692b730b2 100644 --- a/test/p2p/README.md +++ b/test/p2p/README.md @@ -38,7 +38,7 @@ for i in $(seq 1 4); do --name local_testnet_$i \ --entrypoint tendermint \ -e TMHOME=/go/src/github.com/tendermint/tendermint/test/p2p/data/mach$i/core \ - tendermint_tester node --p2p.seeds 172.57.0.101:46656,172.57.0.102:46656,172.57.0.103:46656,172.57.0.104:46656 --proxy_app=dummy + tendermint_tester node --p2p.manual_peers 172.57.0.101:46656,172.57.0.102:46656,172.57.0.103:46656,172.57.0.104:46656 --proxy_app=dummy done ``` diff --git a/test/p2p/fast_sync/test_peer.sh b/test/p2p/fast_sync/test_peer.sh index 8174be0e7..ab5d517d9 100644 --- a/test/p2p/fast_sync/test_peer.sh +++ b/test/p2p/fast_sync/test_peer.sh @@ -23,11 +23,11 @@ docker rm -vf local_testnet_$ID set -e # restart peer - should have an empty blockchain -SEEDS="$(test/p2p/ip.sh 1):46656" +MANUAL_PEERS="$(test/p2p/ip.sh 1):46656" for j in `seq 2 $N`; do - SEEDS="$SEEDS,$(test/p2p/ip.sh $j):46656" + MANUAL_PEERS="$MANUAL_PEERS,$(test/p2p/ip.sh $j):46656" done -bash test/p2p/peer.sh $DOCKER_IMAGE $NETWORK_NAME $ID $PROXY_APP "--p2p.seeds $SEEDS --p2p.pex --rpc.unsafe" +bash test/p2p/peer.sh $DOCKER_IMAGE $NETWORK_NAME $ID $PROXY_APP "--p2p.manual_peers $MANUAL_PEERS --p2p.pex --rpc.unsafe" # wait for peer to sync and check the app hash bash test/p2p/client.sh $DOCKER_IMAGE $NETWORK_NAME fs_$ID "test/p2p/fast_sync/check_peer.sh $ID" diff --git a/test/p2p/local_testnet_start.sh b/test/p2p/local_testnet_start.sh index f70bdf04c..c808c613d 100644 --- a/test/p2p/local_testnet_start.sh +++ b/test/p2p/local_testnet_start.sh @@ -7,10 +7,10 @@ N=$3 APP_PROXY=$4 set +u -SEEDS=$5 -if [[ "$SEEDS" != "" ]]; then - echo "Seeds: $SEEDS" - SEEDS="--p2p.seeds $SEEDS" +MANUAL_PEERS=$5 +if [[ "$MANUAL_PEERS" != "" ]]; then + echo "ManualPeers: $MANUAL_PEERS" + MANUAL_PEERS="--p2p.manual_peers $MANUAL_PEERS" fi set -u @@ -20,5 +20,5 @@ cd "$GOPATH/src/github.com/tendermint/tendermint" docker network create --driver bridge --subnet 172.57.0.0/16 "$NETWORK_NAME" for i in $(seq 1 "$N"); do - bash test/p2p/peer.sh "$DOCKER_IMAGE" "$NETWORK_NAME" "$i" "$APP_PROXY" "$SEEDS --p2p.pex --rpc.unsafe" + bash test/p2p/peer.sh "$DOCKER_IMAGE" "$NETWORK_NAME" "$i" "$APP_PROXY" "$MANUAL_PEERS --p2p.pex --rpc.unsafe" done diff --git a/test/p2p/manual_peers.sh b/test/p2p/manual_peers.sh new file mode 100644 index 000000000..90051b15b --- /dev/null +++ b/test/p2p/manual_peers.sh @@ -0,0 +1,12 @@ +#! /bin/bash +set -eu + +N=$1 + +cd "$GOPATH/src/github.com/tendermint/tendermint" + +manual_peers="$(test/p2p/ip.sh 1):46656" +for i in $(seq 2 $N); do + manual_peers="$manual_peers,$(test/p2p/ip.sh $i):46656" +done +echo "$manual_peers" diff --git a/test/p2p/pex/dial_seeds.sh b/test/p2p/pex/dial_manual_peers.sh similarity index 60% rename from test/p2p/pex/dial_seeds.sh rename to test/p2p/pex/dial_manual_peers.sh index 15c22af67..4ee79b869 100644 --- a/test/p2p/pex/dial_seeds.sh +++ b/test/p2p/pex/dial_manual_peers.sh @@ -19,13 +19,13 @@ for i in `seq 1 $N`; do done set -e -# seeds need quotes -seeds="\"$(test/p2p/ip.sh 1):46656\"" +# manual_peers need quotes +manual_peers="\"$(test/p2p/ip.sh 1):46656\"" for i in `seq 2 $N`; do - seeds="$seeds,\"$(test/p2p/ip.sh $i):46656\"" + manual_peers="$manual_peers,\"$(test/p2p/ip.sh $i):46656\"" done -echo $seeds +echo $manual_peers -echo $seeds +echo $manual_peers IP=$(test/p2p/ip.sh 1) -curl --data-urlencode "seeds=[$seeds]" "$IP:46657/dial_seeds" +curl --data-urlencode "manual_peers=[$manual_peers]" "$IP:46657/dial_manual_peers" diff --git a/test/p2p/pex/test.sh b/test/p2p/pex/test.sh index d54d81350..2c42781dd 100644 --- a/test/p2p/pex/test.sh +++ b/test/p2p/pex/test.sh @@ -11,5 +11,5 @@ cd $GOPATH/src/github.com/tendermint/tendermint echo "Test reconnecting from the address book" bash test/p2p/pex/test_addrbook.sh $DOCKER_IMAGE $NETWORK_NAME $N $PROXY_APP -echo "Test connecting via /dial_seeds" -bash test/p2p/pex/test_dial_seeds.sh $DOCKER_IMAGE $NETWORK_NAME $N $PROXY_APP +echo "Test connecting via /dial_manual_peers" +bash test/p2p/pex/test_dial_manual_peers.sh $DOCKER_IMAGE $NETWORK_NAME $N $PROXY_APP diff --git a/test/p2p/pex/test_addrbook.sh b/test/p2p/pex/test_addrbook.sh index 35dcb89d3..b215606d6 100644 --- a/test/p2p/pex/test_addrbook.sh +++ b/test/p2p/pex/test_addrbook.sh @@ -9,7 +9,7 @@ PROXY_APP=$4 ID=1 echo "----------------------------------------------------------------------" -echo "Testing pex creates the addrbook and uses it if seeds are not provided" +echo "Testing pex creates the addrbook and uses it if manual_peers are not provided" echo "(assuming peers are started with pex enabled)" CLIENT_NAME="pex_addrbook_$ID" @@ -22,7 +22,7 @@ set +e #CIRCLE docker rm -vf "local_testnet_$ID" set -e -# NOTE that we do not provide seeds +# NOTE that we do not provide manual_peers bash test/p2p/peer.sh "$DOCKER_IMAGE" "$NETWORK_NAME" "$ID" "$PROXY_APP" "--p2p.pex --rpc.unsafe" docker cp "/tmp/addrbook.json" "local_testnet_$ID:/go/src/github.com/tendermint/tendermint/test/p2p/data/mach1/core/addrbook.json" echo "with the following addrbook:" @@ -35,7 +35,7 @@ echo "" bash test/p2p/client.sh "$DOCKER_IMAGE" "$NETWORK_NAME" "$CLIENT_NAME" "test/p2p/pex/check_peer.sh $ID $N" echo "----------------------------------------------------------------------" -echo "Testing other peers connect to us if we have neither seeds nor the addrbook" +echo "Testing other peers connect to us if we have neither manual_peers nor the addrbook" echo "(assuming peers are started with pex enabled)" CLIENT_NAME="pex_no_addrbook_$ID" @@ -46,7 +46,7 @@ set +e #CIRCLE docker rm -vf "local_testnet_$ID" set -e -# NOTE that we do not provide seeds +# NOTE that we do not provide manual_peers bash test/p2p/peer.sh "$DOCKER_IMAGE" "$NETWORK_NAME" "$ID" "$PROXY_APP" "--p2p.pex --rpc.unsafe" # if the client runs forever, it means other peers have removed us from their books (which should not happen) diff --git a/test/p2p/pex/test_dial_seeds.sh b/test/p2p/pex/test_dial_manual_peers.sh similarity index 75% rename from test/p2p/pex/test_dial_seeds.sh rename to test/p2p/pex/test_dial_manual_peers.sh index ea72004db..ba3e1c4d0 100644 --- a/test/p2p/pex/test_dial_seeds.sh +++ b/test/p2p/pex/test_dial_manual_peers.sh @@ -11,7 +11,7 @@ ID=1 cd $GOPATH/src/github.com/tendermint/tendermint echo "----------------------------------------------------------------------" -echo "Testing full network connection using one /dial_seeds call" +echo "Testing full network connection using one /dial_manual_peers call" echo "(assuming peers are started with pex enabled)" # stop the existing testnet and remove local network @@ -21,16 +21,16 @@ set -e # start the testnet on a local network # NOTE we re-use the same network for all tests -SEEDS="" -bash test/p2p/local_testnet_start.sh $DOCKER_IMAGE $NETWORK_NAME $N $PROXY_APP $SEEDS +MANUAL_PEERS="" +bash test/p2p/local_testnet_start.sh $DOCKER_IMAGE $NETWORK_NAME $N $PROXY_APP $MANUAL_PEERS -# dial seeds from one node -CLIENT_NAME="dial_seeds" -bash test/p2p/client.sh $DOCKER_IMAGE $NETWORK_NAME $CLIENT_NAME "test/p2p/pex/dial_seeds.sh $N" +# dial manual_peers from one node +CLIENT_NAME="dial_manual_peers" +bash test/p2p/client.sh $DOCKER_IMAGE $NETWORK_NAME $CLIENT_NAME "test/p2p/pex/dial_manual_peers.sh $N" # test basic connectivity and consensus # start client container and check the num peers and height for all nodes -CLIENT_NAME="dial_seeds_basic" +CLIENT_NAME="dial_manual_peers_basic" bash test/p2p/client.sh $DOCKER_IMAGE $NETWORK_NAME $CLIENT_NAME "test/p2p/basic/test.sh $N" diff --git a/test/p2p/seeds.sh b/test/p2p/seeds.sh deleted file mode 100644 index 4bf866cba..000000000 --- a/test/p2p/seeds.sh +++ /dev/null @@ -1,12 +0,0 @@ -#! /bin/bash -set -eu - -N=$1 - -cd "$GOPATH/src/github.com/tendermint/tendermint" - -seeds="$(test/p2p/ip.sh 1):46656" -for i in $(seq 2 $N); do - seeds="$seeds,$(test/p2p/ip.sh $i):46656" -done -echo "$seeds" diff --git a/test/p2p/test.sh b/test/p2p/test.sh index 6a5537b98..f348efe4a 100644 --- a/test/p2p/test.sh +++ b/test/p2p/test.sh @@ -13,11 +13,11 @@ set +e bash test/p2p/local_testnet_stop.sh "$NETWORK_NAME" "$N" set -e -SEEDS=$(bash test/p2p/seeds.sh $N) +MANUAL_PEERS=$(bash test/p2p/manual_peers.sh $N) # start the testnet on a local network # NOTE we re-use the same network for all tests -bash test/p2p/local_testnet_start.sh "$DOCKER_IMAGE" "$NETWORK_NAME" "$N" "$PROXY_APP" "$SEEDS" +bash test/p2p/local_testnet_start.sh "$DOCKER_IMAGE" "$NETWORK_NAME" "$N" "$PROXY_APP" "$MANUAL_PEERS" # test basic connectivity and consensus # start client container and check the num peers and height for all nodes From 37f86f9518cc80b1d2f759ce09f381ea96730e54 Mon Sep 17 00:00:00 2001 From: Anton Kaliaev Date: Thu, 28 Dec 2017 18:27:36 -0600 Subject: [PATCH 03/10] update changelog [ci skip] --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index cda150717..1ceddd2ef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,13 @@ BUG FIXES: - Graceful handling/recovery for apps that have non-determinism or fail to halt - Graceful handling/recovery for violations of safety, or liveness +## 0.16.0 (TBD) + +BREAKING CHANGES: +- rpc: `/unsafe_dial_seeds` renamed to `/unsafe_dial_manual_peers` +- [p2p] old `seeds` is now `manual_peers` (persistent peers to which TM will always connect to) +- [p2p] now `seeds` only used for getting addresses (if addrbook is empty; not persistent) + ## 0.15.0 (December 29, 2017) BREAKING CHANGES: From e4897b7bdd033067d7d0fbbbd25c3f917d35d25a Mon Sep 17 00:00:00 2001 From: Anton Kaliaev Date: Tue, 9 Jan 2018 16:18:05 -0600 Subject: [PATCH 04/10] rename manual peers to persistent peers --- CHANGELOG.md | 4 ++-- benchmarks/blockchain/localsync.sh | 2 +- cmd/tendermint/commands/run_node.go | 2 +- config/config.go | 6 +++--- config/toml.go | 4 ++-- docs/deploy-testnets.rst | 4 ++-- docs/specification/configuration.rst | 2 +- docs/specification/rpc.rst | 2 +- docs/using-tendermint.rst | 10 +++++----- node/node.go | 6 +++--- p2p/pex_reactor.go | 2 +- p2p/switch.go | 2 +- rpc/client/localclient.go | 4 ++-- rpc/client/mock/client.go | 4 ++-- rpc/core/doc.go | 2 +- rpc/core/net.go | 14 +++++++------- rpc/core/routes.go | 2 +- rpc/core/types/responses.go | 2 +- test/p2p/README.md | 2 +- test/p2p/fast_sync/test_peer.sh | 6 +++--- test/p2p/local_testnet_start.sh | 10 +++++----- test/p2p/manual_peers.sh | 6 +++--- test/p2p/pex/dial_manual_peers.sh | 16 ++++++++-------- test/p2p/pex/test.sh | 4 ++-- test/p2p/pex/test_addrbook.sh | 8 ++++---- test/p2p/pex/test_dial_manual_peers.sh | 14 +++++++------- test/p2p/test.sh | 4 ++-- 27 files changed, 72 insertions(+), 72 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1ceddd2ef..b935a3816 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,8 +28,8 @@ BUG FIXES: ## 0.16.0 (TBD) BREAKING CHANGES: -- rpc: `/unsafe_dial_seeds` renamed to `/unsafe_dial_manual_peers` -- [p2p] old `seeds` is now `manual_peers` (persistent peers to which TM will always connect to) +- rpc: `/unsafe_dial_seeds` renamed to `/unsafe_dial_persistent_peers` +- [p2p] old `seeds` is now `persistent_peers` (persistent peers to which TM will always connect to) - [p2p] now `seeds` only used for getting addresses (if addrbook is empty; not persistent) ## 0.15.0 (December 29, 2017) diff --git a/benchmarks/blockchain/localsync.sh b/benchmarks/blockchain/localsync.sh index 18afaee82..389464b6c 100755 --- a/benchmarks/blockchain/localsync.sh +++ b/benchmarks/blockchain/localsync.sh @@ -51,7 +51,7 @@ tendermint node \ --proxy_app dummy \ --p2p.laddr tcp://127.0.0.1:56666 \ --rpc.laddr tcp://127.0.0.1:56667 \ - --p2p.manual_peers 127.0.0.1:56656 \ + --p2p.persistent_peers 127.0.0.1:56656 \ --log_level error & # wait for node to start up so we only count time where we are actually syncing diff --git a/cmd/tendermint/commands/run_node.go b/cmd/tendermint/commands/run_node.go index 5b87a4b82..0eb7a4259 100644 --- a/cmd/tendermint/commands/run_node.go +++ b/cmd/tendermint/commands/run_node.go @@ -29,7 +29,7 @@ func AddNodeFlags(cmd *cobra.Command) { // p2p flags cmd.Flags().String("p2p.laddr", config.P2P.ListenAddress, "Node listen address. (0.0.0.0:0 means any interface, any port)") cmd.Flags().String("p2p.seeds", config.P2P.Seeds, "Comma delimited host:port seed nodes") - cmd.Flags().String("p2p.manual_peers", config.P2P.ManualPeers, "Comma delimited host:port manual peers") + cmd.Flags().String("p2p.persistent_peers", config.P2P.PersistentPeers, "Comma delimited host:port persistent peers") cmd.Flags().Bool("p2p.skip_upnp", config.P2P.SkipUPNP, "Skip UPNP configuration") cmd.Flags().Bool("p2p.pex", config.P2P.PexReactor, "Enable/disable Peer-Exchange") diff --git a/config/config.go b/config/config.go index 2d38ed916..04a37c68c 100644 --- a/config/config.go +++ b/config/config.go @@ -170,7 +170,7 @@ type RPCConfig struct { // NOTE: This server only supports /broadcast_tx_commit GRPCListenAddress string `mapstructure:"grpc_laddr"` - // Activate unsafe RPC commands like /dial_manual_peers and /unsafe_flush_mempool + // Activate unsafe RPC commands like /dial_persistent_peers and /unsafe_flush_mempool Unsafe bool `mapstructure:"unsafe"` } @@ -206,9 +206,9 @@ type P2PConfig struct { // We only use these if we can’t connect to peers in the addrbook Seeds string `mapstructure:"seeds"` - // Comma separated list of manual peers to connect to + // Comma separated list of persistent peers to connect to // We always connect to these - ManualPeers string `mapstructure:"manual_peers"` + PersistentPeers string `mapstructure:"persistent_peers"` // Skip UPNP port forwarding SkipUPNP bool `mapstructure:"skip_upnp"` diff --git a/config/toml.go b/config/toml.go index 59fc46dcf..e644445f0 100644 --- a/config/toml.go +++ b/config/toml.go @@ -42,7 +42,7 @@ laddr = "tcp://0.0.0.0:46657" [p2p] laddr = "tcp://0.0.0.0:46656" seeds = "" -manual_peers = "" +persistent_peers = "" ` func defaultConfig(moniker string) string { @@ -107,7 +107,7 @@ laddr = "tcp://0.0.0.0:36657" [p2p] laddr = "tcp://0.0.0.0:36656" seeds = "" -manual_peers = "" +persistent_peers = "" ` func testConfig(moniker string) (testConfig string) { diff --git a/docs/deploy-testnets.rst b/docs/deploy-testnets.rst index 8c66c4b34..33c214570 100644 --- a/docs/deploy-testnets.rst +++ b/docs/deploy-testnets.rst @@ -24,13 +24,13 @@ Here are the steps to setting up a testnet manually: ``tendermint gen_validator`` 4) Compile a list of public keys for each validator into a ``genesis.json`` file. -5) Run ``tendermint node --p2p.manual_peers=< peer addresses >`` on each node, +5) Run ``tendermint node --p2p.persistent_peers=< peer addresses >`` on each node, where ``< peer addresses >`` is a comma separated list of the IP:PORT combination for each node. The default port for Tendermint is ``46656``. Thus, if the IP addresses of your nodes were ``192.168.0.1, 192.168.0.2, 192.168.0.3, 192.168.0.4``, the command would look like: - ``tendermint node --p2p.manual_peers=192.168.0.1:46656,192.168.0.2:46656,192.168.0.3:46656,192.168.0.4:46656``. + ``tendermint node --p2p.persistent_peers=192.168.0.1:46656,192.168.0.2:46656,192.168.0.3:46656,192.168.0.4:46656``. After a few seconds, all the nodes should connect to eachother and start making blocks! For more information, see the Tendermint Networks section diff --git a/docs/specification/configuration.rst b/docs/specification/configuration.rst index 3271cd59d..46e4059e3 100644 --- a/docs/specification/configuration.rst +++ b/docs/specification/configuration.rst @@ -49,7 +49,7 @@ The main config parameters are defined - ``p2p.pex``: Enable Peer-Exchange (dev feature). *Default*: ``false`` - ``p2p.seeds``: Comma delimited host:port seed nodes. *Default*: ``""`` -- ``p2p.manual_peers``: Comma delimited host:port manual peers. *Default*: +- ``p2p.persistent_peers``: Comma delimited host:port persistent peers. *Default*: ``""`` - ``p2p.skip_upnp``: Skip UPNP detection. *Default*: ``false`` diff --git a/docs/specification/rpc.rst b/docs/specification/rpc.rst index f637c1717..daafce111 100644 --- a/docs/specification/rpc.rst +++ b/docs/specification/rpc.rst @@ -111,7 +111,7 @@ An HTTP Get request to the root RPC endpoint (e.g. http://localhost:46657/broadcast_tx_commit?tx=_ http://localhost:46657/broadcast_tx_sync?tx=_ http://localhost:46657/commit?height=_ - http://localhost:46657/dial_manual_peers?manual_peers=_ + http://localhost:46657/dial_persistent_peers?persistent_peers=_ http://localhost:46657/subscribe?event=_ http://localhost:46657/tx?hash=_&prove=_ http://localhost:46657/unsafe_start_cpu_profiler?filename=_ diff --git a/docs/using-tendermint.rst b/docs/using-tendermint.rst index 2ec5624ec..2a04ac543 100644 --- a/docs/using-tendermint.rst +++ b/docs/using-tendermint.rst @@ -270,14 +270,14 @@ For instance, :: - tendermint node --p2p.manual_peers "1.2.3.4:46656,5.6.7.8:46656" + tendermint node --p2p.persistent_peers "1.2.3.4:46656,5.6.7.8:46656" -Alternatively, you can use the ``/dial_manual_peers`` endpoint of the RPC to +Alternatively, you can use the ``/dial_persistent_peers`` endpoint of the RPC to specify peers for a running node to connect to: :: - curl --data-urlencode "manual_peers=[\"1.2.3.4:46656\",\"5.6.7.8:46656\"]" localhost:46657/dial_manual_peers + curl --data-urlencode "persistent_peers=[\"1.2.3.4:46656\",\"5.6.7.8:46656\"]" localhost:46657/dial_persistent_peers Additionally, the peer-exchange protocol can be enabled using the ``--pex`` flag, though this feature is `still under @@ -290,7 +290,7 @@ Adding a Non-Validator Adding a non-validator is simple. Just copy the original ``genesis.json`` to ``~/.tendermint`` on the new machine and start the -node, specifying manual_peers as necessary. If no manual_peers are specified, the node +node, specifying persistent_peers as necessary. If no persistent_peers are specified, the node won't make any blocks, because it's not a validator, and it won't hear about any blocks, because it's not connected to the other peer. @@ -363,7 +363,7 @@ and the new ``priv_validator.json`` to the ``~/.tendermint`` on a new machine. Now run ``tendermint node`` on both machines, and use either -``--p2p.manual_peers`` or the ``/dial_manual_peers`` to get them to peer up. They +``--p2p.persistent_peers`` or the ``/dial_persistent_peers`` to get them to peer up. They should start making blocks, and will only continue to do so as long as both of them are online. diff --git a/node/node.go b/node/node.go index 1970bb88e..a4ea193b8 100644 --- a/node/node.go +++ b/node/node.go @@ -380,9 +380,9 @@ func (n *Node) OnStart() error { return err } - // Always connect to manual peers - if n.config.P2P.ManualPeers != "" { - err = n.sw.DialPeersAsync(n.addrBook, strings.Split(n.config.P2P.ManualPeers, ","), true) + // Always connect to persistent peers + if n.config.P2P.PersistentPeers != "" { + err = n.sw.DialPeersAsync(n.addrBook, strings.Split(n.config.P2P.PersistentPeers, ","), true) if err != nil { return err } diff --git a/p2p/pex_reactor.go b/p2p/pex_reactor.go index d4a8cbf18..64e7dafb9 100644 --- a/p2p/pex_reactor.go +++ b/p2p/pex_reactor.go @@ -100,7 +100,7 @@ func (r *PEXReactor) GetChannels() []*ChannelDescriptor { func (r *PEXReactor) AddPeer(p Peer) { if p.IsOutbound() { // For outbound peers, the address is already in the books. - // Either it was added in DialManualPeers or when we + // Either it was added in DialPersistentPeers or when we // received the peer's address in r.Receive if r.book.NeedMoreAddrs() { r.RequestPEX(p) diff --git a/p2p/switch.go b/p2p/switch.go index 4deee63d4..1b449d7e0 100644 --- a/p2p/switch.go +++ b/p2p/switch.go @@ -323,7 +323,7 @@ func (sw *Switch) DialPeersAsync(addrBook *AddrBook, peers []string, persistent } if addrBook != nil { - // add manual peers to `addrBook` + // add persistent peers to `addrBook` ourAddrS := sw.nodeInfo.ListenAddr ourAddr, _ := NewNetAddressString(ourAddrS) for _, netAddr := range netAddrs { diff --git a/rpc/client/localclient.go b/rpc/client/localclient.go index d30f7543c..af91ac791 100644 --- a/rpc/client/localclient.go +++ b/rpc/client/localclient.go @@ -84,8 +84,8 @@ func (Local) DumpConsensusState() (*ctypes.ResultDumpConsensusState, error) { return core.DumpConsensusState() } -func (Local) DialManualPeers(manual_peers []string) (*ctypes.ResultDialManualPeers, error) { - return core.UnsafeDialManualPeers(manual_peers) +func (Local) DialPersistentPeers(persistent_peers []string) (*ctypes.ResultDialPersistentPeers, error) { + return core.UnsafeDialPersistentPeers(persistent_peers) } func (Local) BlockchainInfo(minHeight, maxHeight int64) (*ctypes.ResultBlockchainInfo, error) { diff --git a/rpc/client/mock/client.go b/rpc/client/mock/client.go index 84f6aa2d7..469e80a67 100644 --- a/rpc/client/mock/client.go +++ b/rpc/client/mock/client.go @@ -107,8 +107,8 @@ func (c Client) NetInfo() (*ctypes.ResultNetInfo, error) { return core.NetInfo() } -func (c Client) DialManualPeers(manual_peers []string) (*ctypes.ResultDialManualPeers, error) { - return core.UnsafeDialManualPeers(manual_peers) +func (c Client) DialPersistentPeers(persistent_peers []string) (*ctypes.ResultDialPersistentPeers, error) { + return core.UnsafeDialPersistentPeers(persistent_peers) } func (c Client) BlockchainInfo(minHeight, maxHeight int64) (*ctypes.ResultBlockchainInfo, error) { diff --git a/rpc/core/doc.go b/rpc/core/doc.go index 1a59459dd..030e5d617 100644 --- a/rpc/core/doc.go +++ b/rpc/core/doc.go @@ -94,7 +94,7 @@ Endpoints that require arguments: /broadcast_tx_commit?tx=_ /broadcast_tx_sync?tx=_ /commit?height=_ -/dial_manual_peers?manual_peers=_ +/dial_persistent_peers?persistent_peers=_ /subscribe?event=_ /tx?hash=_&prove=_ /unsafe_start_cpu_profiler?filename=_ diff --git a/rpc/core/net.go b/rpc/core/net.go index 845cda646..c79c55deb 100644 --- a/rpc/core/net.go +++ b/rpc/core/net.go @@ -54,18 +54,18 @@ func NetInfo() (*ctypes.ResultNetInfo, error) { }, nil } -func UnsafeDialManualPeers(manual_peers []string) (*ctypes.ResultDialManualPeers, error) { +func UnsafeDialPersistentPeers(persistent_peers []string) (*ctypes.ResultDialPersistentPeers, error) { - if len(manual_peers) == 0 { - return &ctypes.ResultDialManualPeers{}, fmt.Errorf("No manual peers provided") + if len(persistent_peers) == 0 { + return &ctypes.ResultDialPersistentPeers{}, fmt.Errorf("No persistent peers provided") } // starts go routines to dial each peer after random delays - logger.Info("DialManualPeers", "addrBook", addrBook, "manual_peers", manual_peers) - err := p2pSwitch.DialPeersAsync(addrBook, manual_peers, true) + logger.Info("DialPersistentPeers", "addrBook", addrBook, "persistent_peers", persistent_peers) + err := p2pSwitch.DialPeersAsync(addrBook, persistent_peers, true) if err != nil { - return &ctypes.ResultDialManualPeers{}, err + return &ctypes.ResultDialPersistentPeers{}, err } - return &ctypes.ResultDialManualPeers{"Dialing manual peers in progress. See /net_info for details"}, nil + return &ctypes.ResultDialPersistentPeers{"Dialing persistent peers in progress. See /net_info for details"}, nil } // Get genesis file. diff --git a/rpc/core/routes.go b/rpc/core/routes.go index 84d405ac6..0bf7af623 100644 --- a/rpc/core/routes.go +++ b/rpc/core/routes.go @@ -38,7 +38,7 @@ var Routes = map[string]*rpc.RPCFunc{ func AddUnsafeRoutes() { // control API - Routes["dial_manual_peers"] = rpc.NewRPCFunc(UnsafeDialManualPeers, "manual_peers") + Routes["dial_persistent_peers"] = rpc.NewRPCFunc(UnsafeDialPersistentPeers, "persistent_peers") Routes["unsafe_flush_mempool"] = rpc.NewRPCFunc(UnsafeFlushMempool, "") // profiler API diff --git a/rpc/core/types/responses.go b/rpc/core/types/responses.go index 4d8e79469..59c2aeea9 100644 --- a/rpc/core/types/responses.go +++ b/rpc/core/types/responses.go @@ -82,7 +82,7 @@ type ResultNetInfo struct { Peers []Peer `json:"peers"` } -type ResultDialManualPeers struct { +type ResultDialPersistentPeers struct { Log string `json:"log"` } diff --git a/test/p2p/README.md b/test/p2p/README.md index 692b730b2..b68f7a819 100644 --- a/test/p2p/README.md +++ b/test/p2p/README.md @@ -38,7 +38,7 @@ for i in $(seq 1 4); do --name local_testnet_$i \ --entrypoint tendermint \ -e TMHOME=/go/src/github.com/tendermint/tendermint/test/p2p/data/mach$i/core \ - tendermint_tester node --p2p.manual_peers 172.57.0.101:46656,172.57.0.102:46656,172.57.0.103:46656,172.57.0.104:46656 --proxy_app=dummy + tendermint_tester node --p2p.persistent_peers 172.57.0.101:46656,172.57.0.102:46656,172.57.0.103:46656,172.57.0.104:46656 --proxy_app=dummy done ``` diff --git a/test/p2p/fast_sync/test_peer.sh b/test/p2p/fast_sync/test_peer.sh index ab5d517d9..1f341bf5d 100644 --- a/test/p2p/fast_sync/test_peer.sh +++ b/test/p2p/fast_sync/test_peer.sh @@ -23,11 +23,11 @@ docker rm -vf local_testnet_$ID set -e # restart peer - should have an empty blockchain -MANUAL_PEERS="$(test/p2p/ip.sh 1):46656" +PERSISTENT_PEERS="$(test/p2p/ip.sh 1):46656" for j in `seq 2 $N`; do - MANUAL_PEERS="$MANUAL_PEERS,$(test/p2p/ip.sh $j):46656" + PERSISTENT_PEERS="$PERSISTENT_PEERS,$(test/p2p/ip.sh $j):46656" done -bash test/p2p/peer.sh $DOCKER_IMAGE $NETWORK_NAME $ID $PROXY_APP "--p2p.manual_peers $MANUAL_PEERS --p2p.pex --rpc.unsafe" +bash test/p2p/peer.sh $DOCKER_IMAGE $NETWORK_NAME $ID $PROXY_APP "--p2p.persistent_peers $PERSISTENT_PEERS --p2p.pex --rpc.unsafe" # wait for peer to sync and check the app hash bash test/p2p/client.sh $DOCKER_IMAGE $NETWORK_NAME fs_$ID "test/p2p/fast_sync/check_peer.sh $ID" diff --git a/test/p2p/local_testnet_start.sh b/test/p2p/local_testnet_start.sh index c808c613d..25b3c6d3e 100644 --- a/test/p2p/local_testnet_start.sh +++ b/test/p2p/local_testnet_start.sh @@ -7,10 +7,10 @@ N=$3 APP_PROXY=$4 set +u -MANUAL_PEERS=$5 -if [[ "$MANUAL_PEERS" != "" ]]; then - echo "ManualPeers: $MANUAL_PEERS" - MANUAL_PEERS="--p2p.manual_peers $MANUAL_PEERS" +PERSISTENT_PEERS=$5 +if [[ "$PERSISTENT_PEERS" != "" ]]; then + echo "PersistentPeers: $PERSISTENT_PEERS" + PERSISTENT_PEERS="--p2p.persistent_peers $PERSISTENT_PEERS" fi set -u @@ -20,5 +20,5 @@ cd "$GOPATH/src/github.com/tendermint/tendermint" docker network create --driver bridge --subnet 172.57.0.0/16 "$NETWORK_NAME" for i in $(seq 1 "$N"); do - bash test/p2p/peer.sh "$DOCKER_IMAGE" "$NETWORK_NAME" "$i" "$APP_PROXY" "$MANUAL_PEERS --p2p.pex --rpc.unsafe" + bash test/p2p/peer.sh "$DOCKER_IMAGE" "$NETWORK_NAME" "$i" "$APP_PROXY" "$PERSISTENT_PEERS --p2p.pex --rpc.unsafe" done diff --git a/test/p2p/manual_peers.sh b/test/p2p/manual_peers.sh index 90051b15b..4ad55bc03 100644 --- a/test/p2p/manual_peers.sh +++ b/test/p2p/manual_peers.sh @@ -5,8 +5,8 @@ N=$1 cd "$GOPATH/src/github.com/tendermint/tendermint" -manual_peers="$(test/p2p/ip.sh 1):46656" +persistent_peers="$(test/p2p/ip.sh 1):46656" for i in $(seq 2 $N); do - manual_peers="$manual_peers,$(test/p2p/ip.sh $i):46656" + persistent_peers="$persistent_peers,$(test/p2p/ip.sh $i):46656" done -echo "$manual_peers" +echo "$persistent_peers" diff --git a/test/p2p/pex/dial_manual_peers.sh b/test/p2p/pex/dial_manual_peers.sh index 4ee79b869..95c1d6e9c 100644 --- a/test/p2p/pex/dial_manual_peers.sh +++ b/test/p2p/pex/dial_manual_peers.sh @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/bash set -u N=$1 @@ -11,7 +11,7 @@ for i in `seq 1 $N`; do curl -s $addr/status > /dev/null ERR=$? while [ "$ERR" != 0 ]; do - sleep 1 + sleep 1 curl -s $addr/status > /dev/null ERR=$? done @@ -19,13 +19,13 @@ for i in `seq 1 $N`; do done set -e -# manual_peers need quotes -manual_peers="\"$(test/p2p/ip.sh 1):46656\"" +# persistent_peers need quotes +persistent_peers="\"$(test/p2p/ip.sh 1):46656\"" for i in `seq 2 $N`; do - manual_peers="$manual_peers,\"$(test/p2p/ip.sh $i):46656\"" + persistent_peers="$persistent_peers,\"$(test/p2p/ip.sh $i):46656\"" done -echo $manual_peers +echo $persistent_peers -echo $manual_peers +echo $persistent_peers IP=$(test/p2p/ip.sh 1) -curl --data-urlencode "manual_peers=[$manual_peers]" "$IP:46657/dial_manual_peers" +curl --data-urlencode "persistent_peers=[$persistent_peers]" "$IP:46657/dial_persistent_peers" diff --git a/test/p2p/pex/test.sh b/test/p2p/pex/test.sh index 2c42781dd..7cf6151d5 100644 --- a/test/p2p/pex/test.sh +++ b/test/p2p/pex/test.sh @@ -11,5 +11,5 @@ cd $GOPATH/src/github.com/tendermint/tendermint echo "Test reconnecting from the address book" bash test/p2p/pex/test_addrbook.sh $DOCKER_IMAGE $NETWORK_NAME $N $PROXY_APP -echo "Test connecting via /dial_manual_peers" -bash test/p2p/pex/test_dial_manual_peers.sh $DOCKER_IMAGE $NETWORK_NAME $N $PROXY_APP +echo "Test connecting via /dial_persistent_peers" +bash test/p2p/pex/test_dial_persistent_peers.sh $DOCKER_IMAGE $NETWORK_NAME $N $PROXY_APP diff --git a/test/p2p/pex/test_addrbook.sh b/test/p2p/pex/test_addrbook.sh index b215606d6..1dd26b172 100644 --- a/test/p2p/pex/test_addrbook.sh +++ b/test/p2p/pex/test_addrbook.sh @@ -9,7 +9,7 @@ PROXY_APP=$4 ID=1 echo "----------------------------------------------------------------------" -echo "Testing pex creates the addrbook and uses it if manual_peers are not provided" +echo "Testing pex creates the addrbook and uses it if persistent_peers are not provided" echo "(assuming peers are started with pex enabled)" CLIENT_NAME="pex_addrbook_$ID" @@ -22,7 +22,7 @@ set +e #CIRCLE docker rm -vf "local_testnet_$ID" set -e -# NOTE that we do not provide manual_peers +# NOTE that we do not provide persistent_peers bash test/p2p/peer.sh "$DOCKER_IMAGE" "$NETWORK_NAME" "$ID" "$PROXY_APP" "--p2p.pex --rpc.unsafe" docker cp "/tmp/addrbook.json" "local_testnet_$ID:/go/src/github.com/tendermint/tendermint/test/p2p/data/mach1/core/addrbook.json" echo "with the following addrbook:" @@ -35,7 +35,7 @@ echo "" bash test/p2p/client.sh "$DOCKER_IMAGE" "$NETWORK_NAME" "$CLIENT_NAME" "test/p2p/pex/check_peer.sh $ID $N" echo "----------------------------------------------------------------------" -echo "Testing other peers connect to us if we have neither manual_peers nor the addrbook" +echo "Testing other peers connect to us if we have neither persistent_peers nor the addrbook" echo "(assuming peers are started with pex enabled)" CLIENT_NAME="pex_no_addrbook_$ID" @@ -46,7 +46,7 @@ set +e #CIRCLE docker rm -vf "local_testnet_$ID" set -e -# NOTE that we do not provide manual_peers +# NOTE that we do not provide persistent_peers bash test/p2p/peer.sh "$DOCKER_IMAGE" "$NETWORK_NAME" "$ID" "$PROXY_APP" "--p2p.pex --rpc.unsafe" # if the client runs forever, it means other peers have removed us from their books (which should not happen) diff --git a/test/p2p/pex/test_dial_manual_peers.sh b/test/p2p/pex/test_dial_manual_peers.sh index ba3e1c4d0..7dda62b13 100644 --- a/test/p2p/pex/test_dial_manual_peers.sh +++ b/test/p2p/pex/test_dial_manual_peers.sh @@ -11,7 +11,7 @@ ID=1 cd $GOPATH/src/github.com/tendermint/tendermint echo "----------------------------------------------------------------------" -echo "Testing full network connection using one /dial_manual_peers call" +echo "Testing full network connection using one /dial_persistent_peers call" echo "(assuming peers are started with pex enabled)" # stop the existing testnet and remove local network @@ -21,16 +21,16 @@ set -e # start the testnet on a local network # NOTE we re-use the same network for all tests -MANUAL_PEERS="" -bash test/p2p/local_testnet_start.sh $DOCKER_IMAGE $NETWORK_NAME $N $PROXY_APP $MANUAL_PEERS +PERSISTENT_PEERS="" +bash test/p2p/local_testnet_start.sh $DOCKER_IMAGE $NETWORK_NAME $N $PROXY_APP $PERSISTENT_PEERS -# dial manual_peers from one node -CLIENT_NAME="dial_manual_peers" -bash test/p2p/client.sh $DOCKER_IMAGE $NETWORK_NAME $CLIENT_NAME "test/p2p/pex/dial_manual_peers.sh $N" +# dial persistent_peers from one node +CLIENT_NAME="dial_persistent_peers" +bash test/p2p/client.sh $DOCKER_IMAGE $NETWORK_NAME $CLIENT_NAME "test/p2p/pex/dial_persistent_peers.sh $N" # test basic connectivity and consensus # start client container and check the num peers and height for all nodes -CLIENT_NAME="dial_manual_peers_basic" +CLIENT_NAME="dial_persistent_peers_basic" bash test/p2p/client.sh $DOCKER_IMAGE $NETWORK_NAME $CLIENT_NAME "test/p2p/basic/test.sh $N" diff --git a/test/p2p/test.sh b/test/p2p/test.sh index f348efe4a..c95f69733 100644 --- a/test/p2p/test.sh +++ b/test/p2p/test.sh @@ -13,11 +13,11 @@ set +e bash test/p2p/local_testnet_stop.sh "$NETWORK_NAME" "$N" set -e -MANUAL_PEERS=$(bash test/p2p/manual_peers.sh $N) +PERSISTENT_PEERS=$(bash test/p2p/persistent_peers.sh $N) # start the testnet on a local network # NOTE we re-use the same network for all tests -bash test/p2p/local_testnet_start.sh "$DOCKER_IMAGE" "$NETWORK_NAME" "$N" "$PROXY_APP" "$MANUAL_PEERS" +bash test/p2p/local_testnet_start.sh "$DOCKER_IMAGE" "$NETWORK_NAME" "$N" "$PROXY_APP" "$PERSISTENT_PEERS" # test basic connectivity and consensus # start client container and check the num peers and height for all nodes From 1b455883d2a5acfd0705c2dddf5c31eff2b7a01b Mon Sep 17 00:00:00 2001 From: Anton Kaliaev Date: Tue, 9 Jan 2018 16:36:15 -0600 Subject: [PATCH 05/10] readd /dial_seeds --- CHANGELOG.md | 4 +++- docs/specification/rpc.rst | 1 + rpc/client/localclient.go | 4 ++++ rpc/client/mock/client.go | 4 ++++ rpc/core/doc.go | 1 + rpc/core/net.go | 19 +++++++++++++++---- rpc/core/routes.go | 1 + rpc/core/types/responses.go | 4 ++++ ...nual_peers.sh => dial_persistent_peers.sh} | 0 test/p2p/pex/test.sh | 6 +++--- ...peers.sh => test_dial_persistent_peers.sh} | 0 11 files changed, 36 insertions(+), 8 deletions(-) rename test/p2p/pex/{dial_manual_peers.sh => dial_persistent_peers.sh} (100%) rename test/p2p/pex/{test_dial_manual_peers.sh => test_dial_persistent_peers.sh} (100%) diff --git a/CHANGELOG.md b/CHANGELOG.md index b935a3816..fdf3aea50 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,10 +28,12 @@ BUG FIXES: ## 0.16.0 (TBD) BREAKING CHANGES: -- rpc: `/unsafe_dial_seeds` renamed to `/unsafe_dial_persistent_peers` - [p2p] old `seeds` is now `persistent_peers` (persistent peers to which TM will always connect to) - [p2p] now `seeds` only used for getting addresses (if addrbook is empty; not persistent) +FEATURES: +- [p2p] added new `/dial_persistent_peers` **unsafe** endpoint + ## 0.15.0 (December 29, 2017) BREAKING CHANGES: diff --git a/docs/specification/rpc.rst b/docs/specification/rpc.rst index daafce111..e273ce84a 100644 --- a/docs/specification/rpc.rst +++ b/docs/specification/rpc.rst @@ -111,6 +111,7 @@ An HTTP Get request to the root RPC endpoint (e.g. http://localhost:46657/broadcast_tx_commit?tx=_ http://localhost:46657/broadcast_tx_sync?tx=_ http://localhost:46657/commit?height=_ + http://localhost:46657/dial_seeds?seeds=_ http://localhost:46657/dial_persistent_peers?persistent_peers=_ http://localhost:46657/subscribe?event=_ http://localhost:46657/tx?hash=_&prove=_ diff --git a/rpc/client/localclient.go b/rpc/client/localclient.go index af91ac791..cc23b9449 100644 --- a/rpc/client/localclient.go +++ b/rpc/client/localclient.go @@ -84,6 +84,10 @@ func (Local) DumpConsensusState() (*ctypes.ResultDumpConsensusState, error) { return core.DumpConsensusState() } +func (Local) DialSeeds(seeds []string) (*ctypes.ResultDialSeeds, error) { + return core.UnsafeDialSeeds(seeds) +} + func (Local) DialPersistentPeers(persistent_peers []string) (*ctypes.ResultDialPersistentPeers, error) { return core.UnsafeDialPersistentPeers(persistent_peers) } diff --git a/rpc/client/mock/client.go b/rpc/client/mock/client.go index 469e80a67..913812d6d 100644 --- a/rpc/client/mock/client.go +++ b/rpc/client/mock/client.go @@ -107,6 +107,10 @@ func (c Client) NetInfo() (*ctypes.ResultNetInfo, error) { return core.NetInfo() } +func (c Client) DialSeeds(seeds []string) (*ctypes.ResultDialSeeds, error) { + return core.UnsafeDialSeeds(seeds) +} + func (c Client) DialPersistentPeers(persistent_peers []string) (*ctypes.ResultDialPersistentPeers, error) { return core.UnsafeDialPersistentPeers(persistent_peers) } diff --git a/rpc/core/doc.go b/rpc/core/doc.go index 030e5d617..a801cd0d2 100644 --- a/rpc/core/doc.go +++ b/rpc/core/doc.go @@ -94,6 +94,7 @@ Endpoints that require arguments: /broadcast_tx_commit?tx=_ /broadcast_tx_sync?tx=_ /commit?height=_ +/dial_seeds?seeds=_ /dial_persistent_peers?persistent_peers=_ /subscribe?event=_ /tx?hash=_&prove=_ diff --git a/rpc/core/net.go b/rpc/core/net.go index c79c55deb..b528e1e35 100644 --- a/rpc/core/net.go +++ b/rpc/core/net.go @@ -1,8 +1,7 @@ package core import ( - "fmt" - + "github.com/pkg/errors" ctypes "github.com/tendermint/tendermint/rpc/core/types" ) @@ -54,10 +53,22 @@ func NetInfo() (*ctypes.ResultNetInfo, error) { }, nil } -func UnsafeDialPersistentPeers(persistent_peers []string) (*ctypes.ResultDialPersistentPeers, error) { +func UnsafeDialSeeds(seeds []string) (*ctypes.ResultDialSeeds, error) { + if len(seeds) == 0 { + return &ctypes.ResultDialSeeds{}, errors.New("No seeds provided") + } + // starts go routines to dial each peer after random delays + logger.Info("DialSeeds", "addrBook", addrBook, "seeds", seeds) + err := p2pSwitch.DialPeersAsync(addrBook, seeds, false) + if err != nil { + return &ctypes.ResultDialSeeds{}, err + } + return &ctypes.ResultDialSeeds{"Dialing seeds in progress. See /net_info for details"}, nil +} +func UnsafeDialPersistentPeers(persistent_peers []string) (*ctypes.ResultDialPersistentPeers, error) { if len(persistent_peers) == 0 { - return &ctypes.ResultDialPersistentPeers{}, fmt.Errorf("No persistent peers provided") + return &ctypes.ResultDialPersistentPeers{}, errors.New("No persistent peers provided") } // starts go routines to dial each peer after random delays logger.Info("DialPersistentPeers", "addrBook", addrBook, "persistent_peers", persistent_peers) diff --git a/rpc/core/routes.go b/rpc/core/routes.go index 0bf7af623..d00165e6a 100644 --- a/rpc/core/routes.go +++ b/rpc/core/routes.go @@ -38,6 +38,7 @@ var Routes = map[string]*rpc.RPCFunc{ func AddUnsafeRoutes() { // control API + Routes["dial_seeds"] = rpc.NewRPCFunc(UnsafeDialSeeds, "seeds") Routes["dial_persistent_peers"] = rpc.NewRPCFunc(UnsafeDialPersistentPeers, "persistent_peers") Routes["unsafe_flush_mempool"] = rpc.NewRPCFunc(UnsafeFlushMempool, "") diff --git a/rpc/core/types/responses.go b/rpc/core/types/responses.go index 59c2aeea9..c26defb76 100644 --- a/rpc/core/types/responses.go +++ b/rpc/core/types/responses.go @@ -82,6 +82,10 @@ type ResultNetInfo struct { Peers []Peer `json:"peers"` } +type ResultDialSeeds struct { + Log string `json:"log"` +} + type ResultDialPersistentPeers struct { Log string `json:"log"` } diff --git a/test/p2p/pex/dial_manual_peers.sh b/test/p2p/pex/dial_persistent_peers.sh similarity index 100% rename from test/p2p/pex/dial_manual_peers.sh rename to test/p2p/pex/dial_persistent_peers.sh diff --git a/test/p2p/pex/test.sh b/test/p2p/pex/test.sh index 7cf6151d5..06d40c3ed 100644 --- a/test/p2p/pex/test.sh +++ b/test/p2p/pex/test.sh @@ -6,10 +6,10 @@ NETWORK_NAME=$2 N=$3 PROXY_APP=$4 -cd $GOPATH/src/github.com/tendermint/tendermint +cd "$GOPATH/src/github.com/tendermint/tendermint" echo "Test reconnecting from the address book" -bash test/p2p/pex/test_addrbook.sh $DOCKER_IMAGE $NETWORK_NAME $N $PROXY_APP +bash test/p2p/pex/test_addrbook.sh "$DOCKER_IMAGE" "$NETWORK_NAME" "$N" "$PROXY_APP" echo "Test connecting via /dial_persistent_peers" -bash test/p2p/pex/test_dial_persistent_peers.sh $DOCKER_IMAGE $NETWORK_NAME $N $PROXY_APP +bash test/p2p/pex/test_dial_persistent_peers.sh "$DOCKER_IMAGE" "$NETWORK_NAME" "$N" "$PROXY_APP" diff --git a/test/p2p/pex/test_dial_manual_peers.sh b/test/p2p/pex/test_dial_persistent_peers.sh similarity index 100% rename from test/p2p/pex/test_dial_manual_peers.sh rename to test/p2p/pex/test_dial_persistent_peers.sh From ef0493ddf3744249a47f20ab49f27fa974b3cf84 Mon Sep 17 00:00:00 2001 From: Anton Kaliaev Date: Tue, 9 Jan 2018 17:41:49 -0600 Subject: [PATCH 06/10] rewrite Peers section of Using Tendermint guide [ci skip] --- docs/using-tendermint.rst | 45 ++++++++++++++++++++++++--------------- 1 file changed, 28 insertions(+), 17 deletions(-) diff --git a/docs/using-tendermint.rst b/docs/using-tendermint.rst index 2a04ac543..20c5fa06d 100644 --- a/docs/using-tendermint.rst +++ b/docs/using-tendermint.rst @@ -129,7 +129,7 @@ No Empty Blocks This much requested feature was implemented in version 0.10.3. While the default behaviour of ``tendermint`` is still to create blocks approximately once per second, it is possible to disable empty blocks or set a block creation interval. In the former case, blocks will be created when there are new transactions or when the AppHash changes. -To configure tendermint to not produce empty blocks unless there are txs or the app hash changes, +To configure tendermint to not produce empty blocks unless there are txs or the app hash changes, run tendermint with this additional flag: :: @@ -263,36 +263,47 @@ with the consensus protocol. Peers ~~~~~ -To connect to peers on start-up, specify them in the ``config.toml`` or -on the command line. +If you are starting Tendermint core for the first time, it will need some peers. + +You can provide a list of seeds (nodes, whole purpose is providing you with +peers) in the ``config.toml`` or on the command line. For instance, :: - tendermint node --p2p.persistent_peers "1.2.3.4:46656,5.6.7.8:46656" + tendermint node --p2p.seeds "1.2.3.4:46656,5.6.7.8:46656" -Alternatively, you can use the ``/dial_persistent_peers`` endpoint of the RPC to -specify peers for a running node to connect to: +Alternatively, you can use the ``/dial_seeds`` endpoint of the RPC to +specify seeds for a running node to connect to: :: - curl --data-urlencode "persistent_peers=[\"1.2.3.4:46656\",\"5.6.7.8:46656\"]" localhost:46657/dial_persistent_peers + curl --data-urlencode "seeds=[\"1.2.3.4:46656\",\"5.6.7.8:46656\"]" localhost:46657/dial_seeds + +Note, if the peer-exchange protocol (PEX) is enabled (default), you should not +normally need seeds after the first start. Peers will be gossipping about known +peers and forming a network, storing peer addresses in the addrbook. + +If you want Tendermint to connect to specific set of addresses and maintain a +persistent connection with each, you can use the ``--p2p.persistent_peers`` +flag or the corresponding setting in the ``config.toml`` or the +``/dial_persistent_peers`` RPC endpoint to do it without stopping Tendermint +core instance. + +:: -Additionally, the peer-exchange protocol can be enabled using the -``--pex`` flag, though this feature is `still under -development `__. If -``--pex`` is enabled, peers will gossip about known peers and form a -more resilient network. + tendermint node --p2p.persistent_peers "10.11.12.13:46656,10.11.12.14:46656" + curl --data-urlencode "persistent_peers=[\"10.11.12.13:46656\",\"10.11.12.14:46656\"]" localhost:46657/dial_persistent_peers Adding a Non-Validator ~~~~~~~~~~~~~~~~~~~~~~ -Adding a non-validator is simple. Just copy the original -``genesis.json`` to ``~/.tendermint`` on the new machine and start the -node, specifying persistent_peers as necessary. If no persistent_peers are specified, the node -won't make any blocks, because it's not a validator, and it won't hear -about any blocks, because it's not connected to the other peer. +Adding a non-validator is simple. Just copy the original ``genesis.json`` to +``~/.tendermint`` on the new machine and start the node, specifying seeds or +persistent peers. If no seeds or persistent peers are specified, the node won't +make any blocks, because it's not a validator, and it won't hear about any +blocks, because it's not connected to the other peers. Adding a Validator ~~~~~~~~~~~~~~~~~~ From 705d51aa423b617d293501b3888eb57367cbf16f Mon Sep 17 00:00:00 2001 From: Anton Kaliaev Date: Tue, 9 Jan 2018 17:09:09 -0600 Subject: [PATCH 07/10] move dialSeedsIfAddrBookIsEmptyOrPEXFailedToConnect into PEX reactor --- node/node.go | 32 ++----------------- p2p/pex_reactor.go | 19 +++++++++-- p2p/pex_reactor_test.go | 10 +++--- .../{manual_peers.sh => persistent_peers.sh} | 0 4 files changed, 24 insertions(+), 37 deletions(-) rename test/p2p/{manual_peers.sh => persistent_peers.sh} (100%) diff --git a/node/node.go b/node/node.go index a4ea193b8..cf78a8aaa 100644 --- a/node/node.go +++ b/node/node.go @@ -8,7 +8,6 @@ import ( "net" "net/http" "strings" - "time" abci "github.com/tendermint/abci/types" crypto "github.com/tendermint/go-crypto" @@ -256,7 +255,8 @@ func NewNode(config *cfg.Config, trustMetricStore = trust.NewTrustMetricStore(trustHistoryDB, trust.DefaultConfig()) trustMetricStore.SetLogger(p2pLogger) - pexReactor := p2p.NewPEXReactor(addrBook) + pexReactor := p2p.NewPEXReactor(addrBook, + &p2p.PEXReactorConfig{Seeds: strings.Split(config.P2P.Seeds, ",")}) pexReactor.SetLogger(p2pLogger) sw.AddReactor("PEX", pexReactor) } @@ -388,38 +388,10 @@ func (n *Node) OnStart() error { } } - if n.config.P2P.Seeds != "" { - err = n.dialSeedsIfAddrBookIsEmptyOrPEXFailedToConnect(strings.Split(n.config.P2P.Seeds, ",")) - if err != nil { - return err - } - } - // start tx indexer return n.indexerService.Start() } -func (n *Node) dialSeedsIfAddrBookIsEmptyOrPEXFailedToConnect(seeds []string) error { - // prefer peers from address book - if n.config.P2P.PexReactor && n.addrBook.Size() > 0 { - // give some time for PexReactor to connect us to other peers - const fallbackToSeedsAfter = 30 * time.Second - go func() { - time.Sleep(fallbackToSeedsAfter) - // fallback to dialing seeds if for some reason we can't connect to any - // peers - outbound, inbound, _ := n.sw.NumPeers() - if n.IsRunning() && outbound+inbound == 0 { - // TODO: ignore error? - n.sw.DialPeersAsync(n.addrBook, seeds, false) - } - }() - return nil - } - - return n.sw.DialPeersAsync(n.addrBook, seeds, false) -} - // OnStop stops the Node. It implements cmn.Service. func (n *Node) OnStop() { n.BaseService.OnStop() diff --git a/p2p/pex_reactor.go b/p2p/pex_reactor.go index 64e7dafb9..9e67a6c2f 100644 --- a/p2p/pex_reactor.go +++ b/p2p/pex_reactor.go @@ -45,6 +45,7 @@ type PEXReactor struct { BaseReactor book *AddrBook + config *PEXReactorConfig ensurePeersPeriod time.Duration // tracks message count by peer, so we can prevent abuse @@ -52,10 +53,18 @@ type PEXReactor struct { maxMsgCountByPeer uint16 } +// PEXReactorConfig holds reactor specific configuration data. +type PEXReactorConfig struct { + // Seeds is a list of addresses reactor may use if it can't connect to peers + // in the addrbook. + Seeds []string +} + // NewPEXReactor creates new PEX reactor. -func NewPEXReactor(b *AddrBook) *PEXReactor { +func NewPEXReactor(b *AddrBook, config *PEXReactorConfig) *PEXReactor { r := &PEXReactor{ book: b, + config: config, ensurePeersPeriod: defaultEnsurePeersPeriod, msgCountByPeer: cmn.NewCMap(), maxMsgCountByPeer: defaultMaxMsgCountByPeer, @@ -238,7 +247,7 @@ func (r *PEXReactor) ensurePeersRoutine() { // placeholder. It should not be the case that an address becomes old/vetted // upon a single successful connection. func (r *PEXReactor) ensurePeers() { - numOutPeers, _, numDialing := r.Switch.NumPeers() + numOutPeers, numInPeers, numDialing := r.Switch.NumPeers() numToDial := minNumOutboundPeers - (numOutPeers + numDialing) r.Logger.Info("Ensure peers", "numOutPeers", numOutPeers, "numDialing", numDialing, "numToDial", numToDial) if numToDial <= 0 { @@ -291,6 +300,12 @@ func (r *PEXReactor) ensurePeers() { r.RequestPEX(peer) } } + + // If we can't connect to any known address, fallback to dialing seeds + if numOutPeers+numInPeers+numDialing == 0 { + r.Logger.Info("No addresses to dial nor connected peers. Will dial seeds", "seeds", r.config.Seeds) + r.Switch.DialPeersAsync(r.book, r.config.Seeds, false) + } } func (r *PEXReactor) flushMsgCountByPeer() { diff --git a/p2p/pex_reactor_test.go b/p2p/pex_reactor_test.go index a14f0eb2a..b37f66411 100644 --- a/p2p/pex_reactor_test.go +++ b/p2p/pex_reactor_test.go @@ -24,7 +24,7 @@ func TestPEXReactorBasic(t *testing.T) { book := NewAddrBook(dir+"addrbook.json", true) book.SetLogger(log.TestingLogger()) - r := NewPEXReactor(book) + r := NewPEXReactor(book, &PEXReactorConfig{}) r.SetLogger(log.TestingLogger()) assert.NotNil(r) @@ -40,7 +40,7 @@ func TestPEXReactorAddRemovePeer(t *testing.T) { book := NewAddrBook(dir+"addrbook.json", true) book.SetLogger(log.TestingLogger()) - r := NewPEXReactor(book) + r := NewPEXReactor(book, &PEXReactorConfig{}) r.SetLogger(log.TestingLogger()) size := book.Size() @@ -76,7 +76,7 @@ func TestPEXReactorRunning(t *testing.T) { switches[i] = makeSwitch(config, i, "127.0.0.1", "123.123.123", func(i int, sw *Switch) *Switch { sw.SetLogger(log.TestingLogger().With("switch", i)) - r := NewPEXReactor(book) + r := NewPEXReactor(book, &PEXReactorConfig{}) r.SetLogger(log.TestingLogger()) r.SetEnsurePeersPeriod(250 * time.Millisecond) sw.AddReactor("pex", r) @@ -141,7 +141,7 @@ func TestPEXReactorReceive(t *testing.T) { book := NewAddrBook(dir+"addrbook.json", false) book.SetLogger(log.TestingLogger()) - r := NewPEXReactor(book) + r := NewPEXReactor(book, &PEXReactorConfig{}) r.SetLogger(log.TestingLogger()) peer := createRandomPeer(false) @@ -166,7 +166,7 @@ func TestPEXReactorAbuseFromPeer(t *testing.T) { book := NewAddrBook(dir+"addrbook.json", true) book.SetLogger(log.TestingLogger()) - r := NewPEXReactor(book) + r := NewPEXReactor(book, &PEXReactorConfig{}) r.SetLogger(log.TestingLogger()) r.SetMaxMsgCountByPeer(5) diff --git a/test/p2p/manual_peers.sh b/test/p2p/persistent_peers.sh similarity index 100% rename from test/p2p/manual_peers.sh rename to test/p2p/persistent_peers.sh From 075ae1e301c5957dd1954a769e3e09eb270852cc Mon Sep 17 00:00:00 2001 From: Anton Kaliaev Date: Tue, 9 Jan 2018 18:29:29 -0600 Subject: [PATCH 08/10] minimal test for dialing seeds in pex reactor --- p2p/pex_reactor.go | 13 ++++++----- p2p/pex_reactor_test.go | 49 ++++++++++++++++++++++++++++++++++++++++- 2 files changed, 55 insertions(+), 7 deletions(-) diff --git a/p2p/pex_reactor.go b/p2p/pex_reactor.go index 9e67a6c2f..ce2bba8bc 100644 --- a/p2p/pex_reactor.go +++ b/p2p/pex_reactor.go @@ -293,16 +293,17 @@ func (r *PEXReactor) ensurePeers() { // If we need more addresses, pick a random peer and ask for more. if r.book.NeedMoreAddrs() { - if peers := r.Switch.Peers().List(); len(peers) > 0 { - i := rand.Int() % len(peers) // nolint: gas - peer := peers[i] - r.Logger.Info("No addresses to dial. Sending pexRequest to random peer", "peer", peer) + peers := r.Switch.Peers().List() + peersCount := len(peers) + if peersCount > 0 { + peer := peers[rand.Int()%peersCount] // nolint: gas + r.Logger.Info("We need more addresses. Sending pexRequest to random peer", "peer", peer) r.RequestPEX(peer) } } - // If we can't connect to any known address, fallback to dialing seeds - if numOutPeers+numInPeers+numDialing == 0 { + // If we are not connected to nor dialing anybody, fallback to dialing seeds. + if numOutPeers+numInPeers+numDialing+len(toDial) == 0 { r.Logger.Info("No addresses to dial nor connected peers. Will dial seeds", "seeds", r.config.Seeds) r.Switch.DialPeersAsync(r.book, r.config.Seeds, false) } diff --git a/p2p/pex_reactor_test.go b/p2p/pex_reactor_test.go index b37f66411..fc2fe687f 100644 --- a/p2p/pex_reactor_test.go +++ b/p2p/pex_reactor_test.go @@ -107,6 +107,7 @@ func TestPEXReactorRunning(t *testing.T) { func assertSomePeersWithTimeout(t *testing.T, switches []*Switch, checkPeriod, timeout time.Duration) { ticker := time.NewTicker(checkPeriod) + remaining := timeout for { select { case <-ticker.C: @@ -118,16 +119,21 @@ func assertSomePeersWithTimeout(t *testing.T, switches []*Switch, checkPeriod, t allGood = false } } + remaining -= checkPeriod + if remaining < 0 { + remaining = 0 + } if allGood { return } - case <-time.After(timeout): + case <-time.After(remaining): numPeersStr := "" for i, s := range switches { outbound, inbound, _ := s.NumPeers() numPeersStr += fmt.Sprintf("%d => {outbound: %d, inbound: %d}, ", i, outbound, inbound) } t.Errorf("expected all switches to be connected to at least one peer (switches: %s)", numPeersStr) + return } } } @@ -180,6 +186,47 @@ func TestPEXReactorAbuseFromPeer(t *testing.T) { assert.True(r.ReachedMaxMsgCountForPeer(peer.NodeInfo().ListenAddr)) } +func TestPEXReactorUsesSeedsIfNeeded(t *testing.T) { + dir, err := ioutil.TempDir("", "pex_reactor") + require.Nil(t, err) + defer os.RemoveAll(dir) // nolint: errcheck + + book := NewAddrBook(dir+"addrbook.json", false) + book.SetLogger(log.TestingLogger()) + + // 1. create seed + seed := makeSwitch(config, 0, "127.0.0.1", "123.123.123", func(i int, sw *Switch) *Switch { + sw.SetLogger(log.TestingLogger()) + + r := NewPEXReactor(book, &PEXReactorConfig{}) + r.SetLogger(log.TestingLogger()) + r.SetEnsurePeersPeriod(250 * time.Millisecond) + sw.AddReactor("pex", r) + return sw + }) + seed.AddListener(NewDefaultListener("tcp", seed.NodeInfo().ListenAddr, true, log.TestingLogger())) + err = seed.Start() + require.Nil(t, err) + defer seed.Stop() + + // 2. create usual peer + sw := makeSwitch(config, 1, "127.0.0.1", "123.123.123", func(i int, sw *Switch) *Switch { + sw.SetLogger(log.TestingLogger()) + + r := NewPEXReactor(book, &PEXReactorConfig{Seeds: []string{seed.NodeInfo().ListenAddr}}) + r.SetLogger(log.TestingLogger()) + r.SetEnsurePeersPeriod(250 * time.Millisecond) + sw.AddReactor("pex", r) + return sw + }) + err = sw.Start() + require.Nil(t, err) + defer sw.Stop() + + // 3. check that peer at least connects to seed + assertSomePeersWithTimeout(t, []*Switch{sw}, 10*time.Millisecond, 10*time.Second) +} + func createRoutableAddr() (addr string, netAddr *NetAddress) { for { addr = cmn.Fmt("%v.%v.%v.%v:46656", rand.Int()%256, rand.Int()%256, rand.Int()%256, rand.Int()%256) From e2b3b5b58ccec6efff6385ddd64806d71e1fb3f6 Mon Sep 17 00:00:00 2001 From: Ethan Buchman Date: Sat, 13 Jan 2018 14:50:32 -0500 Subject: [PATCH 09/10] dial_persistent_peers -> dial_peers with persistent option --- docs/specification/rpc.rst | 2 +- docs/using-tendermint.rst | 8 ++++---- p2p/switch.go | 2 +- rpc/client/localclient.go | 4 ++-- rpc/client/mock/client.go | 4 ++-- rpc/core/net.go | 14 +++++++------- rpc/core/routes.go | 2 +- rpc/core/types/responses.go | 2 +- 8 files changed, 19 insertions(+), 19 deletions(-) diff --git a/docs/specification/rpc.rst b/docs/specification/rpc.rst index e714cb353..7df394d77 100644 --- a/docs/specification/rpc.rst +++ b/docs/specification/rpc.rst @@ -112,7 +112,7 @@ An HTTP Get request to the root RPC endpoint (e.g. http://localhost:46657/broadcast_tx_sync?tx=_ http://localhost:46657/commit?height=_ http://localhost:46657/dial_seeds?seeds=_ - http://localhost:46657/dial_persistent_peers?persistent_peers=_ + http://localhost:46657/dial_peers?peers=_&persistent=_ http://localhost:46657/subscribe?event=_ http://localhost:46657/tx?hash=_&prove=_ http://localhost:46657/unsafe_start_cpu_profiler?filename=_ diff --git a/docs/using-tendermint.rst b/docs/using-tendermint.rst index 1b60ea5ff..735fce654 100644 --- a/docs/using-tendermint.rst +++ b/docs/using-tendermint.rst @@ -287,7 +287,7 @@ specify seeds for a running node to connect to: :: - curl --data-urlencode "seeds=[\"1.2.3.4:46656\",\"5.6.7.8:46656\"]" localhost:46657/dial_seeds + curl 'localhost:46657/dial_seeds?seeds=\["1.2.3.4:46656","5.6.7.8:46656"\]' Note, if the peer-exchange protocol (PEX) is enabled (default), you should not normally need seeds after the first start. Peers will be gossipping about known @@ -296,13 +296,13 @@ peers and forming a network, storing peer addresses in the addrbook. If you want Tendermint to connect to specific set of addresses and maintain a persistent connection with each, you can use the ``--p2p.persistent_peers`` flag or the corresponding setting in the ``config.toml`` or the -``/dial_persistent_peers`` RPC endpoint to do it without stopping Tendermint +``/dial_peers`` RPC endpoint to do it without stopping Tendermint core instance. :: tendermint node --p2p.persistent_peers "10.11.12.13:46656,10.11.12.14:46656" - curl --data-urlencode "persistent_peers=[\"10.11.12.13:46656\",\"10.11.12.14:46656\"]" localhost:46657/dial_persistent_peers + curl 'localhost:46657/dial_peers?persistent=true&peers=\["1.2.3.4:46656","5.6.7.8:46656"\]' Adding a Non-Validator ~~~~~~~~~~~~~~~~~~~~~~ @@ -382,7 +382,7 @@ and the new ``priv_validator.json`` to the ``~/.tendermint/config`` on a new machine. Now run ``tendermint node`` on both machines, and use either -``--p2p.persistent_peers`` or the ``/dial_persistent_peers`` to get them to peer up. They +``--p2p.persistent_peers`` or the ``/dial_peers`` to get them to peer up. They should start making blocks, and will only continue to do so as long as both of them are online. diff --git a/p2p/switch.go b/p2p/switch.go index 1b449d7e0..95c632aa7 100644 --- a/p2p/switch.go +++ b/p2p/switch.go @@ -323,7 +323,7 @@ func (sw *Switch) DialPeersAsync(addrBook *AddrBook, peers []string, persistent } if addrBook != nil { - // add persistent peers to `addrBook` + // add peers to `addrBook` ourAddrS := sw.nodeInfo.ListenAddr ourAddr, _ := NewNetAddressString(ourAddrS) for _, netAddr := range netAddrs { diff --git a/rpc/client/localclient.go b/rpc/client/localclient.go index cc23b9449..5e0573a1b 100644 --- a/rpc/client/localclient.go +++ b/rpc/client/localclient.go @@ -88,8 +88,8 @@ func (Local) DialSeeds(seeds []string) (*ctypes.ResultDialSeeds, error) { return core.UnsafeDialSeeds(seeds) } -func (Local) DialPersistentPeers(persistent_peers []string) (*ctypes.ResultDialPersistentPeers, error) { - return core.UnsafeDialPersistentPeers(persistent_peers) +func (Local) DialPeers(peers []string, persistent bool) (*ctypes.ResultDialPeers, error) { + return core.UnsafeDialPeers(peers, persistent) } func (Local) BlockchainInfo(minHeight, maxHeight int64) (*ctypes.ResultBlockchainInfo, error) { diff --git a/rpc/client/mock/client.go b/rpc/client/mock/client.go index 913812d6d..6c4728986 100644 --- a/rpc/client/mock/client.go +++ b/rpc/client/mock/client.go @@ -111,8 +111,8 @@ func (c Client) DialSeeds(seeds []string) (*ctypes.ResultDialSeeds, error) { return core.UnsafeDialSeeds(seeds) } -func (c Client) DialPersistentPeers(persistent_peers []string) (*ctypes.ResultDialPersistentPeers, error) { - return core.UnsafeDialPersistentPeers(persistent_peers) +func (c Client) DialPeers(peers []string, persistent bool) (*ctypes.ResultDialPeers, error) { + return core.UnsafeDialPeers(peers, persistent) } func (c Client) BlockchainInfo(minHeight, maxHeight int64) (*ctypes.ResultBlockchainInfo, error) { diff --git a/rpc/core/net.go b/rpc/core/net.go index b528e1e35..af52c81cc 100644 --- a/rpc/core/net.go +++ b/rpc/core/net.go @@ -66,17 +66,17 @@ func UnsafeDialSeeds(seeds []string) (*ctypes.ResultDialSeeds, error) { return &ctypes.ResultDialSeeds{"Dialing seeds in progress. See /net_info for details"}, nil } -func UnsafeDialPersistentPeers(persistent_peers []string) (*ctypes.ResultDialPersistentPeers, error) { - if len(persistent_peers) == 0 { - return &ctypes.ResultDialPersistentPeers{}, errors.New("No persistent peers provided") +func UnsafeDialPeers(peers []string, persistent bool) (*ctypes.ResultDialPeers, error) { + if len(peers) == 0 { + return &ctypes.ResultDialPeers{}, errors.New("No peers provided") } // starts go routines to dial each peer after random delays - logger.Info("DialPersistentPeers", "addrBook", addrBook, "persistent_peers", persistent_peers) - err := p2pSwitch.DialPeersAsync(addrBook, persistent_peers, true) + logger.Info("DialPeers", "addrBook", addrBook, "peers", peers, "persistent", persistent) + err := p2pSwitch.DialPeersAsync(addrBook, peers, persistent) if err != nil { - return &ctypes.ResultDialPersistentPeers{}, err + return &ctypes.ResultDialPeers{}, err } - return &ctypes.ResultDialPersistentPeers{"Dialing persistent peers in progress. See /net_info for details"}, nil + return &ctypes.ResultDialPeers{"Dialing peers in progress. See /net_info for details"}, nil } // Get genesis file. diff --git a/rpc/core/routes.go b/rpc/core/routes.go index d00165e6a..3ea7aa08c 100644 --- a/rpc/core/routes.go +++ b/rpc/core/routes.go @@ -39,7 +39,7 @@ var Routes = map[string]*rpc.RPCFunc{ func AddUnsafeRoutes() { // control API Routes["dial_seeds"] = rpc.NewRPCFunc(UnsafeDialSeeds, "seeds") - Routes["dial_persistent_peers"] = rpc.NewRPCFunc(UnsafeDialPersistentPeers, "persistent_peers") + Routes["dial_peers"] = rpc.NewRPCFunc(UnsafeDialPeers, "peers,persistent") Routes["unsafe_flush_mempool"] = rpc.NewRPCFunc(UnsafeFlushMempool, "") // profiler API diff --git a/rpc/core/types/responses.go b/rpc/core/types/responses.go index c26defb76..bffdd0281 100644 --- a/rpc/core/types/responses.go +++ b/rpc/core/types/responses.go @@ -86,7 +86,7 @@ type ResultDialSeeds struct { Log string `json:"log"` } -type ResultDialPersistentPeers struct { +type ResultDialPeers struct { Log string `json:"log"` } From c1e167e330907f5639c32b4099d393ae3492f868 Mon Sep 17 00:00:00 2001 From: Ethan Buchman Date: Sat, 13 Jan 2018 15:11:13 -0500 Subject: [PATCH 10/10] note in trust metric test --- p2p/trust/metric_test.go | 2 ++ p2p/trust/ticker.go | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/p2p/trust/metric_test.go b/p2p/trust/metric_test.go index 00219a19e..69c9f8f2a 100644 --- a/p2p/trust/metric_test.go +++ b/p2p/trust/metric_test.go @@ -68,7 +68,9 @@ func TestTrustMetricStopPause(t *testing.T) { tt.NextTick() tm.Pause() + // could be 1 or 2 because Pause and NextTick race first := tm.Copy().numIntervals + // Allow more time to pass and check the intervals are unchanged tt.NextTick() tt.NextTick() diff --git a/p2p/trust/ticker.go b/p2p/trust/ticker.go index bce9fcc24..3f0f30919 100644 --- a/p2p/trust/ticker.go +++ b/p2p/trust/ticker.go @@ -24,7 +24,7 @@ type TestTicker struct { // NewTestTicker returns our ticker used within test routines func NewTestTicker() *TestTicker { - c := make(chan time.Time, 1) + c := make(chan time.Time) return &TestTicker{ C: c, }