aboutsummaryrefslogtreecommitdiffstats
path: root/swarm
diff options
context:
space:
mode:
authorFelix Lange <fjl@users.noreply.github.com>2018-10-12 02:32:14 +0800
committerGitHub <noreply@github.com>2018-10-12 02:32:14 +0800
commitdcae0d348bb7f5d9052e50a83383a33538ce376a (patch)
tree9dee15f209bd31c3adf32fef3835a06bda8f18e4 /swarm
parentf951e23fb5ad2f7017f314a95287bc0506a67d05 (diff)
downloaddexon-dcae0d348bb7f5d9052e50a83383a33538ce376a.tar
dexon-dcae0d348bb7f5d9052e50a83383a33538ce376a.tar.gz
dexon-dcae0d348bb7f5d9052e50a83383a33538ce376a.tar.bz2
dexon-dcae0d348bb7f5d9052e50a83383a33538ce376a.tar.lz
dexon-dcae0d348bb7f5d9052e50a83383a33538ce376a.tar.xz
dexon-dcae0d348bb7f5d9052e50a83383a33538ce376a.tar.zst
dexon-dcae0d348bb7f5d9052e50a83383a33538ce376a.zip
p2p/simulations: fix a deadlock and clean up adapters (#17891)
This fixes a rare deadlock with the inproc adapter: - A node is stopped, which acquires Network.lock. - The protocol code being simulated (swarm/network in my case) waits for its goroutines to shut down. - One of those goroutines calls into the simulation to add a peer, which waits for Network.lock. The fix for the deadlock is really simple, just release the lock before stopping the simulation node. Other changes in this PR clean up the exec adapter so it reports node startup errors better and remove the docker adapter because it just adds overhead. In the exec adapter, node information is now posted to a one-shot server. This avoids log parsing and allows reporting startup errors to the simulation host. A small change in package node was needed because simulation nodes use port zero. Node.{HTTP,WS}Endpoint now return the live endpoints after startup by checking the TCP listener.
Diffstat (limited to 'swarm')
-rw-r--r--swarm/network/simulations/discovery/discovery_test.go19
1 files changed, 1 insertions, 18 deletions
diff --git a/swarm/network/simulations/discovery/discovery_test.go b/swarm/network/simulations/discovery/discovery_test.go
index d11eabf95..3c3affe58 100644
--- a/swarm/network/simulations/discovery/discovery_test.go
+++ b/swarm/network/simulations/discovery/discovery_test.go
@@ -125,22 +125,6 @@ func BenchmarkDiscovery_64_4(b *testing.B) { benchmarkDiscovery(b, 64, 4) }
func BenchmarkDiscovery_128_4(b *testing.B) { benchmarkDiscovery(b, 128, 4) }
func BenchmarkDiscovery_256_4(b *testing.B) { benchmarkDiscovery(b, 256, 4) }
-func TestDiscoverySimulationDockerAdapter(t *testing.T) {
- testDiscoverySimulationDockerAdapter(t, *nodeCount, *initCount)
-}
-
-func testDiscoverySimulationDockerAdapter(t *testing.T, nodes, conns int) {
- adapter, err := adapters.NewDockerAdapter()
- if err != nil {
- if err == adapters.ErrLinuxOnly {
- t.Skip(err)
- } else {
- t.Fatal(err)
- }
- }
- testDiscoverySimulation(t, nodes, conns, adapter)
-}
-
func TestDiscoverySimulationExecAdapter(t *testing.T) {
testDiscoverySimulationExecAdapter(t, *nodeCount, *initCount)
}
@@ -545,8 +529,7 @@ func triggerChecks(trigger chan enode.ID, net *simulations.Network, id enode.ID)
}
func newService(ctx *adapters.ServiceContext) (node.Service, error) {
- node := enode.NewV4(&ctx.Config.PrivateKey.PublicKey, adapters.ExternalIP(), int(ctx.Config.Port), int(ctx.Config.Port))
- addr := network.NewAddr(node)
+ addr := network.NewAddr(ctx.Config.Node())
kp := network.NewKadParams()
kp.MinProxBinSize = testMinProxBinSize