diff --git a/go.mod b/go.mod index 19c4e89b..120e7419 100644 --- a/go.mod +++ b/go.mod @@ -6,10 +6,10 @@ require ( 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.7 + github.com/ava-labs/teleporter v1.0.8-0.20241121223552-226937a967e8 github.com/aws/aws-sdk-go-v2 v1.32.5 - github.com/aws/aws-sdk-go-v2/config v1.28.5 - github.com/aws/aws-sdk-go-v2/service/kms v1.37.6 + github.com/aws/aws-sdk-go-v2/config v1.28.3 + github.com/aws/aws-sdk-go-v2/service/kms v1.37.5 github.com/ethereum/go-ethereum v1.13.14 github.com/hashicorp/golang-lru/v2 v2.0.7 github.com/onsi/ginkgo/v2 v2.22.0 @@ -156,15 +156,15 @@ 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 - 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 diff --git a/go.sum b/go.sum index 84f38877..b86f59b0 100644 --- a/go.sum +++ b/go.sum @@ -66,12 +66,12 @@ 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.7 h1:9H0wTWhgWeA4u6uxi9KngdBu/LOoYsfAmIZhXNzuvf8= -github.com/ava-labs/teleporter v1.0.7/go.mod h1:wgCgU6vU5MtP83otpjEin8jL2jrflVBNQCTxVXMx/kU= +github.com/ava-labs/teleporter v1.0.8-0.20241121223552-226937a967e8 h1:jsH1wv1GgeztvipQG3di1OTruSHbFAwwP4K6clzTRLE= +github.com/ava-labs/teleporter v1.0.8-0.20241121223552-226937a967e8/go.mod h1:Q4/DDZPLI5f96xDykVXPT85PeJS3IqDPDJDk3UdQOuQ= github.com/aws/aws-sdk-go-v2 v1.32.5 h1:U8vdWJuY7ruAkzaOdD7guwJjD06YSKmnKCJs7s3IkIo= github.com/aws/aws-sdk-go-v2 v1.32.5/go.mod h1:P5WJBrYqqbWVaOxgH0X/FYYD47/nooaPOZPlQdmiN2U= -github.com/aws/aws-sdk-go-v2/config v1.28.5 h1:Za41twdCXbuyyWv9LndXxZZv3QhTG1DinqlFsSuvtI0= -github.com/aws/aws-sdk-go-v2/config v1.28.5/go.mod h1:4VsPbHP8JdcdUDmbTVgNL/8w9SqOkM5jyY8ljIxLO3o= +github.com/aws/aws-sdk-go-v2/config v1.28.3 h1:kL5uAptPcPKaJ4q0sDUjUIdueO18Q7JDzl64GpVwdOM= +github.com/aws/aws-sdk-go-v2/config v1.28.3/go.mod h1:SPEn1KA8YbgQnwiJ/OISU4fz7+F6Fe309Jf0QTsRCl4= github.com/aws/aws-sdk-go-v2/credentials v1.17.46 h1:AU7RcriIo2lXjUfHFnFKYsLCwgbz1E7Mm95ieIRDNUg= github.com/aws/aws-sdk-go-v2/credentials v1.17.46/go.mod h1:1FmYyLGL08KQXQ6mcTlifyFXfJVCNJTVGuQP4m0d/UA= github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.20 h1:sDSXIrlsFSFJtWKLQS4PUWRvrT580rrnuLydJrCQ/yA= @@ -86,8 +86,8 @@ github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.1 h1:iXtILhv github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.1/go.mod h1:9nu0fVANtYiAePIBh2/pFUSwtJ402hLnp854CNoDOeE= github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.5 h1:wtpJ4zcwrSbwhECWQoI/g6WM9zqCcSpHDJIWSbMLOu4= github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.5/go.mod h1:qu/W9HXQbbQ4+1+JcZp0ZNPV31ym537ZJN+fiS7Ti8E= -github.com/aws/aws-sdk-go-v2/service/kms v1.37.6 h1:CZImQdb1QbU9sGgJ9IswhVkxAcjkkD1eQTMA1KHWk+E= -github.com/aws/aws-sdk-go-v2/service/kms v1.37.6/go.mod h1:YJDdlK0zsyxVBxGU48AR/Mi8DMrGdc1E3Yij4fNrONA= +github.com/aws/aws-sdk-go-v2/service/kms v1.37.5 h1:5dQJ6Q5QrQOqZxXjSbRXukBqU8Pgu6Ro6Qqtyd8yiz4= +github.com/aws/aws-sdk-go-v2/service/kms v1.37.5/go.mod h1:A9vfQcNHVBCE7ZZN6H+UUJpXtbH26Vv6L7Zhk5nIJAY= github.com/aws/aws-sdk-go-v2/service/sso v1.24.6 h1:3zu537oLmsPfDMyjnUS2g+F2vITgy5pB74tHI+JBNoM= github.com/aws/aws-sdk-go-v2/service/sso v1.24.6/go.mod h1:WJSZH2ZvepM6t6jwu4w/Z45Eoi75lPN7DcydSRtJg6Y= github.com/aws/aws-sdk-go-v2/service/ssooidc v1.28.5 h1:K0OQAsDywb0ltlFrZm0JHPY3yZp/S9OaoLU33S7vPS8= @@ -706,8 +706,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= @@ -791,8 +791,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= @@ -884,12 +884,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= @@ -900,8 +900,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= @@ -963,8 +963,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= diff --git a/scripts/e2e_test.sh b/scripts/e2e_test.sh index 9d29d848..a920f8df 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,42 +19,32 @@ 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 - BASEDIR=$DATA_DIRECTORY AVALANCHEGO_BUILD_PATH=$DATA_DIRECTORY/avalanchego ./scripts/install_avalanchego_release.sh - cd $SUBNET_EVM_PATH - ./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 ) 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 ./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 + # 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/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..f96bcc86 100644 --- a/tests/basic_relay.go +++ b/tests/basic_relay.go @@ -13,6 +13,7 @@ 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" @@ -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()) @@ -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, ) @@ -78,9 +78,9 @@ func BasicRelay(network interfaces.LocalNetwork) { log.Info("Sending transaction from Subnet A to Subnet B") testUtils.RelayBasicMessage( ctx, + teleporter, subnetAInfo, subnetBInfo, - teleporterContractAddress, fundedKey, fundedAddress, ) @@ -91,9 +91,9 @@ func BasicRelay(network interfaces.LocalNetwork) { log.Info("Test Relaying from Subnet B to Subnet A") testUtils.RelayBasicMessage( ctx, + teleporter, subnetBInfo, subnetAInfo, - teleporterContractAddress, fundedKey, fundedAddress, ) @@ -172,6 +172,7 @@ func BasicRelay(network interfaces.LocalNetwork) { log.Info("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/contracts/lib/teleporter b/tests/contracts/lib/teleporter index f23da2da..226937a9 160000 --- a/tests/contracts/lib/teleporter +++ b/tests/contracts/lib/teleporter @@ -1 +1 @@ -Subproject commit f23da2da8fdd5ef4e3bad46358054c4b36dec78b +Subproject commit 226937a967e8947034f2704de6f168bcf48e2d2b diff --git a/tests/e2e_test.go b/tests/e2e_test.go index 2210d66a..f92cfdde 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, @@ -103,21 +105,28 @@ var _ = ginkgo.BeforeSuite(func() { NodeCount: 2, }, }, + 4, 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( + networkStartCtx, + 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 +164,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..d7cb8344 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, diff --git a/tests/utils/utils.go b/tests/utils/utils.go index 70974a4b..84cfd42d 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, 60*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,30 @@ 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()) @@ -442,7 +502,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) @@ -450,18 +510,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 +533,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 +543,7 @@ func DeployBatchCrossChainMessenger( address, tx, exampleMessenger, err := batchcrosschainmessenger.DeployBatchCrossChainMessenger( opts, subnet.RPCClient, - subnet.TeleporterRegistryAddress, + teleporter.TeleporterRegistryAddress(subnet), teleporterManager, ) Expect(err).Should(BeNil()) @@ -518,14 +579,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" }() 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, )