From a09d89e8d4f36cd8d9633a6f24bc61affbe6a353 Mon Sep 17 00:00:00 2001 From: Maru Newby Date: Fri, 22 Dec 2023 16:19:07 -0800 Subject: [PATCH] e2e: Remove network manager and dependency on ANR --- go.mod | 7 +- go.sum | 21 +- scripts/versions.sh | 2 +- tests/utils/constants.go | 4 - tests/utils/runner/network_manager.go | 402 -------------------------- tests/warp/warp_test.go | 29 +- 6 files changed, 35 insertions(+), 430 deletions(-) delete mode 100644 tests/utils/runner/network_manager.go diff --git a/go.mod b/go.mod index b1ab124645..e399a82865 100644 --- a/go.mod +++ b/go.mod @@ -4,8 +4,7 @@ go 1.20 require ( github.com/VictoriaMetrics/fastcache v1.10.0 - github.com/ava-labs/avalanche-network-runner v1.7.4-0.20231127162258-2f3ceed8ae4b - github.com/ava-labs/avalanchego v1.10.18-rc.0 + github.com/ava-labs/avalanchego v1.10.18-rc.5.0.20240104202004-2dca1dce4aa2 github.com/cespare/cp v0.1.0 github.com/cockroachdb/pebble v0.0.0-20230209160836-829675f94811 github.com/davecgh/go-spew v1.1.1 @@ -114,7 +113,6 @@ require ( github.com/mr-tron/base58 v1.2.0 // indirect github.com/nbutton23/zxcvbn-go v0.0.0-20180912185939-ae427f1e4c1d // indirect github.com/opentracing/opentracing-go v1.1.0 // indirect - github.com/otiai10/copy v1.11.0 // indirect github.com/pelletier/go-toml v1.9.5 // indirect github.com/pelletier/go-toml/v2 v2.0.5 // indirect github.com/peterh/liner v1.1.1-0.20190123174540-a2c9a5303de7 // indirect @@ -146,7 +144,6 @@ require ( go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.26.0 // indirect golang.org/x/exp v0.0.0-20231127185646-65229373498e // indirect - golang.org/x/mod v0.14.0 // indirect golang.org/x/net v0.19.0 // indirect golang.org/x/term v0.15.0 // indirect golang.org/x/tools v0.16.0 // indirect @@ -162,4 +159,4 @@ require ( rsc.io/tmplfunc v0.0.3 // indirect ) -replace github.com/ava-labs/avalanchego => github.com/ava-labs/avalanchego v1.10.18-0.20231223011330-c500f6a5a91d +replace github.com/ava-labs/avalanchego => github.com/ava-labs/avalanchego v1.10.18-0.20231223041851-6a97a1e42458 diff --git a/go.sum b/go.sum index 19fbfe3dde..5ef25d9120 100644 --- a/go.sum +++ b/go.sum @@ -59,10 +59,8 @@ github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156 h1:eMwmnE/GDgah github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156/go.mod h1:Cb/ax3seSYIx7SuZdm2G2xzfwmv3TPSk2ucNfQESPXM= github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= -github.com/ava-labs/avalanche-network-runner v1.7.4-0.20231127162258-2f3ceed8ae4b h1:iH6q+S7dmBOYCXrZx+nNlS1HBp72L2msiVCLs39Ls5A= -github.com/ava-labs/avalanche-network-runner v1.7.4-0.20231127162258-2f3ceed8ae4b/go.mod h1:aeAm8dgJ1xucQKlYoRDMgYjA0UWGwmaICG9wL0WvseU= -github.com/ava-labs/avalanchego v1.10.18-0.20231223011330-c500f6a5a91d h1:wKHpI3wzVVgdVZYucExripEelNabYJgc5ItplwjVilI= -github.com/ava-labs/avalanchego v1.10.18-0.20231223011330-c500f6a5a91d/go.mod h1:mc5LNZv4377kMCnSShUYatDkFntpUqh1SFwo2LbiQjU= +github.com/ava-labs/avalanchego v1.10.18-0.20231223041851-6a97a1e42458 h1:IAOvC/XBCKS222DnrWPmU1GIQDvhzG9/AwW8YKX090o= +github.com/ava-labs/avalanchego v1.10.18-0.20231223041851-6a97a1e42458/go.mod h1:mc5LNZv4377kMCnSShUYatDkFntpUqh1SFwo2LbiQjU= github.com/ava-labs/coreth v0.12.10-rc.0 h1:qmuom7rtH5hc1E3lnqrMFNLFL1TMnEVa/2O8poB1YLU= github.com/ava-labs/coreth v0.12.10-rc.0/go.mod h1:plFm/xzvWmx1+qJ3JQSTzF8+FdaA2xu7GgY/AdaZDfk= github.com/aymerick/raymond v2.0.3-0.20180322193309-b565731e1464+incompatible/go.mod h1:osfaiScAUVup+UC9Nfq76eWqDhXlp+4UYaA8uhTBO6g= @@ -130,6 +128,7 @@ github.com/cockroachdb/pebble v0.0.0-20230209160836-829675f94811 h1:ytcWPaNPhNoG github.com/cockroachdb/pebble v0.0.0-20230209160836-829675f94811/go.mod h1:Nb5lgvnQ2+oGlE/EyZy4+2/CxRh9KfvCXnag1vtpxVM= github.com/cockroachdb/redact v1.1.3 h1:AKZds10rFSIj7qADf0g46UixK8NNLwWTNdCIGS5wfSQ= github.com/cockroachdb/redact v1.1.3/go.mod h1:BVNblN9mBWFyMyqK1k3AAiSxhvhfK2oOZZ2lK+dpvRg= +github.com/cockroachdb/sentry-go v0.6.1-cockroachdb.2/go.mod h1:8BT+cPK6xvFOcRlk0R8eg+OTkcqI6baNH4xAkpiYVvQ= github.com/codegangsta/inject v0.0.0-20150114235600-33e0aa1cb7c0/go.mod h1:4Zcjuz89kmFXt9morQgcfYZAYZ5n8WHjt81YYWIwtTM= github.com/consensys/bavard v0.1.13 h1:oLhMLOFGTLdlda/kma4VOJazblc7IM5y5QPd2A/YjhQ= github.com/consensys/bavard v0.1.13/go.mod h1:9ItSMtA/dXMAiL7BG6bqW2m3NdSEObYWoH223nGHukI= @@ -219,6 +218,7 @@ github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxI github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= +github.com/go-logfmt/logfmt v0.5.1/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs= github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/logr v1.3.0 h1:2y3SDp0ZXuc6/cjLSZ+Q3ir+QB9T/iG5yYRXqsagWSY= github.com/go-logr/logr v1.3.0/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= @@ -391,13 +391,16 @@ github.com/jackpal/go-nat-pmp v1.0.2 h1:KzKSgb7qkJvOUTqYl9/Hg/me3pWgBmERKrTGD7Bd github.com/jackpal/go-nat-pmp v1.0.2/go.mod h1:QPH045xvCAeXUZOxsnwmrtiCoxIr9eob+4orBN1SBKc= github.com/jessevdk/go-flags v0.0.0-20141203071132-1679536dcc89/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= +github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4= github.com/jrick/logrotate v1.0.0/go.mod h1:LNinyqDIJnpAur+b8yyulnQw/wDuN1+BYKlTRt3OuAQ= github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= +github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= github.com/julienschmidt/httprouter v1.3.0 h1:U0609e9tgbseu3rBINet9P48AI/D3oJs4dN7jwJOQ1U= +github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM= github.com/k0kubun/colorstring v0.0.0-20150214042306-9440f1994b88/go.mod h1:3w7q1U84EfirKl04SVQ/s7nPm1ZPhiXd34z40TNz36k= github.com/kataras/golog v0.0.10/go.mod h1:yJ8YKCmyL+nWjERB90Qwn+bdyBZsaQwU3bTVFgkFIp8= github.com/kataras/iris/v12 v12.1.8/go.mod h1:LMYy4VlP67TQ3Zgriz8RE2h2kMZV2SgMYbq3UhfoFmE= @@ -428,6 +431,7 @@ github.com/labstack/echo/v4 v4.2.1/go.mod h1:AA49e0DZ8kk5jTOOCKNuPR6oTnBS0dYiM4F github.com/labstack/echo/v4 v4.5.0/go.mod h1:czIriw4a0C1dFun+ObrXp7ok03xON0N1awStJ6ArI7Y= github.com/labstack/gommon v0.3.0/go.mod h1:MULnywXg0yavhxWKc+lOruYdAhDwPK9wf0OL7NoOu+k= github.com/leanovate/gopter v0.2.9 h1:fQjYxZaynp97ozCzfOyOuAGOU4aU/z37zf/tOujFk7c= +github.com/leanovate/gopter v0.2.9/go.mod h1:U2L/78B+KVFIx2VmW6onHJQzXtFb+p5y3y2Sh+Jxxv8= github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= github.com/magiconair/properties v1.8.6 h1:5ibWZ6iY0NctNGWo87LalDlEZ6R41TqbbDamhfG/Qzo= github.com/magiconair/properties v1.8.6/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60= @@ -469,9 +473,11 @@ github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJ github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= github.com/moul/http2curl v1.0.0/go.mod h1:8UbvGypXm98wA/IqH45anm5Y2Z6ep6O31QGOAZ3H0fQ= github.com/mr-tron/base58 v1.2.0 h1:T/HDJBh4ZCPbU39/+c3rRvE0uKBQlU27+QI8LJ4t64o= github.com/mr-tron/base58 v1.2.0/go.mod h1:BinMc/sQntlIE1frQmRFPUoPA1Zkr8VRgBdjWI2mNwc= +github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/nats-io/jwt v0.3.0/go.mod h1:fRYCDE99xlTsqUzISS1Bi75UBJ6ljOJQOAAu5VglpSg= github.com/nats-io/nats.go v1.9.1/go.mod h1:ZjDU1L/7fJ09jvUSRVBR2e7+RnLiiIQyqyzEE/Zbp4w= github.com/nats-io/nkeys v0.1.0/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w= @@ -504,9 +510,6 @@ github.com/onsi/gomega v1.29.0 h1:KIA/t2t5UBzoirT4H9tsML45GEbo3ouUnBHsCfD2tVg= github.com/onsi/gomega v1.29.0/go.mod h1:9sxs+SwGrKI0+PWe4Fxa9tFQQBG5xSsSbMXOI8PPpoQ= github.com/opentracing/opentracing-go v1.1.0 h1:pWlfV3Bxv7k65HYwkikxat0+s3pV4bsqf19k25Ur8rU= github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= -github.com/otiai10/copy v1.11.0 h1:OKBD80J/mLBrwnzXqGtFCzprFSGioo30JcmR4APsNwc= -github.com/otiai10/copy v1.11.0/go.mod h1:rSaLseMUsZFFbsFGc7wCJnnkTAvdc5L6VWxPE4308Ww= -github.com/otiai10/mint v1.5.1 h1:XaPLeE+9vGbuyEHem1JNk3bYc7KKqyI/na0/mLd/Kks= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= github.com/pelletier/go-toml v1.9.5 h1:4yBQzkHv+7BHq2PQUZF3Mx0IYxG7LsP222s7Agd3ve8= github.com/pelletier/go-toml v1.9.5/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c= @@ -579,7 +582,7 @@ github.com/status-im/keycard-go v0.2.0 h1:QDLFswOQu1r5jsycloeQh3bVU8n/NatHHaZobt github.com/status-im/keycard-go v0.2.0/go.mod h1:wlp8ZLbsmrF6g6WjugPAx+IzoLrkdf9+mHxBEeo3Hbg= 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 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c= +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= @@ -658,6 +661,7 @@ go.opentelemetry.io/otel/trace v1.11.0/go.mod h1:nyYjis9jy0gytE9LXGU+/m1sHTKbRY0 go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= go.opentelemetry.io/proto/otlp v0.19.0 h1:IVN6GR+mhC4s5yfcTbmzHYODqvWAp3ZedA2SJPI1Nnw= go.opentelemetry.io/proto/otlp v0.19.0/go.mod h1:H7XAot3MsfNsj7EXtrA2q5xSNQ10UqI405h3+duxN4U= +go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/goleak v1.2.1 h1:NBol2c7O1ZokfZ0LEU9K6Whx/KnwvepVetCUhtKja4A= go.uber.org/goleak v1.2.1/go.mod h1:qlT2yGI9QafXHhZZLxlSuNsMw3FFLxBr+tBRlmO1xH4= go.uber.org/mock v0.2.0 h1:TaP3xedm7JaAgScZO7tlvlKrqT0p7I6OsdGB5YNSMDU= @@ -722,7 +726,6 @@ golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.14.0 h1:dGoOF9QVLYng8IHTm7BAyWqCqSheQ5pYWGhzW00YJr0= -golang.org/x/mod v0.14.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20180719180050-a680a1efc54d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= diff --git a/scripts/versions.sh b/scripts/versions.sh index fc6485c506..7c188d58bc 100644 --- a/scripts/versions.sh +++ b/scripts/versions.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash # Don't export them as they're used in the context of other calls -AVALANCHE_VERSION=${AVALANCHE_VERSION:-'c500f6a5a'} +AVALANCHE_VERSION=${AVALANCHE_VERSION:-'2dca1dce4'} GINKGO_VERSION=${GINKGO_VERSION:-'v2.2.0'} # This won't be used, but it's here to make code syncs easier diff --git a/tests/utils/constants.go b/tests/utils/constants.go index 4b07626d08..cd507eca1b 100644 --- a/tests/utils/constants.go +++ b/tests/utils/constants.go @@ -14,7 +14,3 @@ const ( DefaultLocalNodeURI = "http://127.0.0.1:9650" ) - -var ( - NodeURIs = []string{DefaultLocalNodeURI, "http://127.0.0.1:9652", "http://127.0.0.1:9654", "http://127.0.0.1:9656", "http://127.0.0.1:9658"} -) diff --git a/tests/utils/runner/network_manager.go b/tests/utils/runner/network_manager.go deleted file mode 100644 index 6c816bff65..0000000000 --- a/tests/utils/runner/network_manager.go +++ /dev/null @@ -1,402 +0,0 @@ -// Copyright (C) 2023, Ava Labs, Inc. All rights reserved. -// See the file LICENSE for licensing terms. - -package runner - -import ( - "context" - "crypto/ecdsa" - "fmt" - "os" - "time" - - runner_sdk "github.com/ava-labs/avalanche-network-runner/client" - "github.com/ava-labs/avalanche-network-runner/rpcpb" - runner_server "github.com/ava-labs/avalanche-network-runner/server" - "github.com/ava-labs/avalanchego/ids" - "github.com/ava-labs/avalanchego/utils/logging" - "github.com/ava-labs/avalanchego/utils/wrappers" - "github.com/ava-labs/subnet-evm/plugin/evm" - "github.com/ethereum/go-ethereum/log" - "github.com/onsi/ginkgo/v2" - "github.com/onsi/gomega" -) - -// Subnet provides the basic details of a created subnet -// Note: currently assumes one blockchain per subnet -type Subnet struct { - // SubnetID is the txID of the transaction that created the subnet - SubnetID ids.ID `json:"subnetID"` - // Current ANR assumes one blockchain per subnet, so we have a single blockchainID here - BlockchainID ids.ID `json:"blockchainID"` - // Key funded in the genesis of the blockchain - PreFundedKey *ecdsa.PrivateKey - // ValidatorURIs is the base URIs for each participant of the Subnet - ValidatorURIs []string `json:"validatorURIs"` -} - -type ANRConfig struct { - LogLevel string - AvalancheGoExecPath string - PluginDir string - GlobalNodeConfig string - GlobalCChainConfig string -} - -// NetworkManager is a wrapper around the ANR to simplify the setup and teardown code -// of tests that rely on the ANR. -type NetworkManager struct { - ANRConfig ANRConfig - - subnets []*Subnet - - logFactory logging.Factory - anrClient runner_sdk.Client - anrServer runner_server.Server - done chan struct{} - serverCtxCancel context.CancelFunc -} - -// NewDefaultANRConfig returns a default config for launching the avalanche-network-runner manager -// with both a server and client. -// By default, it expands $GOPATH/src/github.com/ava-labs/avalanchego/build/ directory to extract -// the AvalancheGoExecPath and PluginDir arguments. -// If the AVALANCHEGO_BUILD_PATH environment variable is set, it overrides the default location for -// the AvalancheGoExecPath and PluginDir arguments. -func NewDefaultANRConfig() ANRConfig { - defaultConfig := ANRConfig{ - LogLevel: "info", - AvalancheGoExecPath: os.ExpandEnv("$GOPATH/src/github.com/ava-labs/avalanchego/build/avalanchego"), - PluginDir: os.ExpandEnv("$GOPATH/src/github.com/ava-labs/avalanchego/build/plugins"), - GlobalNodeConfig: `{ - "log-display-level":"info", - "proposervm-use-current-height":true - }`, - GlobalCChainConfig: `{ - "warp-api-enabled": true, - "log-level": "debug" - }`, - } - // If AVALANCHEGO_BUILD_PATH is populated, override location set by GOPATH - if envBuildPath, exists := os.LookupEnv("AVALANCHEGO_BUILD_PATH"); exists { - defaultConfig.AvalancheGoExecPath = fmt.Sprintf("%s/avalanchego", envBuildPath) - defaultConfig.PluginDir = fmt.Sprintf("%s/plugins", envBuildPath) - } - return defaultConfig -} - -// NewNetworkManager constructs a new instance of a network manager -func NewNetworkManager(config ANRConfig) *NetworkManager { - manager := &NetworkManager{ - ANRConfig: config, - } - - logLevel, err := logging.ToLevel(config.LogLevel) - if err != nil { - panic(fmt.Errorf("invalid ANR log level: %w", err)) - } - manager.logFactory = logging.NewFactory(logging.Config{ - DisplayLevel: logLevel, - LogLevel: logLevel, - }) - - return manager -} - -// startServer starts a new ANR server and sets/overwrites the anrServer, done channel, and serverCtxCancel function. -func (n *NetworkManager) startServer(ctx context.Context) (<-chan struct{}, error) { - done := make(chan struct{}) - zapServerLog, err := n.logFactory.Make("server") - if err != nil { - return nil, fmt.Errorf("failed to make server log: %w", err) - } - - logLevel, err := logging.ToLevel(n.ANRConfig.LogLevel) - if err != nil { - return nil, fmt.Errorf("failed to parse ANR log level: %w", err) - } - - n.anrServer, err = runner_server.New( - runner_server.Config{ - Port: ":12352", - GwPort: ":12353", - GwDisabled: false, - DialTimeout: 10 * time.Second, - RedirectNodesOutput: true, - SnapshotsDir: "", - LogLevel: logLevel, - }, - zapServerLog, - ) - if err != nil { - return nil, fmt.Errorf("failed to start ANR server: %w", err) - } - n.done = done - - // Use a separate background context here, since the server should only be canceled by explicit shutdown - serverCtx, serverCtxCancel := context.WithCancel(context.Background()) - n.serverCtxCancel = serverCtxCancel - go func() { - if err := n.anrServer.Run(serverCtx); err != nil { - log.Error("Error shutting down ANR server", "err", err) - } else { - log.Info("Terminating ANR Server") - } - close(done) - }() - - return done, nil -} - -// startClient starts an ANR Client dialing the ANR server at the expected endpoint. -// Note: will overwrite client if it already exists. -func (n *NetworkManager) startClient() error { - logLevel, err := logging.ToLevel(n.ANRConfig.LogLevel) - if err != nil { - return fmt.Errorf("failed to parse ANR log level: %w", err) - } - logFactory := logging.NewFactory(logging.Config{ - DisplayLevel: logLevel, - LogLevel: logLevel, - }) - zapLog, err := logFactory.Make("main") - if err != nil { - return fmt.Errorf("failed to make client log: %w", err) - } - - n.anrClient, err = runner_sdk.New(runner_sdk.Config{ - Endpoint: "0.0.0.0:12352", - DialTimeout: 10 * time.Second, - }, zapLog) - if err != nil { - return fmt.Errorf("failed to start ANR client: %w", err) - } - - return nil -} - -// initServer starts the ANR server if it is not populated -func (n *NetworkManager) initServer() error { - if n.anrServer != nil { - return nil - } - - _, err := n.startServer(context.Background()) - return err -} - -// initClient starts an ANR client if it not populated -func (n *NetworkManager) initClient() error { - if n.anrClient != nil { - return nil - } - - return n.startClient() -} - -// init starts the ANR server and client if they are not yet populated -func (n *NetworkManager) init() error { - if err := n.initServer(); err != nil { - return err - } - return n.initClient() -} - -// StartDefaultNetwork constructs a default 5 node network. -func (n *NetworkManager) StartDefaultNetwork(ctx context.Context) (<-chan struct{}, error) { - if err := n.init(); err != nil { - return nil, err - } - - log.Info("Sending 'start'", "AvalancheGoExecPath", n.ANRConfig.AvalancheGoExecPath) - - // Start cluster - opts := []runner_sdk.OpOption{ - runner_sdk.WithPluginDir(n.ANRConfig.PluginDir), - runner_sdk.WithGlobalNodeConfig(n.ANRConfig.GlobalNodeConfig), - } - if len(n.ANRConfig.GlobalCChainConfig) != 0 { - opts = append(opts, runner_sdk.WithChainConfigs(map[string]string{ - "C": n.ANRConfig.GlobalCChainConfig, - })) - } - resp, err := n.anrClient.Start( - ctx, - n.ANRConfig.AvalancheGoExecPath, - opts..., - ) - if err != nil { - return nil, fmt.Errorf("failed to start ANR network: %w", err) - } - log.Info("successfully started cluster", "RootDataDir", resp.ClusterInfo.RootDataDir, "Subnets", resp.GetClusterInfo().GetSubnets()) - return n.done, nil -} - -// SetupNetwork constructs blockchains with the given [blockchainSpecs] and adds them to the network manager. -// Uses [execPath] as the AvalancheGo binary execution path for any started nodes. -// Note: this assumes that the default network has already been constructed. -func (n *NetworkManager) SetupNetwork(ctx context.Context, execPath string, blockchainSpecs []*rpcpb.BlockchainSpec) error { - // timeout according to how many blockchains we're creating - timeout := 2 * time.Minute * time.Duration(len(blockchainSpecs)) - cctx, cancel := context.WithTimeout(ctx, timeout) - defer cancel() - if err := n.init(); err != nil { - return err - } - sresp, err := n.anrClient.CreateBlockchains( - ctx, - blockchainSpecs, - ) - if err != nil { - return fmt.Errorf("failed to create blockchains: %w", err) - } - - // TODO: network runner health should imply custom VM healthiness - // or provide a separate API for custom VM healthiness - // "start" is async, so wait some time for cluster health - log.Info("waiting for all VMs to report healthy", "VMID", evm.ID) - for { - v, err := n.anrClient.Health(ctx) - log.Info("Pinged CLI Health", "result", v, "err", err) - if err != nil { - time.Sleep(1 * time.Second) - continue - } else if ctx.Err() != nil { - return fmt.Errorf("failed to await healthy network: %w", ctx.Err()) - } - break - } - - status, err := n.anrClient.Status(cctx) - if err != nil { - return fmt.Errorf("failed to get ANR status: %w", err) - } - nodeInfos := status.GetClusterInfo().GetNodeInfos() - - for i, chainSpec := range blockchainSpecs { - blockchainIDStr := sresp.ChainIds[i] - blockchainID, err := ids.FromString(blockchainIDStr) - if err != nil { - panic(err) - } - subnetIDStr := sresp.ClusterInfo.CustomChains[blockchainIDStr].SubnetId - subnetID, err := ids.FromString(subnetIDStr) - if err != nil { - panic(err) - } - subnet := &Subnet{ - SubnetID: subnetID, - BlockchainID: blockchainID, - } - for _, nodeName := range chainSpec.SubnetSpec.Participants { - subnet.ValidatorURIs = append(subnet.ValidatorURIs, nodeInfos[nodeName].Uri) - } - n.subnets = append(n.subnets, subnet) - } - - return nil -} - -// TeardownNetwork tears down the network constructed by the network manager and cleans up -// everything associated with it. -func (n *NetworkManager) TeardownNetwork() error { - if err := n.initClient(); err != nil { - return err - } - errs := wrappers.Errs{} - log.Info("Shutting down cluster") - ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute) - _, err := n.anrClient.Stop(ctx) - cancel() - errs.Add(err) - errs.Add(n.anrClient.Close()) - if n.serverCtxCancel != nil { - n.serverCtxCancel() - } - return errs.Err -} - -// CloseClient closes the connection between the ANR client and server without terminating the -// running network. -func (n *NetworkManager) CloseClient() error { - if n.anrClient == nil { - return nil - } - err := n.anrClient.Close() - n.anrClient = nil - return err -} - -// GetSubnets returns the IDs of the currently running subnets -func (n *NetworkManager) GetSubnets() []ids.ID { - subnetIDs := make([]ids.ID, 0, len(n.subnets)) - for _, subnet := range n.subnets { - subnetIDs = append(subnetIDs, subnet.SubnetID) - } - return subnetIDs -} - -// GetSubnet retrieves the subnet details for the requested subnetID -func (n *NetworkManager) GetSubnet(subnetID ids.ID) (*Subnet, bool) { - for _, subnet := range n.subnets { - if subnet.SubnetID == subnetID { - return subnet, true - } - } - return nil, false -} - -func (n *NetworkManager) GetAllURIs(ctx context.Context) ([]string, error) { - return n.anrClient.URIs(ctx) -} - -func RegisterFiveNodeSubnetRun() func() *Subnet { - var ( - config = NewDefaultANRConfig() - manager = NewNetworkManager(config) - numNodes = 5 - ) - - _ = ginkgo.BeforeSuite(func() { - // Name 10 new validators (which should have BLS key registered) - subnetA := make([]string, 0) - for i := 1; i <= numNodes; i++ { - subnetA = append(subnetA, fmt.Sprintf("node%d-bls", i)) - } - - ctx := context.Background() - var err error - _, err = manager.StartDefaultNetwork(ctx) - gomega.Expect(err).Should(gomega.BeNil()) - err = manager.SetupNetwork( - ctx, - config.AvalancheGoExecPath, - []*rpcpb.BlockchainSpec{ - { - VmName: evm.IDStr, - Genesis: "./tests/load/genesis/genesis.json", - ChainConfig: "", - SubnetSpec: &rpcpb.SubnetSpec{ - Participants: subnetA, - }, - }, - }, - ) - gomega.Expect(err).Should(gomega.BeNil()) - }) - - _ = ginkgo.AfterSuite(func() { - gomega.Expect(manager).ShouldNot(gomega.BeNil()) - gomega.Expect(manager.TeardownNetwork()).Should(gomega.BeNil()) - // TODO: bootstrap an additional node to ensure that we can bootstrap the test data correctly - }) - - return func() *Subnet { - subnetIDs := manager.GetSubnets() - gomega.Expect(len(subnetIDs)).Should(gomega.Equal(1)) - subnetID := subnetIDs[0] - subnetDetails, ok := manager.GetSubnet(subnetID) - gomega.Expect(ok).Should(gomega.BeTrue()) - return subnetDetails - } -} diff --git a/tests/warp/warp_test.go b/tests/warp/warp_test.go index 6c1f72dd1e..4bd9487a0a 100644 --- a/tests/warp/warp_test.go +++ b/tests/warp/warp_test.go @@ -47,7 +47,6 @@ import ( "github.com/ava-labs/subnet-evm/predicate" "github.com/ava-labs/subnet-evm/tests" "github.com/ava-labs/subnet-evm/tests/utils" - "github.com/ava-labs/subnet-evm/tests/utils/runner" warpBackend "github.com/ava-labs/subnet-evm/warp" "github.com/ava-labs/subnet-evm/warp/aggregator" "github.com/ava-labs/subnet-evm/x/warp" @@ -65,7 +64,7 @@ var ( genesisPath = filepath.Join(repoRootPath, "tests/precompile/genesis/warp.json") - subnetA, subnetB, cChainSubnetDetails *runner.Subnet + subnetA, subnetB, cChainSubnetDetails *Subnet testPayload = []byte{1, 2, 3} ) @@ -75,6 +74,18 @@ func init() { flagVars = e2e.RegisterFlags() } +// subnet provides the basic details of a created subnet +type Subnet struct { + // SubnetID is the txID of the transaction that created the subnet + SubnetID ids.ID + // For simplicity assume a single blockchain per subnet + BlockchainID ids.ID + // Key funded in the genesis of the blockchain + PreFundedKey *ecdsa.PrivateKey + // ValidatorURIs are the base URIs for each participant of the Subnet + ValidatorURIs []string +} + func TestE2E(t *testing.T) { gomega.RegisterFailHandler(ginkgo.Fail) ginkgo.RunSpecs(t, "subnet-evm warp e2e test") @@ -109,7 +120,7 @@ var _ = ginkgo.SynchronizedBeforeSuite(func() []byte { tmpnetSubnetA := network.GetSubnet(subnetAName) require.NotNil(tmpnetSubnetA) - subnetA = &runner.Subnet{ + subnetA = &Subnet{ SubnetID: tmpnetSubnetA.SubnetID, BlockchainID: tmpnetSubnetA.Chains[0].ChainID, PreFundedKey: tmpnetSubnetA.Chains[0].PreFundedKey.ToECDSA(), @@ -118,7 +129,7 @@ var _ = ginkgo.SynchronizedBeforeSuite(func() []byte { tmpnetSubnetB := network.GetSubnet(subnetBName) require.NotNil(tmpnetSubnetB) - subnetB = &runner.Subnet{ + subnetB = &Subnet{ SubnetID: tmpnetSubnetB.SubnetID, BlockchainID: tmpnetSubnetB.Chains[0].ChainID, PreFundedKey: tmpnetSubnetB.Chains[0].PreFundedKey.ToECDSA(), @@ -129,7 +140,7 @@ var _ = ginkgo.SynchronizedBeforeSuite(func() []byte { cChainBlockchainID, err := infoClient.GetBlockchainID(e2e.DefaultContext(), "C") require.NoError(err) - cChainSubnetDetails = &runner.Subnet{ + cChainSubnetDetails = &Subnet{ SubnetID: constants.PrimaryNetworkID, BlockchainID: cChainBlockchainID, PreFundedKey: tmpnet.HardhatKey.ToECDSA(), @@ -138,7 +149,7 @@ var _ = ginkgo.SynchronizedBeforeSuite(func() []byte { }) var _ = ginkgo.Describe("[Warp]", func() { - testFunc := func(sendingSubnet *runner.Subnet, receivingSubnet *runner.Subnet) { + testFunc := func(sendingSubnet *Subnet, receivingSubnet *Subnet) { w := newWarpTest(e2e.DefaultContext(), sendingSubnet, receivingSubnet) log.Info("Sending message from A to B") @@ -174,7 +185,7 @@ type warpTest struct { networkID uint32 // sendingSubnet fields set in the constructor - sendingSubnet *runner.Subnet + sendingSubnet *Subnet sendingSubnetURIs []string sendingSubnetClients []ethclient.Client sendingSubnetFundedKey *ecdsa.PrivateKey @@ -183,7 +194,7 @@ type warpTest struct { sendingSubnetSigner types.Signer // receivingSubnet fields set in the constructor - receivingSubnet *runner.Subnet + receivingSubnet *Subnet receivingSubnetURIs []string receivingSubnetClients []ethclient.Client receivingSubnetFundedKey *ecdsa.PrivateKey @@ -201,7 +212,7 @@ type warpTest struct { addressedCallSignedMessage *avalancheWarp.Message } -func newWarpTest(ctx context.Context, sendingSubnet *runner.Subnet, receivingSubnet *runner.Subnet) *warpTest { +func newWarpTest(ctx context.Context, sendingSubnet *Subnet, receivingSubnet *Subnet) *warpTest { require := require.New(ginkgo.GinkgoT()) sendingSubnetFundedKey := sendingSubnet.PreFundedKey