forked from atticlab/wormhole
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Tiltfile
250 lines (195 loc) · 7.46 KB
/
Tiltfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
# This Tiltfile contains the deployment and build config for the Wormhole devnet.
#
# We use Buildkit cache mounts and careful layering to avoid unnecessary rebuilds - almost
# all source code changes result in small, incremental rebuilds. Dockerfiles are written such
# that, for example, changing the contract source code won't cause Solana itself to be rebuilt.
#
# Graph of dependencies between Dockerfiles, image refs and k8s StatefulSets:
#
# Dockerfile Image ref StatefulSet
# +------------------------------------------------------------------------------+
# rust-1.*
# + +-----------------+
# +-> Dockerfile.agent +-> solana-agent +--------+-----> | [agent] |
# | | +--> | guardian-N |
# +-> solana/Dockerfile +-> solana-contract +---+ | | +-- --------------+
# | | |
# | | |
# | | | +-----------------+
# +--|-----> | solana-devnet |
# golang:1.* +-----> | [setup] |
# + | +-----------------+
# +-> bridge/Dockerfile +-> guardiand-image +---------+
#
#
# node:lts-alpine
# + +-----------------+
# +-> ethereum/Dockerfile +-> eth-node +------------------> | eth-devnet |
# +-----------------+
#
load('ext://namespace', 'namespace_inject', 'namespace_create')
# Runtime configuration
config.define_string("num", False, "Number of guardian nodes to run")
# You do not usually need to set this argument - this argument is for debugging only. If you do use a different
# namespace, note that the "wormhole" namespace is hardcoded in the e2e test and don't forget specifying the argument
# when running "tilt down".
#
config.define_string("namespace", False, "Kubernetes namespace to use")
cfg = config.parse()
num_guardians = int(cfg.get("num", "5"))
namespace = cfg.get("namespace", "wormhole")
# namespace
namespace_create(namespace)
def k8s_yaml_with_ns(objects):
return k8s_yaml(namespace_inject(objects, namespace))
# protos
local_resource(
name = "proto-gen",
deps = ["./proto", "./generate-protos.sh"],
cmd = "./generate-protos.sh",
)
# bridge
docker_build(
ref = "guardiand-image",
context = "bridge",
dockerfile = "bridge/Dockerfile",
)
def build_bridge_yaml():
bridge_yaml = read_yaml_stream("devnet/bridge.yaml")
for obj in bridge_yaml:
if obj["kind"] == "StatefulSet" and obj["metadata"]["name"] == "guardian":
obj["spec"]["replicas"] = num_guardians
container = obj["spec"]["template"]["spec"]["containers"][0]
if container["name"] != "guardiand":
fail("container 0 is not guardiand")
container["command"] += ["--devNumGuardians", str(num_guardians)]
return encode_yaml_stream(bridge_yaml)
k8s_yaml_with_ns(build_bridge_yaml())
k8s_resource("guardian", resource_deps=["proto-gen", "solana-devnet"], port_forwards=[
port_forward(6060, name="Debug/Status Server [:6060]"),
])
# publicRPC proxy that allows grpc over http1, for local development
k8s_yaml_with_ns("./devnet/envoy-proxy.yaml")
k8s_resource("envoy-proxy", resource_deps=["guardian"],
objects=['envoy-proxy:ConfigMap:wormhole'],
port_forwards=[
port_forward(8080, name="gRPC proxy for guardian's publicRPC data [:8080]"),
port_forward(9901, name="gRPC proxy admin [:9901]"), # for proxy debugging
])
# solana agent and cli (runs alongside bridge)
docker_build(
ref="solana-agent",
context=".",
only=["./proto", "./solana"],
dockerfile="Dockerfile.agent",
# Ignore target folders from local (non-container) development.
ignore = ["./solana/target", "./solana/agent/target", "./solana/cli/target"],
)
# solana smart contract
docker_build(
ref = "solana-contract",
context = "solana",
dockerfile = "solana/Dockerfile",
)
# solana local devnet
k8s_yaml_with_ns("devnet/solana-devnet.yaml")
k8s_resource("solana-devnet", port_forwards=[
port_forward(8899, name="Solana RPC [:8899]"),
port_forward(8900, name="Solana WS [:8900]"),
port_forward(9000, name="Solana PubSub [:9000]"),
])
# eth devnet
docker_build(
ref = "eth-node",
context = "./ethereum",
dockerfile = "./ethereum/Dockerfile",
# ignore local node_modules (in case they're present)
ignore = ["./ethereum/node_modules"],
# sync external scripts for incremental development
# (everything else needs to be restarted from scratch for determinism)
#
# This relies on --update-mode=exec to work properly with a non-root user.
# https://github.com/tilt-dev/tilt/issues/3708
live_update = [
sync("./ethereum/src", "/home/node/app/src"),
],
)
k8s_yaml_with_ns("devnet/eth-devnet.yaml")
k8s_resource("eth-devnet", port_forwards=[
port_forward(8545, name="Ganache RPC [:8545]")
])
# qtum devnet
docker_build(
ref = "qtum-contract",
context = "./qtum",
dockerfile = "./qtum/Dockerfile",
# ignore local node_modules (in case they're present)
ignore = ["./qtum/node_modules"],
# sync external scripts for incremental development
# (everything else needs to be restarted from scratch for determinism)
#
# This relies on --update-mode=exec to work properly with a non-root user.
# https://github.com/tilt-dev/tilt/issues/3708
live_update = [
sync("./qtum/src", "/home/node/app/src"),
],
)
k8s_yaml_with_ns("devnet/qtum-devnet.yaml")
k8s_resource("qtum-devnet", port_forwards=[
port_forward(3889, name="Qtum Regtest RPC [:3889]"),
port_forward(23889, name="Janus [:23889]"),
])
# web frontend
docker_build(
ref = "web",
context = "./web",
dockerfile = "./web/Dockerfile",
ignore = ["./web/node_modules"],
live_update = [
sync("./web/src", "/home/node/app/src"),
sync("./web/public", "/home/node/app/public"),
sync("./web/contracts", "/home/node/app/contracts"),
],
)
k8s_yaml_with_ns("devnet/web.yaml")
k8s_resource("web", port_forwards=[
port_forward(3000, name="Experimental Web UI [:3000]")
])
# explorer web app
docker_build(
ref = "explorer",
context = "./explorer",
dockerfile = "./explorer/Dockerfile",
ignore = ["./explorer/node_modules"],
live_update = [
sync("./explorer/src", "/home/node/app/src"),
sync("./explorer/public", "/home/node/app/public"),
],
)
k8s_yaml_with_ns("devnet/explorer.yaml")
k8s_resource("explorer",
resource_deps=["envoy-proxy"],
port_forwards=[
port_forward(8001, name="Explorer Web UI [:8001]")
]
)
# terra devnet
docker_build(
ref = "terra-image",
context = "./terra/devnet",
dockerfile = "terra/devnet/Dockerfile",
)
docker_build(
ref = "terra-contracts",
context = "./terra",
dockerfile = "./terra/Dockerfile",
)
k8s_yaml_with_ns("devnet/terra-devnet.yaml")
k8s_resource(
"terra-lcd",
port_forwards=[port_forward(1317, name="Terra LCD interface [:1317]")]
)
k8s_resource(
"terra-terrad",
port_forwards=[port_forward(26657, name="Terra RPC [:26657]")]
)