waku-org / go-waku

Go implementation of Waku v2 protocol
https://waku.org/
Other
119 stars 43 forks source link

bug: race condition while setting boot nodes for Discv5 #1059

Closed romanzac closed 7 months ago

romanzac commented 7 months ago

Description Race condition error appears during TestDiscV5WithCapabilitiesFilter test run. Problem is with (d *DiscoveryV5) SetBootnodes() call. It looks setting boot nodes after DiscoveryV5 instance was created interferes with discovery process already going on.

To Reproduce 1) Checkout chore-discv5-tests-coverage-improvement 2) go test -race -timeout 300s

Expected behavior Have race condition treated or remove SetBootnodes() feature, as I saw it is not used and it is a bit counterintuitive.

Logs

go test -race -timeout 300s
2024-03-19T09:36:59.456+0800    WARN    p2p-config  config/config.go:304    rcmgr limit conflicts with connmgr limit: conn manager high watermark limit: 192, exceeds the system connection limit of: 1
2024-03-19T09:36:59.479+0800    WARN    p2p-config  config/config.go:304    rcmgr limit conflicts with connmgr limit: conn manager high watermark limit: 192, exceeds the system connection limit of: 1
2024-03-19T09:36:59.500+0800    WARN    p2p-config  config/config.go:304    rcmgr limit conflicts with connmgr limit: conn manager high watermark limit: 192, exceeds the system connection limit of: 1
2024-03-19T09:36:59.521+0800    INFO    gowaku.discv5   discv5/discover.go:190  started Discovery V5    {"listening": "[::]:57267", "advertising": "127.0.0.1:51011"}
2024-03-19T09:36:59.521+0800    INFO    gowaku.discv5   discv5/discover.go:193  Discovery V5: discoverable ENR  {"enr": "enr:-Ji4QPv3OF1oUGsP2tjxSraUmirMEe49vZ120pCwRIKlIz1XVPUEyw2zbKHYBKdrfjsfjSzj5FFY1acI90l8vjUEtQqGAY5UWsg_gmlkgnY0gmlwhH8AAAGJc2VjcDI1NmsxoQIxV4bh5hTTi7soTLqgYTjkpsVktx8X1B1gmWVu2Ot6LIN0Y3CCx0ODdWRwgt-zhXdha3UyDw"}
2024-03-19T09:36:59.522+0800    INFO    gowaku.discv5   discv5/discover.go:190  started Discovery V5    {"listening": "[::]:56246", "advertising": "127.0.0.1:51012"}
2024-03-19T09:36:59.522+0800    INFO    gowaku.discv5   discv5/discover.go:193  Discovery V5: discoverable ENR  {"enr": "enr:-Ji4QJSy6-WfjRtdJdAQOFDGAtcC0P--oRj4HHJfMVvZLSymAdxv869FCgBqriIuPBzgq1ByI6_iCxqm3EnqD0Y2912GAY5UWshUgmlkgnY0gmlwhH8AAAGJc2VjcDI1NmsxoQJLANF9TIG5FJptAWHlIZTVi3l_-wcHGDWGOaKPLhLD0YN0Y3CCx0SDdWRwgtu2hXdha3UyDw"}
2024-03-19T09:36:59.529+0800    INFO    gowaku.discv5   discv5/discover.go:190  started Discovery V5    {"listening": "[::]:54227", "advertising": "127.0.0.1:51013"}
2024-03-19T09:36:59.529+0800    INFO    gowaku.discv5   discv5/discover.go:193  Discovery V5: discoverable ENR  {"enr": "enr:-Ji4QJAqXjMNKaNrgHlbL03ewiSrSjdeB-2t9skaUdUeZ3KkUZDCohMGP2fwPa09P3ZJIvVqr8kTwZVWX5Bia1aeFkaGAY5UWshrgmlkgnY0gmlwhH8AAAGJc2VjcDI1NmsxoQOJV4NsTNdidfuUP-fgdDzzt7Mk6P7jrejDVFxv-d1ghYN0Y3CCx0WDdWRwgtPThXdha3UyDw"}
2024-03-19T09:36:59.533+0800    INFO    gowaku.discv5   discv5/discover.go:190  started Discovery V5    {"listening": "[::]:57937", "advertising": "127.0.0.1:51012"}
2024-03-19T09:36:59.533+0800    INFO    gowaku.discv5   discv5/discover.go:193  Discovery V5: discoverable ENR  {"enr": "enr:-Ji4QFEIzpwaJtfwOpL44tuNUmRZSFyKS6D7yl8IcXCmmxQVXIDZtSTOdD9CXICvbI3WuqpG-tY-YYPMb019MK8C9eeGAY5UWsiBgmlkgnY0gmlwhH8AAAGJc2VjcDI1NmsxoQI3OpFaROARmKBew4GdOTWVrZKj7xv4HkQ2wSA_ECOUfoN0Y3CCx0SDdWRwguJRhXdha3UygA"}
2024-03-19T09:37:01.534+0800    INFO    gowaku.discv5   discv5/discover.go:249  stopped Discovery V5
2024-03-19T09:37:01.534+0800    WARN    gowaku.discv5   discv5/discover.go:487  Discv5 loop stopped
2024-03-19T09:37:01.542+0800    INFO    gowaku.discv5   discv5/discover.go:190  started Discovery V5    {"listening": "[::]:54227", "advertising": "127.0.0.1:51013"}
2024-03-19T09:37:01.542+0800    INFO    gowaku.discv5   discv5/discover.go:193  Discovery V5: discoverable ENR  {"enr": "enr:-Ji4QJAqXjMNKaNrgHlbL03ewiSrSjdeB-2t9skaUdUeZ3KkUZDCohMGP2fwPa09P3ZJIvVqr8kTwZVWX5Bia1aeFkaGAY5UWshrgmlkgnY0gmlwhH8AAAGJc2VjcDI1NmsxoQOJV4NsTNdidfuUP-fgdDzzt7Mk6P7jrejDVFxv-d1ghYN0Y3CCx0WDdWRwgtPThXdha3UyDw"}
2024-03-19T09:37:03.543+0800    INFO    gowaku.discv5   discv5/discover.go:249  stopped Discovery V5
2024-03-19T09:37:03.543+0800    WARN    gowaku.discv5   discv5/discover.go:487  Discv5 loop stopped
2024-03-19T09:37:03.544+0800    WARN    gowaku.discv5   discv5/discover.go:487  Discv5 loop stopped
2024-03-19T09:37:03.544+0800    INFO    gowaku.discv5   discv5/discover.go:249  stopped Discovery V5
2024-03-19T09:37:03.544+0800    WARN    gowaku.discv5   discv5/discover.go:487  Discv5 loop stopped
2024-03-19T09:37:03.546+0800    INFO    gowaku.discv5   discv5/discover.go:249  stopped Discovery V5
2024-03-19T09:37:03.546+0800    WARN    gowaku.discv5   discv5/discover.go:487  Discv5 loop stopped
2024-03-19T09:37:03.546+0800    INFO    gowaku.discv5   discv5/discover.go:249  stopped Discovery V5
2024-03-19T09:37:03.551+0800    WARN    p2p-config  config/config.go:304    rcmgr limit conflicts with connmgr limit: conn manager high watermark limit: 192, exceeds the system connection limit of: 1
2024-03-19T09:37:03.591+0800    WARN    p2p-config  config/config.go:304    rcmgr limit conflicts with connmgr limit: conn manager high watermark limit: 192, exceeds the system connection limit of: 1
2024-03-19T09:37:03.618+0800    WARN    p2p-config  config/config.go:304    rcmgr limit conflicts with connmgr limit: conn manager high watermark limit: 192, exceeds the system connection limit of: 1
2024-03-19T09:37:03.639+0800    INFO    gowaku.discv5   discv5/discover.go:190  started Discovery V5    {"listening": "[::]:53802", "advertising": "127.0.0.1:51018"}
2024-03-19T09:37:03.639+0800    INFO    gowaku.discv5   discv5/discover.go:193  Discovery V5: discoverable ENR  {"enr": "enr:-Ji4QLKrTZ29gmKL4RMIfQi2T9hi0XPzYQChEndMvwkoZ51WGocok-umscEAQNsgiFW47WuOPgGR027L2IicuZGTq7GGAY5UWthlgmlkgnY0gmlwhH8AAAGJc2VjcDI1NmsxoQKbEhROKzhq4BOWQ9y01op-fgE2xotsG23x5VjpL6LzkoN0Y3CCx0qDdWRwgtIqhXdha3UyDw"}
2024-03-19T09:37:03.646+0800    INFO    gowaku.discv5   discv5/discover.go:190  started Discovery V5    {"listening": "[::]:60098", "advertising": "127.0.0.1:51019"}
2024-03-19T09:37:03.646+0800    INFO    gowaku.discv5   discv5/discover.go:193  Discovery V5: discoverable ENR  {"enr": "enr:-Ji4QN6I5GRar6ORgZMmLelN9NNwcPzc-cJhACu9l67ip6qbQtrDLlxZbw8QWGOq7izIscMKdNZfUMZzDxm1jk0fCViGAY5UWtiAgmlkgnY0gmlwhH8AAAGJc2VjcDI1NmsxoQL9nrpB9TrPoQwb6FLNsZxuq-3sEjDTbRXhIGyOT3G1EYN0Y3CCx0uDdWRwgurChXdha3UyDQ"}
==================
WARNING: DATA RACE
Write at 0x00c00029abd0 by goroutine 562:
  github.com/waku-org/go-discover/discover.(*Table).setFallbackNodes()
      /Users/roman/go/pkg/mod/github.com/waku-org/go-discover@v0.0.0-20221209174356-61c833f34d98/discover/table.go:196 +0x278
  github.com/waku-org/go-discover/discover.(*UDPv5).SetFallbackNodes()
      /Users/roman/go/pkg/mod/github.com/waku-org/go-discover@v0.0.0-20221209174356-61c833f34d98/discover/v5_udp.go:851 +0x58
  github.com/waku-org/go-waku/waku/v2/discv5.(*DiscoveryV5).SetBootnodes()
      /Users/roman/sources/waku-org/go-waku/waku/v2/discv5/discover.go:233 +0xb40
  github.com/waku-org/go-waku/waku/v2/discv5.TestDiscV5WithCapabilitiesFilter()
      /Users/roman/sources/waku-org/go-waku/waku/v2/discv5/discover_test.go:204 +0xae8
  testing.tRunner()
      /usr/local/go/src/testing/testing.go:1576 +0x188
  testing.(*T).Run.func1()
      /usr/local/go/src/testing/testing.go:1629 +0x40

Previous read at 0x00c00029abd0 by goroutine 809:
  github.com/waku-org/go-discover/discover.(*Table).loadSeedNodes()
      /Users/roman/go/pkg/mod/github.com/waku-org/go-discover@v0.0.0-20221209174356-61c833f34d98/discover/table.go:308 +0x1c4
  github.com/waku-org/go-discover/discover.(*Table).doRefresh()
      /Users/roman/go/pkg/mod/github.com/waku-org/go-discover@v0.0.0-20221209174356-61c833f34d98/discover/table.go:290 +0x60
  github.com/waku-org/go-discover/discover.(*Table).loop.func4()
      /Users/roman/go/pkg/mod/github.com/waku-org/go-discover@v0.0.0-20221209174356-61c833f34d98/discover/table.go:235 +0x40

Goroutine 562 (running) created at:
  testing.(*T).Run()
      /usr/local/go/src/testing/testing.go:1629 +0x5e4
  testing.runTests.func1()
      /usr/local/go/src/testing/testing.go:2036 +0x80
  testing.tRunner()
      /usr/local/go/src/testing/testing.go:1576 +0x188
  testing.runTests()
      /usr/local/go/src/testing/testing.go:2034 +0x700
  testing.(*M).Run()
      /usr/local/go/src/testing/testing.go:1906 +0x950
  main.main()
      _testmain.go:55 +0x300

Goroutine 809 (running) created at:
  github.com/waku-org/go-discover/discover.(*Table).loop()
      /Users/roman/go/pkg/mod/github.com/waku-org/go-discover@v0.0.0-20221209174356-61c833f34d98/discover/table.go:235 +0x1d8
  github.com/waku-org/go-discover/discover.ListenV5.func1()
      /Users/roman/go/pkg/mod/github.com/waku-org/go-discover@v0.0.0-20221209174356-61c833f34d98/discover/v5_udp.go:131 +0x34
==================
2024-03-19T09:37:03.671+0800    INFO    gowaku.discv5   discv5/discover.go:190  started Discovery V5    {"listening": "[::]:64765", "advertising": "127.0.0.1:51020"}
2024-03-19T09:37:03.671+0800    INFO    gowaku.discv5   discv5/discover.go:193  Discovery V5: discoverable ENR  {"enr": "enr:-Ji4QADxWtjVKTpAeByxUmTAJs1D5AH2XipUIP65HP4W4CFoa_uORbKzcxpB67euA0lZ65F5_LlYuuNKmd-fC2UNONyGAY5UWtiXgmlkgnY0gmlwhH8AAAGJc2VjcDI1NmsxoQJuqYb6dtvpUe4aD1PhKnLNixskzihi6UA9eow03u4DuIN0Y3CCx0yDdWRwgvz9hXdha3UyDQ"}
==================
WARNING: DATA RACE
Write at 0x00c001366a90 by goroutine 562:
  github.com/waku-org/go-discover/discover.(*Table).setFallbackNodes()
      /Users/roman/go/pkg/mod/github.com/waku-org/go-discover@v0.0.0-20221209174356-61c833f34d98/discover/table.go:196 +0x278
  github.com/waku-org/go-discover/discover.(*UDPv5).SetFallbackNodes()
      /Users/roman/go/pkg/mod/github.com/waku-org/go-discover@v0.0.0-20221209174356-61c833f34d98/discover/v5_udp.go:851 +0x58
  github.com/waku-org/go-waku/waku/v2/discv5.(*DiscoveryV5).SetBootnodes()
      /Users/roman/sources/waku-org/go-waku/waku/v2/discv5/discover.go:233 +0xc6c
  github.com/waku-org/go-waku/waku/v2/discv5.TestDiscV5WithCapabilitiesFilter()
      /Users/roman/sources/waku-org/go-waku/waku/v2/discv5/discover_test.go:210 +0xc14
  testing.tRunner()
      /usr/local/go/src/testing/testing.go:1576 +0x188
  testing.(*T).Run.func1()
      /usr/local/go/src/testing/testing.go:1629 +0x40

Previous read at 0x00c001366a90 by goroutine 837:
  github.com/waku-org/go-discover/discover.(*Table).loadSeedNodes()
      /Users/roman/go/pkg/mod/github.com/waku-org/go-discover@v0.0.0-20221209174356-61c833f34d98/discover/table.go:308 +0x1c4
  github.com/waku-org/go-discover/discover.(*Table).doRefresh()
      /Users/roman/go/pkg/mod/github.com/waku-org/go-discover@v0.0.0-20221209174356-61c833f34d98/discover/table.go:290 +0x60
  github.com/waku-org/go-discover/discover.(*Table).loop.func4()
      /Users/roman/go/pkg/mod/github.com/waku-org/go-discover@v0.0.0-20221209174356-61c833f34d98/discover/table.go:235 +0x40

Goroutine 562 (running) created at:
  testing.(*T).Run()
      /usr/local/go/src/testing/testing.go:1629 +0x5e4
  testing.runTests.func1()
      /usr/local/go/src/testing/testing.go:2036 +0x80
  testing.tRunner()
      /usr/local/go/src/testing/testing.go:1576 +0x188
  testing.runTests()
      /usr/local/go/src/testing/testing.go:2034 +0x700
  testing.(*M).Run()
      /usr/local/go/src/testing/testing.go:1906 +0x950
  main.main()
      _testmain.go:55 +0x300

Goroutine 837 (running) created at:
  github.com/waku-org/go-discover/discover.(*Table).loop()
      /Users/roman/go/pkg/mod/github.com/waku-org/go-discover@v0.0.0-20221209174356-61c833f34d98/discover/table.go:235 +0x1d8
  github.com/waku-org/go-discover/discover.ListenV5.func1()
      /Users/roman/go/pkg/mod/github.com/waku-org/go-discover@v0.0.0-20221209174356-61c833f34d98/discover/v5_udp.go:131 +0x34
==================
2024-03-19T09:37:05.687+0800    INFO    gowaku  discv5/discover_test.go:48  found peer  {"ID": "16Uiu2HAm5s1APDnSuEg22tXu2V39gNHDj5fjxxksTiNz7vND54Zf"}
2024-03-19T09:37:05.687+0800    INFO    gowaku  discv5/discover_test.go:51  found required number of nodes, stopping on demand discovery
2024-03-19T09:37:05.688+0800    WARN    gowaku.discv5   discv5/discover.go:487  Discv5 loop stopped
2024-03-19T09:37:05.688+0800    INFO    gowaku.discv5   discv5/discover.go:249  stopped Discovery V5
2024-03-19T09:37:05.688+0800    WARN    gowaku.discv5   discv5/discover.go:487  Discv5 loop stopped
2024-03-19T09:37:05.688+0800    INFO    gowaku.discv5   discv5/discover.go:249  stopped Discovery V5
2024-03-19T09:37:05.688+0800    INFO    gowaku.discv5   discv5/discover.go:249  stopped Discovery V5
2024-03-19T09:37:05.688+0800    WARN    gowaku.discv5   discv5/discover.go:487  Discv5 loop stopped
--- FAIL: TestDiscV5WithCapabilitiesFilter (2.14s)
    testing.go:1446: race detected during execution of test
2024-03-19T09:37:05.690+0800    WARN    p2p-config  config/config.go:304    rcmgr limit conflicts with connmgr limit: conn manager high watermark limit: 192, exceeds the system connection limit of: 1
2024-03-19T09:37:05.726+0800    WARN    p2p-config  config/config.go:304    rcmgr limit conflicts with connmgr limit: conn manager high watermark limit: 192, exceeds the system connection limit of: 1
2024-03-19T09:37:05.754+0800    WARN    p2p-config  config/config.go:304    rcmgr limit conflicts with connmgr limit: conn manager high watermark limit: 192, exceeds the system connection limit of: 1
2024-03-19T09:37:05.777+0800    INFO    gowaku.discv5   discv5/discover.go:190  started Discovery V5    {"listening": "[::]:52302", "advertising": "127.0.0.1:51021"}
2024-03-19T09:37:05.777+0800    INFO    gowaku.discv5   discv5/discover.go:193  Discovery V5: discoverable ENR  {"enr": "enr:-KG4QEzWnif5NhvE0--Ga8fWAf8QRloxmmDXZuw5pS0FUoZpY2oavZ72ZcKLi99K4M3zv-4ttCR_mFn3aQK_bBPgz-WGAY5UWuC9gmlkgnY0gmlwhH8AAAGCcnOFAAoBAAGJc2VjcDI1NmsxoQPfWGn6dZAHbJhI5uxGLv65fWkyi_RoFY8_OUNd-MKUO4N0Y3CCx02DdWRwgsxOhXdha3UyDw"}
2024-03-19T09:37:05.785+0800    INFO    gowaku.discv5   discv5/discover.go:190  started Discovery V5    {"listening": "[::]:65182", "advertising": "127.0.0.1:51022"}
2024-03-19T09:37:05.785+0800    INFO    gowaku.discv5   discv5/discover.go:193  Discovery V5: discoverable ENR  {"enr": "enr:-KG4QHwHvSIanQsnB5TSVSpQ8o4I84Q34K6AD4d5mfYN64l-VJFFAG4prwMaC8lE0xBBcsyx5OuuKrEih8ZYpE3EbGKGAY5UWuDYgmlkgnY0gmlwhH8AAAGCcnOFAAoBAAGJc2VjcDI1NmsxoQPQcgj_DVG-RyppImXqsbi8NBziR36CIyVSILdOGHYwpIN0Y3CCx06DdWRwgv6ehXdha3UyDQ"}
2024-03-19T09:37:05.791+0800    INFO    gowaku.discv5   discv5/discover.go:190  started Discovery V5    {"listening": "[::]:50711", "advertising": "127.0.0.1:51023"}
2024-03-19T09:37:05.791+0800    INFO    gowaku.discv5   discv5/discover.go:193  Discovery V5: discoverable ENR  {"enr": "enr:-Ji4QALWVM095LeMfWpH4Ubw3JEpWnZH0R6BTq-9cCW7nKWGF6U1-AWMraEIabUuhSgnzgewCi-JWJVaWfojODkUq06GAY5UWuDwgmlkgnY0gmlwhH8AAAGJc2VjcDI1NmsxoQLfQbboYQoCjRNfhYkYLkrrptjDmQRpC_z0KB2FFkTalIN0Y3CCx0-DdWRwgsYXhXdha3UyDQ"}
2024-03-19T09:37:07.793+0800    INFO    gowaku  discv5/discover_test.go:48  found peer  {"ID": "16Uiu2HAmTgqTh47j3J5FBYbAZF9CbLie2DgzdbFqBu31zzyHzG7U"}
2024-03-19T09:37:07.795+0800    INFO    gowaku  discv5/discover_test.go:48  found peer  {"ID": "16Uiu2HAmSgg1F96STd3vKnp91FAQNMD4AKVScSvZUmY2WdT1Qdrb"}
2024-03-19T09:37:07.795+0800    INFO    gowaku  discv5/discover_test.go:51  found required number of nodes, stopping on demand discovery
2024-03-19T09:37:07.797+0800    WARN    gowaku.discv5   discv5/discover.go:487  Discv5 loop stopped
2024-03-19T09:37:07.798+0800    INFO    gowaku.discv5   discv5/discover.go:249  stopped Discovery V5
2024-03-19T09:37:07.799+0800    WARN    gowaku.discv5   discv5/discover.go:487  Discv5 loop stopped
2024-03-19T09:37:07.800+0800    INFO    gowaku.discv5   discv5/discover.go:249  stopped Discovery V5
2024-03-19T09:37:07.801+0800    WARN    gowaku.discv5   discv5/discover.go:487  Discv5 loop stopped
2024-03-19T09:37:07.801+0800    INFO    gowaku.discv5   discv5/discover.go:249  stopped Discovery V5
2024-03-19T09:37:07.810+0800    WARN    p2p-config  config/config.go:304    rcmgr limit conflicts with connmgr limit: conn manager high watermark limit: 192, exceeds the system connection limit of: 1
2024-03-19T09:37:07.833+0800    WARN    p2p-config  config/config.go:304    rcmgr limit conflicts with connmgr limit: conn manager high watermark limit: 192, exceeds the system connection limit of: 1
2024-03-19T09:37:07.856+0800    WARN    p2p-config  config/config.go:304    rcmgr limit conflicts with connmgr limit: conn manager high watermark limit: 192, exceeds the system connection limit of: 1
2024-03-19T09:37:07.879+0800    INFO    gowaku.discv5   discv5/discover.go:190  started Discovery V5    {"listening": "[::]:55278", "advertising": "127.0.0.1:51024"}
2024-03-19T09:37:07.879+0800    INFO    gowaku.discv5   discv5/discover.go:193  Discovery V5: discoverable ENR  {"enr": "enr:-Ji4QDnNcUChRus6q4y6RueFK-xwrNnT71JM0g2_YJyojzy9OyBBJyY8Fd3XnlBQdkuP7QLqPEE0YQ-B0Er4cJHXp--GAY5UWuj4gmlkgnY0gmlwhH8AAAGJc2VjcDI1NmsxoQJv3K0-X3Jyki-OvdGIwY7LYjqfwOW4910CPw7XIFNOyIN0Y3CCx1CDdWRwgtfuhXdha3UyDw"}
2024-03-19T09:37:07.881+0800    INFO    gowaku.discv5   discv5/discover.go:190  started Discovery V5    {"listening": "[::]:54820", "advertising": "127.0.0.1:51025"}
2024-03-19T09:37:07.881+0800    INFO    gowaku.discv5   discv5/discover.go:193  Discovery V5: discoverable ENR  {"enr": "enr:-Ji4QJgJlTdzno9fu4S9zf-UGo7_iH2rKbb3qLxNyBjDZJ94MTPrHbZfwR6DwTHdb_ohQiIvJz_pr_KcpFHnklVsGQyGAY5UWukPgmlkgnY0gmlwhH8AAAGJc2VjcDI1NmsxoQNzX6w4xhpDD9QoyxYeEY_QYU-q2OQEH3Wap4aR1eiODoN0Y3CCx1GDdWRwgtYkhXdha3UyDw"}
2024-03-19T09:37:07.890+0800    INFO    gowaku.discv5   discv5/discover.go:190  started Discovery V5    {"listening": "[::]:60904", "advertising": "127.0.0.1:51026"}
2024-03-19T09:37:07.890+0800    INFO    gowaku.discv5   discv5/discover.go:193  Discovery V5: discoverable ENR  {"enr": "enr:-Ji4QMObeaFxJpmKIxbewVQDmocJBNy60DkdKm8_z_hB6jPmBtWbBIkkdQ3EGtEvMX_gzKYtLMeplRQ6ZO_kdUnl_DKGAY5UWukngmlkgnY0gmlwhH8AAAGJc2VjcDI1NmsxoQNl2XJY01Dj_sYbnRlX-dHG79Mo9TE6g7g3YOm5yYzSx4N0Y3CCx1KDdWRwgu3ohXdha3UyDw"}
2024-03-19T09:37:09.890+0800    INFO    gowaku.discv5   discv5/discover.go:249  stopped Discovery V5
2024-03-19T09:37:09.891+0800    WARN    gowaku.discv5   discv5/discover.go:487  Discv5 loop stopped
2024-03-19T09:37:09.893+0800    WARN    gowaku.discv5   discv5/discover.go:487  Discv5 loop stopped
2024-03-19T09:37:09.893+0800    INFO    gowaku.discv5   discv5/discover.go:249  stopped Discovery V5
2024-03-19T09:37:09.893+0800    WARN    gowaku.discv5   discv5/discover.go:487  Discv5 loop stopped
2024-03-19T09:37:09.893+0800    INFO    gowaku.discv5   discv5/discover.go:249  stopped Discovery V5
FAIL
exit status 1
FAIL    github.com/waku-org/go-waku/waku/v2/discv5  11.106s
romanzac commented 7 months ago

Issue belongs to https://github.com/waku-org/go-waku/pull/1051

chaitanyaprem commented 7 months ago

Have race condition treated or remove SetBootnodes() feature, as I saw it is not used and it is a bit counterintuitive.

I kind of agree with having SetBooNodes after starting discv5 may not be intutive, but wondering if this race condition actually causes any issues. The read is done in a doRefresh method which seems to be called in a loop, so the bootNodes would be used in the next iteration of the loop and hence this should not cause any functional issue.

cc @richard-ramos

richard-ramos commented 7 months ago

For context, this function was added with the purpose of being used in status-go, in https://github.com/status-im/status-go/blob/develop/wakuv2/waku.go#L1686, because it was found that sometimes DNS Discovery failed to return the bootnodes.

Status-go has a loop which periodically attempts to retrieve bootnodes https://github.com/status-im/status-go/blob/develop/wakuv2/waku.go#L1583-L1615 and once it does, it will then execute SetBootnodes.

As @chaitanyaprem this race condition shouldn't cause issues as the values set on the table nursery table of discv5 will be read in next iteration, but just for the sake of not having this issue pop up in the CI, i'll protect the nursery attr with the mutex