فهرست منبع

aptos: deploy contracts and register in Tilt

Csongor Kiss 3 سال پیش
والد
کامیت
09debeb780
7فایلهای تغییر یافته به همراه47 افزوده شده و 12 حذف شده
  1. 1 0
      Dockerfile.const
  2. 4 3
      Tiltfile
  3. 0 5
      aptos/Dockerfile
  4. 6 1
      aptos/scripts/deploy
  5. 24 0
      aptos/scripts/register_devnet
  6. 1 1
      clients/js/aptos.ts
  7. 11 2
      devnet/aptos-localnet.yaml

+ 1 - 0
Dockerfile.const

@@ -46,3 +46,4 @@ COPY --from=const-build /scripts/.env.hex terra/tools/.env
 COPY --from=const-build /scripts/.env.hex cosmwasm/tools/.env
 COPY --from=const-build /scripts/.env.hex algorand/.env
 COPY --from=const-build /scripts/.env.hex near/.env
+COPY --from=const-build /scripts/.env.hex aptos/.env

+ 4 - 3
Tiltfile

@@ -177,9 +177,9 @@ def build_node_yaml():
                     "--aptosRPC",
                     "http://aptos:8080",
                     "--aptosAccount",
-                    "277fa055b6a73c42c0662d5236c65c864ccbf2d4abd21f174a30c8b786eab84b",
+                    "de0036a9600559e295d5f6802ef6f3f802f510366e0c23912b0655d972166017",
                     "--aptosHandle",
-                    "0x277fa055b6a73c42c0662d5236c65c864ccbf2d4abd21f174a30c8b786eab84b::state::WormholeMessageHandle",
+                    "0xde0036a9600559e295d5f6802ef6f3f802f510366e0c23912b0655d972166017::state::WormholeMessageHandle",
                 ]
 
             if evm2:
@@ -263,6 +263,8 @@ if terra_classic:
     guardian_resource_deps = guardian_resource_deps + ["terra-terrad"]
 if terra2:
     guardian_resource_deps = guardian_resource_deps + ["terra2-terrad"]
+if aptos:
+    guardian_resource_deps = guardian_resource_deps + ["aptos"]
 
 k8s_resource(
     "guardian",
@@ -742,7 +744,6 @@ if aptos:
         context = "aptos",
         dockerfile = "aptos/Dockerfile",
         target = "aptos",
-        only = ["Dockerfile", "node_builder.sh", "start_node.sh", "README.md", "cert.pem"],
     )
 
     k8s_resource(

+ 0 - 5
aptos/Dockerfile

@@ -15,11 +15,6 @@ COPY Makefile Makefile
 COPY scripts scripts
 COPY start_node.sh start_node.sh
 
-FROM aptos AS boot
-
-WORKDIR /tmp
-COPY .env .env
-
 FROM aptos AS tests
 
 WORKDIR /tmp

+ 6 - 1
aptos/scripts/deploy

@@ -2,7 +2,10 @@
 
 set -euo pipefail
 
-GUARDIAN_ADDR=0xbeFA429d57cD18b7F8A4d91A2da9AB4AF05d0FBe
+DOTENV=$(dirname $0)/../.env
+[[ -f "$DOTENV" ]] && . "$DOTENV"
+
+GUARDIAN_ADDR="${INIT_SIGNERS_CSV:-0xbeFA429d57cD18b7F8A4d91A2da9AB4AF05d0FBe}"
 WORMHOLE_ADDR=$(worm contract devnet aptos Core)
 TOKEN_BRIDGE_ADDR=$(worm contract devnet aptos TokenBridge)
 DEPLOYER_ADDR=0x277fa055b6a73c42c0662d5236c65c864ccbf2d4abd21f174a30c8b786eab84b
@@ -29,3 +32,5 @@ worm aptos deploy --network devnet ../examples/core_messages --named-addresses "
 
 # Deploy coin
 #worm aptos deploy --network devnet ../wormhole --named-addresses $NAMED_ADDRS
+
+echo "Deployments successful."

+ 24 - 0
aptos/scripts/register_devnet

@@ -0,0 +1,24 @@
+#!/bin/bash
+
+set -e
+
+DOTENV=../.env
+[ -f $DOTENV ] || (echo "$DOTENV does not exist." >&2; exit 1)
+
+# 1. load variables from .env file
+. $DOTENV
+
+# 2. next we get all the token bridge registration VAAs from the environment
+# if a new VAA is added, this will automatically pick it up
+VAAS=$(set | grep "REGISTER_.*_TOKEN_BRIDGE_VAA" | grep -v APTOS | cut -d '=' -f1)
+
+# TODO: this will not be needed when the sdk is published
+TOKEN_BRIDGE_ADDR=$(worm contract devnet aptos TokenBridge)
+
+# 3. use 'worm' to submit each registration VAA
+for VAA in $VAAS
+do
+    VAA=${!VAA}
+    worm submit $VAA --chain aptos --contract-address $TOKEN_BRIDGE_ADDR --network devnet
+done
+echo "Registrations successful."

+ 1 - 1
clients/js/aptos.ts

@@ -163,7 +163,7 @@ export async function callEntryFunc(
     TxnBuilderTypes.AccountAddress.fromHex(accountFrom.address()),
     BigInt(sequenceNumber),
     txPayload,
-    BigInt(20000), //max gas to be used. TODO(csongor): we could compute this from the simulation below...
+    BigInt(30000), //max gas to be used. TODO(csongor): we could compute this from the simulation below...
     BigInt(100), //price per unit gas TODO(csongor): we should get this dynamically
     BigInt(Math.floor(Date.now() / 1000) + 10),
     new TxnBuilderTypes.ChainId(chainId),

+ 11 - 2
devnet/aptos-localnet.yaml

@@ -55,5 +55,14 @@ spec:
           readinessProbe:
             tcpSocket:
               port: 8081
-
-      restartPolicy: Always
+        - name: aptos-contracts
+          image: aptos-node
+          command: ["/bin/bash", "-c"]
+          args: ["cd /tmp/scripts && ./deploy && ./register_devnet && touch success && sleep infinity"]
+          readinessProbe:
+            periodSeconds: 1
+            failureThreshold: 300
+            exec:
+              command:
+                - cat
+                - /tmp/scripts/success