From 6444b599dfafc7d3e7bca681d40f83c59c1b1649 Mon Sep 17 00:00:00 2001 From: Leo Chen Date: Sat, 5 Dec 2020 05:49:45 +0000 Subject: [PATCH 1/5] [bootnode] support dnsaddr in bootnode Signed-off-by: Leo Chen --- api/service/networkinfo/service.go | 17 ++++++++++++++++- go.mod | 1 + 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/api/service/networkinfo/service.go b/api/service/networkinfo/service.go index 2e7c7c183..5d8297e81 100644 --- a/api/service/networkinfo/service.go +++ b/api/service/networkinfo/service.go @@ -18,6 +18,7 @@ import ( libp2pdis "github.com/libp2p/go-libp2p-discovery" libp2pdht "github.com/libp2p/go-libp2p-kad-dht" libp2pdhtopts "github.com/libp2p/go-libp2p-kad-dht/opts" + madns "github.com/multiformats/go-multiaddr-dns" manet "github.com/multiformats/go-multiaddr-net" "github.com/pkg/errors" ) @@ -139,7 +140,21 @@ func (s *Service) Init() error { } connected := false - for _, peerAddr := range s.bootnodes { + var bnList p2p.AddrList + for _, maddr := range s.bootnodes { + if madns.Matches(maddr) { + mas, err := madns.Resolve(context.Background(), maddr) + if err != nil { + utils.Logger().Error().Err(err).Msg("Resolve bootnode") + continue + } + bnList = append(bnList, mas...) + } else { + bnList = append(bnList, maddr) + } + } + + for _, peerAddr := range bnList { peerinfo, _ := libp2p_peer.AddrInfoFromP2pAddr(peerAddr) wg.Add(1) go func() { diff --git a/go.mod b/go.mod index e970e2432..9088b5bfa 100644 --- a/go.mod +++ b/go.mod @@ -38,6 +38,7 @@ require ( github.com/libp2p/go-libp2p-kad-dht v0.8.3 github.com/libp2p/go-libp2p-pubsub v0.3.3 github.com/multiformats/go-multiaddr v0.2.2 + github.com/multiformats/go-multiaddr-dns v0.2.0 github.com/multiformats/go-multiaddr-net v0.1.5 github.com/natefinch/lumberjack v2.0.0+incompatible github.com/pborman/uuid v1.2.0 From 68d49370a7e35f657fe632691b5d16d55b1356bf Mon Sep 17 00:00:00 2001 From: Leo Chen Date: Sat, 5 Dec 2020 06:12:09 +0000 Subject: [PATCH 2/5] [bootnode] use dnsaddr for stress network Signed-off-by: Leo Chen --- internal/configs/node/network.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/configs/node/network.go b/internal/configs/node/network.go index b17793626..759765637 100644 --- a/internal/configs/node/network.go +++ b/internal/configs/node/network.go @@ -24,7 +24,7 @@ var ( } stressBootNodes = []string{ - "/ip4/52.40.84.2/tcp/9842/p2p/QmbPVwrqWsTYXq1RxGWcxx9SWaTUCfoo1wA6wmdbduWe29", + "/dnsaddr/bootstrap.stn.hmny.io", } devnetBootNodes = []string{} From 4164251d2091e373c0bf4dac70a5f2347be0f913 Mon Sep 17 00:00:00 2001 From: Leo Chen Date: Sat, 5 Dec 2020 06:19:37 +0000 Subject: [PATCH 3/5] [bootnode] use dnsaddr for mainnet Signed-off-by: Leo Chen --- internal/configs/node/network.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/internal/configs/node/network.go b/internal/configs/node/network.go index 759765637..5022217f1 100644 --- a/internal/configs/node/network.go +++ b/internal/configs/node/network.go @@ -2,10 +2,7 @@ package nodeconfig var ( mainnetBootNodes = []string{ - "/ip4/100.26.90.187/tcp/9874/p2p/Qmdfjtk6hPoyrH1zVD9PEH4zfWLo38dP2mDvvKXfh3tnEv", - "/ip4/54.213.43.194/tcp/9874/p2p/QmZJJx6AdaoEkGLrYG4JeLCKeCKDjnFz2wfHNHxAqFSGA9", - "/ip4/13.113.101.219/tcp/12019/p2p/QmQayinFSgMMw5cSpDUiD9pQ2WeP6WNmGxpZ6ou3mdVFJX", - "/ip4/99.81.170.167/tcp/12019/p2p/QmRVbTpEYup8dSaURZfF6ByrMTSKa4UyUzJhSjahFzRqNj", + "/dnsaddr/bootstrap.t.hmny.io", } testnetBootNodes = []string{ From 8f668515bd870456e8d02de93d939d24fb6b0e39 Mon Sep 17 00:00:00 2001 From: Leo Chen Date: Sat, 5 Dec 2020 06:20:09 +0000 Subject: [PATCH 4/5] [bootnode] use dnsaddr for testnet Signed-off-by: Leo Chen --- internal/configs/node/network.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/internal/configs/node/network.go b/internal/configs/node/network.go index 5022217f1..fbdaa2e4b 100644 --- a/internal/configs/node/network.go +++ b/internal/configs/node/network.go @@ -6,8 +6,7 @@ var ( } testnetBootNodes = []string{ - "/ip4/54.86.126.90/tcp/9867/p2p/Qmdfjtk6hPoyrH1zVD9PEH4zfWLo38dP2mDvvKXfh3tnEv", - "/ip4/52.40.84.2/tcp/9867/p2p/QmbPVwrqWsTYXq1RxGWcxx9SWaTUCfoo1wA6wmdbduWe29", + "/dnsaddr/bootstrap.b.hmny.io", } pangaeaBootNodes = []string{ From 5c6dfc0d46fc85c4a6dbbba6907e8fb9a5a1f9e1 Mon Sep 17 00:00:00 2001 From: Leo Chen Date: Sat, 5 Dec 2020 06:45:51 +0000 Subject: [PATCH 5/5] [bootnode] fix config test Signed-off-by: Leo Chen --- cmd/harmony/config_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/harmony/config_test.go b/cmd/harmony/config_test.go index a9b4831ab..75aa71ef5 100644 --- a/cmd/harmony/config_test.go +++ b/cmd/harmony/config_test.go @@ -63,7 +63,7 @@ func TestV1_0_0Config(t *testing.T) { Verbosity = 3 [Network] - BootNodes = ["/ip4/100.26.90.187/tcp/9874/p2p/Qmdfjtk6hPoyrH1zVD9PEH4zfWLo38dP2mDvvKXfh3tnEv","/ip4/54.213.43.194/tcp/9874/p2p/QmZJJx6AdaoEkGLrYG4JeLCKeCKDjnFz2wfHNHxAqFSGA9","/ip4/13.113.101.219/tcp/12019/p2p/QmQayinFSgMMw5cSpDUiD9pQ2WeP6WNmGxpZ6ou3mdVFJX","/ip4/99.81.170.167/tcp/12019/p2p/QmRVbTpEYup8dSaURZfF6ByrMTSKa4UyUzJhSjahFzRqNj"] + BootNodes = ["/dnsaddr/bootstrap.t.hmny.io"] DNSPort = 9000 DNSZone = "t.hmny.io" LegacySyncing = false