Repository: libp2p/go-libp2p
Pull request #3252 (2025-03-25 19:22:10)

peerstore: remove unused badger tests
We are testing with both badger and LevelDB. Removing badger as just testing with LevelDB should be enough. Not sure if we need LevelDB  either, but for now just removing badger as it is any way unused.

See: #3250


Patch:
diff --git a/config/config.go b/config/config.go
index 607dceba..b5d42eed 100644
--- a/config/config.go
+++ b/config/config.go
@@ -292,11 +292,11 @@ func (cfg *Config) addTransports() ([]fx.Option, error) {
 		fx.Provide(func() connmgr.ConnectionGater { return cfg.ConnectionGater }),
 		fx.Provide(func() pnet.PSK { return cfg.PSK }),
 		fx.Provide(func() network.ResourceManager { return cfg.ResourceManager }),
-		fx.Provide(func(upgrader transport.Upgrader) *tcpreuse.ConnMgr {
+		fx.Provide(func(gater connmgr.ConnectionGater, rcmgr network.ResourceManager) *tcpreuse.ConnMgr {
 			if !cfg.ShareTCPListener {
 				return nil
 			}
-			return tcpreuse.NewConnMgr(tcpreuse.EnvReuseportVal, upgrader)
+			return tcpreuse.NewConnMgr(tcpreuse.EnvReuseportVal, gater, rcmgr)
 		}),
 		fx.Provide(func(cm *quicreuse.ConnManager, sw *swarm.Swarm) libp2pwebrtc.ListenUDPFn {
 			hasQuicAddrPortFor := func(network string, laddr *net.UDPAddr) bool {
diff --git a/core/transport/transport.go b/core/transport/transport.go
index e9e59b67..908fc5b3 100644
--- a/core/transport/transport.go
+++ b/core/transport/transport.go
@@ -129,41 +129,11 @@ type TransportNetwork interface {
 	AddTransport(t Transport) error
 }
 
-// GatedMaListener is listener that listens for raw(unsecured and non-multiplexed) incoming connections,
-// gates them with a `connmgr.ConnGater`and creates a resource management scope for them.
-// It can be upgraded to a full libp2p transport listener by the Upgrader.
-//
-// Compared to manet.Listener, this listener creates the resource management scope for the accepted connection.
-type GatedMaListener interface {
-	// Accept waits for and returns the next connection to the listener.
-	Accept() (manet.Conn, network.ConnManagementScope, error)
-
-	// Close closes the listener.
-	// Any blocked Accept operations will be unblocked and return errors.
-	Close() error
-
-	// Multiaddr returns the listener's (local) Multiaddr.
-	Multiaddr() ma.Multiaddr
-
-	// Addr returns the net.Listener's network address.
-	Addr() net.Addr
-}
-
 // Upgrader is a multistream upgrader that can upgrade an underlying connection
 // to a full transport connection (secure and multiplexed).
 type Upgrader interface {
 	// UpgradeListener upgrades the passed multiaddr-net listener into a full libp2p-transport listener.
-	//
-	// Deprecated: Use UpgradeGatedMaListener(upgrader.GateMaListener(manet.Listener)) instead.
 	UpgradeListener(Transport, manet.Listener) Listener
-
-	// GateMaListener creates a GatedMaListener from a manet.Listener. It gates the accepted connection
-	// and creates a resource scope for it.
-	GateMaListener(manet.Listener) GatedMaListener
-
-	// UpgradeGatedMaListener upgrades the passed GatedMaListener into a full libp2p-transport listener.
-	UpgradeGatedMaListener(Transport, GatedMaListener) Listener
-
 	// Upgrade upgrades the multiaddr/net connection into a full libp2p-transport connection.
 	Upgrade(ctx context.Context, t Transport, maconn manet.Conn, dir network.Direction, p peer.ID, scope network.ConnManagementScope) (CapableConn, error)
 }
diff --git a/examples/autotls/main.go b/examples/autotls/main.go
index f3a81247..0caa39d8 100644
--- a/examples/autotls/main.go
+++ b/examples/autotls/main.go
@@ -58,9 +58,6 @@ func main() {
 		// User-Agent to use during DNS-01 ACME challenge
 		p2pforge.WithUserAgent(userAgent),
 
-		// Optional extra delay before the initial registration
-		p2pforge.WithRegistrationDelay(10*time.Second),
-
 		// Optional hook called once certificate is ready
 		p2pforge.WithOnCertLoaded(func() {
 			certLoaded <- true
@@ -133,6 +130,9 @@ func main() {
 
 	go dht.Bootstrap(ctx)
 
+	// Wait for peers to verify public address with AutoNAT
+	time.Sleep(5 * time.Second)
+
 	logger.Info("Addresses: ", h.Addrs())
 
 	certManager.ProvideHost(h)
diff --git a/examples/go.mod b/examples/go.mod
index 9fa9d465..997eca92 100644
--- a/examples/go.mod
+++ b/examples/go.mod
@@ -8,7 +8,7 @@ require (
 	github.com/google/uuid v1.6.0
 	github.com/ipfs/go-datastore v0.6.0
 	github.com/ipfs/go-log/v2 v2.5.1
-	github.com/ipshipyard/p2p-forge v0.4.0
+	github.com/ipshipyard/p2p-forge v0.3.1
 	github.com/libp2p/go-libp2p v0.38.2
 	github.com/libp2p/go-libp2p-kad-dht v0.28.1
 	github.com/multiformats/go-multiaddr v0.14.0
@@ -138,7 +138,7 @@ require (
 	golang.org/x/time v0.8.0 // indirect
 	golang.org/x/tools v0.29.0 // indirect
 	gonum.org/v1/gonum v0.15.1 // indirect
-	google.golang.org/protobuf v1.36.5 // indirect
+	google.golang.org/protobuf v1.36.4 // indirect
 	gopkg.in/yaml.v3 v3.0.1 // indirect
 	lukechampine.com/blake3 v1.3.0 // indirect
 )
diff --git a/examples/go.sum b/examples/go.sum
index c057212f..8279eed5 100644
--- a/examples/go.sum
+++ b/examples/go.sum
@@ -160,8 +160,8 @@ github.com/ipfs/go-test v0.0.4 h1:DKT66T6GBB6PsDFLoO56QZPrOmzJkqU1FZH5C9ySkew=
 github.com/ipfs/go-test v0.0.4/go.mod h1:qhIM1EluEfElKKM6fnWxGn822/z9knUGM1+I/OAQNKI=
 github.com/ipld/go-ipld-prime v0.21.0 h1:n4JmcpOlPDIxBcY037SVfpd1G+Sj1nKZah0m6QH9C2E=
 github.com/ipld/go-ipld-prime v0.21.0/go.mod h1:3RLqy//ERg/y5oShXXdx5YIp50cFGOanyMctpPjsvxQ=
-github.com/ipshipyard/p2p-forge v0.4.0 h1:A40PW027nCZn0d/pw5ufMoxnAo9wZwrG+iuz18A8P5I=
-github.com/ipshipyard/p2p-forge v0.4.0/go.mod h1:hVGPP24xrRezP2+z6q8udEW36w89M+jWuWBz9meLggY=
+github.com/ipshipyard/p2p-forge v0.3.1 h1:Vr0l6wzX4zL7l8+UHJlsRBNHmlHpP3c//NrCZeGj4KU=
+github.com/ipshipyard/p2p-forge v0.3.1/go.mod h1:XQAvFJeXGo4oiyVPXkC3cph//5kF785L5Pjd3/kWFWo=
 github.com/jackpal/go-nat-pmp v1.0.2 h1:KzKSgb7qkJvOUTqYl9/Hg/me3pWgBmERKrTGD7BdWus=
 github.com/jackpal/go-nat-pmp v1.0.2/go.mod h1:QPH045xvCAeXUZOxsnwmrtiCoxIr9eob+4orBN1SBKc=
 github.com/jbenet/go-cienv v0.1.0/go.mod h1:TqNnHUmJgXau0nCzC7kXWeotg3J9W34CUv5Djy1+FlA=
@@ -651,8 +651,8 @@ google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2
 google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
 google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
 google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
-google.golang.org/protobuf v1.36.5 h1:tPhr+woSbjfYvY6/GPufUoYizxw1cF/yFoxJ2fmpwlM=
-google.golang.org/protobuf v1.36.5/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
+google.golang.org/protobuf v1.36.4 h1:6A3ZDJHn/eNqc1i+IdefRzy/9PokBTPvcqMySR7NNIM=
+google.golang.org/protobuf v1.36.4/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
 gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
 gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
 gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
diff --git a/go.mod b/go.mod
index 07da9bf2..200a5143 100644
--- a/go.mod
+++ b/go.mod
@@ -18,7 +18,6 @@ require (
 	github.com/huin/goupnp v1.3.0
 	github.com/ipfs/go-cid v0.5.0
 	github.com/ipfs/go-datastore v0.6.0
-	github.com/ipfs/go-ds-badger v0.3.0
 	github.com/ipfs/go-ds-leveldb v0.5.0
 	github.com/ipfs/go-log/v2 v2.5.1
 	github.com/jackpal/go-nat-pmp v1.0.2
@@ -70,17 +69,11 @@ require (
 )
 
 require (
-	github.com/AndreasBriese/bbloom v0.0.0-20190825152654-46b345b51c96 // indirect
 	github.com/beorn7/perks v1.0.1 // indirect
-	github.com/cespare/xxhash v1.1.0 // indirect
 	github.com/cespare/xxhash/v2 v2.3.0 // indirect
 	github.com/davecgh/go-spew v1.1.1 // indirect
-	github.com/dgraph-io/badger v1.6.2 // indirect
-	github.com/dgraph-io/ristretto v0.0.2 // indirect
-	github.com/dustin/go-humanize v1.0.0 // indirect
 	github.com/francoispqt/gojay v1.2.13 // indirect
 	github.com/go-task/slim-sprig/v3 v3.0.0 // indirect
-	github.com/golang/protobuf v1.5.3 // indirect
 	github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db // indirect
 	github.com/google/pprof v0.0.0-20250208200701-d0013a598941 // indirect
 	github.com/google/uuid v1.6.0 // indirect
@@ -107,7 +100,6 @@ require (
 	github.com/pion/transport/v2 v2.2.10 // indirect
 	github.com/pion/transport/v3 v3.0.7 // indirect
 	github.com/pion/turn/v4 v4.0.0 // indirect
-	github.com/pkg/errors v0.9.1 // indirect
 	github.com/pmezard/go-difflib v1.0.0 // indirect
 	github.com/prometheus/common v0.62.0 // indirect
 	github.com/prometheus/procfs v0.15.1 // indirect
diff --git a/go.sum b/go.sum
index fccd1bad..23e1a7c5 100644
--- a/go.sum
+++ b/go.sum
@@ -7,13 +7,8 @@ dmitri.shuralyov.com/html/belt v0.0.0-20180602232347-f7d459c86be0/go.mod h1:JLBr
 dmitri.shuralyov.com/service/change v0.0.0-20181023043359-a85b471d5412/go.mod h1:a1inKt/atXimZ4Mv927x+r7UpyzRUf4emIoiiSC2TN4=
 dmitri.shuralyov.com/state v0.0.0-20180228185332-28bcc343414c/go.mod h1:0PRwlb0D6DFvNNtx+9ybjezNCa8XF0xaYcETyp6rHWU=
 git.apache.org/thrift.git v0.0.0-20180902110319-2566ecd5d999/go.mod h1:fPE2ZNJGynbRyZ4dJvy6G277gSllfV2HJqblrnkyeyg=
-github.com/AndreasBriese/bbloom v0.0.0-20190825152654-46b345b51c96 h1:cTp8I5+VIoKjsnZuH8vjyaysT/ses3EvZeaV/1UkF2M=
-github.com/AndreasBriese/bbloom v0.0.0-20190825152654-46b345b51c96/go.mod h1:bOvUY6CB00SOBii9/FifXqc0awNKxLFCL/+pkDPuyl8=
 github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
-github.com/OneOfOne/xxhash v1.2.2 h1:KMrpdQIwFcEqXDklaen+P1axHaj9BSKzvpUUfnHldSE=
-github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
 github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c=
-github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
 github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
 github.com/benbjohnson/clock v1.3.5 h1:VvXlSJBzZpA/zum6Sj74hxwYI2DIxRWuNIoXAzHZz5o=
 github.com/benbjohnson/clock v1.3.5/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
@@ -22,16 +17,10 @@ github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
 github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
 github.com/bradfitz/go-smtpd v0.0.0-20170404230938-deb6d6237625/go.mod h1:HYsPBTaaSFSlLx/70C2HPIMNZpVV8+vt/A+FMnYP11g=
 github.com/buger/jsonparser v0.0.0-20181115193947-bf1c66bbce23/go.mod h1:bbYlZJ7hK1yFx9hf58LP0zeX7UjIGs20ufpu3evjr+s=
-github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko=
-github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
 github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
 github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
 github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
-github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
-github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk=
-github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
 github.com/coreos/go-systemd v0.0.0-20181012123002-c6f51f82210d/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
-github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE=
 github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
 github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
 github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
@@ -41,13 +30,6 @@ github.com/decred/dcrd/crypto/blake256 v1.1.0 h1:zPMNGQCm0g4QTY27fOCorQW7EryeQ/U
 github.com/decred/dcrd/crypto/blake256 v1.1.0/go.mod h1:2OfgNZ5wDpcsFmHmCK5gZTPcCXqlm2ArzUIkw9czNJo=
 github.com/decred/dcrd/dcrec/secp256k1/v4 v4.4.0 h1:NMZiJj8QnKe1LgsbDayM4UoHwbvwDRwnI3hwNaAHRnc=
 github.com/decred/dcrd/dcrec/secp256k1/v4 v4.4.0/go.mod h1:ZXNYxsqcloTdSy/rNShjYzMhyjf0LaoftYK0p+A3h40=
-github.com/dgraph-io/badger v1.6.2 h1:mNw0qs90GVgGGWylh0umH5iag1j6n/PeJtNvL6KY/x8=
-github.com/dgraph-io/badger v1.6.2/go.mod h1:JW2yswe3V058sS0kZ2h/AXeDSqFjxnZcRrVH//y2UQE=
-github.com/dgraph-io/ristretto v0.0.2 h1:a5WaUrDa0qm0YrAAS1tUykT5El3kt62KNZZeMxQn3po=
-github.com/dgraph-io/ristretto v0.0.2/go.mod h1:KPxhHT9ZxKefz+PCeOGsrHpl1qZ7i70dGTu2u+Ahh6E=
-github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2 h1:tdlZCpZ/P9DhczCTSixgIKmwPv6+wP5DGjqLYw5SUiA=
-github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw=
-github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo=
 github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
 github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc=
 github.com/flynn/noise v1.1.0 h1:KjPQoQCEFdZDiP03phOvGi11+SVVhBG2wOWAorLsstg=
@@ -71,14 +53,10 @@ github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfb
 github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
 github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
 github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
-github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
-github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg=
-github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
 github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db h1:woRePGFeVFfLKN/pOkfl+p/TAqKOfFu+7KPlMVpok/w=
 github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
 github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
 github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
-github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
 github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
 github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
 github.com/google/go-github v17.0.0+incompatible/go.mod h1:zLgOLi98H3fifZn+44m+umXrS52loVEgC2AApnigrVQ=
@@ -104,11 +82,9 @@ github.com/hashicorp/golang-lru/arc/v2 v2.0.7 h1:QxkVTxwColcduO+LP7eJO56r2hFiG8z
 github.com/hashicorp/golang-lru/arc/v2 v2.0.7/go.mod h1:Pe7gBlGdc8clY5LJ0LpJXMt5AmgmWNH1g+oFFVUHOEc=
 github.com/hashicorp/golang-lru/v2 v2.0.7 h1:a+bsQ5rvGLjzHuww6tVxozPZFVghXaHOwFs4luLUK2k=
 github.com/hashicorp/golang-lru/v2 v2.0.7/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM=
-github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
 github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
 github.com/huin/goupnp v1.3.0 h1:UvLUlWDNpoUdYzb2TCn+MuTWtcjXKSza2n6CBdQ0xXc=
 github.com/huin/goupnp v1.3.0/go.mod h1:gnGPsThkYa7bFi/KWmEysQRf48l2dvR5bxr2OFckNX8=
-github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
 github.com/ipfs/go-cid v0.5.0 h1:goEKKhaGm0ul11IHA7I6p1GmKz8kEYniqFopaB5Otwg=
 github.com/ipfs/go-cid v0.5.0/go.mod h1:0L7vmeNXpQpUS9vt+yEARkJ8rOg43DF3iPgn4GIN0mk=
 github.com/ipfs/go-datastore v0.5.0/go.mod h1:9zhEApYMTl17C8YDp7JmU7sQZi2/wqiYh73hakZ90Bk=
@@ -116,12 +92,9 @@ github.com/ipfs/go-datastore v0.6.0 h1:JKyz+Gvz1QEZw0LsX1IBn+JFCJQH4SJVFtM4uWU0M
 github.com/ipfs/go-datastore v0.6.0/go.mod h1:rt5M3nNbSO/8q1t4LNkLyUwRs8HupMeN/8O4Vn9YAT8=
 github.com/ipfs/go-detect-race v0.0.1 h1:qX/xay2W3E4Q1U7d9lNs1sU9nvguX0a7319XbyQ6cOk=
 github.com/ipfs/go-detect-race v0.0.1/go.mod h1:8BNT7shDZPo99Q74BpGMK+4D8Mn4j46UU0LZ723meps=
-github.com/ipfs/go-ds-badger v0.3.0 h1:xREL3V0EH9S219kFFueOYJJTcjgNSZ2HY1iSvN7U1Ro=
-github.com/ipfs/go-ds-badger v0.3.0/go.mod h1:1ke6mXNqeV8K3y5Ak2bAA0osoTfmxUdupVCGm4QUIek=
 github.com/ipfs/go-ds-leveldb v0.5.0 h1:s++MEBbD3ZKc9/8/njrn4flZLnCuY9I79v94gBUNumo=
 github.com/ipfs/go-ds-leveldb v0.5.0/go.mod h1:d3XG9RUDzQ6V4SHi8+Xgj9j1XuEk1z82lquxrVbml/Q=
 github.com/ipfs/go-ipfs-delay v0.0.0-20181109222059-70721b86a9a8/go.mod h1:8SP1YXK1M1kXuc4KJZINY3TQQ03J2rwBG9QfXmbRPrw=
-github.com/ipfs/go-log/v2 v2.0.5/go.mod h1:eZs4Xt4ZUJQFM3DlanGhy7TkwwawCZcSByscwkWG+dw=
 github.com/ipfs/go-log/v2 v2.5.1 h1:1XdUzF7048prq4aBjDQQ4SL5RxftpRGdXhNRwKSAlcY=
 github.com/ipfs/go-log/v2 v2.5.1/go.mod h1:prSpmC1Gpllc9UYWxDiZDreBYw7zp4Iqp1kOLU9U5UI=
 github.com/jackpal/go-nat-pmp v1.0.2 h1:KzKSgb7qkJvOUTqYl9/Hg/me3pWgBmERKrTGD7BdWus=
@@ -170,7 +143,6 @@ github.com/libp2p/go-yamux/v5 v5.0.0/go.mod h1:en+3cdX51U0ZslwRdRLrvQsdayFt3TSUK
 github.com/libp2p/zeroconf/v2 v2.2.0 h1:Cup06Jv6u81HLhIj1KasuNM/RHHrJ8T7wOTS4+Tv53Q=
 github.com/libp2p/zeroconf/v2 v2.2.0/go.mod h1:fuJqLnUwZTshS3U/bMRJ3+ow/v9oid1n0DmyYyNO1Xs=
 github.com/lunixbochs/vtclean v1.0.0/go.mod h1:pHhQNgMf3btfWnGBVipUOjRYhoOsdGqdm/+2c2E2WMI=
-github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
 github.com/mailru/easyjson v0.0.0-20190312143242-1de009706dbe/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
 github.com/marten-seemann/tcp v0.0.0-20210406111302-dfbc87cc63fd h1:br0buuQ854V8u83wA0rVZ8ttrq5CpaPZdvrK0LP2lOk=
 github.com/marten-seemann/tcp v0.0.0-20210406111302-dfbc87cc63fd/go.mod h1:QuCEs1Nt24+FYQEqAAncTDPJIuGs+LxK1MCiFL25pMU=
@@ -192,8 +164,6 @@ github.com/minio/blake2b-simd v0.0.0-20160723061019-3f5f724cb5b1/go.mod h1:pD8Rv
 github.com/minio/sha256-simd v0.1.1-0.20190913151208-6de447530771/go.mod h1:B5e1o+1/KgNmWrSQK08Y6Z1Vb5pwIktudl0J58iy0KM=
 github.com/minio/sha256-simd v1.0.1 h1:6kaan5IFmwTNynnKKpDHe6FWHohJOHhCPchzK49dzMM=
 github.com/minio/sha256-simd v1.0.1/go.mod h1:Pz6AKMiUdngCLpeTL/RJY1M9rUuPMYujV5xJjtbRSN8=
-github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
-github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
 github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
 github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
 github.com/mr-tron/base58 v1.1.2/go.mod h1:BinMc/sQntlIE1frQmRFPUoPA1Zkr8VRgBdjWI2mNwc=
@@ -239,7 +209,6 @@ github.com/onsi/gomega v1.36.2/go.mod h1:DdwyADRjrc825LhMEkD76cHR5+pUnjhUN8GlHlR
 github.com/openzipkin/zipkin-go v0.1.1/go.mod h1:NtoC/o8u3JlF1lSlyPNswIbeQH9bJTmOf0Erfk+hxe8=
 github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58 h1:onHthvaw9LFnH4t2DcNVpwGmV9E1BkGknEliJkfwQj0=
 github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58/go.mod h1:DXv8WO4yhMYhSNPKjeNKa5WY9YCIEBRbNzFFPJbWO6Y=
-github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
 github.com/pion/datachannel v1.5.10 h1:ly0Q26K1i6ZkGf42W7D4hQYR90pZwzFOjTq5AuCKk4o=
 github.com/pion/datachannel v1.5.10/go.mod h1:p/jJfC9arb29W7WrxyKbepTU20CFgyx5oLo8Rs4Py/M=
 github.com/pion/dtls/v2 v2.2.7/go.mod h1:8WiMkebSHFD0T+dIU+UeBaoV7kDhOW5oDCzZ7WZ/F9s=
@@ -283,8 +252,6 @@ github.com/pion/turn/v4 v4.0.0/go.mod h1:MuPDkm15nYSklKpN8vWJ9W2M0PlyQZqYt1McGux
 github.com/pion/webrtc/v4 v4.0.10 h1:Hq/JLjhqLxi+NmCtE8lnRPDr8H4LcNvwg8OxVcdv56Q=
 github.com/pion/webrtc/v4 v4.0.10/go.mod h1:ViHLVaNpiuvaH8pdiuQxuA9awuE6KVzAXx3vVWilOck=
 github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
-github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
-github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
 github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
 github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
 github.com/prometheus/client_golang v0.8.0/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
@@ -334,21 +301,13 @@ github.com/shurcooL/users v0.0.0-20180125191416-49c67e49c537/go.mod h1:QJTqeLYED
 github.com/shurcooL/webdavfs v0.0.0-20170829043945-18c3829fa133/go.mod h1:hKmq5kWdCj2z2KEozexVbfEZIWiTjhE0+UjmZgPqehw=
 github.com/sourcegraph/annotate v0.0.0-20160123013949-f4cad6c6324d/go.mod h1:UdhH50NIW0fCiwBSr0co2m7BnFLdv4fQTgdqdJTHFeE=
 github.com/sourcegraph/syntaxhighlight v0.0.0-20170531221838-bd320f5d308e/go.mod h1:HuIsMU8RRBOtsCgI77wP899iHVBQpCmg4ErYMZB+2IA=
-github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
 github.com/spaolacci/murmur3 v1.1.0 h1:7c1g84S4BPRrfL5Xrdp6fOJ206sU9y293DDHaoy0bLI=
 github.com/spaolacci/murmur3 v1.1.0/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
-github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ=
-github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
-github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU=
-github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo=
-github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
-github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s=
 github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
 github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
 github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
 github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
 github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
-github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
 github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
 github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
 github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
@@ -359,13 +318,11 @@ github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf
 github.com/syndtr/goleveldb v1.0.0 h1:fBdIW9lB4Iz0n9khmH8w27SJ3QEJ7+IgjPEwGSZiFdE=
 github.com/syndtr/goleveldb v1.0.0/go.mod h1:ZVVdQEZoIme9iO1Ch2Jdy24qqXrMMOU6lpPAyBWyWuQ=
 github.com/tarm/serial v0.0.0-20180830185346-98f6abe2eb07/go.mod h1:kDXzergiv9cbyO7IOYJZWg1U88JhDg3PB6klq9Hg2pA=
-github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0=
 github.com/viant/assertly v0.4.8/go.mod h1:aGifi++jvCrUaklKEKT0BU95igDNaqkvz+49uaYMPRU=
 github.com/viant/toolbox v0.24.0/go.mod h1:OxMCG57V0PXuIP2HNQrtJf2CjqdmbrOx5EkMILuUhzM=
 github.com/wlynxg/anet v0.0.3/go.mod h1:eay5PRQr7fIVAMbTbchTnO9gG65Hg/uYGdc7mguHxoA=
 github.com/wlynxg/anet v0.0.5 h1:J3VJGi1gvo0JwZ/P1/Yc/8p63SoW98B5dHkYDmpgvvU=
 github.com/wlynxg/anet v0.0.5/go.mod h1:eay5PRQr7fIVAMbTbchTnO9gG65Hg/uYGdc7mguHxoA=
-github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
 github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
 github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
 go.opencensus.io v0.18.0/go.mod h1:vKdFvxhtzZ9onBp9VKHK8z/sRpBMnKAsufL7wlDrCOA=
@@ -385,14 +342,12 @@ go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9i
 go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
 go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
 go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9Ejo0C68/HhF8uaILCdgjnY+goOA=
-go.uber.org/zap v1.14.1/go.mod h1:Mb2vm2krFEG5DV0W9qcHBYFtp/Wku1cvYaqPsS/WYfc=
 go.uber.org/zap v1.19.1/go.mod h1:j3DNczoxDZroyBnOT1L/Q79cfUMGZxlv/9dzN7SM1rI=
 go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8=
 go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E=
 go4.org v0.0.0-20180809161055-417644f6feb5/go.mod h1:MkTOUMDaeVYJUOUsaDXIhWPZYa1yOyC1qaOBpL57BhE=
 golang.org/x/build v0.0.0-20190111050920-041ab4dc3f9d/go.mod h1:OWs+y06UdEOHN4y+MfF/py+xQ/tYqIWW03b70/CG9Rw=
 golang.org/x/crypto v0.0.0-20181030102418-4d3f4d9ffa16/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
-golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
 golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
 golang.org/x/crypto v0.0.0-20190313024323-a1f597ede03a/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
 golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
@@ -462,11 +417,9 @@ golang.org/x/sync v0.11.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
 golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
 golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
 golang.org/x/sys v0.0.0-20181029174526-d69651ed3497/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
-golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
 golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
 golang.org/x/sys v0.0.0-20190316082340-a2f829d7f35f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-golang.org/x/sys v0.0.0-20190626221950-04f50cda93cb/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 golang.org/x/sys v0.0.0-20200602225109-6fdc65e7d980/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 golang.org/x/sys v0.0.0-20210303074136-134d130e1a04/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
@@ -527,7 +480,6 @@ golang.org/x/tools v0.30.0 h1:BgcpHewrV5AUp2G9MebG4XPFI1E2W41zU1SaqVA9vJY=
 golang.org/x/tools v0.30.0/go.mod h1:c347cR/OJfw5TI+GfX7RUPNMdDRRbjvYTS0jPyvsVtY=
 golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
 golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
-golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
 golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
 google.golang.org/api v0.0.0-20180910000450-7ca32eb868bf/go.mod h1:4mhQ8q/RsB7i+udVvVy5NUi08OU8ZlA0gRVgrF7VFY0=
 google.golang.org/api v0.0.0-20181030000543-1d582fd0359e/go.mod h1:4mhQ8q/RsB7i+udVvVy5NUi08OU8ZlA0gRVgrF7VFY0=
@@ -545,8 +497,6 @@ google.golang.org/grpc v1.14.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmE
 google.golang.org/grpc v1.16.0/go.mod h1:0JHn/cJsOMiMfNA9+DeHDlAU7KAAB5GDlYFpa9MZMio=
 google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs=
 google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
-google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
-google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
 google.golang.org/protobuf v1.36.5 h1:tPhr+woSbjfYvY6/GPufUoYizxw1cF/yFoxJ2fmpwlM=
 google.golang.org/protobuf v1.36.5/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
 gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
diff --git a/p2p/net/upgrader/listener.go b/p2p/net/upgrader/listener.go
index 07abece2..55783f01 100644
--- a/p2p/net/upgrader/listener.go
+++ b/p2p/net/upgrader/listener.go
@@ -6,7 +6,6 @@ import (
 	"strings"
 	"sync"
 
-	"github.com/libp2p/go-libp2p/core/connmgr"
 	"github.com/libp2p/go-libp2p/core/network"
 	"github.com/libp2p/go-libp2p/core/transport"
 
@@ -18,7 +17,7 @@ import (
 var log = logging.Logger("upgrader")
 
 type listener struct {
-	transport.GatedMaListener
+	manet.Listener
 
 	transport transport.Transport
 	upgrader  *upgrader
@@ -36,12 +35,10 @@ type listener struct {
 	cancel func()
 }
 
-var _ transport.Listener = (*listener)(nil)
-
 // Close closes the listener.
 func (l *listener) Close() error {
 	// Do this first to try to get any relevant errors.
-	err := l.GatedMaListener.Close()
+	err := l.Listener.Close()
 
 	l.cancel()
 	// Drain and wait.
@@ -64,7 +61,7 @@ func (l *listener) handleIncoming() {
 	var wg sync.WaitGroup
 	defer func() {
 		// make sure we're closed
-		l.GatedMaListener.Close()
+		l.Listener.Close()
 		if l.err == nil {
 			l.err = fmt.Errorf("listener closed")
 		}
@@ -75,7 +72,7 @@ func (l *listener) handleIncoming() {
 
 	var catcher tec.TempErrCatcher
 	for l.ctx.Err() == nil {
-		maconn, connScope, err := l.GatedMaListener.Accept()
+		maconn, err := l.Listener.Accept()
 		if err != nil {
 			// Note: function may pause the accept loop.
 			if catcher.IsTemporary(err) {
@@ -87,10 +84,33 @@ func (l *listener) handleIncoming() {
 		}
 		catcher.Reset()
 
+		// Check if we already have a connection scope. See the comment in tcpreuse/listener.go for an explanation.
+		var connScope network.ConnManagementScope
+		if sc, ok := maconn.(interface {
+			Scope() network.ConnManagementScope
+		}); ok {
+			connScope = sc.Scope()
+		}
 		if connScope == nil {
-			log.Errorf("BUG: got nil connScope for incoming connection from %s", maconn.RemoteMultiaddr())
-			maconn.Close()
-			continue
+			// gate the connection if applicable
+			if l.upgrader.connGater != nil && !l.upgrader.connGater.InterceptAccept(maconn) {
+				log.Debugf("gater blocked incoming connection on local addr %s from %s",
+					maconn.LocalMultiaddr(), maconn.RemoteMultiaddr())
+				if err := maconn.Close(); err != nil {
+					log.Warnf("failed to close incoming connection rejected by gater: %s", err)
+				}
+				continue
+			}
+
+			var err error
+			connScope, err = l.rcmgr.OpenConnection(network.DirInbound, true, maconn.RemoteMultiaddr())
+			if err != nil {
+				log.Debugw("resource manager blocked accept of new connection", "error", err)
+				if err := maconn.Close(); err != nil {
+					log.Warnf("failed to open incoming connection. Rejected by resource manager: %s", err)
+				}
+				continue
+			}
 		}
 
 		// The go routine below calls Release when the context is
@@ -134,10 +154,14 @@ func (l *listener) handleIncoming() {
 			select {
 			case l.incoming <- conn:
 			case <-ctx.Done():
-				// Listener not closed but the accept timeout expired.
 				if l.ctx.Err() == nil {
-					log.Warnf("listener dropped connection due to slow accept. remote addr: %s peer: %s", maconn.RemoteMultiaddr(), conn.RemotePeer())
+					// Listener *not* closed but the accept timeout expired.
+					log.Warn("listener dropped connection due to slow accept")
 				}
+				// Wait on the context with a timeout. This way,
+				// if we stop accepting connections for some reason,
+				// we'll eventually close all the open ones
+				// instead of hanging onto them.
 				conn.CloseWithError(network.ConnRateLimited)
 			}
 		}()
@@ -165,38 +189,4 @@ func (l *listener) String() string {
 	return fmt.Sprintf("<stream.Listener %s>", l.Multiaddr())
 }
 
-type gatedMaListener struct {
-	manet.Listener
-	rcmgr     network.ResourceManager
-	connGater connmgr.ConnectionGater
-}
-
-var _ transport.GatedMaListener = &gatedMaListener{}
-
-func (l *gatedMaListener) Accept() (manet.Conn, network.ConnManagementScope, error) {
-	for {
-		conn, err := l.Listener.Accept()
-		if err != nil {
-			return nil, nil, err
-		}
-		// gate the connection if applicable
-		if l.connGater != nil && !l.connGater.InterceptAccept(conn) {
-			log.Debugf("gater blocked incoming connection on local addr %s from %s",
-				conn.LocalMultiaddr(), conn.RemoteMultiaddr())
-			if err := conn.Close(); err != nil {
-				log.Warnf("failed to close incoming connection rejected by gater: %s", err)
-			}
-			continue
-		}
-
-		connScope, err := l.rcmgr.OpenConnection(network.DirInbound, true, conn.RemoteMultiaddr())
-		if err != nil {
-			log.Debugw("resource manager blocked accept of new connection", "error", err)
-			if err := conn.Close(); err != nil {
-				log.Warnf("failed to open incoming connection. Rejected by resource manager: %s", err)
-			}
-			continue
-		}
-		return conn, connScope, nil
-	}
-}
+var _ transport.Listener = (*listener)(nil)
diff --git a/p2p/net/upgrader/upgrader.go b/p2p/net/upgrader/upgrader.go
index 99ffc691..3a6f8b9f 100644
--- a/p2p/net/upgrader/upgrader.go
+++ b/p2p/net/upgrader/upgrader.go
@@ -105,32 +105,19 @@ func New(security []sec.SecureTransport, muxers []StreamMuxer, psk ipnet.PSK, rc
 
 // UpgradeListener upgrades the passed multiaddr-net listener into a full libp2p-transport listener.
 func (u *upgrader) UpgradeListener(t transport.Transport, list manet.Listener) transport.Listener {
-	return u.UpgradeGatedMaListener(t, u.GateMaListener(list))
-}
-
-func (u *upgrader) GateMaListener(l manet.Listener) transport.GatedMaListener {
-	return &gatedMaListener{
-		Listener:  l,
-		rcmgr:     u.rcmgr,
-		connGater: u.connGater,
-	}
-}
-
-// UpgradeGatedMaListener upgrades the passed multiaddr-net listener into a full libp2p-transport listener.
-func (u *upgrader) UpgradeGatedMaListener(t transport.Transport, l transport.GatedMaListener) transport.Listener {
 	ctx, cancel := context.WithCancel(context.Background())
-	list := &listener{
-		GatedMaListener: l,
-		upgrader:        u,
-		transport:       t,
-		rcmgr:           u.rcmgr,
-		threshold:       newThreshold(AcceptQueueLength),
-		incoming:        make(chan transport.CapableConn),
-		cancel:          cancel,
-		ctx:             ctx,
+	l := &listener{
+		Listener:  list,
+		upgrader:  u,
+		transport: t,
+		rcmgr:     u.rcmgr,
+		threshold: newThreshold(AcceptQueueLength),
+		incoming:  make(chan transport.CapableConn),
+		cancel:    cancel,
+		ctx:       ctx,
 	}
-	go list.handleIncoming()
-	return list
+	go l.handleIncoming()
+	return l
 }
 
 // Upgrade upgrades the multiaddr/net connection into a full libp2p-transport connection.
diff --git a/p2p/protocol/circuitv2/client/transport.go b/p2p/protocol/circuitv2/client/transport.go
index 553f8fa5..553af77f 100644
--- a/p2p/protocol/circuitv2/client/transport.go
+++ b/p2p/protocol/circuitv2/client/transport.go
@@ -101,7 +101,7 @@ func (c *Client) Listen(addr ma.Multiaddr) (transport.Listener, error) {
 		return nil, err
 	}
 
-	return c.upgrader.UpgradeGatedMaListener(c, c.upgrader.GateMaListener(c.Listener())), nil
+	return c.upgrader.UpgradeListener(c, c.Listener()), nil
 }
 
 func (c *Client) Protocols() []int {
diff --git a/p2p/transport/tcp/metrics.go b/p2p/transport/tcp/metrics.go
index e3946cf3..cbd2f92f 100644
--- a/p2p/transport/tcp/metrics.go
+++ b/p2p/transport/tcp/metrics.go
@@ -8,7 +8,6 @@ import (
 	"time"
 
 	"github.com/libp2p/go-libp2p/core/network"
-	"github.com/libp2p/go-libp2p/core/transport"
 	"github.com/marten-seemann/tcp"
 	"github.com/mikioh/tcpinfo"
 	manet "github.com/multiformats/go-multiaddr/net"
@@ -254,6 +253,16 @@ func (c *tracingConn) Close() error {
 	return c.closeErr
 }
 
+func (c *tracingConn) Scope() network.ConnManagementScope {
+	if cs, ok := c.Conn.(interface {
+		Scope() network.ConnManagementScope
+	}); ok {
+		return cs.Scope()
+	}
+	// upgrader is expected to handle this
+	return nil
+}
+
 func (c *tracingConn) getTCPInfo() (*tcpinfo.Info, error) {
 	var o tcpinfo.Info
 	var b [256]byte
@@ -266,31 +275,19 @@ func (c *tracingConn) getTCPInfo() (*tcpinfo.Info, error) {
 }
 
 type tracingListener struct {
-	transport.GatedMaListener
+	manet.Listener
 	collector *aggregatingCollector
 }
 
 // newTracingListener wraps a manet.Listener with a tracingListener. A nil collector will use the default collector.
-func newTracingListener(l transport.GatedMaListener, collector *aggregatingCollector) *tracingListener {
-	return &tracingListener{GatedMaListener: l, collector: collector}
+func newTracingListener(l manet.Listener, collector *aggregatingCollector) *tracingListener {
+	return &tracingListener{Listener: l, collector: collector}
 }
 
-func (l *tracingListener) Accept() (manet.Conn, network.ConnManagementScope, error) {
-	conn, scope, err := l.GatedMaListener.Accept()
-	if err != nil {
-		if scope != nil {
-			scope.Done()
-			log.Errorf("BUG: got non-nil scope but also an error: %s", err)
-		}
-		return nil, nil, err
-	}
-
-	tc, err := newTracingConn(conn, l.collector, false)
+func (l *tracingListener) Accept() (manet.Conn, error) {
+	conn, err := l.Listener.Accept()
 	if err != nil {
-		log.Errorf("failed to create tracingConn from %T: %s", conn, err)
-		conn.Close()
-		scope.Done()
-		return nil, nil, err
+		return nil, err
 	}
-	return tc, scope, nil
+	return newTracingConn(conn, l.collector, false)
 }
diff --git a/p2p/transport/tcp/metrics_none.go b/p2p/transport/tcp/metrics_none.go
index 2e561fb6..cbee9820 100644
--- a/p2p/transport/tcp/metrics_none.go
+++ b/p2p/transport/tcp/metrics_none.go
@@ -4,16 +4,11 @@
 
 package tcp
 
-import (
-	"github.com/libp2p/go-libp2p/core/transport"
-	manet "github.com/multiformats/go-multiaddr/net"
-)
+import manet "github.com/multiformats/go-multiaddr/net"
 
 type aggregatingCollector struct{}
 
 func newTracingConn(c manet.Conn, collector *aggregatingCollector, isClient bool) (manet.Conn, error) {
 	return c, nil
 }
-func newTracingListener(l transport.GatedMaListener, collector *aggregatingCollector) transport.GatedMaListener {
-	return l
-}
+func newTracingListener(l manet.Listener, collector *aggregatingCollector) manet.Listener { return l }
diff --git a/p2p/transport/tcp/tcp.go b/p2p/transport/tcp/tcp.go
index 0b0980c9..758adde8 100644
--- a/p2p/transport/tcp/tcp.go
+++ b/p2p/transport/tcp/tcp.go
@@ -41,7 +41,7 @@ var ReuseportIsAvailable = tcpreuse.ReuseportIsAvailable
 func tryKeepAlive(conn net.Conn, keepAlive bool) {
 	keepAliveConn, ok := conn.(canKeepAlive)
 	if !ok {
-		log.Errorf("can't set TCP keepalives. net.Conn of type %T doesn't support SetKeepAlive", conn)
+		log.Errorf("Can't set TCP keepalives.")
 		return
 	}
 	if err := keepAliveConn.SetKeepAlive(keepAlive); err != nil {
@@ -76,23 +76,23 @@ func tryLinger(conn net.Conn, sec int) {
 	}
 }
 
-type tcpGatedMaListener struct {
-	transport.GatedMaListener
+type tcpListener struct {
+	manet.Listener
 	sec int
 }
 
-func (ll *tcpGatedMaListener) Accept() (manet.Conn, network.ConnManagementScope, error) {
-	c, scope, err := ll.GatedMaListener.Accept()
+func (ll *tcpListener) Accept() (manet.Conn, error) {
+	c, err := ll.Listener.Accept()
 	if err != nil {
-		if scope != nil {
-			log.Errorf("BUG: got non-nil scope but also an error: %s", err)
-			scope.Done()
-		}
-		return nil, nil, err
+		return nil, err
 	}
 	tryLinger(c, ll.sec)
 	tryKeepAlive(c, true)
-	return c, scope, nil
+	// We're not calling OpenConnection in the resource manager here,
+	// since the manet.Conn doesn't allow us to save the scope.
+	// It's the caller's (usually the p2p/net/upgrader) responsibility
+	// to call the resource manager.
+	return c, nil
 }
 
 type Option func(*TcpTransport) error
@@ -316,26 +316,22 @@ func (t *TcpTransport) unsharedMAListen(laddr ma.Multiaddr) (manet.Listener, err
 
 // Listen listens on the given multiaddr.
 func (t *TcpTransport) Listen(laddr ma.Multiaddr) (transport.Listener, error) {
-	var list transport.GatedMaListener
+	var list manet.Listener
 	var err error
-	if t.sharedTcp != nil {
-		list, err = t.sharedTcp.DemultiplexedListen(laddr, tcpreuse.DemultiplexedConnType_MultistreamSelect)
-		if err != nil {
-			return nil, err
-		}
+
+	if t.sharedTcp == nil {
+		list, err = t.unsharedMAListen(laddr)
 	} else {
-		mal, err := t.unsharedMAListen(laddr)
-		if err != nil {
-			return nil, err
-		}
-		list = t.upgrader.GateMaListener(mal)
+		list, err = t.sharedTcp.DemultiplexedListen(laddr, tcpreuse.DemultiplexedConnType_MultistreamSelect)
+	}
+	if err != nil {
+		return nil, err
 	}
 
 	if t.enableMetrics {
-		// TODO: Fix this: The tcpListener wrapping should happen on both enableMetrics and disabledMetrics path
-		list = newTracingListener(&tcpGatedMaListener{list, 0}, t.metricsCollector)
+		list = newTracingListener(&tcpListener{list, 0}, t.metricsCollector)
 	}
-	return t.upgrader.UpgradeGatedMaListener(t, list), nil
+	return t.upgrader.UpgradeListener(t, list), nil
 }
 
 // Protocols returns the list of terminal protocols this transport can dial.
diff --git a/p2p/transport/tcpreuse/connwithscope.go b/p2p/transport/tcpreuse/connwithscope.go
index 23354b81..bddd3c0f 100644
--- a/p2p/transport/tcpreuse/connwithscope.go
+++ b/p2p/transport/tcpreuse/connwithscope.go
@@ -10,15 +10,19 @@ import (
 
 type connWithScope struct {
 	sampledconn.ManetTCPConnInterface
-	ConnScope network.ConnManagementScope
+	scope network.ConnManagementScope
+}
+
+func (c connWithScope) Scope() network.ConnManagementScope {
+	return c.scope
 }
 
 func (c *connWithScope) Close() error {
-	defer c.ConnScope.Done()
+	c.scope.Done()
 	return c.ManetTCPConnInterface.Close()
 }
 
-func manetConnWithScope(c manet.Conn, scope network.ConnManagementScope) (*connWithScope, error) {
+func manetConnWithScope(c manet.Conn, scope network.ConnManagementScope) (manet.Conn, error) {
 	if tcpconn, ok := c.(sampledconn.ManetTCPConnInterface); ok {
 		return &connWithScope{tcpconn, scope}, nil
 	}
diff --git a/p2p/transport/tcpreuse/listener.go b/p2p/transport/tcpreuse/listener.go
index 4c787acc..d0affb9f 100644
--- a/p2p/transport/tcpreuse/listener.go
+++ b/p2p/transport/tcpreuse/listener.go
@@ -9,6 +9,7 @@ import (
 	"time"
 
 	logging "github.com/ipfs/go-log/v2"
+	"github.com/libp2p/go-libp2p/core/connmgr"
 	"github.com/libp2p/go-libp2p/core/network"
 	"github.com/libp2p/go-libp2p/core/transport"
 	"github.com/libp2p/go-libp2p/p2p/net/reuseport"
@@ -27,36 +28,32 @@ var log = logging.Logger("tcp-demultiplex")
 type ConnMgr struct {
 	enableReuseport bool
 	reuse           reuseport.Transport
-	upgrader        transport.Upgrader
+	connGater       connmgr.ConnectionGater
+	rcmgr           network.ResourceManager
 
 	mx        sync.Mutex
 	listeners map[string]*multiplexedListener
 }
 
-func NewConnMgr(enableReuseport bool, upgrader transport.Upgrader) *ConnMgr {
+func NewConnMgr(enableReuseport bool, gater connmgr.ConnectionGater, rcmgr network.ResourceManager) *ConnMgr {
+	if rcmgr == nil {
+		rcmgr = &network.NullResourceManager{}
+	}
 	return &ConnMgr{
 		enableReuseport: enableReuseport,
 		reuse:           reuseport.Transport{},
-		upgrader:        upgrader,
+		connGater:       gater,
+		rcmgr:           rcmgr,
 		listeners:       make(map[string]*multiplexedListener),
 	}
 }
 
-func (t *ConnMgr) gatedMaListen(listenAddr ma.Multiaddr) (transport.GatedMaListener, error) {
-	var mal manet.Listener
-	var err error
+func (t *ConnMgr) maListen(listenAddr ma.Multiaddr) (manet.Listener, error) {
 	if t.useReuseport() {
-		mal, err = t.reuse.Listen(listenAddr)
-		if err != nil {
-			return nil, err
-		}
+		return t.reuse.Listen(listenAddr)
 	} else {
-		mal, err = manet.Listen(listenAddr)
-		if err != nil {
-			return nil, err
-		}
+		return manet.Listen(listenAddr)
 	}
-	return t.upgrader.GateMaListener(mal), nil
 }
 
 func (t *ConnMgr) useReuseport() bool {
@@ -83,7 +80,7 @@ func getTCPAddr(listenAddr ma.Multiaddr) (ma.Multiaddr, error) {
 // DemultiplexedListen returns a listener for laddr listening for `connType` connections. The connections
 // accepted from returned listeners need to be upgraded with a `transport.Upgrader`.
 // NOTE: All listeners for port 0 share the same underlying socket, so they have the same specific port.
-func (t *ConnMgr) DemultiplexedListen(laddr ma.Multiaddr, connType DemultiplexedConnType) (transport.GatedMaListener, error) {
+func (t *ConnMgr) DemultiplexedListen(laddr ma.Multiaddr, connType DemultiplexedConnType) (manet.Listener, error) {
 	if !connType.IsKnown() {
 		return nil, fmt.Errorf("unknown connection type: %s", connType)
 	}
@@ -103,7 +100,7 @@ func (t *ConnMgr) DemultiplexedListen(laddr ma.Multiaddr, connType Demultiplexed
 		return dl, nil
 	}
 
-	gmal, err := t.gatedMaListen(laddr)
+	l, err := t.maListen(laddr)
 	if err != nil {
 		return nil, err
 	}
@@ -114,17 +111,19 @@ func (t *ConnMgr) DemultiplexedListen(laddr ma.Multiaddr, connType Demultiplexed
 		t.mx.Lock()
 		defer t.mx.Unlock()
 		delete(t.listeners, laddr.String())
-		delete(t.listeners, gmal.Multiaddr().String())
-		return gmal.Close()
+		delete(t.listeners, l.Multiaddr().String())
+		return l.Close()
 	}
 	ml = &multiplexedListener{
-		GatedMaListener: gmal,
-		listeners:       make(map[DemultiplexedConnType]*demultiplexedListener),
-		ctx:             ctx,
-		closeFn:         cancelFunc,
+		Listener:  l,
+		listeners: make(map[DemultiplexedConnType]*demultiplexedListener),
+		ctx:       ctx,
+		closeFn:   cancelFunc,
+		connGater: t.connGater,
+		rcmgr:     t.rcmgr,
 	}
 	t.listeners[laddr.String()] = ml
-	t.listeners[gmal.Multiaddr().String()] = ml
+	t.listeners[l.Multiaddr().String()] = ml
 
 	dl, err := ml.DemultiplexedListen(connType)
 	if err != nil {
@@ -138,21 +137,23 @@ func (t *ConnMgr) DemultiplexedListen(laddr ma.Multiaddr, connType Demultiplexed
 	return dl, nil
 }
 
-var _ transport.GatedMaListener = &demultiplexedListener{}
+var _ manet.Listener = &demultiplexedListener{}
 
 type multiplexedListener struct {
-	transport.GatedMaListener
+	manet.Listener
 	listeners map[DemultiplexedConnType]*demultiplexedListener
 	mx        sync.RWMutex
 
-	ctx     context.Context
-	closeFn func() error
-	wg      sync.WaitGroup
+	connGater connmgr.ConnectionGater
+	rcmgr     network.ResourceManager
+	ctx       context.Context
+	closeFn   func() error
+	wg        sync.WaitGroup
 }
 
 var ErrListenerExists = errors.New("listener already exists for this conn type on this address")
 
-func (m *multiplexedListener) DemultiplexedListen(connType DemultiplexedConnType) (transport.GatedMaListener, error) {
+func (m *multiplexedListener) DemultiplexedListen(connType DemultiplexedConnType) (manet.Listener, error) {
 	if !connType.IsKnown() {
 		return nil, fmt.Errorf("unknown connection type: %s", connType)
 	}
@@ -165,8 +166,8 @@ func (m *multiplexedListener) DemultiplexedListen(connType DemultiplexedConnType
 
 	ctx, cancel := context.WithCancel(m.ctx)
 	l := &demultiplexedListener{
-		buffer:     make(chan *connWithScope),
-		inner:      m.GatedMaListener,
+		buffer:     make(chan manet.Conn),
+		inner:      m.Listener,
 		ctx:        ctx,
 		cancelFunc: cancel,
 		closeFn:    func() error { m.removeDemultiplexedListener(connType); return nil },
@@ -182,35 +183,53 @@ func (m *multiplexedListener) run() error {
 	defer m.wg.Done()
 	acceptQueue := make(chan struct{}, acceptQueueSize)
 	for {
-		c, connScope, err := m.GatedMaListener.Accept()
+		c, err := m.Listener.Accept()
 		if err != nil {
 			return err
 		}
-		ctx, cancelCtx := context.WithTimeout(m.ctx, acceptTimeout)
+
+		// Gate and resource limit the connection here.
+		// If done after sampling the connection, we'll be vulnerable to DOS attacks by a single peer
+		// which clogs up our entire connection queue.
+		// This duplicates the responsibility of gating and resource limiting between here and the upgrader. The
+		// alternative without duplication requires moving the process of upgrading the connection here, which forces
+		// us to establish the websocket connection here. That is more duplication, or a significant breaking change.
+		//
+		// Bugs around multiple calls to OpenConnection or InterceptAccept are prevented by the transport
+		// integration tests.
+		if m.connGater != nil && !m.connGater.InterceptAccept(c) {
+			log.Debugf("gater blocked incoming connection on local addr %s from %s",
+				c.LocalMultiaddr(), c.RemoteMultiaddr())
+			if err := c.Close(); err != nil {
+				log.Warnf("failed to close incoming connection rejected by gater: %s", err)
+			}
+			continue
+		}
+		connScope, err := m.rcmgr.OpenConnection(network.DirInbound, true, c.RemoteMultiaddr())
+		if err != nil {
+			log.Debugw("resource manager blocked accept of new connection", "error", err)
+			if err := c.Close(); err != nil {
+				log.Warnf("failed to open incoming connection. Rejected by resource manager: %s", err)
+			}
+			continue
+		}
+
 		select {
 		case acceptQueue <- struct{}{}:
-		case <-ctx.Done():
-			cancelCtx()
-			connScope.Done()
-			c.Close()
-			log.Debugf("accept queue full, dropping connection: %s", c.RemoteMultiaddr())
-			continue
+		// NOTE: We can drop the connection, but this is similar to the behaviour in the upgrader.
 		case <-m.ctx.Done():
-			cancelCtx()
-			connScope.Done()
 			c.Close()
-			log.Debugf("listener closed; dropping connection from: %s", c.RemoteMultiaddr())
-			continue
+			log.Debugf("accept queue full, dropping connection: %s", c.RemoteMultiaddr())
 		}
 
 		m.wg.Add(1)
 		go func() {
 			defer func() { <-acceptQueue }()
 			defer m.wg.Done()
+			ctx, cancelCtx := context.WithTimeout(m.ctx, acceptTimeout)
 			defer cancelCtx()
 			t, c, err := identifyConnType(c)
 			if err != nil {
-				// conn closed by identifyConnType
 				connScope.Done()
 				log.Debugf("error demultiplexing connection: %s", err.Error())
 				return
@@ -260,7 +279,7 @@ func (m *multiplexedListener) Close() error {
 }
 
 func (m *multiplexedListener) closeListener() error {
-	lerr := m.GatedMaListener.Close()
+	lerr := m.Listener.Close()
 	cerr := m.closeFn()
 	return errors.Join(lerr, cerr)
 }
@@ -279,19 +298,19 @@ func (m *multiplexedListener) removeDemultiplexedListener(c DemultiplexedConnTyp
 }
 
 type demultiplexedListener struct {
-	buffer     chan *connWithScope
-	inner      transport.GatedMaListener
+	buffer     chan manet.Conn
+	inner      manet.Listener
 	ctx        context.Context
 	cancelFunc context.CancelFunc
 	closeFn    func() error
 }
 
-func (m *demultiplexedListener) Accept() (manet.Conn, network.ConnManagementScope, error) {
+func (m *demultiplexedListener) Accept() (manet.Conn, error) {
 	select {
 	case c := <-m.buffer:
-		return c.ManetTCPConnInterface, c.ConnScope, nil
+		return c, nil
 	case <-m.ctx.Done():
-		return nil, nil, transport.ErrListenerClosed
+		return nil, transport.ErrListenerClosed
 	}
 }
 
diff --git a/p2p/transport/websocket/conn.go b/p2p/transport/websocket/conn.go
index 0d474608..1c2ecd03 100644
--- a/p2p/transport/websocket/conn.go
+++ b/p2p/transport/websocket/conn.go
@@ -1,6 +1,7 @@
 package websocket
 
 import (
+	"crypto/tls"
 	"errors"
 	"io"
 	"net"
@@ -8,6 +9,7 @@ import (
 	"time"
 
 	"github.com/libp2p/go-libp2p/core/network"
+	"github.com/libp2p/go-libp2p/core/transport"
 	ma "github.com/multiformats/go-multiaddr"
 	manet "github.com/multiformats/go-multiaddr/net"
 
@@ -21,7 +23,6 @@ var GracefulCloseTimeout = 100 * time.Millisecond
 // Conn implements net.Conn interface for gorilla/websocket.
 type Conn struct {
 	*ws.Conn
-	Scope              network.ConnManagementScope
 	secure             bool
 	DefaultMessageType int
 	reader             io.Reader
@@ -35,8 +36,10 @@ type Conn struct {
 var _ net.Conn = (*Conn)(nil)
 var _ manet.Conn = (*Conn)(nil)
 
-// newConn creates a Conn given a regular gorilla/websocket Conn.
-func newConn(raw *ws.Conn, secure bool, scope network.ConnManagementScope) *Conn {
+// NewConn creates a Conn given a regular gorilla/websocket Conn.
+//
+// Deprecated: There's no reason to use this method externally. It'll be unexported in a future release.
+func NewConn(raw *ws.Conn, secure bool) *Conn {
 	lna := NewAddrWithScheme(raw.LocalAddr().String(), secure)
 	laddr, err := manet.FromNetAddr(lna)
 	if err != nil {
@@ -53,7 +56,6 @@ func newConn(raw *ws.Conn, secure bool, scope network.ConnManagementScope) *Conn
 
 	c := &Conn{
 		Conn:               raw,
-		Scope:              scope,
 		secure:             secure,
 		DefaultMessageType: ws.BinaryMessage,
 		laddr:              laddr,
@@ -134,6 +136,23 @@ func (c *Conn) Write(b []byte) (n int, err error) {
 	return len(b), nil
 }
 
+func (c *Conn) Scope() network.ConnManagementScope {
+	nc := c.NetConn()
+	if sc, ok := nc.(interface {
+		Scope() network.ConnManagementScope
+	}); ok {
+		return sc.Scope()
+	}
+	if nc, ok := nc.(*tls.Conn); ok {
+		if sc, ok := nc.NetConn().(interface {
+			Scope() network.ConnManagementScope
+		}); ok {
+			return sc.Scope()
+		}
+	}
+	return nil
+}
+
 // Close closes the connection.
 // subsequent and concurrent calls will return the same error value.
 // This method is thread-safe.
@@ -182,3 +201,13 @@ func (c *Conn) SetWriteDeadline(t time.Time) error {
 
 	return c.Conn.SetWriteDeadline(t)
 }
+
+type capableConn struct {
+	transport.CapableConn
+}
+
+func (c *capableConn) ConnState() network.ConnectionState {
+	cs := c.CapableConn.ConnState()
+	cs.Transport = "websocket"
+	return cs
+}
diff --git a/p2p/transport/websocket/listener.go b/p2p/transport/websocket/listener.go
index b7402c0e..e72e7dab 100644
--- a/p2p/transport/websocket/listener.go
+++ b/p2p/transport/websocket/listener.go
@@ -1,22 +1,17 @@
 package websocket
 
 import (
-	"context"
 	"crypto/tls"
 	"errors"
 	"fmt"
 	"net"
 	"net/http"
-	"net/url"
 	"sync"
-	"time"
 
 	"go.uber.org/zap"
 
-	ws "github.com/gorilla/websocket"
 	logging "github.com/ipfs/go-log/v2"
 
-	"github.com/libp2p/go-libp2p/core/network"
 	"github.com/libp2p/go-libp2p/core/transport"
 	"github.com/libp2p/go-libp2p/p2p/transport/tcpreuse"
 
@@ -28,9 +23,8 @@ var log = logging.Logger("websocket-transport")
 var stdLog = zap.NewStdLog(log.Desugar())
 
 type listener struct {
-	netListener *httpNetListener
-	server      http.Server
-	wsUpgrader  ws.Upgrader
+	nl     net.Listener
+	server http.Server
 	// The Go standard library sets the http.Server.TLSConfig no matter if this is a WS or WSS,
 	// so we can't rely on checking if server.TLSConfig is set.
 	isWss bool
@@ -42,11 +36,8 @@ type listener struct {
 	closeOnce sync.Once
 	closeErr  error
 	closed    chan struct{}
-	wsurl     *url.URL
 }
 
-var _ transport.GatedMaListener = &listener{}
-
 func (pwma *parsedWebsocketMultiaddr) toMultiaddr() ma.Multiaddr {
 	if !pwma.isWSS {
 		return pwma.restMultiaddr.AppendComponent(wsComponent)
@@ -61,7 +52,7 @@ func (pwma *parsedWebsocketMultiaddr) toMultiaddr() ma.Multiaddr {
 
 // newListener creates a new listener from a raw net.Listener.
 // tlsConf may be nil (for unencrypted websockets).
-func newListener(a ma.Multiaddr, tlsConf *tls.Config, sharedTcp *tcpreuse.ConnMgr, upgrader transport.Upgrader, handshakeTimeout time.Duration) (*listener, error) {
+func newListener(a ma.Multiaddr, tlsConf *tls.Config, sharedTcp *tcpreuse.ConnMgr) (*listener, error) {
 	parsed, err := parseWebsocketMultiaddr(a)
 	if err != nil {
 		return nil, err
@@ -71,13 +62,17 @@ func newListener(a ma.Multiaddr, tlsConf *tls.Config, sharedTcp *tcpreuse.ConnMg
 		return nil, fmt.Errorf("cannot listen on wss address %s without a tls.Config", a)
 	}
 
-	var gmal transport.GatedMaListener
+	var nl net.Listener
+
 	if sharedTcp == nil {
-		mal, err := manet.Listen(parsed.restMultiaddr)
+		lnet, lnaddr, err := manet.DialArgs(parsed.restMultiaddr)
+		if err != nil {
+			return nil, err
+		}
+		nl, err = net.Listen(lnet, lnaddr)
 		if err != nil {
 			return nil, err
 		}
-		gmal = upgrader.GateMaListener(mal)
 	} else {
 		var connType tcpreuse.DemultiplexedConnType
 		if parsed.isWSS {
@@ -85,146 +80,89 @@ func newListener(a ma.Multiaddr, tlsConf *tls.Config, sharedTcp *tcpreuse.ConnMg
 		} else {
 			connType = tcpreuse.DemultiplexedConnType_HTTP
 		}
-		gmal, err = sharedTcp.DemultiplexedListen(parsed.restMultiaddr, connType)
+		mal, err := sharedTcp.DemultiplexedListen(parsed.restMultiaddr, connType)
 		if err != nil {
 			return nil, err
 		}
+		nl = manet.NetListener(mal)
 	}
 
-	// laddr has the correct port in case we listened on port 0
-	laddr := gmal.Multiaddr()
+	laddr, err := manet.FromNetAddr(nl.Addr())
+	if err != nil {
+		return nil, err
+	}
 
+	first, _ := ma.SplitFirst(a)
 	// Don't resolve dns addresses.
 	// We want to be able to announce domain names, so the peer can validate the TLS certificate.
-	first, _ := ma.SplitFirst(a)
 	if c := first.Protocol().Code; c == ma.P_DNS || c == ma.P_DNS4 || c == ma.P_DNS6 || c == ma.P_DNSADDR {
 		_, last := ma.SplitFirst(laddr)
 		laddr = first.Encapsulate(last)
 	}
 	parsed.restMultiaddr = laddr
 
-	listenAddr := parsed.toMultiaddr()
-	wsurl, err := parseMultiaddr(listenAddr)
-	if err != nil {
-		gmal.Close()
-		return nil, fmt.Errorf("failed to parse multiaddr to URL: %v: %w", listenAddr, err)
-	}
 	ln := &listener{
-		netListener: &httpNetListener{
-			GatedMaListener:  gmal,
-			handshakeTimeout: handshakeTimeout,
-		},
+		nl:       nl,
 		laddr:    parsed.toMultiaddr(),
 		incoming: make(chan *Conn),
 		closed:   make(chan struct{}),
-		isWss:    parsed.isWSS,
-		wsurl:    wsurl,
-		wsUpgrader: ws.Upgrader{
-			// Allow requests from *all* origins.
-			CheckOrigin: func(r *http.Request) bool {
-				return true
-			},
-			HandshakeTimeout: handshakeTimeout,
-		},
 	}
-	ln.server = http.Server{Handler: ln, ErrorLog: stdLog, ConnContext: ln.ConnContext, TLSConfig: tlsConf}
+	ln.server = http.Server{Handler: ln, ErrorLog: stdLog}
+	if parsed.isWSS {
+		ln.isWss = true
+		ln.server.TLSConfig = tlsConf
+	}
 	return ln, nil
 }
 
 func (l *listener) serve() {
 	defer close(l.closed)
 	if !l.isWss {
-		l.server.Serve(l.netListener)
+		l.server.Serve(l.nl)
 	} else {
-		l.server.ServeTLS(l.netListener, "", "")
+		l.server.ServeTLS(l.nl, "", "")
 	}
 }
 
-type connKey struct{}
-
-func (l *listener) ConnContext(ctx context.Context, c net.Conn) context.Context {
-	// prefer `*tls.Conn` over `(interface{NetConn() net.Conn})` in case `manet.Conn` is extended
-	// to support a `NetConn() net.Conn` method.
-	if tc, ok := c.(*tls.Conn); ok {
-		c = tc.NetConn()
-	}
-	if nc, ok := c.(*negotiatingConn); ok {
-		return context.WithValue(ctx, connKey{}, nc)
-	}
-	log.Errorf("BUG: expected net.Conn of type *websocket.negotiatingConn: got %T", c)
-	// might as well close the connection as there's no way to proceed now.
-	c.Close()
-	return ctx
-}
-
-func (l *listener) extractConnFromContext(ctx context.Context) (*negotiatingConn, error) {
-	c := ctx.Value(connKey{})
-	if c == nil {
-		return nil, fmt.Errorf("expected *websocket.negotiatingConn in context: got nil")
-	}
-	nc, ok := c.(*negotiatingConn)
-	if !ok {
-		return nil, fmt.Errorf("expected *websocket.negotiatingConn in context: got %T", c)
-	}
-	return nc, nil
-}
-
 func (l *listener) ServeHTTP(w http.ResponseWriter, r *http.Request) {
-	c, err := l.wsUpgrader.Upgrade(w, r, nil)
+	c, err := upgrader.Upgrade(w, r, nil)
 	if err != nil {
 		// The upgrader writes a response for us.
 		return
 	}
-	nc, err := l.extractConnFromContext(r.Context())
-	if err != nil {
+	nc := NewConn(c, l.isWss)
+	if nc == nil {
 		c.Close()
 		w.WriteHeader(500)
-		log.Errorf("BUG: failed to extract conn from context: RemoteAddr: %s: err: %s", r.RemoteAddr, err)
 		return
 	}
-
-	cs, err := nc.Unwrap()
-	if err != nil {
-		c.Close()
-		w.WriteHeader(500)
-		log.Debugf("connection timed out from: %s", r.RemoteAddr)
-		return
-	}
-
-	conn := newConn(c, l.isWss, cs.Scope)
-	if conn == nil {
-		c.Close()
-		w.WriteHeader(500)
-		return
-	}
-
 	select {
-	case l.incoming <- conn:
+	case l.incoming <- nc:
 	case <-l.closed:
-		conn.Close()
+		nc.Close()
 	}
 	// The connection has been hijacked, it's safe to return.
 }
 
-func (l *listener) Accept() (manet.Conn, network.ConnManagementScope, error) {
+func (l *listener) Accept() (manet.Conn, error) {
 	select {
 	case c, ok := <-l.incoming:
 		if !ok {
-			return nil, nil, transport.ErrListenerClosed
+			return nil, transport.ErrListenerClosed
 		}
-		return c, c.Scope, nil
+		return c, nil
 	case <-l.closed:
-		return nil, nil, transport.ErrListenerClosed
+		return nil, transport.ErrListenerClosed
 	}
 }
 
 func (l *listener) Addr() net.Addr {
-	return &Addr{URL: l.wsurl}
+	return l.nl.Addr()
 }
 
 func (l *listener) Close() error {
 	l.closeOnce.Do(func() {
-		err1 := l.netListener.Close()
+		err1 := l.nl.Close()
 		err2 := l.server.Close()
 		<-l.closed
 		l.closeErr = errors.Join(err1, err2)
@@ -236,74 +174,14 @@ func (l *listener) Multiaddr() ma.Multiaddr {
 	return l.laddr
 }
 
-// httpNetListener is a net.Listener that adapts a transport.GatedMaListener to a net.Listener.
-// It wraps the manet.Conn, and the Scope from the underlying gated listener in a connWithScope.
-type httpNetListener struct {
-	transport.GatedMaListener
-	handshakeTimeout time.Duration
+type transportListener struct {
+	transport.Listener
 }
 
-var _ net.Listener = &httpNetListener{}
-
-func (l *httpNetListener) Accept() (net.Conn, error) {
-	conn, scope, err := l.GatedMaListener.Accept()
+func (l *transportListener) Accept() (transport.CapableConn, error) {
+	conn, err := l.Listener.Accept()
 	if err != nil {
-		if scope != nil {
-			log.Errorf("BUG: scope non-nil when err is non nil: %v", err)
-			scope.Done()
-		}
 		return nil, err
 	}
-	connWithScope := connWithScope{
-		Conn:  conn,
-		Scope: scope,
-	}
-	ctx, cancel := context.WithTimeout(context.Background(), l.handshakeTimeout)
-	return &negotiatingConn{
-		connWithScope: connWithScope,
-		ctx:           ctx,
-		cancelCtx:     cancel,
-		stopClose: context.AfterFunc(ctx, func() {
-			connWithScope.Close()
-			log.Debugf("handshake timeout for conn from: %s", conn.RemoteAddr())
-		}),
-	}, nil
-}
-
-type connWithScope struct {
-	net.Conn
-	Scope network.ConnManagementScope
-}
-
-func (c connWithScope) Close() error {
-	c.Scope.Done()
-	return c.Conn.Close()
-}
-
-type negotiatingConn struct {
-	connWithScope
-	ctx       context.Context
-	cancelCtx context.CancelFunc
-	stopClose func() bool
-}
-
-// Close closes the negotiating conn and the underlying connWithScope
-// This will be called in case the tls handshake or websocket upgrade fails.
-func (c *negotiatingConn) Close() error {
-	defer c.cancelCtx()
-	if c.stopClose != nil {
-		c.stopClose()
-	}
-	return c.connWithScope.Close()
-}
-
-func (c *negotiatingConn) Unwrap() (connWithScope, error) {
-	defer c.cancelCtx()
-	if c.stopClose != nil {
-		if !c.stopClose() {
-			return connWithScope{}, errors.New("timed out")
-		}
-		c.stopClose = nil
-	}
-	return c.connWithScope, nil
+	return &capableConn{CapableConn: conn}, nil
 }
diff --git a/p2p/transport/websocket/websocket.go b/p2p/transport/websocket/websocket.go
index 3a6badac..0ddf1905 100644
--- a/p2p/transport/websocket/websocket.go
+++ b/p2p/transport/websocket/websocket.go
@@ -5,6 +5,7 @@ import (
 	"context"
 	"crypto/tls"
 	"net"
+	"net/http"
 	"time"
 
 	"github.com/libp2p/go-libp2p/core/network"
@@ -50,6 +51,14 @@ func init() {
 	manet.RegisterToNetAddr(ConvertWebsocketMultiaddrToNetAddr, "wss")
 }
 
+// Default gorilla upgrader
+var upgrader = ws.Upgrader{
+	// Allow requests from *all* origins.
+	CheckOrigin: func(r *http.Request) bool {
+		return true
+	},
+}
+
 type Option func(*WebsocketTransport) error
 
 // WithTLSClientConfig sets a TLS client configuration on the WebSocket Dialer. Only
@@ -72,24 +81,15 @@ func WithTLSConfig(conf *tls.Config) Option {
 	}
 }
 
-var defaultHandshakeTimeout = 15 * time.Second
-
-// WithHandshakeTimeout sets a timeout for the websocket upgrade.
-func WithHandshakeTimeout(timeout time.Duration) Option {
-	return func(t *WebsocketTransport) error {
-		t.handshakeTimeout = timeout
-		return nil
-	}
-}
-
 // WebsocketTransport is the actual go-libp2p transport
 type WebsocketTransport struct {
-	upgrader         transport.Upgrader
-	rcmgr            network.ResourceManager
-	tlsClientConf    *tls.Config
-	tlsConf          *tls.Config
-	sharedTcp        *tcpreuse.ConnMgr
-	handshakeTimeout time.Duration
+	upgrader transport.Upgrader
+	rcmgr    network.ResourceManager
+
+	tlsClientConf *tls.Config
+	tlsConf       *tls.Config
+
+	sharedTcp *tcpreuse.ConnMgr
 }
 
 var _ transport.Transport = (*WebsocketTransport)(nil)
@@ -99,11 +99,10 @@ func New(u transport.Upgrader, rcmgr network.ResourceManager, sharedTCP *tcpreus
 		rcmgr = &network.NullResourceManager{}
 	}
 	t := &WebsocketTransport{
-		upgrader:         u,
-		rcmgr:            rcmgr,
-		tlsClientConf:    &tls.Config{},
-		sharedTcp:        sharedTCP,
-		handshakeTimeout: defaultHandshakeTimeout,
+		upgrader:      u,
+		rcmgr:         rcmgr,
+		tlsClientConf: &tls.Config{},
+		sharedTcp:     sharedTCP,
 	}
 	for _, opt := range opts {
 		if err := opt(t); err != nil {
@@ -177,7 +176,7 @@ func (t *WebsocketTransport) Dial(ctx context.Context, raddr ma.Multiaddr, p pee
 }
 
 func (t *WebsocketTransport) dialWithScope(ctx context.Context, raddr ma.Multiaddr, p peer.ID, connScope network.ConnManagementScope) (transport.CapableConn, error) {
-	macon, err := t.maDial(ctx, raddr, connScope)
+	macon, err := t.maDial(ctx, raddr)
 	if err != nil {
 		return nil, err
 	}
@@ -188,14 +187,14 @@ func (t *WebsocketTransport) dialWithScope(ctx context.Context, raddr ma.Multiad
 	return &capableConn{CapableConn: conn}, nil
 }
 
-func (t *WebsocketTransport) maDial(ctx context.Context, raddr ma.Multiaddr, scope network.ConnManagementScope) (manet.Conn, error) {
+func (t *WebsocketTransport) maDial(ctx context.Context, raddr ma.Multiaddr) (manet.Conn, error) {
 	wsurl, err := parseMultiaddr(raddr)
 	if err != nil {
 		return nil, err
 	}
 	isWss := wsurl.Scheme == "wss"
 	dialer := ws.Dialer{
-		HandshakeTimeout: t.handshakeTimeout,
+		HandshakeTimeout: 30 * time.Second,
 		// Inherit the default proxy behavior
 		Proxy: ws.DefaultDialer.Proxy,
 	}
@@ -237,7 +236,7 @@ func (t *WebsocketTransport) maDial(ctx context.Context, raddr ma.Multiaddr, sco
 		return nil, err
 	}
 
-	mnc, err := manet.WrapNetConn(newConn(wscon, isWss, scope))
+	mnc, err := manet.WrapNetConn(NewConn(wscon, isWss))
 	if err != nil {
 		wscon.Close()
 		return nil, err
@@ -245,12 +244,12 @@ func (t *WebsocketTransport) maDial(ctx context.Context, raddr ma.Multiaddr, sco
 	return mnc, nil
 }
 
-func (t *WebsocketTransport) gatedMaListen(a ma.Multiaddr) (transport.GatedMaListener, error) {
+func (t *WebsocketTransport) maListen(a ma.Multiaddr) (manet.Listener, error) {
 	var tlsConf *tls.Config
 	if t.tlsConf != nil {
 		tlsConf = t.tlsConf.Clone()
 	}
-	l, err := newListener(a, tlsConf, t.sharedTcp, t.upgrader, t.handshakeTimeout)
+	l, err := newListener(a, tlsConf, t.sharedTcp)
 	if err != nil {
 		return nil, err
 	}
@@ -259,32 +258,9 @@ func (t *WebsocketTransport) gatedMaListen(a ma.Multiaddr) (transport.GatedMaLis
 }
 
 func (t *WebsocketTransport) Listen(a ma.Multiaddr) (transport.Listener, error) {
-	gmal, err := t.gatedMaListen(a)
-	if err != nil {
-		return nil, err
-	}
-	return &transportListener{Listener: t.upgrader.UpgradeGatedMaListener(t, gmal)}, nil
-}
-
-// transportListener wraps a transport.Listener to provide connections with a `ConnState() network.ConnectionState` method.
-type transportListener struct {
-	transport.Listener
-}
-
-type capableConn struct {
-	transport.CapableConn
-}
-
-func (c *capableConn) ConnState() network.ConnectionState {
-	cs := c.CapableConn.ConnState()
-	cs.Transport = "websocket"
-	return cs
-}
-
-func (l *transportListener) Accept() (transport.CapableConn, error) {
-	conn, err := l.Listener.Accept()
+	malist, err := t.maListen(a)
 	if err != nil {
 		return nil, err
 	}
-	return &capableConn{CapableConn: conn}, nil
+	return &transportListener{Listener: t.upgrader.UpgradeListener(t, malist)}, nil
 }


Test patch:
diff --git a/p2p/host/peerstore/pstoreds/ds_test.go b/p2p/host/peerstore/pstoreds/ds_test.go
index 60a4ba17..f9d474c0 100644
--- a/p2p/host/peerstore/pstoreds/ds_test.go
+++ b/p2p/host/peerstore/pstoreds/ds_test.go
@@ -2,16 +2,14 @@ package pstoreds
 
 import (
 	"context"
-	"os"
 	"testing"
 	"time"
 
 	pstore "github.com/libp2p/go-libp2p/core/peerstore"
 	pt "github.com/libp2p/go-libp2p/p2p/host/peerstore/test"
 
-	mockClock "github.com/benbjohnson/clock"
+	mockclock "github.com/benbjohnson/clock"
 	ds "github.com/ipfs/go-datastore"
-	badger "github.com/ipfs/go-ds-badger"
 	leveldb "github.com/ipfs/go-ds-leveldb"
 	"github.com/stretchr/testify/require"
 )
@@ -19,7 +17,6 @@ import (
 type datastoreFactory func(tb testing.TB) (ds.Batching, func())
 
 var dstores = map[string]datastoreFactory{
-	// "Badger": badgerStore,
 	"Leveldb": leveldbStore,
 }
 
@@ -49,7 +46,7 @@ func TestDsAddrBook(t *testing.T) {
 			opts := DefaultOpts()
 			opts.GCPurgeInterval = 1 * time.Second
 			opts.CacheSize = 1024
-			clk := mockClock.NewMock()
+			clk := mockclock.NewMock()
 			opts.Clock = clk
 
 			pt.TestAddrBook(t, addressBookFactory(t, dsFactory, opts), clk)
@@ -59,7 +56,7 @@ func TestDsAddrBook(t *testing.T) {
 			opts := DefaultOpts()
 			opts.GCPurgeInterval = 1 * time.Second
 			opts.CacheSize = 0
-			clk := mockClock.NewMock()
+			clk := mockclock.NewMock()
 			opts.Clock = clk
 
 			pt.TestAddrBook(t, addressBookFactory(t, dsFactory, opts), clk)
@@ -100,25 +97,6 @@ func BenchmarkDsPeerstore(b *testing.B) {
 	}
 }
 
-// Doesn't work on 32bit because badger.
-//
-//lint:ignore U1000 disabled for now
-func badgerStore(tb testing.TB) (ds.Batching, func()) {
-	dataPath, err := os.MkdirTemp(os.TempDir(), "badger")
-	if err != nil {
-		tb.Fatal(err)
-	}
-	store, err := badger.NewDatastore(dataPath, nil)
-	if err != nil {
-		tb.Fatal(err)
-	}
-	closer := func() {
-		store.Close()
-		os.RemoveAll(dataPath)
-	}
-	return store, closer
-}
-
 func leveldbStore(tb testing.TB) (ds.Batching, func()) {
 	// Intentionally test in-memory because disks suck, especially in CI.
 	store, err := leveldb.NewDatastore("", nil)
diff --git a/p2p/net/upgrader/listener_test.go b/p2p/net/upgrader/listener_test.go
index e2def7cc..14800e59 100644
--- a/p2p/net/upgrader/listener_test.go
+++ b/p2p/net/upgrader/listener_test.go
@@ -30,7 +30,7 @@ func createListener(t *testing.T, u transport.Upgrader) transport.Listener {
 	require.NoError(t, err)
 	ln, err := manet.Listen(addr)
 	require.NoError(t, err)
-	return u.UpgradeGatedMaListener(nil, u.GateMaListener(ln))
+	return u.UpgradeListener(nil, ln)
 }
 
 func TestAcceptSingleConn(t *testing.T) {
diff --git a/p2p/test/transport/gating_test.go b/p2p/test/transport/gating_test.go
index c9ae4fd8..52f6477c 100644
--- a/p2p/test/transport/gating_test.go
+++ b/p2p/test/transport/gating_test.go
@@ -203,7 +203,7 @@ func TestInterceptAccept(t *testing.T) {
 				connGater.EXPECT().InterceptAccept(gomock.Any()).Do(func(addrs network.ConnMultiaddrs) {
 					require.Equal(t, normalize(h2.Addrs()[0]), normalize(addrs.LocalMultiaddr()))
 				}).AnyTimes()
-			} else if strings.Contains(tc.Name, "WebSocket") {
+			} else if strings.Contains(tc.Name, "WebSocket-Shared") || strings.Contains(tc.Name, "WebSocket-Secured-Shared") {
 				connGater.EXPECT().InterceptAccept(gomock.Any()).Do(func(addrs network.ConnMultiaddrs) {
 					require.Equal(t, addrPort(h2.Addrs()[0]), addrPort(addrs.LocalMultiaddr()))
 				})
diff --git a/p2p/transport/quicreuse/tracer_test.go b/p2p/transport/quicreuse/tracer_test.go
index bea6b91d..3347c5f7 100644
--- a/p2p/transport/quicreuse/tracer_test.go
+++ b/p2p/transport/quicreuse/tracer_test.go
@@ -13,6 +13,13 @@ import (
 	"github.com/stretchr/testify/require"
 )
 
+func createLogDir(t *testing.T) string {
+	dir, err := os.MkdirTemp("", "libp2p-quic-transport-test")
+	require.NoError(t, err)
+	t.Cleanup(func() { os.RemoveAll(dir) })
+	return dir
+}
+
 func getFile(t *testing.T, dir string) os.FileInfo {
 	files, err := os.ReadDir(dir)
 	require.NoError(t, err)
@@ -23,7 +30,7 @@ func getFile(t *testing.T, dir string) os.FileInfo {
 }
 
 func TestSaveQlog(t *testing.T) {
-	qlogDir := t.TempDir()
+	qlogDir := createLogDir(t)
 	logger := newQlogger(qlogDir, logging.PerspectiveServer, quic.ConnectionIDFromBytes([]byte{0xde, 0xad, 0xbe, 0xef}))
 	file := getFile(t, qlogDir)
 	require.Equal(t, ".", string(file.Name()[0]))
@@ -38,7 +45,7 @@ func TestSaveQlog(t *testing.T) {
 }
 
 func TestQlogBuffering(t *testing.T) {
-	qlogDir := t.TempDir()
+	qlogDir := createLogDir(t)
 	logger := newQlogger(qlogDir, logging.PerspectiveServer, quic.ConnectionIDFromBytes([]byte("connid")))
 	initialSize := getFile(t, qlogDir).Size()
 	// Do a small write.
@@ -53,7 +60,7 @@ func TestQlogBuffering(t *testing.T) {
 }
 
 func TestQlogCompression(t *testing.T) {
-	qlogDir := t.TempDir()
+	qlogDir := createLogDir(t)
 	logger := newQlogger(qlogDir, logging.PerspectiveServer, quic.ConnectionIDFromBytes([]byte("connid")))
 	logger.Write([]byte("foobar"))
 	require.NoError(t, logger.Close())
diff --git a/p2p/transport/tcp/metrics_test.go b/p2p/transport/tcp/metrics_test.go
index 7645abc8..9a994696 100644
--- a/p2p/transport/tcp/metrics_test.go
+++ b/p2p/transport/tcp/metrics_test.go
@@ -15,10 +15,8 @@ func TestTcpTransportCollectsMetricsWithSharedTcpSocket(t *testing.T) {
 	peerA, ia := makeInsecureMuxer(t)
 	_, ib := makeInsecureMuxer(t)
 
-	upg, err := tptu.New(ia, muxers, nil, nil, nil)
-	require.NoError(t, err)
-	sharedTCPSocketA := tcpreuse.NewConnMgr(false, upg)
-	sharedTCPSocketB := tcpreuse.NewConnMgr(false, upg)
+	sharedTCPSocketA := tcpreuse.NewConnMgr(false, nil, nil)
+	sharedTCPSocketB := tcpreuse.NewConnMgr(false, nil, nil)
 
 	ua, err := tptu.New(ia, muxers, nil, nil, nil)
 	require.NoError(t, err)
diff --git a/p2p/transport/tcpreuse/listener_test.go b/p2p/transport/tcpreuse/listener_test.go
index 0f91d499..b5dc49f2 100644
--- a/p2p/transport/tcpreuse/listener_test.go
+++ b/p2p/transport/tcpreuse/listener_test.go
@@ -17,9 +17,6 @@ import (
 	"time"
 
 	"github.com/gorilla/websocket"
-	"github.com/libp2p/go-libp2p/core/network"
-	"github.com/libp2p/go-libp2p/core/transport"
-	tptu "github.com/libp2p/go-libp2p/p2p/net/upgrader"
 	ma "github.com/multiformats/go-multiaddr"
 	manet "github.com/multiformats/go-multiaddr/net"
 	"github.com/multiformats/go-multistream"
@@ -56,17 +53,6 @@ func selfSignedTLSConfig(t *testing.T) *tls.Config {
 	return tlsConfig
 }
 
-type maListener struct {
-	transport.GatedMaListener
-}
-
-var _ manet.Listener = &maListener{}
-
-func (ml *maListener) Accept() (manet.Conn, error) {
-	c, _, err := ml.GatedMaListener.Accept()
-	return c, err
-}
-
 type wsHandler struct{ conns chan *websocket.Conn }
 
 func (wh wsHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
@@ -75,19 +61,12 @@ func (wh wsHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
 	wh.conns <- c
 }
 
-func upgrader(t *testing.T) transport.Upgrader {
-	t.Helper()
-	upd, err := tptu.New(nil, nil, nil, &network.NullResourceManager{}, nil)
-	require.NoError(t, err)
-	return upd
-}
-
 func TestListenerSingle(t *testing.T) {
 	listenAddr := ma.StringCast("/ip4/0.0.0.0/tcp/0")
 	const N = 64
 	for _, enableReuseport := range []bool{true, false} {
 		t.Run(fmt.Sprintf("multistream-reuseport:%v", enableReuseport), func(t *testing.T) {
-			cm := NewConnMgr(enableReuseport, upgrader(t))
+			cm := NewConnMgr(enableReuseport, nil, nil)
 			l, err := cm.DemultiplexedListen(listenAddr, DemultiplexedConnType_MultistreamSelect)
 			require.NoError(t, err)
 			go func() {
@@ -117,7 +96,7 @@ func TestListenerSingle(t *testing.T) {
 
 			var wg sync.WaitGroup
 			for i := 0; i < N; i++ {
-				c, _, err := l.Accept()
+				c, err := l.Accept()
 				require.NoError(t, err)
 				wg.Add(1)
 				go func() {
@@ -138,12 +117,12 @@ func TestListenerSingle(t *testing.T) {
 		})
 
 		t.Run(fmt.Sprintf("WebSocket-reuseport:%v", enableReuseport), func(t *testing.T) {
-			cm := NewConnMgr(enableReuseport, upgrader(t))
+			cm := NewConnMgr(enableReuseport, nil, nil)
 			l, err := cm.DemultiplexedListen(listenAddr, DemultiplexedConnType_HTTP)
 			require.NoError(t, err)
 			wh := wsHandler{conns: make(chan *websocket.Conn, acceptQueueSize)}
 			go func() {
-				http.Serve(manet.NetListener(&maListener{GatedMaListener: l}), wh)
+				http.Serve(manet.NetListener(l), wh)
 			}()
 			go func() {
 				d := websocket.Dialer{}
@@ -190,14 +169,14 @@ func TestListenerSingle(t *testing.T) {
 		})
 
 		t.Run(fmt.Sprintf("WebSocketTLS-reuseport:%v", enableReuseport), func(t *testing.T) {
-			cm := NewConnMgr(enableReuseport, upgrader(t))
+			cm := NewConnMgr(enableReuseport, nil, nil)
 			l, err := cm.DemultiplexedListen(listenAddr, DemultiplexedConnType_TLS)
 			require.NoError(t, err)
 			defer l.Close()
 			wh := wsHandler{conns: make(chan *websocket.Conn, acceptQueueSize)}
 			go func() {
 				s := http.Server{Handler: wh, TLSConfig: selfSignedTLSConfig(t)}
-				s.ServeTLS(manet.NetListener(&maListener{GatedMaListener: l}), "", "")
+				s.ServeTLS(manet.NetListener(l), "", "")
 			}()
 			go func() {
 				d := websocket.Dialer{TLSClientConfig: &tls.Config{InsecureSkipVerify: true}}
@@ -249,7 +228,7 @@ func TestListenerMultiplexed(t *testing.T) {
 	listenAddr := ma.StringCast("/ip4/0.0.0.0/tcp/0")
 	const N = 20
 	for _, enableReuseport := range []bool{true, false} {
-		cm := NewConnMgr(enableReuseport, upgrader(t))
+		cm := NewConnMgr(enableReuseport, nil, nil)
 		msl, err := cm.DemultiplexedListen(listenAddr, DemultiplexedConnType_MultistreamSelect)
 		require.NoError(t, err)
 		defer msl.Close()
@@ -260,7 +239,7 @@ func TestListenerMultiplexed(t *testing.T) {
 		require.Equal(t, wsl.Multiaddr(), msl.Multiaddr())
 		wh := wsHandler{conns: make(chan *websocket.Conn, acceptQueueSize)}
 		go func() {
-			http.Serve(manet.NetListener(&maListener{GatedMaListener: wsl}), wh)
+			http.Serve(manet.NetListener(wsl), wh)
 		}()
 
 		wssl, err := cm.DemultiplexedListen(listenAddr, DemultiplexedConnType_TLS)
@@ -270,7 +249,7 @@ func TestListenerMultiplexed(t *testing.T) {
 		whs := wsHandler{conns: make(chan *websocket.Conn, acceptQueueSize)}
 		go func() {
 			s := http.Server{Handler: whs, TLSConfig: selfSignedTLSConfig(t)}
-			s.ServeTLS(manet.NetListener(&maListener{GatedMaListener: wssl}), "", "")
+			s.ServeTLS(manet.NetListener(wssl), "", "")
 		}()
 
 		// multistream connections
@@ -352,7 +331,7 @@ func TestListenerMultiplexed(t *testing.T) {
 		go func() {
 			defer wg.Done()
 			for i := 0; i < N; i++ {
-				c, _, err := msl.Accept()
+				c, err := msl.Accept()
 				if !assert.NoError(t, err) {
 					return
 				}
@@ -425,7 +404,7 @@ func TestListenerMultiplexed(t *testing.T) {
 func TestListenerClose(t *testing.T) {
 	testClose := func(listenAddr ma.Multiaddr) {
 		// listen on port 0
-		cm := NewConnMgr(false, upgrader(t))
+		cm := NewConnMgr(false, nil, nil)
 		ml, err := cm.DemultiplexedListen(listenAddr, DemultiplexedConnType_MultistreamSelect)
 		require.NoError(t, err)
 		wl, err := cm.DemultiplexedListen(listenAddr, DemultiplexedConnType_HTTP)
@@ -480,7 +459,7 @@ func setDeferReset[T any](t testing.TB, ptr *T, val T) {
 func TestHitTimeout(t *testing.T) {
 	setDeferReset(t, &identifyConnTimeout, 100*time.Millisecond)
 	// listen on port 0
-	cm := NewConnMgr(false, upgrader(t))
+	cm := NewConnMgr(false, nil, nil)
 
 	listenAddr := ma.StringCast("/ip4/127.0.0.1/tcp/0")
 	ml, err := cm.DemultiplexedListen(listenAddr, DemultiplexedConnType_MultistreamSelect)
diff --git a/p2p/transport/websocket/addrs_test.go b/p2p/transport/websocket/addrs_test.go
index 1a73c287..50a8b9e8 100644
--- a/p2p/transport/websocket/addrs_test.go
+++ b/p2p/transport/websocket/addrs_test.go
@@ -4,6 +4,8 @@ import (
 	"net/url"
 	"testing"
 
+	"github.com/stretchr/testify/require"
+
 	ma "github.com/multiformats/go-multiaddr"
 )
 
@@ -65,3 +67,15 @@ func TestConvertWebsocketMultiaddrToNetAddr(t *testing.T) {
 		t.Fatalf("expected network: \"websocket\", got \"%s\"", wsaddr.Network())
 	}
 }
+
+func TestListeningOnDNSAddr(t *testing.T) {
+	ln, err := newListener(ma.StringCast("/dns/localhost/tcp/0/ws"), nil, nil)
+	require.NoError(t, err)
+	addr := ln.Multiaddr()
+	first, rest := ma.SplitFirst(addr)
+	require.Equal(t, ma.P_DNS, first.Protocol().Code)
+	require.Equal(t, "localhost", first.Value())
+	next, _ := ma.SplitFirst(rest)
+	require.Equal(t, ma.P_TCP, next.Protocol().Code)
+	require.NotEqual(t, 0, next.Value())
+}
diff --git a/p2p/transport/websocket/websocket_test.go b/p2p/transport/websocket/websocket_test.go
index 2c47adf3..f83576ba 100644
--- a/p2p/transport/websocket/websocket_test.go
+++ b/p2p/transport/websocket/websocket_test.go
@@ -35,7 +35,6 @@ import (
 	ttransport "github.com/libp2p/go-libp2p/p2p/transport/testsuite"
 
 	ma "github.com/multiformats/go-multiaddr"
-	"github.com/stretchr/testify/assert"
 	"github.com/stretchr/testify/require"
 )
 
@@ -297,39 +296,18 @@ func TestDialWssNoClientCert(t *testing.T) {
 }
 
 func TestWebsocketTransport(t *testing.T) {
-	t.Run("/ws", func(t *testing.T) {
-		peerA, ua := newUpgrader(t)
-		ta, err := New(ua, nil, nil)
-		if err != nil {
-			t.Fatal(err)
-		}
-		peerB, ub := newUpgrader(t)
-		tb, err := New(ub, nil, nil)
-		if err != nil {
-			t.Fatal(err)
-		}
-
-		ttransport.SubtestTransport(t, ta, tb, "/ip4/127.0.0.1/tcp/0/ws", peerA)
-		ttransport.SubtestTransport(t, tb, ta, "/ip4/127.0.0.1/tcp/0/ws", peerB)
-
-	})
-	t.Run("/wss", func(t *testing.T) {
-		peerA, ua := newUpgrader(t)
-		tca := generateTLSConfig(t)
-		ta, err := New(ua, nil, nil, WithTLSConfig(tca), WithTLSClientConfig(&tls.Config{InsecureSkipVerify: true}))
-		if err != nil {
-			t.Fatal(err)
-		}
-		peerB, ub := newUpgrader(t)
-		tcb := generateTLSConfig(t)
-		tb, err := New(ub, nil, nil, WithTLSConfig(tcb), WithTLSClientConfig(&tls.Config{InsecureSkipVerify: true}))
-		if err != nil {
-			t.Fatal(err)
-		}
+	peerA, ua := newUpgrader(t)
+	ta, err := New(ua, nil, nil)
+	if err != nil {
+		t.Fatal(err)
+	}
+	_, ub := newUpgrader(t)
+	tb, err := New(ub, nil, nil)
+	if err != nil {
+		t.Fatal(err)
+	}
 
-		ttransport.SubtestTransport(t, ta, tb, "/ip4/127.0.0.1/tcp/0/wss", peerA)
-		ttransport.SubtestTransport(t, tb, ta, "/ip4/127.0.0.1/tcp/0/ws", peerB)
-	})
+	ttransport.SubtestTransport(t, ta, tb, "/ip4/127.0.0.1/tcp/0/ws", peerA)
 }
 
 func isWSS(addr ma.Multiaddr) bool {
@@ -463,7 +441,7 @@ func TestConcurrentClose(t *testing.T) {
 	_, u := newUpgrader(t)
 	tpt, err := New(u, &network.NullResourceManager{}, nil)
 	require.NoError(t, err)
-	l, err := tpt.gatedMaListen(ma.StringCast("/ip4/127.0.0.1/tcp/0/ws"))
+	l, err := tpt.maListen(ma.StringCast("/ip4/127.0.0.1/tcp/0/ws"))
 	if err != nil {
 		t.Fatal(err)
 	}
@@ -473,7 +451,7 @@ func TestConcurrentClose(t *testing.T) {
 
 	go func() {
 		for i := 0; i < 100; i++ {
-			c, err := tpt.maDial(context.Background(), l.Multiaddr(), &network.NullScope{})
+			c, err := tpt.maDial(context.Background(), l.Multiaddr())
 			if err != nil {
 				t.Error(err)
 				return
@@ -489,7 +467,7 @@ func TestConcurrentClose(t *testing.T) {
 	}()
 
 	for i := 0; i < 100; i++ {
-		c, _, err := l.Accept()
+		c, err := l.Accept()
 		if err != nil {
 			t.Fatal(err)
 		}
@@ -503,7 +481,7 @@ func TestWriteZero(t *testing.T) {
 	if err != nil {
 		t.Fatal(err)
 	}
-	l, err := tpt.gatedMaListen(ma.StringCast("/ip4/127.0.0.1/tcp/0/ws"))
+	l, err := tpt.maListen(ma.StringCast("/ip4/127.0.0.1/tcp/0/ws"))
 	if err != nil {
 		t.Fatal(err)
 	}
@@ -512,7 +490,7 @@ func TestWriteZero(t *testing.T) {
 	msg := []byte(nil)
 
 	go func() {
-		c, err := tpt.maDial(context.Background(), l.Multiaddr(), &network.NullScope{})
+		c, err := tpt.maDial(context.Background(), l.Multiaddr())
 		if err != nil {
 			t.Error(err)
 			return
@@ -531,7 +509,7 @@ func TestWriteZero(t *testing.T) {
 		}
 	}()
 
-	c, _, err := l.Accept()
+	c, err := l.Accept()
 	if err != nil {
 		t.Fatal(err)
 	}
@@ -645,98 +623,3 @@ func TestSocksProxy(t *testing.T) {
 		})
 	}
 }
-
-func TestListenerAddr(t *testing.T) {
-	_, upgrader := newUpgrader(t)
-	transport, err := New(upgrader, &network.NullResourceManager{}, nil, WithTLSConfig(generateTLSConfig(t)))
-	require.NoError(t, err)
-	l1, err := transport.Listen(ma.StringCast("/ip4/127.0.0.1/tcp/0/ws"))
-	require.NoError(t, err)
-	defer l1.Close()
-	require.Regexp(t, `^ws://127\.0\.0\.1:[\d]+$`, l1.Addr().String())
-	l2, err := transport.Listen(ma.StringCast("/ip4/127.0.0.1/tcp/0/wss"))
-	require.NoError(t, err)
-	defer l2.Close()
-	require.Regexp(t, `^wss://127\.0\.0\.1:[\d]+$`, l2.Addr().String())
-}
-func TestHandshakeTimeout(t *testing.T) {
-	handshakeTimeout := 200 * time.Millisecond
-	_, upgrader := newUpgrader(t)
-	tlsconf := generateTLSConfig(t)
-	transport, err := New(upgrader, &network.NullResourceManager{}, nil, WithHandshakeTimeout(handshakeTimeout), WithTLSConfig(tlsconf))
-	require.NoError(t, err)
-
-	fastWSDialer := gws.Dialer{
-		HandshakeTimeout: 10 * handshakeTimeout,
-		TLSClientConfig:  &tls.Config{InsecureSkipVerify: true},
-		NetDial: func(network, addr string) (net.Conn, error) {
-			tcpConn, err := net.Dial("tcp", addr)
-			if !assert.NoError(t, err) {
-				return nil, err
-			}
-			return tcpConn, nil
-		},
-	}
-
-	slowWSDialer := gws.Dialer{
-		HandshakeTimeout: 10 * handshakeTimeout,
-		NetDial: func(network, addr string) (net.Conn, error) {
-			tcpConn, err := net.Dial("tcp", addr)
-			if !assert.NoError(t, err) {
-				return nil, err
-			}
-			// wait to simulate a slow handshake
-			time.Sleep(2 * handshakeTimeout)
-			return tcpConn, nil
-		},
-		TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
-	}
-	t.Run("ws", func(t *testing.T) {
-		// test the gatedMaListener as we're interested in the websocket handshake timeout and not the upgrader steps.
-		wsListener, err := transport.gatedMaListen(ma.StringCast("/ip4/127.0.0.1/tcp/0/ws"))
-		require.NoError(t, err)
-		defer wsListener.Close()
-
-		ctx, cancel := context.WithTimeout(context.Background(), 10*handshakeTimeout)
-		defer cancel()
-		conn, resp, err := fastWSDialer.DialContext(ctx, wsListener.Addr().String(), nil)
-		if !assert.NoError(t, err) {
-			return
-		}
-		conn.Close()
-		resp.Body.Close()
-
-		ctx, cancel = context.WithTimeout(context.Background(), 10*handshakeTimeout)
-		defer cancel()
-		conn, resp, err = slowWSDialer.DialContext(ctx, wsListener.Addr().String(), nil)
-		if err == nil {
-			conn.Close()
-			resp.Body.Close()
-			t.Fatal("should error as the handshake will time out")
-		}
-	})
-
-	t.Run("wss", func(t *testing.T) {
-		// test the gatedMaListener as we're interested in the websocket handshake timeout and not the upgrader steps.
-		wsListener, err := transport.gatedMaListen(ma.StringCast("/ip4/127.0.0.1/tcp/0/wss"))
-		require.NoError(t, err)
-		defer wsListener.Close()
-
-		// Test that the normal dial works fine
-		ctx, cancel := context.WithTimeout(context.Background(), 10*handshakeTimeout)
-		defer cancel()
-		wsConn, resp, err := fastWSDialer.DialContext(ctx, wsListener.Addr().String(), nil)
-		require.NoError(t, err)
-		wsConn.Close()
-		resp.Body.Close()
-
-		ctx, cancel = context.WithTimeout(context.Background(), 10*handshakeTimeout)
-		defer cancel()
-		wsConn, resp, err = slowWSDialer.DialContext(ctx, wsListener.Addr().String(), nil)
-		if err == nil {
-			wsConn.Close()
-			resp.Body.Close()
-			t.Fatal("websocket handshake should have timed out")
-		}
-	})
-}