Skip to content

Commit f69a91d

Browse files
author
Stanisław Drozd
authored
Add the Squads Mesh program to Tilt and initialize a Vault for it (#421)
* solana-devnet: Deploy a copy of the Mesh multisig program * solana/keys: Add keys for multisig testing * *.py: Remove airdrop, use devnet_setup.sh keypair instead * Dockerfile.p2w-attest: Improve caching - Move cheap Python script additions after the expensive rust build - Cache Cargo's package cache to shorten the "updating crates.io registry" build steps * Add a multisig Tilt resource, k8s yaml and runtime script This contains most of the work on Tilt/testing harness side. * multisig-wh-message-builder: Add init-vault subcommand This new subcommand enables the runtime Python script to create a multisig vault on the fly on the mock Solana devnet. * multisig-wh-message-builder: findProgramAddress -> getMsPDA * mutlisig-wh-message-builder: apply review advice - Use default mesh program address - remove unused program.json - remove redundant null checks - hardcode vault address (it is deterministic against the constant mesh program pubkey) - Start depending on solana-devnet in Tilt - Add carol to vault and set threshold to 2
1 parent 92bb656 commit f69a91d

18 files changed

+419
-114
lines changed

Dockerfile.multisig

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#syntax=docker/dockerfile:1.2@sha256:e2a8561e419ab1ba6b2fe6cbdf49fd92b95912df1cf7d313c3e2230a333fdbcc
2+
FROM ghcr.io/certusone/solana:1.10.31
3+
4+
# This image builds an environment to initialize and use a local
5+
# devnet multisig. It uses Pyth's Mesh client.
6+
7+
RUN apt-get update && apt-get install -yq python3 libudev-dev ncat
8+
9+
RUN curl -fsSL https://deb.nodesource.com/setup_16.x | bash - && apt-get install -y nodejs
10+
11+
WORKDIR /root
12+
13+
# Also used by the multisig provisioning script
14+
ENV MULTISIG_SCRIPT_DIR=/root/pyth/multisig-wh-message-builder
15+
16+
WORKDIR $MULTISIG_SCRIPT_DIR
17+
18+
ENV LOCAL_MULTISIG_SCRIPT_DIR=third_party/pyth/multisig-wh-message-builder
19+
20+
# Add a barebones representation of our deps for Docker layer caching
21+
ADD $LOCAL_MULTISIG_SCRIPT_DIR/package.json \
22+
$LOCAL_MULTISIG_SCRIPT_DIR/package-lock.json \
23+
$LOCAL_MULTISIG_SCRIPT_DIR/tsconfig.json \
24+
.
25+
26+
RUN mkdir src # tsc is run as part of the install, add minimal placeholders to satisfy it
27+
RUN touch src/index.ts
28+
29+
RUN --mount=type=cache,target=/home/node/.cache \
30+
npm ci && cp -r node_modules node_modules_cached
31+
RUN rm -rf node_modules && mv node_modules_cached node_modules
32+
33+
# Add the rest of the code. This ensures that real code changes do not affect the layer caching of `npm ci`
34+
ADD third_party/pyth /root/pyth
35+
ADD solana/keys /usr/src/solana/keys
36+
37+
RUN npm install

Dockerfile.solana

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,15 @@ RUN tar -xvf v${WORMHOLE_REV}.tar.gz
3434
RUN mv wormhole-${WORMHOLE_REV} wormhole
3535
# RUN mkdir -p /usr/src/bridge/wormhole/solana/target
3636

37+
WORKDIR /usr/src/squads
38+
39+
ARG SQUADS_REV=1.2.0
40+
ADD https://github.com/Squads-Protocol/squads-mpl/archive/refs/tags/v${SQUADS_REV}.tar.gz .
41+
42+
RUN tar -xvf v${SQUADS_REV}.tar.gz
43+
RUN mv squads-mpl-${SQUADS_REV} squads-mpl
44+
45+
WORKDIR /usr/src/bridge
3746

3847
ADD solana solana
3948
ADD pythnet pythnet
@@ -48,14 +57,17 @@ WORKDIR /usr/src/bridge/solana
4857
# Build Wormhole Solana programs
4958
RUN --mount=type=cache,target=/usr/src/bridge/wormhole/solana/target \
5059
--mount=type=cache,target=/usr/src/bridge/solana/pyth2wormhole/target \
60+
--mount=type=cache,target=/usr/src/squads/squads-mpl/target \
5161
--mount=type=cache,target=/usr/local/cargo/registry \
5262
--mount=type=cache,target=/root/.cache \
5363
cargo build-bpf --manifest-path "../wormhole/solana/bridge/program/Cargo.toml" -- --locked && \
5464
cargo build-bpf --manifest-path "../wormhole/solana/bridge/cpi_poster/Cargo.toml" -- --locked && \
5565
cargo build-bpf --manifest-path "pyth2wormhole/program/Cargo.toml" -- --locked && \
66+
cargo build-bpf --manifest-path "/usr/src/squads/squads-mpl/programs/mesh/Cargo.toml" -- --locked && \
5667
cp ../wormhole/solana/target/deploy/bridge.so /opt/solana/deps/bridge.so && \
5768
cp ../wormhole/solana/target/deploy/cpi_poster.so /opt/solana/deps/cpi_poster.so && \
58-
cp pyth2wormhole/target/deploy/pyth2wormhole.so /opt/solana/deps/pyth2wormhole.so
69+
cp pyth2wormhole/target/deploy/pyth2wormhole.so /opt/solana/deps/pyth2wormhole.so && \
70+
cp /usr/src/squads/squads-mpl/target/deploy/mesh.so /opt/solana/deps/mesh.so
5971

6072
COPY --from=pyth-oracle-copy /home/pyth/pyth-client/target/oracle.so /opt/solana/deps/pyth_oracle.so
6173

Tiltfile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,3 +351,18 @@ k8s_resource(
351351
labels = ["prometheus"],
352352
trigger_mode = trigger_mode,
353353
)
354+
355+
docker_build(
356+
ref = "multisig",
357+
context = ".",
358+
dockerfile = "Dockerfile.multisig",
359+
)
360+
361+
k8s_yaml_with_ns("devnet/multisig.yaml")
362+
363+
k8s_resource(
364+
"multisig",
365+
resource_deps = ["solana-devnet"],
366+
labels = ["solana"],
367+
trigger_mode = trigger_mode,
368+
)

devnet/multisig.yaml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
---
2+
apiVersion: v1
3+
kind: Service
4+
metadata:
5+
name: multisig
6+
labels:
7+
app: multisig
8+
spec:
9+
clusterIP: None
10+
selector:
11+
app: multisig
12+
---
13+
apiVersion: apps/v1
14+
kind: StatefulSet
15+
metadata:
16+
name: multisig
17+
spec:
18+
selector:
19+
matchLabels:
20+
app: multisig
21+
serviceName: multisig
22+
template:
23+
metadata:
24+
labels:
25+
app: multisig
26+
spec:
27+
restartPolicy: Always
28+
terminationGracePeriodSeconds: 0
29+
containers:
30+
- name: multisig
31+
image: multisig
32+
readinessProbe:
33+
tcpSocket:
34+
port: 2000
35+
periodSeconds: 1
36+
failureThreshold: 300
37+
command:
38+
- python3
39+
- /root/pyth/prepare_multisig.py

devnet/solana-devnet.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ spec:
5050
- --bpf-program
5151
- P2WH424242424242424242424242424242424242424
5252
- /opt/solana/deps/pyth2wormhole.so
53+
- --bpf-program
54+
- SMPLVC8MxZ5Bf5EfF7PaMiTCxoBAcmkbM2vkrvMK8ho # copied from squads-mpl/programs/mesh/src/lib.rs
55+
- /opt/solana/deps/mesh.so
5356
- --log
5457
ports:
5558
- containerPort: 8001

solana/keys/squads/create_key.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[
2+
174, 86, 158, 146, 5, 14, 115, 61, 113, 135, 247, 80, 154, 1, 168, 241, 237,
3+
184, 94, 53, 32, 115, 162, 198, 35, 226, 72, 198, 108, 242, 35, 175, 226, 156,
4+
60, 163, 77, 178, 58, 243, 50, 48, 28, 249, 226, 125, 150, 188, 35, 23, 131,
5+
149, 177, 124, 235, 145, 103, 119, 237, 30, 30, 25, 145, 128
6+
]
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[
2+
172, 234, 168, 90, 159, 133, 183, 38, 206, 220, 115, 240, 201, 186, 191, 12,
3+
38, 133, 233, 164, 62, 92, 164, 155, 149, 133, 68, 83, 168, 233, 67, 12, 1,
4+
134, 165, 231, 211, 192, 216, 167, 186, 77, 109, 120, 172, 131, 36, 27, 95,
5+
207, 60, 228, 128, 201, 74, 109, 132, 176, 165, 156, 62, 146, 247, 75
6+
]

solana/keys/squads/member_alice.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[
2+
196, 148, 217, 170, 205, 37, 40, 95, 214, 198, 118, 8, 52, 12, 250, 196, 95,
3+
138, 15, 163, 55, 212, 93, 215, 72, 15, 11, 125, 221, 67, 196, 176, 219, 38,
4+
22, 196, 10, 226, 177, 210, 88, 255, 245, 194, 140, 68, 61, 222, 16, 199, 151,
5+
74, 161, 165, 178, 130, 124, 60, 99, 168, 130, 199, 251, 149
6+
]

solana/keys/squads/member_bob.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[
2+
238, 68, 150, 179, 87, 216, 135, 224, 44, 190, 97, 182, 75, 109, 167, 101,
3+
146, 236, 95, 142, 190, 237, 251, 179, 186, 54, 100, 145, 166, 113, 222, 85,
4+
0, 42, 46, 190, 161, 239, 138, 33, 240, 218, 84, 112, 63, 54, 170, 185, 140,
5+
21, 211, 216, 57, 146, 161, 87, 170, 18, 29, 186, 231, 15, 241, 91
6+
]

solana/keys/squads/member_carol.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[
2+
140, 155, 132, 14, 35, 183, 53, 188, 155, 194, 27, 24, 251, 0, 26, 136, 173,
3+
9, 140, 24, 155, 157, 172, 249, 41, 205, 221, 234, 114, 32, 128, 179, 120,
4+
208, 86, 87, 116, 157, 31, 72, 104, 90, 21, 155, 104, 85, 190, 144, 253, 151,
5+
189, 47, 172, 194, 170, 246, 97, 26, 211, 96, 203, 106, 98, 216
6+
]

0 commit comments

Comments
 (0)