Update codebase to leverage Whisper v6 (#703)

* Update project to use Whisper v6. Part of #638

* Revert "Add patch to downgrade usage of Whisper v6 to v5 in some geth 1.8.1 vendor files. Part of #665" - this reverts commit 6aefb4c8fd02dbcfffac6b69e8bb22b13ef86b6b.

* Enable light mode on Whisper v6 for non-mail servers. Part of #638

* Fix race condition in whisperv6/peer.go. Part of #665 (PR already accepted upstream for 1.8.2)

* Update bootnode addresses in staticnodes.json. Part of #638

* Add `shh.lightclient` flag and tests for bloom filter setting logic. Part of #638

* Move MakeTestNodeConfig to utils. Part of #638

* Reduce PoW in `whisper_jail_test.go` to fix flaky test. Part of #638
This commit is contained in:
Pedro Pombeiro 2018-03-02 10:25:30 +01:00 committed by GitHub
parent e5743695cc
commit 6cdea4ef97
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
39 changed files with 363 additions and 249 deletions

2
Gopkg.lock generated
View File

@ -470,6 +470,6 @@
[solve-meta]
analyzer-name = "dep"
analyzer-version = 1
inputs-digest = "6272bfa7822dec71d4c8da4cf7b45de6cefe920e0eeb0c48acce55b9928903e7"
inputs-digest = "29b8637c1c6198d24f34a9882acf15d3203d8a9cdd6439464967ecff798efba1"
solver-name = "gps-cdcl"
solver-version = 1

View File

@ -1,26 +0,0 @@
diff --git a/cmd/wnode/main.go b/cmd/wnode/main.go
index 971b1c0ab..d42409db5 100644
--- a/cmd/wnode/main.go
+++ b/cmd/wnode/main.go
@@ -43,7 +43,7 @@ import (
"github.com/ethereum/go-ethereum/p2p/discover"
"github.com/ethereum/go-ethereum/p2p/nat"
"github.com/ethereum/go-ethereum/whisper/mailserver"
- whisper "github.com/ethereum/go-ethereum/whisper/whisperv6"
+ whisper "github.com/ethereum/go-ethereum/whisper/whisperv5"
"golang.org/x/crypto/pbkdf2"
)
diff --git a/whisper/mailserver/mailserver.go b/whisper/mailserver/mailserver.go
index 6555fd5c0..0ec6ec570 100644
--- a/whisper/mailserver/mailserver.go
+++ b/whisper/mailserver/mailserver.go
@@ -26,7 +26,7 @@ import (
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/rlp"
- whisper "github.com/ethereum/go-ethereum/whisper/whisperv6"
+ whisper "github.com/ethereum/go-ethereum/whisper/whisperv5"
"github.com/syndtr/goleveldb/leveldb"
"github.com/syndtr/goleveldb/leveldb/util"
)

View File

@ -0,0 +1,35 @@
diff --git a/whisper/whisperv6/peer.go b/whisper/whisperv6/peer.go
index 4ef0f3c4..6a7ab358 100644
--- a/whisper/whisperv6/peer.go
+++ b/whisper/whisperv6/peer.go
@@ -19,6 +19,7 @@ package whisperv6
import (
"fmt"
"math"
+ "sync"
"time"
"github.com/ethereum/go-ethereum/common"
@@ -38,6 +39,7 @@ type Peer struct {
powRequirement float64
+ bloomMu sync.Mutex
bloomFilter []byte
fullNode bool
known *set.Set // Messages already known by the peer to avoid wasting bandwidth
@@ -225,10 +227,14 @@ func (peer *Peer) notifyAboutBloomFilterChange(bloom []byte) error {
}
func (peer *Peer) bloomMatch(env *Envelope) bool {
+ peer.bloomMu.Lock()
+ defer peer.bloomMu.Unlock()
return peer.fullNode || bloomFilterMatch(peer.bloomFilter, env.Bloom())
}
func (peer *Peer) setBloomFilter(bloom []byte) {
+ peer.bloomMu.Lock()
+ defer peer.bloomMu.Unlock()
peer.bloomFilter = bloom
peer.fullNode = isFullNode(bloom)
if peer.fullNode && peer.bloomFilter == nil {

View File

@ -35,8 +35,7 @@ Instructions for creating a patch from the command line:
- [`0010-geth-17-fix-npe-in-filter-system.patch`](./0010-geth-17-fix-npe-in-filter-system.patch) - Temp patch for 1.7.x to fix a NPE in the filter system.
- [`0014-whisperv6-notifications.patch`](./0014-whisperv6-notifications.patch) — adds Whisper v6 notifications (need to be reviewed and documented)
- [`0015-whisperv6-envelopes-tracing.patch`](./0015-whisperv6-envelopes-tracing.patch) — adds Whisper v6 envelope tracing (need to be reviewed and documented)
- [`0017-geth-18-downgrade-to-whisperv5.patch`](./0017-geth-18-downgrade-to-whisperv5.patch) — some files in geth 1.8 import Whisper v6, instead of v5. This patch ensures v5 is used everywhere
- [`0018-geth-181-whisperv6-peer-race-cond-fix.patch`](./0018-geth-181-whisperv6-peer-race-cond-fix.patch) — Fixes race condition in Whisper v6. This has been merged upstream and this patch will need to be removed for 1.8.2.
# Updating

View File

@ -58,6 +58,7 @@ var (
passwordFile = flag.String("shh.passwordfile", "", "Password file (password is used for symmetric encryption)")
minPow = flag.Float64("shh.pow", params.WhisperMinimumPoW, "PoW for messages to be added to queue, in float format")
ttl = flag.Int("shh.ttl", params.WhisperTTL, "Time to live for messages, in seconds")
lightClient = flag.Bool("shh.lightclient", false, "Start with empty bloom filter, and don't forward messages")
// MailServer
enableMailServer = flag.Bool("shh.mailserver", false, "Delivers expired messages on demand")

View File

@ -14,6 +14,7 @@ func whisperConfig(nodeConfig *params.NodeConfig) (*params.NodeConfig, error) {
whisperConfig := nodeConfig.WhisperConfig
whisperConfig.Enabled = true
whisperConfig.EnableMailServer = *enableMailServer
whisperConfig.LightClient = *lightClient
whisperConfig.MinimumPoW = *minPow
whisperConfig.TTL = *ttl

View File

@ -12,7 +12,7 @@ import (
"github.com/ethereum/go-ethereum/accounts"
"github.com/ethereum/go-ethereum/accounts/keystore"
gethcommon "github.com/ethereum/go-ethereum/common"
whisper "github.com/ethereum/go-ethereum/whisper/whisperv5"
whisper "github.com/ethereum/go-ethereum/whisper/whisperv6"
"github.com/golang/mock/gomock"
"github.com/status-im/status-go/geth/common"
. "github.com/status-im/status-go/t/utils"

View File

@ -16,7 +16,7 @@ import (
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/les"
"github.com/ethereum/go-ethereum/node"
whisper "github.com/ethereum/go-ethereum/whisper/whisperv5"
whisper "github.com/ethereum/go-ethereum/whisper/whisperv6"
"github.com/status-im/status-go/geth/params"
"github.com/status-im/status-go/geth/rpc"
"github.com/status-im/status-go/static"

View File

@ -11,7 +11,7 @@ import (
common "github.com/ethereum/go-ethereum/common"
les "github.com/ethereum/go-ethereum/les"
node "github.com/ethereum/go-ethereum/node"
whisperv5 "github.com/ethereum/go-ethereum/whisper/whisperv5"
whisperv6 "github.com/ethereum/go-ethereum/whisper/whisperv6"
gomock "github.com/golang/mock/gomock"
params "github.com/status-im/status-go/geth/params"
rpc "github.com/status-im/status-go/geth/rpc"
@ -165,9 +165,9 @@ func (mr *MockNodeManagerMockRecorder) LightEthereumService() *gomock.Call {
}
// WhisperService mocks base method
func (m *MockNodeManager) WhisperService() (*whisperv5.Whisper, error) {
func (m *MockNodeManager) WhisperService() (*whisperv6.Whisper, error) {
ret := m.ctrl.Call(m, "WhisperService")
ret0, _ := ret[0].(*whisperv5.Whisper)
ret0, _ := ret[0].(*whisperv6.Whisper)
ret1, _ := ret[1].(error)
return ret0, ret1
}

View File

@ -4,7 +4,7 @@ import (
"github.com/ethereum/go-ethereum/node"
"github.com/ethereum/go-ethereum/p2p"
"github.com/ethereum/go-ethereum/rpc"
whisper "github.com/ethereum/go-ethereum/whisper/whisperv5"
whisper "github.com/ethereum/go-ethereum/whisper/whisperv6"
)
// ServiceProvider provides node and required services.

View File

@ -9,7 +9,7 @@ import (
"time"
"github.com/ethereum/go-ethereum/p2p/discover"
whisper "github.com/ethereum/go-ethereum/whisper/whisperv5"
whisper "github.com/ethereum/go-ethereum/whisper/whisperv6"
"github.com/status-im/status-go/geth/log"
)

View File

@ -6,7 +6,7 @@ import (
"time"
"github.com/ethereum/go-ethereum/node"
whisper "github.com/ethereum/go-ethereum/whisper/whisperv5"
whisper "github.com/ethereum/go-ethereum/whisper/whisperv6"
gomock "github.com/golang/mock/gomock"
"github.com/stretchr/testify/require"
)

View File

@ -6,7 +6,7 @@ package mailservice
import (
node "github.com/ethereum/go-ethereum/node"
whisperv5 "github.com/ethereum/go-ethereum/whisper/whisperv5"
whisperv6 "github.com/ethereum/go-ethereum/whisper/whisperv6"
gomock "github.com/golang/mock/gomock"
reflect "reflect"
)
@ -48,9 +48,9 @@ func (mr *MockServiceProviderMockRecorder) Node() *gomock.Call {
}
// WhisperService mocks base method
func (m *MockServiceProvider) WhisperService() (*whisperv5.Whisper, error) {
func (m *MockServiceProvider) WhisperService() (*whisperv6.Whisper, error) {
ret := m.ctrl.Call(m, "WhisperService")
ret0, _ := ret[0].(*whisperv5.Whisper)
ret0, _ := ret[0].(*whisperv6.Whisper)
ret1, _ := ret[1].(error)
return ret0, ret1
}

View File

@ -14,7 +14,7 @@ import (
"github.com/ethereum/go-ethereum/les"
"github.com/ethereum/go-ethereum/node"
"github.com/ethereum/go-ethereum/p2p/discover"
whisper "github.com/ethereum/go-ethereum/whisper/whisperv5"
whisper "github.com/ethereum/go-ethereum/whisper/whisperv6"
"github.com/status-im/status-go/geth/log"
"github.com/status-im/status-go/geth/mailservice"
"github.com/status-im/status-go/geth/params"

View File

@ -19,7 +19,7 @@ import (
"github.com/ethereum/go-ethereum/p2p/discover"
"github.com/ethereum/go-ethereum/p2p/nat"
"github.com/ethereum/go-ethereum/whisper/mailserver"
whisper "github.com/ethereum/go-ethereum/whisper/whisperv5"
whisper "github.com/ethereum/go-ethereum/whisper/whisperv6"
"github.com/status-im/status-go/geth/log"
"github.com/status-im/status-go/geth/params"
shhmetrics "github.com/status-im/status-go/metrics/whisper"
@ -185,6 +185,13 @@ func activateShhService(stack *node.Node, config *params.NodeConfig) error {
mailServer.Init(whisperService, whisperConfig.DataDir, whisperConfig.Password, whisperConfig.MinimumPoW)
}
if whisperConfig.LightClient {
emptyBloomFilter := make([]byte, 64)
if err := whisperService.SetBloomFilter(emptyBloomFilter); err != nil {
return nil, err
}
}
return whisperService, nil
}

View File

@ -0,0 +1,52 @@
package node
import (
"testing"
whisper "github.com/ethereum/go-ethereum/whisper/whisperv6"
. "github.com/status-im/status-go/t/utils"
"github.com/stretchr/testify/require"
)
func TestWhisperLightModeEnabledSetsEmptyBloomFilter(t *testing.T) {
config, err := MakeTestNodeConfig(GetNetworkID())
require.NoError(t, err)
config.WhisperConfig.LightClient = true
node, nodeErr := MakeNode(config)
require.NoError(t, nodeErr)
require.NoError(t, node.Start())
defer func() {
err := node.Stop()
require.NoError(t, err)
}()
var whisper *whisper.Whisper
err = node.Service(&whisper)
require.NoError(t, err)
bloomFilter := whisper.BloomFilter()
expectedEmptyBloomFilter := make([]byte, 64)
require.NotNil(t, bloomFilter)
require.Equal(t, expectedEmptyBloomFilter, bloomFilter)
}
func TestWhisperLightModeEnabledSetsNilBloomFilter(t *testing.T) {
config, err := MakeTestNodeConfig(GetNetworkID())
require.NoError(t, err)
config.WhisperConfig.LightClient = false
node, nodeErr := MakeNode(config)
require.NoError(t, nodeErr)
require.NoError(t, node.Start())
defer func() {
err := node.Stop()
require.NoError(t, err)
}()
var whisper *whisper.Whisper
err = node.Service(&whisper)
require.NoError(t, err)
require.Nil(t, whisper.BloomFilter())
}

View File

@ -91,6 +91,9 @@ type WhisperConfig struct {
// (if no account file selected, then this password is used for symmetric encryption).
Password string
// LightClient should be true if the node should start with an empty bloom filter and not forward messages from other nodes
LightClient bool
// EnableMailServer is mode when node is capable of delivering expired messages on demand
EnableMailServer bool

View File

@ -225,7 +225,7 @@ var loadConfigTestCases = []struct {
require.True(t, nodeConfig.BootClusterConfig.Enabled, "boot cluster is expected to be enabled by default")
enodes := nodeConfig.BootClusterConfig.BootNodes
require.True(t, len(enodes) >= 3)
require.Len(t, enodes, 2)
},
},
{
@ -240,7 +240,7 @@ var loadConfigTestCases = []struct {
require.True(t, nodeConfig.BootClusterConfig.Enabled, "boot cluster is expected to be enabled by default")
enodes := nodeConfig.BootClusterConfig.BootNodes
require.True(t, len(enodes) >= 3)
require.Len(t, enodes, 2)
},
},
{
@ -340,6 +340,20 @@ var loadConfigTestCases = []struct {
require.True(t, nodeConfig.BootClusterConfig.Enabled)
},
},
{
`explicit WhisperConfig.LightClient = true`,
`{
"NetworkId": 3,
"DataDir": "$TMPDIR",
"WhisperConfig": {
"LightClient": true
}
}`,
func(t *testing.T, dataDir string, nodeConfig *params.NodeConfig, err error) {
require.NoError(t, err)
require.True(t, nodeConfig.WhisperConfig.LightClient)
},
},
}
// TestLoadNodeConfig tests loading JSON configuration and setting default values.

View File

@ -6,7 +6,7 @@ package whisper
import (
"expvar"
whisper "github.com/ethereum/go-ethereum/whisper/whisperv5"
whisper "github.com/ethereum/go-ethereum/whisper/whisperv6"
)
var (

View File

@ -4,7 +4,7 @@
package whisper
import (
whisper "github.com/ethereum/go-ethereum/whisper/whisperv5"
whisper "github.com/ethereum/go-ethereum/whisper/whisperv6"
"github.com/status-im/status-go/geth/log"
)

View File

@ -6,7 +6,7 @@ package whisper
import (
"strconv"
whisper "github.com/ethereum/go-ethereum/whisper/whisperv5"
whisper "github.com/ethereum/go-ethereum/whisper/whisperv6"
"github.com/prometheus/client_golang/prometheus"
)

File diff suppressed because one or more lines are too long

View File

@ -4,42 +4,14 @@
"genesisHash": "0x41941023680923e0fe4d74a34bdac8141f2540e3ae90623718e47d66d1ca4a2d",
"prod": {
"bootnodes": [
"enode://7ab298cedc4185a894d21d8a4615262ec6bdce66c9b6783878258e0d5b31013d30c9038932432f70e5b2b6a5cd323bf820554fcb22fbc7b45367889522e9c449@51.15.63.93:30303",
"enode://f59e8701f18c79c5cbc7618dc7bb928d44dc2f5405c7d693dad97da2d8585975942ec6fd36d3fe608bfdc7270a34a4dd00f38cfe96b2baa24f7cd0ac28d382a1@51.15.79.88:30303",
"enode://e2a3587b7b41acfc49eddea9229281905d252efba0baf565cf6276df17faf04801b7879eead757da8b5be13b05f25e775ab6d857ff264bc53a89c027a657dd10@51.15.45.114:30303",
"enode://fe991752c4ceab8b90608fbf16d89a5f7d6d1825647d4981569ebcece1b243b2000420a5db721e214231c7a6da3543fa821185c706cbd9b9be651494ec97f56a@51.15.67.119:30303",
"enode://482484b9198530ee2e00db89791823244ca41dcd372242e2e1297dd06f6d8dd357603960c5ad9cc8dc15fcdf0e4edd06b7ad7db590e67a0b54f798c26581ebd7@51.15.75.138:30303",
"enode://9e99e183b5c71d51deb16e6b42ac9c26c75cfc95fff9dfae828b871b348354cbecf196dff4dd43567b26c8241b2b979cb4ea9f8dae2d9aacf86649dafe19a39a@51.15.79.176:30303",
"enode://12d52c3796700fb5acff2c7d96df7bbb6d7109b67f3442ee3d99ac1c197016cddb4c3568bbeba05d39145c59c990cd64f76bc9b00d4b13f10095c49507dd4cf9@51.15.63.110:30303",
"enode://0f7c65277f916ff4379fe520b875082a56e587eb3ce1c1567d9ff94206bdb05ba167c52272f20f634cd1ebdec5d9dfeb393018bfde1595d8e64a717c8b46692f@51.15.54.150:30303",
"enode://e006f0b2dc98e757468b67173295519e9b6d5ff4842772acb18fd055c620727ab23766c95b8ee1008dea9e8ef61e83b1515ddb3fb56dbfb9dbf1f463552a7c9f@212.47.237.127:30303",
"enode://d40871fc3e11b2649700978e06acd68a24af54e603d4333faecb70926ca7df93baa0b7bf4e927fcad9a7c1c07f9b325b22f6d1730e728314d0e4e6523e5cebc2@51.15.132.235:30303",
"enode://ea37c9724762be7f668e15d3dc955562529ab4f01bd7951f0b3c1960b75ecba45e8c3bb3c8ebe6a7504d9a40dd99a562b13629cc8e5e12153451765f9a12a61d@163.172.189.205:30303",
"enode://88c2b24429a6f7683fbfd06874ae3f1e7c8b4a5ffb846e77c705ba02e2543789d66fc032b6606a8d8888eb6239a2abe5897ce83f78dcdcfcb027d6ea69aa6fe9@163.172.157.61:30303",
"enode://ce6854c2c77a8800fcc12600206c344b8053bb90ee3ba280e6c4f18f3141cdc5ee80bcc3bdb24cbc0e96dffd4b38d7b57546ed528c00af6cd604ab65c4d528f6@163.172.153.124:30303",
"enode://00ae60771d9815daba35766d463a82a7b360b3a80e35ab2e0daa25bdc6ca6213ff4c8348025e7e1a908a8f58411a364fe02a0fb3c2aa32008304f063d8aaf1a2@163.172.132.85:30303",
"enode://86ebc843aa51669e08e27400e435f957918e39dc540b021a2f3291ab776c88bbda3d97631639219b6e77e375ab7944222c47713bdeb3251b25779ce743a39d70@212.47.254.155:30303",
"enode://a1ef9ba5550d5fac27f7cbd4e8d20a643ad75596f307c91cd6e7f85b548b8a6bf215cca436d6ee436d6135f9fe51398f8dd4c0bd6c6a0c332ccb41880f33ec12@51.15.218.125:30303"
"enode://fa63a6cc730468c5456eab365b2a7a68a166845423c8c9acc363e5f8c4699ff6d954e7ec58f13ae49568600cff9899561b54f6fc2b9923136cd7104911f31cce@163.172.168.202:30303",
"enode://90cbf961c87eb837adc1300a0a6722a57134d843f0028a976d35dff387f101a2754842b6b694e50a01093808f304440d4d968bcbc599259e895ff26e5a1a17cf@51.15.194.39:30303"
]
},
"dev": {
"bootnodes": [
"enode://7ab298cedc4185a894d21d8a4615262ec6bdce66c9b6783878258e0d5b31013d30c9038932432f70e5b2b6a5cd323bf820554fcb22fbc7b45367889522e9c449@51.15.63.93:30303",
"enode://f59e8701f18c79c5cbc7618dc7bb928d44dc2f5405c7d693dad97da2d8585975942ec6fd36d3fe608bfdc7270a34a4dd00f38cfe96b2baa24f7cd0ac28d382a1@51.15.79.88:30303",
"enode://e2a3587b7b41acfc49eddea9229281905d252efba0baf565cf6276df17faf04801b7879eead757da8b5be13b05f25e775ab6d857ff264bc53a89c027a657dd10@51.15.45.114:30303",
"enode://fe991752c4ceab8b90608fbf16d89a5f7d6d1825647d4981569ebcece1b243b2000420a5db721e214231c7a6da3543fa821185c706cbd9b9be651494ec97f56a@51.15.67.119:30303",
"enode://482484b9198530ee2e00db89791823244ca41dcd372242e2e1297dd06f6d8dd357603960c5ad9cc8dc15fcdf0e4edd06b7ad7db590e67a0b54f798c26581ebd7@51.15.75.138:30303",
"enode://9e99e183b5c71d51deb16e6b42ac9c26c75cfc95fff9dfae828b871b348354cbecf196dff4dd43567b26c8241b2b979cb4ea9f8dae2d9aacf86649dafe19a39a@51.15.79.176:30303",
"enode://12d52c3796700fb5acff2c7d96df7bbb6d7109b67f3442ee3d99ac1c197016cddb4c3568bbeba05d39145c59c990cd64f76bc9b00d4b13f10095c49507dd4cf9@51.15.63.110:30303",
"enode://0f7c65277f916ff4379fe520b875082a56e587eb3ce1c1567d9ff94206bdb05ba167c52272f20f634cd1ebdec5d9dfeb393018bfde1595d8e64a717c8b46692f@51.15.54.150:30303",
"enode://e006f0b2dc98e757468b67173295519e9b6d5ff4842772acb18fd055c620727ab23766c95b8ee1008dea9e8ef61e83b1515ddb3fb56dbfb9dbf1f463552a7c9f@212.47.237.127:30303",
"enode://d40871fc3e11b2649700978e06acd68a24af54e603d4333faecb70926ca7df93baa0b7bf4e927fcad9a7c1c07f9b325b22f6d1730e728314d0e4e6523e5cebc2@51.15.132.235:30303",
"enode://ea37c9724762be7f668e15d3dc955562529ab4f01bd7951f0b3c1960b75ecba45e8c3bb3c8ebe6a7504d9a40dd99a562b13629cc8e5e12153451765f9a12a61d@163.172.189.205:30303",
"enode://88c2b24429a6f7683fbfd06874ae3f1e7c8b4a5ffb846e77c705ba02e2543789d66fc032b6606a8d8888eb6239a2abe5897ce83f78dcdcfcb027d6ea69aa6fe9@163.172.157.61:30303",
"enode://ce6854c2c77a8800fcc12600206c344b8053bb90ee3ba280e6c4f18f3141cdc5ee80bcc3bdb24cbc0e96dffd4b38d7b57546ed528c00af6cd604ab65c4d528f6@163.172.153.124:30303",
"enode://00ae60771d9815daba35766d463a82a7b360b3a80e35ab2e0daa25bdc6ca6213ff4c8348025e7e1a908a8f58411a364fe02a0fb3c2aa32008304f063d8aaf1a2@163.172.132.85:30303",
"enode://86ebc843aa51669e08e27400e435f957918e39dc540b021a2f3291ab776c88bbda3d97631639219b6e77e375ab7944222c47713bdeb3251b25779ce743a39d70@212.47.254.155:30303",
"enode://a1ef9ba5550d5fac27f7cbd4e8d20a643ad75596f307c91cd6e7f85b548b8a6bf215cca436d6ee436d6135f9fe51398f8dd4c0bd6c6a0c332ccb41880f33ec12@51.15.218.125:30303"
"enode://fa63a6cc730468c5456eab365b2a7a68a166845423c8c9acc363e5f8c4699ff6d954e7ec58f13ae49568600cff9899561b54f6fc2b9923136cd7104911f31cce@163.172.168.202:30303",
"enode://90cbf961c87eb837adc1300a0a6722a57134d843f0028a976d35dff387f101a2754842b6b694e50a01093808f304440d4d968bcbc599259e895ff26e5a1a17cf@51.15.194.39:30303"
]
}
},

View File

@ -7,7 +7,6 @@ import (
"github.com/status-im/status-go/geth/api"
"github.com/status-im/status-go/geth/log"
"github.com/status-im/status-go/t/e2e"
. "github.com/status-im/status-go/t/utils"
"github.com/ethereum/go-ethereum/p2p"
@ -32,7 +31,7 @@ type PeersTestSuite struct {
func (s *PeersTestSuite) SetupTest() {
s.backend = api.NewStatusBackend()
config, err := e2e.MakeTestNodeConfig(GetNetworkID())
config, err := MakeTestNodeConfig(GetNetworkID())
s.Require().NoError(err)
// we need to enable atleast 1 protocol, otherwise peers won't connect
config.LightEthConfig.Enabled = false

View File

@ -13,7 +13,6 @@ import (
"github.com/status-im/status-go/geth/api"
"github.com/status-im/status-go/geth/log"
"github.com/status-im/status-go/t/e2e"
. "github.com/status-im/status-go/t/utils"
)
@ -32,7 +31,7 @@ type SyncTestSuite struct {
func (s *SyncTestSuite) SetupTest() {
s.backend = api.NewStatusBackend()
config, err := e2e.MakeTestNodeConfig(GetNetworkID())
config, err := MakeTestNodeConfig(GetNetworkID())
s.Require().NoError(err)
s.tempDir, err = ioutil.TempDir("/tmp", "status-sync-chain")
s.Require().NoError(err)

View File

@ -14,7 +14,6 @@ import (
"github.com/status-im/status-go/geth/node"
"github.com/status-im/status-go/geth/params"
"github.com/status-im/status-go/geth/signal"
e2e "github.com/status-im/status-go/t/e2e"
. "github.com/status-im/status-go/t/utils"
"github.com/stretchr/testify/suite"
)
@ -65,10 +64,10 @@ func (s *APITestSuite) TestRaceConditions() {
progress := make(chan struct{}, cnt)
rnd := rand.New(rand.NewSource(time.Now().UnixNano()))
nodeConfig1, err := e2e.MakeTestNodeConfig(GetNetworkID())
nodeConfig1, err := MakeTestNodeConfig(GetNetworkID())
s.NoError(err)
nodeConfig2, err := e2e.MakeTestNodeConfig(GetNetworkID())
nodeConfig2, err := MakeTestNodeConfig(GetNetworkID())
s.NoError(err)
nodeConfigs := []*params.NodeConfig{nodeConfig1, nodeConfig2}
@ -138,7 +137,7 @@ func (s *APITestSuite) TestCellsRemovedAfterSwitchAccount() {
}
)
config, err := e2e.MakeTestNodeConfig(GetNetworkID())
config, err := MakeTestNodeConfig(GetNetworkID())
require.NoError(err)
err = s.api.StartNode(config)
require.NoError(err)
@ -175,7 +174,7 @@ func (s *APITestSuite) TestLogoutRemovesCells() {
require = s.Require()
)
config, err := e2e.MakeTestNodeConfig(GetNetworkID())
config, err := MakeTestNodeConfig(GetNetworkID())
require.NoError(err)
err = s.api.StartNode(config)
require.NoError(err)
@ -205,7 +204,7 @@ func (s *APITestSuite) TestEventsNodeStartStop() {
envelopes <- envelope
})
nodeConfig, err := e2e.MakeTestNodeConfig(GetNetworkID())
nodeConfig, err := MakeTestNodeConfig(GetNetworkID())
s.NoError(err)
s.NoError(s.api.StartNode(nodeConfig))
s.NoError(s.api.StopNode())
@ -243,7 +242,7 @@ func (s *APITestSuite) TestNodeStartCrash() {
})
defer signal.ResetDefaultNodeNotificationHandler()
nodeConfig, err := e2e.MakeTestNodeConfig(GetNetworkID())
nodeConfig, err := MakeTestNodeConfig(GetNetworkID())
s.NoError(err)
// start node outside the manager (on the same port), so that manager node.Start() method fails

View File

@ -36,10 +36,10 @@ func (s *APIBackendTestSuite) TestRaceConditions() {
progress := make(chan struct{}, cnt)
rnd := rand.New(rand.NewSource(time.Now().UnixNano()))
nodeConfig1, err := e2e.MakeTestNodeConfig(GetNetworkID())
nodeConfig1, err := MakeTestNodeConfig(GetNetworkID())
require.NoError(err)
nodeConfig2, err := e2e.MakeTestNodeConfig(GetNetworkID())
nodeConfig2, err := MakeTestNodeConfig(GetNetworkID())
require.NoError(err)
nodeConfigs := []*params.NodeConfig{nodeConfig1, nodeConfig2}
@ -192,7 +192,7 @@ func (s *APIBackendTestSuite) TestRaceConditions() {
// so this test should only check StatusBackend logic with a mocked version of the underlying NodeManager.
func (s *APIBackendTestSuite) TestNetworkSwitching() {
// get Ropsten config
nodeConfig, err := e2e.MakeTestNodeConfig(GetNetworkID())
nodeConfig, err := MakeTestNodeConfig(GetNetworkID())
s.NoError(err)
s.False(s.Backend.IsNodeRunning())
@ -207,7 +207,7 @@ func (s *APIBackendTestSuite) TestNetworkSwitching() {
s.NoError(s.Backend.StopNode())
// start new node with completely different config
nodeConfig, err = e2e.MakeTestNodeConfig(GetNetworkID())
nodeConfig, err = MakeTestNodeConfig(GetNetworkID())
s.NoError(err)
s.False(s.Backend.IsNodeRunning())
@ -254,7 +254,7 @@ func (s *APIBackendTestSuite) TestRestartNode() {
require.NotNil(s.Backend)
// get config
nodeConfig, err := e2e.MakeTestNodeConfig(GetNetworkID())
nodeConfig, err := MakeTestNodeConfig(GetNetworkID())
s.NoError(err)
s.False(s.Backend.IsNodeRunning())

View File

@ -9,7 +9,7 @@ import (
"github.com/ethereum/go-ethereum/les"
gethnode "github.com/ethereum/go-ethereum/node"
"github.com/ethereum/go-ethereum/rpc"
whisper "github.com/ethereum/go-ethereum/whisper/whisperv5"
whisper "github.com/ethereum/go-ethereum/whisper/whisperv6"
"github.com/status-im/status-go/geth/node"
"github.com/status-im/status-go/geth/params"
@ -180,7 +180,7 @@ func (s *ManagerTestSuite) TestReferencesWithStartedNode() {
}
func (s *ManagerTestSuite) TestNodeStartStop() {
nodeConfig, err := e2e.MakeTestNodeConfig(GetNetworkID())
nodeConfig, err := MakeTestNodeConfig(GetNetworkID())
s.NoError(err)
// try stopping non-started node
@ -213,7 +213,7 @@ func (s *ManagerTestSuite) TestNodeStartStop() {
func (s *ManagerTestSuite) TestNetworkSwitching() {
// get Ropsten config
nodeConfig, err := e2e.MakeTestNodeConfig(GetNetworkID())
nodeConfig, err := MakeTestNodeConfig(GetNetworkID())
s.NoError(err)
s.False(s.NodeManager.IsNodeRunning())
s.NoError(s.NodeManager.StartNode(nodeConfig))
@ -230,7 +230,7 @@ func (s *ManagerTestSuite) TestNetworkSwitching() {
s.False(s.NodeManager.IsNodeRunning())
// start new node with completely different config
nodeConfig, err = e2e.MakeTestNodeConfig(params.RinkebyNetworkID)
nodeConfig, err = MakeTestNodeConfig(params.RinkebyNetworkID)
s.NoError(err)
s.NoError(s.NodeManager.StartNode(nodeConfig))
s.True(s.NodeManager.IsNodeRunning())
@ -249,7 +249,7 @@ func (s *ManagerTestSuite) TestStartNodeWithUpstreamEnabled() {
s.T().Skip()
}
nodeConfig, err := e2e.MakeTestNodeConfig(GetNetworkID())
nodeConfig, err := MakeTestNodeConfig(GetNetworkID())
s.NoError(err)
networkURL, err := GetRemoteURL()
@ -273,10 +273,10 @@ func (s *ManagerTestSuite) TestStartNodeWithUpstreamEnabled() {
// progress := make(chan struct{}, cnt)
// rnd := rand.New(rand.NewSource(time.Now().UnixNano()))
//
// nodeConfig1, e := e2e.MakeTestNodeConfig(GetNetworkID())
// nodeConfig1, e := MakeTestNodeConfig(GetNetworkID())
// s.NoError(e)
//
// nodeConfig2, e := e2e.MakeTestNodeConfig(GetNetworkID())
// nodeConfig2, e := MakeTestNodeConfig(GetNetworkID())
// s.NoError(e)
//
// nodeConfigs := []*params.NodeConfig{nodeConfig1, nodeConfig2}

View File

@ -24,7 +24,7 @@ func (s *RPCClientTestSuite) SetupTest() {
}
func (s *RPCClientTestSuite) TestNewClient() {
config, err := e2e.MakeTestNodeConfig(GetNetworkID())
config, err := MakeTestNodeConfig(GetNetworkID())
s.NoError(err)
// upstream disabled

View File

@ -36,7 +36,7 @@ func (s *RPCTestSuite) TestCallRPC() {
}
for _, upstreamEnabled := range []bool{false, true} {
nodeConfig, err := e2e.MakeTestNodeConfig(GetNetworkID())
nodeConfig, err := MakeTestNodeConfig(GetNetworkID())
s.NoError(err)
nodeConfig.IPCEnabled = false
@ -64,7 +64,7 @@ func (s *RPCTestSuite) TestCallRPC() {
{
`{"jsonrpc":"2.0","method":"shh_version","params":[],"id":67}`,
func(resultJSON string) {
expected := `{"jsonrpc":"2.0","id":67,"result":"5.0"}`
expected := `{"jsonrpc":"2.0","id":67,"result":"6.0"}`
s.Equal(expected, resultJSON)
},
},
@ -126,7 +126,7 @@ func (s *RPCTestSuite) TestCallRPC() {
// TestCallRawResult checks if returned response is a valid JSON-RPC response.
func (s *RPCTestSuite) TestCallRawResult() {
nodeConfig, err := e2e.MakeTestNodeConfig(GetNetworkID())
nodeConfig, err := MakeTestNodeConfig(GetNetworkID())
s.NoError(err)
s.NoError(s.NodeManager.StartNode(nodeConfig))
@ -135,7 +135,7 @@ func (s *RPCTestSuite) TestCallRawResult() {
s.NotNil(client)
jsonResult := client.CallRaw(`{"jsonrpc":"2.0","method":"shh_version","params":[],"id":67}`)
s.Equal(`{"jsonrpc":"2.0","id":67,"result":"5.0"}`, jsonResult)
s.Equal(`{"jsonrpc":"2.0","id":67,"result":"6.0"}`, jsonResult)
s.NoError(s.NodeManager.StopNode())
}
@ -144,7 +144,7 @@ func (s *RPCTestSuite) TestCallRawResult() {
// for a not yet mained transaction is "error":{"code":-32000,"message":"unknown transaction"}.
// Issue: https://github.com/status-im/status-go/issues/547
func (s *RPCTestSuite) TestCallRawResultGetTransactionReceipt() {
nodeConfig, err := e2e.MakeTestNodeConfig(GetNetworkID())
nodeConfig, err := MakeTestNodeConfig(GetNetworkID())
s.NoError(err)
s.NoError(s.NodeManager.StartNode(nodeConfig))

View File

@ -2,7 +2,7 @@ package e2e
import (
"github.com/ethereum/go-ethereum/les"
whisper "github.com/ethereum/go-ethereum/whisper/whisperv5"
whisper "github.com/ethereum/go-ethereum/whisper/whisperv6"
"github.com/status-im/status-go/geth/api"
"github.com/status-im/status-go/geth/common"
"github.com/status-im/status-go/geth/log"

View File

@ -2,15 +2,10 @@ package e2e
import (
"context"
"path/filepath"
"runtime"
"strconv"
"testing"
gethcommon "github.com/ethereum/go-ethereum/common"
"github.com/status-im/status-go/geth/common"
"github.com/status-im/status-go/geth/params"
. "github.com/status-im/status-go/t/utils" //nolint: golint
)
// TestNodeOption is a callback passed to StartTestNode which alters its config.
@ -31,37 +26,6 @@ func WithDataDir(path string) TestNodeOption {
}
}
// MakeTestNodeConfig defines a function to return a giving params.NodeConfig
// where specific network addresses are assigned based on provieded network id.
func MakeTestNodeConfig(networkID int) (*params.NodeConfig, error) {
testDir := filepath.Join(TestDataDir, TestNetworkNames[networkID])
if runtime.GOOS == "windows" {
testDir = filepath.ToSlash(testDir)
}
// run tests with "INFO" log level only
// when `go test` invoked with `-v` flag
errorLevel := "ERROR"
if testing.Verbose() {
errorLevel = "INFO"
}
configJSON := `{
"NetworkId": ` + strconv.Itoa(networkID) + `,
"DataDir": "` + testDir + `",
"HTTPPort": ` + strconv.Itoa(TestConfig.Node.HTTPPort) + `,
"WSPort": ` + strconv.Itoa(TestConfig.Node.WSPort) + `,
"LogLevel": "` + errorLevel + `"
}`
nodeConfig, err := params.LoadNodeConfig(configJSON)
if err != nil {
return nil, err
}
return nodeConfig, nil
}
// FirstBlockHash validates Attach operation for the NodeManager.
func FirstBlockHash(nodeManager common.NodeManager) (string, error) {
// obtain RPC client for running node

View File

@ -6,7 +6,7 @@ import (
"time"
"github.com/ethereum/go-ethereum/crypto"
whisper "github.com/ethereum/go-ethereum/whisper/whisperv5"
whisper "github.com/ethereum/go-ethereum/whisper/whisperv6"
"github.com/status-im/status-go/geth/jail"
"github.com/status-im/status-go/static"
e2e "github.com/status-im/status-go/t/e2e"
@ -85,7 +85,7 @@ func (s *WhisperJailTestSuite) TestJailWhisper() {
{
"test 0: ensure correct version of Whisper is used",
`
var expectedVersion = '5.0';
var expectedVersion = '6.0';
if (web3.version.whisper != expectedVersion) {
throw 'unexpected shh version, expected: ' + expectedVersion + ', got: ' + web3.version.whisper;
}
@ -118,8 +118,8 @@ func (s *WhisperJailTestSuite) TestJailWhisper() {
// post message
var message = {
ttl: 10,
powTarget: 1.0,
powTime: 20,
powTarget: 0.001,
powTime: 2,
topic: topic,
sig: shh.getPublicKey(identity1),
pubKey: shh.getPublicKey(identity2),
@ -196,8 +196,8 @@ func (s *WhisperJailTestSuite) TestJailWhisper() {
// post message
var message = {
ttl: 10,
powTarget: 1.0,
powTime: 20,
powTarget: 0.001,
powTime: 2,
topic: topic,
symKeyID: keyid,
payload: web3.toHex(payload),
@ -267,8 +267,8 @@ func (s *WhisperJailTestSuite) TestJailWhisper() {
// post message
var message = {
ttl: 10,
powTarget: 1.0,
powTime: 20,
powTarget: 0.001,
powTime: 2,
sig: shh.getPublicKey(identity2),
pubKey: shh.getPublicKey(identity1),
topic: topic,
@ -341,7 +341,7 @@ func (s *WhisperJailTestSuite) TestJailWhisper() {
r.True(ok)
break poll_loop
case <-timedOut:
s.FailNow("polling for messages timed out")
s.FailNow("polling for messages timed out. Test case: " + tc.name)
case <-time.After(time.Second):
}

View File

@ -12,10 +12,9 @@ import (
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/p2p/discover"
"github.com/ethereum/go-ethereum/whisper/whisperv5"
whisper "github.com/ethereum/go-ethereum/whisper/whisperv6"
"github.com/status-im/status-go/geth/api"
"github.com/status-im/status-go/geth/rpc"
e2e "github.com/status-im/status-go/t/e2e"
. "github.com/status-im/status-go/t/utils"
"github.com/stretchr/testify/suite"
)
@ -68,7 +67,7 @@ func (s *WhisperMailboxSuite) TestRequestMessageFromMailboxAsync() {
s.Require().NotNil(rpcClient)
//create topic
topic := whisperv5.BytesToTopic([]byte("topic name"))
topic := whisper.BytesToTopic([]byte("topic name"))
//Add key pair to whisper
keyID, err := senderWhisperService.NewKeyPair()
@ -177,7 +176,7 @@ func (s *WhisperMailboxSuite) TestRequestMessagesInGroupChat() {
groupChatKey, err := aliceWhisperService.GetSymKey(groupChatKeyID)
s.Require().NoError(err)
//generate group chat topic
groupChatTopic := whisperv5.BytesToTopic([]byte("groupChatTopic"))
groupChatTopic := whisper.BytesToTopic([]byte("groupChatTopic"))
groupChatPayload := newGroupChatParams(groupChatKey, groupChatTopic)
payloadStr, err := groupChatPayload.Encode()
s.Require().NoError(err)
@ -188,14 +187,14 @@ func (s *WhisperMailboxSuite) TestRequestMessagesInGroupChat() {
bobKey, err := bobWhisperService.GetPrivateKey(bobKeyID)
s.Require().NoError(err)
bobPubkey := hexutil.Bytes(crypto.FromECDSAPub(&bobKey.PublicKey))
bobAliceKeySendTopic := whisperv5.BytesToTopic([]byte("bobAliceKeySendTopic "))
bobAliceKeySendTopic := whisper.BytesToTopic([]byte("bobAliceKeySendTopic "))
charlieKeyID, err := charlieWhisperService.NewKeyPair()
s.Require().NoError(err)
charlieKey, err := charlieWhisperService.GetPrivateKey(charlieKeyID)
s.Require().NoError(err)
charliePubkey := hexutil.Bytes(crypto.FromECDSAPub(&charlieKey.PublicKey))
charlieAliceKeySendTopic := whisperv5.BytesToTopic([]byte("charlieAliceKeySendTopic "))
charlieAliceKeySendTopic := whisper.BytesToTopic([]byte("charlieAliceKeySendTopic "))
//bob and charlie create message filter
bobMessageFilterID := s.createPrivateChatMessageFilter(bobRPCClient, bobKeyID, bobAliceKeySendTopic.String())
@ -277,7 +276,7 @@ func (s *WhisperMailboxSuite) TestRequestMessagesInGroupChat() {
s.Require().Equal(helloWorldMessage, messages[0]["payload"].(string))
}
func newGroupChatParams(symkey []byte, topic whisperv5.TopicType) groupChatParams {
func newGroupChatParams(symkey []byte, topic whisper.TopicType) groupChatParams {
groupChatKeyStr := hexutil.Bytes(symkey).String()
return groupChatParams{
Key: groupChatKeyStr,
@ -310,7 +309,7 @@ func (d *groupChatParams) Encode() (string, error) {
func (s *WhisperMailboxSuite) startBackend(name string) (*api.StatusBackend, func()) {
datadir := filepath.Join(RootDir, ".ethereumtest/mailbox", name)
backend := api.NewStatusBackend()
nodeConfig, err := e2e.MakeTestNodeConfig(GetNetworkID())
nodeConfig, err := MakeTestNodeConfig(GetNetworkID())
nodeConfig.DataDir = datadir
s.Require().NoError(err)
s.Require().False(backend.IsNodeRunning())
@ -336,7 +335,7 @@ func (s *WhisperMailboxSuite) startBackend(name string) (*api.StatusBackend, fun
//Start mailbox node
func (s *WhisperMailboxSuite) startMailboxBackend() (*api.StatusBackend, func()) {
mailboxBackend := api.NewStatusBackend()
mailboxConfig, err := e2e.MakeTestNodeConfig(GetNetworkID())
mailboxConfig, err := MakeTestNodeConfig(GetNetworkID())
s.Require().NoError(err)
datadir := filepath.Join(RootDir, ".ethereumtest/mailbox/mailserver")

View File

@ -5,7 +5,7 @@ import (
"testing"
"github.com/ethereum/go-ethereum/crypto"
whisper "github.com/ethereum/go-ethereum/whisper/whisperv5"
whisper "github.com/ethereum/go-ethereum/whisper/whisperv6"
"github.com/status-im/status-go/geth/account"
"github.com/status-im/status-go/geth/node"
e2e "github.com/status-im/status-go/t/e2e"

View File

@ -8,7 +8,10 @@ import (
"io"
"os"
"path/filepath"
"runtime"
"strconv"
"strings"
"testing"
"time"
"github.com/status-im/status-go/geth/common"
@ -229,5 +232,35 @@ func WaitClosed(c <-chan struct{}, d time.Duration) error {
case <-timer.C:
return ErrTimeout
}
}
// MakeTestNodeConfig defines a function to return a giving params.NodeConfig
// where specific network addresses are assigned based on provided network id.
func MakeTestNodeConfig(networkID int) (*params.NodeConfig, error) {
testDir := filepath.Join(TestDataDir, TestNetworkNames[networkID])
if runtime.GOOS == "windows" {
testDir = filepath.ToSlash(testDir)
}
// run tests with "INFO" log level only
// when `go test` invoked with `-v` flag
errorLevel := "ERROR"
if testing.Verbose() {
errorLevel = "INFO"
}
configJSON := `{
"NetworkId": ` + strconv.Itoa(networkID) + `,
"DataDir": "` + testDir + `",
"HTTPPort": ` + strconv.Itoa(TestConfig.Node.HTTPPort) + `,
"WSPort": ` + strconv.Itoa(TestConfig.Node.WSPort) + `,
"LogLevel": "` + errorLevel + `"
}`
nodeConfig, err := params.LoadNodeConfig(configJSON)
if err != nil {
return nil, err
}
return nodeConfig, nil
}

View File

@ -43,7 +43,7 @@ import (
"github.com/ethereum/go-ethereum/p2p/discover"
"github.com/ethereum/go-ethereum/p2p/nat"
"github.com/ethereum/go-ethereum/whisper/mailserver"
whisper "github.com/ethereum/go-ethereum/whisper/whisperv5"
whisper "github.com/ethereum/go-ethereum/whisper/whisperv6"
"golang.org/x/crypto/pbkdf2"
)

View File

@ -26,7 +26,7 @@ import (
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/rlp"
whisper "github.com/ethereum/go-ethereum/whisper/whisperv5"
whisper "github.com/ethereum/go-ethereum/whisper/whisperv6"
"github.com/syndtr/goleveldb/leveldb"
"github.com/syndtr/goleveldb/leveldb/util"
)

View File

@ -19,6 +19,7 @@ package whisperv6
import (
"fmt"
"math"
"sync"
"time"
"github.com/ethereum/go-ethereum/common"
@ -36,6 +37,7 @@ type Peer struct {
trusted bool
powRequirement float64
bloomMu sync.Mutex
bloomFilter []byte
fullNode bool
@ -225,10 +227,14 @@ func (peer *Peer) notifyAboutBloomFilterChange(bloom []byte) error {
}
func (peer *Peer) bloomMatch(env *Envelope) bool {
peer.bloomMu.Lock()
defer peer.bloomMu.Unlock()
return peer.fullNode || bloomFilterMatch(peer.bloomFilter, env.Bloom())
}
func (peer *Peer) setBloomFilter(bloom []byte) {
peer.bloomMu.Lock()
defer peer.bloomMu.Unlock()
peer.bloomFilter = bloom
peer.fullNode = isFullNode(bloom)
if peer.fullNode && peer.bloomFilter == nil {