chore: bump go-waku to fix high cpu usage by peer exchange (#4777)
This commit is contained in:
parent
0856efff6f
commit
f650915a49
2
go.mod
2
go.mod
|
@ -89,7 +89,7 @@ require (
|
||||||
github.com/mutecomm/go-sqlcipher/v4 v4.4.2
|
github.com/mutecomm/go-sqlcipher/v4 v4.4.2
|
||||||
github.com/schollz/peerdiscovery v1.7.0
|
github.com/schollz/peerdiscovery v1.7.0
|
||||||
github.com/siphiuel/lc-proxy-wrapper v0.0.0-20230516150924-246507cee8c7
|
github.com/siphiuel/lc-proxy-wrapper v0.0.0-20230516150924-246507cee8c7
|
||||||
github.com/waku-org/go-waku v0.8.1-0.20240130093642-77ea359ef873
|
github.com/waku-org/go-waku v0.8.1-0.20240220211751-9bb2c8e39680
|
||||||
github.com/wk8/go-ordered-map/v2 v2.1.7
|
github.com/wk8/go-ordered-map/v2 v2.1.7
|
||||||
github.com/yeqown/go-qrcode/v2 v2.2.1
|
github.com/yeqown/go-qrcode/v2 v2.2.1
|
||||||
github.com/yeqown/go-qrcode/writer/standard v1.2.1
|
github.com/yeqown/go-qrcode/writer/standard v1.2.1
|
||||||
|
|
4
go.sum
4
go.sum
|
@ -2101,8 +2101,8 @@ github.com/waku-org/go-discover v0.0.0-20240129014929-85f2c00b96a3 h1:Kk0KYXZE/u
|
||||||
github.com/waku-org/go-discover v0.0.0-20240129014929-85f2c00b96a3/go.mod h1:eBHgM6T4EG0RZzxpxKy+rGz/6Dw2Nd8DWxS0lm9ESDw=
|
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 h1:0e1h+p84yBp0IN7AqgbZlV7lgFBjm214lgSOE7CeJmE=
|
||||||
github.com/waku-org/go-libp2p-rendezvous v0.0.0-20230628220917-7b4e5ae4c0e7/go.mod h1:pFvOZ9YTFsW0o5zJW7a0B5tr1owAijRWJctXJ2toL04=
|
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.20240130093642-77ea359ef873 h1:pnUvFENjM/h7HVF8VsNWTmOXx/rYs62P7H2EFjAnwVw=
|
github.com/waku-org/go-waku v0.8.1-0.20240220211751-9bb2c8e39680 h1:WGPMcGDmW7q9ZPoD5V53T1ak36/qo1rYLE9bv4g5BVY=
|
||||||
github.com/waku-org/go-waku v0.8.1-0.20240130093642-77ea359ef873/go.mod h1:RjTvkTrIwpoT1cM9HeQqwa2Q7t7WOkb3hpuB/zuZ6SM=
|
github.com/waku-org/go-waku v0.8.1-0.20240220211751-9bb2c8e39680/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 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 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=
|
github.com/waku-org/go-zerokit-rln-apple v0.0.0-20230916172309-ee0ee61dde2b h1:KgZVhsLkxsj5gb/FfndSCQu6VYwALrCOgYI3poR95yE=
|
||||||
|
|
|
@ -317,24 +317,7 @@ func (d *DiscoveryV5) Iterate(ctx context.Context, iterator enode.Iterator, onNo
|
||||||
defer iterator.Close()
|
defer iterator.Close()
|
||||||
|
|
||||||
peerCnt := 0
|
peerCnt := 0
|
||||||
for {
|
for DelayedHasNext(ctx, iterator, &peerCnt) {
|
||||||
|
|
||||||
if !delayedHasNext(ctx, iterator) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
peerCnt++
|
|
||||||
if peerCnt == bucketSize { // Delay every bucketSize peers discovered
|
|
||||||
peerCnt = 0
|
|
||||||
t := time.NewTimer(delayBetweenDiscoveredPeerCnt)
|
|
||||||
select {
|
|
||||||
case <-ctx.Done():
|
|
||||||
return
|
|
||||||
case <-t.C:
|
|
||||||
t.Stop()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
_, addresses, err := wenr.Multiaddress(iterator.Node())
|
_, addresses, err := wenr.Multiaddress(iterator.Node())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.metrics.RecordError(peerInfoFailure)
|
d.metrics.RecordError(peerInfoFailure)
|
||||||
|
@ -364,7 +347,7 @@ func (d *DiscoveryV5) Iterate(ctx context.Context, iterator enode.Iterator, onNo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func delayedHasNext(ctx context.Context, iterator enode.Iterator) bool {
|
func DelayedHasNext(ctx context.Context, iterator enode.Iterator, peerCnt *int) bool {
|
||||||
// Delay if .Next() is too fast
|
// Delay if .Next() is too fast
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
hasNext := iterator.Next()
|
hasNext := iterator.Next()
|
||||||
|
@ -383,6 +366,18 @@ func delayedHasNext(ctx context.Context, iterator enode.Iterator) bool {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
*peerCnt++
|
||||||
|
if *peerCnt == bucketSize { // Delay every bucketSize peers discovered
|
||||||
|
*peerCnt = 0
|
||||||
|
t := time.NewTimer(delayBetweenDiscoveredPeerCnt)
|
||||||
|
select {
|
||||||
|
case <-ctx.Done():
|
||||||
|
return false
|
||||||
|
case <-t.C:
|
||||||
|
t.Stop()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -144,7 +144,8 @@ func (wakuPX *WakuPeerExchange) iterate(ctx context.Context) error {
|
||||||
// Closing iterator
|
// Closing iterator
|
||||||
defer iterator.Close()
|
defer iterator.Close()
|
||||||
|
|
||||||
for iterator.Next() {
|
peerCnt := 0
|
||||||
|
for discv5.DelayedHasNext(ctx, iterator, &peerCnt) {
|
||||||
_, addresses, err := enr.Multiaddress(iterator.Node())
|
_, addresses, err := enr.Multiaddress(iterator.Node())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
wakuPX.log.Error("extracting multiaddrs from enr", zap.Error(err))
|
wakuPX.log.Error("extracting multiaddrs from enr", zap.Error(err))
|
||||||
|
@ -183,12 +184,15 @@ func (wakuPX *WakuPeerExchange) runPeerExchangeDiscv5Loop(ctx context.Context) {
|
||||||
err := wakuPX.iterate(ctx)
|
err := wakuPX.iterate(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
wakuPX.log.Debug("iterating peer exchange", zap.Error(err))
|
wakuPX.log.Debug("iterating peer exchange", zap.Error(err))
|
||||||
time.Sleep(2 * time.Second)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
t := time.NewTimer(5 * time.Second)
|
||||||
select {
|
select {
|
||||||
|
case <-t.C:
|
||||||
|
t.Stop()
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
|
t.Stop()
|
||||||
return
|
return
|
||||||
default:
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
||||||
github.com/waku-org/go-libp2p-rendezvous/db
|
github.com/waku-org/go-libp2p-rendezvous/db
|
||||||
github.com/waku-org/go-libp2p-rendezvous/pb
|
github.com/waku-org/go-libp2p-rendezvous/pb
|
||||||
# github.com/waku-org/go-waku v0.8.1-0.20240130093642-77ea359ef873
|
# github.com/waku-org/go-waku v0.8.1-0.20240220211751-9bb2c8e39680
|
||||||
## explicit; go 1.19
|
## explicit; go 1.19
|
||||||
github.com/waku-org/go-waku/logging
|
github.com/waku-org/go-waku/logging
|
||||||
github.com/waku-org/go-waku/waku/persistence
|
github.com/waku-org/go-waku/waku/persistence
|
||||||
|
|
Loading…
Reference in New Issue