diff --git a/cmd/ronin/les_test.go b/cmd/ronin/les_test.go index 151c12c68c..b42b0da312 100644 --- a/cmd/ronin/les_test.go +++ b/cmd/ronin/les_test.go @@ -141,7 +141,7 @@ func startGethWithIpc(t *testing.T, name string, args ...string) *gethrpc { // We can't know exactly how long geth will take to start, so we try 10 // times over a 5 second period. var err error - for i := 0; i < 10; i++ { + for i := 0; i < 30; i++ { time.Sleep(500 * time.Millisecond) if g.rpc, err = rpc.Dial(ipcpath); err == nil { return g diff --git a/eth/backend.go b/eth/backend.go index 75e837941b..fcaae8adfc 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -319,6 +319,7 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) { // Setup DNS discovery iterators. dnsclient := dnsdisc.NewClient(dnsdisc.Config{}) + log.Info("DNS url", "eth", eth.config.EthDiscoveryURLs, "snap", eth.config.SnapDiscoveryURLs) eth.ethDialCandidates, err = dnsclient.NewIterator(eth.config.EthDiscoveryURLs...) if err != nil { return nil, err diff --git a/p2p/server.go b/p2p/server.go index bcfc1bd10b..22daa6f843 100644 --- a/p2p/server.go +++ b/p2p/server.go @@ -62,6 +62,12 @@ const ( // Maximum amount of time allowed for writing a complete message. frameWriteTimeout = 20 * time.Second + + // The number of DHT seed nodes got from DNS resolve + numSeedNodesFromDns = 5 + + // Name of eth protocol + ethProtocolName = "eth" ) var errServerStopped = errors.New("server stopped") @@ -539,6 +545,21 @@ func (srv *Server) setupDiscovery() error { added := make(map[string]bool) for _, proto := range srv.Protocols { if proto.DialCandidates != nil && !added[proto.Name] { + // If the protocol is eth, the dial candidates are retrieved from + // DNS URL. We want to use the DNS discovery for bootstrap nodes + // too, so resolve some node from DNS and add to DHT. + if proto.Name == ethProtocolName { + for i := 0; i < numSeedNodesFromDns; i++ { + if !proto.DialCandidates.Next() { + break + } + + node := proto.DialCandidates.Node() + srv.BootstrapNodes = append(srv.BootstrapNodes, node) + srv.BootstrapNodesV5 = append(srv.BootstrapNodes, node) + } + } + srv.discmix.AddSource(proto.DialCandidates) added[proto.Name] = true }