diff --git a/examples/local/fivenodenetwork/main.go b/examples/local/fivenodenetwork/main.go index 69cd8aa8..7a33b2d9 100644 --- a/examples/local/fivenodenetwork/main.go +++ b/examples/local/fivenodenetwork/main.go @@ -46,7 +46,10 @@ func shutdownOnSignal( // The network runs until the user provides a SIGINT or SIGTERM. func main() { // Create the logger - logFactory := logging.NewFactory(logging.DefaultConfig) + logFactory := logging.NewFactory(logging.Config{ + DisplayLevel: logging.Info, + LogLevel: logging.Debug, + }) log, err := logFactory.Make("main") if err != nil { fmt.Println(err) diff --git a/examples/local/indepth/main.go b/examples/local/indepth/main.go index ce119409..3f943af1 100644 --- a/examples/local/indepth/main.go +++ b/examples/local/indepth/main.go @@ -53,7 +53,10 @@ func shutdownOnSignal( // The network runs until the user provides a SIGINT or SIGTERM. func main() { // Create the logger - logFactory := logging.NewFactory(logging.DefaultConfig) + logFactory := logging.NewFactory(logging.Config{ + DisplayLevel: logging.Info, + LogLevel: logging.Debug, + }) log, err := logFactory.Make("main") if err != nil { fmt.Println(err) diff --git a/go.mod b/go.mod index 269e4fb3..bef364d8 100644 --- a/go.mod +++ b/go.mod @@ -3,27 +3,27 @@ module github.com/ava-labs/avalanche-network-runner go 1.17 require ( - github.com/ava-labs/avalanchego v1.7.11-0.20220416161358-8755486a274e - github.com/ava-labs/coreth v0.8.9-rc.1 + github.com/ava-labs/avalanchego v1.7.11 + github.com/ava-labs/coreth v0.8.10-rc.7 github.com/ethereum/go-ethereum v1.10.16 github.com/grpc-ecosystem/grpc-gateway/v2 v2.7.2 github.com/onsi/ginkgo/v2 v2.1.3 github.com/onsi/gomega v1.19.0 - github.com/prometheus/client_golang v1.11.0 + github.com/prometheus/client_golang v1.12.1 github.com/spf13/cobra v1.3.0 github.com/stretchr/testify v1.7.0 go.uber.org/zap v1.21.0 golang.org/x/sync v0.0.0-20210220032951-036812b2e83c google.golang.org/genproto v0.0.0-20220228195345-15d65a4533f7 google.golang.org/grpc v1.45.0 - google.golang.org/protobuf v1.27.1 + google.golang.org/protobuf v1.28.0 ) require ( github.com/Microsoft/go-winio v0.4.16 // indirect github.com/NYTimes/gziphandler v1.1.1 // indirect github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6 // indirect - github.com/VictoriaMetrics/fastcache v1.9.0 // indirect + github.com/VictoriaMetrics/fastcache v1.10.0 // indirect github.com/benbjohnson/clock v1.3.0 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/btcsuite/btcd v0.21.0-beta // indirect @@ -79,8 +79,8 @@ require ( github.com/pelletier/go-toml v1.9.4 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/prometheus/client_model v0.2.0 // indirect - github.com/prometheus/common v0.26.0 // indirect - github.com/prometheus/procfs v0.6.0 // indirect + github.com/prometheus/common v0.32.1 // indirect + github.com/prometheus/procfs v0.7.3 // indirect github.com/rjeczalik/notify v0.9.2 // indirect github.com/rs/cors v1.7.0 // indirect github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible // indirect @@ -99,14 +99,15 @@ require ( github.com/tyler-smith/go-bip39 v1.0.2 // indirect go.uber.org/atomic v1.9.0 // indirect go.uber.org/multierr v1.8.0 // indirect - golang.org/x/crypto v0.0.0-20210817164053-32db794688a5 // indirect + golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 // indirect golang.org/x/net v0.0.0-20220225172249-27dd8689420f // indirect - golang.org/x/sys v0.0.0-20220227234510-4e6760a101f9 // indirect + golang.org/x/sys v0.0.0-20220405052023-b1e9470b6e64 // indirect golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect golang.org/x/text v0.3.7 // indirect golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac // indirect gonum.org/v1/gonum v0.9.1 // indirect gopkg.in/ini.v1 v1.66.2 // indirect + gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect gopkg.in/urfave/cli.v1 v1.20.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect diff --git a/go.sum b/go.sum index 86da802b..950d0585 100644 --- a/go.sum +++ b/go.sum @@ -97,6 +97,8 @@ github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6/go.mod h1:3eOhrU github.com/VictoriaMetrics/fastcache v1.6.0/go.mod h1:0qHz5QP0GMX4pfmMA/zt5RgfNuXJrTP0zS7DqpHGGTw= github.com/VictoriaMetrics/fastcache v1.9.0 h1:oMwsS6c8abz98B7ytAewQ7M1ZN/Im/iwKoE1euaFvhs= github.com/VictoriaMetrics/fastcache v1.9.0/go.mod h1:otoTS3xu+6IzF/qByjqzjp3rTuzM3Qf0ScU1UTj97iU= +github.com/VictoriaMetrics/fastcache v1.10.0 h1:5hDJnLsKLpnUEToub7ETuRu8RCkb40woBZAUiKonXzY= +github.com/VictoriaMetrics/fastcache v1.10.0/go.mod h1:tjiYeEfYXCqacuvYw/7UoDIeJaNxq6132xHICNP77w8= github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII= github.com/ajstarks/svgo v0.0.0-20180226025133-644b8db467af/go.mod h1:K08gAheRH3/J6wwsYMMT4xOr94bZjxIelGM0+d/wbFw= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= @@ -126,6 +128,8 @@ github.com/ava-labs/avalanchego v1.7.7-rc.4/go.mod h1:ZFuoVdAoCKS3Q4NFBKsR7TVCGy github.com/ava-labs/avalanchego v1.7.8/go.mod h1:1QNPNIFEYjNevyzaGx+RhdhWGG5LiA6Mn3iomnkf/h0= github.com/ava-labs/avalanchego v1.7.11-0.20220416161358-8755486a274e h1:BC9sVeGLUgT/hPiQQs8WSD6jLlck1r51J8SM4ihJhg4= github.com/ava-labs/avalanchego v1.7.11-0.20220416161358-8755486a274e/go.mod h1:QVjeerfAaeS//G34swRgfrZu77SRpcprOkvkrJ+MeVE= +github.com/ava-labs/avalanchego v1.7.11 h1:tb/dYm85sUm1M0N+2yfwq4dm1X967PKDdjU3lmg7qEs= +github.com/ava-labs/avalanchego v1.7.11/go.mod h1:z/zteB07lMn/xO0aPRJOw80VGuLsn7FRfgbMCd0y4HY= github.com/ava-labs/avalanchego-operator v0.0.0-20211115144351-99f07d2570bf/go.mod h1:RTkVkouQ0HBSBVSFAQCUviXPU7Iuxoy+Fui3ykmD9HA= github.com/ava-labs/coreth v0.8.4-rc.1/go.mod h1:bP2Atm7pCJdx8fwzsPT3xU/kWOdHFklpja7aRNT++Qo= github.com/ava-labs/coreth v0.8.4-rc.3/go.mod h1:9TgpLJVY9ot6RV8Lh66F356S4MfalvaL3sAqw4+miTU= @@ -134,6 +138,8 @@ github.com/ava-labs/coreth v0.8.7-rc.1/go.mod h1:E9yfBswaDbV3WeFeX90wS0eRAfeW7WP github.com/ava-labs/coreth v0.8.8-rc.0/go.mod h1:HC8D4Ei7PNRzpPpqGC/M08YYeBp1kogJBVcWIfGseVA= github.com/ava-labs/coreth v0.8.9-rc.1 h1:ZqNZlStP9DVS5+rTuWDkR7m0o2QGO06YS8F5Fjt0lmY= github.com/ava-labs/coreth v0.8.9-rc.1/go.mod h1:ScMfik1WsNItRzz45Id8JvhOMTAxdlPwFiQpPp5a2ks= +github.com/ava-labs/coreth v0.8.10-rc.7 h1:AAltb0z0iZxM4+3KwzYTsB9yM5/uvSCgIZ45OM+jMxA= +github.com/ava-labs/coreth v0.8.10-rc.7/go.mod h1:O80e8u3YOQeXLMRqy9M3sS3hwty0qDZJ3G2Ne09rN30= github.com/aws/aws-sdk-go-v2 v1.2.0/go.mod h1:zEQs02YRBw1DjK0PoJv3ygDYOFTre1ejlJWl8FwAuQo= github.com/aws/aws-sdk-go-v2/config v1.1.1/go.mod h1:0XsVy9lBI/BCXm+2Tuvt39YmdHwS5unDQmxZOYe8F5Y= github.com/aws/aws-sdk-go-v2/credentials v1.1.1/go.mod h1:mM2iIjwl7LULWtS6JCACyInboHirisUUdkBPoTHMOUo= @@ -761,6 +767,8 @@ github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3O github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= github.com/prometheus/client_golang v1.11.0 h1:HNkLOAEQMIDv/K+04rukrLx6ch7msSRwf3/SASFAGtQ= github.com/prometheus/client_golang v1.11.0/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqroYurpAkEiz0P2BEV0= +github.com/prometheus/client_golang v1.12.1 h1:ZiaPsmm9uiBeaSMRznKsCDNtPCS0T3JVDGF+06gjBzk= +github.com/prometheus/client_golang v1.12.1/go.mod h1:3Z9XVyYiZYEO+YQWt3RD2R3jrbd179Rt297l4aS6nDY= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= @@ -774,6 +782,8 @@ github.com/prometheus/common v0.9.1/go.mod h1:yhUN8i9wzaXS3w1O07YhxHEBxD+W35wd8b github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo= github.com/prometheus/common v0.26.0 h1:iMAkS2TDoNWnKM+Kopnx/8tnEStIfpYA0ur0xQzzhMQ= github.com/prometheus/common v0.26.0/go.mod h1:M7rCNAaPfAosfx8veZJCuw84e35h3Cfd9VFqTh1DIvc= +github.com/prometheus/common v0.32.1 h1:hWIdL3N2HoUx3B8j3YN9mWor0qhY/NlEKZEaXxuIRh4= +github.com/prometheus/common v0.32.1/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= @@ -782,6 +792,8 @@ github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4O github.com/prometheus/procfs v0.2.0/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= github.com/prometheus/procfs v0.6.0 h1:mxy4L2jP6qMonqmq+aTtOx1ifVWUgG/TAmntgbh3xv4= github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= +github.com/prometheus/procfs v0.7.3 h1:4jVXhlkAyzOScmCkXBTOLRLTz8EeU+eyjrwB/EPq0VU= +github.com/prometheus/procfs v0.7.3/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= github.com/prometheus/tsdb v0.10.0 h1:If5rVCMTp6W2SiRAQFlbpJNgVlgMEd+U2GZckwK38ic= github.com/prometheus/tsdb v0.10.0/go.mod h1:oi49uRhEe9dPUTlS3JRZOwJuVi6tmh10QSgwXEyGCt4= @@ -965,6 +977,8 @@ golang.org/x/crypto v0.0.0-20210220033148-5ea612d1eb83/go.mod h1:jdWPYTVW3xRLrWP golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= golang.org/x/crypto v0.0.0-20210817164053-32db794688a5 h1:HWj/xjIHfjYU5nVXpTM0s39J9CbLn7Cc5a7IC5rwsMQ= golang.org/x/crypto v0.0.0-20210817164053-32db794688a5/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 h1:7I4JAnoQBe7ZtJcBaYHi5UtiO8tQHbUSXxL+pnGRANg= +golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20180807140117-3d87b88a115f/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= @@ -1068,6 +1082,7 @@ golang.org/x/net v0.0.0-20210410081132-afb366fc7cd1/go.mod h1:9tjilg8BloeKEkVJvy golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk= golang.org/x/net v0.0.0-20210503060351-7fd8e65b6420/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20210520170846-37e1c6afe023/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20210813160813-60bc85c4be6d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220225172249-27dd8689420f h1:oA4XRj0qtSt8Yo1Zms0CUlsT3KG69V2UGQWPBxujDmc= @@ -1195,9 +1210,12 @@ golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20211124211545-fe61309f8881/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211205182925-97ca703d548d/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220204135822-1c1b9b1eba6a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220227234510-4e6760a101f9 h1:nhht2DYV/Sn3qOayu8lM+cU1ii9sTLUeBQwQQfUHtrs= golang.org/x/sys v0.0.0-20220227234510-4e6760a101f9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220405052023-b1e9470b6e64 h1:D1v9ucDTYBtbz5vNuBbAhIMAGhQhJ6Ym5ah3maMVNX4= +golang.org/x/sys v0.0.0-20220405052023-b1e9470b6e64/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= @@ -1462,6 +1480,8 @@ google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp0 google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.27.1 h1:SnqbnDw1V7RiZcXPx5MEeqPv2s79L9i7BJUlG/+RurQ= google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= +google.golang.org/protobuf v1.28.0 h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw= +google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= 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= @@ -1476,6 +1496,7 @@ gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= gopkg.in/ini.v1 v1.51.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/ini.v1 v1.66.2 h1:XfR1dOYubytKy4Shzc2LHrrGhU0lDCfDGG1yLPmpgsI= gopkg.in/ini.v1 v1.66.2/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= +gopkg.in/natefinch/lumberjack.v2 v2.0.0 h1:1Lc07Kr7qY4U2YPouBjpCLxpiyxIVoxqXgkXLknAOE8= gopkg.in/natefinch/lumberjack.v2 v2.0.0/go.mod h1:l0ndWWf7gzL7RNwBG7wST/UCcT4T24xpD6X8LsfU/+k= gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce/go.mod h1:5AcXVHNjg+BDxry382+8OKon8SEWiKktQR07RKPsv1c= gopkg.in/olebedev/go-duktape.v3 v3.0.0-20200619000410-60c24ae608a6/go.mod h1:uAJfkITjFhyEEuUfm7bsmCZRbW5WRq8s9EY8HZ6hCns= diff --git a/local/network.go b/local/network.go index d8547e04..1b991ae2 100644 --- a/local/network.go +++ b/local/network.go @@ -23,9 +23,9 @@ import ( "github.com/ava-labs/avalanche-network-runner/utils" "github.com/ava-labs/avalanchego/config" "github.com/ava-labs/avalanchego/staking" - avago_utils "github.com/ava-labs/avalanchego/utils" "github.com/ava-labs/avalanchego/utils/beacon" "github.com/ava-labs/avalanchego/utils/constants" + "github.com/ava-labs/avalanchego/utils/ips" "github.com/ava-labs/avalanchego/utils/logging" "github.com/ava-labs/avalanchego/utils/wrappers" dircopy "github.com/otiai10/copy" @@ -480,7 +480,7 @@ func (ln *localNetwork) addNode(nodeConfig node.Config) (node.Node, error) { // Note that we do this *after* we set this node's bootstrap IPs/IDs // so this node won't try to use itself as a beacon. if nodeConfig.IsBeacon { - err = ln.bootstraps.Add(beacon.New(nodeID, avago_utils.IPDesc{ + err = ln.bootstraps.Add(beacon.New(nodeID, ips.IPPort{ IP: net.IPv6loopback, Port: p2pPort, })) diff --git a/local/network_test.go b/local/network_test.go index d633d999..46d5afc0 100644 --- a/local/network_test.go +++ b/local/network_test.go @@ -24,7 +24,6 @@ import ( "github.com/ava-labs/avalanchego/ids" "github.com/ava-labs/avalanchego/message" "github.com/ava-labs/avalanchego/snow/networking/router" - "github.com/ava-labs/avalanchego/utils/constants" "github.com/ava-labs/avalanchego/utils/logging" "github.com/ava-labs/avalanchego/utils/rpc" "github.com/stretchr/testify/assert" @@ -543,7 +542,7 @@ func TestGenerateDefaultNetwork(t *testing.T) { node, err := net.GetNode(nodeInfo.name) assert.NoError(err) assert.EqualValues(nodeInfo.name, node.GetName()) - expectedID, err := ids.ShortFromPrefixedString(nodeInfo.ID, constants.NodeIDPrefix) + expectedID, err := ids.NodeIDFromString(nodeInfo.ID) assert.NoError(err) assert.EqualValues(expectedID, node.GetNodeID()) } @@ -910,7 +909,7 @@ func emptyNetworkConfig() (network.Config, error) { }, }, nil, - []ids.ShortID{ids.GenerateTestShortID()}, + []ids.NodeID{ids.GenerateTestNodeID()}, ) if err != nil { return network.Config{}, err diff --git a/local/node.go b/local/node.go index 39304a1b..4ccdc558 100644 --- a/local/node.go +++ b/local/node.go @@ -16,11 +16,14 @@ import ( "github.com/ava-labs/avalanchego/network/peer" "github.com/ava-labs/avalanchego/network/throttling" "github.com/ava-labs/avalanchego/snow/networking/router" + "github.com/ava-labs/avalanchego/snow/networking/tracker" "github.com/ava-labs/avalanchego/snow/validators" "github.com/ava-labs/avalanchego/staking" - avago_utils "github.com/ava-labs/avalanchego/utils" "github.com/ava-labs/avalanchego/utils/constants" + "github.com/ava-labs/avalanchego/utils/ips" "github.com/ava-labs/avalanchego/utils/logging" + "github.com/ava-labs/avalanchego/utils/math/meter" + "github.com/ava-labs/avalanchego/utils/resource" "github.com/ava-labs/avalanchego/version" "github.com/prometheus/client_golang/prometheus" ) @@ -45,6 +48,11 @@ type NodeProcess interface { Wait() error } +const ( + peerMsgQueueBufferSize = 1024 + peerResourceTrackerDuration = 10 * time.Second +) + type nodeProcessImpl struct { cmd *exec.Cmd } @@ -67,7 +75,7 @@ type localNode struct { name string // [nodeID] is this node's Avalannche Node ID. // Set in network.AddNode - nodeID ids.ShortID + nodeID ids.NodeID // The ID of the network this node exists in networkID uint32 // Allows user to make API calls to this node. @@ -123,16 +131,24 @@ func (node *localNode) AttachPeer(ctx context.Context, router router.InboundHand if err != nil { return nil, err } - ip := avago_utils.IPDesc{ + ip := ips.IPPort{ IP: net.IPv6zero, Port: 0, } + resourceTracker, err := tracker.NewResourceTracker( + prometheus.NewRegistry(), + resource.NoUsage, + meter.ContinuousFactory{}, + peerResourceTrackerDuration, + ) + if err != nil { + return nil, err + } config := &peer.Config{ - Metrics: metrics, - MessageCreator: mc, - Log: logging.NoLog{}, - InboundMsgThrottler: throttling.NewNoInboundThrottler(), - OutboundMsgThrottler: throttling.NewNoOutboundThrottler(), + Metrics: metrics, + MessageCreator: mc, + Log: logging.NoLog{}, + InboundMsgThrottler: throttling.NewNoInboundThrottler(), Network: peer.NewTestNetwork( mc, node.networkID, @@ -144,13 +160,14 @@ func (node *localNode) AttachPeer(ctx context.Context, router router.InboundHand ), Router: router, VersionCompatibility: version.GetCompatibility(node.networkID), - VersionParser: version.NewDefaultApplicationParser(), + VersionParser: version.DefaultApplicationParser, MySubnets: ids.Set{}, Beacons: validators.NewSet(), NetworkID: node.networkID, PingFrequency: constants.DefaultPingFrequency, PongTimeout: constants.DefaultPingPongTimeout, MaxClockDifference: time.Minute, + ResourceTracker: resourceTracker, } _, conn, cert, err := clientUpgrader.Upgrade(conn) if err != nil { @@ -161,7 +178,12 @@ func (node *localNode) AttachPeer(ctx context.Context, router router.InboundHand config, conn, cert, - peer.CertToID(tlsCert.Leaf), + ids.NodeIDFromCert(tlsCert.Leaf), + peer.NewBlockingMessageQueue( + config.Metrics, + logging.NoLog{}, + peerMsgQueueBufferSize, + ), ) if err != nil { return nil, err @@ -176,7 +198,7 @@ func (node *localNode) GetName() string { } // See node.Node -func (node *localNode) GetNodeID() ids.ShortID { +func (node *localNode) GetNodeID() ids.NodeID { return node.nodeID } diff --git a/local/node_test.go b/local/node_test.go index f6c01643..3d301b57 100644 --- a/local/node_test.go +++ b/local/node_test.go @@ -16,15 +16,15 @@ import ( "github.com/ava-labs/avalanchego/message" "github.com/ava-labs/avalanchego/network/peer" "github.com/ava-labs/avalanchego/staking" - "github.com/ava-labs/avalanchego/utils" "github.com/ava-labs/avalanchego/utils/constants" + "github.com/ava-labs/avalanchego/utils/ips" "github.com/ava-labs/avalanchego/utils/wrappers" "github.com/ava-labs/avalanchego/version" "github.com/prometheus/client_golang/prometheus" "github.com/stretchr/testify/assert" ) -func upgradeConn(myTLSCert *tls.Certificate, conn net.Conn) (ids.ShortID, net.Conn, error) { +func upgradeConn(myTLSCert *tls.Certificate, conn net.Conn) (ids.NodeID, net.Conn, error) { tlsConfig := peer.TLSConfig(*myTLSCert) upgrader := peer.NewTLSServerUpgrader(tlsConfig) // this will block until the ssh handshake is done @@ -65,7 +65,7 @@ func verifyProtocol( // send the peer our version and peerlist // create the version message - myIP := utils.IPDesc{ + myIP := ips.IPPort{ IP: net.IPv6zero, Port: 0, } @@ -95,7 +95,7 @@ func verifyProtocol( } // create the PeerList message - plMsg, err := mc.PeerList([]utils.IPCertDesc{}, true) + plMsg, err := mc.PeerList([]ips.ClaimedIPPort{}, true) if err != nil { errCh <- err return @@ -185,7 +185,7 @@ func TestAttachPeer(t *testing.T) { }() node := localNode{ - nodeID: ids.GenerateTestShortID(), + nodeID: ids.GenerateTestNodeID(), networkID: constants.MainnetID, getConnFunc: func(ctx context.Context, n node.Node) (net.Conn, error) { return peerConn, nil @@ -236,7 +236,7 @@ func TestAttachPeer(t *testing.T) { msg, err := mc.Chits(chainID, requestID, containerIDs) assert.NoError(err) // send chits to [node] - ok := p.Send(msg) + ok := p.Send(context.Background(), msg) assert.True(ok) // wait until the go routines are done // also ensures that [assert] calls will be reflected in test results if failed diff --git a/network/config.go b/network/config.go index 68139928..bce7493c 100644 --- a/network/config.go +++ b/network/config.go @@ -12,7 +12,7 @@ import ( "github.com/ava-labs/avalanchego/genesis" "github.com/ava-labs/avalanchego/ids" "github.com/ava-labs/avalanchego/utils/constants" - "github.com/ava-labs/avalanchego/utils/formatting" + "github.com/ava-labs/avalanchego/utils/formatting/address" "github.com/ava-labs/avalanchego/utils/units" ) @@ -98,7 +98,7 @@ func NewAvalancheGoGenesis( networkID uint32, xChainBalances []AddrAndBalance, cChainBalances []AddrAndBalance, - genesisVdrs []ids.ShortID, + genesisVdrs []ids.NodeID, ) ([]byte, error) { switch networkID { case constants.TestnetID, constants.MainnetID, constants.LocalID: @@ -112,7 +112,11 @@ func NewAvalancheGoGenesis( } // Address that controls stake doesn't matter -- generate it randomly - genesisVdrStakeAddr, _ := formatting.FormatAddress("X", constants.GetHRP(networkID), ids.GenerateTestShortID().Bytes()) + genesisVdrStakeAddr, _ := address.Format( + "X", + constants.GetHRP(networkID), + ids.GenerateTestShortID().Bytes(), + ) config := genesis.UnparsedConfig{ NetworkID: networkID, Allocations: []genesis.UnparsedAllocation{ @@ -135,7 +139,7 @@ func NewAvalancheGoGenesis( } for _, xChainBal := range xChainBalances { - xChainAddr, _ := formatting.FormatAddress("X", constants.GetHRP(networkID), xChainBal.Addr[:]) + xChainAddr, _ := address.Format("X", constants.GetHRP(networkID), xChainBal.Addr[:]) config.Allocations = append( config.Allocations, genesis.UnparsedAllocation{ @@ -172,12 +176,12 @@ func NewAvalancheGoGenesis( // Set initial validators. // Give staking rewards to random address. - rewardAddr, _ := formatting.FormatAddress("X", constants.GetHRP(networkID), ids.GenerateTestShortID().Bytes()) + rewardAddr, _ := address.Format("X", constants.GetHRP(networkID), ids.GenerateTestShortID().Bytes()) for _, genesisVdr := range genesisVdrs { config.InitialStakers = append( config.InitialStakers, genesis.UnparsedStaker{ - NodeID: genesisVdr.PrefixedString(constants.NodeIDPrefix), + NodeID: genesisVdr, RewardAddress: rewardAddr, DelegationFee: 10_000, }, diff --git a/network/node/node.go b/network/node/node.go index 620b2d95..2acf09b9 100644 --- a/network/node/node.go +++ b/network/node/node.go @@ -19,7 +19,7 @@ type Node interface { // across all the nodes in its network. GetName() string // Return this node's Avalanche node ID. - GetNodeID() ids.ShortID + GetNodeID() ids.NodeID // Return a client that can be used to make API calls. GetAPIClient() api.Client // Return this node's IP (e.g. 127.0.0.1). diff --git a/server/custom_vms.go b/server/custom_vms.go index 977b1500..d572d1d4 100644 --- a/server/custom_vms.go +++ b/server/custom_vms.go @@ -21,6 +21,7 @@ import ( "github.com/ava-labs/avalanchego/utils/constants" "github.com/ava-labs/avalanchego/utils/units" "github.com/ava-labs/avalanchego/vms/platformvm" + "github.com/ava-labs/avalanchego/vms/platformvm/validator" "github.com/ava-labs/avalanchego/vms/secp256k1fx" "github.com/ava-labs/avalanchego/wallet/subnet/primary/common" "go.uber.org/zap" @@ -180,7 +181,7 @@ func (lc *localNetwork) setupWallet(ctx context.Context, httpRPCEp string) (base return baseWallet, avaxAssetID, testKeyAddr, nil } -func (lc *localNetwork) checkValidators(ctx context.Context, platformCli platformvm.Client, baseWallet *refreshableWallet, testKeyAddr ids.ShortID) (validatorIDs []ids.ShortID, err error) { +func (lc *localNetwork) checkValidators(ctx context.Context, platformCli platformvm.Client, baseWallet *refreshableWallet, testKeyAddr ids.ShortID) (validatorIDs []ids.NodeID, err error) { println() color.Outf("{{green}}fetching all nodes from the existing cluster to make sure all nodes are validating the primary network/subnet{{/}}\n") // ref. https://docs.avax.network/build/avalanchego-apis/p-chain/#platformgetcurrentvalidators @@ -190,31 +191,23 @@ func (lc *localNetwork) checkValidators(ctx context.Context, platformCli platfor if err != nil { return nil, err } - curValidators := make(map[string]struct{}) + curValidators := make(map[ids.NodeID]struct{}) for _, v := range vs { - va, ok := v.(map[string]interface{}) - if !ok { - return nil, fmt.Errorf("failed to parse validator data: %T %+v", v, v) - } - nodeID, ok := va["nodeID"].(string) - if !ok { - return nil, fmt.Errorf("failed to parse validator data: %T %+v", va, va) - } - curValidators[nodeID] = struct{}{} - zap.L().Info("current validator", zap.String("node-id", nodeID)) + curValidators[v.NodeID] = struct{}{} + zap.L().Info("current validator", zap.String("node-id", v.NodeID.String())) } println() color.Outf("{{green}}adding all nodes as validator for the primary subnet{{/}}\n") - validatorIDs = make([]ids.ShortID, 0, len(lc.nodeInfos)) + validatorIDs = make([]ids.NodeID, 0, len(lc.nodeInfos)) for nodeName, nodeInfo := range lc.nodeInfos { - nodeID, err := ids.ShortFromPrefixedString(nodeInfo.Id, constants.NodeIDPrefix) + nodeID, err := ids.NodeIDFromString(nodeInfo.Id) if err != nil { return nil, err } validatorIDs = append(validatorIDs, nodeID) - _, isValidator := curValidators[nodeInfo.Id] + _, isValidator := curValidators[nodeID] if isValidator { zap.L().Info("the node is already validating the primary subnet; skipping", zap.String("node-name", nodeName), @@ -229,7 +222,7 @@ func (lc *localNetwork) checkValidators(ctx context.Context, platformCli platfor ) cctx, cancel = createDefaultCtx(ctx) txID, err := baseWallet.P().IssueAddValidatorTx( - &platformvm.Validator{ + &validator.Validator{ NodeID: nodeID, Start: uint64(time.Now().Add(10 * time.Second).Unix()), End: uint64(time.Now().Add(300 * time.Hour).Unix()), @@ -350,7 +343,7 @@ func (lc *localNetwork) restartNodesWithWhitelistedSubnets(ctx context.Context) return nil } -func (lc *localNetwork) addSubnetValidators(ctx context.Context, baseWallet *refreshableWallet, validatorIDs []ids.ShortID) error { +func (lc *localNetwork) addSubnetValidators(ctx context.Context, baseWallet *refreshableWallet, validatorIDs []ids.NodeID) error { println() color.Outf("{{green}}adding all nodes as subnet validator for each subnet{{/}}\n") for vmID, vmInfo := range lc.customVMIDToInfo { @@ -362,8 +355,8 @@ func (lc *localNetwork) addSubnetValidators(ctx context.Context, baseWallet *ref for _, validatorID := range validatorIDs { cctx, cancel := createDefaultCtx(ctx) txID, err := baseWallet.P().IssueAddSubnetValidatorTx( - &platformvm.SubnetValidator{ - Validator: platformvm.Validator{ + &validator.SubnetValidator{ + Validator: validator.Validator{ NodeID: validatorID, // reasonable delay in most/slow test environments diff --git a/server/network.go b/server/network.go index 6cec5080..999b160c 100644 --- a/server/network.go +++ b/server/network.go @@ -19,7 +19,6 @@ import ( "github.com/ava-labs/avalanchego/config" "github.com/ava-labs/avalanchego/ids" "github.com/ava-labs/avalanchego/network/peer" - "github.com/ava-labs/avalanchego/utils/constants" "github.com/ava-labs/avalanchego/utils/logging" "go.uber.org/zap" ) @@ -103,7 +102,10 @@ type localNetworkOptions struct { } func newLocalNetwork(opts localNetworkOptions) (*localNetwork, error) { - lcfg := logging.DefaultConfig + lcfg := logging.Config{ + DisplayLevel: logging.Info, + LogLevel: logging.Debug, + } lcfg.Directory = opts.rootDataDir logFactory := logging.NewFactory(lcfg) logger, err := logFactory.Make("main") @@ -412,7 +414,7 @@ func (lc *localNetwork) updateNodeInfo() error { lc.nodeInfos[name] = &rpcpb.NodeInfo{ Name: node.GetName(), Uri: fmt.Sprintf("http://%s:%d", node.GetURL(), node.GetAPIPort()), - Id: node.GetNodeID().PrefixedString(constants.NodeIDPrefix), + Id: node.GetNodeID().String(), ExecPath: node.GetBinaryPath(), LogDir: node.GetLogsDir(), DbDir: node.GetDbDir(), diff --git a/server/server.go b/server/server.go index 5543d92a..464c8952 100644 --- a/server/server.go +++ b/server/server.go @@ -859,7 +859,7 @@ func (s *server) SendOutboundMessage(ctx context.Context, req *rpcpb.SendOutboun } msg := message.NewTestMsg(message.Op(req.Op), req.Bytes, false) - sent := attachedPeer.Send(msg) + sent := attachedPeer.Send(ctx, msg) return &rpcpb.SendOutboundMessageResponse{Sent: sent}, nil } diff --git a/utils/utils.go b/utils/utils.go index bff1f0e1..ee73e8a9 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -8,18 +8,17 @@ import ( "os" "github.com/ava-labs/avalanchego/ids" - "github.com/ava-labs/avalanchego/network/peer" "github.com/ava-labs/avalanchego/staking" ) const genesisNetworkIDKey = "networkID" -func ToNodeID(stakingKey, stakingCert []byte) (ids.ShortID, error) { +func ToNodeID(stakingKey, stakingCert []byte) (ids.NodeID, error) { cert, err := staking.LoadTLSCertFromBytes(stakingKey, stakingCert) if err != nil { - return ids.ShortID{}, err + return ids.EmptyNodeID, err } - nodeID := peer.CertToID(cert.Leaf) + nodeID := ids.NodeIDFromCert(cert.Leaf) return nodeID, nil }