From 366b0dc8cea67ded86e93ac6378eb389c22d35ee Mon Sep 17 00:00:00 2001 From: Ian Suvak Date: Thu, 3 Oct 2024 14:38:20 -0400 Subject: [PATCH 01/28] bump to v1.12.0-initial-poc.2 --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 8877b32d..f6423757 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/ava-labs/awm-relayer go 1.22.8 require ( - github.com/ava-labs/avalanchego v1.12.0-initial-poc.0 + github.com/ava-labs/avalanchego v1.12.0-initial-poc.2 github.com/ava-labs/coreth v0.13.8 github.com/ava-labs/subnet-evm v0.6.10 github.com/ava-labs/teleporter v1.0.7 diff --git a/go.sum b/go.sum index ad89e032..c92ccfd9 100644 --- a/go.sum +++ b/go.sum @@ -58,8 +58,8 @@ github.com/alexliesenfeld/health v0.8.0/go.mod h1:TfNP0f+9WQVWMQRzvMUjlws4ceXKEL github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156 h1:eMwmnE/GDgah4HI848JfFxHt+iPb26b4zyfspmqY0/8= github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156/go.mod h1:Cb/ax3seSYIx7SuZdm2G2xzfwmv3TPSk2ucNfQESPXM= github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= -github.com/ava-labs/avalanchego v1.12.0-initial-poc.0 h1:9JO0Yh4+fWfuoNenPgkJsaVuIh8cq4c1rYTD8Hv9fU8= -github.com/ava-labs/avalanchego v1.12.0-initial-poc.0/go.mod h1:qSHmog3wMVjo/ruIAQo0ppXAilyni07NIu5K88RyhWE= +github.com/ava-labs/avalanchego v1.12.0-initial-poc.2 h1:Xsb9XUXW1wjtP2yULhpknW9Ghobm2U3PW3z1MqP0SkY= +github.com/ava-labs/avalanchego v1.12.0-initial-poc.2/go.mod h1:qSHmog3wMVjo/ruIAQo0ppXAilyni07NIu5K88RyhWE= github.com/ava-labs/coreth v0.13.8 h1:f14X3KgwHl9LwzfxlN6S4bbn5VA2rhEsNnHaRLSTo/8= github.com/ava-labs/coreth v0.13.8/go.mod h1:t3BSv/eQv0AlDPMfEDCMMoD/jq1RkUsbFzQAFg5qBcE= github.com/ava-labs/subnet-evm v0.6.10 h1:uIh6bFMA4GCMVMQ3agBPxTMlYHL8FBR5FrhMR+drfKI= From 2db445c994d6dcb3125fbe1b0ada1f042ace8024 Mon Sep 17 00:00:00 2001 From: cam-schultz Date: Thu, 10 Oct 2024 11:17:24 -0500 Subject: [PATCH 02/28] avago poc v5 --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 7f2948f2..0f0822cf 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/ava-labs/awm-relayer go 1.22.8 require ( - github.com/ava-labs/avalanchego v1.12.0-initial-poc.2 + github.com/ava-labs/avalanchego v1.12.0-initial-poc.5 github.com/ava-labs/coreth v0.13.8 github.com/ava-labs/subnet-evm v0.6.10 github.com/ava-labs/teleporter v1.0.7 diff --git a/go.sum b/go.sum index 17682c32..df402e9a 100644 --- a/go.sum +++ b/go.sum @@ -58,8 +58,8 @@ github.com/alexliesenfeld/health v0.8.0/go.mod h1:TfNP0f+9WQVWMQRzvMUjlws4ceXKEL github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156 h1:eMwmnE/GDgah4HI848JfFxHt+iPb26b4zyfspmqY0/8= github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156/go.mod h1:Cb/ax3seSYIx7SuZdm2G2xzfwmv3TPSk2ucNfQESPXM= github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= -github.com/ava-labs/avalanchego v1.12.0-initial-poc.2 h1:Xsb9XUXW1wjtP2yULhpknW9Ghobm2U3PW3z1MqP0SkY= -github.com/ava-labs/avalanchego v1.12.0-initial-poc.2/go.mod h1:qSHmog3wMVjo/ruIAQo0ppXAilyni07NIu5K88RyhWE= +github.com/ava-labs/avalanchego v1.12.0-initial-poc.5 h1:gW4xAqZNvkA4gP8M9yDyd7YUzuwfQbbCR+hgd1ztOto= +github.com/ava-labs/avalanchego v1.12.0-initial-poc.5/go.mod h1:qSHmog3wMVjo/ruIAQo0ppXAilyni07NIu5K88RyhWE= github.com/ava-labs/coreth v0.13.8 h1:f14X3KgwHl9LwzfxlN6S4bbn5VA2rhEsNnHaRLSTo/8= github.com/ava-labs/coreth v0.13.8/go.mod h1:t3BSv/eQv0AlDPMfEDCMMoD/jq1RkUsbFzQAFg5qBcE= github.com/ava-labs/subnet-evm v0.6.10 h1:uIh6bFMA4GCMVMQ3agBPxTMlYHL8FBR5FrhMR+drfKI= From 472c76dde8218a842f4d769d5989f6a70d3573ab Mon Sep 17 00:00:00 2001 From: cam-schultz Date: Tue, 12 Nov 2024 11:28:51 -0600 Subject: [PATCH 03/28] avago initial poc 8 --- go.mod | 34 +++++++++++++++--- go.sum | 70 +++++++++++++++++++++++++++++++----- peers/app_request_network.go | 2 +- peers/info_client.go | 4 +-- relayer/main/main.go | 2 +- 5 files changed, 96 insertions(+), 16 deletions(-) diff --git a/go.mod b/go.mod index 0f0822cf..57cfce11 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/ava-labs/awm-relayer go 1.22.8 require ( - github.com/ava-labs/avalanchego v1.12.0-initial-poc.5 + github.com/ava-labs/avalanchego v1.12.0-initial-poc.8 github.com/ava-labs/coreth v0.13.8 github.com/ava-labs/subnet-evm v0.6.10 github.com/ava-labs/teleporter v1.0.7 @@ -64,6 +64,7 @@ require ( github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect github.com/dlclark/regexp2 v1.7.0 // indirect github.com/dop251/goja v0.0.0-20230806174421-c933cf95e127 // indirect + github.com/emicklei/go-restful/v3 v3.11.0 // indirect github.com/ethereum/c-kzg-4844 v0.4.0 // indirect github.com/fjl/memsize v0.0.2 // indirect github.com/fsnotify/fsnotify v1.6.0 // indirect @@ -74,12 +75,18 @@ require ( github.com/go-logr/logr v1.4.2 // indirect github.com/go-logr/stdr v1.2.2 // indirect github.com/go-ole/go-ole v1.3.0 // indirect + github.com/go-openapi/jsonpointer v0.19.6 // indirect + github.com/go-openapi/jsonreference v0.20.2 // indirect + github.com/go-openapi/swag v0.22.3 // indirect github.com/go-sourcemap/sourcemap v2.1.3+incompatible // indirect github.com/go-task/slim-sprig/v3 v3.0.0 // indirect github.com/gogo/protobuf v1.3.2 // indirect + github.com/golang/protobuf v1.5.4 // indirect github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb // indirect github.com/google/btree v1.1.2 // indirect + github.com/google/gnostic-models v0.6.8 // indirect github.com/google/go-cmp v0.6.0 // indirect + github.com/google/gofuzz v1.2.0 // indirect github.com/google/pprof v0.0.0-20240827171923-fa2c70bbbfe5 // indirect github.com/google/renameio/v2 v2.0.0 // indirect github.com/google/uuid v1.6.0 // indirect @@ -96,18 +103,25 @@ require ( github.com/huin/goupnp v1.3.0 // indirect github.com/jackpal/gateway v1.0.6 // indirect github.com/jackpal/go-nat-pmp v1.0.2 // indirect + github.com/josharian/intern v1.0.0 // indirect + github.com/json-iterator/go v1.1.12 // indirect github.com/klauspost/compress v1.17.9 // indirect github.com/kr/pretty v0.3.1 // indirect github.com/kr/text v0.2.0 // indirect github.com/magiconair/properties v1.8.7 // indirect + github.com/mailru/easyjson v0.7.7 // indirect github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.17 // indirect github.com/mattn/go-runewidth v0.0.13 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/mitchellh/pointerstructure v1.2.0 // indirect github.com/mmcloughlin/addchain v0.4.0 // indirect + github.com/moby/spdystream v0.2.0 // indirect + github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect + github.com/modern-go/reflect2 v1.0.2 // indirect github.com/mr-tron/base58 v1.2.0 // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect + github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f // indirect github.com/nbutton23/zxcvbn-go v0.0.0-20180912185939-ae427f1e4c1d // indirect github.com/olekukonko/tablewriter v0.0.5 // indirect github.com/pelletier/go-toml/v2 v2.0.8 // indirect @@ -117,7 +131,7 @@ require ( github.com/prometheus/common v0.55.0 // indirect github.com/prometheus/procfs v0.15.1 // indirect github.com/rivo/uniseg v0.2.0 // indirect - github.com/rogpeppe/go-internal v1.10.0 // indirect + github.com/rogpeppe/go-internal v1.12.0 // indirect github.com/rs/cors v1.7.0 // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect github.com/shirou/gopsutil v3.21.11+incompatible // indirect @@ -126,7 +140,7 @@ require ( github.com/spf13/jwalterweatherman v1.1.0 // indirect github.com/status-im/keycard-go v0.2.0 // indirect github.com/subosito/gotenv v1.4.2 // indirect - github.com/supranational/blst v0.3.11 // indirect + github.com/supranational/blst v0.3.13 // indirect github.com/syndtr/goleveldb v1.0.1-0.20220614013038-64ee5596c38a // indirect github.com/tklauser/go-sysconf v0.3.12 // indirect github.com/tklauser/numcpus v0.6.1 // indirect @@ -146,6 +160,7 @@ require ( golang.org/x/crypto v0.26.0 // indirect golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 // indirect golang.org/x/net v0.28.0 // indirect + golang.org/x/oauth2 v0.22.0 // indirect golang.org/x/sys v0.24.0 // indirect golang.org/x/term v0.23.0 // indirect golang.org/x/text v0.17.0 // indirect @@ -153,11 +168,22 @@ require ( golang.org/x/tools v0.24.0 // indirect gonum.org/v1/gonum v0.11.0 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240827150818-7e3bb234dfed // indirect + gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect + gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect + k8s.io/api v0.29.0 // indirect + k8s.io/apimachinery v0.29.0 // indirect + k8s.io/client-go v0.29.0 // indirect + k8s.io/klog/v2 v2.110.1 // indirect + k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00 // indirect + k8s.io/utils v0.0.0-20230726121419-3b25d923346b // indirect rsc.io/tmplfunc v0.0.3 // indirect + sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect + sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect + sigs.k8s.io/yaml v1.3.0 // indirect ) require ( diff --git a/go.sum b/go.sum index df402e9a..67e659b8 100644 --- a/go.sum +++ b/go.sum @@ -58,8 +58,10 @@ github.com/alexliesenfeld/health v0.8.0/go.mod h1:TfNP0f+9WQVWMQRzvMUjlws4ceXKEL github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156 h1:eMwmnE/GDgah4HI848JfFxHt+iPb26b4zyfspmqY0/8= github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156/go.mod h1:Cb/ax3seSYIx7SuZdm2G2xzfwmv3TPSk2ucNfQESPXM= github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= -github.com/ava-labs/avalanchego v1.12.0-initial-poc.5 h1:gW4xAqZNvkA4gP8M9yDyd7YUzuwfQbbCR+hgd1ztOto= -github.com/ava-labs/avalanchego v1.12.0-initial-poc.5/go.mod h1:qSHmog3wMVjo/ruIAQo0ppXAilyni07NIu5K88RyhWE= +github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio= +github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs= +github.com/ava-labs/avalanchego v1.12.0-initial-poc.8 h1:UuCN1CYPZgf2FGGaO4XURVPWHjbv2U++VkarrADeT64= +github.com/ava-labs/avalanchego v1.12.0-initial-poc.8/go.mod h1:86tO6F1FT8emclUwdQ2WCwAtAerqjm5A4IbV6XxNUyM= github.com/ava-labs/coreth v0.13.8 h1:f14X3KgwHl9LwzfxlN6S4bbn5VA2rhEsNnHaRLSTo/8= github.com/ava-labs/coreth v0.13.8/go.mod h1:t3BSv/eQv0AlDPMfEDCMMoD/jq1RkUsbFzQAFg5qBcE= github.com/ava-labs/subnet-evm v0.6.10 h1:uIh6bFMA4GCMVMQ3agBPxTMlYHL8FBR5FrhMR+drfKI= @@ -201,6 +203,8 @@ github.com/dop251/goja_nodejs v0.0.0-20210225215109-d91c329300e7/go.mod h1:hn7BA github.com/dop251/goja_nodejs v0.0.0-20211022123610-8dd9abb0616d/go.mod h1:DngW8aVqWbuLRMHItjPUyqdj+HWPvnQe8V8y1nDpIbM= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/eknkc/amber v0.0.0-20171010120322-cdade1c07385/go.mod h1:0vRUJqYpeSZifjYj7uP3BG/gKcuzL9xWVV/Y+cK33KM= +github.com/emicklei/go-restful/v3 v3.11.0 h1:rAQeMHw1c7zTmncogyy8VvRZwtkmkZ4FxERmMY4rD+g= +github.com/emicklei/go-restful/v3 v3.11.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= @@ -244,6 +248,7 @@ github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9 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-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= +github.com/go-logr/logr v1.3.0/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= @@ -252,6 +257,12 @@ github.com/go-martini/martini v0.0.0-20170121215854-22fa46961aab/go.mod h1:/P9AE github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= github.com/go-ole/go-ole v1.3.0 h1:Dt6ye7+vXGIKZ7Xtk4s6/xVdGDQynvom7xCFEdWr6uE= github.com/go-ole/go-ole v1.3.0/go.mod h1:5LS6F96DhAwUc7C+1HLexzMXY1xGRSryjyPPKW6zv78= +github.com/go-openapi/jsonpointer v0.19.6 h1:eCs3fxoIi3Wh6vtgmLTOjdhSpiqphQ+DaPn38N2ZdrE= +github.com/go-openapi/jsonpointer v0.19.6/go.mod h1:osyAmYz/mB/C3I+WsTTSgw1ONzaLJoLCyoi6/zppojs= +github.com/go-openapi/jsonreference v0.20.2 h1:3sVjiK66+uXK/6oQ8xgcRKcFgQ5KXa2KvnJRumpMGbE= +github.com/go-openapi/jsonreference v0.20.2/go.mod h1:Bl1zwGIM8/wsvqjsOQLJ/SH+En5Ap4rVB5KVcIDZG2k= +github.com/go-openapi/swag v0.22.3 h1:yMBqmnQ0gyZvEb/+KzuWZOXgllrXT4SADYbvDaXHv/g= +github.com/go-openapi/swag v0.22.3/go.mod h1:UzaqsxGiab7freDnrUUra0MwWfN/q7tE4j+VcZ0yl14= github.com/go-sourcemap/sourcemap v2.1.3+incompatible h1:W1iEw64niKVGogNgBN3ePyLFfuisuzeidWPMPWmECqU= github.com/go-sourcemap/sourcemap v2.1.3+incompatible/go.mod h1:F8jJfvm2KbVjc5NqelyYJmf/v5J0dwNLS2mL4sNA1Jg= github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE= @@ -308,6 +319,8 @@ github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Z github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v1.1.2 h1:xf4v41cLI2Z6FxbKm+8Bu+m8ifhj15JuZ9sa0jZCMUU= github.com/google/btree v1.1.2/go.mod h1:qOPhT0dTNdNzV6Z/lhRX0YXUafgPLFUh+gZMl761Gm4= +github.com/google/gnostic-models v0.6.8 h1:yo/ABAfM5IMRsS1VnXjTBvUb61tFIHozhlYvRgGre9I= +github.com/google/gnostic-models v0.6.8/go.mod h1:5n7qKqH0f5wFt+aWF8CW6pZLLNOfYuF5OpfBSENuI8U= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= @@ -318,10 +331,13 @@ github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= 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-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= +github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= github.com/google/martian/v3 v3.1.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= @@ -355,6 +371,7 @@ github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB7 github.com/gorilla/rpc v1.2.0 h1:WvvdC2lNeT1SP32zrIce5l0ECBfbAlmrmSBsuc57wfk= github.com/gorilla/rpc v1.2.0/go.mod h1:V4h9r+4sF5HnzqbwIez0fKSpANP0zlYd3qR7p36jkTQ= github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= +github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc= github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 h1:Ovs26xHkKqVztRpIrF/92BcuyuQ/YW4NSIpoGtfXNho= @@ -398,9 +415,13 @@ 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/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= +github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= 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 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= +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= @@ -437,6 +458,8 @@ github.com/leanovate/gopter v0.2.9/go.mod h1:U2L/78B+KVFIx2VmW6onHJQzXtFb+p5y3y2 github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY= github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= +github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= +github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= github.com/mattn/go-colorable v0.1.11/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= @@ -466,15 +489,22 @@ github.com/mitchellh/pointerstructure v1.2.0/go.mod h1:BRAsLI5zgXmw97Lf6s25bs8oh github.com/mmcloughlin/addchain v0.4.0 h1:SobOdjm2xLj1KkXN5/n0xTIWyZA2+s99UCY1iPfkHRY= github.com/mmcloughlin/addchain v0.4.0/go.mod h1:A86O+tHqZLMNO4w6ZZ4FlVQEadcoqkyU72HC5wJ4RlU= github.com/mmcloughlin/profile v0.1.1/go.mod h1:IhHD7q1ooxgwTgjxQYkACGA77oFTDdFVejUS1/tS/qU= +github.com/moby/spdystream v0.2.0 h1:cjW1zVyyoiM0T7b6UoySUFqzXMoqRckQtXwGPiBhOM8= +github.com/moby/spdystream v0.2.0/go.mod h1:f7i0iNDQJ059oMTcWxx8MA/zKFIuD/lY+0GqbN2Wy8c= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= 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 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= +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/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= +github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f h1:y5//uYreIhSUg3J1GEMiLbxo1LJaP8RfCpH6pymGZus= +github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f/go.mod h1:ZdcZmHo+o7JKHSa8/e818NopupXU1YMK5fe1lsApnBw= 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= @@ -536,8 +566,8 @@ github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFR github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= github.com/rogpeppe/go-internal v1.8.1/go.mod h1:JeRgkft04UBgHMgCIwADu4Pn6Mtm5d4nPKWu0nJ5d+o= github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= -github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= -github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog= +github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8= +github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4= github.com/rs/cors v1.7.0 h1:+88SsELBHx5r+hZ8TCkggzSstaWNbDvThkVK8H6f9ik= github.com/rs/cors v1.7.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU= github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= @@ -584,13 +614,14 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.8.3/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/subosito/gotenv v1.4.2 h1:X1TuBLAMDFbaTAChgCBLu3DU3UPyELpnF2jjJ2cz/S8= github.com/subosito/gotenv v1.4.2/go.mod h1:ayKnFf/c6rvx/2iiLrJUk1e6plDbT3edrFNGqEflhK0= -github.com/supranational/blst v0.3.11 h1:LyU6FolezeWAhvQk0k6O/d49jqgO52MSDDfYgbeoEm4= -github.com/supranational/blst v0.3.11/go.mod h1:jZJtfjgudtNl4en1tzwPIV3KjUnQUvG3/j+w+fVonLw= +github.com/supranational/blst v0.3.13 h1:AYeSxdOMacwu7FBmpfloBz5pbFXDmJL33RuwnKtmTjk= +github.com/supranational/blst v0.3.13/go.mod h1:jZJtfjgudtNl4en1tzwPIV3KjUnQUvG3/j+w+fVonLw= github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc= github.com/syndtr/goleveldb v1.0.1-0.20220614013038-64ee5596c38a h1:1ur3QoCqvE5fl+nylMaIr9PVV1w343YRDtsy+Rwu7XI= github.com/syndtr/goleveldb v1.0.1-0.20220614013038-64ee5596c38a/go.mod h1:RRCYJbIwD5jmqPI9XoAFR0OcDxqUctll6zUj/+B4S48= @@ -773,6 +804,8 @@ golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43/go.mod h1:KelEdhl1UZF7XfJ golang.org/x/oauth2 v0.0.0-20201109201403-9fd604954f58/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20201208152858-08078c50e5b5/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20210218202405-ba52d332ba99/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.22.0 h1:BzDx2FehcG7jJwgWLELCdmLuxk2i+x9UDpSiss2u0ZA= +golang.org/x/oauth2 v0.22.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -1007,8 +1040,8 @@ google.golang.org/genproto v0.0.0-20210226172003-ab064af71705/go.mod h1:FWY/as6D google.golang.org/genproto v0.0.0-20210624195500-8bfb893ecb84/go.mod h1:SzzZ/N+nwJDaO1kznhnlzqS8ocJICar6hYhVyhi++24= google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142 h1:wKguEg1hsxI2/L3hUYrpo1RVi48K+uTyzKqprwLXsb8= google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142/go.mod h1:d6be+8HhtEtucleCbxpPW9PA9XwISACu8nvpPqF0BVo= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 h1:e7S5W7MGGLaSu8j3YjdezkZ+m1/Nm0uRVRMEMGk26Xs= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142/go.mod h1:UqMtugtsSgubUsoxbuAoiCXvqvErP7Gf0so0mK9tHxU= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240827150818-7e3bb234dfed h1:J6izYgfBXAI3xTKLgxzTmUltdYaLsuBxFCgDHWJ/eXg= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240827150818-7e3bb234dfed/go.mod h1:UqMtugtsSgubUsoxbuAoiCXvqvErP7Gf0so0mK9tHxU= google.golang.org/grpc v1.12.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= @@ -1052,6 +1085,8 @@ gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/go-playground/assert.v1 v1.2.1/go.mod h1:9RXL0bg/zibRAgZUYszZSwO/z8Y/a8bDuhia5mkpMnE= gopkg.in/go-playground/validator.v8 v8.18.2/go.mod h1:RX2a/7Ha8BgOhfk7j780h4/u/RRjR0eouCJSH80/M2Y= +gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc= +gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= gopkg.in/ini.v1 v1.51.1/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA= gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= @@ -1063,6 +1098,7 @@ gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWD gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= @@ -1078,8 +1114,26 @@ honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWh honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= +k8s.io/api v0.29.0 h1:NiCdQMY1QOp1H8lfRyeEf8eOwV6+0xA6XEE44ohDX2A= +k8s.io/api v0.29.0/go.mod h1:sdVmXoz2Bo/cb77Pxi71IPTSErEW32xa4aXwKH7gfBA= +k8s.io/apimachinery v0.29.0 h1:+ACVktwyicPz0oc6MTMLwa2Pw3ouLAfAon1wPLtG48o= +k8s.io/apimachinery v0.29.0/go.mod h1:eVBxQ/cwiJxH58eK/jd/vAk4mrxmVlnpBH5J2GbMeis= +k8s.io/client-go v0.29.0 h1:KmlDtFcrdUzOYrBhXHgKw5ycWzc3ryPX5mQe0SkG3y8= +k8s.io/client-go v0.29.0/go.mod h1:yLkXH4HKMAywcrD82KMSmfYg2DlE8mepPR4JGSo5n38= +k8s.io/klog/v2 v2.110.1 h1:U/Af64HJf7FcwMcXyKm2RPM22WZzyR7OSpYj5tg3cL0= +k8s.io/klog/v2 v2.110.1/go.mod h1:YGtd1984u+GgbuZ7e08/yBuAfKLSO0+uR1Fhi6ExXjo= +k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00 h1:aVUu9fTY98ivBPKR9Y5w/AuzbMm96cd3YHRTU83I780= +k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00/go.mod h1:AsvuZPBlUDVuCdzJ87iajxtXuR9oktsTctW/R9wwouA= +k8s.io/utils v0.0.0-20230726121419-3b25d923346b h1:sgn3ZU783SCgtaSJjpcVVlRqd6GSnlTLKgpAAttJvpI= +k8s.io/utils v0.0.0-20230726121419-3b25d923346b/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= rsc.io/tmplfunc v0.0.3 h1:53XFQh69AfOa8Tw0Jm7t+GV7KZhOi6jzsCzTtKbMvzU= rsc.io/tmplfunc v0.0.3/go.mod h1:AG3sTPzElb1Io3Yg4voV9AGZJuleGAwaVRxL9M49PhA= +sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo= +sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0= +sigs.k8s.io/structured-merge-diff/v4 v4.4.1 h1:150L+0vs/8DA78h1u02ooW1/fFq/Lwr+sGiqlzvrtq4= +sigs.k8s.io/structured-merge-diff/v4 v4.4.1/go.mod h1:N8hJocpFajUSSeSJ9bOZ77VzejKZaXsTtZo4/u7Io08= +sigs.k8s.io/yaml v1.3.0 h1:a2VclLzOGrwOHDiV8EfBGhvjHvP46CtW5j6POvhYGGo= +sigs.k8s.io/yaml v1.3.0/go.mod h1:GeOyir5tyXNByN85N/dRIT9es5UQNerPYEKK56eTBm8= diff --git a/peers/app_request_network.go b/peers/app_request_network.go index df4e20e0..a555d1b3 100644 --- a/peers/app_request_network.go +++ b/peers/app_request_network.go @@ -155,7 +155,7 @@ func (n *appRequestNetwork) ConnectPeers(nodeIDs set.Set[ids.NodeID]) set.Set[id startInfoAPICall := time.Now() // Get the list of peers - peers, err := n.infoAPI.Peers(context.Background()) + peers, err := n.infoAPI.Peers(context.Background(), nil) n.setInfoAPICallLatencyMS(float64(time.Since(startInfoAPICall).Milliseconds())) if err != nil { n.logger.Error( diff --git a/peers/info_client.go b/peers/info_client.go index bf6ea091..dbefc0ac 100644 --- a/peers/info_client.go +++ b/peers/info_client.go @@ -68,8 +68,8 @@ func (i *InfoAPI) IsBootstrapped(ctx context.Context, chainID string) (bool, err return i.client.IsBootstrapped(ctx, chainID, i.options...) } -func (i *InfoAPI) Peers(ctx context.Context) ([]info.Peer, error) { - return i.client.Peers(ctx, i.options...) +func (i *InfoAPI) Peers(ctx context.Context, nodes []ids.NodeID) ([]info.Peer, error) { + return i.client.Peers(ctx, nodes, i.options...) } func (i *InfoAPI) Uptime(ctx context.Context) (*info.UptimeResponse, error) { diff --git a/relayer/main/main.go b/relayer/main/main.go index 06e4c6e5..77d73ed4 100644 --- a/relayer/main/main.go +++ b/relayer/main/main.go @@ -555,7 +555,7 @@ func startMetricsServer(logger logging.Logger, gatherer prometheus.Gatherer, por } func initializeMetrics() (prometheus.Gatherer, prometheus.Registerer, error) { - gatherer := metrics.NewMultiGatherer() + gatherer := metrics.NewPrefixGatherer() registry := prometheus.NewRegistry() if err := gatherer.Register("app", registry); err != nil { return nil, nil, err From 75fe28d79cbd6e22e1cc380894dc225432b1ac51 Mon Sep 17 00:00:00 2001 From: cam-schultz Date: Wed, 6 Nov 2024 13:52:15 -0600 Subject: [PATCH 04/28] use latest local network framework --- go.mod | 28 ++++---- go.sum | 48 ++++++------- peers/app_request_network.go | 30 +++++++- peers/mocks/mock_app_request_network.go | 16 +++++ relayer/main/main.go | 28 ++++---- signature-aggregator/aggregator/aggregator.go | 4 +- .../aggregator/aggregator_test.go | 1 - signature-aggregator/main/main.go | 23 ++++--- tests/allowed_addresses.go | 31 +++++---- tests/basic_relay.go | 37 +++++----- tests/batch_relay.go | 10 +-- tests/e2e_test.go | 42 +++++++----- tests/etna_upgrade.go | 12 ++-- tests/manual_message.go | 19 +++--- tests/relay_message_api.go | 11 +-- tests/shared_db.go | 16 +++-- tests/signature_aggregator_api.go | 7 +- tests/utils/utils.go | 68 +++++++++++++++---- tests/warp_api.go | 12 ++-- 19 files changed, 274 insertions(+), 169 deletions(-) diff --git a/go.mod b/go.mod index 57cfce11..3b114490 100644 --- a/go.mod +++ b/go.mod @@ -2,21 +2,23 @@ module github.com/ava-labs/awm-relayer go 1.22.8 +replace github.com/ava-labs/teleporter => /Users/cameron.schultz/teleporter + require ( github.com/ava-labs/avalanchego v1.12.0-initial-poc.8 github.com/ava-labs/coreth v0.13.8 - github.com/ava-labs/subnet-evm v0.6.10 + github.com/ava-labs/subnet-evm v0.6.11 github.com/ava-labs/teleporter v1.0.7 github.com/aws/aws-sdk-go-v2 v1.32.2 github.com/aws/aws-sdk-go-v2/config v1.27.9 github.com/aws/aws-sdk-go-v2/service/kms v1.37.2 github.com/ethereum/go-ethereum v1.13.14 github.com/hashicorp/golang-lru/v2 v2.0.7 - github.com/onsi/ginkgo/v2 v2.20.2 - github.com/onsi/gomega v1.34.2 + github.com/onsi/ginkgo/v2 v2.21.0 + github.com/onsi/gomega v1.35.1 github.com/pingcap/errors v0.11.4 github.com/pkg/errors v0.9.1 - github.com/prometheus/client_golang v1.20.4 + github.com/prometheus/client_golang v1.20.5 github.com/redis/go-redis/v9 v9.6.1 github.com/spf13/pflag v1.0.5 github.com/spf13/viper v1.16.0 @@ -66,7 +68,6 @@ require ( github.com/dop251/goja v0.0.0-20230806174421-c933cf95e127 // indirect github.com/emicklei/go-restful/v3 v3.11.0 // indirect github.com/ethereum/c-kzg-4844 v0.4.0 // indirect - github.com/fjl/memsize v0.0.2 // indirect github.com/fsnotify/fsnotify v1.6.0 // indirect github.com/gballet/go-libpcsclite v0.0.0-20191108122812-4678299bea08 // indirect github.com/gballet/go-verkle v0.1.1-0.20231031103413-a67434b50f46 // indirect @@ -87,7 +88,7 @@ require ( github.com/google/gnostic-models v0.6.8 // indirect github.com/google/go-cmp v0.6.0 // indirect github.com/google/gofuzz v1.2.0 // indirect - github.com/google/pprof v0.0.0-20240827171923-fa2c70bbbfe5 // indirect + github.com/google/pprof v0.0.0-20241029153458-d1b30febd7db // indirect github.com/google/renameio/v2 v2.0.0 // indirect github.com/google/uuid v1.6.0 // indirect github.com/gorilla/mux v1.8.0 // indirect @@ -123,7 +124,9 @@ require ( github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f // indirect github.com/nbutton23/zxcvbn-go v0.0.0-20180912185939-ae427f1e4c1d // indirect + github.com/nxadm/tail v1.4.8 // indirect github.com/olekukonko/tablewriter v0.0.5 // indirect + github.com/onsi/ginkgo v1.16.5 // indirect github.com/pelletier/go-toml/v2 v2.0.8 // indirect github.com/pires/go-proxyproto v0.6.2 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect @@ -157,21 +160,22 @@ require ( go.opentelemetry.io/otel/trace v1.22.0 // indirect go.opentelemetry.io/proto/otlp v1.0.0 // indirect go.uber.org/multierr v1.11.0 // indirect - golang.org/x/crypto v0.26.0 // indirect + golang.org/x/crypto v0.28.0 // indirect golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 // indirect - golang.org/x/net v0.28.0 // indirect + golang.org/x/net v0.30.0 // indirect golang.org/x/oauth2 v0.22.0 // indirect - golang.org/x/sys v0.24.0 // indirect - golang.org/x/term v0.23.0 // indirect - golang.org/x/text v0.17.0 // indirect + golang.org/x/sys v0.26.0 // indirect + golang.org/x/term v0.25.0 // indirect + golang.org/x/text v0.19.0 // indirect golang.org/x/time v0.3.0 // indirect - golang.org/x/tools v0.24.0 // indirect + golang.org/x/tools v0.26.0 // indirect gonum.org/v1/gonum v0.11.0 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20240827150818-7e3bb234dfed // indirect gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect + gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect k8s.io/api v0.29.0 // indirect diff --git a/go.sum b/go.sum index 67e659b8..3abc8e93 100644 --- a/go.sum +++ b/go.sum @@ -64,10 +64,8 @@ github.com/ava-labs/avalanchego v1.12.0-initial-poc.8 h1:UuCN1CYPZgf2FGGaO4XURVP github.com/ava-labs/avalanchego v1.12.0-initial-poc.8/go.mod h1:86tO6F1FT8emclUwdQ2WCwAtAerqjm5A4IbV6XxNUyM= github.com/ava-labs/coreth v0.13.8 h1:f14X3KgwHl9LwzfxlN6S4bbn5VA2rhEsNnHaRLSTo/8= github.com/ava-labs/coreth v0.13.8/go.mod h1:t3BSv/eQv0AlDPMfEDCMMoD/jq1RkUsbFzQAFg5qBcE= -github.com/ava-labs/subnet-evm v0.6.10 h1:uIh6bFMA4GCMVMQ3agBPxTMlYHL8FBR5FrhMR+drfKI= -github.com/ava-labs/subnet-evm v0.6.10/go.mod h1:dw4kg0o58dvYlndj2ZcwB7hioRc1kjg00yXYrcSmnj8= -github.com/ava-labs/teleporter v1.0.7 h1:9H0wTWhgWeA4u6uxi9KngdBu/LOoYsfAmIZhXNzuvf8= -github.com/ava-labs/teleporter v1.0.7/go.mod h1:wgCgU6vU5MtP83otpjEin8jL2jrflVBNQCTxVXMx/kU= +github.com/ava-labs/subnet-evm v0.6.11 h1:XgIAn9ihPyGjrBFD2rXg2H76HFl6htliHabN0fjciaQ= +github.com/ava-labs/subnet-evm v0.6.11/go.mod h1:fP46lzBtiniRfpNH+Qu9BFvSsa02YGkAobxinZ78gDU= github.com/aws/aws-sdk-go-v2 v1.32.2 h1:AkNLZEyYMLnx/Q/mSKkcMqwNFXMAvFto9bNsHqcTduI= github.com/aws/aws-sdk-go-v2 v1.32.2/go.mod h1:2SK5n0a2karNTv5tbP1SjsX0uhttou00v/HpXKM1ZUo= github.com/aws/aws-sdk-go-v2/config v1.27.9 h1:gRx/NwpNEFSk+yQlgmk1bmxxvQ5TyJ76CWXs9XScTqg= @@ -219,8 +217,6 @@ github.com/ethereum/go-ethereum v1.13.14 h1:EwiY3FZP94derMCIam1iW4HFVrSgIcpsu0Hw github.com/ethereum/go-ethereum v1.13.14/go.mod h1:TN8ZiHrdJwSe8Cb6x+p0hs5CxhJZPbqB7hHkaUXcmIU= github.com/fasthttp-contrib/websocket v0.0.0-20160511215533-1f3b11f56072/go.mod h1:duJ4Jxv5lDcvg4QuQr0oowTf7dz4/CR8NtyCooz9HL8= github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M= -github.com/fjl/memsize v0.0.2 h1:27txuSD9or+NZlnOWdKUxeBzTAUkWCVh+4Gf2dWFOzA= -github.com/fjl/memsize v0.0.2/go.mod h1:VvhXpOYNQvB+uIk2RvXzuaQtkQJzzIx6lSBe1xv7hi0= github.com/frankban/quicktest v1.14.4 h1:g2rn0vABPOOXmZUj+vbmUp0lPoXEMuhTpIluN0XL9UY= github.com/frankban/quicktest v1.14.4/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= @@ -353,8 +349,8 @@ github.com/google/pprof v0.0.0-20201203190320-1bf35d6f28c2/go.mod h1:kpwsk12EmLe github.com/google/pprof v0.0.0-20201218002935-b9804c9f04c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20230207041349-798e818bf904/go.mod h1:uglQLonpP8qtYCYyzA+8c/9qtqgA3qsXGYqCPKARAFg= -github.com/google/pprof v0.0.0-20240827171923-fa2c70bbbfe5 h1:5iH8iuqE5apketRbSFBy+X1V0o+l+8NF1avt4HWl7cA= -github.com/google/pprof v0.0.0-20240827171923-fa2c70bbbfe5/go.mod h1:vavhavw2zAxS5dIdcRluK6cSGGPlZynqzFM8NdvU144= +github.com/google/pprof v0.0.0-20241029153458-d1b30febd7db h1:097atOisP2aRj7vFgYQBbFN4U4JNXUNYpxael3UzMyo= +github.com/google/pprof v0.0.0-20241029153458-d1b30febd7db/go.mod h1:vavhavw2zAxS5dIdcRluK6cSGGPlZynqzFM8NdvU144= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/google/renameio/v2 v2.0.0 h1:UifI23ZTGY8Tt29JbYFiuyIU3eX+RNFtUwefq9qAhxg= github.com/google/renameio/v2 v2.0.0/go.mod h1:BtmJXm5YlszgC+TD4HOEEUFgkJP3nLxehU6hfe7jRt4= @@ -525,16 +521,16 @@ github.com/onsi/ginkgo v1.16.4/go.mod h1:dX+/inL/fNMqNlz0e9LfyB9TswhZpCVdJM/Z6Vv github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE= github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU= github.com/onsi/ginkgo/v2 v2.1.3/go.mod h1:vw5CSIxN1JObi/U8gcbwft7ZxR2dgaR70JSE3/PpL4c= -github.com/onsi/ginkgo/v2 v2.20.2 h1:7NVCeyIWROIAheY21RLS+3j2bb52W0W82tkberYytp4= -github.com/onsi/ginkgo/v2 v2.20.2/go.mod h1:K9gyxPIlb+aIvnZ8bd9Ak+YP18w3APlR+5coaZoE2ag= +github.com/onsi/ginkgo/v2 v2.21.0 h1:7rg/4f3rB88pb5obDgNZrNHrQ4e6WpjonchcpuBRnZM= +github.com/onsi/ginkgo/v2 v2.21.0/go.mod h1:7Du3c42kxCUegi0IImZ1wUQzMBVecgIHjR1C+NkhLQo= github.com/onsi/gomega v1.4.1/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= github.com/onsi/gomega v1.17.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY= github.com/onsi/gomega v1.19.0/go.mod h1:LY+I3pBVzYsTBU1AnDwOSxaYi9WoWiqgwooUqq9yPro= -github.com/onsi/gomega v1.34.2 h1:pNCwDkzrsv7MS9kpaQvVb1aVLahQXyJ/Tv5oAZMI3i8= -github.com/onsi/gomega v1.34.2/go.mod h1:v1xfxRgk0KIsG+QOdm7p8UosrOzPYRo60fd3B/1Dukc= +github.com/onsi/gomega v1.35.1 h1:Cwbd75ZBPxFSuZ6T+rN/WCb/gOc6YgFBXLlZLhC7Ds4= +github.com/onsi/gomega v1.35.1/go.mod h1:PvZbdDc8J6XJEpDK4HCuRBm8a6Fzp9/DmhC9C7yFlog= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= github.com/pelletier/go-toml/v2 v2.0.8 h1:0ctb6s9mE31h0/lhu+J6OPmVeDxJn+kYnJc2jZR9tGQ= github.com/pelletier/go-toml/v2 v2.0.8/go.mod h1:vuYfssBdrU2XDZ9bYydBu6t+6a6PYNcZljzZR9VXg+4= @@ -549,8 +545,8 @@ github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE github.com/pkg/sftp v1.13.1/go.mod h1:3HaPG6Dq1ILlpPZRO0HVMrsydcdLt6HRDccSgb87qRg= 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 v1.20.4 h1:Tgh3Yr67PaOv/uTqloMsCEdeuFTatm5zIq5+qNN23vI= -github.com/prometheus/client_golang v1.20.4/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE= +github.com/prometheus/client_golang v1.20.5 h1:cxppBPuYhUnsO6yo/aoRol4L7q7UFfdm+bR9r+8l63Y= +github.com/prometheus/client_golang v1.20.5/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E= github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY= @@ -708,8 +704,8 @@ golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.26.0 h1:RrRspgV4mU+YwB4FYnuBoKsUapNIL5cohGAmSH3azsw= -golang.org/x/crypto v0.26.0/go.mod h1:GY7jblb9wI+FOo5y8/S2oY4zWP07AkOJ4+jxCqdqn54= +golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw= +golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -793,8 +789,8 @@ golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qx golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/net v0.0.0-20220607020251-c690dde0001d/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.28.0 h1:a9JDOJc5GMUJ0+UDqmLT86WiEy7iWyIhz8gz8E4e5hE= -golang.org/x/net v0.28.0/go.mod h1:yqtgsTWOOnlGLG9GFRrK3++bGOUEkNBoHZc8MEDWPNg= +golang.org/x/net v0.30.0 h1:AcW1SDZMkb8IpzCdQUaIq2sP4sZ4zw+55h6ynffypl4= +golang.org/x/net v0.30.0/go.mod h1:2wGyMJ5iFasEhkwi13ChkO/t1ECNC4X4eBKkVFyYFlU= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -886,12 +882,12 @@ golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg= -golang.org/x/sys v0.24.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo= +golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.23.0 h1:F6D4vR+EHoL9/sWAWgAR1H2DcHr4PareCbAaCo1RpuU= -golang.org/x/term v0.23.0/go.mod h1:DgV24QBUrK6jhZXl+20l6UWznPlwAHm1Q1mGHtydmSk= +golang.org/x/term v0.25.0 h1:WtHI/ltw4NvSUig5KARz9h521QvRC8RmF/cuYqifU24= +golang.org/x/term v0.25.0/go.mod h1:RPyXicDX+6vLxogjjRxjgD2TKtmAO6NZBsBRfrOLu7M= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -902,8 +898,8 @@ golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= -golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc= -golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= +golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM= +golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -965,8 +961,8 @@ golang.org/x/tools v0.0.0-20210108195828-e2f9c7f1fc8e/go.mod h1:emZCQorbCU4vsT4f golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= golang.org/x/tools v0.1.3/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= -golang.org/x/tools v0.24.0 h1:J1shsA93PJUEVaUSaay7UXAyE8aimq3GW0pjlolpa24= -golang.org/x/tools v0.24.0/go.mod h1:YhNqVBIfWHdzvTLs0d8LCuMhkKUgSUKldakyV7W/WDQ= +golang.org/x/tools v0.26.0 h1:v/60pFQmzmT9ExmjDv2gGIfi3OqfKoEP6I5+umXlbnQ= +golang.org/x/tools v0.26.0/go.mod h1:TPVVj70c7JJ3WCazhD8OdXcZg/og+b9+tH/KxylGwH0= 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= diff --git a/peers/app_request_network.go b/peers/app_request_network.go index a555d1b3..a84fdbd8 100644 --- a/peers/app_request_network.go +++ b/peers/app_request_network.go @@ -42,6 +42,12 @@ type AppRequestNetwork interface { requestID uint32, numExpectedResponse int, ) chan message.InboundMessage + Message( + sourceChainID ids.ID, + requestID uint32, + timeout time.Duration, + request []byte, + ) (message.OutboundMessage, error) Send( msg message.OutboundMessage, nodeIDs set.Set[ids.NodeID], @@ -58,6 +64,7 @@ type appRequestNetwork struct { lock *sync.Mutex validatorClient *validators.CanonicalValidatorClient metrics *AppRequestNetworkMetrics + messageCreator message.Creator } // NewNetwork creates a p2p network client for interacting with validators @@ -65,6 +72,7 @@ func NewNetwork( logLevel logging.Level, registerer prometheus.Registerer, trackedSubnets set.Set[ids.ID], + messageCreator message.Creator, cfg Config, ) (AppRequestNetwork, error) { logger := logging.NewLogger( @@ -79,7 +87,7 @@ func NewNetwork( metrics, err := newAppRequestNetworkMetrics(registerer) if err != nil { logger.Fatal("Failed to create app request network metrics", zap.Error(err)) - panic(err) + return nil, err } // Create the handler for handling inbound app responses @@ -128,6 +136,7 @@ func NewNetwork( lock: new(sync.Mutex), validatorClient: validatorClient, metrics: metrics, + messageCreator: messageCreator, } go logger.RecoverAndPanic(func() { testNetwork.Dispatch() @@ -142,6 +151,11 @@ func (n *appRequestNetwork) ConnectPeers(nodeIDs set.Set[ids.NodeID]) set.Set[id n.lock.Lock() defer n.lock.Unlock() + // TODONOW: + // Get primary network validators + // Request peers from one of them + // Iterate through and manually connect to + // First, check if we are already connected to all the peers connectedPeers := n.network.PeerInfo(nodeIDs.List()) if len(connectedPeers) == nodeIDs.Len() { @@ -262,6 +276,20 @@ func (n *appRequestNetwork) ConnectToCanonicalValidators(subnetID ids.ID) (*Conn }, nil } +func (n *appRequestNetwork) Message( + sourceChainID ids.ID, + requestID uint32, + timeout time.Duration, + request []byte, +) (message.OutboundMessage, error) { + return n.messageCreator.AppRequest( + sourceChainID, + requestID, + timeout, + request, + ) +} + func (n *appRequestNetwork) Send( msg message.OutboundMessage, nodeIDs set.Set[ids.NodeID], diff --git a/peers/mocks/mock_app_request_network.go b/peers/mocks/mock_app_request_network.go index f989358c..4e42bb2b 100644 --- a/peers/mocks/mock_app_request_network.go +++ b/peers/mocks/mock_app_request_network.go @@ -11,6 +11,7 @@ package mocks import ( reflect "reflect" + time "time" ids "github.com/ava-labs/avalanchego/ids" message "github.com/ava-labs/avalanchego/message" @@ -87,6 +88,21 @@ func (mr *MockAppRequestNetworkMockRecorder) GetSubnetID(blockchainID any) *gomo return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetSubnetID", reflect.TypeOf((*MockAppRequestNetwork)(nil).GetSubnetID), blockchainID) } +// Message mocks base method. +func (m *MockAppRequestNetwork) Message(sourceChainID ids.ID, requestID uint32, timeout time.Duration, request []byte) (message.OutboundMessage, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Message", sourceChainID, requestID, timeout, request) + ret0, _ := ret[0].(message.OutboundMessage) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// Message indicates an expected call of Message. +func (mr *MockAppRequestNetworkMockRecorder) Message(sourceChainID, requestID, timeout, request any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Message", reflect.TypeOf((*MockAppRequestNetwork)(nil).Message), sourceChainID, requestID, timeout, request) +} + // RegisterAppRequest mocks base method. func (m *MockAppRequestNetwork) RegisterAppRequest(requestID ids.RequestID) { m.ctrl.T.Helper() diff --git a/relayer/main/main.go b/relayer/main/main.go index 77d73ed4..8b0f00ef 100644 --- a/relayer/main/main.go +++ b/relayer/main/main.go @@ -149,10 +149,24 @@ func main() { trackedSubnets.Add(sourceBlockchain.GetSubnetID()) } + // Initialize message creator passed down to relayers for creating app requests. + // We do not collect metrics for the message creator. + messageCreator, err := message.NewCreator( + logger, + prometheus.DefaultRegisterer, + constants.DefaultNetworkCompressionType, + constants.DefaultNetworkMaximumInboundTimeout, + ) + if err != nil { + logger.Fatal("Failed to create message creator", zap.Error(err)) + panic(err) + } + network, err := peers.NewNetwork( networkLogLevel, registerer, trackedSubnets, + messageCreator, &cfg, ) if err != nil { @@ -174,19 +188,6 @@ func main() { panic(err) } - // Initialize message creator passed down to relayers for creating app requests. - // We do not collect metrics for the message creator. - messageCreator, err := message.NewCreator( - logger, - prometheus.DefaultRegisterer, - constants.DefaultNetworkCompressionType, - constants.DefaultNetworkMaximumInboundTimeout, - ) - if err != nil { - logger.Fatal("Failed to create message creator", zap.Error(err)) - panic(err) - } - // Initialize the database db, err := database.NewDatabase(logger, &cfg) if err != nil { @@ -226,7 +227,6 @@ func main() { sigAggMetrics.NewSignatureAggregatorMetrics( prometheus.DefaultRegisterer, ), - messageCreator, cfg.EtnaTime, ) if err != nil { diff --git a/signature-aggregator/aggregator/aggregator.go b/signature-aggregator/aggregator/aggregator.go index 7d2b9b01..b86198c9 100644 --- a/signature-aggregator/aggregator/aggregator.go +++ b/signature-aggregator/aggregator/aggregator.go @@ -72,7 +72,6 @@ func NewSignatureAggregator( logger logging.Logger, signatureCacheSize uint64, metrics *metrics.SignatureAggregatorMetrics, - messageCreator message.Creator, etnaTime time.Time, ) (*SignatureAggregator, error) { cache, err := cache.NewCache(signatureCacheSize, logger) @@ -87,7 +86,6 @@ func NewSignatureAggregator( subnetIDsByBlockchainID: map[ids.ID]ids.ID{}, logger: logger, metrics: metrics, - messageCreator: messageCreator, currentRequestID: atomic.Uint32{}, cache: cache, etnaTime: etnaTime, @@ -197,7 +195,7 @@ func (s *SignatureAggregator) CreateSignedMessage( // Construct the AppRequest requestID := s.currentRequestID.Add(1) - outMsg, err := s.messageCreator.AppRequest( + outMsg, err := s.network.Message( unsignedMessage.SourceChainID, requestID, peers.DefaultAppRequestTimeout, diff --git a/signature-aggregator/aggregator/aggregator_test.go b/signature-aggregator/aggregator/aggregator_test.go index 03273145..3870cec2 100644 --- a/signature-aggregator/aggregator/aggregator_test.go +++ b/signature-aggregator/aggregator/aggregator_test.go @@ -66,7 +66,6 @@ func instantiateAggregator(t *testing.T) ( ), 1024, sigAggMetrics, - messageCreator, // Setting the etnaTime to a minute ago so that the post-etna code path is used in the test time.Now().Add(-1*time.Minute), ) diff --git a/signature-aggregator/main/main.go b/signature-aggregator/main/main.go index 27edfd3b..143784b5 100644 --- a/signature-aggregator/main/main.go +++ b/signature-aggregator/main/main.go @@ -84,16 +84,6 @@ func main() { if logLevel <= logging.Debug { networkLogLevel = logLevel } - network, err := peers.NewNetwork( - networkLogLevel, - prometheus.DefaultRegisterer, - nil, - &cfg, - ) - if err != nil { - logger.Fatal("Failed to create app request network", zap.Error(err)) - panic(err) - } // Initialize message creator passed down to relayers for creating app requests. // We do not collect metrics for the message creator. @@ -108,6 +98,18 @@ func main() { panic(err) } + network, err := peers.NewNetwork( + networkLogLevel, + prometheus.DefaultRegisterer, + nil, + messageCreator, + &cfg, + ) + if err != nil { + logger.Fatal("Failed to create app request network", zap.Error(err)) + panic(err) + } + registry := metrics.Initialize(cfg.MetricsPort) metricsInstance := metrics.NewSignatureAggregatorMetrics(registry) @@ -116,7 +118,6 @@ func main() { logger, cfg.SignatureCacheSize, metricsInstance, - messageCreator, cfg.EtnaTime, ) if err != nil { diff --git a/tests/allowed_addresses.go b/tests/allowed_addresses.go index f662878c..0c1c5386 100644 --- a/tests/allowed_addresses.go +++ b/tests/allowed_addresses.go @@ -13,6 +13,7 @@ import ( testUtils "github.com/ava-labs/awm-relayer/tests/utils" "github.com/ava-labs/subnet-evm/accounts/abi/bind" "github.com/ava-labs/teleporter/tests/interfaces" + "github.com/ava-labs/teleporter/tests/network" "github.com/ava-labs/teleporter/tests/utils" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" @@ -36,11 +37,10 @@ const numKeys = 4 // - Deliver from a specific source address to a specific destination address // Then, checks that each relayer instance is able to properly catch up on missed messages that // match its particular configuration. -func AllowedAddresses(network interfaces.LocalNetwork) { +func AllowedAddresses(network *network.LocalNetwork, teleporter utils.TeleporterTestInfo) { subnetAInfo := network.GetPrimaryNetworkInfo() - subnetBInfo, _ := utils.GetTwoSubnets(network) + subnetBInfo, _ := network.GetTwoSubnets() fundedAddress, fundedKey := network.GetFundedAccountInfo() - teleporterContractAddress := network.GetTeleporterContractAddress() err := testUtils.ClearRelayerStorage() Expect(err).Should(BeNil()) @@ -84,9 +84,9 @@ func AllowedAddresses(network interfaces.LocalNetwork) { // All sources -> All destinations // Will send from allowed Address 0 -> 0 relayerConfig1 := testUtils.CreateDefaultRelayerConfig( + teleporter, []interfaces.SubnetTestInfo{subnetAInfo, subnetBInfo}, []interfaces.SubnetTestInfo{subnetAInfo, subnetBInfo}, - teleporterContractAddress, fundedAddress, relayerKey, ) @@ -94,9 +94,9 @@ func AllowedAddresses(network interfaces.LocalNetwork) { // Specific source -> All destinations // Will send from allowed Address 1 -> 0 relayerConfig2 := testUtils.CreateDefaultRelayerConfig( + teleporter, []interfaces.SubnetTestInfo{subnetAInfo, subnetBInfo}, []interfaces.SubnetTestInfo{subnetAInfo, subnetBInfo}, - teleporterContractAddress, fundedAddress, relayerKey, ) @@ -109,9 +109,9 @@ func AllowedAddresses(network interfaces.LocalNetwork) { // All sources -> Specific destination // Will send from allowed Address 2 -> 0 relayerConfig3 := testUtils.CreateDefaultRelayerConfig( + teleporter, []interfaces.SubnetTestInfo{subnetAInfo, subnetBInfo}, []interfaces.SubnetTestInfo{subnetAInfo, subnetBInfo}, - teleporterContractAddress, fundedAddress, relayerKey, ) @@ -135,9 +135,9 @@ func AllowedAddresses(network interfaces.LocalNetwork) { // Specific source -> Specific destination // Will send from allowed Address 3 -> 0 relayerConfig4 := testUtils.CreateDefaultRelayerConfig( + teleporter, []interfaces.SubnetTestInfo{subnetAInfo, subnetBInfo}, []interfaces.SubnetTestInfo{subnetAInfo, subnetBInfo}, - teleporterContractAddress, fundedAddress, relayerKey, ) @@ -188,9 +188,9 @@ func AllowedAddresses(network interfaces.LocalNetwork) { // Allowed by Relayer 1 testUtils.RelayBasicMessage( ctx, + teleporter, subnetAInfo, subnetBInfo, - teleporterContractAddress, allowedKeys[generalAllowedAddressIdx], allowedAddresses[generalAllowedAddressIdx], ) @@ -218,13 +218,14 @@ func AllowedAddresses(network interfaces.LocalNetwork) { // Disallowed by Relayer 2 _, _, id := testUtils.SendBasicTeleporterMessage( ctx, + teleporter, subnetAInfo, subnetBInfo, allowedKeys[generalAllowedAddressIdx], // not allowed allowedAddresses[generalAllowedAddressIdx], ) Consistently(func() bool { - delivered, err := subnetBInfo.TeleporterMessenger.MessageReceived( + delivered, err := teleporter.TeleporterMessenger(subnetBInfo).MessageReceived( &bind.CallOpts{}, id, ) Expect(err).Should(BeNil()) @@ -234,9 +235,9 @@ func AllowedAddresses(network interfaces.LocalNetwork) { // Allowed by Relayer 2 testUtils.RelayBasicMessage( ctx, + teleporter, subnetAInfo, subnetBInfo, - teleporterContractAddress, allowedKeys[relayer2AllowedSrcAddressIdx], allowedAddresses[generalAllowedAddressIdx], ) @@ -264,13 +265,14 @@ func AllowedAddresses(network interfaces.LocalNetwork) { // Disallowed by Relayer 3 _, _, id = testUtils.SendBasicTeleporterMessage( ctx, + teleporter, subnetAInfo, subnetBInfo, allowedKeys[generalAllowedAddressIdx], allowedAddresses[generalAllowedAddressIdx], // not allowed ) Consistently(func() bool { - delivered, err := subnetBInfo.TeleporterMessenger.MessageReceived( + delivered, err := teleporter.TeleporterMessenger(subnetBInfo).MessageReceived( &bind.CallOpts{}, id, ) Expect(err).Should(BeNil()) @@ -280,9 +282,9 @@ func AllowedAddresses(network interfaces.LocalNetwork) { // Allowed by Relayer 3 testUtils.RelayBasicMessage( ctx, + teleporter, subnetAInfo, subnetBInfo, - teleporterContractAddress, allowedKeys[generalAllowedAddressIdx], allowedAddresses[relayer3AllowedDstAddressIdx], ) @@ -309,13 +311,14 @@ func AllowedAddresses(network interfaces.LocalNetwork) { // Disallowed by Relayer 4 _, _, id = testUtils.SendBasicTeleporterMessage( ctx, + teleporter, subnetAInfo, subnetBInfo, allowedKeys[generalAllowedAddressIdx], // not allowed allowedAddresses[generalAllowedAddressIdx], ) Consistently(func() bool { - delivered, err := subnetBInfo.TeleporterMessenger.MessageReceived( + delivered, err := teleporter.TeleporterMessenger(subnetBInfo).MessageReceived( &bind.CallOpts{}, id, ) Expect(err).Should(BeNil()) @@ -325,9 +328,9 @@ func AllowedAddresses(network interfaces.LocalNetwork) { // Allowed by Relayer 4 testUtils.RelayBasicMessage( ctx, + teleporter, subnetAInfo, subnetBInfo, - teleporterContractAddress, allowedKeys[relayer4AllowedSrcAddressIdx], allowedAddresses[relayer4AllowedDstAddressIdx], ) diff --git a/tests/basic_relay.go b/tests/basic_relay.go index ed3aa2f2..509e67fc 100644 --- a/tests/basic_relay.go +++ b/tests/basic_relay.go @@ -5,6 +5,7 @@ package tests import ( "context" + "fmt" "os" "time" @@ -13,9 +14,9 @@ import ( testUtils "github.com/ava-labs/awm-relayer/tests/utils" "github.com/ava-labs/subnet-evm/core/types" "github.com/ava-labs/teleporter/tests/interfaces" + "github.com/ava-labs/teleporter/tests/network" "github.com/ava-labs/teleporter/tests/utils" "github.com/ethereum/go-ethereum/crypto" - "github.com/ethereum/go-ethereum/log" . "github.com/onsi/gomega" ) @@ -24,11 +25,10 @@ import ( // - Relaying from Subnet B to Subnet A // - Relaying an already delivered message // - Setting ProcessHistoricalBlocksFromHeight in config -func BasicRelay(network interfaces.LocalNetwork) { +func BasicRelay(network *network.LocalNetwork, teleporter utils.TeleporterTestInfo) { subnetAInfo := network.GetPrimaryNetworkInfo() - subnetBInfo, _ := utils.GetTwoSubnets(network) + subnetBInfo, _ := network.GetTwoSubnets() fundedAddress, fundedKey := network.GetFundedAccountInfo() - teleporterContractAddress := network.GetTeleporterContractAddress() err := testUtils.ClearRelayerStorage() Expect(err).Should(BeNil()) @@ -37,7 +37,7 @@ func BasicRelay(network interfaces.LocalNetwork) { // ctx := context.Background() - log.Info("Funding relayer address on all subnets") + fmt.Println("Funding relayer address on all subnets") relayerKey, err := crypto.GenerateKey() Expect(err).Should(BeNil()) testUtils.FundRelayers(ctx, []interfaces.SubnetTestInfo{subnetAInfo, subnetBInfo}, fundedKey, relayerKey) @@ -46,9 +46,9 @@ func BasicRelay(network interfaces.LocalNetwork) { // Set up relayer config // relayerConfig := testUtils.CreateDefaultRelayerConfig( + teleporter, []interfaces.SubnetTestInfo{subnetAInfo, subnetBInfo}, []interfaces.SubnetTestInfo{subnetAInfo, subnetBInfo}, - teleporterContractAddress, fundedAddress, relayerKey, ) @@ -60,9 +60,9 @@ func BasicRelay(network interfaces.LocalNetwork) { // // Test Relaying from Subnet A to Subnet B // - log.Info("Test Relaying from Subnet A to Subnet B") + fmt.Println("Test Relaying from Subnet A to Subnet B") - log.Info("Starting the relayer") + fmt.Println("Starting the relayer") relayerCleanup, readyChan := testUtils.RunRelayerExecutable( ctx, relayerConfigPath, @@ -75,12 +75,12 @@ func BasicRelay(network interfaces.LocalNetwork) { defer startupCancel() testUtils.WaitForChannelClose(startupCtx, readyChan) - log.Info("Sending transaction from Subnet A to Subnet B") + fmt.Println("Sending transaction from Subnet A to Subnet B") testUtils.RelayBasicMessage( ctx, + teleporter, subnetAInfo, subnetBInfo, - teleporterContractAddress, fundedKey, fundedAddress, ) @@ -88,24 +88,24 @@ func BasicRelay(network interfaces.LocalNetwork) { // // Test Relaying from Subnet B to Subnet A // - log.Info("Test Relaying from Subnet B to Subnet A") + fmt.Println("Test Relaying from Subnet B to Subnet A") testUtils.RelayBasicMessage( ctx, + teleporter, subnetBInfo, subnetAInfo, - teleporterContractAddress, fundedKey, fundedAddress, ) - log.Info("Finished sending warp message, closing down output channel") + fmt.Println("Finished sending warp message, closing down output channel") // Cancel the command and stop the relayer relayerCleanup() // // Try Relaying Already Delivered Message // - log.Info("Test Relaying Already Delivered Message") + fmt.Println("Test Relaying Already Delivered Message") logger := logging.NewLogger( "awm-relayer", logging.NewWrappedCore( @@ -147,7 +147,7 @@ func BasicRelay(network interfaces.LocalNetwork) { defer sub.Unsubscribe() // Run the relayer - log.Info("Creating new relayer instance to test already delivered message") + fmt.Println("Creating new relayer instance to test already delivered message") relayerCleanup, readyChan = testUtils.RunRelayerExecutable( ctx, relayerConfigPath, @@ -156,22 +156,23 @@ func BasicRelay(network interfaces.LocalNetwork) { defer relayerCleanup() // Wait for relayer to start up - log.Info("Waiting for the relayer to start up") + fmt.Println("Waiting for the relayer to start up") startupCtx, startupCancel = context.WithTimeout(ctx, 15*time.Second) defer startupCancel() testUtils.WaitForChannelClose(startupCtx, readyChan) // We should not receive a new block on subnet B, since the relayer should have // seen the Teleporter message was already delivered. - log.Info("Waiting for 10s to ensure no new block confirmations on destination chain") + fmt.Println("Waiting for 10s to ensure no new block confirmations on destination chain") Consistently(newHeadsB, 10*time.Second, 500*time.Millisecond).ShouldNot(Receive()) // // Set ProcessHistoricalBlocksFromHeight in config // - log.Info("Test Setting ProcessHistoricalBlocksFromHeight in config") + fmt.Println("Test Setting ProcessHistoricalBlocksFromHeight in config") testUtils.TriggerProcessMissedBlocks( ctx, + teleporter, subnetAInfo, subnetBInfo, relayerCleanup, diff --git a/tests/batch_relay.go b/tests/batch_relay.go index b1960a5c..db6d3b2e 100644 --- a/tests/batch_relay.go +++ b/tests/batch_relay.go @@ -12,6 +12,7 @@ import ( "github.com/ava-labs/subnet-evm/accounts/abi/bind" "github.com/ava-labs/subnet-evm/core/types" "github.com/ava-labs/teleporter/tests/interfaces" + "github.com/ava-labs/teleporter/tests/network" "github.com/ava-labs/teleporter/tests/utils" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" @@ -20,10 +21,9 @@ import ( ) // Processes multiple Warp messages contained in the same block -func BatchRelay(network interfaces.LocalNetwork) { - subnetAInfo, subnetBInfo := utils.GetTwoSubnets(network) +func BatchRelay(network *network.LocalNetwork, teleporter utils.TeleporterTestInfo) { + subnetAInfo, subnetBInfo := network.GetTwoSubnets() fundedAddress, fundedKey := network.GetFundedAccountInfo() - teleporterContractAddress := network.GetTeleporterContractAddress() err := testUtils.ClearRelayerStorage() Expect(err).Should(BeNil()) @@ -34,12 +34,14 @@ func BatchRelay(network interfaces.LocalNetwork) { _, batchMessengerA := testUtils.DeployBatchCrossChainMessenger( ctx, fundedKey, + teleporter, fundedAddress, subnetAInfo, ) batchMessengerAddressB, batchMessengerB := testUtils.DeployBatchCrossChainMessenger( ctx, fundedKey, + teleporter, fundedAddress, subnetBInfo, ) @@ -57,9 +59,9 @@ func BatchRelay(network interfaces.LocalNetwork) { // Set up relayer config // relayerConfig := testUtils.CreateDefaultRelayerConfig( + teleporter, []interfaces.SubnetTestInfo{subnetAInfo, subnetBInfo}, []interfaces.SubnetTestInfo{subnetAInfo, subnetBInfo}, - teleporterContractAddress, fundedAddress, relayerKey, ) diff --git a/tests/e2e_test.go b/tests/e2e_test.go index 2210d66a..0a5e2bc3 100644 --- a/tests/e2e_test.go +++ b/tests/e2e_test.go @@ -17,7 +17,8 @@ import ( testUtils "github.com/ava-labs/awm-relayer/tests/utils" "github.com/ava-labs/awm-relayer/utils" - "github.com/ava-labs/teleporter/tests/local" + "github.com/ava-labs/teleporter/tests/network" + teleporterTestUtils "github.com/ava-labs/teleporter/tests/utils" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/log" "github.com/onsi/ginkgo/v2" @@ -29,7 +30,8 @@ const ( ) var ( - localNetworkInstance *local.LocalNetwork + localNetworkInstance *network.LocalNetwork + teleporterInfo teleporterTestUtils.TeleporterTestInfo decider *exec.Cmd cancelFn context.CancelFunc @@ -81,11 +83,11 @@ var _ = ginkgo.BeforeSuite(func() { Expect(err).Should(BeNil()) networkStartCtx, networkStartCancel := context.WithTimeout(ctx, 120*time.Second) defer networkStartCancel() - localNetworkInstance = local.NewLocalNetwork( + localNetworkInstance = network.NewLocalNetwork( networkStartCtx, "icm-off-chain-services-e2e-test", warpGenesisTemplateFile, - []local.SubnetSpec{ + []network.SubnetSpec{ { Name: "A", EVMChainID: 12345, @@ -105,19 +107,25 @@ var _ = ginkgo.BeforeSuite(func() { }, 0, ) + teleporterInfo = teleporterTestUtils.NewTeleporterTestInfo(localNetworkInstance.GetAllSubnetsInfo()) + // Only need to deploy Teleporter on the C-Chain since it is included in the genesis of the subnet chains. _, fundedKey := localNetworkInstance.GetFundedAccountInfo() - log.Info("Deployed Teleporter contracts") - localNetworkInstance.DeployTeleporterContractToCChain( + teleporterInfo.DeployTeleporterMessenger( + ctx, + localNetworkInstance.GetPrimaryNetworkInfo(), teleporterDeployerTransaction, teleporterDeployerAddress, teleporterContractAddress, fundedKey, ) - localNetworkInstance.SetTeleporterContractAddress(teleporterContractAddress) // Deploy the Teleporter registry contracts to all subnets and the C-Chain. - localNetworkInstance.DeployTeleporterRegistryContracts(teleporterContractAddress, fundedKey) + for _, subnet := range localNetworkInstance.GetAllSubnetsInfo() { + teleporterInfo.SetTeleporter(teleporterContractAddress, subnet) + teleporterInfo.InitializeBlockchainID(subnet, fundedKey) + teleporterInfo.DeployTeleporterRegistry(subnet, fundedKey) + } decider = exec.CommandContext(ctx, "./tests/cmd/decider/decider") decider.Start() @@ -155,30 +163,30 @@ var _ = ginkgo.AfterSuite(cleanup) var _ = ginkgo.Describe("[AWM Relayer Integration Tests", func() { ginkgo.It("Manually Provided Message", func() { - ManualMessage(localNetworkInstance) + ManualMessage(localNetworkInstance, teleporterInfo) }) ginkgo.It("Basic Relay", func() { - BasicRelay(localNetworkInstance) + BasicRelay(localNetworkInstance, teleporterInfo) }) ginkgo.It("Shared Database", func() { - SharedDatabaseAccess(localNetworkInstance) + SharedDatabaseAccess(localNetworkInstance, teleporterInfo) }) ginkgo.It("Allowed Addresses", func() { - AllowedAddresses(localNetworkInstance) + AllowedAddresses(localNetworkInstance, teleporterInfo) }) ginkgo.It("Batch Message", func() { - BatchRelay(localNetworkInstance) + BatchRelay(localNetworkInstance, teleporterInfo) }) ginkgo.It("Relay Message API", func() { - RelayMessageAPI(localNetworkInstance) + RelayMessageAPI(localNetworkInstance, teleporterInfo) }) ginkgo.It("Warp API", func() { - WarpAPIRelay(localNetworkInstance) + WarpAPIRelay(localNetworkInstance, teleporterInfo) }) ginkgo.It("Signature Aggregator", func() { - SignatureAggregatorAPI(localNetworkInstance) + SignatureAggregatorAPI(localNetworkInstance, teleporterInfo) }) ginkgo.It("Etna Upgrade", func() { - EtnaUpgrade(localNetworkInstance) + EtnaUpgrade(localNetworkInstance, teleporterInfo) }) }) diff --git a/tests/etna_upgrade.go b/tests/etna_upgrade.go index 02ab768c..1c9ce1f2 100644 --- a/tests/etna_upgrade.go +++ b/tests/etna_upgrade.go @@ -9,6 +9,7 @@ import ( testUtils "github.com/ava-labs/awm-relayer/tests/utils" "github.com/ava-labs/teleporter/tests/interfaces" + "github.com/ava-labs/teleporter/tests/network" "github.com/ava-labs/teleporter/tests/utils" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/log" @@ -20,11 +21,10 @@ import ( // to the config and therefore are testing the pre-etna case // - Relaying from Subnet A to Subnet B // - Relaying from Subnet B to Subnet A -func EtnaUpgrade(network interfaces.LocalNetwork) { +func EtnaUpgrade(network *network.LocalNetwork, teleporter utils.TeleporterTestInfo) { subnetAInfo := network.GetPrimaryNetworkInfo() - subnetBInfo, _ := utils.GetTwoSubnets(network) + subnetBInfo, _ := network.GetTwoSubnets() fundedAddress, fundedKey := network.GetFundedAccountInfo() - teleporterContractAddress := network.GetTeleporterContractAddress() err := testUtils.ClearRelayerStorage() Expect(err).Should(BeNil()) // @@ -41,9 +41,9 @@ func EtnaUpgrade(network interfaces.LocalNetwork) { // Set up relayer config // relayerConfig := testUtils.CreateDefaultRelayerConfig( + teleporter, []interfaces.SubnetTestInfo{subnetAInfo, subnetBInfo}, []interfaces.SubnetTestInfo{subnetAInfo, subnetBInfo}, - teleporterContractAddress, fundedAddress, relayerKey, ) @@ -75,9 +75,9 @@ func EtnaUpgrade(network interfaces.LocalNetwork) { log.Info("Sending transaction from Subnet A to Subnet B") testUtils.RelayBasicMessage( ctx, + teleporter, subnetAInfo, subnetBInfo, - teleporterContractAddress, fundedKey, fundedAddress, ) @@ -85,9 +85,9 @@ func EtnaUpgrade(network interfaces.LocalNetwork) { log.Info("Test Relaying from Subnet B to Subnet A") testUtils.RelayBasicMessage( ctx, + teleporter, subnetBInfo, subnetAInfo, - teleporterContractAddress, fundedKey, fundedAddress, ) diff --git a/tests/manual_message.go b/tests/manual_message.go index b254ad99..6e4be6b2 100644 --- a/tests/manual_message.go +++ b/tests/manual_message.go @@ -17,6 +17,8 @@ import ( testUtils "github.com/ava-labs/awm-relayer/tests/utils" "github.com/ava-labs/subnet-evm/accounts/abi/bind" "github.com/ava-labs/teleporter/tests/interfaces" + "github.com/ava-labs/teleporter/tests/network" + "github.com/ava-labs/teleporter/tests/utils" teleporterTestUtils "github.com/ava-labs/teleporter/tests/utils" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" @@ -27,18 +29,17 @@ import ( // Tests relayer support for off-chain Teleporter Registry updates // - Configures the relayer to send an off-chain message to the Teleporter Registry // - Verifies that the Teleporter Registry is updated -func ManualMessage(network interfaces.LocalNetwork) { +func ManualMessage(network *network.LocalNetwork, teleporter utils.TeleporterTestInfo) { cChainInfo := network.GetPrimaryNetworkInfo() - subnetAInfo, subnetBInfo := teleporterTestUtils.GetTwoSubnets(network) + subnetAInfo, subnetBInfo := network.GetTwoSubnets() fundedAddress, fundedKey := network.GetFundedAccountInfo() - teleporterContractAddress := network.GetTeleporterContractAddress() err := testUtils.ClearRelayerStorage() Expect(err).Should(BeNil()) // // Get the current Teleporter Registry version // - currentVersion, err := cChainInfo.TeleporterRegistry.LatestVersion(&bind.CallOpts{}) + currentVersion, err := teleporter.TeleporterRegistry(cChainInfo).LatestVersion(&bind.CallOpts{}) Expect(err).Should(BeNil()) expectedNewVersion := currentVersion.Add(currentVersion, big.NewInt(1)) @@ -66,18 +67,21 @@ func ManualMessage(network interfaces.LocalNetwork) { unsignedMessage, warpEnabledChainConfigC := teleporterTestUtils.InitOffChainMessageChainConfig( networkID, cChainInfo, + teleporter.TeleporterRegistryAddress(cChainInfo), newProtocolAddress, 2, ) _, warpEnabledChainConfigA := teleporterTestUtils.InitOffChainMessageChainConfig( networkID, subnetAInfo, + teleporter.TeleporterRegistryAddress(subnetAInfo), newProtocolAddress, 2, ) _, warpEnabledChainConfigB := teleporterTestUtils.InitOffChainMessageChainConfig( networkID, subnetBInfo, + teleporter.TeleporterRegistryAddress(subnetBInfo), newProtocolAddress, 2, ) @@ -89,10 +93,9 @@ func ManualMessage(network interfaces.LocalNetwork) { chainConfigs.Add(subnetAInfo, warpEnabledChainConfigA) // Restart nodes with new chain config - nodeIDs := network.GetAllNodeIDs() log.Info("Restarting nodes with new chain config") network.SetChainConfigs(chainConfigs) - network.RestartNodes(ctx, nodeIDs) + // Refresh the subnet info to get the new clients cChainInfo = network.GetPrimaryNetworkInfo() @@ -100,9 +103,9 @@ func ManualMessage(network interfaces.LocalNetwork) { // Set up relayer config // relayerConfig := testUtils.CreateDefaultRelayerConfig( + teleporter, []interfaces.SubnetTestInfo{cChainInfo}, []interfaces.SubnetTestInfo{cChainInfo}, - teleporterContractAddress, fundedAddress, relayerKey, ) @@ -150,7 +153,7 @@ func ManualMessage(network interfaces.LocalNetwork) { // Wait for all nodes to see new transaction time.Sleep(1 * time.Second) - newVersion, err := cChainInfo.TeleporterRegistry.LatestVersion(&bind.CallOpts{}) + newVersion, err := teleporter.TeleporterRegistry(cChainInfo).LatestVersion(&bind.CallOpts{}) Expect(err).Should(BeNil()) Expect(newVersion.Uint64()).Should(Equal(expectedNewVersion.Uint64())) } diff --git a/tests/relay_message_api.go b/tests/relay_message_api.go index 2c18ed81..67618d63 100644 --- a/tests/relay_message_api.go +++ b/tests/relay_message_api.go @@ -20,6 +20,7 @@ import ( subnetEvmInterfaces "github.com/ava-labs/subnet-evm/interfaces" "github.com/ava-labs/subnet-evm/precompile/contracts/warp" "github.com/ava-labs/teleporter/tests/interfaces" + "github.com/ava-labs/teleporter/tests/network" "github.com/ava-labs/teleporter/tests/utils" teleporterTestUtils "github.com/ava-labs/teleporter/tests/utils" "github.com/ethereum/go-ethereum/common" @@ -28,12 +29,11 @@ import ( . "github.com/onsi/gomega" ) -func RelayMessageAPI(network interfaces.LocalNetwork) { +func RelayMessageAPI(network *network.LocalNetwork, teleporter utils.TeleporterTestInfo) { ctx := context.Background() subnetAInfo := network.GetPrimaryNetworkInfo() - subnetBInfo, _ := utils.GetTwoSubnets(network) + subnetBInfo, _ := network.GetTwoSubnets() fundedAddress, fundedKey := network.GetFundedAccountInfo() - teleporterContractAddress := network.GetTeleporterContractAddress() err := testUtils.ClearRelayerStorage() Expect(err).Should(BeNil()) @@ -45,6 +45,7 @@ func RelayMessageAPI(network interfaces.LocalNetwork) { log.Info("Sending teleporter message") receipt, _, teleporterMessageID := testUtils.SendBasicTeleporterMessage( ctx, + teleporter, subnetAInfo, subnetBInfo, fundedKey, @@ -54,9 +55,9 @@ func RelayMessageAPI(network interfaces.LocalNetwork) { // Set up relayer config relayerConfig := testUtils.CreateDefaultRelayerConfig( + teleporter, []interfaces.SubnetTestInfo{subnetAInfo, subnetBInfo}, []interfaces.SubnetTestInfo{subnetAInfo, subnetBInfo}, - teleporterContractAddress, fundedAddress, relayerKey, ) @@ -117,7 +118,7 @@ func RelayMessageAPI(network interfaces.LocalNetwork) { Expect(err).Should(BeNil()) receiveEvent, err := teleporterTestUtils.GetEventFromLogs( receipt.Logs, - subnetBInfo.TeleporterMessenger.ParseReceiveCrossChainMessage, + teleporter.TeleporterMessenger(subnetBInfo).ParseReceiveCrossChainMessage, ) Expect(err).Should(BeNil()) Expect(ids.ID(receiveEvent.MessageID)).Should(Equal(teleporterMessageID)) diff --git a/tests/shared_db.go b/tests/shared_db.go index 0114dd18..7817de78 100644 --- a/tests/shared_db.go +++ b/tests/shared_db.go @@ -6,6 +6,7 @@ import ( testUtils "github.com/ava-labs/awm-relayer/tests/utils" "github.com/ava-labs/teleporter/tests/interfaces" + "github.com/ava-labs/teleporter/tests/network" "github.com/ava-labs/teleporter/tests/utils" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/log" @@ -15,11 +16,10 @@ import ( const relayerCfgFnameA = "relayer-config-a.json" const relayerCfgFnameB = "relayer-config-b.json" -func SharedDatabaseAccess(network interfaces.LocalNetwork) { +func SharedDatabaseAccess(network *network.LocalNetwork, teleporter utils.TeleporterTestInfo) { subnetAInfo := network.GetPrimaryNetworkInfo() - subnetBInfo, _ := utils.GetTwoSubnets(network) + subnetBInfo, _ := network.GetTwoSubnets() fundedAddress, fundedKey := network.GetFundedAccountInfo() - teleporterContractAddress := network.GetTeleporterContractAddress() err := testUtils.ClearRelayerStorage() Expect(err).Should(BeNil()) @@ -42,17 +42,17 @@ func SharedDatabaseAccess(network interfaces.LocalNetwork) { // // Relayer A will relay messages from Subnet A to Subnet B relayerConfigA := testUtils.CreateDefaultRelayerConfig( + teleporter, []interfaces.SubnetTestInfo{subnetAInfo}, []interfaces.SubnetTestInfo{subnetBInfo}, - teleporterContractAddress, fundedAddress, relayerKeyA, ) // Relayer B will relay messages from Subnet B to Subnet A relayerConfigB := testUtils.CreateDefaultRelayerConfig( + teleporter, []interfaces.SubnetTestInfo{subnetBInfo}, []interfaces.SubnetTestInfo{subnetAInfo}, - teleporterContractAddress, fundedAddress, relayerKeyB, ) @@ -96,9 +96,9 @@ func SharedDatabaseAccess(network interfaces.LocalNetwork) { log.Info("Sending transaction from Subnet A to Subnet B") testUtils.RelayBasicMessage( ctx, + teleporter, subnetAInfo, subnetBInfo, - teleporterContractAddress, fundedKey, fundedAddress, ) @@ -109,9 +109,9 @@ func SharedDatabaseAccess(network interfaces.LocalNetwork) { log.Info("Test Relaying from Subnet B to Subnet A") testUtils.RelayBasicMessage( ctx, + teleporter, subnetBInfo, subnetAInfo, - teleporterContractAddress, fundedKey, fundedAddress, ) @@ -122,6 +122,7 @@ func SharedDatabaseAccess(network interfaces.LocalNetwork) { log.Info("Testing processing missed blocks on Subnet A") testUtils.TriggerProcessMissedBlocks( ctx, + teleporter, subnetAInfo, subnetBInfo, relayerCleanupA, @@ -133,6 +134,7 @@ func SharedDatabaseAccess(network interfaces.LocalNetwork) { log.Info("Testing processing missed blocks on Subnet B") testUtils.TriggerProcessMissedBlocks( ctx, + teleporter, subnetBInfo, subnetAInfo, relayerCleanupB, diff --git a/tests/signature_aggregator_api.go b/tests/signature_aggregator_api.go index 2e26855e..27f2486e 100644 --- a/tests/signature_aggregator_api.go +++ b/tests/signature_aggregator_api.go @@ -21,6 +21,7 @@ import ( "github.com/ava-labs/awm-relayer/signature-aggregator/metrics" testUtils "github.com/ava-labs/awm-relayer/tests/utils" "github.com/ava-labs/teleporter/tests/interfaces" + "github.com/ava-labs/teleporter/tests/network" "github.com/ava-labs/teleporter/tests/utils" "github.com/ethereum/go-ethereum/log" . "github.com/onsi/gomega" @@ -35,12 +36,12 @@ import ( // - Reads the warp message unsigned bytes from the log // - Sends the unsigned message to the signature aggregator API // - Confirms that the signed message is returned and matches the originally sent message -func SignatureAggregatorAPI(network interfaces.LocalNetwork) { +func SignatureAggregatorAPI(network *network.LocalNetwork, teleporter utils.TeleporterTestInfo) { // Begin Setup step ctx := context.Background() subnetAInfo := network.GetPrimaryNetworkInfo() - subnetBInfo, _ := utils.GetTwoSubnets(network) + subnetBInfo, _ := network.GetTwoSubnets() fundedAddress, fundedKey := network.GetFundedAccountInfo() signatureAggregatorConfig := testUtils.CreateDefaultSignatureAggregatorConfig( @@ -71,6 +72,7 @@ func SignatureAggregatorAPI(network interfaces.LocalNetwork) { log.Info("Sending teleporter message") receipt, _, _ := testUtils.SendBasicTeleporterMessage( ctx, + teleporter, subnetAInfo, subnetBInfo, fundedKey, @@ -156,6 +158,7 @@ func SignatureAggregatorAPI(network interfaces.LocalNetwork) { ) } + // TODONOW: Fix this using the new subnet weights post conversion // make a second request, and ensure that the metrics reflect that the // signatures for the second request are retrieved from the cache. note // that even though 4 signatures were requested in the previous diff --git a/tests/utils/utils.go b/tests/utils/utils.go index 70974a4b..e01f9395 100644 --- a/tests/utils/utils.go +++ b/tests/utils/utils.go @@ -110,9 +110,9 @@ func ReadHexTextFile(filename string) string { // Constructs a relayer config with all subnets as sources and destinations func CreateDefaultRelayerConfig( + teleporter teleporterTestUtils.TeleporterTestInfo, sourceSubnetsInfo []interfaces.SubnetTestInfo, destinationSubnetsInfo []interfaces.SubnetTestInfo, - teleporterContractAddress common.Address, fundedAddress common.Address, relayerKey *ecdsa.PrivateKey, ) relayercfg.Config { @@ -144,7 +144,7 @@ func CreateDefaultRelayerConfig( }, MessageContracts: map[string]relayercfg.MessageProtocolConfig{ - teleporterContractAddress.Hex(): { + teleporter.TeleporterMessengerAddress(subnetInfo).Hex(): { MessageFormat: relayercfg.TELEPORTER.String(), Settings: map[string]interface{}{ "reward-address": fundedAddress.Hex(), @@ -153,7 +153,7 @@ func CreateDefaultRelayerConfig( offchainregistry.OffChainRegistrySourceAddress.Hex(): { MessageFormat: relayercfg.OFF_CHAIN_REGISTRY.String(), Settings: map[string]interface{}{ - "teleporter-registry-address": subnetInfo.TeleporterRegistryAddress.Hex(), + "teleporter-registry-address": teleporter.TeleporterRegistryAddress(subnetInfo).Hex(), }, }, }, @@ -264,6 +264,7 @@ func FundRelayers( func SendBasicTeleporterMessageAsync( ctx context.Context, + teleporter teleporterTestUtils.TeleporterTestInfo, source interfaces.SubnetTestInfo, destination interfaces.SubnetTestInfo, fundedKey *ecdsa.PrivateKey, @@ -290,6 +291,7 @@ func SendBasicTeleporterMessageAsync( ) _, teleporterMessageID := teleporterTestUtils.SendCrossChainMessageAndWaitForAcceptance( ctx, + teleporter.TeleporterMessenger(source), source, destination, input, @@ -300,6 +302,7 @@ func SendBasicTeleporterMessageAsync( func SendBasicTeleporterMessage( ctx context.Context, + teleporter teleporterTestUtils.TeleporterTestInfo, source interfaces.SubnetTestInfo, destination interfaces.SubnetTestInfo, fundedKey *ecdsa.PrivateKey, @@ -325,6 +328,7 @@ func SendBasicTeleporterMessage( ) receipt, teleporterMessageID := teleporterTestUtils.SendCrossChainMessageAndWaitForAcceptance( ctx, + teleporter.TeleporterMessenger(source), source, destination, input, @@ -332,7 +336,7 @@ func SendBasicTeleporterMessage( ) sendEvent, err := teleporterTestUtils.GetEventFromLogs( receipt.Logs, - source.TeleporterMessenger.ParseSendCrossChainMessage, + teleporter.TeleporterMessenger(source).ParseSendCrossChainMessage, ) Expect(err).Should(BeNil()) @@ -341,9 +345,9 @@ func SendBasicTeleporterMessage( func RelayBasicMessage( ctx context.Context, + teleporter teleporterTestUtils.TeleporterTestInfo, source interfaces.SubnetTestInfo, destination interfaces.SubnetTestInfo, - teleporterContractAddress common.Address, fundedKey *ecdsa.PrivateKey, destinationAddress common.Address, ) { @@ -354,6 +358,7 @@ func RelayBasicMessage( _, _, teleporterMessageID := SendBasicTeleporterMessage( ctx, + teleporter, source, destination, fundedKey, @@ -361,10 +366,43 @@ func RelayBasicMessage( ) log.Info("Waiting for Teleporter message delivery") - err = utils.WaitTeleporterMessageDelivered(ctx, destination.TeleporterMessenger, teleporterMessageID) + err = WaitTeleporterMessageDelivered(ctx, teleporter.TeleporterMessenger(destination), teleporterMessageID) Expect(err).Should(BeNil()) } +// Blocks until the given teleporter message is delivered to the specified TeleporterMessenger +// before the timeout, or if an error occurred. +func WaitTeleporterMessageDelivered( + ctx context.Context, + teleporterMessenger *teleportermessenger.TeleporterMessenger, + teleporterMessageID ids.ID, +) error { + cctx, cancel := context.WithTimeout(ctx, 20*time.Second) + defer cancel() + + queryTicker := time.NewTicker(200 * time.Millisecond) + defer queryTicker.Stop() + for { + delivered, err := teleporterMessenger.MessageReceived( + &bind.CallOpts{}, teleporterMessageID, + ) + if err != nil { + return err + } + + if delivered { + return nil + } + + // Wait for the next round. + select { + case <-cctx.Done(): + return cctx.Err() + case <-queryTicker.C: + } + } +} + func WriteRelayerConfig(relayerConfig relayercfg.Config, fname string) string { data, err := json.MarshalIndent(relayerConfig, "", "\t") Expect(err).Should(BeNil()) @@ -398,6 +436,7 @@ func WriteSignatureAggregatorConfig(signatureAggregatorConfig signatureaggregato func TriggerProcessMissedBlocks( ctx context.Context, + teleporter teleporterTestUtils.TeleporterTestInfo, sourceSubnetInfo interfaces.SubnetTestInfo, destinationSubnetInfo interfaces.SubnetTestInfo, currRelayerCleanup context.CancelFunc, @@ -416,9 +455,9 @@ func TriggerProcessMissedBlocks( // Send three Teleporter messages from subnet A to subnet B log.Info("Sending three Teleporter messages from subnet A to subnet B") - _, _, id1 := SendBasicTeleporterMessage(ctx, sourceSubnetInfo, destinationSubnetInfo, fundedKey, fundedAddress) - _, _, id2 := SendBasicTeleporterMessage(ctx, sourceSubnetInfo, destinationSubnetInfo, fundedKey, fundedAddress) - _, _, id3 := SendBasicTeleporterMessage(ctx, sourceSubnetInfo, destinationSubnetInfo, fundedKey, fundedAddress) + _, _, id1 := SendBasicTeleporterMessage(ctx, teleporter, sourceSubnetInfo, destinationSubnetInfo, fundedKey, fundedAddress) + _, _, id2 := SendBasicTeleporterMessage(ctx, teleporter, sourceSubnetInfo, destinationSubnetInfo, fundedKey, fundedAddress) + _, _, id3 := SendBasicTeleporterMessage(ctx, teleporter, sourceSubnetInfo, destinationSubnetInfo, fundedKey, fundedAddress) currHeight, err := sourceSubnetInfo.RPCClient.BlockNumber(ctx) Expect(err).Should(BeNil()) @@ -450,18 +489,18 @@ func TriggerProcessMissedBlocks( <-newHeads log.Info("Waiting for Teleporter message delivery") - err = utils.WaitTeleporterMessageDelivered(ctx, destinationSubnetInfo.TeleporterMessenger, id3) + err = WaitTeleporterMessageDelivered(ctx, teleporter.TeleporterMessenger(destinationSubnetInfo), id3) Expect(err).Should(BeNil()) - delivered1, err := destinationSubnetInfo.TeleporterMessenger.MessageReceived( + delivered1, err := teleporter.TeleporterMessenger(destinationSubnetInfo).MessageReceived( &bind.CallOpts{}, id1, ) Expect(err).Should(BeNil()) - delivered2, err := destinationSubnetInfo.TeleporterMessenger.MessageReceived( + delivered2, err := teleporter.TeleporterMessenger(destinationSubnetInfo).MessageReceived( &bind.CallOpts{}, id2, ) Expect(err).Should(BeNil()) - delivered3, err := destinationSubnetInfo.TeleporterMessenger.MessageReceived( + delivered3, err := teleporter.TeleporterMessenger(destinationSubnetInfo).MessageReceived( &bind.CallOpts{}, id3, ) Expect(err).Should(BeNil()) @@ -473,6 +512,7 @@ func TriggerProcessMissedBlocks( func DeployBatchCrossChainMessenger( ctx context.Context, senderKey *ecdsa.PrivateKey, + teleporter teleporterTestUtils.TeleporterTestInfo, teleporterManager common.Address, subnet interfaces.SubnetTestInfo, ) (common.Address, *batchcrosschainmessenger.BatchCrossChainMessenger) { @@ -482,7 +522,7 @@ func DeployBatchCrossChainMessenger( address, tx, exampleMessenger, err := batchcrosschainmessenger.DeployBatchCrossChainMessenger( opts, subnet.RPCClient, - subnet.TeleporterRegistryAddress, + teleporter.TeleporterRegistryAddress(subnet), teleporterManager, ) Expect(err).Should(BeNil()) diff --git a/tests/warp_api.go b/tests/warp_api.go index 9a374fc2..194ed5c4 100644 --- a/tests/warp_api.go +++ b/tests/warp_api.go @@ -15,6 +15,7 @@ import ( testUtils "github.com/ava-labs/awm-relayer/tests/utils" "github.com/ava-labs/teleporter/tests/interfaces" + "github.com/ava-labs/teleporter/tests/network" "github.com/ava-labs/teleporter/tests/utils" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/log" @@ -28,11 +29,10 @@ const rpcSignatureMetricName = "app_fetch_signature_rpc_count" // - Relaying from Subnet A to Subnet B // - Relaying from Subnet B to Subnet A // - Verifying the messages were signed using the Warp API -func WarpAPIRelay(network interfaces.LocalNetwork) { +func WarpAPIRelay(network *network.LocalNetwork, teleporter utils.TeleporterTestInfo) { subnetAInfo := network.GetPrimaryNetworkInfo() - subnetBInfo, _ := utils.GetTwoSubnets(network) + subnetBInfo, _ := network.GetTwoSubnets() fundedAddress, fundedKey := network.GetFundedAccountInfo() - teleporterContractAddress := network.GetTeleporterContractAddress() err := testUtils.ClearRelayerStorage() Expect(err).Should(BeNil()) @@ -50,9 +50,9 @@ func WarpAPIRelay(network interfaces.LocalNetwork) { // Set up relayer config // relayerConfig := testUtils.CreateDefaultRelayerConfig( + teleporter, []interfaces.SubnetTestInfo{subnetAInfo, subnetBInfo}, []interfaces.SubnetTestInfo{subnetAInfo, subnetBInfo}, - teleporterContractAddress, fundedAddress, relayerKey, ) @@ -85,9 +85,9 @@ func WarpAPIRelay(network interfaces.LocalNetwork) { log.Info("Sending transaction from Subnet A to Subnet B") testUtils.RelayBasicMessage( ctx, + teleporter, subnetAInfo, subnetBInfo, - teleporterContractAddress, fundedKey, fundedAddress, ) @@ -98,9 +98,9 @@ func WarpAPIRelay(network interfaces.LocalNetwork) { log.Info("Test Relaying from Subnet B to Subnet A") testUtils.RelayBasicMessage( ctx, + teleporter, subnetBInfo, subnetAInfo, - teleporterContractAddress, fundedKey, fundedAddress, ) From 99c58e925a752d10e1abb8662c1c460921ec4ac1 Mon Sep 17 00:00:00 2001 From: cam-schultz Date: Wed, 13 Nov 2024 16:01:27 -0600 Subject: [PATCH 05/28] bump teleporter dep --- go.mod | 7 +------ go.sum | 2 ++ tests/e2e_test.go | 1 + 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index 3b114490..6d6d8ca2 100644 --- a/go.mod +++ b/go.mod @@ -2,13 +2,11 @@ module github.com/ava-labs/awm-relayer go 1.22.8 -replace github.com/ava-labs/teleporter => /Users/cameron.schultz/teleporter - require ( github.com/ava-labs/avalanchego v1.12.0-initial-poc.8 github.com/ava-labs/coreth v0.13.8 github.com/ava-labs/subnet-evm v0.6.11 - github.com/ava-labs/teleporter v1.0.7 + github.com/ava-labs/teleporter v1.0.8-0.20241113215352-fdd3e578a507 github.com/aws/aws-sdk-go-v2 v1.32.2 github.com/aws/aws-sdk-go-v2/config v1.27.9 github.com/aws/aws-sdk-go-v2/service/kms v1.37.2 @@ -124,9 +122,7 @@ require ( github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f // indirect github.com/nbutton23/zxcvbn-go v0.0.0-20180912185939-ae427f1e4c1d // indirect - github.com/nxadm/tail v1.4.8 // indirect github.com/olekukonko/tablewriter v0.0.5 // indirect - github.com/onsi/ginkgo v1.16.5 // indirect github.com/pelletier/go-toml/v2 v2.0.8 // indirect github.com/pires/go-proxyproto v0.6.2 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect @@ -175,7 +171,6 @@ require ( gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect - gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect k8s.io/api v0.29.0 // indirect diff --git a/go.sum b/go.sum index 3abc8e93..c968db09 100644 --- a/go.sum +++ b/go.sum @@ -66,6 +66,8 @@ github.com/ava-labs/coreth v0.13.8 h1:f14X3KgwHl9LwzfxlN6S4bbn5VA2rhEsNnHaRLSTo/ github.com/ava-labs/coreth v0.13.8/go.mod h1:t3BSv/eQv0AlDPMfEDCMMoD/jq1RkUsbFzQAFg5qBcE= github.com/ava-labs/subnet-evm v0.6.11 h1:XgIAn9ihPyGjrBFD2rXg2H76HFl6htliHabN0fjciaQ= github.com/ava-labs/subnet-evm v0.6.11/go.mod h1:fP46lzBtiniRfpNH+Qu9BFvSsa02YGkAobxinZ78gDU= +github.com/ava-labs/teleporter v1.0.8-0.20241113215352-fdd3e578a507 h1:Ki3ueqLWblscPkGtVPFapKemyJ5xHidgeXZ1ISQGHug= +github.com/ava-labs/teleporter v1.0.8-0.20241113215352-fdd3e578a507/go.mod h1:UOcmJTB6+mNCn50V7Fit9MB6dVL8obOHu3i5dP6is34= github.com/aws/aws-sdk-go-v2 v1.32.2 h1:AkNLZEyYMLnx/Q/mSKkcMqwNFXMAvFto9bNsHqcTduI= github.com/aws/aws-sdk-go-v2 v1.32.2/go.mod h1:2SK5n0a2karNTv5tbP1SjsX0uhttou00v/HpXKM1ZUo= github.com/aws/aws-sdk-go-v2/config v1.27.9 h1:gRx/NwpNEFSk+yQlgmk1bmxxvQ5TyJ76CWXs9XScTqg= diff --git a/tests/e2e_test.go b/tests/e2e_test.go index 0a5e2bc3..2012de5d 100644 --- a/tests/e2e_test.go +++ b/tests/e2e_test.go @@ -105,6 +105,7 @@ var _ = ginkgo.BeforeSuite(func() { NodeCount: 2, }, }, + 4, 0, ) teleporterInfo = teleporterTestUtils.NewTeleporterTestInfo(localNetworkInstance.GetAllSubnetsInfo()) From 6c29cff742ef681e44baa56c25d33113f0b95895 Mon Sep 17 00:00:00 2001 From: cam-schultz Date: Thu, 14 Nov 2024 16:57:16 -0600 Subject: [PATCH 06/28] manually tracked peers cfg --- relayer/config/config.go | 6 ++++++ tests/basic_relay.go | 18 ++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/relayer/config/config.go b/relayer/config/config.go index 3f643dd2..db70f399 100644 --- a/relayer/config/config.go +++ b/relayer/config/config.go @@ -67,6 +67,7 @@ type Config struct { ProcessMissedBlocks bool `mapstructure:"process-missed-blocks" json:"process-missed-blocks"` DeciderURL string `mapstructure:"decider-url" json:"decider-url"` SignatureCacheSize uint64 `mapstructure:"signature-cache-size" json:"signature-cache-size"` + ManuallyTrackedPeers []basecfg.PeerConfig `mapstructure:"manually-tracked-peers" json:"manually-tracked-peers"` // mapstructure doesn't handle time.Time out of the box so handle it manually EtnaTime time.Time `json:"etna-time"` @@ -110,6 +111,11 @@ func (c *Config) Validate() error { if c.DBWriteIntervalSeconds == 0 || c.DBWriteIntervalSeconds > 600 { return errors.New("db-write-interval-seconds must be between 1 and 600") } + for _, p := range c.ManuallyTrackedPeers { + if err := p.Validate(); err != nil { + return err + } + } blockchainIDToSubnetID := make(map[ids.ID]ids.ID) diff --git a/tests/basic_relay.go b/tests/basic_relay.go index 509e67fc..0aa2957a 100644 --- a/tests/basic_relay.go +++ b/tests/basic_relay.go @@ -6,10 +6,13 @@ package tests import ( "context" "fmt" + "net/netip" "os" "time" + "url" "github.com/ava-labs/avalanchego/utils/logging" + "github.com/ava-labs/awm-relayer/config" "github.com/ava-labs/awm-relayer/database" testUtils "github.com/ava-labs/awm-relayer/tests/utils" "github.com/ava-labs/subnet-evm/core/types" @@ -52,6 +55,21 @@ func BasicRelay(network *network.LocalNetwork, teleporter utils.TeleporterTestIn fundedAddress, relayerKey, ) + + // Add primary network validators as manually tracked peers + var manuallyTrackedPeers []config.PeerConfig + primaryNetworkValidators := network.GetPrimaryNetworkValidators() + for _, validator := range primaryNetworkValidators { + parsed, err := url.Parse(validator.URI) + Expect(err).Should(BeNil()) + ip, err := netip.ParseAddrPort(parsed.Host) + Expect(err).Should(BeNil()) + manuallyTrackedPeers = append(manuallyTrackedPeers, config.PeerConfig{ + IP: ip, + ID: validator.NodeID, + }) + } + // The config needs to be validated in order to be passed to database.GetConfigRelayerIDs relayerConfig.Validate() From bbb2c71e05ae80efb09649bdd4732a3f6e6a0dab Mon Sep 17 00:00:00 2001 From: cam-schultz Date: Fri, 15 Nov 2024 15:29:28 -0600 Subject: [PATCH 07/28] wip --- config/peer_config.go | 41 +++++++++ go.mod | 5 ++ go.sum | 4 - peers/app_request_network.go | 51 +++++++++++- peers/external_handler.go | 2 +- relayer/config/config.go | 2 +- relayer/main/main.go | 16 ++-- scripts/e2e_test.sh | 49 +++++++---- tests/basic_relay.go | 60 +++++++++++--- tests/e2e_test.go | 64 ++++++++------ tests/utils/utils.go | 10 +-- tests/utils/warp-genesis-template.json | 110 ++++++++++++++++--------- 12 files changed, 294 insertions(+), 120 deletions(-) create mode 100644 config/peer_config.go diff --git a/config/peer_config.go b/config/peer_config.go new file mode 100644 index 00000000..7cf93999 --- /dev/null +++ b/config/peer_config.go @@ -0,0 +1,41 @@ +package config + +import ( + "net/netip" + + "github.com/ava-labs/avalanchego/ids" +) + +type PeerConfig struct { + ID string `mapstructure:"id" json:"id"` + IP string `mapstructure:"ip" json:"ip"` + + id ids.NodeID + ip netip.AddrPort +} + +func (c *PeerConfig) Validate() error { + var ( + id ids.NodeID + ip netip.AddrPort + err error + ) + if id, err = ids.NodeIDFromString(c.ID); err != nil { + return err + } + if ip, err = netip.ParseAddrPort(c.IP); err != nil { + return err + } + c.id = id + c.ip = ip + + return nil +} + +func (c *PeerConfig) GetID() ids.NodeID { + return c.id +} + +func (c *PeerConfig) GetIP() netip.AddrPort { + return c.ip +} diff --git a/go.mod b/go.mod index 9f920e45..34fadf82 100644 --- a/go.mod +++ b/go.mod @@ -2,6 +2,11 @@ module github.com/ava-labs/awm-relayer go 1.22.8 +replace ( + github.com/ava-labs/avalanchego => /Users/cameron.schultz/avalanchego + github.com/ava-labs/teleporter => /Users/cameron.schultz/teleporter +) + require ( github.com/ava-labs/avalanchego v1.12.0-initial-poc.8 github.com/ava-labs/coreth v0.13.8 diff --git a/go.sum b/go.sum index 5dbd67e7..09b5e03c 100644 --- a/go.sum +++ b/go.sum @@ -60,14 +60,10 @@ github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156/go.mod h1:Cb/ax github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio= github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs= -github.com/ava-labs/avalanchego v1.12.0-initial-poc.8 h1:UuCN1CYPZgf2FGGaO4XURVPWHjbv2U++VkarrADeT64= -github.com/ava-labs/avalanchego v1.12.0-initial-poc.8/go.mod h1:86tO6F1FT8emclUwdQ2WCwAtAerqjm5A4IbV6XxNUyM= github.com/ava-labs/coreth v0.13.8 h1:f14X3KgwHl9LwzfxlN6S4bbn5VA2rhEsNnHaRLSTo/8= github.com/ava-labs/coreth v0.13.8/go.mod h1:t3BSv/eQv0AlDPMfEDCMMoD/jq1RkUsbFzQAFg5qBcE= github.com/ava-labs/subnet-evm v0.6.11 h1:XgIAn9ihPyGjrBFD2rXg2H76HFl6htliHabN0fjciaQ= github.com/ava-labs/subnet-evm v0.6.11/go.mod h1:fP46lzBtiniRfpNH+Qu9BFvSsa02YGkAobxinZ78gDU= -github.com/ava-labs/teleporter v1.0.8-0.20241113215352-fdd3e578a507 h1:Ki3ueqLWblscPkGtVPFapKemyJ5xHidgeXZ1ISQGHug= -github.com/ava-labs/teleporter v1.0.8-0.20241113215352-fdd3e578a507/go.mod h1:UOcmJTB6+mNCn50V7Fit9MB6dVL8obOHu3i5dP6is34= github.com/aws/aws-sdk-go-v2 v1.32.4 h1:S13INUiTxgrPueTmrm5DZ+MiAo99zYzHEFh1UNkOxNE= github.com/aws/aws-sdk-go-v2 v1.32.4/go.mod h1:2SK5n0a2karNTv5tbP1SjsX0uhttou00v/HpXKM1ZUo= github.com/aws/aws-sdk-go-v2/config v1.27.9 h1:gRx/NwpNEFSk+yQlgmk1bmxxvQ5TyJ76CWXs9XScTqg= diff --git a/peers/app_request_network.go b/peers/app_request_network.go index 3abe8cc7..774fdb20 100644 --- a/peers/app_request_network.go +++ b/peers/app_request_network.go @@ -147,10 +147,27 @@ func NewNetwork( messageCreator: messageCreator, manuallyTrackedPeers: manuallyTrackedPeers, } + + for _, peer := range manuallyTrackedPeers { + logger.Info("Manually Tracking peer (startup)", zap.String("ID", peer.ID.String()), zap.String("IP", peer.PublicIP.String())) + arNetwork.network.ManuallyTrack(peer.ID, peer.PublicIP) + } + go logger.RecoverAndPanic(func() { testNetwork.Dispatch() }) + go func() { + for { + connectedPeers := arNetwork.network.PeerInfo(nil) + arNetwork.logger.Info("Startup Connected peers", zap.Int("count", len(connectedPeers))) + for _, peer := range connectedPeers { + arNetwork.logger.Info("Connected peer", zap.String("ID", peer.ID.String())) + } + time.Sleep(2 * time.Second) + } + }() + return arNetwork, nil } @@ -166,10 +183,14 @@ func (n *appRequestNetwork) ConnectPeers(nodeIDs set.Set[ids.NodeID]) set.Set[id // Iterate through and manually connect to // First, check if we are already connected to all the peers - connectedPeers := n.network.PeerInfo(nodeIDs.List()) - if len(connectedPeers) == nodeIDs.Len() { - return nodeIDs + connectedPeers := n.network.PeerInfo(nil) + n.logger.Info("Connected peers", zap.Int("count", len(connectedPeers))) + for _, peer := range connectedPeers { + n.logger.Info("Connected peer", zap.String("ID", peer.ID.String())) } + // if len(connectedPeers) == nodeIDs.Len() { + // return nodeIDs + // } // If we are not connected to all the peers already, then we have to iterate // through the full list of peers obtained from the info API. Rather than iterating @@ -187,22 +208,44 @@ func (n *appRequestNetwork) ConnectPeers(nodeIDs set.Set[ids.NodeID]) set.Set[id ) return nil } + n.logger.Info("Fetched peers from info API") + for _, peer := range peers { + n.logger.Info("Peer", zap.String("ID", peer.ID.String())) + } // Add manually tracked peers - peers = append(peers, n.manuallyTrackedPeers...) + for _, peer := range n.manuallyTrackedPeers { + n.logger.Info("Manually Tracking peer", zap.String("ID", peer.ID.String()), zap.String("IP", peer.PublicIP.String())) + n.network.ManuallyTrack(peer.ID, peer.PublicIP) + } // Attempt to connect to each peer var trackedNodes set.Set[ids.NodeID] for _, peer := range peers { if nodeIDs.Contains(peer.ID) { trackedNodes.Add(peer.ID) + n.logger.Info("Tracking peer", zap.String("ID", peer.ID.String()), zap.String("IP", peer.PublicIP.String())) n.network.ManuallyTrack(peer.ID, peer.PublicIP) + // TODONOW: length checks are not correct if len(trackedNodes) == nodeIDs.Len() { + // DEBUG + connectedPeers = n.network.PeerInfo(nil) + n.logger.Info("Connected peers", zap.Int("count", len(connectedPeers))) + for _, peer := range connectedPeers { + n.logger.Info("Connected peer", zap.String("ID", peer.ID.String())) + } return trackedNodes } } } + // DEBUG + connectedPeers = n.network.PeerInfo(nil) + n.logger.Info("Connected peers", zap.Int("count", len(connectedPeers))) + for _, peer := range connectedPeers { + n.logger.Info("Connected peer", zap.String("ID", peer.ID.String())) + } + // If the Info API node is in nodeIDs, it will not be reflected in the call to info.Peers. // In this case, we need to manually track the API node. startInfoAPICall = time.Now() diff --git a/peers/external_handler.go b/peers/external_handler.go index 0f82bf9e..2c0c686e 100644 --- a/peers/external_handler.go +++ b/peers/external_handler.go @@ -101,7 +101,7 @@ func (h *RelayerExternalHandler) HandleInbound(_ context.Context, inboundMessage } func (h *RelayerExternalHandler) Connected(nodeID ids.NodeID, version *version.Application, subnetID ids.ID) { - h.log.Debug( + h.log.Info( "Connected", zap.Stringer("nodeID", nodeID), zap.Stringer("version", version), diff --git a/relayer/config/config.go b/relayer/config/config.go index db70f399..43457077 100644 --- a/relayer/config/config.go +++ b/relayer/config/config.go @@ -67,7 +67,7 @@ type Config struct { ProcessMissedBlocks bool `mapstructure:"process-missed-blocks" json:"process-missed-blocks"` DeciderURL string `mapstructure:"decider-url" json:"decider-url"` SignatureCacheSize uint64 `mapstructure:"signature-cache-size" json:"signature-cache-size"` - ManuallyTrackedPeers []basecfg.PeerConfig `mapstructure:"manually-tracked-peers" json:"manually-tracked-peers"` + ManuallyTrackedPeers []*basecfg.PeerConfig `mapstructure:"manually-tracked-peers" json:"manually-tracked-peers"` // mapstructure doesn't handle time.Time out of the box so handle it manually EtnaTime time.Time `json:"etna-time"` diff --git a/relayer/main/main.go b/relayer/main/main.go index 87b1fe78..58af24a9 100644 --- a/relayer/main/main.go +++ b/relayer/main/main.go @@ -135,10 +135,10 @@ func main() { // The app request network generates P2P networking logs that are verbose at the info level. // Unless the log level is debug or lower, set the network log level to error to avoid spamming the logs. // We do not collect metrics for the network. - networkLogLevel := logging.Error - if logLevel <= logging.Debug { - networkLogLevel = logLevel - } + // networkLogLevel := logging.Error + // if logLevel <= logging.Debug { + // networkLogLevel = logLevel + // } var trackedSubnets set.Set[ids.ID] // trackedSubnets is no longer strictly required but keeping it here for now // to keep full parity with existing AWM relayer for now @@ -168,18 +168,18 @@ func main() { for _, p := range cfg.ManuallyTrackedPeers { manuallyTrackedPeers = append(manuallyTrackedPeers, info.Peer{ Info: peer.Info{ - PublicIP: p.IP, - ID: p.ID, + PublicIP: p.GetIP(), + ID: p.GetID(), }, }) } network, err := peers.NewNetwork( - networkLogLevel, + logging.Verbo, registerer, trackedSubnets, messageCreator, - nil, + manuallyTrackedPeers, &cfg, ) if err != nil { diff --git a/scripts/e2e_test.sh b/scripts/e2e_test.sh index 028d2547..3949371f 100755 --- a/scripts/e2e_test.sh +++ b/scripts/e2e_test.sh @@ -33,24 +33,24 @@ if [ "$HELP" = true ]; then exit 0 fi -if [ "$LOCAL" = true ]; then - if [ -z "$DATA_DIRECTORY" ]; then - echo "Must specify data directory when running local" - exit 1 - fi - if [ -z "$SUBNET_EVM_PATH" ]; then - echo "Must specify subnet-evm path when running local" - exit 1 - fi - cwd=$PWD - cd $SUBNET_EVM_PATH - BASEDIR=$DATA_DIRECTORY AVALANCHEGO_BUILD_PATH=$DATA_DIRECTORY/avalanchego ./scripts/install_avalanchego_release.sh - ./scripts/build.sh $DATA_DIRECTORY/avalanchego/plugins/srEXiWaHuhNyGwPUi444Tu47ZEDwxTWrbQiuD7FmgSAQ6X7Dy +# if [ "$LOCAL" = true ]; then +# if [ -z "$DATA_DIRECTORY" ]; then +# echo "Must specify data directory when running local" +# exit 1 +# fi +# if [ -z "$SUBNET_EVM_PATH" ]; then +# echo "Must specify subnet-evm path when running local" +# exit 1 +# fi +# cwd=$PWD +# cd $SUBNET_EVM_PATH +# BASEDIR=$DATA_DIRECTORY AVALANCHEGO_BUILD_PATH=$DATA_DIRECTORY/avalanchego ./scripts/install_avalanchego_release.sh +# ./scripts/build.sh $DATA_DIRECTORY/avalanchego/plugins/srEXiWaHuhNyGwPUi444Tu47ZEDwxTWrbQiuD7FmgSAQ6X7Dy - cd $cwd - export AVALANCHEGO_BUILD_PATH=$DATA_DIRECTORY/avalanchego - export DATA_DIR=$DATA_DIRECTORY/data -fi +# cd $cwd +# export AVALANCHEGO_BUILD_PATH=$DATA_DIRECTORY/avalanchego +# export DATA_DIR=$DATA_DIRECTORY/data +# fi BASE_PATH=$( cd "$(dirname "${BASH_SOURCE[0]}")" @@ -58,9 +58,22 @@ BASE_PATH=$( ) source "$BASE_PATH"/scripts/constants.sh - source "$BASE_PATH"/scripts/versions.sh +BASEDIR=${BASEDIR:-"$HOME/.teleporter-deps"} + +cwd=$(pwd) +# Install the avalanchego and subnet-evm binaries +rm -rf $BASEDIR/avalanchego +BASEDIR=$BASEDIR AVALANCHEGO_BUILD_PATH=$BASEDIR/avalanchego "${TELEPORTER_PATH}/scripts/install_avalanchego_release.sh" +BASEDIR=$BASEDIR "${TELEPORTER_PATH}/scripts/install_subnetevm_release.sh" + +cp ${BASEDIR}/subnet-evm/subnet-evm ${BASEDIR}/avalanchego/plugins/srEXiWaHuhNyGwPUi444Tu47ZEDwxTWrbQiuD7FmgSAQ6X7Dy +echo "Copied ${BASEDIR}/subnet-evm/subnet-evm binary to ${BASEDIR}/avalanchego/plugins/" + +export AVALANCHEGO_BUILD_PATH=$BASEDIR/avalanchego +cp /Users/cameron.schultz/avalanchego/build/avalanchego $AVALANCHEGO_BUILD_PATH/avalanchego + # Build ginkgo # to install the ginkgo binary (required for test build and run) go install -v github.com/onsi/ginkgo/v2/ginkgo@${GINKGO_VERSION} diff --git a/tests/basic_relay.go b/tests/basic_relay.go index 0aa2957a..71450692 100644 --- a/tests/basic_relay.go +++ b/tests/basic_relay.go @@ -6,10 +6,9 @@ package tests import ( "context" "fmt" - "net/netip" + "net/url" "os" "time" - "url" "github.com/ava-labs/avalanchego/utils/logging" "github.com/ava-labs/awm-relayer/config" @@ -29,8 +28,16 @@ import ( // - Relaying an already delivered message // - Setting ProcessHistoricalBlocksFromHeight in config func BasicRelay(network *network.LocalNetwork, teleporter utils.TeleporterTestInfo) { + // Restart the network to attempt to refresh TLS connections + { + ctx, cancel := context.WithTimeout(context.Background(), time.Duration(60*len(network.Network.Nodes))*time.Second) + defer cancel() + err := network.Network.Restart(ctx, os.Stdout) + Expect(err).Should(BeNil()) + } + subnetAInfo := network.GetPrimaryNetworkInfo() - subnetBInfo, _ := network.GetTwoSubnets() + subnetAInfo, subnetBInfo := network.GetTwoSubnets() fundedAddress, fundedKey := network.GetFundedAccountInfo() err := testUtils.ClearRelayerStorage() Expect(err).Should(BeNil()) @@ -57,18 +64,19 @@ func BasicRelay(network *network.LocalNetwork, teleporter utils.TeleporterTestIn ) // Add primary network validators as manually tracked peers - var manuallyTrackedPeers []config.PeerConfig + var manuallyTrackedPeers []*config.PeerConfig primaryNetworkValidators := network.GetPrimaryNetworkValidators() - for _, validator := range primaryNetworkValidators { + for _, validator := range primaryNetworkValidators[0:1] { parsed, err := url.Parse(validator.URI) Expect(err).Should(BeNil()) - ip, err := netip.ParseAddrPort(parsed.Host) - Expect(err).Should(BeNil()) - manuallyTrackedPeers = append(manuallyTrackedPeers, config.PeerConfig{ - IP: ip, - ID: validator.NodeID, + // ip, err := netip.ParseAddrPort(parsed.Host) + // Expect(err).Should(BeNil()) + manuallyTrackedPeers = append(manuallyTrackedPeers, &config.PeerConfig{ + IP: parsed.Host, + ID: validator.NodeID.String(), }) } + relayerConfig.ManuallyTrackedPeers = manuallyTrackedPeers // The config needs to be validated in order to be passed to database.GetConfigRelayerIDs relayerConfig.Validate() @@ -89,7 +97,7 @@ func BasicRelay(network *network.LocalNetwork, teleporter utils.TeleporterTestIn defer relayerCleanup() // Wait for relayer to start up - startupCtx, startupCancel := context.WithTimeout(ctx, 15*time.Second) + startupCtx, startupCancel := context.WithTimeout(ctx, 30*time.Second) defer startupCancel() testUtils.WaitForChannelClose(startupCtx, readyChan) @@ -103,6 +111,34 @@ func BasicRelay(network *network.LocalNetwork, teleporter utils.TeleporterTestIn fundedAddress, ) + time.Sleep(10 * time.Second) + + // + // Test Relaying from Subnet B to Subnet A + // + fmt.Println("Test Relaying from Subnet B to Subnet A") + testUtils.RelayBasicMessage( + ctx, + teleporter, + subnetBInfo, + subnetAInfo, + fundedKey, + fundedAddress, + ) + + time.Sleep(10 * time.Second) + fmt.Println("Sending transaction from Subnet A to Subnet B") + testUtils.RelayBasicMessage( + ctx, + teleporter, + subnetAInfo, + subnetBInfo, + fundedKey, + fundedAddress, + ) + + time.Sleep(10 * time.Second) + // // Test Relaying from Subnet B to Subnet A // @@ -175,7 +211,7 @@ func BasicRelay(network *network.LocalNetwork, teleporter utils.TeleporterTestIn // Wait for relayer to start up fmt.Println("Waiting for the relayer to start up") - startupCtx, startupCancel = context.WithTimeout(ctx, 15*time.Second) + startupCtx, startupCancel = context.WithTimeout(ctx, 30*time.Second) defer startupCancel() testUtils.WaitForChannelClose(startupCtx, readyChan) diff --git a/tests/e2e_test.go b/tests/e2e_test.go index 2012de5d..d408b5ee 100644 --- a/tests/e2e_test.go +++ b/tests/e2e_test.go @@ -15,6 +15,7 @@ import ( "testing" "time" + "github.com/ava-labs/avalanchego/utils/units" testUtils "github.com/ava-labs/awm-relayer/tests/utils" "github.com/ava-labs/awm-relayer/utils" "github.com/ava-labs/teleporter/tests/network" @@ -81,7 +82,7 @@ var _ = ginkgo.BeforeSuite(func() { utils.SanitizeHexString(teleporterDeployerTransactionStr), ) Expect(err).Should(BeNil()) - networkStartCtx, networkStartCancel := context.WithTimeout(ctx, 120*time.Second) + networkStartCtx, networkStartCancel := context.WithTimeout(ctx, 120*2*time.Second) defer networkStartCancel() localNetworkInstance = network.NewLocalNetwork( networkStartCtx, @@ -113,7 +114,7 @@ var _ = ginkgo.BeforeSuite(func() { // Only need to deploy Teleporter on the C-Chain since it is included in the genesis of the subnet chains. _, fundedKey := localNetworkInstance.GetFundedAccountInfo() teleporterInfo.DeployTeleporterMessenger( - ctx, + networkStartCtx, localNetworkInstance.GetPrimaryNetworkInfo(), teleporterDeployerTransaction, teleporterDeployerAddress, @@ -128,6 +129,17 @@ var _ = ginkgo.BeforeSuite(func() { teleporterInfo.DeployTeleporterRegistry(subnet, fundedKey) } + // Convert the subnets to sovereign L1s + for _, subnet := range localNetworkInstance.GetSubnetsInfo() { + localNetworkInstance.ConvertSubnet( + networkStartCtx, + subnet, + teleporterTestUtils.PoAValidatorManager, + []uint64{units.Schmeckle, units.Schmeckle}, + fundedKey, + false) + } + decider = exec.CommandContext(ctx, "./tests/cmd/decider/decider") decider.Start() go func() { @@ -163,31 +175,31 @@ func cleanup() { var _ = ginkgo.AfterSuite(cleanup) var _ = ginkgo.Describe("[AWM Relayer Integration Tests", func() { - ginkgo.It("Manually Provided Message", func() { - ManualMessage(localNetworkInstance, teleporterInfo) - }) + // ginkgo.It("Manually Provided Message", func() { + // ManualMessage(localNetworkInstance, teleporterInfo) + // }) ginkgo.It("Basic Relay", func() { BasicRelay(localNetworkInstance, teleporterInfo) }) - ginkgo.It("Shared Database", func() { - SharedDatabaseAccess(localNetworkInstance, teleporterInfo) - }) - ginkgo.It("Allowed Addresses", func() { - AllowedAddresses(localNetworkInstance, teleporterInfo) - }) - ginkgo.It("Batch Message", func() { - BatchRelay(localNetworkInstance, teleporterInfo) - }) - ginkgo.It("Relay Message API", func() { - RelayMessageAPI(localNetworkInstance, teleporterInfo) - }) - ginkgo.It("Warp API", func() { - WarpAPIRelay(localNetworkInstance, teleporterInfo) - }) - ginkgo.It("Signature Aggregator", func() { - SignatureAggregatorAPI(localNetworkInstance, teleporterInfo) - }) - ginkgo.It("Etna Upgrade", func() { - EtnaUpgrade(localNetworkInstance, teleporterInfo) - }) + // ginkgo.It("Shared Database", func() { + // SharedDatabaseAccess(localNetworkInstance, teleporterInfo) + // }) + // ginkgo.It("Allowed Addresses", func() { + // AllowedAddresses(localNetworkInstance, teleporterInfo) + // }) + // ginkgo.It("Batch Message", func() { + // BatchRelay(localNetworkInstance, teleporterInfo) + // }) + // ginkgo.It("Relay Message API", func() { + // RelayMessageAPI(localNetworkInstance, teleporterInfo) + // }) + // ginkgo.It("Warp API", func() { + // WarpAPIRelay(localNetworkInstance, teleporterInfo) + // }) + // ginkgo.It("Signature Aggregator", func() { + // SignatureAggregatorAPI(localNetworkInstance, teleporterInfo) + // }) + // ginkgo.It("Etna Upgrade", func() { + // EtnaUpgrade(localNetworkInstance, teleporterInfo) + // }) }) diff --git a/tests/utils/utils.go b/tests/utils/utils.go index e01f9395..2d8d90f7 100644 --- a/tests/utils/utils.go +++ b/tests/utils/utils.go @@ -414,7 +414,7 @@ func WriteRelayerConfig(relayerConfig relayercfg.Config, fname string) string { Expect(err).Should(BeNil()) relayerConfigPath := f.Name() - log.Info("Created awm-relayer config", "configPath", relayerConfigPath, "config", string(data)) + fmt.Println("Created awm-relayer config", "configPath", relayerConfigPath, "config", string(data)) return relayerConfigPath } @@ -548,7 +548,7 @@ func runExecutable( Expect(err).Should(BeNil()) // Start the command - log.Info("Starting executable", "appName", appName) + fmt.Println("Starting executable", "appName", appName) err = cmd.Start() Expect(err).Should(BeNil()) @@ -558,14 +558,14 @@ func runExecutable( go func() { scanner := bufio.NewScanner(cmdStdOutReader) for scanner.Scan() { - log.Info(scanner.Text()) + fmt.Println(scanner.Text()) } cmdOutput <- "Command execution finished" }() go func() { scanner := bufio.NewScanner(cmdStdErrReader) for scanner.Scan() { - log.Error(scanner.Text()) + fmt.Println(scanner.Text()) } cmdOutput <- "Command execution finished" }() @@ -574,7 +574,7 @@ func runExecutable( // Context cancellation is the only expected way for the process to exit, otherwise log an error // Don't panic to allow for easier cleanup if !errors.Is(ctx.Err(), context.Canceled) { - log.Error("Executable exited abnormally", "appName", appName, "err", err) + fmt.Println("Executable exited abnormally", "appName", appName, "err", err) } }() go func() { // wait for health check to report healthy diff --git a/tests/utils/warp-genesis-template.json b/tests/utils/warp-genesis-template.json index 44dd8b5d..4cf2d62e 100644 --- a/tests/utils/warp-genesis-template.json +++ b/tests/utils/warp-genesis-template.json @@ -1,5 +1,5 @@ { - "config": { + "config": { "chainId": , "homesteadBlock": 0, "eip150Block": 0, @@ -12,52 +12,80 @@ "istanbulBlock": 0, "muirGlacierBlock": 0, "feeConfig": { - "gasLimit": 20000000, - "minBaseFee": 1000000000, - "targetGas": 100000000, - "baseFeeChangeDenominator": 48, - "minBlockGasCost": 0, - "maxBlockGasCost": 10000000, - "targetBlockRate": 2, - "blockGasCostStep": 500000 + "gasLimit": 20000000, + "minBaseFee": 1000000000, + "targetGas": 100000000, + "baseFeeChangeDenominator": 48, + "minBlockGasCost": 0, + "maxBlockGasCost": 10000000, + "targetBlockRate": 2, + "blockGasCostStep": 500000 }, "warpConfig": { - "blockTimestamp": 1719343601 + "blockTimestamp": 1719343601 }, "contractNativeMinterConfig": { - "blockTimestamp": 0, - "adminAddresses": [ - "0xAcB633F5B00099c7ec187eB00156c5cd9D854b5B", - "0x3405506b3711859c5070949ed9b700c7ba7bf750" - ] + "blockTimestamp": 0, + "adminAddresses": [ + "0xAcB633F5B00099c7ec187eB00156c5cd9D854b5B", + "0x3405506b3711859c5070949ed9b700c7ba7bf750", + "0x962c62B01529ecc0561D85d3fe395921ddC3665B", + "0x1549B96D9D97F435CA9b25000FEDE3A7e54C0bb9", + "0x190110D1228EB2cDd36559b2215A572Dc8592C3d", + "0xf9EF017A764F265A1fD0975bfc200725E41d860E", + "0x4f3663be6d22B0F19F8617f1A9E9485aB0144Bff", + "0x463a6bE7a5098A5f06435c6c468adD338F15B93A", + "0x8db97C7cEcE249c2b98bDC0226Cc4C2A57BF52FC" + ] } - }, - "alloc": { - "0x8db97C7cEcE249c2b98bDC0226Cc4C2A57BF52FC": { - "balance": "0x52B7D2DCC80CD2E4000000" - }, + }, + "alloc": { "": { - "balance": "0x0", - "code": "", - "storage": { - "0x0000000000000000000000000000000000000000000000000000000000000000": "0x0000000000000000000000000000000000000000000000000000000000000001", - "0x0000000000000000000000000000000000000000000000000000000000000001": "0x0000000000000000000000000000000000000000000000000000000000000001" - }, - "nonce": 1 + "balance": "0x0", + "code": "", + "storage": { + "0x0000000000000000000000000000000000000000000000000000000000000000": "0x0000000000000000000000000000000000000000000000000000000000000001", + "0x0000000000000000000000000000000000000000000000000000000000000001": "0x0000000000000000000000000000000000000000000000000000000000000001" + }, + "nonce": 1 }, "": { - "balance": "0x0", - "nonce": 1 + "balance": "0x0", + "nonce": 1 + }, + "0x8db97C7cEcE249c2b98bDC0226Cc4C2A57BF52FC": { + "balance": "0x52B7D2DCC80CD2E4000000" + }, + "0x1337cfd2dCff6270615B90938aCB1efE79801704": { + "balance": "0x52B7D2DCC80CD2E4000000" + }, + "0xFcec6c0674037f99fa473de09609B4b6D8158863": { + "balance": "0x52B7D2DCC80CD2E4000000" + }, + "0x2e1533d976A675bCD6306deC3B05e9f73e6722Fb": { + "balance": "0x52B7D2DCC80CD2E4000000" + }, + "0xA638b0a597dc0520e2f20E83cFbeBBCd45a79990": { + "balance": "0x52B7D2DCC80CD2E4000000" + }, + "0x787C079cB0d5A7AA1Cae95d991F76Dce771A432D": { + "balance": "0x52B7D2DCC80CD2E4000000" + }, + "0x741D536f5B07bcD43727CD8435389CA36aE5A4Ae": { + "balance": "0x52B7D2DCC80CD2E4000000" + }, + "0xd466f12795BA59d0fef389c21fA63c287956fb18": { + "balance": "0x52B7D2DCC80CD2E4000000" } - }, - "nonce": "0x0", - "timestamp": "0x667B19F0", - "extraData": "0x00", - "gasLimit": "0x1312D00", - "difficulty": "0x0", - "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000", - "coinbase": "0x0000000000000000000000000000000000000000", - "number": "0x0", - "gasUsed": "0x0", - "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000" -} + }, + "nonce": "0x0", + "timestamp": "0x667B19F0", + "extraData": "0x00", + "gasLimit": "0x1312D00", + "difficulty": "0x0", + "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000", + "coinbase": "0x0000000000000000000000000000000000000000", + "number": "0x0", + "gasUsed": "0x0", + "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000" + } From 3ca88fe7eba15efc25026e557b1895f3dbc429df Mon Sep 17 00:00:00 2001 From: cam-schultz Date: Thu, 21 Nov 2024 10:58:22 -0600 Subject: [PATCH 08/28] p2p tests passing --- database/json_file_storage.go | 2 + go.mod | 6 +- go.sum | 6 +- peers/app_request_network.go | 313 +++++++++++++----- .../validators/canonical_validator_client.go | 11 +- relayer/application_relayer.go | 6 + relayer/checkpoint/checkpoint.go | 9 + relayer/main/main.go | 24 +- relayer/message_coordinator.go | 3 +- signature-aggregator/aggregator/aggregator.go | 15 +- signature-aggregator/main/main.go | 3 + tests/basic_relay.go | 10 +- tests/contracts/lib/teleporter | 2 +- tests/e2e_test.go | 50 +-- tests/signature_aggregator_api.go | 119 ++++--- tests/utils/utils.go | 11 +- 16 files changed, 397 insertions(+), 193 deletions(-) diff --git a/database/json_file_storage.go b/database/json_file_storage.go index 95353546..6e83faf3 100644 --- a/database/json_file_storage.go +++ b/database/json_file_storage.go @@ -125,6 +125,7 @@ func (s *JSONFileStorage) getCurrentState(relayerID common.Hash) (chainState, bo // Put the value into the JSON database. Read the current chain state and overwrite the key, if it exists // If the file corresponding to {relayerID} does not exist, then it will be created func (s *JSONFileStorage) Put(relayerID common.Hash, dataKey DataKey, value []byte) error { + s.logger.Debug("putting value into database") mutex, ok := s.mutexes[relayerID] if !ok { return errors.Wrap( @@ -135,6 +136,7 @@ func (s *JSONFileStorage) Put(relayerID common.Hash, dataKey DataKey, value []by mutex.Lock() defer mutex.Unlock() + s.logger.Debug("acquired lock") // Update the in-memory state and write to disk s.currentState[relayerID][dataKey.String()] = string(value) diff --git a/go.mod b/go.mod index 34fadf82..a064c223 100644 --- a/go.mod +++ b/go.mod @@ -8,9 +8,9 @@ replace ( ) require ( - github.com/ava-labs/avalanchego v1.12.0-initial-poc.8 - github.com/ava-labs/coreth v0.13.8 - github.com/ava-labs/subnet-evm v0.6.11 + github.com/ava-labs/avalanchego v1.12.0-fuji + github.com/ava-labs/coreth v0.13.9-rc.1 + github.com/ava-labs/subnet-evm v0.6.12 github.com/ava-labs/teleporter v1.0.8-0.20241113215352-fdd3e578a507 github.com/aws/aws-sdk-go-v2 v1.32.4 github.com/aws/aws-sdk-go-v2/config v1.27.9 diff --git a/go.sum b/go.sum index 09b5e03c..bdfcbb87 100644 --- a/go.sum +++ b/go.sum @@ -60,10 +60,12 @@ github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156/go.mod h1:Cb/ax github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio= github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs= -github.com/ava-labs/coreth v0.13.8 h1:f14X3KgwHl9LwzfxlN6S4bbn5VA2rhEsNnHaRLSTo/8= -github.com/ava-labs/coreth v0.13.8/go.mod h1:t3BSv/eQv0AlDPMfEDCMMoD/jq1RkUsbFzQAFg5qBcE= +github.com/ava-labs/coreth v0.13.9-rc.1 h1:qIICpC/OZGYUP37QnLgIqqwGmxnLwLpZaUlqJNI85vU= +github.com/ava-labs/coreth v0.13.9-rc.1/go.mod h1:7aMsRIo/3GBE44qWZMjnfqdqfcfZ5yShTTm2LObLaYo= github.com/ava-labs/subnet-evm v0.6.11 h1:XgIAn9ihPyGjrBFD2rXg2H76HFl6htliHabN0fjciaQ= github.com/ava-labs/subnet-evm v0.6.11/go.mod h1:fP46lzBtiniRfpNH+Qu9BFvSsa02YGkAobxinZ78gDU= +github.com/ava-labs/subnet-evm v0.6.12 h1:jL3FmjdFcNfS0qwbehwN6DkAg9y7zexB1riiGBxRsM0= +github.com/ava-labs/subnet-evm v0.6.12/go.mod h1:vffwL4UqAh7ibpWjveUuUhamm3a9w75q92bG5vXdX5k= github.com/aws/aws-sdk-go-v2 v1.32.4 h1:S13INUiTxgrPueTmrm5DZ+MiAo99zYzHEFh1UNkOxNE= github.com/aws/aws-sdk-go-v2 v1.32.4/go.mod h1:2SK5n0a2karNTv5tbP1SjsX0uhttou00v/HpXKM1ZUo= github.com/aws/aws-sdk-go-v2/config v1.27.9 h1:gRx/NwpNEFSk+yQlgmk1bmxxvQ5TyJ76CWXs9XScTqg= diff --git a/peers/app_request_network.go b/peers/app_request_network.go index 774fdb20..9bc670b2 100644 --- a/peers/app_request_network.go +++ b/peers/app_request_network.go @@ -8,6 +8,7 @@ package peers import ( "context" "encoding/hex" + "fmt" "os" "sync" "time" @@ -18,9 +19,12 @@ import ( "github.com/ava-labs/avalanchego/network" avagoCommon "github.com/ava-labs/avalanchego/snow/engine/common" snowVdrs "github.com/ava-labs/avalanchego/snow/validators" + vdrs "github.com/ava-labs/avalanchego/snow/validators" "github.com/ava-labs/avalanchego/subnets" + "github.com/ava-labs/avalanchego/utils/constants" "github.com/ava-labs/avalanchego/utils/logging" "github.com/ava-labs/avalanchego/utils/set" + "github.com/ava-labs/avalanchego/vms/platformvm" "github.com/ava-labs/avalanchego/vms/platformvm/warp" "github.com/ava-labs/awm-relayer/peers/validators" "github.com/prometheus/client_golang/prometheus" @@ -56,6 +60,8 @@ type AppRequestNetwork interface { subnetID ids.ID, allower subnets.Allower, ) set.Set[ids.NodeID] + Shutdown() + TrackSubnet(subnetID ids.ID) } type appRequestNetwork struct { @@ -71,11 +77,14 @@ type appRequestNetwork struct { // Nodes that we should connect to that are not publicly discoverable. // Should only be used for local or custom blockchains where validators are not // publicly discoverable by primary network nodes. - manuallyTrackedPeers []info.Peer + manuallyTrackedPeers []info.Peer // TODONOW: we should be able to remove this from the struct + trackedSubnets set.Set[ids.ID] + manager vdrs.Manager } // NewNetwork creates a P2P network client for interacting with validators func NewNetwork( + tag string, logLevel logging.Level, registerer prometheus.Registerer, trackedSubnets set.Set[ids.ID], @@ -84,7 +93,7 @@ func NewNetwork( cfg Config, ) (AppRequestNetwork, error) { logger := logging.NewLogger( - "p2p-network", + fmt.Sprintf("p2p-network-%s", tag), logging.NewWrappedCore( logLevel, os.Stdout, @@ -125,7 +134,19 @@ func NewNetwork( return nil, err } - testNetwork, err := network.NewTestNetwork(logger, networkID, snowVdrs.NewManager(), trackedSubnets, handler) + // TODONOW: Get the list of current primary network validators + validatorClient := validators.NewCanonicalValidatorClient(logger, cfg.GetPChainAPI()) + manager := snowVdrs.NewManager() + // TODO: We can probably just do this in the below worker + if err := updatePrimaryNetworkValidators(context.Background(), logger, constants.PrimaryNetworkID, manager, validatorClient); err != nil { + logger.Error( + "Failed to set primary network validators on startup", + zap.Error(err), + ) + return nil, err + } + + testNetwork, err := network.NewTestNetwork(logger, networkID, manager, trackedSubnets, handler) if err != nil { logger.Error( "Failed to create test network", @@ -134,8 +155,7 @@ func NewNetwork( return nil, err } - validatorClient := validators.NewCanonicalValidatorClient(logger, cfg.GetPChainAPI()) - + // TODONOW: construct this when we return arNetwork := &appRequestNetwork{ network: testNetwork, handler: handler, @@ -146,6 +166,8 @@ func NewNetwork( metrics: metrics, messageCreator: messageCreator, manuallyTrackedPeers: manuallyTrackedPeers, + trackedSubnets: trackedSubnets, + manager: manager, } for _, peer := range manuallyTrackedPeers { @@ -153,29 +175,157 @@ func NewNetwork( arNetwork.network.ManuallyTrack(peer.ID, peer.PublicIP) } + // Connect to a sample of the primary network validators + // TODO: this seems to be returning subnet A validators as well (but NOT subnet B validators) + peers, err := infoAPI.Peers(context.Background(), nil) + if err != nil { + logger.Error( + "Failed to get peers", + zap.Error(err), + ) + return nil, err + } + pClient := platformvm.NewClient(cfg.GetPChainAPI().BaseURL) + for _, peer := range peers { + vdrs, err := pClient.GetCurrentValidators(context.Background(), ids.Empty, []ids.NodeID{peer.ID}) + if err != nil { + panic(err) + } + if len(vdrs) == 0 { + continue + } + logger.Info("Manually tracking bootstrap node", zap.String("ID", peer.ID.String()), zap.String("IP", peer.PublicIP.String())) + arNetwork.network.ManuallyTrack(peer.ID, peer.PublicIP) + } + // s := sampler.NewUniform() + // s.Initialize(uint64(len(peers))) + // indices, _ := s.Sample(min(len(peers), 5)) + // for _, i := range indices { + // logger.Info("Manually tracking bootstrap node", zap.String("ID", peers[i].ID.String()), zap.String("IP", peers[i].PublicIP.String())) + // arNetwork.network.ManuallyTrack(peers[i].ID, peers[i].PublicIP) + // } + + // TODO: Is this necessary? + // Register outselves as a validator (from our view) so that we request all peers + // manager.AddStaker(constants.PrimaryNetworkID, arNetwork..) + go logger.RecoverAndPanic(func() { testNetwork.Dispatch() }) + // Periodically update the primary network validator set + // TODO: This needs to update the subent validator set as well + // go func() { + // for range time.Tick(5 * time.Second) { + // updatePrimaryNetworkValidators(context.Background(), constants.PrimaryNetworkID, manager, validatorClient) + // for _, subnet := range trackedSubnets.List() { + // updatePrimaryNetworkValidators(context.Background(), subnet, manager, validatorClient) + // } + + // // DBG + // connectedPeers := arNetwork.network.PeerInfo(nil) + // arNetwork.logger.Info("Startup Connected peers", zap.Int("count", len(connectedPeers))) + // for _, peer := range connectedPeers { + // arNetwork.logger.Info("Connected peer", zap.String("ID", peer.ID.String())) + // } + // } + // }() + arNetwork.startUpdateValidators() + + return arNetwork, nil +} + +func (n *appRequestNetwork) TrackSubnet(subnetID ids.ID) { + n.logger.Debug("acquiring lock 2") + n.lock.Lock() + defer n.lock.Unlock() + n.logger.Debug("acquired lock 2") + n.logger.Debug("Tracking subnet", zap.String("subnetID", subnetID.String())) + n.trackedSubnets.Add(subnetID) +} + +func (n *appRequestNetwork) startUpdateValidators() { go func() { - for { - connectedPeers := arNetwork.network.PeerInfo(nil) - arNetwork.logger.Info("Startup Connected peers", zap.Int("count", len(connectedPeers))) + for range time.Tick(5 * time.Second) { + n.logger.Debug("acquiring lock 3") + n.lock.Lock() + n.logger.Debug("acquired lock 3") + + updatePrimaryNetworkValidators(context.Background(), n.logger, constants.PrimaryNetworkID, n.manager, n.validatorClient) + for _, subnet := range n.trackedSubnets.List() { + updatePrimaryNetworkValidators(context.Background(), n.logger, subnet, n.manager, n.validatorClient) + } + n.lock.Unlock() + + // DBG + connectedPeers := n.network.PeerInfo(nil) + n.logger.Info("Startup Connected peers", zap.Int("count", len(connectedPeers))) for _, peer := range connectedPeers { - arNetwork.logger.Info("Connected peer", zap.String("ID", peer.ID.String())) + n.logger.Info("Connected peer", zap.String("ID", peer.ID.String()), zap.Any("trackedSubnets", n.trackedSubnets)) } - time.Sleep(2 * time.Second) } }() +} - return arNetwork, nil +func updatePrimaryNetworkValidators(ctx context.Context, logger logging.Logger, subnetID ids.ID, manager vdrs.Manager, client *validators.CanonicalValidatorClient) error { + logger.Debug("Fetching validators for subnet ID", zap.Stringer("subnetID", subnetID)) + + // Fetch the primary network validators from the P-Chain + height, err := client.GetCurrentHeight(ctx) + if err != nil { + return err + } + validators, err := client.GetValidatorSet(ctx, height, subnetID) + if err != nil { + return err + } + + validatorsMap := make(map[ids.NodeID]*vdrs.GetValidatorOutput) + for _, vdr := range validators { + validatorsMap[vdr.NodeID] = vdr + } + + // Remove any elements from the manager that are not in the new validator set + currentVdrs := manager.GetValidatorIDs(subnetID) + for _, nodeID := range currentVdrs { + if _, ok := validatorsMap[nodeID]; !ok { + logger.Debug("Removing validator", zap.Stringer("nodeID", nodeID), zap.Stringer("subnetID", subnetID)) + weight := manager.GetWeight(subnetID, nodeID) + if err := manager.RemoveWeight(subnetID, nodeID, weight); err != nil { + return err + } + } + } + + // Add any elements from the new validator set that are not in the manager + for _, vdr := range validators { + if _, ok := manager.GetValidator(subnetID, vdr.NodeID); !ok { + logger.Debug("Adding validator", zap.Stringer("nodeID", vdr.NodeID), zap.Stringer("subnetID", subnetID)) + if err := manager.AddStaker( + subnetID, + vdr.NodeID, + vdr.PublicKey, + ids.Empty, + vdr.Weight, + ); err != nil { + return err + } + } + } + return nil +} + +func (n *appRequestNetwork) Shutdown() { + n.network.StartClose() } // ConnectPeers connects the network to peers with the given nodeIDs. // Returns the set of nodeIDs that were successfully connected to. func (n *appRequestNetwork) ConnectPeers(nodeIDs set.Set[ids.NodeID]) set.Set[ids.NodeID] { + n.logger.Debug("acquiring lock 1") n.lock.Lock() defer n.lock.Unlock() + n.logger.Debug("acquired lock 1") // TODONOW: // Get primary network validators @@ -197,81 +347,82 @@ func (n *appRequestNetwork) ConnectPeers(nodeIDs set.Set[ids.NodeID]) set.Set[id // through connectedPeers for already tracked peers, just iterate through the full list, // re-adding connections to already tracked peers. - startInfoAPICall := time.Now() - // Get the list of publicly discoverable peers - peers, err := n.infoAPI.Peers(context.Background(), nil) - n.setInfoAPICallLatencyMS(float64(time.Since(startInfoAPICall).Milliseconds())) - if err != nil { - n.logger.Error( - "Failed to get peers", - zap.Error(err), - ) - return nil - } - n.logger.Info("Fetched peers from info API") - for _, peer := range peers { - n.logger.Info("Peer", zap.String("ID", peer.ID.String())) - } + // startInfoAPICall := time.Now() + // // Get the list of publicly discoverable peers + // peers, err := n.infoAPI.Peers(context.Background(), nil) + // n.setInfoAPICallLatencyMS(float64(time.Since(startInfoAPICall).Milliseconds())) + // if err != nil { + // n.logger.Error( + // "Failed to get peers", + // zap.Error(err), + // ) + // return nil + // } + // n.logger.Info("Fetched peers from info API") + // for _, peer := range peers { + // n.logger.Info("Peer", zap.String("ID", peer.ID.String())) + // } - // Add manually tracked peers - for _, peer := range n.manuallyTrackedPeers { - n.logger.Info("Manually Tracking peer", zap.String("ID", peer.ID.String()), zap.String("IP", peer.PublicIP.String())) - n.network.ManuallyTrack(peer.ID, peer.PublicIP) - } + // // Add manually tracked peers + // for _, peer := range n.manuallyTrackedPeers { + // n.logger.Info("Manually Tracking peer", zap.String("ID", peer.ID.String()), zap.String("IP", peer.PublicIP.String())) + // n.network.ManuallyTrack(peer.ID, peer.PublicIP) + // } - // Attempt to connect to each peer - var trackedNodes set.Set[ids.NodeID] - for _, peer := range peers { - if nodeIDs.Contains(peer.ID) { - trackedNodes.Add(peer.ID) - n.logger.Info("Tracking peer", zap.String("ID", peer.ID.String()), zap.String("IP", peer.PublicIP.String())) - n.network.ManuallyTrack(peer.ID, peer.PublicIP) - // TODONOW: length checks are not correct - if len(trackedNodes) == nodeIDs.Len() { - // DEBUG - connectedPeers = n.network.PeerInfo(nil) - n.logger.Info("Connected peers", zap.Int("count", len(connectedPeers))) - for _, peer := range connectedPeers { - n.logger.Info("Connected peer", zap.String("ID", peer.ID.String())) - } - return trackedNodes - } - } - } + // // Attempt to connect to each peer + // var trackedNodes set.Set[ids.NodeID] + // for _, peer := range peers { + // if nodeIDs.Contains(peer.ID) { + // trackedNodes.Add(peer.ID) + // n.logger.Info("Tracking peer", zap.String("ID", peer.ID.String()), zap.String("IP", peer.PublicIP.String())) + // n.network.ManuallyTrack(peer.ID, peer.PublicIP) + // // TODONOW: length checks are not correct + // if len(trackedNodes) == nodeIDs.Len() { + // // DEBUG + // connectedPeers = n.network.PeerInfo(nil) + // n.logger.Info("Connected peers", zap.Int("count", len(connectedPeers))) + // for _, peer := range connectedPeers { + // n.logger.Info("Connected peer", zap.String("ID", peer.ID.String())) + // } + // return trackedNodes + // } + // } + // } // DEBUG - connectedPeers = n.network.PeerInfo(nil) - n.logger.Info("Connected peers", zap.Int("count", len(connectedPeers))) - for _, peer := range connectedPeers { - n.logger.Info("Connected peer", zap.String("ID", peer.ID.String())) - } + // connectedPeers = n.network.PeerInfo(nil) + // n.logger.Info("Connected peers", zap.Int("count", len(connectedPeers))) + // for _, peer := range connectedPeers { + // n.logger.Info("Connected peer", zap.String("ID", peer.ID.String())) + // } - // If the Info API node is in nodeIDs, it will not be reflected in the call to info.Peers. - // In this case, we need to manually track the API node. - startInfoAPICall = time.Now() - apiNodeID, _, err := n.infoAPI.GetNodeID(context.Background()) - n.setInfoAPICallLatencyMS(float64(time.Since(startInfoAPICall).Milliseconds())) - if err != nil { - n.logger.Error( - "Failed to get API Node ID", - zap.Error(err), - ) - } else if nodeIDs.Contains(apiNodeID) { - startInfoAPICall = time.Now() - apiNodeIPPort, err := n.infoAPI.GetNodeIP(context.Background()) - n.setInfoAPICallLatencyMS(float64(time.Since(startInfoAPICall).Milliseconds())) - if err != nil { - n.logger.Error( - "Failed to get API Node IP", - zap.Error(err), - ) - } else { - trackedNodes.Add(apiNodeID) - n.network.ManuallyTrack(apiNodeID, apiNodeIPPort) - } - } + // // If the Info API node is in nodeIDs, it will not be reflected in the call to info.Peers. + // // In this case, we need to manually track the API node. + // startInfoAPICall = time.Now() + // apiNodeID, _, err := n.infoAPI.GetNodeID(context.Background()) + // n.setInfoAPICallLatencyMS(float64(time.Since(startInfoAPICall).Milliseconds())) + // if err != nil { + // n.logger.Error( + // "Failed to get API Node ID", + // zap.Error(err), + // ) + // } else if nodeIDs.Contains(apiNodeID) { + // startInfoAPICall = time.Now() + // apiNodeIPPort, err := n.infoAPI.GetNodeIP(context.Background()) + // n.setInfoAPICallLatencyMS(float64(time.Since(startInfoAPICall).Milliseconds())) + // if err != nil { + // n.logger.Error( + // "Failed to get API Node IP", + // zap.Error(err), + // ) + // } else { + // trackedNodes.Add(apiNodeID) + // n.network.ManuallyTrack(apiNodeID, apiNodeIPPort) + // } + // } - return trackedNodes + // return trackedNodes + return nodeIDs } // Helper struct to hold connected validator information @@ -315,7 +466,9 @@ func (n *appRequestNetwork) ConnectToCanonicalValidators(subnetID ids.ID) (*Conn // Manually connect to all peers in the validator set // If new peers are connected, AppRequests may fail while the handshake is in progress. // In that case, AppRequests to those nodes will be retried in the next iteration of the retry loop. + n.logger.Debug("connecting to peers") connectedNodes := n.ConnectPeers(nodeIDs) + n.logger.Debug("connected to peers") // Calculate the total weight of connected validators. connectedWeight := calculateConnectedWeight(validatorSet, nodeValidatorIndexMap, connectedNodes) diff --git a/peers/validators/canonical_validator_client.go b/peers/validators/canonical_validator_client.go index 4d51e1c3..996e3523 100644 --- a/peers/validators/canonical_validator_client.go +++ b/peers/validators/canonical_validator_client.go @@ -15,6 +15,8 @@ import ( "github.com/ava-labs/awm-relayer/config" "github.com/ava-labs/awm-relayer/peers/utils" "go.uber.org/zap" + + pchainapi "github.com/ava-labs/avalanchego/vms/platformvm/api" ) var _ validators.State = &CanonicalValidatorClient{} @@ -89,7 +91,7 @@ func (v *CanonicalValidatorClient) GetValidatorSet( ) (map[ids.NodeID]*validators.GetValidatorOutput, error) { // First, attempt to use the "getValidatorsAt" RPC method. This method may not be available on // all API nodes, in which case we can fall back to using "getCurrentValidators" if needed. - res, err := v.client.GetValidatorsAt(ctx, subnetID, height, v.options...) + res, err := v.client.GetValidatorsAt(ctx, subnetID, pchainapi.Height(height), v.options...) if err != nil { v.logger.Debug( "P-chain RPC to getValidatorAt returned error. Falling back to getCurrentValidators", @@ -101,6 +103,13 @@ func (v *CanonicalValidatorClient) GetValidatorSet( return res, nil } +func (v *CanonicalValidatorClient) GetCurrentValidatorSet( + _ context.Context, + _ ids.ID, +) (map[ids.ID]*validators.GetCurrentValidatorOutput, uint64, error) { + return nil, 0, nil +} + // Gets the current validator set of the given subnet ID, including the validators' BLS public // keys. The implementation currently makes two RPC requests, one to get the subnet validators, // and another to get their BLS public keys. This is necessary in order to enable the use of diff --git a/relayer/application_relayer.go b/relayer/application_relayer.go index c1c93910..a9ba1d43 100644 --- a/relayer/application_relayer.go +++ b/relayer/application_relayer.go @@ -146,6 +146,7 @@ func (r *ApplicationRelayer) ProcessHeight( handlers []messages.MessageHandler, errChan chan error, ) { + r.logger.Debug("Processing block", zap.Uint64("height", height), zap.String("relayerID", r.relayerID.ID.String()), zap.Stringer("blockchainID", r.relayerID.SourceBlockchainID), zap.Int("numMessages", len(handlers))) var eg errgroup.Group for _, handler := range handlers { eg.Go(func() error { @@ -182,6 +183,7 @@ func (r *ApplicationRelayer) ProcessMessage(handler messages.MessageHandler) (co zap.String("relayerID", r.relayerID.ID.String()), ) shouldSend, err := handler.ShouldSendMessage(r.destinationClient) + r.logger.Debug("called should send", zap.String("relayerID", r.relayerID.ID.String())) if err != nil { r.logger.Error( "Failed to check if message should be sent", @@ -195,6 +197,7 @@ func (r *ApplicationRelayer) ProcessMessage(handler messages.MessageHandler) (co return common.Hash{}, nil } unsignedMessage := handler.GetUnsignedMessage() + r.logger.Debug("got unsigned message", zap.String("relayerID", r.relayerID.ID.String())) startCreateSignedMessageTime := time.Now() // Query nodes on the origin chain for signatures, and construct the signed warp message. @@ -202,6 +205,7 @@ func (r *ApplicationRelayer) ProcessMessage(handler messages.MessageHandler) (co // sourceWarpSignatureClient is nil iff the source blockchain is configured to fetch signatures via AppRequest if r.sourceWarpSignatureClient == nil { + r.logger.Debug("creating signed message 1", zap.String("relayerID", r.relayerID.ID.String())) signedMessage, err = r.signatureAggregator.CreateSignedMessage( unsignedMessage, nil, @@ -219,6 +223,7 @@ func (r *ApplicationRelayer) ProcessMessage(handler messages.MessageHandler) (co } } else { r.incFetchSignatureRPCCount() + r.logger.Debug("creating signed message 2", zap.String("relayerID", r.relayerID.ID.String())) signedMessage, err = r.createSignedMessage(unsignedMessage) if err != nil { r.logger.Error( @@ -233,6 +238,7 @@ func (r *ApplicationRelayer) ProcessMessage(handler messages.MessageHandler) (co // create signed message latency (ms) r.setCreateSignedMessageLatencyMS(float64(time.Since(startCreateSignedMessageTime).Milliseconds())) + r.logger.Debug("sending message", zap.String("relayerID", r.relayerID.ID.String())) txHash, err := handler.SendMessage(signedMessage, r.destinationClient) if err != nil { r.logger.Error( diff --git a/relayer/checkpoint/checkpoint.go b/relayer/checkpoint/checkpoint.go index 6df59338..610d8fbc 100644 --- a/relayer/checkpoint/checkpoint.go +++ b/relayer/checkpoint/checkpoint.go @@ -57,6 +57,14 @@ func (cm *CheckpointManager) Run() { go cm.listenForWriteSignal() } +func (cm *CheckpointManager) RLock() { + cm.lock.RLock() +} + +func (cm *CheckpointManager) RUnlock() { + cm.lock.RUnlock() +} + func (cm *CheckpointManager) writeToDatabase() { cm.lock.RLock() defer cm.lock.RUnlock() @@ -106,6 +114,7 @@ func (cm *CheckpointManager) listenForWriteSignal() { // Heights are committed in sequence, so if height is not exactly one // greater than the current committedHeight, it is instead cached in memory // to potentially be committed later. +// TODONOW: We should only stage heights once all app relayers for a given source chain have staged func (cm *CheckpointManager) StageCommittedHeight(height uint64) { cm.lock.Lock() defer cm.lock.Unlock() diff --git a/relayer/main/main.go b/relayer/main/main.go index 58af24a9..cf423d8f 100644 --- a/relayer/main/main.go +++ b/relayer/main/main.go @@ -19,7 +19,6 @@ import ( "github.com/ava-labs/avalanchego/network/peer" "github.com/ava-labs/avalanchego/utils/constants" "github.com/ava-labs/avalanchego/utils/logging" - "github.com/ava-labs/avalanchego/utils/set" "github.com/ava-labs/awm-relayer/database" "github.com/ava-labs/awm-relayer/messages" offchainregistry "github.com/ava-labs/awm-relayer/messages/off-chain-registry" @@ -135,20 +134,9 @@ func main() { // The app request network generates P2P networking logs that are verbose at the info level. // Unless the log level is debug or lower, set the network log level to error to avoid spamming the logs. // We do not collect metrics for the network. - // networkLogLevel := logging.Error - // if logLevel <= logging.Debug { - // networkLogLevel = logLevel - // } - var trackedSubnets set.Set[ids.ID] - // trackedSubnets is no longer strictly required but keeping it here for now - // to keep full parity with existing AWM relayer for now - // TODO: remove this from here once trackedSubnets are no longer referenced - // by ping messages in avalanchego - for _, sourceBlockchain := range cfg.SourceBlockchains { - if sourceBlockchain.GetSubnetID() == constants.PrimaryNetworkID { - continue - } - trackedSubnets.Add(sourceBlockchain.GetSubnetID()) + networkLogLevel := logging.Error + if logLevel <= logging.Debug { + networkLogLevel = logLevel } // Initialize message creator passed down to relayers for creating app requests. @@ -175,9 +163,10 @@ func main() { } network, err := peers.NewNetwork( - logging.Verbo, + "relayer", + networkLogLevel, registerer, - trackedSubnets, + nil, messageCreator, manuallyTrackedPeers, &cfg, @@ -186,6 +175,7 @@ func main() { logger.Fatal("Failed to create app request network", zap.Error(err)) panic(err) } + defer network.Shutdown() err = relayer.InitializeConnectionsAndCheckStake(logger, network, &cfg) if err != nil { diff --git a/relayer/message_coordinator.go b/relayer/message_coordinator.go index acf7317d..f91f4edc 100644 --- a/relayer/message_coordinator.go +++ b/relayer/message_coordinator.go @@ -228,6 +228,7 @@ func (mc *MessageCoordinator) ProcessBlock( ethClient ethclient.Client, errChan chan error, ) { + mc.logger.Debug("Processing block", zap.Uint64("blockNumber", blockHeader.Number.Uint64()), zap.String("blockchainID", blockchainID.String())) // Parse the logs in the block, and group by application relayer block, err := relayerTypes.NewWarpBlockInfo(blockHeader, ethClient) if err != nil { @@ -263,7 +264,7 @@ func (mc *MessageCoordinator) ProcessBlock( // Dispatch all messages in the block to the appropriate application relayer. // An empty slice is still a valid argument to ProcessHeight; in this case the height is immediately committed. handlers := messageHandlers[appRelayer.relayerID.ID] - + mc.logger.Debug("Dispatching to app relayer", zap.String("relayerID", appRelayer.relayerID.ID.String()), zap.Int("numMessages", len(handlers))) go appRelayer.ProcessHeight(block.BlockNumber, handlers, errChan) } } diff --git a/signature-aggregator/aggregator/aggregator.go b/signature-aggregator/aggregator/aggregator.go index b86198c9..aaca14df 100644 --- a/signature-aggregator/aggregator/aggregator.go +++ b/signature-aggregator/aggregator/aggregator.go @@ -39,10 +39,10 @@ type blsSignatureBuf [bls.SignatureLen]byte const ( // Number of retries to collect signatures from validators - maxRelayerQueryAttempts = 5 + maxRelayerQueryAttempts = 10 // Maximum amount of time to spend waiting (in addition to network round trip time per attempt) // during relayer signature query routine - signatureRequestRetryWaitPeriodMs = 10_000 + signatureRequestRetryWaitPeriodMs = 20_000 ) var ( @@ -94,19 +94,24 @@ func NewSignatureAggregator( return &sa, nil } +func (s *SignatureAggregator) Shutdown() { + s.network.Shutdown() +} + func (s *SignatureAggregator) CreateSignedMessage( unsignedMessage *avalancheWarp.UnsignedMessage, justification []byte, inputSigningSubnet ids.ID, quorumPercentage uint64, ) (*avalancheWarp.Message, error) { + s.logger.Debug("Creating signed message", zap.String("warpMessageID", unsignedMessage.ID().String())) var signingSubnet ids.ID var err error // If signingSubnet is not set we default to the subnet of the source blockchain sourceSubnet, err := s.getSubnetID(unsignedMessage.SourceChainID) if err != nil { return nil, fmt.Errorf( - "Source message subnet not found for chainID %s", + "source message subnet not found for chainID %s", unsignedMessage.SourceChainID, ) } @@ -115,7 +120,10 @@ func (s *SignatureAggregator) CreateSignedMessage( } else { signingSubnet = inputSigningSubnet } + s.logger.Debug("Creating signed message with signing subnet", zap.String("warpMessageID", unsignedMessage.ID().String()), zap.Stringer("signingSubnet", signingSubnet)) + s.network.TrackSubnet(signingSubnet) + s.logger.Debug("tracked subnet") connectedValidators, err := s.network.ConnectToCanonicalValidators(signingSubnet) if err != nil { msg := "Failed to connect to canonical validators" @@ -127,6 +135,7 @@ func (s *SignatureAggregator) CreateSignedMessage( s.metrics.FailuresToGetValidatorSet.Inc() return nil, fmt.Errorf("%s: %w", msg, err) } + s.logger.Debug("Connected to canonical validators", zap.String("warpMessageID", unsignedMessage.ID().String())) s.metrics.ConnectedStakeWeightPercentage.WithLabelValues( signingSubnet.String(), ).Set( diff --git a/signature-aggregator/main/main.go b/signature-aggregator/main/main.go index 14cceb3b..c915ff4b 100644 --- a/signature-aggregator/main/main.go +++ b/signature-aggregator/main/main.go @@ -84,6 +84,7 @@ func main() { if logLevel <= logging.Debug { networkLogLevel = logLevel } + networkLogLevel = logging.Verbo // Initialize message creator passed down to relayers for creating app requests. // We do not collect metrics for the message creator. @@ -99,6 +100,7 @@ func main() { } network, err := peers.NewNetwork( + "aggregator", networkLogLevel, prometheus.DefaultRegisterer, nil, @@ -110,6 +112,7 @@ func main() { logger.Fatal("Failed to create app request network", zap.Error(err)) panic(err) } + defer network.Shutdown() registry := metrics.Initialize(cfg.MetricsPort) metricsInstance := metrics.NewSignatureAggregatorMetrics(registry) diff --git a/tests/basic_relay.go b/tests/basic_relay.go index 71450692..6ef116a0 100644 --- a/tests/basic_relay.go +++ b/tests/basic_relay.go @@ -77,7 +77,7 @@ func BasicRelay(network *network.LocalNetwork, teleporter utils.TeleporterTestIn }) } relayerConfig.ManuallyTrackedPeers = manuallyTrackedPeers - + relayerConfig.LogLevel = "debug" // The config needs to be validated in order to be passed to database.GetConfigRelayerIDs relayerConfig.Validate() @@ -89,7 +89,7 @@ func BasicRelay(network *network.LocalNetwork, teleporter utils.TeleporterTestIn fmt.Println("Test Relaying from Subnet A to Subnet B") fmt.Println("Starting the relayer") - relayerCleanup, readyChan := testUtils.RunRelayerExecutable( + relayerCleanup, readyChan /*readyChan*/ := testUtils.RunRelayerExecutable( ctx, relayerConfigPath, relayerConfig, @@ -97,7 +97,7 @@ func BasicRelay(network *network.LocalNetwork, teleporter utils.TeleporterTestIn defer relayerCleanup() // Wait for relayer to start up - startupCtx, startupCancel := context.WithTimeout(ctx, 30*time.Second) + startupCtx, startupCancel := context.WithTimeout(ctx, 60*time.Second) defer startupCancel() testUtils.WaitForChannelClose(startupCtx, readyChan) @@ -202,7 +202,7 @@ func BasicRelay(network *network.LocalNetwork, teleporter utils.TeleporterTestIn // Run the relayer fmt.Println("Creating new relayer instance to test already delivered message") - relayerCleanup, readyChan = testUtils.RunRelayerExecutable( + relayerCleanup, readyChan /*readyChan*/ = testUtils.RunRelayerExecutable( ctx, relayerConfigPath, relayerConfig, @@ -211,7 +211,7 @@ func BasicRelay(network *network.LocalNetwork, teleporter utils.TeleporterTestIn // Wait for relayer to start up fmt.Println("Waiting for the relayer to start up") - startupCtx, startupCancel = context.WithTimeout(ctx, 30*time.Second) + startupCtx, startupCancel = context.WithTimeout(ctx, 60*time.Second) defer startupCancel() testUtils.WaitForChannelClose(startupCtx, readyChan) diff --git a/tests/contracts/lib/teleporter b/tests/contracts/lib/teleporter index fdd3e578..106a220b 160000 --- a/tests/contracts/lib/teleporter +++ b/tests/contracts/lib/teleporter @@ -1 +1 @@ -Subproject commit fdd3e578a5074f4079473e90a35e729cad63ec64 +Subproject commit 106a220b2b5720072cc9dc2fd24be3caec21c015 diff --git a/tests/e2e_test.go b/tests/e2e_test.go index d408b5ee..07da354a 100644 --- a/tests/e2e_test.go +++ b/tests/e2e_test.go @@ -82,7 +82,7 @@ var _ = ginkgo.BeforeSuite(func() { utils.SanitizeHexString(teleporterDeployerTransactionStr), ) Expect(err).Should(BeNil()) - networkStartCtx, networkStartCancel := context.WithTimeout(ctx, 120*2*time.Second) + networkStartCtx, networkStartCancel := context.WithTimeout(ctx, 240*2*time.Second) defer networkStartCancel() localNetworkInstance = network.NewLocalNetwork( networkStartCtx, @@ -175,31 +175,31 @@ func cleanup() { var _ = ginkgo.AfterSuite(cleanup) var _ = ginkgo.Describe("[AWM Relayer Integration Tests", func() { - // ginkgo.It("Manually Provided Message", func() { - // ManualMessage(localNetworkInstance, teleporterInfo) - // }) + ginkgo.It("Manually Provided Message", func() { + ManualMessage(localNetworkInstance, teleporterInfo) + }) ginkgo.It("Basic Relay", func() { BasicRelay(localNetworkInstance, teleporterInfo) }) - // ginkgo.It("Shared Database", func() { - // SharedDatabaseAccess(localNetworkInstance, teleporterInfo) - // }) - // ginkgo.It("Allowed Addresses", func() { - // AllowedAddresses(localNetworkInstance, teleporterInfo) - // }) - // ginkgo.It("Batch Message", func() { - // BatchRelay(localNetworkInstance, teleporterInfo) - // }) - // ginkgo.It("Relay Message API", func() { - // RelayMessageAPI(localNetworkInstance, teleporterInfo) - // }) - // ginkgo.It("Warp API", func() { - // WarpAPIRelay(localNetworkInstance, teleporterInfo) - // }) - // ginkgo.It("Signature Aggregator", func() { - // SignatureAggregatorAPI(localNetworkInstance, teleporterInfo) - // }) - // ginkgo.It("Etna Upgrade", func() { - // EtnaUpgrade(localNetworkInstance, teleporterInfo) - // }) + ginkgo.It("Shared Database", func() { + SharedDatabaseAccess(localNetworkInstance, teleporterInfo) + }) + ginkgo.It("Allowed Addresses", func() { + AllowedAddresses(localNetworkInstance, teleporterInfo) + }) + ginkgo.It("Batch Message", func() { + BatchRelay(localNetworkInstance, teleporterInfo) + }) + ginkgo.It("Relay Message API", func() { + RelayMessageAPI(localNetworkInstance, teleporterInfo) + }) + ginkgo.It("Warp API", func() { + WarpAPIRelay(localNetworkInstance, teleporterInfo) + }) + ginkgo.It("Signature Aggregator", func() { + SignatureAggregatorAPI(localNetworkInstance, teleporterInfo) + }) + ginkgo.It("Etna Upgrade", func() { + EtnaUpgrade(localNetworkInstance, teleporterInfo) + }) }) diff --git a/tests/signature_aggregator_api.go b/tests/signature_aggregator_api.go index 27f2486e..8b275325 100644 --- a/tests/signature_aggregator_api.go +++ b/tests/signature_aggregator_api.go @@ -41,7 +41,7 @@ func SignatureAggregatorAPI(network *network.LocalNetwork, teleporter utils.Tele ctx := context.Background() subnetAInfo := network.GetPrimaryNetworkInfo() - subnetBInfo, _ := network.GetTwoSubnets() + subnetAInfo, subnetBInfo := network.GetTwoSubnets() fundedAddress, fundedKey := network.GetFundedAccountInfo() signatureAggregatorConfig := testUtils.CreateDefaultSignatureAggregatorConfig( @@ -123,58 +123,75 @@ func SignatureAggregatorAPI(network *network.LocalNetwork, teleporter utils.Tele sendRequestToAPI() // Check metrics - metricsSample := sampleMetrics(signatureAggregatorConfig.MetricsPort) - for _, m := range []struct { - name string - op string - value int - }{ - {metrics.Opts.AggregateSignaturesRequestCount.Name, "==", 1}, - {metrics.Opts.AggregateSignaturesLatencyMS.Name, ">", 0}, - {metrics.Opts.AppRequestCount.Name, "<=", 5}, - {metrics.Opts.FailuresToGetValidatorSet.Name, "==", 0}, - {metrics.Opts.FailuresToConnectToSufficientStake.Name, "==", 0}, - {metrics.Opts.FailuresSendingToNode.Name, "<", 5}, - {metrics.Opts.ValidatorTimeouts.Name, "==", 0}, - {metrics.Opts.InvalidSignatureResponses.Name, "==", 0}, - {metrics.Opts.SignatureCacheHits.Name, "==", 0}, - {metrics.Opts.SignatureCacheMisses.Name, "==", 0}, - { - fmt.Sprintf( - "%s{subnetID=\"%s\"}", - metrics.Opts.ConnectedStakeWeightPercentage.Name, - subnetAInfo.SubnetID.String(), - ), - "==", - 100, - }, - } { - Expect(metricsSample[m.name]).Should( - BeNumerically(m.op, m.value), - "Expected metric %s %s %d", - m.name, - m.op, - m.value, - ) - } + // metricsSample := sampleMetrics(signatureAggregatorConfig.MetricsPort) + // for _, m := range []struct { + // name string + // op string + // value int + // }{ + // {metrics.Opts.AggregateSignaturesRequestCount.Name, "==", 1}, + // {metrics.Opts.AggregateSignaturesLatencyMS.Name, ">", 0}, + // {metrics.Opts.AppRequestCount.Name, "<=", 5}, + // {metrics.Opts.FailuresToGetValidatorSet.Name, "==", 0}, + // {metrics.Opts.FailuresToConnectToSufficientStake.Name, "==", 0}, + // {metrics.Opts.FailuresSendingToNode.Name, "<", 5}, + // {metrics.Opts.ValidatorTimeouts.Name, "==", 0}, + // {metrics.Opts.InvalidSignatureResponses.Name, "==", 0}, + // {metrics.Opts.SignatureCacheHits.Name, "==", 0}, + // {metrics.Opts.SignatureCacheMisses.Name, "==", 0}, + // { + // fmt.Sprintf( + // "%s{subnetID=\"%s\"}", + // metrics.Opts.ConnectedStakeWeightPercentage.Name, + // subnetAInfo.SubnetID.String(), + // ), + // "==", + // 100, + // }, + // } { + // Expect(metricsSample[m.name]).Should( + // BeNumerically(m.op, m.value), + // "Expected metric %s %s %d", + // m.name, + // m.op, + // m.value, + // ) + // } + + // // TODONOW: Fix this using the new subnet weights post conversion + // // make a second request, and ensure that the metrics reflect that the + // // signatures for the second request are retrieved from the cache. note + // // that even though 4 signatures were requested in the previous + // // request, only 3 will be cached, because that's all that was required + // // to reach a quorum, so that's all that were handled. + // sendRequestToAPI() + // metricsSample2 := sampleMetrics(signatureAggregatorConfig.MetricsPort) + // Expect( + // metricsSample2[metrics.Opts.AppRequestCount.Name], + // ).Should(Equal(metricsSample[metrics.Opts.AppRequestCount.Name])) + // Expect( + // metricsSample2[metrics.Opts.SignatureCacheHits.Name], + // ).Should(BeNumerically("==", 3)) + // Expect( + // metricsSample2[metrics.Opts.SignatureCacheMisses.Name], + // ).Should(Equal(metricsSample[metrics.Opts.SignatureCacheMisses.Name])) + + // Try in the other direction + log.Info("Sending teleporter message") + receipt, _, _ = testUtils.SendBasicTeleporterMessage( + ctx, + teleporter, + subnetBInfo, + subnetAInfo, + fundedKey, + fundedAddress, + ) + warpMessage = getWarpMessageFromLog(ctx, receipt, subnetBInfo) - // TODONOW: Fix this using the new subnet weights post conversion - // make a second request, and ensure that the metrics reflect that the - // signatures for the second request are retrieved from the cache. note - // that even though 4 signatures were requested in the previous - // request, only 3 will be cached, because that's all that was required - // to reach a quorum, so that's all that were handled. + reqBody = api.AggregateSignatureRequest{ + Message: "0x" + hex.EncodeToString(warpMessage.Bytes()), + } sendRequestToAPI() - metricsSample2 := sampleMetrics(signatureAggregatorConfig.MetricsPort) - Expect( - metricsSample2[metrics.Opts.AppRequestCount.Name], - ).Should(Equal(metricsSample[metrics.Opts.AppRequestCount.Name])) - Expect( - metricsSample2[metrics.Opts.SignatureCacheHits.Name], - ).Should(BeNumerically("==", 3)) - Expect( - metricsSample2[metrics.Opts.SignatureCacheMisses.Name], - ).Should(Equal(metricsSample[metrics.Opts.SignatureCacheMisses.Name])) } // returns a map of metric names to metric samples diff --git a/tests/utils/utils.go b/tests/utils/utils.go index 2d8d90f7..08a094ca 100644 --- a/tests/utils/utils.go +++ b/tests/utils/utils.go @@ -120,6 +120,7 @@ func CreateDefaultRelayerConfig( if err != nil { logLevel = logging.Info } + logLevel = logging.Debug log.Info( "Setting up relayer config", @@ -192,7 +193,7 @@ func CreateDefaultRelayerConfig( } return relayercfg.Config{ - LogLevel: logging.Info.LowerString(), + LogLevel: logLevel.LowerString(), PChainAPI: &config.APIConfig{ BaseURL: sourceSubnetsInfo[0].NodeURIs[0], }, @@ -228,7 +229,7 @@ func CreateDefaultSignatureAggregatorConfig( ) // Construct the config values for each subnet return signatureaggregatorcfg.Config{ - LogLevel: logging.Info.LowerString(), + LogLevel: logging.Verbo.LowerString(), PChainAPI: &config.APIConfig{ BaseURL: sourceSubnetsInfo[0].NodeURIs[0], }, @@ -377,7 +378,7 @@ func WaitTeleporterMessageDelivered( teleporterMessenger *teleportermessenger.TeleporterMessenger, teleporterMessageID ids.ID, ) error { - cctx, cancel := context.WithTimeout(ctx, 20*time.Second) + cctx, cancel := context.WithTimeout(ctx, 60*time.Second) defer cancel() queryTicker := time.NewTicker(200 * time.Millisecond) @@ -481,7 +482,7 @@ func TriggerProcessMissedBlocks( defer relayerCleanup() // Wait for relayer to start up - startupCtx, startupCancel := context.WithTimeout(ctx, 15*time.Second) + startupCtx, startupCancel := context.WithTimeout(ctx, 60*time.Second) defer startupCancel() WaitForChannelClose(startupCtx, readyChan) @@ -581,9 +582,11 @@ func runExecutable( for { resp, err := http.Get(healthCheckUrl) if err == nil && resp.StatusCode == 200 { + fmt.Println("Health check passed", "appName", appName) close(readyChan) break } + fmt.Println("Health check failed", "appName", appName, "err", err) time.Sleep(time.Second * 1) } }() From 9923b3ead085c0024f13362628f89a578ee52878 Mon Sep 17 00:00:00 2001 From: cam-schultz Date: Thu, 21 Nov 2024 12:12:39 -0600 Subject: [PATCH 09/28] cleanup --- config/peer_config.go | 3 + database/json_file_storage.go | 3 +- peers/app_request_network.go | 255 +++--------------- relayer/application_relayer.go | 5 - relayer/checkpoint/checkpoint.go | 10 +- relayer/main/main.go | 3 +- scripts/e2e_test.sh | 29 +- signature-aggregator/aggregator/aggregator.go | 5 +- signature-aggregator/main/main.go | 4 +- tests/basic_relay.go | 77 +----- tests/e2e_test.go | 54 ++-- tests/signature_aggregator_api.go | 58 +--- tests/utils/utils.go | 19 +- 13 files changed, 104 insertions(+), 421 deletions(-) diff --git a/config/peer_config.go b/config/peer_config.go index 7cf93999..e9667784 100644 --- a/config/peer_config.go +++ b/config/peer_config.go @@ -1,3 +1,6 @@ +// Copyright (C) 2024, Ava Labs, Inc. All rights reserved. +// See the file LICENSE for licensing terms. + package config import ( diff --git a/database/json_file_storage.go b/database/json_file_storage.go index 6e83faf3..e1916f60 100644 --- a/database/json_file_storage.go +++ b/database/json_file_storage.go @@ -125,7 +125,7 @@ func (s *JSONFileStorage) getCurrentState(relayerID common.Hash) (chainState, bo // Put the value into the JSON database. Read the current chain state and overwrite the key, if it exists // If the file corresponding to {relayerID} does not exist, then it will be created func (s *JSONFileStorage) Put(relayerID common.Hash, dataKey DataKey, value []byte) error { - s.logger.Debug("putting value into database") + s.logger.Debug("db put", zap.Stringer("relayerID", relayerID), zap.Stringer("key", dataKey), zap.String("value", string(value))) mutex, ok := s.mutexes[relayerID] if !ok { return errors.Wrap( @@ -136,7 +136,6 @@ func (s *JSONFileStorage) Put(relayerID common.Hash, dataKey DataKey, value []by mutex.Lock() defer mutex.Unlock() - s.logger.Debug("acquired lock") // Update the in-memory state and write to disk s.currentState[relayerID][dataKey.String()] = string(value) diff --git a/peers/app_request_network.go b/peers/app_request_network.go index 9bc670b2..e70e70ef 100644 --- a/peers/app_request_network.go +++ b/peers/app_request_network.go @@ -8,7 +8,6 @@ package peers import ( "context" "encoding/hex" - "fmt" "os" "sync" "time" @@ -34,10 +33,11 @@ import ( const ( InboundMessageChannelSize = 1000 DefaultAppRequestTimeout = time.Second * 2 + ValidatorRefreshPeriod = time.Second * 5 + NumBootstrapNodes = 5 ) type AppRequestNetwork interface { - ConnectPeers(nodeIDs set.Set[ids.NodeID]) set.Set[ids.NodeID] ConnectToCanonicalValidators(subnetID ids.ID) ( *ConnectedCanonicalValidators, error, @@ -48,12 +48,6 @@ type AppRequestNetwork interface { requestID uint32, numExpectedResponse int, ) chan message.InboundMessage - Message( - sourceChainID ids.ID, - requestID uint32, - timeout time.Duration, - request []byte, - ) (message.OutboundMessage, error) Send( msg message.OutboundMessage, nodeIDs set.Set[ids.NodeID], @@ -69,31 +63,24 @@ type appRequestNetwork struct { handler *RelayerExternalHandler infoAPI *InfoAPI logger logging.Logger - lock *sync.Mutex + lock *sync.RWMutex validatorClient *validators.CanonicalValidatorClient metrics *AppRequestNetworkMetrics - messageCreator message.Creator - - // Nodes that we should connect to that are not publicly discoverable. - // Should only be used for local or custom blockchains where validators are not - // publicly discoverable by primary network nodes. - manuallyTrackedPeers []info.Peer // TODONOW: we should be able to remove this from the struct - trackedSubnets set.Set[ids.ID] - manager vdrs.Manager + + trackedSubnets set.Set[ids.ID] + manager vdrs.Manager } // NewNetwork creates a P2P network client for interacting with validators func NewNetwork( - tag string, logLevel logging.Level, registerer prometheus.Registerer, trackedSubnets set.Set[ids.ID], - messageCreator message.Creator, manuallyTrackedPeers []info.Peer, cfg Config, ) (AppRequestNetwork, error) { logger := logging.NewLogger( - fmt.Sprintf("p2p-network-%s", tag), + "p2p-network", logging.NewWrappedCore( logLevel, os.Stdout, @@ -134,17 +121,8 @@ func NewNetwork( return nil, err } - // TODONOW: Get the list of current primary network validators validatorClient := validators.NewCanonicalValidatorClient(logger, cfg.GetPChainAPI()) manager := snowVdrs.NewManager() - // TODO: We can probably just do this in the below worker - if err := updatePrimaryNetworkValidators(context.Background(), logger, constants.PrimaryNetworkID, manager, validatorClient); err != nil { - logger.Error( - "Failed to set primary network validators on startup", - zap.Error(err), - ) - return nil, err - } testNetwork, err := network.NewTestNetwork(logger, networkID, manager, trackedSubnets, handler) if err != nil { @@ -155,28 +133,12 @@ func NewNetwork( return nil, err } - // TODONOW: construct this when we return - arNetwork := &appRequestNetwork{ - network: testNetwork, - handler: handler, - infoAPI: infoAPI, - logger: logger, - lock: new(sync.Mutex), - validatorClient: validatorClient, - metrics: metrics, - messageCreator: messageCreator, - manuallyTrackedPeers: manuallyTrackedPeers, - trackedSubnets: trackedSubnets, - manager: manager, - } - for _, peer := range manuallyTrackedPeers { logger.Info("Manually Tracking peer (startup)", zap.String("ID", peer.ID.String()), zap.String("IP", peer.PublicIP.String())) - arNetwork.network.ManuallyTrack(peer.ID, peer.PublicIP) + testNetwork.ManuallyTrack(peer.ID, peer.PublicIP) } // Connect to a sample of the primary network validators - // TODO: this seems to be returning subnet A validators as well (but NOT subnet B validators) peers, err := infoAPI.Peers(context.Background(), nil) if err != nil { logger.Error( @@ -186,83 +148,71 @@ func NewNetwork( return nil, err } pClient := platformvm.NewClient(cfg.GetPChainAPI().BaseURL) + numConnected := 0 for _, peer := range peers { - vdrs, err := pClient.GetCurrentValidators(context.Background(), ids.Empty, []ids.NodeID{peer.ID}) + vdrs, err := pClient.GetCurrentValidators(context.Background(), constants.PrimaryNetworkID, []ids.NodeID{peer.ID}) if err != nil { panic(err) } + // Only track the peer if it is a primary network validator if len(vdrs) == 0 { continue } logger.Info("Manually tracking bootstrap node", zap.String("ID", peer.ID.String()), zap.String("IP", peer.PublicIP.String())) - arNetwork.network.ManuallyTrack(peer.ID, peer.PublicIP) + testNetwork.ManuallyTrack(peer.ID, peer.PublicIP) + numConnected++ + if numConnected >= NumBootstrapNodes { + break + } } - // s := sampler.NewUniform() - // s.Initialize(uint64(len(peers))) - // indices, _ := s.Sample(min(len(peers), 5)) - // for _, i := range indices { - // logger.Info("Manually tracking bootstrap node", zap.String("ID", peers[i].ID.String()), zap.String("IP", peers[i].PublicIP.String())) - // arNetwork.network.ManuallyTrack(peers[i].ID, peers[i].PublicIP) - // } - - // TODO: Is this necessary? - // Register outselves as a validator (from our view) so that we request all peers - // manager.AddStaker(constants.PrimaryNetworkID, arNetwork..) go logger.RecoverAndPanic(func() { testNetwork.Dispatch() }) - // Periodically update the primary network validator set - // TODO: This needs to update the subent validator set as well - // go func() { - // for range time.Tick(5 * time.Second) { - // updatePrimaryNetworkValidators(context.Background(), constants.PrimaryNetworkID, manager, validatorClient) - // for _, subnet := range trackedSubnets.List() { - // updatePrimaryNetworkValidators(context.Background(), subnet, manager, validatorClient) - // } - - // // DBG - // connectedPeers := arNetwork.network.PeerInfo(nil) - // arNetwork.logger.Info("Startup Connected peers", zap.Int("count", len(connectedPeers))) - // for _, peer := range connectedPeers { - // arNetwork.logger.Info("Connected peer", zap.String("ID", peer.ID.String())) - // } - // } - // }() + arNetwork := &appRequestNetwork{ + network: testNetwork, + handler: handler, + infoAPI: infoAPI, + logger: logger, + lock: new(sync.RWMutex), + validatorClient: validatorClient, + metrics: metrics, + trackedSubnets: trackedSubnets, + manager: manager, + } + arNetwork.startUpdateValidators() return arNetwork, nil } func (n *appRequestNetwork) TrackSubnet(subnetID ids.ID) { - n.logger.Debug("acquiring lock 2") + n.lock.RLock() + if n.trackedSubnets.Contains(subnetID) { + n.lock.RUnlock() + return + } + n.lock.RUnlock() + n.lock.Lock() defer n.lock.Unlock() - n.logger.Debug("acquired lock 2") n.logger.Debug("Tracking subnet", zap.String("subnetID", subnetID.String())) n.trackedSubnets.Add(subnetID) } func (n *appRequestNetwork) startUpdateValidators() { go func() { - for range time.Tick(5 * time.Second) { - n.logger.Debug("acquiring lock 3") + // Fetch validators immediately when called, and refresh every ValidatorRefreshPeriod + ticker := time.NewTicker(ValidatorRefreshPeriod) + for ; true; <-ticker.C { n.lock.Lock() - n.logger.Debug("acquired lock 3") updatePrimaryNetworkValidators(context.Background(), n.logger, constants.PrimaryNetworkID, n.manager, n.validatorClient) for _, subnet := range n.trackedSubnets.List() { updatePrimaryNetworkValidators(context.Background(), n.logger, subnet, n.manager, n.validatorClient) } n.lock.Unlock() - - // DBG - connectedPeers := n.network.PeerInfo(nil) - n.logger.Info("Startup Connected peers", zap.Int("count", len(connectedPeers))) - for _, peer := range connectedPeers { - n.logger.Info("Connected peer", zap.String("ID", peer.ID.String()), zap.Any("trackedSubnets", n.trackedSubnets)) - } } }() } @@ -319,112 +269,6 @@ func (n *appRequestNetwork) Shutdown() { n.network.StartClose() } -// ConnectPeers connects the network to peers with the given nodeIDs. -// Returns the set of nodeIDs that were successfully connected to. -func (n *appRequestNetwork) ConnectPeers(nodeIDs set.Set[ids.NodeID]) set.Set[ids.NodeID] { - n.logger.Debug("acquiring lock 1") - n.lock.Lock() - defer n.lock.Unlock() - n.logger.Debug("acquired lock 1") - - // TODONOW: - // Get primary network validators - // Request peers from one of them - // Iterate through and manually connect to - - // First, check if we are already connected to all the peers - connectedPeers := n.network.PeerInfo(nil) - n.logger.Info("Connected peers", zap.Int("count", len(connectedPeers))) - for _, peer := range connectedPeers { - n.logger.Info("Connected peer", zap.String("ID", peer.ID.String())) - } - // if len(connectedPeers) == nodeIDs.Len() { - // return nodeIDs - // } - - // If we are not connected to all the peers already, then we have to iterate - // through the full list of peers obtained from the info API. Rather than iterating - // through connectedPeers for already tracked peers, just iterate through the full list, - // re-adding connections to already tracked peers. - - // startInfoAPICall := time.Now() - // // Get the list of publicly discoverable peers - // peers, err := n.infoAPI.Peers(context.Background(), nil) - // n.setInfoAPICallLatencyMS(float64(time.Since(startInfoAPICall).Milliseconds())) - // if err != nil { - // n.logger.Error( - // "Failed to get peers", - // zap.Error(err), - // ) - // return nil - // } - // n.logger.Info("Fetched peers from info API") - // for _, peer := range peers { - // n.logger.Info("Peer", zap.String("ID", peer.ID.String())) - // } - - // // Add manually tracked peers - // for _, peer := range n.manuallyTrackedPeers { - // n.logger.Info("Manually Tracking peer", zap.String("ID", peer.ID.String()), zap.String("IP", peer.PublicIP.String())) - // n.network.ManuallyTrack(peer.ID, peer.PublicIP) - // } - - // // Attempt to connect to each peer - // var trackedNodes set.Set[ids.NodeID] - // for _, peer := range peers { - // if nodeIDs.Contains(peer.ID) { - // trackedNodes.Add(peer.ID) - // n.logger.Info("Tracking peer", zap.String("ID", peer.ID.String()), zap.String("IP", peer.PublicIP.String())) - // n.network.ManuallyTrack(peer.ID, peer.PublicIP) - // // TODONOW: length checks are not correct - // if len(trackedNodes) == nodeIDs.Len() { - // // DEBUG - // connectedPeers = n.network.PeerInfo(nil) - // n.logger.Info("Connected peers", zap.Int("count", len(connectedPeers))) - // for _, peer := range connectedPeers { - // n.logger.Info("Connected peer", zap.String("ID", peer.ID.String())) - // } - // return trackedNodes - // } - // } - // } - - // DEBUG - // connectedPeers = n.network.PeerInfo(nil) - // n.logger.Info("Connected peers", zap.Int("count", len(connectedPeers))) - // for _, peer := range connectedPeers { - // n.logger.Info("Connected peer", zap.String("ID", peer.ID.String())) - // } - - // // If the Info API node is in nodeIDs, it will not be reflected in the call to info.Peers. - // // In this case, we need to manually track the API node. - // startInfoAPICall = time.Now() - // apiNodeID, _, err := n.infoAPI.GetNodeID(context.Background()) - // n.setInfoAPICallLatencyMS(float64(time.Since(startInfoAPICall).Milliseconds())) - // if err != nil { - // n.logger.Error( - // "Failed to get API Node ID", - // zap.Error(err), - // ) - // } else if nodeIDs.Contains(apiNodeID) { - // startInfoAPICall = time.Now() - // apiNodeIPPort, err := n.infoAPI.GetNodeIP(context.Background()) - // n.setInfoAPICallLatencyMS(float64(time.Since(startInfoAPICall).Milliseconds())) - // if err != nil { - // n.logger.Error( - // "Failed to get API Node IP", - // zap.Error(err), - // ) - // } else { - // trackedNodes.Add(apiNodeID) - // n.network.ManuallyTrack(apiNodeID, apiNodeIPPort) - // } - // } - - // return trackedNodes - return nodeIDs -} - // Helper struct to hold connected validator information // Warp Validators sharing the same BLS key may consist of multiple nodes, // so we need to track the node ID to validator index mapping @@ -463,15 +307,8 @@ func (n *appRequestNetwork) ConnectToCanonicalValidators(subnetID ids.ID) (*Conn } } - // Manually connect to all peers in the validator set - // If new peers are connected, AppRequests may fail while the handshake is in progress. - // In that case, AppRequests to those nodes will be retried in the next iteration of the retry loop. - n.logger.Debug("connecting to peers") - connectedNodes := n.ConnectPeers(nodeIDs) - n.logger.Debug("connected to peers") - // Calculate the total weight of connected validators. - connectedWeight := calculateConnectedWeight(validatorSet, nodeValidatorIndexMap, connectedNodes) + connectedWeight := calculateConnectedWeight(validatorSet, nodeValidatorIndexMap, nodeIDs) return &ConnectedCanonicalValidators{ ConnectedWeight: connectedWeight, @@ -481,20 +318,6 @@ func (n *appRequestNetwork) ConnectToCanonicalValidators(subnetID ids.ID) (*Conn }, nil } -func (n *appRequestNetwork) Message( - sourceChainID ids.ID, - requestID uint32, - timeout time.Duration, - request []byte, -) (message.OutboundMessage, error) { - return n.messageCreator.AppRequest( - sourceChainID, - requestID, - timeout, - request, - ) -} - func (n *appRequestNetwork) Send( msg message.OutboundMessage, nodeIDs set.Set[ids.NodeID], diff --git a/relayer/application_relayer.go b/relayer/application_relayer.go index a9ba1d43..34d9cc34 100644 --- a/relayer/application_relayer.go +++ b/relayer/application_relayer.go @@ -183,7 +183,6 @@ func (r *ApplicationRelayer) ProcessMessage(handler messages.MessageHandler) (co zap.String("relayerID", r.relayerID.ID.String()), ) shouldSend, err := handler.ShouldSendMessage(r.destinationClient) - r.logger.Debug("called should send", zap.String("relayerID", r.relayerID.ID.String())) if err != nil { r.logger.Error( "Failed to check if message should be sent", @@ -197,7 +196,6 @@ func (r *ApplicationRelayer) ProcessMessage(handler messages.MessageHandler) (co return common.Hash{}, nil } unsignedMessage := handler.GetUnsignedMessage() - r.logger.Debug("got unsigned message", zap.String("relayerID", r.relayerID.ID.String())) startCreateSignedMessageTime := time.Now() // Query nodes on the origin chain for signatures, and construct the signed warp message. @@ -205,7 +203,6 @@ func (r *ApplicationRelayer) ProcessMessage(handler messages.MessageHandler) (co // sourceWarpSignatureClient is nil iff the source blockchain is configured to fetch signatures via AppRequest if r.sourceWarpSignatureClient == nil { - r.logger.Debug("creating signed message 1", zap.String("relayerID", r.relayerID.ID.String())) signedMessage, err = r.signatureAggregator.CreateSignedMessage( unsignedMessage, nil, @@ -223,7 +220,6 @@ func (r *ApplicationRelayer) ProcessMessage(handler messages.MessageHandler) (co } } else { r.incFetchSignatureRPCCount() - r.logger.Debug("creating signed message 2", zap.String("relayerID", r.relayerID.ID.String())) signedMessage, err = r.createSignedMessage(unsignedMessage) if err != nil { r.logger.Error( @@ -238,7 +234,6 @@ func (r *ApplicationRelayer) ProcessMessage(handler messages.MessageHandler) (co // create signed message latency (ms) r.setCreateSignedMessageLatencyMS(float64(time.Since(startCreateSignedMessageTime).Milliseconds())) - r.logger.Debug("sending message", zap.String("relayerID", r.relayerID.ID.String())) txHash, err := handler.SendMessage(signedMessage, r.destinationClient) if err != nil { r.logger.Error( diff --git a/relayer/checkpoint/checkpoint.go b/relayer/checkpoint/checkpoint.go index 610d8fbc..21060f5c 100644 --- a/relayer/checkpoint/checkpoint.go +++ b/relayer/checkpoint/checkpoint.go @@ -57,14 +57,6 @@ func (cm *CheckpointManager) Run() { go cm.listenForWriteSignal() } -func (cm *CheckpointManager) RLock() { - cm.lock.RLock() -} - -func (cm *CheckpointManager) RUnlock() { - cm.lock.RUnlock() -} - func (cm *CheckpointManager) writeToDatabase() { cm.lock.RLock() defer cm.lock.RUnlock() @@ -114,7 +106,7 @@ func (cm *CheckpointManager) listenForWriteSignal() { // Heights are committed in sequence, so if height is not exactly one // greater than the current committedHeight, it is instead cached in memory // to potentially be committed later. -// TODONOW: We should only stage heights once all app relayers for a given source chain have staged +// TODO: We should only stage heights once all app relayers for a given source chain have staged func (cm *CheckpointManager) StageCommittedHeight(height uint64) { cm.lock.Lock() defer cm.lock.Unlock() diff --git a/relayer/main/main.go b/relayer/main/main.go index cf423d8f..5a1f0ab7 100644 --- a/relayer/main/main.go +++ b/relayer/main/main.go @@ -163,11 +163,9 @@ func main() { } network, err := peers.NewNetwork( - "relayer", networkLogLevel, registerer, nil, - messageCreator, manuallyTrackedPeers, &cfg, ) @@ -226,6 +224,7 @@ func main() { signatureAggregator, err := aggregator.NewSignatureAggregator( network, logger, + messageCreator, cfg.SignatureCacheSize, sigAggMetrics.NewSignatureAggregatorMetrics( prometheus.DefaultRegisterer, diff --git a/scripts/e2e_test.sh b/scripts/e2e_test.sh index 3949371f..880bbfaa 100755 --- a/scripts/e2e_test.sh +++ b/scripts/e2e_test.sh @@ -4,16 +4,10 @@ set -e -SUBNET_EVM_PATH= -LOCAL= -DATA_DIRECTORY= HELP= LOG_LEVEL= while [ $# -gt 0 ]; do case "$1" in - -l | --local) LOCAL=true ;; - -s | --subnet-evm) SUBNET_EVM_PATH=$2 ;; - -d | --data-dir) DATA_DIRECTORY=$2 ;; -v | --verbose) LOG_LEVEL=debug ;; -h | --help) HELP=true ;; esac @@ -25,33 +19,11 @@ if [ "$HELP" = true ]; then echo "Run E2E tests for AWM Relayer." echo "" echo "Options:" - echo " -l, --local Run the test locally. Requires --subnet-evm and --data-dir" - echo " -s, --subnet-evm Path to subnet-evm repo" - echo " -d, --data-dir Path to data directory" echo " -v, --verbose Enable debug logs" echo " -h, --help Print this help message" exit 0 fi -# if [ "$LOCAL" = true ]; then -# if [ -z "$DATA_DIRECTORY" ]; then -# echo "Must specify data directory when running local" -# exit 1 -# fi -# if [ -z "$SUBNET_EVM_PATH" ]; then -# echo "Must specify subnet-evm path when running local" -# exit 1 -# fi -# cwd=$PWD -# cd $SUBNET_EVM_PATH -# BASEDIR=$DATA_DIRECTORY AVALANCHEGO_BUILD_PATH=$DATA_DIRECTORY/avalanchego ./scripts/install_avalanchego_release.sh -# ./scripts/build.sh $DATA_DIRECTORY/avalanchego/plugins/srEXiWaHuhNyGwPUi444Tu47ZEDwxTWrbQiuD7FmgSAQ6X7Dy - -# cd $cwd -# export AVALANCHEGO_BUILD_PATH=$DATA_DIRECTORY/avalanchego -# export DATA_DIR=$DATA_DIRECTORY/data -# fi - BASE_PATH=$( cd "$(dirname "${BASH_SOURCE[0]}")" cd .. && pwd @@ -72,6 +44,7 @@ cp ${BASEDIR}/subnet-evm/subnet-evm ${BASEDIR}/avalanchego/plugins/srEXiWaHuhNyG echo "Copied ${BASEDIR}/subnet-evm/subnet-evm binary to ${BASEDIR}/avalanchego/plugins/" export AVALANCHEGO_BUILD_PATH=$BASEDIR/avalanchego +# TODO: Remove this once we have tagged dependencies cp /Users/cameron.schultz/avalanchego/build/avalanchego $AVALANCHEGO_BUILD_PATH/avalanchego # Build ginkgo diff --git a/signature-aggregator/aggregator/aggregator.go b/signature-aggregator/aggregator/aggregator.go index aaca14df..c1fb567b 100644 --- a/signature-aggregator/aggregator/aggregator.go +++ b/signature-aggregator/aggregator/aggregator.go @@ -70,6 +70,7 @@ type SignatureAggregator struct { func NewSignatureAggregator( network peers.AppRequestNetwork, logger logging.Logger, + messageCreator message.Creator, signatureCacheSize uint64, metrics *metrics.SignatureAggregatorMetrics, etnaTime time.Time, @@ -89,6 +90,7 @@ func NewSignatureAggregator( currentRequestID: atomic.Uint32{}, cache: cache, etnaTime: etnaTime, + messageCreator: messageCreator, } sa.currentRequestID.Store(rand.Uint32()) return &sa, nil @@ -123,7 +125,6 @@ func (s *SignatureAggregator) CreateSignedMessage( s.logger.Debug("Creating signed message with signing subnet", zap.String("warpMessageID", unsignedMessage.ID().String()), zap.Stringer("signingSubnet", signingSubnet)) s.network.TrackSubnet(signingSubnet) - s.logger.Debug("tracked subnet") connectedValidators, err := s.network.ConnectToCanonicalValidators(signingSubnet) if err != nil { msg := "Failed to connect to canonical validators" @@ -204,7 +205,7 @@ func (s *SignatureAggregator) CreateSignedMessage( // Construct the AppRequest requestID := s.currentRequestID.Add(1) - outMsg, err := s.network.Message( + outMsg, err := s.messageCreator.AppRequest( unsignedMessage.SourceChainID, requestID, peers.DefaultAppRequestTimeout, diff --git a/signature-aggregator/main/main.go b/signature-aggregator/main/main.go index c915ff4b..48ef4302 100644 --- a/signature-aggregator/main/main.go +++ b/signature-aggregator/main/main.go @@ -84,7 +84,6 @@ func main() { if logLevel <= logging.Debug { networkLogLevel = logLevel } - networkLogLevel = logging.Verbo // Initialize message creator passed down to relayers for creating app requests. // We do not collect metrics for the message creator. @@ -100,11 +99,9 @@ func main() { } network, err := peers.NewNetwork( - "aggregator", networkLogLevel, prometheus.DefaultRegisterer, nil, - messageCreator, nil, &cfg, ) @@ -120,6 +117,7 @@ func main() { signatureAggregator, err := aggregator.NewSignatureAggregator( network, logger, + messageCreator, cfg.SignatureCacheSize, metricsInstance, cfg.EtnaTime, diff --git a/tests/basic_relay.go b/tests/basic_relay.go index 6ef116a0..2d0c0281 100644 --- a/tests/basic_relay.go +++ b/tests/basic_relay.go @@ -5,13 +5,10 @@ package tests import ( "context" - "fmt" - "net/url" "os" "time" "github.com/ava-labs/avalanchego/utils/logging" - "github.com/ava-labs/awm-relayer/config" "github.com/ava-labs/awm-relayer/database" testUtils "github.com/ava-labs/awm-relayer/tests/utils" "github.com/ava-labs/subnet-evm/core/types" @@ -19,6 +16,7 @@ import ( "github.com/ava-labs/teleporter/tests/network" "github.com/ava-labs/teleporter/tests/utils" "github.com/ethereum/go-ethereum/crypto" + "github.com/ethereum/go-ethereum/log" . "github.com/onsi/gomega" ) @@ -28,16 +26,8 @@ import ( // - Relaying an already delivered message // - Setting ProcessHistoricalBlocksFromHeight in config func BasicRelay(network *network.LocalNetwork, teleporter utils.TeleporterTestInfo) { - // Restart the network to attempt to refresh TLS connections - { - ctx, cancel := context.WithTimeout(context.Background(), time.Duration(60*len(network.Network.Nodes))*time.Second) - defer cancel() - err := network.Network.Restart(ctx, os.Stdout) - Expect(err).Should(BeNil()) - } - subnetAInfo := network.GetPrimaryNetworkInfo() - subnetAInfo, subnetBInfo := network.GetTwoSubnets() + subnetBInfo, _ := network.GetTwoSubnets() fundedAddress, fundedKey := network.GetFundedAccountInfo() err := testUtils.ClearRelayerStorage() Expect(err).Should(BeNil()) @@ -47,7 +37,7 @@ func BasicRelay(network *network.LocalNetwork, teleporter utils.TeleporterTestIn // ctx := context.Background() - fmt.Println("Funding relayer address on all subnets") + log.Info("Funding relayer address on all subnets") relayerKey, err := crypto.GenerateKey() Expect(err).Should(BeNil()) testUtils.FundRelayers(ctx, []interfaces.SubnetTestInfo{subnetAInfo, subnetBInfo}, fundedKey, relayerKey) @@ -63,21 +53,6 @@ func BasicRelay(network *network.LocalNetwork, teleporter utils.TeleporterTestIn relayerKey, ) - // Add primary network validators as manually tracked peers - var manuallyTrackedPeers []*config.PeerConfig - primaryNetworkValidators := network.GetPrimaryNetworkValidators() - for _, validator := range primaryNetworkValidators[0:1] { - parsed, err := url.Parse(validator.URI) - Expect(err).Should(BeNil()) - // ip, err := netip.ParseAddrPort(parsed.Host) - // Expect(err).Should(BeNil()) - manuallyTrackedPeers = append(manuallyTrackedPeers, &config.PeerConfig{ - IP: parsed.Host, - ID: validator.NodeID.String(), - }) - } - relayerConfig.ManuallyTrackedPeers = manuallyTrackedPeers - relayerConfig.LogLevel = "debug" // The config needs to be validated in order to be passed to database.GetConfigRelayerIDs relayerConfig.Validate() @@ -86,9 +61,9 @@ func BasicRelay(network *network.LocalNetwork, teleporter utils.TeleporterTestIn // // Test Relaying from Subnet A to Subnet B // - fmt.Println("Test Relaying from Subnet A to Subnet B") + log.Info("Test Relaying from Subnet A to Subnet B") - fmt.Println("Starting the relayer") + log.Info("Starting the relayer") relayerCleanup, readyChan /*readyChan*/ := testUtils.RunRelayerExecutable( ctx, relayerConfigPath, @@ -101,33 +76,7 @@ func BasicRelay(network *network.LocalNetwork, teleporter utils.TeleporterTestIn defer startupCancel() testUtils.WaitForChannelClose(startupCtx, readyChan) - fmt.Println("Sending transaction from Subnet A to Subnet B") - testUtils.RelayBasicMessage( - ctx, - teleporter, - subnetAInfo, - subnetBInfo, - fundedKey, - fundedAddress, - ) - - time.Sleep(10 * time.Second) - - // - // Test Relaying from Subnet B to Subnet A - // - fmt.Println("Test Relaying from Subnet B to Subnet A") - testUtils.RelayBasicMessage( - ctx, - teleporter, - subnetBInfo, - subnetAInfo, - fundedKey, - fundedAddress, - ) - - time.Sleep(10 * time.Second) - fmt.Println("Sending transaction from Subnet A to Subnet B") + log.Info("Sending transaction from Subnet A to Subnet B") testUtils.RelayBasicMessage( ctx, teleporter, @@ -142,7 +91,7 @@ func BasicRelay(network *network.LocalNetwork, teleporter utils.TeleporterTestIn // // Test Relaying from Subnet B to Subnet A // - fmt.Println("Test Relaying from Subnet B to Subnet A") + log.Info("Test Relaying from Subnet B to Subnet A") testUtils.RelayBasicMessage( ctx, teleporter, @@ -152,14 +101,14 @@ func BasicRelay(network *network.LocalNetwork, teleporter utils.TeleporterTestIn fundedAddress, ) - fmt.Println("Finished sending warp message, closing down output channel") + log.Info("Finished sending warp message, closing down output channel") // Cancel the command and stop the relayer relayerCleanup() // // Try Relaying Already Delivered Message // - fmt.Println("Test Relaying Already Delivered Message") + log.Info("Test Relaying Already Delivered Message") logger := logging.NewLogger( "awm-relayer", logging.NewWrappedCore( @@ -201,7 +150,7 @@ func BasicRelay(network *network.LocalNetwork, teleporter utils.TeleporterTestIn defer sub.Unsubscribe() // Run the relayer - fmt.Println("Creating new relayer instance to test already delivered message") + log.Info("Creating new relayer instance to test already delivered message") relayerCleanup, readyChan /*readyChan*/ = testUtils.RunRelayerExecutable( ctx, relayerConfigPath, @@ -210,20 +159,20 @@ func BasicRelay(network *network.LocalNetwork, teleporter utils.TeleporterTestIn defer relayerCleanup() // Wait for relayer to start up - fmt.Println("Waiting for the relayer to start up") + log.Info("Waiting for the relayer to start up") startupCtx, startupCancel = context.WithTimeout(ctx, 60*time.Second) defer startupCancel() testUtils.WaitForChannelClose(startupCtx, readyChan) // We should not receive a new block on subnet B, since the relayer should have // seen the Teleporter message was already delivered. - fmt.Println("Waiting for 10s to ensure no new block confirmations on destination chain") + log.Info("Waiting for 10s to ensure no new block confirmations on destination chain") Consistently(newHeadsB, 10*time.Second, 500*time.Millisecond).ShouldNot(Receive()) // // Set ProcessHistoricalBlocksFromHeight in config // - fmt.Println("Test Setting ProcessHistoricalBlocksFromHeight in config") + log.Info("Test Setting ProcessHistoricalBlocksFromHeight in config") testUtils.TriggerProcessMissedBlocks( ctx, teleporter, diff --git a/tests/e2e_test.go b/tests/e2e_test.go index 07da354a..64e26f2b 100644 --- a/tests/e2e_test.go +++ b/tests/e2e_test.go @@ -140,6 +140,12 @@ var _ = ginkgo.BeforeSuite(func() { false) } + // Restart the network to attempt to refresh TLS connections + ctx, cancel := context.WithTimeout(context.Background(), time.Duration(60*len(localNetworkInstance.Nodes))*time.Second) + defer cancel() + err = localNetworkInstance.Restart(ctx, os.Stdout) + Expect(err).Should(BeNil()) + decider = exec.CommandContext(ctx, "./tests/cmd/decider/decider") decider.Start() go func() { @@ -175,31 +181,31 @@ func cleanup() { var _ = ginkgo.AfterSuite(cleanup) var _ = ginkgo.Describe("[AWM Relayer Integration Tests", func() { - ginkgo.It("Manually Provided Message", func() { - ManualMessage(localNetworkInstance, teleporterInfo) - }) + // ginkgo.It("Manually Provided Message", func() { + // ManualMessage(localNetworkInstance, teleporterInfo) + // }) ginkgo.It("Basic Relay", func() { BasicRelay(localNetworkInstance, teleporterInfo) }) - ginkgo.It("Shared Database", func() { - SharedDatabaseAccess(localNetworkInstance, teleporterInfo) - }) - ginkgo.It("Allowed Addresses", func() { - AllowedAddresses(localNetworkInstance, teleporterInfo) - }) - ginkgo.It("Batch Message", func() { - BatchRelay(localNetworkInstance, teleporterInfo) - }) - ginkgo.It("Relay Message API", func() { - RelayMessageAPI(localNetworkInstance, teleporterInfo) - }) - ginkgo.It("Warp API", func() { - WarpAPIRelay(localNetworkInstance, teleporterInfo) - }) - ginkgo.It("Signature Aggregator", func() { - SignatureAggregatorAPI(localNetworkInstance, teleporterInfo) - }) - ginkgo.It("Etna Upgrade", func() { - EtnaUpgrade(localNetworkInstance, teleporterInfo) - }) + // ginkgo.It("Shared Database", func() { + // SharedDatabaseAccess(localNetworkInstance, teleporterInfo) + // }) + // ginkgo.It("Allowed Addresses", func() { + // AllowedAddresses(localNetworkInstance, teleporterInfo) + // }) + // ginkgo.It("Batch Message", func() { + // BatchRelay(localNetworkInstance, teleporterInfo) + // }) + // ginkgo.It("Relay Message API", func() { + // RelayMessageAPI(localNetworkInstance, teleporterInfo) + // }) + // ginkgo.It("Warp API", func() { + // WarpAPIRelay(localNetworkInstance, teleporterInfo) + // }) + // ginkgo.It("Signature Aggregator", func() { + // SignatureAggregatorAPI(localNetworkInstance, teleporterInfo) + // }) + // ginkgo.It("Etna Upgrade", func() { + // EtnaUpgrade(localNetworkInstance, teleporterInfo) + // }) }) diff --git a/tests/signature_aggregator_api.go b/tests/signature_aggregator_api.go index 8b275325..f0b56d2b 100644 --- a/tests/signature_aggregator_api.go +++ b/tests/signature_aggregator_api.go @@ -69,7 +69,7 @@ func SignatureAggregatorAPI(network *network.LocalNetwork, teleporter utils.Tele // End setup step // Begin Test Case 1 - log.Info("Sending teleporter message") + log.Info("Sending teleporter message from A -> B") receipt, _, _ := testUtils.SendBasicTeleporterMessage( ctx, teleporter, @@ -122,62 +122,8 @@ func SignatureAggregatorAPI(network *network.LocalNetwork, teleporter utils.Tele sendRequestToAPI() - // Check metrics - // metricsSample := sampleMetrics(signatureAggregatorConfig.MetricsPort) - // for _, m := range []struct { - // name string - // op string - // value int - // }{ - // {metrics.Opts.AggregateSignaturesRequestCount.Name, "==", 1}, - // {metrics.Opts.AggregateSignaturesLatencyMS.Name, ">", 0}, - // {metrics.Opts.AppRequestCount.Name, "<=", 5}, - // {metrics.Opts.FailuresToGetValidatorSet.Name, "==", 0}, - // {metrics.Opts.FailuresToConnectToSufficientStake.Name, "==", 0}, - // {metrics.Opts.FailuresSendingToNode.Name, "<", 5}, - // {metrics.Opts.ValidatorTimeouts.Name, "==", 0}, - // {metrics.Opts.InvalidSignatureResponses.Name, "==", 0}, - // {metrics.Opts.SignatureCacheHits.Name, "==", 0}, - // {metrics.Opts.SignatureCacheMisses.Name, "==", 0}, - // { - // fmt.Sprintf( - // "%s{subnetID=\"%s\"}", - // metrics.Opts.ConnectedStakeWeightPercentage.Name, - // subnetAInfo.SubnetID.String(), - // ), - // "==", - // 100, - // }, - // } { - // Expect(metricsSample[m.name]).Should( - // BeNumerically(m.op, m.value), - // "Expected metric %s %s %d", - // m.name, - // m.op, - // m.value, - // ) - // } - - // // TODONOW: Fix this using the new subnet weights post conversion - // // make a second request, and ensure that the metrics reflect that the - // // signatures for the second request are retrieved from the cache. note - // // that even though 4 signatures were requested in the previous - // // request, only 3 will be cached, because that's all that was required - // // to reach a quorum, so that's all that were handled. - // sendRequestToAPI() - // metricsSample2 := sampleMetrics(signatureAggregatorConfig.MetricsPort) - // Expect( - // metricsSample2[metrics.Opts.AppRequestCount.Name], - // ).Should(Equal(metricsSample[metrics.Opts.AppRequestCount.Name])) - // Expect( - // metricsSample2[metrics.Opts.SignatureCacheHits.Name], - // ).Should(BeNumerically("==", 3)) - // Expect( - // metricsSample2[metrics.Opts.SignatureCacheMisses.Name], - // ).Should(Equal(metricsSample[metrics.Opts.SignatureCacheMisses.Name])) - // Try in the other direction - log.Info("Sending teleporter message") + log.Info("Sending teleporter message from B -> A") receipt, _, _ = testUtils.SendBasicTeleporterMessage( ctx, teleporter, diff --git a/tests/utils/utils.go b/tests/utils/utils.go index 08a094ca..d601afe3 100644 --- a/tests/utils/utils.go +++ b/tests/utils/utils.go @@ -49,7 +49,7 @@ const ( func BuildAllExecutables(ctx context.Context) { cmd := exec.Command("./scripts/build.sh") out, err := cmd.CombinedOutput() - fmt.Println(string(out)) + log.Info(string(out)) Expect(err).Should(BeNil()) } @@ -120,7 +120,6 @@ func CreateDefaultRelayerConfig( if err != nil { logLevel = logging.Info } - logLevel = logging.Debug log.Info( "Setting up relayer config", @@ -229,7 +228,7 @@ func CreateDefaultSignatureAggregatorConfig( ) // Construct the config values for each subnet return signatureaggregatorcfg.Config{ - LogLevel: logging.Verbo.LowerString(), + LogLevel: logLevel.LowerString(), PChainAPI: &config.APIConfig{ BaseURL: sourceSubnetsInfo[0].NodeURIs[0], }, @@ -415,7 +414,7 @@ func WriteRelayerConfig(relayerConfig relayercfg.Config, fname string) string { Expect(err).Should(BeNil()) relayerConfigPath := f.Name() - fmt.Println("Created awm-relayer config", "configPath", relayerConfigPath, "config", string(data)) + log.Info("Created awm-relayer config", "configPath", relayerConfigPath, "config", string(data)) return relayerConfigPath } @@ -549,7 +548,7 @@ func runExecutable( Expect(err).Should(BeNil()) // Start the command - fmt.Println("Starting executable", "appName", appName) + log.Info("Starting executable", "appName", appName) err = cmd.Start() Expect(err).Should(BeNil()) @@ -559,14 +558,14 @@ func runExecutable( go func() { scanner := bufio.NewScanner(cmdStdOutReader) for scanner.Scan() { - fmt.Println(scanner.Text()) + log.Info(scanner.Text()) } cmdOutput <- "Command execution finished" }() go func() { scanner := bufio.NewScanner(cmdStdErrReader) for scanner.Scan() { - fmt.Println(scanner.Text()) + log.Error(scanner.Text()) } cmdOutput <- "Command execution finished" }() @@ -575,18 +574,18 @@ func runExecutable( // Context cancellation is the only expected way for the process to exit, otherwise log an error // Don't panic to allow for easier cleanup if !errors.Is(ctx.Err(), context.Canceled) { - fmt.Println("Executable exited abnormally", "appName", appName, "err", err) + log.Error("Executable exited abnormally", "appName", appName, "err", err) } }() go func() { // wait for health check to report healthy for { resp, err := http.Get(healthCheckUrl) if err == nil && resp.StatusCode == 200 { - fmt.Println("Health check passed", "appName", appName) + log.Info("Health check passed", "appName", appName) close(readyChan) break } - fmt.Println("Health check failed", "appName", appName, "err", err) + log.Info("Health check failed", "appName", appName, "err", err) time.Sleep(time.Second * 1) } }() From 48dcc49d9afbdaf55613ab105f55d7505ee69721 Mon Sep 17 00:00:00 2001 From: cam-schultz Date: Thu, 21 Nov 2024 12:56:30 -0600 Subject: [PATCH 10/28] track subnet on connection --- peers/app_request_network.go | 3 +++ signature-aggregator/aggregator/aggregator.go | 1 - 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/peers/app_request_network.go b/peers/app_request_network.go index e70e70ef..1f964186 100644 --- a/peers/app_request_network.go +++ b/peers/app_request_network.go @@ -287,6 +287,9 @@ func (c *ConnectedCanonicalValidators) GetValidator(nodeID ids.NodeID) (*warp.Va // ConnectToCanonicalValidators connects to the canonical validators of the given subnet and returns the connected // validator information func (n *appRequestNetwork) ConnectToCanonicalValidators(subnetID ids.ID) (*ConnectedCanonicalValidators, error) { + // Track the subnet + n.TrackSubnet(subnetID) + // Get the subnet's current canonical validator set startPChainAPICall := time.Now() validatorSet, totalValidatorWeight, err := n.validatorClient.GetCurrentCanonicalValidatorSet(subnetID) diff --git a/signature-aggregator/aggregator/aggregator.go b/signature-aggregator/aggregator/aggregator.go index c1fb567b..f9e14702 100644 --- a/signature-aggregator/aggregator/aggregator.go +++ b/signature-aggregator/aggregator/aggregator.go @@ -124,7 +124,6 @@ func (s *SignatureAggregator) CreateSignedMessage( } s.logger.Debug("Creating signed message with signing subnet", zap.String("warpMessageID", unsignedMessage.ID().String()), zap.Stringer("signingSubnet", signingSubnet)) - s.network.TrackSubnet(signingSubnet) connectedValidators, err := s.network.ConnectToCanonicalValidators(signingSubnet) if err != nil { msg := "Failed to connect to canonical validators" From 41362e0475eebfb3a18033c365941b8be5b0d66e Mon Sep 17 00:00:00 2001 From: cam-schultz Date: Thu, 21 Nov 2024 12:56:41 -0600 Subject: [PATCH 11/28] enable all tests --- tests/e2e_test.go | 48 +++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/tests/e2e_test.go b/tests/e2e_test.go index 64e26f2b..00bbd396 100644 --- a/tests/e2e_test.go +++ b/tests/e2e_test.go @@ -181,31 +181,31 @@ func cleanup() { var _ = ginkgo.AfterSuite(cleanup) var _ = ginkgo.Describe("[AWM Relayer Integration Tests", func() { - // ginkgo.It("Manually Provided Message", func() { - // ManualMessage(localNetworkInstance, teleporterInfo) - // }) + ginkgo.It("Manually Provided Message", func() { + ManualMessage(localNetworkInstance, teleporterInfo) + }) ginkgo.It("Basic Relay", func() { BasicRelay(localNetworkInstance, teleporterInfo) }) - // ginkgo.It("Shared Database", func() { - // SharedDatabaseAccess(localNetworkInstance, teleporterInfo) - // }) - // ginkgo.It("Allowed Addresses", func() { - // AllowedAddresses(localNetworkInstance, teleporterInfo) - // }) - // ginkgo.It("Batch Message", func() { - // BatchRelay(localNetworkInstance, teleporterInfo) - // }) - // ginkgo.It("Relay Message API", func() { - // RelayMessageAPI(localNetworkInstance, teleporterInfo) - // }) - // ginkgo.It("Warp API", func() { - // WarpAPIRelay(localNetworkInstance, teleporterInfo) - // }) - // ginkgo.It("Signature Aggregator", func() { - // SignatureAggregatorAPI(localNetworkInstance, teleporterInfo) - // }) - // ginkgo.It("Etna Upgrade", func() { - // EtnaUpgrade(localNetworkInstance, teleporterInfo) - // }) + ginkgo.It("Shared Database", func() { + SharedDatabaseAccess(localNetworkInstance, teleporterInfo) + }) + ginkgo.It("Allowed Addresses", func() { + AllowedAddresses(localNetworkInstance, teleporterInfo) + }) + ginkgo.It("Batch Message", func() { + BatchRelay(localNetworkInstance, teleporterInfo) + }) + ginkgo.It("Relay Message API", func() { + RelayMessageAPI(localNetworkInstance, teleporterInfo) + }) + ginkgo.It("Warp API", func() { + WarpAPIRelay(localNetworkInstance, teleporterInfo) + }) + ginkgo.It("Signature Aggregator", func() { + SignatureAggregatorAPI(localNetworkInstance, teleporterInfo) + }) + ginkgo.It("Etna Upgrade", func() { + EtnaUpgrade(localNetworkInstance, teleporterInfo) + }) }) From 4f2a3250eedf4943d951d772f90d37d3b0971128 Mon Sep 17 00:00:00 2001 From: cam-schultz Date: Thu, 21 Nov 2024 15:13:39 -0600 Subject: [PATCH 12/28] fetch validators on new subnet tracked --- peers/app_request_network.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/peers/app_request_network.go b/peers/app_request_network.go index 1f964186..a5842650 100644 --- a/peers/app_request_network.go +++ b/peers/app_request_network.go @@ -199,6 +199,7 @@ func (n *appRequestNetwork) TrackSubnet(subnetID ids.ID) { defer n.lock.Unlock() n.logger.Debug("Tracking subnet", zap.String("subnetID", subnetID.String())) n.trackedSubnets.Add(subnetID) + updateValidatorSet(context.Background(), n.logger, subnetID, n.manager, n.validatorClient) } func (n *appRequestNetwork) startUpdateValidators() { @@ -208,16 +209,16 @@ func (n *appRequestNetwork) startUpdateValidators() { for ; true; <-ticker.C { n.lock.Lock() - updatePrimaryNetworkValidators(context.Background(), n.logger, constants.PrimaryNetworkID, n.manager, n.validatorClient) + updateValidatorSet(context.Background(), n.logger, constants.PrimaryNetworkID, n.manager, n.validatorClient) for _, subnet := range n.trackedSubnets.List() { - updatePrimaryNetworkValidators(context.Background(), n.logger, subnet, n.manager, n.validatorClient) + updateValidatorSet(context.Background(), n.logger, subnet, n.manager, n.validatorClient) } n.lock.Unlock() } }() } -func updatePrimaryNetworkValidators(ctx context.Context, logger logging.Logger, subnetID ids.ID, manager vdrs.Manager, client *validators.CanonicalValidatorClient) error { +func updateValidatorSet(ctx context.Context, logger logging.Logger, subnetID ids.ID, manager vdrs.Manager, client *validators.CanonicalValidatorClient) error { logger.Debug("Fetching validators for subnet ID", zap.Stringer("subnetID", subnetID)) // Fetch the primary network validators from the P-Chain From 3dae643932ee4534ca41ec9814d05998fd0c4a96 Mon Sep 17 00:00:00 2001 From: cam-schultz Date: Fri, 22 Nov 2024 13:39:29 -0600 Subject: [PATCH 13/28] use temp avago workaround branch --- go.mod | 23 ++++++++++------------ go.sum | 36 +++++++++++++++++----------------- scripts/versions.sh | 2 ++ tests/contracts/lib/teleporter | 2 +- 4 files changed, 31 insertions(+), 32 deletions(-) diff --git a/go.mod b/go.mod index a064c223..583fd79c 100644 --- a/go.mod +++ b/go.mod @@ -2,13 +2,10 @@ module github.com/ava-labs/awm-relayer go 1.22.8 -replace ( - github.com/ava-labs/avalanchego => /Users/cameron.schultz/avalanchego - github.com/ava-labs/teleporter => /Users/cameron.schultz/teleporter -) +replace github.com/ava-labs/teleporter => /Users/cameron.schultz/teleporter require ( - github.com/ava-labs/avalanchego v1.12.0-fuji + github.com/ava-labs/avalanchego v1.12.0-initial-poc.9.0.20241122192639-7c3ad181c928 github.com/ava-labs/coreth v0.13.9-rc.1 github.com/ava-labs/subnet-evm v0.6.12 github.com/ava-labs/teleporter v1.0.8-0.20241113215352-fdd3e578a507 @@ -17,7 +14,7 @@ require ( github.com/aws/aws-sdk-go-v2/service/kms v1.37.2 github.com/ethereum/go-ethereum v1.13.14 github.com/hashicorp/golang-lru/v2 v2.0.7 - github.com/onsi/ginkgo/v2 v2.21.0 + github.com/onsi/ginkgo/v2 v2.22.0 github.com/onsi/gomega v1.35.1 github.com/pingcap/errors v0.11.4 github.com/pkg/errors v0.9.1 @@ -29,19 +26,19 @@ require ( go.uber.org/mock v0.5.0 go.uber.org/zap v1.27.0 google.golang.org/grpc v1.68.0 - google.golang.org/protobuf v1.35.1 + google.golang.org/protobuf v1.35.2 ) require ( github.com/google/gofuzz v1.2.0 // indirect github.com/google/pprof v0.0.0-20241029153458-d1b30febd7db // indirect - golang.org/x/net v0.30.0 // indirect + golang.org/x/net v0.31.0 // indirect golang.org/x/oauth2 v0.23.0 // indirect - golang.org/x/sys v0.26.0 // indirect - golang.org/x/term v0.25.0 // indirect - golang.org/x/text v0.19.0 // indirect + golang.org/x/sys v0.27.0 // indirect + golang.org/x/term v0.26.0 // indirect + golang.org/x/text v0.20.0 // indirect golang.org/x/time v0.3.0 // indirect - golang.org/x/tools v0.26.0 // indirect + golang.org/x/tools v0.27.0 // indirect gonum.org/v1/gonum v0.11.0 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20240903143218-8af14fe29dc1 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1 // indirect @@ -175,7 +172,7 @@ require ( go.opentelemetry.io/otel/trace v1.22.0 // indirect go.opentelemetry.io/proto/otlp v1.0.0 // indirect go.uber.org/multierr v1.11.0 // indirect - golang.org/x/crypto v0.28.0 // indirect + golang.org/x/crypto v0.29.0 // indirect golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect diff --git a/go.sum b/go.sum index bdfcbb87..e29983f1 100644 --- a/go.sum +++ b/go.sum @@ -60,10 +60,10 @@ github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156/go.mod h1:Cb/ax github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio= github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs= +github.com/ava-labs/avalanchego v1.12.0-initial-poc.9.0.20241122192639-7c3ad181c928 h1:th+K+wWgAYL/NsrFJyO+/sThLRdEDE0+I4vgbPLoWQQ= +github.com/ava-labs/avalanchego v1.12.0-initial-poc.9.0.20241122192639-7c3ad181c928/go.mod h1:yhD5dpZyStIVbxQ550EDi5w5SL7DQ/xGE6TIxosb7U0= github.com/ava-labs/coreth v0.13.9-rc.1 h1:qIICpC/OZGYUP37QnLgIqqwGmxnLwLpZaUlqJNI85vU= github.com/ava-labs/coreth v0.13.9-rc.1/go.mod h1:7aMsRIo/3GBE44qWZMjnfqdqfcfZ5yShTTm2LObLaYo= -github.com/ava-labs/subnet-evm v0.6.11 h1:XgIAn9ihPyGjrBFD2rXg2H76HFl6htliHabN0fjciaQ= -github.com/ava-labs/subnet-evm v0.6.11/go.mod h1:fP46lzBtiniRfpNH+Qu9BFvSsa02YGkAobxinZ78gDU= github.com/ava-labs/subnet-evm v0.6.12 h1:jL3FmjdFcNfS0qwbehwN6DkAg9y7zexB1riiGBxRsM0= github.com/ava-labs/subnet-evm v0.6.12/go.mod h1:vffwL4UqAh7ibpWjveUuUhamm3a9w75q92bG5vXdX5k= github.com/aws/aws-sdk-go-v2 v1.32.4 h1:S13INUiTxgrPueTmrm5DZ+MiAo99zYzHEFh1UNkOxNE= @@ -521,8 +521,8 @@ github.com/onsi/ginkgo v1.16.4/go.mod h1:dX+/inL/fNMqNlz0e9LfyB9TswhZpCVdJM/Z6Vv github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE= github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU= github.com/onsi/ginkgo/v2 v2.1.3/go.mod h1:vw5CSIxN1JObi/U8gcbwft7ZxR2dgaR70JSE3/PpL4c= -github.com/onsi/ginkgo/v2 v2.21.0 h1:7rg/4f3rB88pb5obDgNZrNHrQ4e6WpjonchcpuBRnZM= -github.com/onsi/ginkgo/v2 v2.21.0/go.mod h1:7Du3c42kxCUegi0IImZ1wUQzMBVecgIHjR1C+NkhLQo= +github.com/onsi/ginkgo/v2 v2.22.0 h1:Yed107/8DjTr0lKCNt7Dn8yQ6ybuDRQoMGrNFKzMfHg= +github.com/onsi/ginkgo/v2 v2.22.0/go.mod h1:7Du3c42kxCUegi0IImZ1wUQzMBVecgIHjR1C+NkhLQo= github.com/onsi/gomega v1.4.1/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= @@ -704,8 +704,8 @@ golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw= -golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U= +golang.org/x/crypto v0.29.0 h1:L5SG1JTTXupVV3n6sUqMTeWbjAyfPwoda2DLX8J8FrQ= +golang.org/x/crypto v0.29.0/go.mod h1:+F4F4N5hv6v38hfeYwTdx20oUvLLc+QfrE9Ax9HtgRg= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -789,8 +789,8 @@ golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qx golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/net v0.0.0-20220607020251-c690dde0001d/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.30.0 h1:AcW1SDZMkb8IpzCdQUaIq2sP4sZ4zw+55h6ynffypl4= -golang.org/x/net v0.30.0/go.mod h1:2wGyMJ5iFasEhkwi13ChkO/t1ECNC4X4eBKkVFyYFlU= +golang.org/x/net v0.31.0 h1:68CPQngjLL0r2AlUKiSxtQFKvzRVbnzLwMUn5SzcLHo= +golang.org/x/net v0.31.0/go.mod h1:P4fl1q7dY2hnZFxEk4pPSkDHF+QqjitcnDjUQyMM+pM= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -882,12 +882,12 @@ golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo= -golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.27.0 h1:wBqf8DvsY9Y/2P8gAfPDEYNuS30J4lPHJxXSb/nJZ+s= +golang.org/x/sys v0.27.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.25.0 h1:WtHI/ltw4NvSUig5KARz9h521QvRC8RmF/cuYqifU24= -golang.org/x/term v0.25.0/go.mod h1:RPyXicDX+6vLxogjjRxjgD2TKtmAO6NZBsBRfrOLu7M= +golang.org/x/term v0.26.0 h1:WEQa6V3Gja/BhNxg540hBip/kkaYtRg3cxg4oXSw4AU= +golang.org/x/term v0.26.0/go.mod h1:Si5m1o57C5nBNQo5z1iq+XDijt21BDBDp2bK0QI8e3E= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -898,8 +898,8 @@ golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= -golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM= -golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= +golang.org/x/text v0.20.0 h1:gK/Kv2otX8gz+wn7Rmb3vT96ZwuoxnQlY+HlJVj7Qug= +golang.org/x/text v0.20.0/go.mod h1:D4IsuqiFMhST5bX19pQ9ikHC2GsaKyk/oF+pn3ducp4= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -961,8 +961,8 @@ golang.org/x/tools v0.0.0-20210108195828-e2f9c7f1fc8e/go.mod h1:emZCQorbCU4vsT4f golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= golang.org/x/tools v0.1.3/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= -golang.org/x/tools v0.26.0 h1:v/60pFQmzmT9ExmjDv2gGIfi3OqfKoEP6I5+umXlbnQ= -golang.org/x/tools v0.26.0/go.mod h1:TPVVj70c7JJ3WCazhD8OdXcZg/og+b9+tH/KxylGwH0= +golang.org/x/tools v0.27.0 h1:qEKojBykQkQ4EynWy4S8Weg69NumxKdn40Fce3uc/8o= +golang.org/x/tools v0.27.0/go.mod h1:sUi0ZgbwW9ZPAq26Ekut+weQPR5eIM6GQLQ1Yjm1H0Q= 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= @@ -1070,8 +1070,8 @@ google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGj google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= 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.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA= -google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= +google.golang.org/protobuf v1.35.2 h1:8Ar7bF+apOIoThw1EdZl0p1oWvMqTHmpA2fRTyZO8io= +google.golang.org/protobuf v1.35.2/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/scripts/versions.sh b/scripts/versions.sh index ceef4a14..eee4d782 100755 --- a/scripts/versions.sh +++ b/scripts/versions.sh @@ -18,6 +18,8 @@ export GO_VERSION=${GO_VERSION:-$(getDepVersion go)} # Don't export them as they're used in the context of other calls AVALANCHEGO_VERSION=${AVALANCHEGO_VERSION:-$(getDepVersion github.com/ava-labs/avalanchego)} +# Temporarily hardcode the Avalanchego version until outbound networking relaxation is available +AVALANCHEGO_VERSION=v1.12.0-fuji GINKGO_VERSION=${GINKGO_VERSION:-$(getDepVersion github.com/onsi/ginkgo/v2)} SUBNET_EVM_VERSION=${SUBNET_EVM_VERSION:-$(getDepVersion github.com/ava-labs/subnet-evm)} diff --git a/tests/contracts/lib/teleporter b/tests/contracts/lib/teleporter index 106a220b..226937a9 160000 --- a/tests/contracts/lib/teleporter +++ b/tests/contracts/lib/teleporter @@ -1 +1 @@ -Subproject commit 106a220b2b5720072cc9dc2fd24be3caec21c015 +Subproject commit 226937a967e8947034f2704de6f168bcf48e2d2b From e74f59bcb2cce152221a488d4c7a531f048aceb4 Mon Sep 17 00:00:00 2001 From: cam-schultz Date: Fri, 22 Nov 2024 13:55:49 -0600 Subject: [PATCH 14/28] remove local teleporter dep --- go.mod | 4 +--- go.sum | 2 ++ 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 583fd79c..7d21c516 100644 --- a/go.mod +++ b/go.mod @@ -2,13 +2,11 @@ module github.com/ava-labs/awm-relayer go 1.22.8 -replace github.com/ava-labs/teleporter => /Users/cameron.schultz/teleporter - require ( github.com/ava-labs/avalanchego v1.12.0-initial-poc.9.0.20241122192639-7c3ad181c928 github.com/ava-labs/coreth v0.13.9-rc.1 github.com/ava-labs/subnet-evm v0.6.12 - github.com/ava-labs/teleporter v1.0.8-0.20241113215352-fdd3e578a507 + github.com/ava-labs/teleporter v1.0.8-0.20241122194201-a6e92843c3b1 github.com/aws/aws-sdk-go-v2 v1.32.4 github.com/aws/aws-sdk-go-v2/config v1.27.9 github.com/aws/aws-sdk-go-v2/service/kms v1.37.2 diff --git a/go.sum b/go.sum index e29983f1..9ca00159 100644 --- a/go.sum +++ b/go.sum @@ -66,6 +66,8 @@ github.com/ava-labs/coreth v0.13.9-rc.1 h1:qIICpC/OZGYUP37QnLgIqqwGmxnLwLpZaUlqJ github.com/ava-labs/coreth v0.13.9-rc.1/go.mod h1:7aMsRIo/3GBE44qWZMjnfqdqfcfZ5yShTTm2LObLaYo= github.com/ava-labs/subnet-evm v0.6.12 h1:jL3FmjdFcNfS0qwbehwN6DkAg9y7zexB1riiGBxRsM0= github.com/ava-labs/subnet-evm v0.6.12/go.mod h1:vffwL4UqAh7ibpWjveUuUhamm3a9w75q92bG5vXdX5k= +github.com/ava-labs/teleporter v1.0.8-0.20241122194201-a6e92843c3b1 h1:y1zjdfGlfTZQoPyUyPjsu9FjDK8w19OWUTpgVzQSh0w= +github.com/ava-labs/teleporter v1.0.8-0.20241122194201-a6e92843c3b1/go.mod h1:45NrpvVlms+xHL/rFZT7VrRJqajT7UUW78lzBe3hAzU= github.com/aws/aws-sdk-go-v2 v1.32.4 h1:S13INUiTxgrPueTmrm5DZ+MiAo99zYzHEFh1UNkOxNE= github.com/aws/aws-sdk-go-v2 v1.32.4/go.mod h1:2SK5n0a2karNTv5tbP1SjsX0uhttou00v/HpXKM1ZUo= github.com/aws/aws-sdk-go-v2/config v1.27.9 h1:gRx/NwpNEFSk+yQlgmk1bmxxvQ5TyJ76CWXs9XScTqg= From 3adfe8a7e82e846022d566120add6f5d382e7f10 Mon Sep 17 00:00:00 2001 From: cam-schultz Date: Fri, 22 Nov 2024 14:30:14 -0600 Subject: [PATCH 15/28] generate mocks & fix test build --- peers/mocks/mock_app_request_network.go | 54 +++++++++---------- .../aggregator/aggregator_test.go | 1 + 2 files changed, 25 insertions(+), 30 deletions(-) diff --git a/peers/mocks/mock_app_request_network.go b/peers/mocks/mock_app_request_network.go index a28ec520..d9bcd991 100644 --- a/peers/mocks/mock_app_request_network.go +++ b/peers/mocks/mock_app_request_network.go @@ -11,7 +11,6 @@ package mocks import ( reflect "reflect" - time "time" ids "github.com/ava-labs/avalanchego/ids" message "github.com/ava-labs/avalanchego/message" @@ -45,20 +44,6 @@ func (m *MockAppRequestNetwork) EXPECT() *MockAppRequestNetworkMockRecorder { return m.recorder } -// ConnectPeers mocks base method. -func (m *MockAppRequestNetwork) ConnectPeers(nodeIDs set.Set[ids.NodeID]) set.Set[ids.NodeID] { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "ConnectPeers", nodeIDs) - ret0, _ := ret[0].(set.Set[ids.NodeID]) - return ret0 -} - -// ConnectPeers indicates an expected call of ConnectPeers. -func (mr *MockAppRequestNetworkMockRecorder) ConnectPeers(nodeIDs any) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ConnectPeers", reflect.TypeOf((*MockAppRequestNetwork)(nil).ConnectPeers), nodeIDs) -} - // ConnectToCanonicalValidators mocks base method. func (m *MockAppRequestNetwork) ConnectToCanonicalValidators(subnetID ids.ID) (*peers.ConnectedCanonicalValidators, error) { m.ctrl.T.Helper() @@ -89,21 +74,6 @@ func (mr *MockAppRequestNetworkMockRecorder) GetSubnetID(blockchainID any) *gomo return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetSubnetID", reflect.TypeOf((*MockAppRequestNetwork)(nil).GetSubnetID), blockchainID) } -// Message mocks base method. -func (m *MockAppRequestNetwork) Message(sourceChainID ids.ID, requestID uint32, timeout time.Duration, request []byte) (message.OutboundMessage, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Message", sourceChainID, requestID, timeout, request) - ret0, _ := ret[0].(message.OutboundMessage) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// Message indicates an expected call of Message. -func (mr *MockAppRequestNetworkMockRecorder) Message(sourceChainID, requestID, timeout, request any) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Message", reflect.TypeOf((*MockAppRequestNetwork)(nil).Message), sourceChainID, requestID, timeout, request) -} - // RegisterAppRequest mocks base method. func (m *MockAppRequestNetwork) RegisterAppRequest(requestID ids.RequestID) { m.ctrl.T.Helper() @@ -143,3 +113,27 @@ func (mr *MockAppRequestNetworkMockRecorder) Send(msg, nodeIDs, subnetID, allowe mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Send", reflect.TypeOf((*MockAppRequestNetwork)(nil).Send), msg, nodeIDs, subnetID, allower) } + +// Shutdown mocks base method. +func (m *MockAppRequestNetwork) Shutdown() { + m.ctrl.T.Helper() + m.ctrl.Call(m, "Shutdown") +} + +// Shutdown indicates an expected call of Shutdown. +func (mr *MockAppRequestNetworkMockRecorder) Shutdown() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Shutdown", reflect.TypeOf((*MockAppRequestNetwork)(nil).Shutdown)) +} + +// TrackSubnet mocks base method. +func (m *MockAppRequestNetwork) TrackSubnet(subnetID ids.ID) { + m.ctrl.T.Helper() + m.ctrl.Call(m, "TrackSubnet", subnetID) +} + +// TrackSubnet indicates an expected call of TrackSubnet. +func (mr *MockAppRequestNetworkMockRecorder) TrackSubnet(subnetID any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "TrackSubnet", reflect.TypeOf((*MockAppRequestNetwork)(nil).TrackSubnet), subnetID) +} diff --git a/signature-aggregator/aggregator/aggregator_test.go b/signature-aggregator/aggregator/aggregator_test.go index c99efbd5..22647baa 100644 --- a/signature-aggregator/aggregator/aggregator_test.go +++ b/signature-aggregator/aggregator/aggregator_test.go @@ -64,6 +64,7 @@ func instantiateAggregator(t *testing.T) ( ), ), ), + messageCreator, 1024, sigAggMetrics, // Setting the etnaTime to a minute ago so that the post-etna code path is used in the test From 69c93e2a49f4438b019416a5f1160ce0bab88b2d Mon Sep 17 00:00:00 2001 From: cam-schultz Date: Fri, 22 Nov 2024 14:42:45 -0600 Subject: [PATCH 16/28] lint --- database/json_file_storage.go | 7 ++- peers/app_request_network.go | 24 +++++--- relayer/application_relayer.go | 8 ++- relayer/message_coordinator.go | 42 ++++++++------ signature-aggregator/aggregator/aggregator.go | 6 +- tests/signature_aggregator_api.go | 58 ------------------- 6 files changed, 60 insertions(+), 85 deletions(-) diff --git a/database/json_file_storage.go b/database/json_file_storage.go index e1916f60..f5785543 100644 --- a/database/json_file_storage.go +++ b/database/json_file_storage.go @@ -125,7 +125,12 @@ func (s *JSONFileStorage) getCurrentState(relayerID common.Hash) (chainState, bo // Put the value into the JSON database. Read the current chain state and overwrite the key, if it exists // If the file corresponding to {relayerID} does not exist, then it will be created func (s *JSONFileStorage) Put(relayerID common.Hash, dataKey DataKey, value []byte) error { - s.logger.Debug("db put", zap.Stringer("relayerID", relayerID), zap.Stringer("key", dataKey), zap.String("value", string(value))) + s.logger.Debug( + "db put", + zap.Stringer("relayerID", relayerID), + zap.Stringer("key", dataKey), + zap.String("value", string(value)), + ) mutex, ok := s.mutexes[relayerID] if !ok { return errors.Wrap( diff --git a/peers/app_request_network.go b/peers/app_request_network.go index a5842650..fe90af17 100644 --- a/peers/app_request_network.go +++ b/peers/app_request_network.go @@ -134,7 +134,11 @@ func NewNetwork( } for _, peer := range manuallyTrackedPeers { - logger.Info("Manually Tracking peer (startup)", zap.String("ID", peer.ID.String()), zap.String("IP", peer.PublicIP.String())) + logger.Info( + "Manually Tracking peer (startup)", + zap.String("ID", peer.ID.String()), + zap.String("IP", peer.PublicIP.String()), + ) testNetwork.ManuallyTrack(peer.ID, peer.PublicIP) } @@ -158,7 +162,11 @@ func NewNetwork( if len(vdrs) == 0 { continue } - logger.Info("Manually tracking bootstrap node", zap.String("ID", peer.ID.String()), zap.String("IP", peer.PublicIP.String())) + logger.Info( + "Manually tracking bootstrap node", + zap.String("ID", peer.ID.String()), + zap.String("IP", peer.PublicIP.String()), + ) testNetwork.ManuallyTrack(peer.ID, peer.PublicIP) numConnected++ if numConnected >= NumBootstrapNodes { @@ -218,7 +226,13 @@ func (n *appRequestNetwork) startUpdateValidators() { }() } -func updateValidatorSet(ctx context.Context, logger logging.Logger, subnetID ids.ID, manager vdrs.Manager, client *validators.CanonicalValidatorClient) error { +func updateValidatorSet( + ctx context.Context, + logger logging.Logger, + subnetID ids.ID, + manager vdrs.Manager, + client *validators.CanonicalValidatorClient, +) error { logger.Debug("Fetching validators for subnet ID", zap.Stringer("subnetID", subnetID)) // Fetch the primary network validators from the P-Chain @@ -345,10 +359,6 @@ func (n *appRequestNetwork) GetSubnetID(blockchainID ids.ID) (ids.ID, error) { // Metrics // -func (n *appRequestNetwork) setInfoAPICallLatencyMS(latency float64) { - n.metrics.infoAPICallLatencyMS.Observe(latency) -} - func (n *appRequestNetwork) setPChainAPICallLatencyMS(latency float64) { n.metrics.pChainAPICallLatencyMS.Observe(latency) } diff --git a/relayer/application_relayer.go b/relayer/application_relayer.go index 5e41602e..847215f1 100644 --- a/relayer/application_relayer.go +++ b/relayer/application_relayer.go @@ -147,7 +147,13 @@ func (r *ApplicationRelayer) ProcessHeight( handlers []messages.MessageHandler, errChan chan error, ) { - r.logger.Debug("Processing block", zap.Uint64("height", height), zap.String("relayerID", r.relayerID.ID.String()), zap.Stringer("blockchainID", r.relayerID.SourceBlockchainID), zap.Int("numMessages", len(handlers))) + r.logger.Debug( + "Processing block", + zap.Uint64("height", height), + zap.Stringer("relayerID", r.relayerID.ID), + zap.Stringer("blockchainID", r.relayerID.SourceBlockchainID), + zap.Int("numMessages", len(handlers)), + ) var eg errgroup.Group for _, handler := range handlers { eg.Go(func() error { diff --git a/relayer/message_coordinator.go b/relayer/message_coordinator.go index f91f4edc..04dde0ec 100644 --- a/relayer/message_coordinator.go +++ b/relayer/message_coordinator.go @@ -66,7 +66,7 @@ func (mc *MessageCoordinator) getAppRelayerMessageHandler( // than just the ones supported by a single listener instance. mc.logger.Debug( "Warp message from unsupported message protocol address. Not relaying.", - zap.String("protocolAddress", warpMessageInfo.SourceAddress.Hex()), + zap.Stringer("protocolAddress", warpMessageInfo.SourceAddress), ) return nil, nil, nil } @@ -86,11 +86,11 @@ func (mc *MessageCoordinator) getAppRelayerMessageHandler( mc.logger.Info( "Unpacked warp message", - zap.String("sourceBlockchainID", sourceBlockchainID.String()), - zap.String("originSenderAddress", originSenderAddress.String()), - zap.String("destinationBlockchainID", destinationBlockchainID.String()), - zap.String("destinationAddress", destinationAddress.String()), - zap.String("warpMessageID", warpMessageInfo.UnsignedMessage.ID().String()), + zap.Stringer("sourceBlockchainID", sourceBlockchainID), + zap.Stringer("originSenderAddress", originSenderAddress), + zap.Stringer("destinationBlockchainID", destinationBlockchainID), + zap.Stringer("destinationAddress", destinationAddress), + zap.Stringer("warpMessageID", warpMessageInfo.UnsignedMessage.ID()), ) appRelayer := mc.getApplicationRelayer( @@ -168,10 +168,10 @@ func (mc *MessageCoordinator) getApplicationRelayer( } mc.logger.Debug( "Application relayer not found. Skipping message relay.", - zap.String("blockchainID", sourceBlockchainID.String()), - zap.String("destinationBlockchainID", destinationBlockchainID.String()), - zap.String("originSenderAddress", originSenderAddress.String()), - zap.String("destinationAddress", destinationAddress.String()), + zap.Stringer("blockchainID", sourceBlockchainID), + zap.Stringer("destinationBlockchainID", destinationBlockchainID), + zap.Stringer("originSenderAddress", originSenderAddress), + zap.Stringer("destinationAddress", destinationAddress), ) return nil } @@ -182,7 +182,7 @@ func (mc *MessageCoordinator) ProcessWarpMessage(warpMessage *relayerTypes.WarpM mc.logger.Error( "Failed to parse Warp message.", zap.Error(err), - zap.String("warpMessageID", warpMessage.UnsignedMessage.ID().String()), + zap.Stringer("warpMessageID", warpMessage.UnsignedMessage.ID()), ) return common.Hash{}, err } @@ -203,7 +203,7 @@ func (mc *MessageCoordinator) ProcessMessageID( if !ok { mc.logger.Error( "Source client not found", - zap.String("blockchainID", blockchainID.String()), + zap.Stringer("blockchainID", blockchainID), ) return common.Hash{}, fmt.Errorf("source client not set for blockchain: %s", blockchainID.String()) } @@ -212,7 +212,7 @@ func (mc *MessageCoordinator) ProcessMessageID( if err != nil { mc.logger.Error( "Failed to fetch warp from blockchain", - zap.String("blockchainID", blockchainID.String()), + zap.Stringer("blockchainID", blockchainID), zap.Error(err), ) return common.Hash{}, fmt.Errorf("could not fetch warp message from ID: %w", err) @@ -228,7 +228,11 @@ func (mc *MessageCoordinator) ProcessBlock( ethClient ethclient.Client, errChan chan error, ) { - mc.logger.Debug("Processing block", zap.Uint64("blockNumber", blockHeader.Number.Uint64()), zap.String("blockchainID", blockchainID.String())) + mc.logger.Debug( + "Processing block", + zap.Uint64("blockNumber", blockHeader.Number.Uint64()), + zap.Stringer("blockchainID", blockchainID), + ) // Parse the logs in the block, and group by application relayer block, err := relayerTypes.NewWarpBlockInfo(blockHeader, ethClient) if err != nil { @@ -244,8 +248,8 @@ func (mc *MessageCoordinator) ProcessBlock( if err != nil { mc.logger.Error( "Failed to parse message", - zap.String("blockchainID", warpLogInfo.UnsignedMessage.SourceChainID.String()), - zap.String("protocolAddress", warpLogInfo.SourceAddress.String()), + zap.Stringer("blockchainID", warpLogInfo.UnsignedMessage.SourceChainID), + zap.Stringer("protocolAddress", warpLogInfo.SourceAddress), zap.Error(err), ) continue @@ -264,7 +268,11 @@ func (mc *MessageCoordinator) ProcessBlock( // Dispatch all messages in the block to the appropriate application relayer. // An empty slice is still a valid argument to ProcessHeight; in this case the height is immediately committed. handlers := messageHandlers[appRelayer.relayerID.ID] - mc.logger.Debug("Dispatching to app relayer", zap.String("relayerID", appRelayer.relayerID.ID.String()), zap.Int("numMessages", len(handlers))) + mc.logger.Debug( + "Dispatching to app relayer", + zap.Stringer("relayerID", appRelayer.relayerID.ID), + zap.Int("numMessages", len(handlers)), + ) go appRelayer.ProcessHeight(block.BlockNumber, handlers, errChan) } } diff --git a/signature-aggregator/aggregator/aggregator.go b/signature-aggregator/aggregator/aggregator.go index 926caf8d..17820f13 100644 --- a/signature-aggregator/aggregator/aggregator.go +++ b/signature-aggregator/aggregator/aggregator.go @@ -122,7 +122,11 @@ func (s *SignatureAggregator) CreateSignedMessage( } else { signingSubnet = inputSigningSubnet } - s.logger.Debug("Creating signed message with signing subnet", zap.String("warpMessageID", unsignedMessage.ID().String()), zap.Stringer("signingSubnet", signingSubnet)) + s.logger.Debug( + "Creating signed message with signing subnet", + zap.String("warpMessageID", unsignedMessage.ID().String()), + zap.Stringer("signingSubnet", signingSubnet), + ) connectedValidators, err := s.network.ConnectToCanonicalValidators(signingSubnet) if err != nil { diff --git a/tests/signature_aggregator_api.go b/tests/signature_aggregator_api.go index f3a099a4..98709676 100644 --- a/tests/signature_aggregator_api.go +++ b/tests/signature_aggregator_api.go @@ -4,7 +4,6 @@ package tests import ( - "bufio" "bytes" "context" "encoding/hex" @@ -12,13 +11,10 @@ import ( "fmt" "io" "net/http" - "strconv" - "strings" "time" avalancheWarp "github.com/ava-labs/avalanchego/vms/platformvm/warp" "github.com/ava-labs/awm-relayer/signature-aggregator/api" - "github.com/ava-labs/awm-relayer/signature-aggregator/metrics" testUtils "github.com/ava-labs/awm-relayer/tests/utils" "github.com/ava-labs/teleporter/tests/interfaces" "github.com/ava-labs/teleporter/tests/network" @@ -139,57 +135,3 @@ func SignatureAggregatorAPI(network *network.LocalNetwork, teleporter utils.Tele } sendRequestToAPI() } - -// returns a map of metric names to metric samples -func sampleMetrics(port uint16) map[string]uint64 { - resp, err := http.Get( - fmt.Sprintf("http://localhost:%d/metrics", port), - ) - Expect(err).Should(BeNil()) - - body, err := io.ReadAll(resp.Body) - Expect(err).Should(BeNil()) - defer resp.Body.Close() - - var samples = make(map[string]uint64) - scanner := bufio.NewScanner(strings.NewReader(string(body))) - for scanner.Scan() { - line := scanner.Text() - for _, metricName := range []string{ - metrics.Opts.AggregateSignaturesLatencyMS.Name, - metrics.Opts.AggregateSignaturesRequestCount.Name, - metrics.Opts.AppRequestCount.Name, - metrics.Opts.FailuresToGetValidatorSet.Name, - metrics.Opts.FailuresToConnectToSufficientStake.Name, - metrics.Opts.FailuresSendingToNode.Name, - metrics.Opts.ValidatorTimeouts.Name, - metrics.Opts.InvalidSignatureResponses.Name, - metrics.Opts.SignatureCacheHits.Name, - metrics.Opts.SignatureCacheMisses.Name, - metrics.Opts.ConnectedStakeWeightPercentage.Name, - } { - if strings.HasPrefix( - line, - "U__signature_2d_aggregator_"+metricName, - ) { - log.Debug("Found metric line", "line", line) - parts := strings.Fields(line) - - metricName = strings.Replace(parts[0], "U__signature_2d_aggregator_", "", 1) - - // Parse the metric count from the last field of the line - value, err := strconv.ParseUint(parts[len(parts)-1], 10, 64) - if err != nil { - log.Warn("failed to parse value from metric line") - continue - } - log.Debug("parsed metric", "name", metricName, "value", value) - - samples[metricName] = value - } else { - log.Debug("Ignoring non-metric line", "line", line) - } - } - } - return samples -} From 03485e1bf56a2cc2d89cbf5714fd5544882b9675 Mon Sep 17 00:00:00 2001 From: cam-schultz Date: Fri, 22 Nov 2024 14:43:00 -0600 Subject: [PATCH 17/28] remove info api metrics --- peers/app_request_network_metrics.go | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/peers/app_request_network_metrics.go b/peers/app_request_network_metrics.go index b585533e..3319bda9 100644 --- a/peers/app_request_network_metrics.go +++ b/peers/app_request_network_metrics.go @@ -11,25 +11,12 @@ var ( ) type AppRequestNetworkMetrics struct { - infoAPICallLatencyMS prometheus.Histogram pChainAPICallLatencyMS prometheus.Histogram connects prometheus.Counter disconnects prometheus.Counter } func newAppRequestNetworkMetrics(registerer prometheus.Registerer) (*AppRequestNetworkMetrics, error) { - infoAPICallLatencyMS := prometheus.NewHistogram( - prometheus.HistogramOpts{ - Name: "info_api_call_latency_ms", - Help: "Latency of calling info api in milliseconds", - Buckets: prometheus.ExponentialBucketsRange(100, 10000, 10), - }, - ) - if infoAPICallLatencyMS == nil { - return nil, ErrFailedToCreateAppRequestNetworkMetrics - } - registerer.MustRegister(infoAPICallLatencyMS) - pChainAPICallLatencyMS := prometheus.NewHistogram( prometheus.HistogramOpts{ Name: "p_chain_api_call_latency_ms", @@ -65,7 +52,6 @@ func newAppRequestNetworkMetrics(registerer prometheus.Registerer) (*AppRequestN registerer.MustRegister(disconnects) return &AppRequestNetworkMetrics{ - infoAPICallLatencyMS: infoAPICallLatencyMS, pChainAPICallLatencyMS: pChainAPICallLatencyMS, connects: connects, disconnects: disconnects, From 6ddba1f7f3028f18fed86d5d8633e55b273586e4 Mon Sep 17 00:00:00 2001 From: cam-schultz Date: Mon, 25 Nov 2024 09:42:50 -0600 Subject: [PATCH 18/28] remove test artifacts --- peers/external_handler.go | 2 +- tests/basic_relay.go | 6 ++---- tests/contracts/lib/teleporter | 2 +- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/peers/external_handler.go b/peers/external_handler.go index 2c0c686e..0f82bf9e 100644 --- a/peers/external_handler.go +++ b/peers/external_handler.go @@ -101,7 +101,7 @@ func (h *RelayerExternalHandler) HandleInbound(_ context.Context, inboundMessage } func (h *RelayerExternalHandler) Connected(nodeID ids.NodeID, version *version.Application, subnetID ids.ID) { - h.log.Info( + h.log.Debug( "Connected", zap.Stringer("nodeID", nodeID), zap.Stringer("version", version), diff --git a/tests/basic_relay.go b/tests/basic_relay.go index 2d0c0281..1de207a8 100644 --- a/tests/basic_relay.go +++ b/tests/basic_relay.go @@ -64,7 +64,7 @@ func BasicRelay(network *network.LocalNetwork, teleporter utils.TeleporterTestIn log.Info("Test Relaying from Subnet A to Subnet B") log.Info("Starting the relayer") - relayerCleanup, readyChan /*readyChan*/ := testUtils.RunRelayerExecutable( + relayerCleanup, readyChan := testUtils.RunRelayerExecutable( ctx, relayerConfigPath, relayerConfig, @@ -86,8 +86,6 @@ func BasicRelay(network *network.LocalNetwork, teleporter utils.TeleporterTestIn fundedAddress, ) - time.Sleep(10 * time.Second) - // // Test Relaying from Subnet B to Subnet A // @@ -151,7 +149,7 @@ func BasicRelay(network *network.LocalNetwork, teleporter utils.TeleporterTestIn // Run the relayer log.Info("Creating new relayer instance to test already delivered message") - relayerCleanup, readyChan /*readyChan*/ = testUtils.RunRelayerExecutable( + relayerCleanup, readyChan = testUtils.RunRelayerExecutable( ctx, relayerConfigPath, relayerConfig, diff --git a/tests/contracts/lib/teleporter b/tests/contracts/lib/teleporter index 226937a9..a6e92843 160000 --- a/tests/contracts/lib/teleporter +++ b/tests/contracts/lib/teleporter @@ -1 +1 @@ -Subproject commit 226937a967e8947034f2704de6f168bcf48e2d2b +Subproject commit a6e92843c3b13eef1e813fd898d9a44a2da6a2a0 From 0c51ebd51c48c94c2160db54d0d8858597b89065 Mon Sep 17 00:00:00 2001 From: cam-schultz Date: Mon, 25 Nov 2024 15:12:28 -0600 Subject: [PATCH 19/28] add lock helper --- peers/app_request_network.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/peers/app_request_network.go b/peers/app_request_network.go index fe90af17..6a548de8 100644 --- a/peers/app_request_network.go +++ b/peers/app_request_network.go @@ -195,13 +195,17 @@ func NewNetwork( return arNetwork, nil } -func (n *appRequestNetwork) TrackSubnet(subnetID ids.ID) { +// Helper to scope read lock acquisition +func (n *appRequestNetwork) containsSubnet(subnetID ids.ID) bool { n.lock.RLock() - if n.trackedSubnets.Contains(subnetID) { - n.lock.RUnlock() + defer n.lock.RUnlock() + return n.trackedSubnets.Contains(subnetID) +} + +func (n *appRequestNetwork) TrackSubnet(subnetID ids.ID) { + if n.containsSubnet(subnetID) { return } - n.lock.RUnlock() n.lock.Lock() defer n.lock.Unlock() From 94fb5d5cba2b2e307072b058bed260dae341ebfa Mon Sep 17 00:00:00 2001 From: cam-schultz Date: Mon, 25 Nov 2024 15:17:15 -0600 Subject: [PATCH 20/28] reduce log level --- peers/app_request_network.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/peers/app_request_network.go b/peers/app_request_network.go index 6a548de8..8b8cadb7 100644 --- a/peers/app_request_network.go +++ b/peers/app_request_network.go @@ -90,7 +90,7 @@ func NewNetwork( metrics, err := newAppRequestNetworkMetrics(registerer) if err != nil { - logger.Fatal("Failed to create app request network metrics", zap.Error(err)) + logger.Error("Failed to create app request network metrics", zap.Error(err)) return nil, err } From dec5f93a523ec8fda18cafcea2a28f1f8fddb69c Mon Sep 17 00:00:00 2001 From: cam-schultz Date: Mon, 25 Nov 2024 15:23:35 -0600 Subject: [PATCH 21/28] updateValidatorSet appRequestNetwork method --- peers/app_request_network.go | 39 ++++++++++++++++-------------------- 1 file changed, 17 insertions(+), 22 deletions(-) diff --git a/peers/app_request_network.go b/peers/app_request_network.go index 8b8cadb7..822e0bcc 100644 --- a/peers/app_request_network.go +++ b/peers/app_request_network.go @@ -207,11 +207,9 @@ func (n *appRequestNetwork) TrackSubnet(subnetID ids.ID) { return } - n.lock.Lock() - defer n.lock.Unlock() n.logger.Debug("Tracking subnet", zap.String("subnetID", subnetID.String())) n.trackedSubnets.Add(subnetID) - updateValidatorSet(context.Background(), n.logger, subnetID, n.manager, n.validatorClient) + n.updateValidatorSet(context.Background(), subnetID) } func (n *appRequestNetwork) startUpdateValidators() { @@ -219,32 +217,29 @@ func (n *appRequestNetwork) startUpdateValidators() { // Fetch validators immediately when called, and refresh every ValidatorRefreshPeriod ticker := time.NewTicker(ValidatorRefreshPeriod) for ; true; <-ticker.C { - n.lock.Lock() - - updateValidatorSet(context.Background(), n.logger, constants.PrimaryNetworkID, n.manager, n.validatorClient) + n.updateValidatorSet(context.Background(), constants.PrimaryNetworkID) for _, subnet := range n.trackedSubnets.List() { - updateValidatorSet(context.Background(), n.logger, subnet, n.manager, n.validatorClient) + n.updateValidatorSet(context.Background(), subnet) } - n.lock.Unlock() } }() } -func updateValidatorSet( +func (n *appRequestNetwork) updateValidatorSet( ctx context.Context, - logger logging.Logger, subnetID ids.ID, - manager vdrs.Manager, - client *validators.CanonicalValidatorClient, ) error { - logger.Debug("Fetching validators for subnet ID", zap.Stringer("subnetID", subnetID)) + n.lock.Lock() + defer n.lock.Unlock() + + n.logger.Debug("Fetching validators for subnet ID", zap.Stringer("subnetID", subnetID)) // Fetch the primary network validators from the P-Chain - height, err := client.GetCurrentHeight(ctx) + height, err := n.validatorClient.GetCurrentHeight(ctx) if err != nil { return err } - validators, err := client.GetValidatorSet(ctx, height, subnetID) + validators, err := n.validatorClient.GetValidatorSet(ctx, height, subnetID) if err != nil { return err } @@ -255,12 +250,12 @@ func updateValidatorSet( } // Remove any elements from the manager that are not in the new validator set - currentVdrs := manager.GetValidatorIDs(subnetID) + currentVdrs := n.manager.GetValidatorIDs(subnetID) for _, nodeID := range currentVdrs { if _, ok := validatorsMap[nodeID]; !ok { - logger.Debug("Removing validator", zap.Stringer("nodeID", nodeID), zap.Stringer("subnetID", subnetID)) - weight := manager.GetWeight(subnetID, nodeID) - if err := manager.RemoveWeight(subnetID, nodeID, weight); err != nil { + n.logger.Debug("Removing validator", zap.Stringer("nodeID", nodeID), zap.Stringer("subnetID", subnetID)) + weight := n.manager.GetWeight(subnetID, nodeID) + if err := n.manager.RemoveWeight(subnetID, nodeID, weight); err != nil { return err } } @@ -268,9 +263,9 @@ func updateValidatorSet( // Add any elements from the new validator set that are not in the manager for _, vdr := range validators { - if _, ok := manager.GetValidator(subnetID, vdr.NodeID); !ok { - logger.Debug("Adding validator", zap.Stringer("nodeID", vdr.NodeID), zap.Stringer("subnetID", subnetID)) - if err := manager.AddStaker( + if _, ok := n.manager.GetValidator(subnetID, vdr.NodeID); !ok { + n.logger.Debug("Adding validator", zap.Stringer("nodeID", vdr.NodeID), zap.Stringer("subnetID", subnetID)) + if err := n.manager.AddStaker( subnetID, vdr.NodeID, vdr.PublicKey, From 0d38d51101d83b311e6c916f1f944cdfa9f75945 Mon Sep 17 00:00:00 2001 From: cam-schultz Date: Mon, 25 Nov 2024 15:24:59 -0600 Subject: [PATCH 22/28] organize go.mod --- go.mod | 38 ++++++++++++++++---------------------- 1 file changed, 16 insertions(+), 22 deletions(-) diff --git a/go.mod b/go.mod index 87ea3d91..3720d705 100644 --- a/go.mod +++ b/go.mod @@ -3,6 +3,7 @@ module github.com/ava-labs/awm-relayer go 1.22.8 require ( + github.com/alexliesenfeld/health v0.8.0 github.com/ava-labs/avalanchego v1.12.0-initial-poc.9.0.20241122192639-7c3ad181c928 github.com/ava-labs/coreth v0.13.9-rc.1 github.com/ava-labs/subnet-evm v0.6.12 @@ -21,27 +22,14 @@ require ( github.com/spf13/pflag v1.0.5 github.com/spf13/viper v1.16.0 github.com/stretchr/testify v1.9.0 + go.uber.org/atomic v1.11.0 go.uber.org/mock v0.5.0 go.uber.org/zap v1.27.0 + golang.org/x/sync v0.9.0 google.golang.org/grpc v1.68.0 google.golang.org/protobuf v1.35.2 ) -require ( - github.com/google/gofuzz v1.2.0 // indirect - github.com/google/pprof v0.0.0-20241029153458-d1b30febd7db // indirect - golang.org/x/net v0.31.0 // indirect - golang.org/x/oauth2 v0.23.0 // indirect - golang.org/x/sys v0.27.0 // indirect - golang.org/x/term v0.26.0 // indirect - golang.org/x/time v0.3.0 // indirect - golang.org/x/tools v0.27.0 // indirect - gonum.org/v1/gonum v0.11.0 // indirect - google.golang.org/genproto/googleapis/api v0.0.0-20240903143218-8af14fe29dc1 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1 // indirect - gopkg.in/inf.v0 v0.9.1 // indirect -) - require ( github.com/DataDog/zstd v1.5.2 // indirect github.com/NYTimes/gziphandler v1.1.1 // indirect @@ -100,12 +88,15 @@ require ( github.com/google/btree v1.1.2 // indirect github.com/google/gnostic-models v0.6.8 // indirect github.com/google/go-cmp v0.6.0 // indirect + github.com/google/gofuzz v1.2.0 // indirect + github.com/google/pprof v0.0.0-20241029153458-d1b30febd7db // indirect github.com/google/renameio/v2 v2.0.0 // indirect github.com/google/uuid v1.6.0 // indirect github.com/gorilla/mux v1.8.0 // indirect github.com/gorilla/rpc v1.2.0 // indirect github.com/gorilla/websocket v1.5.0 // indirect github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 // indirect + github.com/grpc-ecosystem/grpc-gateway/v2 v2.18.0 // indirect github.com/hashicorp/go-bexpr v0.1.10 // indirect github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d // indirect github.com/hashicorp/hcl v1.0.0 // indirect @@ -171,7 +162,17 @@ require ( go.uber.org/multierr v1.11.0 // indirect golang.org/x/crypto v0.29.0 // indirect golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 // indirect + golang.org/x/net v0.31.0 // indirect + golang.org/x/oauth2 v0.23.0 // indirect + golang.org/x/sys v0.27.0 // indirect + golang.org/x/term v0.26.0 // indirect golang.org/x/text v0.20.0 // indirect + golang.org/x/time v0.3.0 // indirect + golang.org/x/tools v0.27.0 // indirect + gonum.org/v1/gonum v0.11.0 // indirect + google.golang.org/genproto/googleapis/api v0.0.0-20240903143218-8af14fe29dc1 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1 // indirect + gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect @@ -187,10 +188,3 @@ require ( sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect sigs.k8s.io/yaml v1.3.0 // indirect ) - -require ( - github.com/alexliesenfeld/health v0.8.0 - github.com/grpc-ecosystem/grpc-gateway/v2 v2.18.0 // indirect - go.uber.org/atomic v1.11.0 - golang.org/x/sync v0.9.0 -) From 98cc1bc3209f73cfb71e67004cb5003ba5488c6a Mon Sep 17 00:00:00 2001 From: cam-schultz Date: Mon, 25 Nov 2024 15:32:14 -0600 Subject: [PATCH 23/28] warn not enough bootstrap nodes --- peers/app_request_network.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/peers/app_request_network.go b/peers/app_request_network.go index 822e0bcc..78d85942 100644 --- a/peers/app_request_network.go +++ b/peers/app_request_network.go @@ -153,10 +153,11 @@ func NewNetwork( } pClient := platformvm.NewClient(cfg.GetPChainAPI().BaseURL) numConnected := 0 - for _, peer := range peers { + for i, peer := range peers { vdrs, err := pClient.GetCurrentValidators(context.Background(), constants.PrimaryNetworkID, []ids.NodeID{peer.ID}) if err != nil { - panic(err) + logger.Error("Failed to get current validators", zap.Error(err)) + return nil, err } // Only track the peer if it is a primary network validator if len(vdrs) == 0 { @@ -172,6 +173,14 @@ func NewNetwork( if numConnected >= NumBootstrapNodes { break } + if i == len(peers)-1 { + logger.Warn( + "Failed to connect to enough bootstrap nodes", + zap.Int("targetBootstrapNodes", NumBootstrapNodes), + zap.Int("numAvailablePeers", len(peers)), + zap.Int("connectedBootstrapNodes", numConnected), + ) + } } go logger.RecoverAndPanic(func() { From fc45025268dfdc1f974f07c0cae02b715d7c6a21 Mon Sep 17 00:00:00 2001 From: cam-schultz Date: Mon, 25 Nov 2024 17:11:30 -0600 Subject: [PATCH 24/28] better bootstrap node sampling --- peers/app_request_network.go | 55 +++++++++++++++++++++--------------- 1 file changed, 33 insertions(+), 22 deletions(-) diff --git a/peers/app_request_network.go b/peers/app_request_network.go index 78d85942..8795d280 100644 --- a/peers/app_request_network.go +++ b/peers/app_request_network.go @@ -8,6 +8,7 @@ package peers import ( "context" "encoding/hex" + "fmt" "os" "sync" "time" @@ -22,6 +23,7 @@ import ( "github.com/ava-labs/avalanchego/subnets" "github.com/ava-labs/avalanchego/utils/constants" "github.com/ava-labs/avalanchego/utils/logging" + "github.com/ava-labs/avalanchego/utils/sampler" "github.com/ava-labs/avalanchego/utils/set" "github.com/ava-labs/avalanchego/vms/platformvm" "github.com/ava-labs/avalanchego/vms/platformvm/warp" @@ -142,7 +144,8 @@ func NewNetwork( testNetwork.ManuallyTrack(peer.ID, peer.PublicIP) } - // Connect to a sample of the primary network validators + // Connect to a sample of the primary network validators, with connection + // info pulled from the info API peers, err := infoAPI.Peers(context.Background(), nil) if err != nil { logger.Error( @@ -151,35 +154,43 @@ func NewNetwork( ) return nil, err } + peersMap := make(map[ids.NodeID]info.Peer) + for _, peer := range peers { + peersMap[peer.ID] = peer + } + pClient := platformvm.NewClient(cfg.GetPChainAPI().BaseURL) + vdrs, err := pClient.GetCurrentValidators(context.Background(), constants.PrimaryNetworkID, nil) + if err != nil { + logger.Error("Failed to get current validators", zap.Error(err)) + return nil, err + } + + // Sample until we've connected to the target number of bootstrap nodes + s := sampler.NewUniform() + s.Initialize(uint64(len(vdrs))) numConnected := 0 - for i, peer := range peers { - vdrs, err := pClient.GetCurrentValidators(context.Background(), constants.PrimaryNetworkID, []ids.NodeID{peer.ID}) - if err != nil { - logger.Error("Failed to get current validators", zap.Error(err)) - return nil, err - } - // Only track the peer if it is a primary network validator - if len(vdrs) == 0 { - continue - } - logger.Info( - "Manually tracking bootstrap node", - zap.String("ID", peer.ID.String()), - zap.String("IP", peer.PublicIP.String()), - ) - testNetwork.ManuallyTrack(peer.ID, peer.PublicIP) - numConnected++ - if numConnected >= NumBootstrapNodes { - break - } - if i == len(peers)-1 { + for numConnected < NumBootstrapNodes { + if i, ok := s.Next(); ok { + if peer, ok := peersMap[vdrs[i].NodeID]; ok { + logger.Info( + "Manually tracking bootstrap node", + zap.Stringer("ID", peer.ID), + zap.Stringer("IP", peer.PublicIP), + ) + testNetwork.ManuallyTrack(peer.ID, peer.PublicIP) + numConnected++ + } + } else { logger.Warn( "Failed to connect to enough bootstrap nodes", zap.Int("targetBootstrapNodes", NumBootstrapNodes), zap.Int("numAvailablePeers", len(peers)), zap.Int("connectedBootstrapNodes", numConnected), ) + if numConnected == 0 { + return nil, fmt.Errorf("failed to connect to any bootstrap nodes") + } } } From f8eaf8ba74480a41ea349b5c317b30a4f496eece Mon Sep 17 00:00:00 2001 From: cam-schultz Date: Mon, 25 Nov 2024 17:25:11 -0600 Subject: [PATCH 25/28] fetch proposed validators --- peers/app_request_network.go | 12 ++++-------- peers/validators/canonical_validator_client.go | 17 ++++++++++++++++- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/peers/app_request_network.go b/peers/app_request_network.go index 8795d280..152ea34f 100644 --- a/peers/app_request_network.go +++ b/peers/app_request_network.go @@ -138,8 +138,8 @@ func NewNetwork( for _, peer := range manuallyTrackedPeers { logger.Info( "Manually Tracking peer (startup)", - zap.String("ID", peer.ID.String()), - zap.String("IP", peer.PublicIP.String()), + zap.Stringer("ID", peer.ID), + zap.Stringer("IP", peer.PublicIP), ) testNetwork.ManuallyTrack(peer.ID, peer.PublicIP) } @@ -227,7 +227,7 @@ func (n *appRequestNetwork) TrackSubnet(subnetID ids.ID) { return } - n.logger.Debug("Tracking subnet", zap.String("subnetID", subnetID.String())) + n.logger.Debug("Tracking subnet", zap.Stringer("subnetID", subnetID)) n.trackedSubnets.Add(subnetID) n.updateValidatorSet(context.Background(), subnetID) } @@ -255,11 +255,7 @@ func (n *appRequestNetwork) updateValidatorSet( n.logger.Debug("Fetching validators for subnet ID", zap.Stringer("subnetID", subnetID)) // Fetch the primary network validators from the P-Chain - height, err := n.validatorClient.GetCurrentHeight(ctx) - if err != nil { - return err - } - validators, err := n.validatorClient.GetValidatorSet(ctx, height, subnetID) + validators, err := n.validatorClient.GetProposedValidators(ctx, subnetID) if err != nil { return err } diff --git a/peers/validators/canonical_validator_client.go b/peers/validators/canonical_validator_client.go index 0373e91c..ea60a805 100644 --- a/peers/validators/canonical_validator_client.go +++ b/peers/validators/canonical_validator_client.go @@ -80,6 +80,21 @@ func (v *CanonicalValidatorClient) GetCurrentValidatorSet( return nil, 0, nil } +func (v *CanonicalValidatorClient) GetProposedValidators( + ctx context.Context, + subnetID ids.ID, +) (map[ids.NodeID]*validators.GetValidatorOutput, error) { + res, err := v.client.GetValidatorsAt(ctx, subnetID, pchainapi.ProposedHeight, v.options...) + if err != nil { + v.logger.Debug( + "Error fetching proposed validators", + zap.String("subnetID", subnetID.String()), + zap.Error(err)) + return nil, err + } + return res, nil +} + // Gets the validator set of the given subnet at the given P-chain block height. // Uses [platform.getValidatorsAt] with supplied height func (v *CanonicalValidatorClient) GetValidatorSet( @@ -90,7 +105,7 @@ func (v *CanonicalValidatorClient) GetValidatorSet( res, err := v.client.GetValidatorsAt(ctx, subnetID, pchainapi.Height(height), v.options...) if err != nil { v.logger.Debug( - "P-chain RPC to getValidatorAt returned error. Falling back to getCurrentValidators", + "Error fetching validators at height", zap.String("subnetID", subnetID.String()), zap.Uint64("pChainHeight", height), zap.Error(err)) From e160dcc8b3f5d04fd909ab1ced87d8a381dae606 Mon Sep 17 00:00:00 2001 From: cam-schultz Date: Mon, 25 Nov 2024 18:36:25 -0600 Subject: [PATCH 26/28] properly break out of loop --- peers/app_request_network.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/peers/app_request_network.go b/peers/app_request_network.go index 152ea34f..94371dc8 100644 --- a/peers/app_request_network.go +++ b/peers/app_request_network.go @@ -182,6 +182,8 @@ func NewNetwork( numConnected++ } } else { + // If we've sampled all the nodes and still haven't connected to the target number of bootstrap nodes, + // then warn and stop sampling by either returning an error or breaking logger.Warn( "Failed to connect to enough bootstrap nodes", zap.Int("targetBootstrapNodes", NumBootstrapNodes), @@ -191,6 +193,7 @@ func NewNetwork( if numConnected == 0 { return nil, fmt.Errorf("failed to connect to any bootstrap nodes") } + break } } From 7988e70ad6c90ec6967217cfe444ed76546e886f Mon Sep 17 00:00:00 2001 From: cam-schultz Date: Tue, 26 Nov 2024 09:00:18 -0600 Subject: [PATCH 27/28] correct comment --- peers/app_request_network.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/peers/app_request_network.go b/peers/app_request_network.go index 94371dc8..c5b08647 100644 --- a/peers/app_request_network.go +++ b/peers/app_request_network.go @@ -257,7 +257,7 @@ func (n *appRequestNetwork) updateValidatorSet( n.logger.Debug("Fetching validators for subnet ID", zap.Stringer("subnetID", subnetID)) - // Fetch the primary network validators from the P-Chain + // Fetch the subnet validators from the P-Chain validators, err := n.validatorClient.GetProposedValidators(ctx, subnetID) if err != nil { return err From 9f47f1e20f77cbbd832c2b161299eb753b934d00 Mon Sep 17 00:00:00 2001 From: cam-schultz Date: Tue, 26 Nov 2024 09:27:41 -0600 Subject: [PATCH 28/28] simplify control flow --- peers/app_request_network.go | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/peers/app_request_network.go b/peers/app_request_network.go index c5b08647..f962ece1 100644 --- a/peers/app_request_network.go +++ b/peers/app_request_network.go @@ -171,17 +171,8 @@ func NewNetwork( s.Initialize(uint64(len(vdrs))) numConnected := 0 for numConnected < NumBootstrapNodes { - if i, ok := s.Next(); ok { - if peer, ok := peersMap[vdrs[i].NodeID]; ok { - logger.Info( - "Manually tracking bootstrap node", - zap.Stringer("ID", peer.ID), - zap.Stringer("IP", peer.PublicIP), - ) - testNetwork.ManuallyTrack(peer.ID, peer.PublicIP) - numConnected++ - } - } else { + i, ok := s.Next() + if !ok { // If we've sampled all the nodes and still haven't connected to the target number of bootstrap nodes, // then warn and stop sampling by either returning an error or breaking logger.Warn( @@ -195,6 +186,15 @@ func NewNetwork( } break } + if peer, ok := peersMap[vdrs[i].NodeID]; ok { + logger.Info( + "Manually tracking bootstrap node", + zap.Stringer("ID", peer.ID), + zap.Stringer("IP", peer.PublicIP), + ) + testNetwork.ManuallyTrack(peer.ID, peer.PublicIP) + numConnected++ + } } go logger.RecoverAndPanic(func() {