Skip to content

Commit

Permalink
Update project to use Whisper v6. Part of #638
Browse files Browse the repository at this point in the history
  • Loading branch information
Pedro Pombeiro committed Feb 13, 2018
1 parent ffef611 commit f089c11
Show file tree
Hide file tree
Showing 26 changed files with 124 additions and 38 deletions.
3 changes: 2 additions & 1 deletion Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

83 changes: 83 additions & 0 deletions _assets/patches/geth/0016-geth-17-use-whisperv6.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
diff --git a/whisper/mailserver/mailserver.go b/whisper/mailserver/mailserver.go
index 0ec6ec570..6555fd5c0 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/whisperv5"
+ whisper "github.com/ethereum/go-ethereum/whisper/whisperv6"
"github.com/syndtr/goleveldb/leveldb"
"github.com/syndtr/goleveldb/leveldb/util"
)
diff --git a/whisper/notifications/discovery.go b/whisper/notifications/discovery.go
index de8ec85be..9a131ded1 100644
--- a/whisper/notifications/discovery.go
+++ b/whisper/notifications/discovery.go
@@ -9,7 +9,7 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/log"
- whisper "github.com/ethereum/go-ethereum/whisper/whisperv5"
+ whisper "github.com/ethereum/go-ethereum/whisper/whisperv6"
)

const (
diff --git a/whisper/notifications/server.go b/whisper/notifications/server.go
index 7f27f0301..94dd1b683 100644
--- a/whisper/notifications/server.go
+++ b/whisper/notifications/server.go
@@ -9,11 +9,12 @@ import (
"crypto/ecdsa"
"encoding/hex"
"encoding/json"
+
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/p2p"
- whisper "github.com/ethereum/go-ethereum/whisper/whisperv5"
+ whisper "github.com/ethereum/go-ethereum/whisper/whisperv6"
"github.com/status-im/status-go/geth/params"
)

@@ -58,9 +59,9 @@ type NotificationServer struct {
// ClientSession abstracts notification client, which expects notifications whenever
// some envelope can be decoded with session key (key hash is compared for optimization)
type ClientSession struct {
- ClientKey string // public key uniquely identifying a client
- SessionKey []byte // actual symkey used for client - server communication
- SessionKeyHash common.Hash // The Keccak256Hash of the symmetric key, which is shared between server/client
+ ClientKey string // public key uniquely identifying a client
+ SessionKey []byte // actual symkey used for client - server communication
+ SessionKeyHash common.Hash // The Keccak256Hash of the symmetric key, which is shared between server/client
SessionKeyInput []byte // raw symkey used as input for actual SessionKey
}

diff --git a/whisper/notifications/utils.go b/whisper/notifications/utils.go
index cca3fba71..dc2e78d73 100644
--- a/whisper/notifications/utils.go
+++ b/whisper/notifications/utils.go
@@ -7,7 +7,7 @@ import (

crand "crypto/rand"

- whisper "github.com/ethereum/go-ethereum/whisper/whisperv5"
+ whisper "github.com/ethereum/go-ethereum/whisper/whisperv6"
"golang.org/x/crypto/pbkdf2"
)

diff --git a/whisper/shhclient/client.go b/whisper/shhclient/client.go
index 61b4775d9..d9754f350 100644
--- a/whisper/shhclient/client.go
+++ b/whisper/shhclient/client.go
@@ -22,7 +22,7 @@ import (
"github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/rpc"
- whisper "github.com/ethereum/go-ethereum/whisper/whisperv5"
+ whisper "github.com/ethereum/go-ethereum/whisper/whisperv6"
)

// Client defines typed wrappers for the Whisper v5 RPC API.
1 change: 1 addition & 0 deletions _assets/patches/geth/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Instructions for creating a patch from the command line:
- [`0013-whisperv6-notifications-envelopeversion.patch`](./0013-whisperv6-notifications-envelopeversion.patch) — replaces usage of EnvelopeVersion with ProtocolVersion in notifications for Whisper v6
- [`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)
- [`0016-geth-17-use-whisperv6.patch`](./0016-geth-17-use-whisperv6.patch) — changes previous patches to use Whisper v6 instead of Whisper v5

# Updating upstream version

Expand Down
2 changes: 1 addition & 1 deletion geth/account/accounts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion geth/common/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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/robertkrimen/otto"
"github.com/status-im/status-go/geth/params"
"github.com/status-im/status-go/geth/rpc"
Expand Down
6 changes: 3 additions & 3 deletions geth/common/types_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion geth/mailservice/mailservice.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion geth/mailservice/mailservice_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down
2 changes: 1 addition & 1 deletion geth/mailservice/mailservice_api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down
6 changes: 3 additions & 3 deletions geth/mailservice/mailservice_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion geth/node/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion geth/node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"github.com/ethereum/go-ethereum/p2p/nat"
"github.com/ethereum/go-ethereum/whisper/mailserver"
"github.com/ethereum/go-ethereum/whisper/notifications"
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"
Expand Down
2 changes: 1 addition & 1 deletion metrics/whisper/tracer_expvar.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
2 changes: 1 addition & 1 deletion metrics/whisper/tracer_log.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down
2 changes: 1 addition & 1 deletion metrics/whisper/tracer_prometheus.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down
2 changes: 1 addition & 1 deletion t/e2e/node/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
4 changes: 2 additions & 2 deletions t/e2e/rpc/rpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
},
},
Expand Down Expand Up @@ -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())
}
Expand Down
2 changes: 1 addition & 1 deletion t/e2e/suites.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package t

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"
Expand Down
4 changes: 2 additions & 2 deletions t/e2e/whisper/whisper_jail_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,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/common"
"github.com/status-im/status-go/static"
e2e "github.com/status-im/status-go/t/e2e"
Expand Down Expand Up @@ -77,7 +77,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;
}
Expand Down
12 changes: 6 additions & 6 deletions t/e2e/whisper/whisper_mailbox_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ 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"
"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"
Expand Down Expand Up @@ -68,7 +68,7 @@ func (s *WhisperMailboxSuite) TestRequestMessageFromMailboxAsync() {
s.Require().NotNil(rpcClient)

//create topic
topic := whisperv5.BytesToTopic([]byte("topic name"))
topic := whisperv6.BytesToTopic([]byte("topic name"))

//Add key pair to whisper
keyID, err := senderWhisperService.NewKeyPair()
Expand Down Expand Up @@ -177,7 +177,7 @@ func (s *WhisperMailboxSuite) TestRequestMessagesInGroupChat() {
groupChatKey, err := aliceWhisperService.GetSymKey(groupChatKeyID)
s.Require().NoError(err)
//generate group chat topic
groupChatTopic := whisperv5.BytesToTopic([]byte("groupChatTopic"))
groupChatTopic := whisperv6.BytesToTopic([]byte("groupChatTopic"))
groupChatPayload := newGroupChatParams(groupChatKey, groupChatTopic)
payloadStr, err := groupChatPayload.Encode()
s.Require().NoError(err)
Expand All @@ -188,14 +188,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 := whisperv6.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 := whisperv6.BytesToTopic([]byte("charlieAliceKeySendTopic "))

//bob and charlie create message filter
bobMessageFilterID := s.createPrivateChatMessageFilter(bobRPCClient, bobKeyID, bobAliceKeySendTopic.String())
Expand Down Expand Up @@ -277,7 +277,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 whisperv6.TopicType) groupChatParams {
groupChatKeyStr := hexutil.Bytes(symkey).String()
return groupChatParams{
Key: groupChatKeyStr,
Expand Down
2 changes: 1 addition & 1 deletion t/e2e/whisper/whisper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit f089c11

Please sign in to comment.