mirror of
https://github.com/status-im/go-waku.git
synced 2025-01-12 23:04:45 +00:00
fix: addr update
This commit is contained in:
parent
ee94581d0a
commit
d4abe15634
@ -1,5 +1,5 @@
|
|||||||
# BUILD IMAGE --------------------------------------------------------
|
# BUILD IMAGE --------------------------------------------------------
|
||||||
FROM golang:1.19 as builder
|
FROM golang:1.20 as builder
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY . .
|
COPY . .
|
||||||
|
@ -5,7 +5,7 @@ A Go implementation of the [Waku v2 protocol](https://rfc.vac.dev/spec/10).
|
|||||||
<p align="left">
|
<p align="left">
|
||||||
<a href="https://goreportcard.com/report/github.com/waku-org/go-waku"><img src="https://goreportcard.com/badge/github.com/waku-org/go-waku" /></a>
|
<a href="https://goreportcard.com/report/github.com/waku-org/go-waku"><img src="https://goreportcard.com/badge/github.com/waku-org/go-waku" /></a>
|
||||||
<a href="https://godoc.org/github.com/waku-org/go-waku"><img src="http://img.shields.io/badge/godoc-reference-5272B4.svg?style=flat-square" /></a>
|
<a href="https://godoc.org/github.com/waku-org/go-waku"><img src="http://img.shields.io/badge/godoc-reference-5272B4.svg?style=flat-square" /></a>
|
||||||
<a href=""><img src="https://img.shields.io/badge/golang-%3E%3D1.19.0-orange.svg?style=flat-square" /></a>
|
<a href=""><img src="https://img.shields.io/badge/golang-%3E%3D1.20.0-orange.svg?style=flat-square" /></a>
|
||||||
<a href="https://codeclimate.com/github/waku-org/go-waku/maintainability"><img src="https://api.codeclimate.com/v1/badges/426bdff6a339ff4d536b/maintainability" /></a>
|
<a href="https://codeclimate.com/github/waku-org/go-waku/maintainability"><img src="https://api.codeclimate.com/v1/badges/426bdff6a339ff4d536b/maintainability" /></a>
|
||||||
<br>
|
<br>
|
||||||
</p>
|
</p>
|
||||||
@ -106,7 +106,7 @@ Thank you for considering to help out with the source code! We welcome contribut
|
|||||||
If you'd like to contribute to go-waku, please fork, fix, commit and send a pull request. If you wish to submit more complex changes though, please check up with the core devs first to ensure those changes are in line with the general philosophy of the project and/or get some early feedback which can make both your efforts much lighter as well as our review and merge procedures quick and simple.
|
If you'd like to contribute to go-waku, please fork, fix, commit and send a pull request. If you wish to submit more complex changes though, please check up with the core devs first to ensure those changes are in line with the general philosophy of the project and/or get some early feedback which can make both your efforts much lighter as well as our review and merge procedures quick and simple.
|
||||||
|
|
||||||
To build and test this repository, you need:
|
To build and test this repository, you need:
|
||||||
- [Go](https://golang.org/) (version 1.19 or 1.20)
|
- [Go](https://golang.org/) (version 1.20)
|
||||||
- [protoc](https://grpc.io/docs/protoc-installation/)
|
- [protoc](https://grpc.io/docs/protoc-installation/)
|
||||||
- [protoc-gen-go](https://protobuf.dev/getting-started/gotutorial/#compiling-protocol-buffers)
|
- [protoc-gen-go](https://protobuf.dev/getting-started/gotutorial/#compiling-protocol-buffers)
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
module basic2
|
module basic2
|
||||||
|
|
||||||
go 1.19
|
go 1.20
|
||||||
|
|
||||||
replace github.com/waku-org/go-waku => ../..
|
replace github.com/waku-org/go-waku => ../..
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
module chat2
|
module chat2
|
||||||
|
|
||||||
go 1.19
|
go 1.20
|
||||||
|
|
||||||
replace github.com/waku-org/go-waku => ../..
|
replace github.com/waku-org/go-waku => ../..
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
module filter2
|
module filter2
|
||||||
|
|
||||||
go 1.19
|
go 1.20
|
||||||
|
|
||||||
replace github.com/waku-org/go-waku => ../..
|
replace github.com/waku-org/go-waku => ../..
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
module noise
|
module noise
|
||||||
|
|
||||||
go 1.19
|
go 1.20
|
||||||
|
|
||||||
replace github.com/waku-org/go-waku => ../..
|
replace github.com/waku-org/go-waku => ../..
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
module rln
|
module rln
|
||||||
|
|
||||||
go 1.19
|
go 1.20
|
||||||
|
|
||||||
replace github.com/waku-org/go-waku => ../..
|
replace github.com/waku-org/go-waku => ../..
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
pkgs = nixpkgsFor.${system};
|
pkgs = nixpkgsFor.${system};
|
||||||
commit = builtins.substring 0 7 (self.rev or "dirty");
|
commit = builtins.substring 0 7 (self.rev or "dirty");
|
||||||
version = builtins.readFile ./VERSION;
|
version = builtins.readFile ./VERSION;
|
||||||
in pkgs.buildGo119Module {
|
in pkgs.buildGo120Module {
|
||||||
name = "go-waku";
|
name = "go-waku";
|
||||||
src = self;
|
src = self;
|
||||||
inherit subPackages;
|
inherit subPackages;
|
||||||
|
4
go.mod
4
go.mod
@ -1,6 +1,6 @@
|
|||||||
module github.com/waku-org/go-waku
|
module github.com/waku-org/go-waku
|
||||||
|
|
||||||
go 1.19
|
go 1.20
|
||||||
|
|
||||||
replace github.com/ethereum/go-ethereum v1.10.26 => github.com/status-im/go-ethereum v1.10.25-status.4
|
replace github.com/ethereum/go-ethereum v1.10.26 => github.com/status-im/go-ethereum v1.10.25-status.4
|
||||||
|
|
||||||
@ -160,7 +160,7 @@ require (
|
|||||||
go.uber.org/atomic v1.11.0 // indirect
|
go.uber.org/atomic v1.11.0 // indirect
|
||||||
go.uber.org/multierr v1.11.0 // indirect
|
go.uber.org/multierr v1.11.0 // indirect
|
||||||
golang.org/x/crypto v0.12.0 // indirect
|
golang.org/x/crypto v0.12.0 // indirect
|
||||||
golang.org/x/exp v0.0.0-20230713183714-613f0c0eb8a1 // indirect
|
golang.org/x/exp v0.0.0-20230713183714-613f0c0eb8a1
|
||||||
golang.org/x/mod v0.12.0 // indirect
|
golang.org/x/mod v0.12.0 // indirect
|
||||||
golang.org/x/net v0.14.0 // indirect
|
golang.org/x/net v0.14.0 // indirect
|
||||||
golang.org/x/sys v0.11.0
|
golang.org/x/sys v0.11.0
|
||||||
|
@ -11,6 +11,7 @@ import (
|
|||||||
golog "github.com/ipfs/go-log/v2"
|
golog "github.com/ipfs/go-log/v2"
|
||||||
"github.com/libp2p/go-libp2p"
|
"github.com/libp2p/go-libp2p"
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
|
"golang.org/x/exp/maps"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/crypto"
|
"github.com/ethereum/go-ethereum/crypto"
|
||||||
"github.com/ethereum/go-ethereum/p2p/enode"
|
"github.com/ethereum/go-ethereum/p2p/enode"
|
||||||
@ -306,7 +307,8 @@ func New(opts ...WakuNodeOption) (*WakuNode, error) {
|
|||||||
func (w *WakuNode) watchMultiaddressChanges(ctx context.Context) {
|
func (w *WakuNode) watchMultiaddressChanges(ctx context.Context) {
|
||||||
defer w.wg.Done()
|
defer w.wg.Done()
|
||||||
|
|
||||||
addrs := w.ListenAddresses()
|
addrsSet := utils.MultiAddrSet(w.ListenAddresses()...)
|
||||||
|
|
||||||
first := make(chan struct{}, 1)
|
first := make(chan struct{}, 1)
|
||||||
first <- struct{}{}
|
first <- struct{}{}
|
||||||
for {
|
for {
|
||||||
@ -314,22 +316,13 @@ func (w *WakuNode) watchMultiaddressChanges(ctx context.Context) {
|
|||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
return
|
return
|
||||||
case <-first:
|
case <-first:
|
||||||
w.log.Info("listening", logging.MultiAddrs("multiaddr", addrs...))
|
addr := maps.Keys(addrsSet)
|
||||||
|
w.log.Info("listening", logging.MultiAddrs("multiaddr", addr...))
|
||||||
case <-w.addressChangesSub.Out():
|
case <-w.addressChangesSub.Out():
|
||||||
newAddrs := w.ListenAddresses()
|
newAddrs := utils.MultiAddrSet(w.ListenAddresses()...)
|
||||||
diff := false
|
if !maps.Equal(addrsSet, newAddrs) {
|
||||||
if len(addrs) != len(newAddrs) {
|
addrsSet = newAddrs
|
||||||
diff = true
|
addrs := maps.Keys(addrsSet)
|
||||||
} else {
|
|
||||||
for i := range newAddrs {
|
|
||||||
if addrs[i].String() != newAddrs[i].String() {
|
|
||||||
diff = true
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if diff {
|
|
||||||
addrs = newAddrs
|
|
||||||
w.log.Info("listening addresses update received", logging.MultiAddrs("multiaddr", addrs...))
|
w.log.Info("listening addresses update received", logging.MultiAddrs("multiaddr", addrs...))
|
||||||
err := w.setupENR(ctx, addrs)
|
err := w.setupENR(ctx, addrs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -889,7 +882,6 @@ func (w *WakuNode) findRelayNodes(ctx context.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Shuffle peers
|
// Shuffle peers
|
||||||
rand.Seed(time.Now().UnixNano())
|
|
||||||
rand.Shuffle(len(peers), func(i, j int) { peers[i], peers[j] = peers[j], peers[i] })
|
rand.Shuffle(len(peers), func(i, j int) { peers[i], peers[j] = peers[j], peers[i] })
|
||||||
|
|
||||||
for _, p := range peers {
|
for _, p := range peers {
|
||||||
|
@ -7,7 +7,6 @@ import (
|
|||||||
crand "crypto/rand"
|
crand "crypto/rand"
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
"fmt"
|
"fmt"
|
||||||
mrand "math/rand"
|
|
||||||
|
|
||||||
"errors"
|
"errors"
|
||||||
"strconv"
|
"strconv"
|
||||||
@ -282,7 +281,7 @@ func generateSecureRandomData(length int) ([]byte, error) {
|
|||||||
} else if !validateDataIntegrity(x, length) {
|
} else if !validateDataIntegrity(x, length) {
|
||||||
return nil, errors.New("crypto/rand failed to generate secure random data")
|
return nil, errors.New("crypto/rand failed to generate secure random data")
|
||||||
}
|
}
|
||||||
_, err = mrand.Read(y)
|
_, err = crand.Read(y)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
} else if !validateDataIntegrity(y, length) {
|
} else if !validateDataIntegrity(y, length) {
|
||||||
|
@ -3,6 +3,7 @@ package payload
|
|||||||
import (
|
import (
|
||||||
"crypto/aes"
|
"crypto/aes"
|
||||||
"crypto/cipher"
|
"crypto/cipher"
|
||||||
|
crand "crypto/rand"
|
||||||
mrand "math/rand"
|
mrand "math/rand"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
@ -84,7 +85,7 @@ func singlePaddingTest(t *testing.T, padSize int) {
|
|||||||
Key: keyInfo,
|
Key: keyInfo,
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = mrand.Read(p.Padding) // nolint: gosec
|
_, err = crand.Read(p.Padding) // nolint: gosec
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
encodedPayload, err := p.Encode(1)
|
encodedPayload, err := p.Encode(1)
|
||||||
|
@ -7,7 +7,6 @@ import (
|
|||||||
"math"
|
"math"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"net"
|
"net"
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/p2p/enode"
|
"github.com/ethereum/go-ethereum/p2p/enode"
|
||||||
"github.com/ethereum/go-ethereum/p2p/enr"
|
"github.com/ethereum/go-ethereum/p2p/enr"
|
||||||
@ -28,7 +27,6 @@ func WithMultiaddress(multiaddrs ...multiaddr.Multiaddr) ENROption {
|
|||||||
return func(localnode *enode.LocalNode) (err error) {
|
return func(localnode *enode.LocalNode) (err error) {
|
||||||
|
|
||||||
// Randomly shuffle multiaddresses
|
// Randomly shuffle multiaddresses
|
||||||
rand.Seed(time.Now().UnixNano())
|
|
||||||
rand.Shuffle(len(multiaddrs), func(i, j int) { multiaddrs[i], multiaddrs[j] = multiaddrs[j], multiaddrs[i] })
|
rand.Shuffle(len(multiaddrs), func(i, j int) { multiaddrs[i], multiaddrs[j] = multiaddrs[j], multiaddrs[i] })
|
||||||
|
|
||||||
// Adding extra multiaddresses. Should probably not exceed the enr max size of 300bytes
|
// Adding extra multiaddresses. Should probably not exceed the enr max size of 300bytes
|
||||||
|
@ -16,3 +16,11 @@ func EncapsulatePeerID(peerID peer.ID, addrs ...multiaddr.Multiaddr) []multiaddr
|
|||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func MultiAddrSet(addr ...multiaddr.Multiaddr) map[multiaddr.Multiaddr]struct{} {
|
||||||
|
r := make(map[multiaddr.Multiaddr]struct{})
|
||||||
|
for _, a := range addr {
|
||||||
|
r[a] = struct{}{}
|
||||||
|
}
|
||||||
|
return r
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user