diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 916aea8e4..d23015fe2 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -4,7 +4,7 @@ on: pull_request: push: branches: - - master + - '**' jobs: build: diff --git a/.github/workflows/docker-publish.yaml b/.github/workflows/docker-publish.yaml index 6c6cd8164..1461b6c89 100644 --- a/.github/workflows/docker-publish.yaml +++ b/.github/workflows/docker-publish.yaml @@ -1,54 +1,63 @@ -name: Create and publish a Docker image +name: Build and Push to DockerHub on: push: tags: - - '**' - branches: - - '**' - -env: - REGISTRY: ghcr.io - IMAGE_NAME: ${{ github.repository }} + - "v*.*.*" jobs: - build-and-push-image: + docker: runs-on: ubuntu-latest - permissions: - contents: read - packages: write - + env: + GOPRIVATE: github.com/sagaxyz/* steps: - - name: Checkout repository - uses: actions/checkout@v2 - - - name: Set up QEMU - uses: docker/setup-qemu-action@v1 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 - - - name: Log in to the Container registry - uses: docker/login-action@v1 + - name: Set up access to private Go modules + env: + GITHUB_USER: ${{ secrets.GH_USER }} + GITHUB_TOKEN: ${{ secrets.GH_ACCESS_TOKEN }} + run: git config --global url."https://${GITHUB_USER}:${GITHUB_TOKEN}@github.com".insteadOf "https://github.com" + + - name: Checkout + uses: actions/checkout@v3 + - + name: Git fetch everything + run: git fetch --prune --unshallow + - name: Setup Go + uses: actions/setup-go@v3 with: - registry: ${{ env.REGISTRY }} - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Extract metadata (tags, labels) for Docker + go-version-file: './go.mod' + cache: true + - run: go version + + - name: Compile rly + run : make build + - + name: Get Github tag id: meta - uses: docker/metadata-action@v3 + run: | + echo "::set-output name=tag::$(echo ${{github.ref_name}} | sed -e 's/^v//')" + - + name: Set up QEMU + uses: docker/setup-qemu-action@v2 + - + name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - + name: Login to DockerHub + uses: docker/login-action@v2 with: - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - - - name: Build and push Docker image - uses: docker/build-push-action@v2.7.0 + registry: docker.io + username: sagaxyz + password: ${{ secrets.DOCKERHUB_TOKEN }} + - + name: Build and push + uses: docker/build-push-action@v3 with: context: . - platforms: linux/amd64,linux/arm64 - file: Dockerfile + file: saga.Dockerfile push: true - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - cache-from: type=gha - cache-to: type=gha,mode=max + build-args: | + GITHUB_USER=${{ secrets.GH_USER }} + GITHUB_TOKEN=${{ secrets.GH_ACCESS_TOKEN }} + platforms: linux/amd64 + tags: sagaxyz/go-relayer:${{ steps.meta.outputs.tag }}, sagaxyz/go-relayer:latest diff --git a/.github/workflows/interchaintest.yml b/.github/workflows/interchaintest.yml index 158329a66..f938b806f 100644 --- a/.github/workflows/interchaintest.yml +++ b/.github/workflows/interchaintest.yml @@ -2,6 +2,9 @@ name: TESTING - interchaintest on: pull_request: + push: + branches: + - main jobs: events: diff --git a/.gitignore b/.gitignore index 1af13e52e..4fe5ba715 100644 --- a/.gitignore +++ b/.gitignore @@ -21,5 +21,4 @@ dist/ # Don't commit the vendor directory if anyone runs 'go mod vendor'. /vendor - -go.work.sum +docker-compose.yml diff --git a/docker-compose.yml.example b/docker-compose.yml.example new file mode 100644 index 000000000..0b0ce35a2 --- /dev/null +++ b/docker-compose.yml.example @@ -0,0 +1,37 @@ +version: '3' + +services: + rly: + container_name: rly + image: "rly:latest" + build: + context: . + dockerfile: saga.Dockerfile + environment: + - KEYNAME=relayer + - PROVIDER_CHAINID= + - CONSUMER_CHAINID= + - PROVIDER_RLY_MNEMONIC= + - CONSUMER_RLY_MNEMONIC= + - KEYRING=test # remember to change to other types of keyring like 'file' in-case exposing to outside world, otherwise your balance will be wiped quickly. The keyring test does not require private key to steal tokens from you + - KEYALGO=secp256k1 + - KEYPASSWD="passw0rdK3y" + - PROVIDER_RPC_ADDRESS= + - CONSUMER_RPC_ADDRESS= + - RLY_SRC_PORT=consumer # Do not change unless you know what you are doing. This impacts the IBC connection ports + - RLY_DST_PORT=provider # Do not change unless you know what you are doing + - RLY_ORDERING=ordered # Do not change unless you know what you are doing + - RLY_DEBUG=true # set it to false as needed + networks: + - localnet + ports: + - 5183:5183 + volumes: + - ./rly/start-rly.sh:/root/start-rly.sh + +volumes: + relayer: + +networks: + localnet: + \ No newline at end of file diff --git a/go.work.sum b/go.work.sum new file mode 100644 index 000000000..81280b1e5 --- /dev/null +++ b/go.work.sum @@ -0,0 +1,166 @@ +cloud.google.com/go v0.110.2/go.mod h1:k04UEeEtb6ZBRTv3dZz4CeJC3jKGxyhl0sAiVVquxiw= +cloud.google.com/go/accessapproval v1.7.1/go.mod h1:JYczztsHRMK7NTXb6Xw+dwbs/WnOJxbo/2mTI+Kgg68= +cloud.google.com/go/accesscontextmanager v1.8.1/go.mod h1:JFJHfvuaTC+++1iL1coPiG1eu5D24db2wXCDWDjIrxo= +cloud.google.com/go/aiplatform v1.45.0/go.mod h1:Iu2Q7sC7QGhXUeOhAj/oCK9a+ULz1O4AotZiqjQ8MYA= +cloud.google.com/go/analytics v0.21.2/go.mod h1:U8dcUtmDmjrmUTnnnRnI4m6zKn/yaA5N9RlEkYFHpQo= +cloud.google.com/go/apigateway v1.6.1/go.mod h1:ufAS3wpbRjqfZrzpvLC2oh0MFlpRJm2E/ts25yyqmXA= +cloud.google.com/go/apigeeconnect v1.6.1/go.mod h1:C4awq7x0JpLtrlQCr8AzVIzAaYgngRqWf9S5Uhg+wWs= +cloud.google.com/go/apigeeregistry v0.7.1/go.mod h1:1XgyjZye4Mqtw7T9TsY4NW10U7BojBvG4RMD+vRDrIw= +cloud.google.com/go/appengine v1.8.1/go.mod h1:6NJXGLVhZCN9aQ/AEDvmfzKEfoYBlfB80/BHiKVputY= +cloud.google.com/go/area120 v0.8.1/go.mod h1:BVfZpGpB7KFVNxPiQBuHkX6Ed0rS51xIgmGyjrAfzsg= +cloud.google.com/go/artifactregistry v1.14.1/go.mod h1:nxVdG19jTaSTu7yA7+VbWL346r3rIdkZ142BSQqhn5E= +cloud.google.com/go/asset v1.14.1/go.mod h1:4bEJ3dnHCqWCDbWJ/6Vn7GVI9LerSi7Rfdi03hd+WTQ= +cloud.google.com/go/assuredworkloads v1.11.1/go.mod h1:+F04I52Pgn5nmPG36CWFtxmav6+7Q+c5QyJoL18Lry0= +cloud.google.com/go/automl v1.13.1/go.mod h1:1aowgAHWYZU27MybSCFiukPO7xnyawv7pt3zK4bheQE= +cloud.google.com/go/baremetalsolution v0.5.0/go.mod h1:dXGxEkmR9BMwxhzBhV0AioD0ULBmuLZI8CdwalUxuss= +cloud.google.com/go/batch v0.7.0/go.mod h1:vLZN95s6teRUqRQ4s3RLDsH8PvboqBK+rn1oevL159g= +cloud.google.com/go/beyondcorp v0.6.1/go.mod h1:YhxDWw946SCbmcWo3fAhw3V4XZMSpQ/VYfcKGAEU8/4= +cloud.google.com/go/bigquery v1.52.0/go.mod h1:3b/iXjRQGU4nKa87cXeg6/gogLjO8C6PmuM8i5Bi/u4= +cloud.google.com/go/billing v1.16.0/go.mod h1:y8vx09JSSJG02k5QxbycNRrN7FGZB6F3CAcgum7jvGA= +cloud.google.com/go/binaryauthorization v1.6.1/go.mod h1:TKt4pa8xhowwffiBmbrbcxijJRZED4zrqnwZ1lKH51U= +cloud.google.com/go/certificatemanager v1.7.1/go.mod h1:iW8J3nG6SaRYImIa+wXQ0g8IgoofDFRp5UMzaNk1UqI= +cloud.google.com/go/channel v1.16.0/go.mod h1:eN/q1PFSl5gyu0dYdmxNXscY/4Fi7ABmeHCJNf/oHmc= +cloud.google.com/go/cloudbuild v1.10.1/go.mod h1:lyJg7v97SUIPq4RC2sGsz/9tNczhyv2AjML/ci4ulzU= +cloud.google.com/go/clouddms v1.6.1/go.mod h1:Ygo1vL52Ov4TBZQquhz5fiw2CQ58gvu+PlS6PVXCpZI= +cloud.google.com/go/cloudtasks v1.11.1/go.mod h1:a9udmnou9KO2iulGscKR0qBYjreuX8oHwpmFsKspEvM= +cloud.google.com/go/compute v1.14.0/go.mod h1:YfLtxrj9sU4Yxv+sXzZkyPjEyPBZfXHUvjxega5vAdo= +cloud.google.com/go/compute v1.19.1/go.mod h1:6ylj3a05WF8leseCdIf77NK0g1ey+nj5IKd5/kvShxE= +cloud.google.com/go/compute v1.19.3/go.mod h1:qxvISKp/gYnXkSAD1ppcSOveRAmzxicEv/JlizULFrI= +cloud.google.com/go/compute/metadata v0.2.0/go.mod h1:zFmK7XCadkQkj6TtorcaGlCW1hT1fIilQDwofLpJ20k= +cloud.google.com/go/contactcenterinsights v1.9.1/go.mod h1:bsg/R7zGLYMVxFFzfh9ooLTruLRCG9fnzhH9KznHhbM= +cloud.google.com/go/container v1.22.1/go.mod h1:lTNExE2R7f+DLbAN+rJiKTisauFCaoDq6NURZ83eVH4= +cloud.google.com/go/containeranalysis v0.10.1/go.mod h1:Ya2jiILITMY68ZLPaogjmOMNkwsDrWBSTyBubGXO7j0= +cloud.google.com/go/datacatalog v1.14.1/go.mod h1:d2CevwTG4yedZilwe+v3E3ZBDRMobQfSG/a6cCCN5R4= +cloud.google.com/go/dataflow v0.9.1/go.mod h1:Wp7s32QjYuQDWqJPFFlnBKhkAtiFpMTdg00qGbnIHVw= +cloud.google.com/go/dataform v0.8.1/go.mod h1:3BhPSiw8xmppbgzeBbmDvmSWlwouuJkXsXsb8UBih9M= +cloud.google.com/go/datafusion v1.7.1/go.mod h1:KpoTBbFmoToDExJUso/fcCiguGDk7MEzOWXUsJo0wsI= +cloud.google.com/go/datalabeling v0.8.1/go.mod h1:XS62LBSVPbYR54GfYQsPXZjTW8UxCK2fkDciSrpRFdY= +cloud.google.com/go/dataplex v1.8.1/go.mod h1:7TyrDT6BCdI8/38Uvp0/ZxBslOslP2X2MPDucliyvSE= +cloud.google.com/go/dataproc v1.12.0/go.mod h1:zrF3aX0uV3ikkMz6z4uBbIKyhRITnxvr4i3IjKsKrw4= +cloud.google.com/go/dataqna v0.8.1/go.mod h1:zxZM0Bl6liMePWsHA8RMGAfmTG34vJMapbHAxQ5+WA8= +cloud.google.com/go/datastore v1.12.0/go.mod h1:KjdB88W897MRITkvWWJrg2OUtrR5XVj1EoLgSp6/N70= +cloud.google.com/go/datastream v1.9.1/go.mod h1:hqnmr8kdUBmrnk65k5wNRoHSCYksvpdZIcZIEl8h43Q= +cloud.google.com/go/deploy v1.11.0/go.mod h1:tKuSUV5pXbn67KiubiUNUejqLs4f5cxxiCNCeyl0F2g= +cloud.google.com/go/dialogflow v1.38.0/go.mod h1:L7jnH+JL2mtmdChzAIcXQHXMvQkE3U4hTaNltEuxXn4= +cloud.google.com/go/dlp v1.10.1/go.mod h1:IM8BWz1iJd8njcNcG0+Kyd9OPnqnRNkDV8j42VT5KOI= +cloud.google.com/go/documentai v1.20.0/go.mod h1:yJkInoMcK0qNAEdRnqY/D5asy73tnPe88I1YTZT+a8E= +cloud.google.com/go/domains v0.9.1/go.mod h1:aOp1c0MbejQQ2Pjf1iJvnVyT+z6R6s8pX66KaCSDYfE= +cloud.google.com/go/edgecontainer v1.1.1/go.mod h1:O5bYcS//7MELQZs3+7mabRqoWQhXCzenBu0R8bz2rwk= +cloud.google.com/go/errorreporting v0.3.0/go.mod h1:xsP2yaAp+OAW4OIm60An2bbLpqIhKXdWR/tawvl7QzU= +cloud.google.com/go/essentialcontacts v1.6.2/go.mod h1:T2tB6tX+TRak7i88Fb2N9Ok3PvY3UNbUsMag9/BARh4= +cloud.google.com/go/eventarc v1.12.1/go.mod h1:mAFCW6lukH5+IZjkvrEss+jmt2kOdYlN8aMx3sRJiAI= +cloud.google.com/go/filestore v1.7.1/go.mod h1:y10jsorq40JJnjR/lQ8AfFbbcGlw3g+Dp8oN7i7FjV4= +cloud.google.com/go/firestore v1.11.0/go.mod h1:b38dKhgzlmNNGTNZZwe7ZRFEuRab1Hay3/DBsIGKKy4= +cloud.google.com/go/functions v1.15.1/go.mod h1:P5yNWUTkyU+LvW/S9O6V+V423VZooALQlqoXdoPz5AE= +cloud.google.com/go/gaming v1.10.1/go.mod h1:XQQvtfP8Rb9Rxnxm5wFVpAp9zCQkJi2bLIb7iHGwB3s= +cloud.google.com/go/gkebackup v0.4.0/go.mod h1:byAyBGUwYGEEww7xsbnUTBHIYcOPy/PgUWUtOeRm9Vg= +cloud.google.com/go/gkeconnect v0.8.1/go.mod h1:KWiK1g9sDLZqhxB2xEuPV8V9NYzrqTUmQR9shJHpOZw= +cloud.google.com/go/gkehub v0.14.1/go.mod h1:VEXKIJZ2avzrbd7u+zeMtW00Y8ddk/4V9511C9CQGTY= +cloud.google.com/go/gkemulticloud v0.6.1/go.mod h1:kbZ3HKyTsiwqKX7Yw56+wUGwwNZViRnxWK2DVknXWfw= +cloud.google.com/go/gsuiteaddons v1.6.1/go.mod h1:CodrdOqRZcLp5WOwejHWYBjZvfY0kOphkAKpF/3qdZY= +cloud.google.com/go/iam v0.13.0/go.mod h1:ljOg+rcNfzZ5d6f1nAUJ8ZIxOaZUVoS14bKCtaLZ/D0= +cloud.google.com/go/iap v1.8.1/go.mod h1:sJCbeqg3mvWLqjZNsI6dfAtbbV1DL2Rl7e1mTyXYREQ= +cloud.google.com/go/ids v1.4.1/go.mod h1:np41ed8YMU8zOgv53MMMoCntLTn2lF+SUzlM+O3u/jw= +cloud.google.com/go/iot v1.7.1/go.mod h1:46Mgw7ev1k9KqK1ao0ayW9h0lI+3hxeanz+L1zmbbbk= +cloud.google.com/go/kms v1.12.1/go.mod h1:c9J991h5DTl+kg7gi3MYomh12YEENGrf48ee/N/2CDM= +cloud.google.com/go/language v1.10.1/go.mod h1:CPp94nsdVNiQEt1CNjF5WkTcisLiHPyIbMhvR8H2AW0= +cloud.google.com/go/lifesciences v0.9.1/go.mod h1:hACAOd1fFbCGLr/+weUKRAJas82Y4vrL3O5326N//Wc= +cloud.google.com/go/logging v1.7.0/go.mod h1:3xjP2CjkM3ZkO73aj4ASA5wRPGGCRrPIAeNqVNkzY8M= +cloud.google.com/go/longrunning v0.4.2/go.mod h1:OHrnaYyLUV6oqwh0xiS7e5sLQhP1m0QU9R+WhGDMgIQ= +cloud.google.com/go/longrunning v0.5.1/go.mod h1:spvimkwdz6SPWKEt/XBij79E9fiTkHSQl/fRUUQJYJc= +cloud.google.com/go/managedidentities v1.6.1/go.mod h1:h/irGhTN2SkZ64F43tfGPMbHnypMbu4RB3yl8YcuEak= +cloud.google.com/go/maps v0.7.0/go.mod h1:3GnvVl3cqeSvgMcpRlQidXsPYuDGQ8naBis7MVzpXsY= +cloud.google.com/go/mediatranslation v0.8.1/go.mod h1:L/7hBdEYbYHQJhX2sldtTO5SZZ1C1vkapubj0T2aGig= +cloud.google.com/go/memcache v1.10.1/go.mod h1:47YRQIarv4I3QS5+hoETgKO40InqzLP6kpNLvyXuyaA= +cloud.google.com/go/metastore v1.11.1/go.mod h1:uZuSo80U3Wd4zi6C22ZZliOUJ3XeM/MlYi/z5OAOWRA= +cloud.google.com/go/monitoring v1.15.1/go.mod h1:lADlSAlFdbqQuwwpaImhsJXu1QSdd3ojypXrFSMr2rM= +cloud.google.com/go/networkconnectivity v1.12.1/go.mod h1:PelxSWYM7Sh9/guf8CFhi6vIqf19Ir/sbfZRUwXh92E= +cloud.google.com/go/networkmanagement v1.8.0/go.mod h1:Ho/BUGmtyEqrttTgWEe7m+8vDdK74ibQc+Be0q7Fof0= +cloud.google.com/go/networksecurity v0.9.1/go.mod h1:MCMdxOKQ30wsBI1eI659f9kEp4wuuAueoC9AJKSPWZQ= +cloud.google.com/go/notebooks v1.9.1/go.mod h1:zqG9/gk05JrzgBt4ghLzEepPHNwE5jgPcHZRKhlC1A8= +cloud.google.com/go/optimization v1.4.1/go.mod h1:j64vZQP7h9bO49m2rVaTVoNM0vEBEN5eKPUPbZyXOrk= +cloud.google.com/go/orchestration v1.8.1/go.mod h1:4sluRF3wgbYVRqz7zJ1/EUNc90TTprliq9477fGobD8= +cloud.google.com/go/orgpolicy v1.11.1/go.mod h1:8+E3jQcpZJQliP+zaFfayC2Pg5bmhuLK755wKhIIUCE= +cloud.google.com/go/osconfig v1.12.1/go.mod h1:4CjBxND0gswz2gfYRCUoUzCm9zCABp91EeTtWXyz0tE= +cloud.google.com/go/oslogin v1.10.1/go.mod h1:x692z7yAue5nE7CsSnoG0aaMbNoRJRXO4sn73R+ZqAs= +cloud.google.com/go/phishingprotection v0.8.1/go.mod h1:AxonW7GovcA8qdEk13NfHq9hNx5KPtfxXNeUxTDxB6I= +cloud.google.com/go/policytroubleshooter v1.7.1/go.mod h1:0NaT5v3Ag1M7U5r0GfDCpUFkWd9YqpubBWsQlhanRv0= +cloud.google.com/go/privatecatalog v0.9.1/go.mod h1:0XlDXW2unJXdf9zFz968Hp35gl/bhF4twwpXZAW50JA= +cloud.google.com/go/pubsub v1.32.0/go.mod h1:f+w71I33OMyxf9VpMVcZbnG5KSUkCOUHYpFd5U1GdRc= +cloud.google.com/go/pubsublite v1.8.1/go.mod h1:fOLdU4f5xldK4RGJrBMm+J7zMWNj/k4PxwEZXy39QS0= +cloud.google.com/go/recaptchaenterprise/v2 v2.7.2/go.mod h1:kR0KjsJS7Jt1YSyWFkseQ756D45kaYNTlDPPaRAvDBU= +cloud.google.com/go/recommendationengine v0.8.1/go.mod h1:MrZihWwtFYWDzE6Hz5nKcNz3gLizXVIDI/o3G1DLcrE= +cloud.google.com/go/recommender v1.10.1/go.mod h1:XFvrE4Suqn5Cq0Lf+mCP6oBHD/yRMA8XxP5sb7Q7gpA= +cloud.google.com/go/redis v1.13.1/go.mod h1:VP7DGLpE91M6bcsDdMuyCm2hIpB6Vp2hI090Mfd1tcg= +cloud.google.com/go/resourcemanager v1.9.1/go.mod h1:dVCuosgrh1tINZ/RwBufr8lULmWGOkPS8gL5gqyjdT8= +cloud.google.com/go/resourcesettings v1.6.1/go.mod h1:M7mk9PIZrC5Fgsu1kZJci6mpgN8o0IUzVx3eJU3y4Jw= +cloud.google.com/go/retail v1.14.1/go.mod h1:y3Wv3Vr2k54dLNIrCzenyKG8g8dhvhncT2NcNjb/6gE= +cloud.google.com/go/run v0.9.0/go.mod h1:Wwu+/vvg8Y+JUApMwEDfVfhetv30hCG4ZwDR/IXl2Qg= +cloud.google.com/go/scheduler v1.10.1/go.mod h1:R63Ldltd47Bs4gnhQkmNDse5w8gBRrhObZ54PxgR2Oo= +cloud.google.com/go/secretmanager v1.11.1/go.mod h1:znq9JlXgTNdBeQk9TBW/FnR/W4uChEKGeqQWAJ8SXFw= +cloud.google.com/go/security v1.15.1/go.mod h1:MvTnnbsWnehoizHi09zoiZob0iCHVcL4AUBj76h9fXA= +cloud.google.com/go/securitycenter v1.23.0/go.mod h1:8pwQ4n+Y9WCWM278R8W3nF65QtY172h4S8aXyI9/hsQ= +cloud.google.com/go/servicedirectory v1.10.1/go.mod h1:Xv0YVH8s4pVOwfM/1eMTl0XJ6bzIOSLDt8f8eLaGOxQ= +cloud.google.com/go/shell v1.7.1/go.mod h1:u1RaM+huXFaTojTbW4g9P5emOrrmLE69KrxqQahKn4g= +cloud.google.com/go/spanner v1.47.0/go.mod h1:IXsJwVW2j4UKs0eYDqodab6HgGuA1bViSqW4uH9lfUI= +cloud.google.com/go/speech v1.17.1/go.mod h1:8rVNzU43tQvxDaGvqOhpDqgkJTFowBpDvCJ14kGlJYo= +cloud.google.com/go/storagetransfer v1.10.0/go.mod h1:DM4sTlSmGiNczmV6iZyceIh2dbs+7z2Ayg6YAiQlYfA= +cloud.google.com/go/talent v1.6.2/go.mod h1:CbGvmKCG61mkdjcqTcLOkb2ZN1SrQI8MDyma2l7VD24= +cloud.google.com/go/texttospeech v1.7.1/go.mod h1:m7QfG5IXxeneGqTapXNxv2ItxP/FS0hCZBwXYqucgSk= +cloud.google.com/go/tpu v1.6.1/go.mod h1:sOdcHVIgDEEOKuqUoi6Fq53MKHJAtOwtz0GuKsWSH3E= +cloud.google.com/go/trace v1.10.1/go.mod h1:gbtL94KE5AJLH3y+WVpfWILmqgc6dXcqgNXdOPAQTYk= +cloud.google.com/go/translate v1.8.1/go.mod h1:d1ZH5aaOA0CNhWeXeC8ujd4tdCFw8XoNWRljklu5RHs= +cloud.google.com/go/video v1.17.1/go.mod h1:9qmqPqw/Ib2tLqaeHgtakU+l5TcJxCJbhFXM7UJjVzU= +cloud.google.com/go/videointelligence v1.11.1/go.mod h1:76xn/8InyQHarjTWsBR058SmlPCwQjgcvoW0aZykOvo= +cloud.google.com/go/vision/v2 v2.7.2/go.mod h1:jKa8oSYBWhYiXarHPvP4USxYANYUEdEsQrloLjrSwJU= +cloud.google.com/go/vmmigration v1.7.1/go.mod h1:WD+5z7a/IpZ5bKK//YmT9E047AD+rjycCAvyMxGJbro= +cloud.google.com/go/vmwareengine v0.4.1/go.mod h1:Px64x+BvjPZwWuc4HdmVhoygcXqEkGHXoa7uyfTgSI0= +cloud.google.com/go/vpcaccess v1.7.1/go.mod h1:FogoD46/ZU+JUBX9D606X21EnxiszYi2tArQwLY4SXs= +cloud.google.com/go/webrisk v1.9.1/go.mod h1:4GCmXKcOa2BZcZPn6DCEvE7HypmEJcJkr4mtM+sqYPc= +cloud.google.com/go/websecurityscanner v1.6.1/go.mod h1:Njgaw3rttgRHXzwCB8kgCYqv5/rGpFCsBOvPbYgszpg= +cloud.google.com/go/workflows v1.11.1/go.mod h1:Z+t10G1wF7h8LgdY/EmRcQY8ptBD/nvofaL6FqlET6g= +github.com/census-instrumentation/opencensus-proto v0.4.1/go.mod h1:4T9NM4+4Vw91VeyqjLS6ao50K5bOcLKN6Q42XnYaRYw= +github.com/cncf/udpa/go v0.0.0-20220112060539-c52dc94e7fbe/go.mod h1:6pvJx4me5XPnfI9Z40ddWsdw2W/uZgQLFXToKeRcDiI= +github.com/cncf/xds/go v0.0.0-20230607035331-e9ce68804cb4/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= +github.com/envoyproxy/go-control-plane v0.11.1-0.20230524094728-9239064ad72f/go.mod h1:sfYdkwUW4BA3PbKjySwjJy+O4Pu0h62rlqCMHNk+K+Q= +github.com/envoyproxy/protoc-gen-validate v0.10.1/go.mod h1:DRjgyB0I43LtJapqN6NiRwroiAU2PaFuvk/vjgh61ss= +github.com/googleapis/gax-go/v2 v2.10.0/go.mod h1:4UOEnMCrxsSqQ940WnTiD6qJ63le2ev3xfyagutxiPw= +github.com/kisielk/errcheck v1.6.2/go.mod h1:nXw/i/MfnvRHqXa7XXmQMUB0oNFGuBrNI8d8NLy0LPw= +github.com/stretchr/objx v0.3.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= +github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= +golang.org/x/crypto v0.9.0/go.mod h1:yrmDGqONDYtNj3tH8X9dzUun2m2lzPa9ngI6/RUPGR0= +golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3/go.mod h1:3p9vT2HGsQu2K1YbXdKPJLVgG5VJdoTa1poYQBtP1AY= +golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= +golang.org/x/mod v0.9.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= +golang.org/x/mod v0.10.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= +golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= +golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= +golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns= +golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= +golang.org/x/oauth2 v0.5.0/go.mod h1:9/XBHVqLaWO3/BRHs5jbpYCnOZVjj5V0ndyaAM7KB4I= +golang.org/x/oauth2 v0.7.0/go.mod h1:hPLQkd9LyjfXTiRohC/41GhcFqxisoUQ99sCUOHO9x4= +golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/term v0.3.0/go.mod h1:q750SLmJuPmVoN1blW3UFBPREJfb1KmY3vwxfr+nFDA= +golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= +golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= +golang.org/x/text v0.11.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= +golang.org/x/tools v0.1.10/go.mod h1:Uh6Zz+xoGYZom868N8YTex3t7RhtHDBrE8Gzo9bV56E= +google.golang.org/api v0.125.0/go.mod h1:mBwVAtz+87bEN6CbA1GtZPDOqY2R5ONPqJeIlvyo4Aw= +google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1/go.mod h1:nKE/iIaLqn2bQwXBg8f1g2Ylh6r5MN5CmZvuzZCgsCU= +google.golang.org/genproto v0.0.0-20230525234025-438c736192d0/go.mod h1:9ExIQyXL5hZrHzQceCwuSYwZZ5QZBazOcprJ5rgs3lY= +google.golang.org/genproto v0.0.0-20230530153820-e85fd2cbaebc/go.mod h1:xZnkP7mREFX5MORlOPEzLMr+90PPZQ2QWzrVTWfAq64= +google.golang.org/genproto/googleapis/api v0.0.0-20230530153820-e85fd2cbaebc/go.mod h1:vHYtlOoi6TsQ3Uk2yxR7NI5z8uoV+3pZtR4jmHIkRig= +google.golang.org/genproto/googleapis/bytestream v0.0.0-20230530153820-e85fd2cbaebc/go.mod h1:ylj+BE99M198VPbBh6A8d9n3w8fChvyLK3wwBOjXBFA= +google.golang.org/genproto/googleapis/rpc v0.0.0-20230525234030-28d5490b6b19/go.mod h1:66JfowdXAEgad5O9NnYcsNPLCPZJD++2L9X0PCMODrA= +google.golang.org/genproto/googleapis/rpc v0.0.0-20230530153820-e85fd2cbaebc/go.mod h1:66JfowdXAEgad5O9NnYcsNPLCPZJD++2L9X0PCMODrA= +google.golang.org/genproto/googleapis/rpc v0.0.0-20230629202037-9506855d4529/go.mod h1:66JfowdXAEgad5O9NnYcsNPLCPZJD++2L9X0PCMODrA= +google.golang.org/grpc v1.54.0/go.mod h1:PUSEXI6iWghWaB6lXM4knEgpJNu2qUcKfDtNci3EC2g= +google.golang.org/grpc v1.55.0/go.mod h1:iYEXKGkEBhg1PjZQvoYEVPTDkHo1/bjTnfwTeGONTY8= +google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= diff --git a/rly/sample-rly.json b/rly/sample-rly.json new file mode 100644 index 000000000..c1181d3bc --- /dev/null +++ b/rly/sample-rly.json @@ -0,0 +1,26 @@ +{ + "type": "cosmos", + "value": { + "key": "", + "chain-id": "", + "rpc-addr": "", + "account-prefix": "saga", + "keyring-backend": "test", + "gas-adjustment": 1.2, + "gas-prices": "0stake", + "min-gas-amount": 0, + "max-gas-amount": 0, + "debug": true, + "timeout": "20s", + "block-timeout": "", + "output-format": "json", + "sign-mode": "direct", + "extra-codecs": [], + "coin-type": null, + "signing-algorithm": "", + "broadcast-mode": "batch", + "min-loop-duration": 0, + "extension-options": [], + "feegrants": null + } +} \ No newline at end of file diff --git a/rly/start-rly.sh b/rly/start-rly.sh index 6cbe3673d..8f9df40ca 100755 --- a/rly/start-rly.sh +++ b/rly/start-rly.sh @@ -1,52 +1,250 @@ #!/bin/bash -KEYPASSWD=${KEYPASSWD:-DoNoTuSeInPrOd} - -rly config init - -echo $RELAYER_CHAINLET_MNEMONIC > mnemo.file.sevm -echo $RELAYER_SPC_MNEMONIC > mnemo.file.spc - -mv /root/tmp/sevm_111-1.json.example /root/tmp/$CHAINLET_CHAIN_ID.json -mv /root/tmp/sevm_111-2.json.example /root/tmp/$SPC_CHAIN_ID.json - -cat /root/tmp/$CHAINLET_CHAIN_ID.json | jq '.value."chain-id"="'$CHAINLET_CHAIN_ID'"' > /root/tmp/$CHAINLET_CHAIN_ID.json.tmp && mv /root/tmp/$CHAINLET_CHAIN_ID.json.tmp /root/tmp/$CHAINLET_CHAIN_ID.json -cat /root/tmp/$SPC_CHAIN_ID.json | jq '.value."chain-id"="'$SPC_CHAIN_ID'"' > /root/tmp/$SPC_CHAIN_ID.json.tmp && mv /root/tmp/$SPC_CHAIN_ID.json.tmp /root/tmp/$SPC_CHAIN_ID.json - -# TODO: hardcoded port; http -cat /root/tmp/$CHAINLET_CHAIN_ID.json | jq '.value."rpc-addr"="'$CHAINLET_RPC_ADDRESS'"' > /root/tmp/$CHAINLET_CHAIN_ID.json.tmp && mv /root/tmp/$CHAINLET_CHAIN_ID.json.tmp /root/tmp/$CHAINLET_CHAIN_ID.json -cat /root/tmp/$SPC_CHAIN_ID.json | jq '.value."rpc-addr"="'$SPC_RPC_EXTERNAL_ADDRESS'"' > /root/tmp/$SPC_CHAIN_ID.json.tmp && mv /root/tmp/$SPC_CHAIN_ID.json.tmp /root/tmp/$SPC_CHAIN_ID.json - -cat /root/tmp/$CHAINLET_CHAIN_ID.json | jq '.value."keyring-backend"="file"' > /root/tmp/$CHAINLET_CHAIN_ID.json.tmp && mv /root/tmp/$CHAINLET_CHAIN_ID.json.tmp /root/tmp/$CHAINLET_CHAIN_ID.json -cat /root/tmp/$SPC_CHAIN_ID.json | jq '.value."keyring-backend"="file"' > /root/tmp/$SPC_CHAIN_ID.json.tmp && mv /root/tmp/$SPC_CHAIN_ID.json.tmp /root/tmp/$SPC_CHAIN_ID.json - -cat /root/tmp/$CHAINLET_CHAIN_ID.json | jq '.value."gas-prices"="'1$CHAINLET_DENOM'"' > /root/tmp/$CHAINLET_CHAIN_ID.json.tmp && mv /root/tmp/$CHAINLET_CHAIN_ID.json.tmp /root/tmp/$CHAINLET_CHAIN_ID.json -cat /root/tmp/$SPC_CHAIN_ID.json | jq '.value."gas-prices"="'1$SPC_DENOM'"' > /root/tmp/$SPC_CHAIN_ID.json.tmp && mv /root/tmp/$SPC_CHAIN_ID.json.tmp /root/tmp/$SPC_CHAIN_ID.json - -cp /root/tmp/$CHAINLET_CHAIN_ID.json /root/.relayer/config/ -cp /root/tmp/$SPC_CHAIN_ID.json /root/.relayer/config/ - -rly chains add $CHAINLET_CHAIN_ID --file /root/.relayer/config/$CHAINLET_CHAIN_ID.json -rly chains add $SPC_CHAIN_ID --file /root/.relayer/config/$SPC_CHAIN_ID.json - -yq -i '.chains."'$CHAINLET_CHAIN_ID'".value.extra-codecs |= ["ethermint"]' /root/.relayer/config/config.yaml - -(echo $KEYPASSWD; echo $KEYPASSWD) | rly keys restore $CHAINLET_CHAIN_ID key1 "$(cat /root/mnemo.file.sevm)" --coin-type=60 -(echo $KEYPASSWD; echo $KEYPASSWD) | rly keys restore $SPC_CHAIN_ID key2 "$(cat /root/mnemo.file.spc)" - -rly paths new $CHAINLET_CHAIN_ID $SPC_CHAIN_ID dp - -# we want to make sure that chainlet is up and running -while true -do - rly q node-state $CHAINLET_CHAIN_ID +#from container environment vars +SLEEPTIME=${SLEEPTIME:-5} # if unset, set to 5 seconds +SLEEPTIME_IBC=${SLEEPTIME_IBC:-60} # Amount of time to wait for an IBC channel to be created +SLEEPTIME_BLOCKWAIT=${SLEEPTIME_BLOCKWAIT:-1} + +PROVIDER_CHAIN=${PROVIDER_CHAIN:-provider} +CONSUMER_CHAIN=${CONSUMER_CHAIN:-consumer} +PROVIDER_RLY_GASPRICE=${PROVIDER_RLY_GASPRICE:-0stake} +CONSUMER_RLY_GASPRICE=${CONSUMER_RLY_GASPRICE:-0stake} +PROVIDER_RLY_CLIENTID=${PROVIDER_RLY_CLIENTID:-07-tendermint-0} +CONSUMER_RLY_CLIENTID=${CONSUMER_RLY_CLIENTID:-07-tendermint-0} +RLY_SRC_PORT=${RLY_SRC_PORT:-transfer} +RLY_DST_PORT=${RLY_DST_PORT:-transfer} +RLY_ORDERING=${RLY_ORDERING:-unordered} +RLY_CHANNEL_VERSION=${RLY_CHANNEL_VERSION:-1} +RLY_DEBUG=${RLY_DEBUG:-false} + +KEYRING=${KEYRING:-file} +TESTKEYRING="test" +KEYALGO=${KEYALGO:-"secp256k1"} +KEYNAME=relayer +KEYPASSWD=${KEYPASSWD:-"passw0rdK3y"} + +SESSION_STAMP=RLY_`date +%m%d%Y%H%M%S` +TMPDIR=/tmp +LOGDIR=/tmp +LOGFILE=${LOGDIR}/${SESSION_STAMP}.log +ERRFILE=${LOGDIR}/${SESSION_STAMP}.err + +Logger() +{ + MSG=$1 + echo "`date` $MSG" >> $LOGFILE + echo "`date` $MSG" +} + +CheckRetcode() +{ + # ERRTYPE 1 = HARD ERROR (Exit script), ERRTYPE <> 1 = SOFT ERROR (Report and Continue) + local RETCODE=$1 + local ERRTYPE=$2 + local MSG=$3 + if [ $RETCODE -ne 0 ]; + then + if [ $ERRTYPE -eq 1 ]; + then + Logger "$MSG" + exit 1 + else + Logger "$MSG" + fi + else + Logger "Return code was $RETCODE. Success!" + fi +} + +ValidateEnvVar() +{ + local ENVVAR=$1 + Logger "Validating environment variable $ENVVAR" + local EXITIFUNSET=${2:-1} # exit if env var is not set. Pass 1 for true, 0 for false i.e. if 0, script will continue executing. Default: True (exit) + local ECHOVAL=${3:-1} # echo the value of the variable in a log entry. Pass 1 = true, 0 = false. Default: True (will echo) + if [[ -z ${!ENVVAR} ]]; + then + Logger "Environment variable $ENVVAR is not set" + if [ $EXITIFUNSET -eq 1 ]; + then + Logger "Exiting in error as environment variable $ENVVAR is not set" + exit 1 + else + Logger "Continuing even though environment variable $ENVVAR is not set" + fi + fi + if [ $ECHOVAL -eq 1 ]; + then + Logger "Environment variable $ENVVAR is set to ${!ENVVAR}" + fi + Logger "Finished validating environment variable $ENVVAR" +} + +ValidateAndEchoEnvVars() +{ + Logger "Starting function ValidateAndEchoEnvVars" + ValidateEnvVar PROVIDER_CHAIN + ValidateEnvVar CONSUMER_CHAIN + ValidateEnvVar PROVIDER_CHAINID + ValidateEnvVar CONSUMER_CHAINID + ValidateEnvVar PROVIDER_RLY_MNEMONIC 1 0 + ValidateEnvVar CONSUMER_RLY_MNEMONIC 1 0 + ValidateEnvVar PROVIDER_RPC_ADDRESS + ValidateEnvVar CONSUMER_RPC_ADDRESS + ValidateEnvVar PROVIDER_RLY_GASPRICE + ValidateEnvVar CONSUMER_RLY_GASPRICE + ValidateEnvVar PROVIDER_RLY_CLIENTID + ValidateEnvVar CONSUMER_RLY_CLIENTID + ValidateEnvVar RLY_SRC_PORT + ValidateEnvVar RLY_DST_PORT + ValidateEnvVar RLY_ORDERING + ValidateEnvVar RLY_CHANNEL_VERSION + ValidateEnvVar RLY_DEBUG + ValidateEnvVar KEYRING + ValidateEnvVar SLEEPTIME 0 1 + ValidateEnvVar KEYALGO + ValidateEnvVar KEYPASSWD + ValidateEnvVar TMPDIR + Logger "Exiting function ValidateAndEchoEnvVars" +} + +InitRelayer() +{ + Logger "Starting function InitRelayer" + rm -rf .relayer 1>> $LOGFILE 2>> $ERRFILE + rly config init --home .relayer 1>> $LOGFILE 2>> $ERRFILE + RETCODE=$? + CheckRetcode $RETCODE 1 "Could not initialize relayer. Return code was $RETCODE. Exiting" + Logger "Exiting function InitRelayer" +} + +GenerateChainFiles() +{ + Logger "Starting function GenerateChainFiles" + jq --arg KEY $KEYNAME '.value.key = $KEY' /root/provider-rly.json > /root/provider-rly-tmp.json && mv /root/provider-rly-tmp.json /root/provider-rly.json + jq --arg CHAINID $PROVIDER_CHAINID '.value."chain-id" = $CHAINID' /root/provider-rly.json > /root/provider-rly-tmp.json && mv /root/provider-rly-tmp.json /root/provider-rly.json + jq --arg RPCADDR $PROVIDER_RPC_ADDRESS '.value."rpc-addr" = $RPCADDR' /root/provider-rly.json > /root/provider-rly-tmp.json && mv /root/provider-rly-tmp.json /root/provider-rly.json + jq --arg KEYRING $KEYRING '.value."keyring-backend" = $KEYRING' /root/provider-rly.json > /root/provider-rly-tmp.json && mv /root/provider-rly-tmp.json /root/provider-rly.json + jq --argjson DEBUG $RLY_DEBUG '.value.debug = $DEBUG' /root/provider-rly.json > /root/provider-rly-tmp.json && mv /root/provider-rly-tmp.json /root/provider-rly.json + jq --arg GAS $PROVIDER_RLY_GASPRICE '.value."gas-prices" = $GAS' /root/provider-rly.json > /root/provider-rly-tmp.json && mv /root/provider-rly-tmp.json /root/provider-rly.json + + jq --arg KEY $KEYNAME '.value.key = $KEY' /root/consumer-rly.json > /root/consumer-rly-tmp.json && mv /root/consumer-rly-tmp.json /root/consumer-rly.json + jq --arg CHAINID $CONSUMER_CHAINID '.value."chain-id" = $CHAINID' /root/consumer-rly.json > /root/consumer-rly-tmp.json && mv /root/consumer-rly-tmp.json /root/consumer-rly.json + jq --arg RPCADDR $CONSUMER_RPC_ADDRESS '.value."rpc-addr" = $RPCADDR' /root/consumer-rly.json > /root/consumer-rly-tmp.json && mv /root/consumer-rly-tmp.json /root/consumer-rly.json + jq --arg KEYRING $KEYRING '.value."keyring-backend" = $KEYRING' /root/consumer-rly.json > /root/consumer-rly-tmp.json && mv /root/consumer-rly-tmp.json /root/consumer-rly.json + jq --argjson DEBUG $RLY_DEBUG '.value.debug = $DEBUG' /root/consumer-rly.json > /root/consumer-rly-tmp.json && mv /root/consumer-rly-tmp.json /root/consumer-rly.json + jq --arg GAS $CONSUMER_RLY_GASPRICE '.value."gas-prices" = $GAS' /root/consumer-rly.json > /root/consumer-rly-tmp.json && mv /root/consumer-rly-tmp.json /root/consumer-rly.json + Logger "Exiting function GenerateChainFiles" +} + +ConfigRelayer() +{ + Logger "Starting function ConfigRelayer" + local PATHNAME=pc + rly chains add $PROVIDER_CHAIN --file /root/provider-rly.json --home .relayer 1>> $LOGFILE 2>> $ERRFILE RETCODE=$? - if [[ ${RETCODE} -eq 0 ]]; then - break + CheckRetcode $RETCODE 1 "Could not add chain $PROVIDER_CHAINID to relayer config. Return code was $RETCODE. Exiting" + rly chains add $CONSUMER_CHAIN --file /root/consumer-rly.json --home .relayer 1>> $LOGFILE 2>> $ERRFILE + RETCODE=$? + CheckRetcode $RETCODE 1 "Could not add chain $CONSUMER_CHAINID to relayer config. Return code was $RETCODE. Exiting" + Logger "Added both provider and consumer chains" + Logger "Restoring keys from provided mnemonics" + if [[ "$KEYRING" == "file" ]]; + then + (echo $KEYPASSWD; echo $KEYPASSWD) | rly keys restore $PROVIDER_CHAIN relayer "${PROVIDER_RLY_MNEMONIC}" --home .relayer 1>> $LOGFILE 2>> $ERRFILE + RETCODE=$? + CheckRetcode $RETCODE 1 "Could not restore keys from mnemonic for chain $PROVIDER_CHAINID. Return code was $RETCODE. Exiting" + (echo $KEYPASSWD; echo $KEYPASSWD) | rly keys restore $CONSUMER_CHAIN relayer "${CONSUMER_RLY_MNEMONIC}" --home .relayer 1>> $LOGFILE 2>> $ERRFILE + RETCODE=$? + CheckRetcode $RETCODE 1 "Could not restore keys from mnemonic for chain $CONSUMER_CHAINID. Return code was $RETCODE. Exiting" + else + rly keys restore $PROVIDER_CHAIN relayer "${PROVIDER_RLY_MNEMONIC}" --home .relayer 1>> $LOGFILE 2>> $ERRFILE + RETCODE=$? + CheckRetcode $RETCODE 1 "Could not restore keys from mnemonic for chain $PROVIDER_CHAINID. Return code was $RETCODE. Exiting" + rly keys restore $CONSUMER_CHAIN relayer "${CONSUMER_RLY_MNEMONIC}" --home .relayer 1>> $LOGFILE 2>> $ERRFILE + RETCODE=$? + CheckRetcode $RETCODE 1 "Could not restore keys from mnemonic for chain $CONSUMER_CHAINID. Return code was $RETCODE. Exiting" fi - sleep 5 -done - -(echo $KEYPASSWD; sleep 1; echo $KEYPASSWD) | rly transact link dp - -(echo $KEYPASSWD; sleep 1; echo $KEYPASSWD) | rly start dp + Logger "Created keys" + Logger "Creating relayer paths..." + rly paths new $CONSUMER_CHAINID $PROVIDER_CHAINID $PATHNAME --home .relayer 1>> $LOGFILE 2>> $ERRFILE + RETCODE=$? + CheckRetcode $RETCODE 1 "Could not create a new path for chains $PROVIDER_CHAINID and $CONSUMER_CHAINID. Return code was $RETCODE. Exiting" + Logger "New path $PATHNAME successfully created for chains $PROVIDER_CHAINID and $CONSUMER_CHAINID" + rly paths update $PATHNAME --src-client-id $CONSUMER_RLY_CLIENTID --dst-client-id $PROVIDER_RLY_CLIENTID --home .relayer 1>> $LOGFILE 2>> $ERRFILE + RETCODE=$? + CheckRetcode $RETCODE 1 "Could not update the path with source/destination client-id for chains $PROVIDER_CHAINID and $CONSUMER_CHAINID. Return code was $RETCODE. Exiting" + Logger "Path $PATHNAME successfully updated for chains $PROVIDER_CHAINID and $CONSUMER_CHAINID" + Logger "Exiting function ConfigRelayer" +} + +LinkRelayer() +{ + Logger "Starting function LinkRelayer" + local cnt=0 + local RETCODE_LNK=0 + Logger "Now connecting $PROVIDER_CHAIN and $CONSUMER_CHAIN. This can take a few minutes..." + until [ $cnt -ge 3 ]; + do + (echo $KEYPASSWD; sleep 1; echo $KEYPASSWD) | rly transact link pc --home .relayer --src-port $RLY_SRC_PORT --dst-port $RLY_DST_PORT --order $RLY_ORDERING --version $RLY_CHANNEL_VERSION 1>> $LOGFILE 2>> $ERRFILE + RETCODE_LNK=$? + Logger "DEBUG RETCODE is $RETCODE_LNK" + if [ $RETCODE_LNK -ne 0 ]; + then + cnt=$(( cnt + 1 )) + Logger "DEBUG cnt = $cnt" + Logger "DEBUG error is `tail -15 $ERRFILE`" + sleep 1 + else + Logger "DEBUG break invoked" + break + fi + done + CheckRetcode $RETCODE_LNK 1 "Could not create a connection between chains $PROVIDER_CHAINID and $CONSUMER_CHAINID after 3 attempts. Exiting" + Logger "Chains $PROVIDER_CHAINID and $CONSUMER_CHAINID successfully connected" + Logger "Exiting function LinkRelayer" +} + +CheckLaunchReadiness() +{ + Logger "Starting function CheckLaunchReadiness" + # we want to make sure that chainlet is up and running + while true + do + rly q node-state $PROVIDER_CHAIN --home .relayer 1>> $LOGFILE 2>> $ERRFILE + RETCODEP=$? + rly q node-state $CONSUMER_CHAIN --home .relayer 1>> $LOGFILE 2>> $ERRFILE + RETCODEC=$? + if [[ ${RETCODEP} -eq 0 && ${RETCODEC} -eq 0 ]]; then + break + fi + Logger "Waiting for provider chain $PROVIDER_CHAINID and consumer chain $CONSUMER_CHAINID to come online" + sleep $SLEEPTIME + done + Logger "Ensuring both provider and consumer chains are producing blocks" + local BLOCKNUM=3 # Height should be at least 2 in order to link the chains via IBC + while true + do + rly q header $PROVIDER_CHAIN $BLOCKNUM --home .relayer 1>> $LOGFILE 2>> $ERRFILE + RETCODEP=$? + rly q header $CONSUMER_CHAIN $BLOCKNUM --home .relayer 1>> $LOGFILE 2>> $ERRFILE + RETCODEC=$? + if [[ ${RETCODEP} -eq 0 && ${RETCODEC} -eq 0 ]]; then + break + fi + Logger "Waiting for provider chain $PROVIDER_CHAINID and consumer chain $CONSUMER_CHAINID to produce blocks" + sleep $SLEEPTIME + done + Logger "Both provider and consumer chains are online and producing blocks. Continuing" + Logger "Exiting function CheckLaunchReadiness" +} + + +## MAIN +ValidateAndEchoEnvVars +InitRelayer +GenerateChainFiles +ConfigRelayer +CheckLaunchReadiness +LinkRelayer +(echo $KEYPASSWD; sleep 1; echo $KEYPASSWD) | rly start pc --home .relayer diff --git a/saga.Dockerfile b/saga.Dockerfile index f779b9743..2b7de22c5 100644 --- a/saga.Dockerfile +++ b/saga.Dockerfile @@ -23,6 +23,8 @@ COPY --from=build-env /root/rly/start-rly.sh /root/start-rly.sh RUN mkdir -p /root/tmp COPY --from=build-env /root/rly/sevm_111-1.json.example /root/tmp/ COPY --from=build-env /root/rly/sevm_111-2.json.example /root/tmp/ +COPY --from=build-env /root/rly/sample-rly.json /root/provider-rly.json +COPY --from=build-env /root/rly/sample-rly.json /root/consumer-rly.json RUN chmod -R 755 /root/start-rly.sh