From 9752e059e1ca10e0a7a2e130fd9ce4b97d1a6e1a Mon Sep 17 00:00:00 2001 From: Anton Kaliaev Date: Fri, 29 Jun 2018 16:03:31 +0400 Subject: [PATCH 1/5] fix nil pointer panic by checking if peer is nil Fixes #1830 remember that PeerSet#Get can return nil --- p2p/peer_set.go | 11 ++++++----- p2p/pex/pex_reactor.go | 8 +++++--- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/p2p/peer_set.go b/p2p/peer_set.go index e048cf4e3..257856156 100644 --- a/p2p/peer_set.go +++ b/p2p/peer_set.go @@ -55,8 +55,8 @@ func (ps *PeerSet) Add(peer Peer) error { return nil } -// Has returns true iff the PeerSet contains -// the peer referred to by this peerKey. +// Has returns true if the set contains the peer referred to by this +// peerKey, otherwise false. func (ps *PeerSet) Has(peerKey ID) bool { ps.mtx.Lock() _, ok := ps.lookup[peerKey] @@ -64,8 +64,8 @@ func (ps *PeerSet) Has(peerKey ID) bool { return ok } -// HasIP returns true if the PeerSet contains the peer referred to by this IP -// address. +// HasIP returns true if the set contains the peer referred to by this IP +// address, otherwise false. func (ps *PeerSet) HasIP(peerIP net.IP) bool { ps.mtx.Lock() defer ps.mtx.Unlock() @@ -85,7 +85,8 @@ func (ps *PeerSet) hasIP(peerIP net.IP) bool { return false } -// Get looks up a peer by the provided peerKey. +// Get looks up a peer by the provided peerKey. Returns nil if peer is not +// found. func (ps *PeerSet) Get(peerKey ID) Peer { ps.mtx.Lock() defer ps.mtx.Unlock() diff --git a/p2p/pex/pex_reactor.go b/p2p/pex/pex_reactor.go index 27ed422c5..48b6d43e7 100644 --- a/p2p/pex/pex_reactor.go +++ b/p2p/pex/pex_reactor.go @@ -77,10 +77,10 @@ type PEXReactor struct { attemptsToDial sync.Map // address (string) -> {number of attempts (int), last time dialed (time.Time)} } -func (pexR *PEXReactor) minReceiveRequestInterval() time.Duration { +func (r *PEXReactor) minReceiveRequestInterval() time.Duration { // NOTE: must be less than ensurePeersPeriod, otherwise we'll request // peers too quickly from others and they'll think we're bad! - return pexR.ensurePeersPeriod / 3 + return r.ensurePeersPeriod / 3 } // PEXReactorConfig holds reactor specific configuration data. @@ -628,7 +628,9 @@ func (r *PEXReactor) crawlPeers() { } // Ask for more addresses peer := r.Switch.Peers().Get(pi.Addr.ID) - r.RequestAddrs(peer) + if peer != nil { + r.RequestAddrs(peer) + } } } From bb0313d0602c15a18aa392b741847317cdfc34d5 Mon Sep 17 00:00:00 2001 From: Lawrence Tran Date: Fri, 29 Jun 2018 13:09:50 -0500 Subject: [PATCH 2/5] Fix typo (#1837) The base64 encoding for 'abcd' is incorrect for the python decoding examples. --- docs/getting-started.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/getting-started.md b/docs/getting-started.md index 2d2c77b16..1fa1405f2 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -125,8 +125,8 @@ The result should look like: Note the `value` in the result (`YWJjZA==`); this is the base64-encoding of the ASCII of `abcd`. You can verify this in a python 2 shell by -running `"61626364".decode('base64')` or in python 3 shell by running -`import codecs; codecs.decode("61626364", 'base64').decode('ascii')`. +running `"YWJjZA==".decode('base64')` or in python 3 shell by running +`import codecs; codecs.decode("YWJjZA==", 'base64').decode('ascii')`. Stay tuned for a future release that [makes this output more human-readable](https://github.com/tendermint/tendermint/issues/1794). From 6e5a01ccec260cf3f0573255cb067ec9dfd46736 Mon Sep 17 00:00:00 2001 From: Ethan Buchman Date: Sun, 1 Jul 2018 00:50:49 -0400 Subject: [PATCH 3/5] changelog and version --- CHANGELOG.md | 49 ++++++++++++++++++++++++++++++---------------- version/version.go | 4 ++-- 2 files changed, 34 insertions(+), 19 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 24ec19d79..154c51c83 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,23 +1,45 @@ # Changelog -## TBD +## 0.22.0 -IMPROVEMENTS: - - [crypto] Make public key size into public constants - -BUG FIXES: -- [rpc] limited number of HTTP/WebSocket connections - (`rpc.max_open_connections`) and gRPC connections - (`rpc.grpc_max_open_connections`). Check out [Running In - Production](https://tendermint.readthedocs.io/en/master/running-in-production.html) - guide if you want to increase them. +*July 1st, 2018* BREAKING CHANGES: - [config] Rename `skip_upnp` to `upnp`, and turn it off by default. +- [config] `MaxPacketMsgPayloadSize` -> `MaxPacketMsgSize` +- [types] Update Amino to v0.10.1 + * Amino is now fully proto3 compatible for the basic types + * JSON-encoded types now use the type name instead of the prefix bytes + * Integers are encoded as strings +- [crypto] Update go-crypto to v0.10.0 and merge into `crypto` + * privKey.Sign returns error. + * ed25519 address is the first 20-bytes of the SHA256 of the pubkey + * `tmlibs/merkle` -> `crypto/merkle`. Uses SHA256 instead of RIPEMD160 +- [rpc] `syncing` is now called `catching_up`. + +FEATURES +- [cmd] Added metrics (served under `/metrics` using a Prometheus client; + disabled by default). See the new `instrumentation` section in the config and + [metrics](https://tendermint.readthedocs.io/projects/tools/en/develop/metrics.html) + guide. +- [p2p] Rudimentary IPv6 support IMPROVEMENT - [rpc/client] Supports https and wss now. - [p2p] Add IPv6 support to peering. +- [crypto] Make public key size into public constants +- [mempool] Log tx hash, not entire tx +- [abci] Merged in github.com/tendermint/abci +- [docs] Move from .rst to .md + +BUG FIXES: +- [rpc] Limited number of HTTP/WebSocket connections + (`rpc.max_open_connections`) and gRPC connections + (`rpc.grpc_max_open_connections`). Check out [Running In + Production](https://tendermint.readthedocs.io/en/master/running-in-production.html) + guide if you want to increase them. +- [consensus] Fix a halting bug where `create_empty_blocks=false` +- [p2p] Fix panic in seed mode ## 0.21.0 @@ -34,13 +56,6 @@ IMPROVEMENT - [pubsub] Set default capacity to 0 - [docs] Various improvements -FEATURES - -- [main] added metrics (served under `/metrics` using a Prometheus client; - disabled by default). See the new `instrumentation` section in the config and - [metrics](https://tendermint.readthedocs.io/projects/tools/en/v0.21.0/metrics.html) - guide. - BUG FIXES - [consensus] Fix an issue where we don't make blocks after `fast_sync` when `create_empty_blocks=false` diff --git a/version/version.go b/version/version.go index df553115a..9be4c9d82 100644 --- a/version/version.go +++ b/version/version.go @@ -3,14 +3,14 @@ package version // Version components const ( Maj = "0" - Min = "21" + Min = "22" Fix = "0" ) var ( // Version is the current version of Tendermint // Must be a string because scripts like dist.sh read this file. - Version = "0.21.0" + Version = "0.22.0" // GitCommit is the current HEAD set using ldflags. GitCommit string From f35ebd5cf71d1362f410ab6f016e4302e3f40f06 Mon Sep 17 00:00:00 2001 From: Ethan Buchman Date: Sun, 1 Jul 2018 01:23:38 -0400 Subject: [PATCH 4/5] docs: minor fix for abci query peer filter --- docs/app-development.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/app-development.md b/docs/app-development.md index 32abe2151..f8c70f21b 100644 --- a/docs/app-development.md +++ b/docs/app-development.md @@ -394,13 +394,13 @@ serialize each query as a single byte array. Additionally, certain instance about which peers to connect to. Tendermint Core currently uses the Query connection to filter peers upon -connecting, according to IP address or public key. For instance, +connecting, according to IP address or node ID. For instance, returning non-OK ABCI response to either of the following queries will cause Tendermint to not connect to the corresponding peer: -- `p2p/filter/addr/`, where `` is an IP address. -- `p2p/filter/pubkey/`, where `` is the hex-encoded - ED25519 key of the node (not it's validator key) +- `p2p/filter/addr/`, where `` is an IP address. +- `p2p/filter/id/`, where `` is the hex-encoded node ID (the hash of + the node's p2p pubkey). Note: these query formats are subject to change! From da4632c651df0ff912dea3c8c328785486087fad Mon Sep 17 00:00:00 2001 From: Ethan Buchman Date: Sun, 1 Jul 2018 01:29:03 -0400 Subject: [PATCH 5/5] docs/spec: update address spec to sha2 for ed25519 --- docs/spec/blockchain/encoding.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/docs/spec/blockchain/encoding.md b/docs/spec/blockchain/encoding.md index 1c33aa1fa..fd8e64a42 100644 --- a/docs/spec/blockchain/encoding.md +++ b/docs/spec/blockchain/encoding.md @@ -84,14 +84,13 @@ Addresses for each public key types are computed as follows: #### Ed25519 -RIPEMD160 hash of the Amino encoded public key: +First 20-bytes of the SHA256 hash of the raw 32-byte public key: ``` -address = RIPEMD160(AMINO(pubkey)) +address = SHA256(pubkey)[:20] ``` -NOTE: this will soon change to the truncated 20-bytes of the SHA256 of the raw -public key +NOTE: before v0.22.0, this was the RIPEMD160 of the Amino encoded public key. #### Secp256k1