Skip to content

Commit 318a0ef

Browse files
committed
chore!: remove waku service
closes: #6663
1 parent e16dc91 commit 318a0ef

File tree

12 files changed

+148
-187
lines changed

12 files changed

+148
-187
lines changed

api/geth_backend.go

Lines changed: 17 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -59,21 +59,17 @@ import (
5959
"github.com/status-im/status-go/rpc"
6060
"github.com/status-im/status-go/server/pairing/statecontrol"
6161
"github.com/status-im/status-go/services/ens"
62-
"github.com/status-im/status-go/services/ext"
6362
"github.com/status-im/status-go/services/personal"
6463
"github.com/status-im/status-go/services/typeddata"
6564
"github.com/status-im/status-go/services/wallet"
6665
"github.com/status-im/status-go/services/wallet/wallettypes"
6766
"github.com/status-im/status-go/signal"
6867
"github.com/status-im/status-go/sqlite"
6968
"github.com/status-im/status-go/transactions"
70-
wakutypes "github.com/status-im/status-go/waku/types"
7169
"github.com/status-im/status-go/walletdatabase"
7270
)
7371

7472
var (
75-
// ErrWakuIdentityInjectionFailure injecting whisper identities has failed.
76-
ErrWakuIdentityInjectionFailure = errors.New("failed to inject identity into waku")
7773
// ErrUnsupportedRPCMethod is for methods not supported by the RPC interface
7874
ErrUnsupportedRPCMethod = errors.New("method is unsupported by RPC interface")
7975
// ErrRPCClientUnavailable is returned if an RPC client can't be retrieved.
@@ -109,7 +105,6 @@ type GethStatusBackend struct {
109105
transactor *transactions.Transactor
110106
connectionState connection.State
111107
appState AppState
112-
selectedAccountKeyID string
113108
allowAllRPC bool // used only for tests, disables api method restrictions
114109
LocalPairingStateManager *statecontrol.ProcessStateManager
115110
centralizedMetrics *centralizedmetrics.MetricService
@@ -185,11 +180,6 @@ func (b *GethStatusBackend) MessageSigner() communities.MessageSigner {
185180
return b.signer
186181
}
187182

188-
// SelectedAccountKeyID returns a Whisper key ID of the selected chat key pair.
189-
func (b *GethStatusBackend) SelectedAccountKeyID() string {
190-
return b.selectedAccountKeyID
191-
}
192-
193183
// IsNodeRunning confirm that node is running
194184
func (b *GethStatusBackend) IsNodeRunning() bool {
195185
return b.statusNode.IsRunning()
@@ -203,6 +193,10 @@ func (b *GethStatusBackend) StartNode(config *params.NodeConfig) error {
203193
signal.SendNodeCrashed(err)
204194
return err
205195
}
196+
197+
// Set initial connection state
198+
b.statusNode.ConnectionChanged(b.connectionState)
199+
206200
return nil
207201
}
208202

@@ -830,9 +824,9 @@ func (b *GethStatusBackend) loginAccount(request *requests.Login) error {
830824
return errors.Wrap(err, "failed to get selected chat account")
831825
}
832826

833-
err = b.injectAccountsIntoServices()
827+
err = b.initProtocol()
834828
if err != nil {
835-
return errors.Wrap(err, "failed to inject accounts into services")
829+
return errors.Wrap(err, "failed to init protocol")
836830
}
837831
}
838832

@@ -943,7 +937,7 @@ func (b *GethStatusBackend) startNodeWithAccount(acc multiaccounts.Account, pass
943937
return err
944938
}
945939

946-
err = b.injectAccountsIntoServices()
940+
err = b.initProtocol()
947941
if err != nil {
948942
return err
949943
}
@@ -2251,7 +2245,7 @@ func (b *GethStatusBackend) startNode(config *params.NodeConfig) (err error) {
22512245
// Handle a case when a node is stopped and resumed.
22522246
// If there is no account selected, an error is returned.
22532247
if _, err := b.accountsManager.SelectedChatAccount(); err == nil {
2254-
if err := b.injectAccountsIntoServices(); err != nil {
2248+
if err := b.initProtocol(); err != nil {
22552249
return err
22562250
}
22572251
} else if err != accsmanagement.ErrNoAccountSelected {
@@ -2608,7 +2602,6 @@ func (b *GethStatusBackend) switchToPreLoginLog() error {
26082602

26092603
// cleanupServices stops parts of services that aren't managed by a node and removes injected data from services.
26102604
func (b *GethStatusBackend) cleanupServices() error {
2611-
b.selectedAccountKeyID = ""
26122605
if b.statusNode == nil {
26132606
return nil
26142607
}
@@ -2662,7 +2655,7 @@ func (b *GethStatusBackend) SelectAccount(loginParams LoginParams) error {
26622655
b.account = loginParams.MultiAccount
26632656
}
26642657

2665-
if err := b.injectAccountsIntoServices(); err != nil {
2658+
if err := b.initProtocol(); err != nil {
26662659
return err
26672660
}
26682661

@@ -2690,7 +2683,12 @@ func (b *GethStatusBackend) LocalPairingStarted() error {
26902683
return accountDB.MnemonicWasShown()
26912684
}
26922685

2693-
func (b *GethStatusBackend) injectAccountsIntoWakuService(w wakutypes.WakuKeyManager, st *ext.Service) error {
2686+
func (b *GethStatusBackend) initProtocol() error {
2687+
st := b.statusNode.WakuV2ExtService()
2688+
if st == nil {
2689+
return nil
2690+
}
2691+
26942692
chatAccount, err := b.accountsManager.SelectedChatAccount()
26952693
if err != nil {
26962694
return err
@@ -2703,23 +2701,13 @@ func (b *GethStatusBackend) injectAccountsIntoWakuService(w wakutypes.WakuKeyMan
27032701
return err
27042702
}
27052703

2706-
if err := w.DeleteKeyPairs(); err != nil { // err is not possible; method return value is incorrect
2707-
return err
2708-
}
2709-
b.selectedAccountKeyID, err = w.AddKeyPair(identity)
2710-
if err != nil {
2711-
return ErrWakuIdentityInjectionFailure
2712-
}
2713-
27142704
if st != nil {
27152705
if err := st.InitProtocol(b.statusNode.GethNode().Config().Name, identity, b.appDB, b.walletDB,
27162706
b.statusNode.HTTPServer(), b.multiaccountsDB, acc, b.accountsManager, b.statusNode.RPCClient(),
2717-
b.statusNode.WalletService(), b.statusNode.CommunityTokensService(), b.statusNode.WakuV2Service(),
2718-
logutils.ZapLogger(), b.statusNode.AccountsPublisher()); err != nil {
2707+
b.statusNode.WalletService(), b.statusNode.CommunityTokensService(),
2708+
logutils.ZapLogger(), b.statusNode.AccountsPublisher(), b.statusNode.TimeSource()); err != nil {
27192709
return err
27202710
}
2721-
// Set initial connection state
2722-
st.ConnectionChanged(b.connectionState)
27232711

27242712
messenger := st.Messenger()
27252713
// Init public status api
@@ -2754,19 +2742,6 @@ func (b *GethStatusBackend) KeyUID() string {
27542742
return ""
27552743
}
27562744

2757-
func (b *GethStatusBackend) injectAccountsIntoServices() error {
2758-
if b.statusNode.WakuV2Service() != nil {
2759-
return b.injectAccountsIntoWakuService(b.statusNode.WakuV2Service(), func() *ext.Service {
2760-
if b.statusNode.WakuV2ExtService() == nil {
2761-
return nil
2762-
}
2763-
return b.statusNode.WakuV2ExtService().Service
2764-
}())
2765-
}
2766-
2767-
return nil
2768-
}
2769-
27702745
// ExtractGroupMembershipSignatures extract signatures from tuples of content/signature
27712746
func (b *GethStatusBackend) ExtractGroupMembershipSignatures(signaturePairs [][2]string) ([]string, error) {
27722747
return crypto.ExtractSignatures(signaturePairs)

node/get_status_node.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ import (
4444
"github.com/status-im/status-go/services/wallet"
4545
"github.com/status-im/status-go/timesource"
4646
"github.com/status-im/status-go/transactions"
47-
"github.com/status-im/status-go/wakuv2"
4847
)
4948

5049
// errors
@@ -94,7 +93,6 @@ type StatusNode struct {
9493
localNotificationsSrvc *localnotifications.Service
9594
personalSrvc *personal.Service
9695
timeSourceSrvc *timesource.NTPTimeSource
97-
wakuV2Srvc *wakuv2.Waku
9896
wakuV2ExtSrvc *wakuv2ext.Service
9997
ensSrvc *ens.Service
10098
communityTokensSrvc *communitytokens.Service
@@ -314,7 +312,6 @@ func (n *StatusNode) stop() error {
314312
n.localNotificationsSrvc = nil
315313
n.personalSrvc = nil
316314
n.timeSourceSrvc = nil
317-
n.wakuV2Srvc = nil
318315
n.wakuV2ExtSrvc = nil
319316
n.ensSrvc = nil
320317
n.communityTokensSrvc = nil

node/geth_node.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ import (
1515
// Errors related to node and services creation.
1616
var (
1717
ErrNodeMakeFailureFormat = "error creating p2p node: %s"
18-
ErrWakuServiceRegistrationFailure = errors.New("failed to register the Waku service")
19-
ErrWakuV2ServiceRegistrationFailure = errors.New("failed to register the WakuV2 service")
2018
ErrLightEthRegistrationFailure = errors.New("failed to register the LES service")
2119
ErrLightEthRegistrationFailureUpstreamEnabled = errors.New("failed to register the LES service, upstream is also configured")
2220
ErrPersonalServiceRegistrationFailure = errors.New("failed to register the personal api service")

node/status_node_rpc_client_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ func TestNodeRPCPrivateClientCallPrivateService(t *testing.T) {
189189
require.NoError(t, err)
190190
}()
191191

192-
result, err := statusNode.CallPrivateRPC(`{"jsonrpc": "2.0", "id": 1, "method": "waku_info"}`)
192+
result, err := statusNode.CallPrivateRPC(`{"jsonrpc": "2.0", "id": 1, "method": "wakuext_echo", "params": ["hello"]}`)
193193
require.NoError(t, err)
194194

195195
// the call is successful

node/status_node_services.go

Lines changed: 3 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,23 @@ package node
22

33
import (
44
"context"
5-
"crypto/ecdsa"
65
"database/sql"
76
"encoding/json"
87
"errors"
9-
"fmt"
10-
"os"
118
"reflect"
129
"time"
1310

1411
"go.uber.org/zap"
1512

1613
"github.com/status-im/status-go/pkg/pubsub"
1714
"github.com/status-im/status-go/server"
18-
"github.com/status-im/status-go/signal"
1915
"github.com/status-im/status-go/transactions"
20-
"github.com/status-im/status-go/wakuv2"
2116

22-
"github.com/ethereum/go-ethereum/common/hexutil"
2317
"github.com/ethereum/go-ethereum/event"
2418
gethrpc "github.com/ethereum/go-ethereum/rpc"
2519

2620
"github.com/status-im/status-go/appmetrics"
2721
"github.com/status-im/status-go/common"
28-
"github.com/status-im/status-go/eth-node/crypto"
29-
"github.com/status-im/status-go/logutils"
3022
"github.com/status-im/status-go/multiaccounts/accounts"
3123
"github.com/status-im/status-go/params"
3224
accountssvc "github.com/status-im/status-go/services/accounts"
@@ -51,7 +43,6 @@ import (
5143
"github.com/status-im/status-go/services/wallet"
5244
"github.com/status-im/status-go/services/wallet/thirdparty"
5345
"github.com/status-im/status-go/timesource"
54-
wakuv2common "github.com/status-im/status-go/wakuv2/common"
5546
)
5647

5748
var (
@@ -111,11 +102,6 @@ func (b *StatusNode) initServices(config *params.NodeConfig, mediaServer *server
111102
config.WakuV2Config.TelemetryServerURL = telemetryServerURL
112103
}
113104
}
114-
waku2Service, err := b.wakuV2Service(config)
115-
if err != nil {
116-
return err
117-
}
118-
services = append(services, waku2Service)
119105

120106
wakuext, err := b.wakuV2ExtService(config)
121107
if err != nil {
@@ -166,7 +152,7 @@ func (b *StatusNode) wakuV2ExtService(config *params.NodeConfig) (*wakuv2ext.Ser
166152
return nil, errors.New("geth node not initialized")
167153
}
168154
if b.wakuV2ExtSrvc == nil {
169-
b.wakuV2ExtSrvc = wakuv2ext.New(*config, b.wakuV2Srvc, b.rpcClient)
155+
b.wakuV2ExtSrvc = wakuv2ext.New(*config, b.rpcClient)
170156
}
171157

172158
return b.wakuV2ExtSrvc, nil
@@ -198,81 +184,6 @@ func (b *StatusNode) EnsService() *ens.Service {
198184
func (b *StatusNode) WakuV2ExtService() *wakuv2ext.Service {
199185
return b.wakuV2ExtSrvc
200186
}
201-
func (b *StatusNode) WakuV2Service() *wakuv2.Waku {
202-
return b.wakuV2Srvc
203-
}
204-
205-
func (b *StatusNode) wakuV2Service(nodeConfig *params.NodeConfig) (*wakuv2.Waku, error) {
206-
if b.wakuV2Srvc == nil {
207-
cfg := &wakuv2.Config{
208-
MaxMessageSize: wakuv2common.DefaultMaxMessageSize,
209-
Host: nodeConfig.WakuV2Config.Host,
210-
Port: nodeConfig.WakuV2Config.Port,
211-
LightClient: nodeConfig.WakuV2Config.LightClient,
212-
WakuNodes: nodeConfig.ClusterConfig.WakuNodes,
213-
EnableStore: nodeConfig.WakuV2Config.EnableStore,
214-
StoreCapacity: nodeConfig.WakuV2Config.StoreCapacity,
215-
StoreSeconds: nodeConfig.WakuV2Config.StoreSeconds,
216-
DiscoveryLimit: nodeConfig.WakuV2Config.DiscoveryLimit,
217-
DiscV5BootstrapNodes: nodeConfig.ClusterConfig.DiscV5BootstrapNodes,
218-
Nameserver: nodeConfig.WakuV2Config.Nameserver,
219-
UDPPort: nodeConfig.WakuV2Config.UDPPort,
220-
AutoUpdate: nodeConfig.WakuV2Config.AutoUpdate,
221-
DefaultShardPubsubTopic: wakuv2.DefaultShardPubsubTopic(),
222-
TelemetryServerURL: nodeConfig.WakuV2Config.TelemetryServerURL,
223-
ClusterID: nodeConfig.ClusterConfig.ClusterID,
224-
EnableMissingMessageVerification: nodeConfig.WakuV2Config.EnableMissingMessageVerification,
225-
EnableStoreConfirmationForMessagesSent: nodeConfig.WakuV2Config.EnableStoreConfirmationForMessagesSent,
226-
UseThrottledPublish: true,
227-
}
228-
229-
// Configure peer exchange and discv5 settings based on node type
230-
if cfg.LightClient {
231-
cfg.EnablePeerExchangeServer = false
232-
cfg.EnablePeerExchangeClient = true
233-
cfg.EnableDiscV5 = false
234-
} else {
235-
cfg.EnablePeerExchangeServer = true
236-
cfg.EnablePeerExchangeClient = false
237-
cfg.EnableDiscV5 = true
238-
}
239-
240-
if nodeConfig.WakuV2Config.MaxMessageSize > 0 {
241-
cfg.MaxMessageSize = nodeConfig.WakuV2Config.MaxMessageSize
242-
}
243-
244-
var nodeKey *ecdsa.PrivateKey
245-
var err error
246-
if nodeConfig.NodeKey != "" {
247-
nodeKey, err = crypto.HexToECDSA(nodeConfig.NodeKey)
248-
if err != nil {
249-
return nil, fmt.Errorf("could not convert nodekey into a valid private key: %v", err)
250-
}
251-
} else {
252-
nodeKeyStr := os.Getenv("WAKUV2_NODE_KEY")
253-
if nodeKeyStr != "" {
254-
nodeKeyBytes, err := hexutil.Decode(nodeKeyStr)
255-
if err != nil {
256-
return nil, fmt.Errorf("failed to decode the go-waku private key: %v", err)
257-
}
258-
259-
nodeKey, err = crypto.ToECDSA(nodeKeyBytes)
260-
if err != nil {
261-
return nil, fmt.Errorf("could not convert nodekey into a valid private key: %v", err)
262-
}
263-
}
264-
}
265-
266-
w, err := wakuv2.New(nodeKey, cfg, logutils.ZapLogger(), b.appDB, b.timeSource(), signal.SendHistoricMessagesRequestFailed, signal.SendPeerStats)
267-
268-
if err != nil {
269-
return nil, err
270-
}
271-
b.wakuV2Srvc = w
272-
}
273-
274-
return b.wakuV2Srvc, nil
275-
}
276187

277188
func (b *StatusNode) connectorService() *connector.Service {
278189
if b.connectorSrvc == nil {
@@ -494,7 +405,7 @@ func (b *StatusNode) personalService() *personal.Service {
494405
return b.personalSrvc
495406
}
496407

497-
func (b *StatusNode) timeSource() *timesource.NTPTimeSource {
408+
func (b *StatusNode) TimeSource() *timesource.NTPTimeSource {
498409

499410
if b.timeSourceSrvc == nil {
500411
b.timeSourceSrvc = timesource.Default()
@@ -510,7 +421,7 @@ func (b *StatusNode) timeSource() *timesource.NTPTimeSource {
510421
}
511422

512423
func (b *StatusNode) timeSourceNow() func() time.Time {
513-
return b.timeSource().Now
424+
return b.TimeSource().Now
514425
}
515426

516427
func (b *StatusNode) Cleanup() error {

protocol/messenger.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1752,6 +1752,7 @@ func (m *Messenger) Shutdown() (err error) {
17521752
}
17531753
}
17541754
}
1755+
m.started = false
17551756
return
17561757
}
17571758

protocol/messenger_mailserver.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,9 @@ const (
3939
var ErrNoFiltersForChat = errors.New("no filter registered for given chat")
4040

4141
func (m *Messenger) shouldSync() (bool, error) {
42-
// TODO (pablo) support community store node as well
43-
if m.messaging.GetActiveStorenode().ID == "" || !m.Online() {
42+
if !m.started ||
43+
m.messaging.GetActiveStorenode().ID == "" ||
44+
!m.Online() {
4445
return false, nil
4546
}
4647

0 commit comments

Comments
 (0)