fix: endless logout (#4563)

This commit is contained in:
frank 2024-01-30 19:45:08 +08:00 committed by GitHub
parent 73a5189398
commit 69948a7024
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
11 changed files with 30 additions and 19 deletions

View File

@ -1 +1 @@
0.172.9
0.172.10

View File

@ -2204,6 +2204,7 @@ func (b *GethStatusBackend) Logout() error {
b.mu.Lock()
defer b.mu.Unlock()
b.log.Debug("logging out")
err := b.cleanupServices()
if err != nil {
return err
@ -2222,6 +2223,11 @@ func (b *GethStatusBackend) Logout() error {
}
b.statusNode = nil
}
if !b.LocalPairingStateManager.IsPairing() {
signal.SendNodeStopped()
}
// re-initialize the node, at some point we should better manage the lifecycle
b.initialize()

4
go.mod
View File

@ -89,7 +89,7 @@ require (
github.com/mutecomm/go-sqlcipher/v4 v4.4.2
github.com/schollz/peerdiscovery v1.7.0
github.com/siphiuel/lc-proxy-wrapper v0.0.0-20230516150924-246507cee8c7
github.com/waku-org/go-waku v0.8.1-0.20240104144340-585648c4eefe
github.com/waku-org/go-waku v0.8.1-0.20240130093642-77ea359ef873
github.com/wk8/go-ordered-map/v2 v2.1.7
github.com/yeqown/go-qrcode/v2 v2.2.1
github.com/yeqown/go-qrcode/writer/standard v1.2.1
@ -261,7 +261,7 @@ require (
github.com/tklauser/numcpus v0.2.2 // indirect
github.com/tyler-smith/go-bip39 v1.1.0 // indirect
github.com/urfave/cli/v2 v2.24.4 // indirect
github.com/waku-org/go-discover v0.0.0-20221209174356-61c833f34d98 // indirect
github.com/waku-org/go-discover v0.0.0-20240129014929-85f2c00b96a3 // indirect
github.com/waku-org/go-libp2p-rendezvous v0.0.0-20230628220917-7b4e5ae4c0e7 // indirect
github.com/waku-org/go-zerokit-rln v0.1.14-0.20240102145250-fa738c0bdf59 // indirect
github.com/waku-org/go-zerokit-rln-apple v0.0.0-20230916172309-ee0ee61dde2b // indirect

8
go.sum
View File

@ -2097,12 +2097,12 @@ github.com/vishvananda/netns v0.0.0-20180720170159-13995c7128cc/go.mod h1:ZjcWmF
github.com/vishvananda/netns v0.0.0-20191106174202-0a2b9b5464df/go.mod h1:JP3t17pCcGlemwknint6hfoeCVQrEMVwxRLRjXpq+BU=
github.com/vishvananda/netns v0.0.0-20200728191858-db3c7e526aae/go.mod h1:DD4vA1DwXk04H54A1oHXtwZmA0grkVMdPxx/VGLCah0=
github.com/vishvananda/netns v0.0.0-20210104183010-2eb08e3e575f/go.mod h1:DD4vA1DwXk04H54A1oHXtwZmA0grkVMdPxx/VGLCah0=
github.com/waku-org/go-discover v0.0.0-20221209174356-61c833f34d98 h1:xwY0kW5XZFimdqfZb9cZwT1S3VJP9j3AE6bdNd9boXM=
github.com/waku-org/go-discover v0.0.0-20221209174356-61c833f34d98/go.mod h1:eBHgM6T4EG0RZzxpxKy+rGz/6Dw2Nd8DWxS0lm9ESDw=
github.com/waku-org/go-discover v0.0.0-20240129014929-85f2c00b96a3 h1:Kk0KYXZE/uNnARF2TbCQyvyZ/w4SgF8VhquNdOVVsNU=
github.com/waku-org/go-discover v0.0.0-20240129014929-85f2c00b96a3/go.mod h1:eBHgM6T4EG0RZzxpxKy+rGz/6Dw2Nd8DWxS0lm9ESDw=
github.com/waku-org/go-libp2p-rendezvous v0.0.0-20230628220917-7b4e5ae4c0e7 h1:0e1h+p84yBp0IN7AqgbZlV7lgFBjm214lgSOE7CeJmE=
github.com/waku-org/go-libp2p-rendezvous v0.0.0-20230628220917-7b4e5ae4c0e7/go.mod h1:pFvOZ9YTFsW0o5zJW7a0B5tr1owAijRWJctXJ2toL04=
github.com/waku-org/go-waku v0.8.1-0.20240104144340-585648c4eefe h1:2D97fbaKlIQRjWMz/iTjnYcxi2z6ekKvspTGtcuPHgU=
github.com/waku-org/go-waku v0.8.1-0.20240104144340-585648c4eefe/go.mod h1:+b5fPPJ4YUIAPJtPOtwB7bTrOQ9lF15I2LnQjV6NMIA=
github.com/waku-org/go-waku v0.8.1-0.20240130093642-77ea359ef873 h1:pnUvFENjM/h7HVF8VsNWTmOXx/rYs62P7H2EFjAnwVw=
github.com/waku-org/go-waku v0.8.1-0.20240130093642-77ea359ef873/go.mod h1:RjTvkTrIwpoT1cM9HeQqwa2Q7t7WOkb3hpuB/zuZ6SM=
github.com/waku-org/go-zerokit-rln v0.1.14-0.20240102145250-fa738c0bdf59 h1:jisj+OCI6QydLtFq3Pyhu49wl9ytPN7oAHjMfepHDrA=
github.com/waku-org/go-zerokit-rln v0.1.14-0.20240102145250-fa738c0bdf59/go.mod h1:1PdBdPzyTaKt3VnpAHk3zj+r9dXPFOr3IHZP9nFle6E=
github.com/waku-org/go-zerokit-rln-apple v0.0.0-20230916172309-ee0ee61dde2b h1:KgZVhsLkxsj5gb/FfndSCQu6VYwALrCOgYI3poR95yE=

View File

@ -472,10 +472,7 @@ func LoginWithKeycard(accountData, password, keyHex string, configJSON string) s
// Logout is equivalent to clearing whisper identities.
func Logout() string {
err := statusBackend.Logout()
if err != nil {
makeJSONResponse(err)
}
return makeJSONResponse(statusBackend.StopNode())
return makeJSONResponse(err)
}
// SignMessage unmarshals rpc params {data, address, password} and

View File

@ -507,7 +507,7 @@ func (n *StatusNode) stop() error {
n.stickersSrvc = nil
n.publicMethods = make(map[string]bool)
n.pendingTracker = nil
n.log.Debug("status node stopped")
return nil
}

View File

@ -123,8 +123,8 @@ type callTimeout struct {
}
// ListenV5 listens on the given connection.
func ListenV5(conn UDPConn, ln *enode.LocalNode, cfg Config) (*UDPv5, error) {
t, err := newUDPv5(conn, ln, cfg)
func ListenV5(ctx context.Context, conn UDPConn, ln *enode.LocalNode, cfg Config) (*UDPv5, error) {
t, err := newUDPv5(ctx, conn, ln, cfg)
if err != nil {
return nil, err
}
@ -136,8 +136,8 @@ func ListenV5(conn UDPConn, ln *enode.LocalNode, cfg Config) (*UDPv5, error) {
}
// newUDPv5 creates a UDPv5 transport, but doesn't start any goroutines.
func newUDPv5(conn UDPConn, ln *enode.LocalNode, cfg Config) (*UDPv5, error) {
closeCtx, cancelCloseCtx := context.WithCancel(context.Background())
func newUDPv5(ctx context.Context, conn UDPConn, ln *enode.LocalNode, cfg Config) (*UDPv5, error) {
closeCtx, cancelCloseCtx := context.WithCancel(ctx)
cfg = cfg.withDefaults()
t := &UDPv5{
// static fields

View File

@ -180,7 +180,7 @@ func (d *DiscoveryV5) listen(ctx context.Context) error {
d.localnode.SetFallbackUDP(d.udpAddr.Port)
listener, err := discover.ListenV5(conn, d.localnode, d.config)
listener, err := discover.ListenV5(ctx, conn, d.localnode, d.config)
if err != nil {
return err
}

4
vendor/modules.txt vendored
View File

@ -1010,7 +1010,7 @@ github.com/tyler-smith/go-bip39/wordlists
# github.com/urfave/cli/v2 v2.24.4
## explicit; go 1.18
github.com/urfave/cli/v2
# github.com/waku-org/go-discover v0.0.0-20221209174356-61c833f34d98
# github.com/waku-org/go-discover v0.0.0-20240129014929-85f2c00b96a3
## explicit; go 1.15
github.com/waku-org/go-discover/discover
github.com/waku-org/go-discover/discover/v4wire
@ -1020,7 +1020,7 @@ github.com/waku-org/go-discover/discover/v5wire
github.com/waku-org/go-libp2p-rendezvous
github.com/waku-org/go-libp2p-rendezvous/db
github.com/waku-org/go-libp2p-rendezvous/pb
# github.com/waku-org/go-waku v0.8.1-0.20240104144340-585648c4eefe
# github.com/waku-org/go-waku v0.8.1-0.20240130093642-77ea359ef873
## explicit; go 1.19
github.com/waku-org/go-waku/logging
github.com/waku-org/go-waku/waku/persistence

View File

@ -93,6 +93,7 @@ func (mgr *FilterManager) runFilterLoop(wg *sync.WaitGroup) {
for {
select {
case <-mgr.ctx.Done():
mgr.logger.Debug("filter loop stopped")
return
case <-ticker.C:
mgr.pingPeers()

View File

@ -544,6 +544,7 @@ func (w *Waku) runPeerExchangeLoop() {
for {
select {
case <-w.ctx.Done():
w.logger.Debug("Peer exchange loop stopped")
return
case <-ticker.C:
w.logger.Info("Running peer exchange loop")
@ -1279,6 +1280,9 @@ func (w *Waku) Start() error {
}
go w.broadcast()
// we should wait `seedBootnodesForDiscV5` shutdown smoothly before set w.ctx to nil within `w.Stop()`
w.wg.Add(1)
go w.seedBootnodesForDiscV5()
return nil
@ -1588,6 +1592,7 @@ func (w *Waku) ConnectionChanged(state connection.State) {
// It also restarts if there's a connection change signalled from the client
func (w *Waku) seedBootnodesForDiscV5() {
if !w.settings.EnableDiscV5 || w.node.DiscV5() == nil {
w.wg.Done()
return
}
@ -1646,6 +1651,8 @@ func (w *Waku) seedBootnodesForDiscV5() {
lastTry = now()
case <-w.ctx.Done():
w.wg.Done()
w.logger.Debug("bootnode seeding stopped")
return
}
}