From 05edb3d14f914a99ca8e12359d829dea7539ce41 Mon Sep 17 00:00:00 2001 From: Stan Drozd Date: Thu, 28 Oct 2021 13:48:43 +0200 Subject: [PATCH] pyth2wormhole: rename p2w-client service to p2w-attest Change-Id: I34a53146919c12ab41b958cc8cd57108ee509faa --- Tiltfile | 20 +++------ devnet/{p2w-client.yaml => p2w-attest.yaml} | 26 +++++++----- devnet/p2w-relay.yaml | 41 +++++++++++++++++++ devnet/pyth.yaml | 3 -- solana/Dockerfile.wasm | 1 + ...rfile.p2w-client => Dockerfile.p2w-attest} | 1 + third_party/pyth/p2w-sdk/Dockerfile | 10 ++++- 7 files changed, 71 insertions(+), 31 deletions(-) rename devnet/{p2w-client.yaml => p2w-attest.yaml} (62%) create mode 100644 devnet/p2w-relay.yaml rename third_party/pyth/{Dockerfile.p2w-client => Dockerfile.p2w-attest} (95%) diff --git a/Tiltfile b/Tiltfile index 1f3347c3..a288db08 100644 --- a/Tiltfile +++ b/Tiltfile @@ -198,30 +198,20 @@ if pyth: # pyth2wormhole client autoattester docker_build( - ref = "p2w-client", + ref = "p2w-attest", context = ".", only = ["./solana", "./third_party"], - dockerfile = "./third_party/pyth/Dockerfile.p2w-client", + dockerfile = "./third_party/pyth/Dockerfile.p2w-attest", ignore = ["./solana/*/target"], ) - k8s_yaml_with_ns("devnet/p2w-client.yaml") - + k8s_yaml_with_ns("devnet/p2w-attest.yaml") k8s_resource( - "p2w-client", - resource_deps = ["solana-devnet", "pyth"], + "p2w-attest", + resource_deps = ["solana-devnet", "pyth", "guardian"], port_forwards = [], ) - # pyth2wormhole JS SDK test - local_resource( - name = "p2w-sdk-test", - resource_deps = ["wasm-gen"], - deps = ["third_party/pyth", "ethereum", "sdk"], - cmd = "tilt docker build -- -f ./third_party/pyth/p2w-sdk/Dockerfile .", - env = {"DOCKER_BUILDKIT": "1"}, - ) - k8s_yaml_with_ns("devnet/eth-devnet.yaml") k8s_resource("eth-devnet", port_forwards = [ diff --git a/devnet/p2w-client.yaml b/devnet/p2w-attest.yaml similarity index 62% rename from devnet/p2w-client.yaml rename to devnet/p2w-attest.yaml index dce78147..471c334a 100644 --- a/devnet/p2w-client.yaml +++ b/devnet/p2w-attest.yaml @@ -2,38 +2,38 @@ apiVersion: v1 kind: Service metadata: - name: p2w-client + name: p2w-attest labels: - app: p2w-client + app: p2w-attest spec: ports: - - port: 8001 - name: http + - port: 4343 + name: p2w-attest protocol: TCP clusterIP: None selector: - app: p2w-client + app: p2w-attest --- apiVersion: apps/v1 kind: StatefulSet metadata: - name: p2w-client + name: p2w-attest spec: selector: matchLabels: - app: p2w-client - serviceName: p2w-client + app: p2w-attest + serviceName: p2w-attest replicas: 1 template: metadata: labels: - app: p2w-client + app: p2w-attest spec: restartPolicy: Always terminationGracePeriodSeconds: 0 containers: - - name: p2w-client - image: p2w-client + - name: p2w-attest + image: p2w-attest command: - python3 - /usr/src/pyth/p2w_autoattest.py @@ -43,3 +43,7 @@ spec: port: 2000 periodSeconds: 1 failureThreshold: 300 + ports: + - containerPort: 4343 + name: p2w-attest + protocol: TCP diff --git a/devnet/p2w-relay.yaml b/devnet/p2w-relay.yaml new file mode 100644 index 00000000..616236c6 --- /dev/null +++ b/devnet/p2w-relay.yaml @@ -0,0 +1,41 @@ +--- +apiVersion: v1 +kind: Service +metadata: + name: p2w-relay + labels: + app: p2w-relay +spec: + clusterIP: None + selector: + app: p2w-relay +--- +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: p2w-relay +spec: + selector: + matchLabels: + app: p2w-relay + serviceName: p2w-relay + replicas: 1 + template: + metadata: + labels: + app: p2w-relay + spec: + restartPolicy: Always + terminationGracePeriodSeconds: 0 + containers: + - name: p2w-relay + image: p2w-relay + command: + - node + - /usr/src/third_party/pyth/p2w-sdk/lib/autorelayer.js + tty: true + readinessProbe: + tcpSocket: + port: 2000 + periodSeconds: 1 + failureThreshold: 300 diff --git a/devnet/pyth.yaml b/devnet/pyth.yaml index d05c42a1..8e0a24a8 100644 --- a/devnet/pyth.yaml +++ b/devnet/pyth.yaml @@ -10,9 +10,6 @@ spec: selector: app: pyth ports: - - port: 8898 - name: pyth-tx - protocol: TCP - port: 4242 name: pyth-accounts protocol: TCP diff --git a/solana/Dockerfile.wasm b/solana/Dockerfile.wasm index 0e174b19..796788b0 100644 --- a/solana/Dockerfile.wasm +++ b/solana/Dockerfile.wasm @@ -76,6 +76,7 @@ COPY --from=build /usr/src/bridge/pyth2wormhole/program/bundler third_party/pyth COPY --from=build /usr/src/bridge/bridge/program/bundler explorer/wasm/core COPY --from=build /usr/src/bridge/modules/token_bridge/program/bundler explorer/wasm/token COPY --from=build /usr/src/bridge/modules/nft_bridge/program/bundler explorer/wasm/nft +COPY --from=build /usr/src/bridge/bridge/program/bundler third_party/pyth/p2w-sdk/src/solana/wormhole-core COPY --from=build /usr/src/bridge/bridge/program/nodejs sdk/js/src/solana/core-node COPY --from=build /usr/src/bridge/modules/token_bridge/program/nodejs sdk/js/src/solana/token-node diff --git a/third_party/pyth/Dockerfile.p2w-client b/third_party/pyth/Dockerfile.p2w-attest similarity index 95% rename from third_party/pyth/Dockerfile.p2w-client rename to third_party/pyth/Dockerfile.p2w-attest index a0d57034..bbdcb6cf 100644 --- a/third_party/pyth/Dockerfile.p2w-client +++ b/third_party/pyth/Dockerfile.p2w-attest @@ -13,5 +13,6 @@ RUN --mount=type=cache,target=/root/.cache \ chmod a+rx /usr/src/pyth/*.py ENV P2W_OWNER_KEYPAIR="/usr/src/solana/keys/p2w_owner.json" +ENV P2W_ATTESTATIONS_PORT="4343" ENV PYTH_PUBLISHER_KEYPAIR="/usr/src/solana/keys/pyth_publisher.json" ENV PYTH_PROGRAM_KEYPAIR="/usr/src/solana/keys/pyth_program.json" diff --git a/third_party/pyth/p2w-sdk/Dockerfile b/third_party/pyth/p2w-sdk/Dockerfile index b76b301a..25eae931 100644 --- a/third_party/pyth/p2w-sdk/Dockerfile +++ b/third_party/pyth/p2w-sdk/Dockerfile @@ -12,9 +12,15 @@ ADD sdk/js/ . RUN --mount=type=cache,target=/home/node/.npm \ npm ci -# Build p2w-sdk +# Build p2w-sdk in dir preserving directory structure +WORKDIR /usr/src/third_party/pyth/p2w-sdk +COPY third_party/pyth/p2w-sdk/package.json third_party/pyth/p2w-sdk/package-lock.json . +RUN --mount=type=cache,target=/root/.cache \ + --mount=type=cache,target=/root/.npm \ + npm ci + WORKDIR /usr/src/third_party/pyth/p2w-sdk COPY third_party/pyth/p2w-sdk . RUN --mount=type=cache,target=/root/.cache \ --mount=type=cache,target=/root/.npm \ - npm ci && npm run build-test && npm run test + npm run build-test