2020-10-31 04:42:18 -07:00
|
|
|
# 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.
|
|
|
|
#
|
|
|
|
|
2021-07-20 13:33:47 -07:00
|
|
|
load("ext://namespace", "namespace_create", "namespace_inject")
|
2021-07-07 02:39:48 -07:00
|
|
|
load('ext://secret', 'secret_yaml_generic')
|
2020-12-05 07:32:37 -08:00
|
|
|
|
|
|
|
# Runtime configuration
|
|
|
|
|
2020-08-19 05:23:00 -07:00
|
|
|
config.define_string("num", False, "Number of guardian nodes to run")
|
2020-12-05 07:32:37 -08:00
|
|
|
|
|
|
|
# You do not usually need to set this argument - this argument is for debugging only. If you do use a different
|
2021-07-21 10:04:04 -07:00
|
|
|
# namespace, note that the "wormhole" namespace is hardcoded in tests and don't forget specifying the argument
|
2020-12-05 07:32:37 -08:00
|
|
|
# when running "tilt down".
|
|
|
|
#
|
|
|
|
config.define_string("namespace", False, "Kubernetes namespace to use")
|
|
|
|
|
2021-07-07 02:39:48 -07:00
|
|
|
# These arguments will enable writing Guardian events to a BigTable instance.
|
|
|
|
# Writing to BigTable is optional. These arguments are not required to run the devnet.
|
|
|
|
config.define_bool("bigTablePersistence", False, "Enable forwarding guardian events to BigTable")
|
|
|
|
config.define_string("gcpProject", False, "GCP project ID for BigTable persistence")
|
|
|
|
config.define_string("bigTableKeyPath", False, "Path to BigTable json key file")
|
|
|
|
|
2020-08-19 05:23:00 -07:00
|
|
|
cfg = config.parse()
|
|
|
|
num_guardians = int(cfg.get("num", "5"))
|
2020-12-05 07:32:37 -08:00
|
|
|
namespace = cfg.get("namespace", "wormhole")
|
2021-07-07 02:39:48 -07:00
|
|
|
bigTablePersistence = cfg.get("bigTablePersistence", False)
|
|
|
|
gcpProject = cfg.get("gcpProject", None)
|
|
|
|
bigTableKeyPath = cfg.get("bigTableKeyPath", "./bigtable-writer.json")
|
2020-12-05 07:32:37 -08:00
|
|
|
|
|
|
|
# namespace
|
|
|
|
|
|
|
|
namespace_create(namespace)
|
|
|
|
|
|
|
|
def k8s_yaml_with_ns(objects):
|
|
|
|
return k8s_yaml(namespace_inject(objects, namespace))
|
2020-08-19 05:23:00 -07:00
|
|
|
|
2020-08-15 13:14:24 -07:00
|
|
|
# protos
|
|
|
|
|
2021-07-30 15:12:28 -07:00
|
|
|
proto_deps = ["./proto", "./generate-protos.sh", "buf.yaml", "buf.gen.yaml"]
|
|
|
|
|
2020-08-15 13:14:24 -07:00
|
|
|
local_resource(
|
|
|
|
name = "proto-gen",
|
2021-07-30 15:12:28 -07:00
|
|
|
deps = proto_deps,
|
2020-08-17 14:01:59 -07:00
|
|
|
cmd = "./generate-protos.sh",
|
2020-08-15 13:14:24 -07:00
|
|
|
)
|
|
|
|
|
2021-07-21 10:04:04 -07:00
|
|
|
local_resource(
|
|
|
|
name = "proto-gen-web",
|
2021-07-30 15:12:28 -07:00
|
|
|
deps = proto_deps,
|
|
|
|
resource_deps = ["proto-gen"],
|
2021-07-21 10:04:04 -07:00
|
|
|
cmd = "./generate-protos-web.sh",
|
|
|
|
)
|
|
|
|
|
2020-08-15 13:14:24 -07:00
|
|
|
# bridge
|
|
|
|
|
2021-07-07 02:39:48 -07:00
|
|
|
if bigTablePersistence:
|
|
|
|
k8s_yaml_with_ns(
|
|
|
|
secret_yaml_generic(
|
|
|
|
"bridge-bigtable-key",
|
|
|
|
from_file = "bigtable-key.json=" + bigTableKeyPath
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
2020-08-15 13:14:24 -07:00
|
|
|
docker_build(
|
|
|
|
ref = "guardiand-image",
|
|
|
|
context = "bridge",
|
|
|
|
dockerfile = "bridge/Dockerfile",
|
|
|
|
)
|
|
|
|
|
2020-08-19 05:23:00 -07:00
|
|
|
def build_bridge_yaml():
|
|
|
|
bridge_yaml = read_yaml_stream("devnet/bridge.yaml")
|
|
|
|
|
|
|
|
for obj in bridge_yaml:
|
2020-08-20 09:56:35 -07:00
|
|
|
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":
|
2020-08-19 05:23:00 -07:00
|
|
|
fail("container 0 is not guardiand")
|
2020-10-28 14:41:38 -07:00
|
|
|
container["command"] += ["--devNumGuardians", str(num_guardians)]
|
2021-07-07 02:39:48 -07:00
|
|
|
if bigTablePersistence:
|
|
|
|
container["command"] += [
|
|
|
|
"--bigTablePersistenceEnabled",
|
|
|
|
"--bigTableGCPProject",
|
|
|
|
gcpProject
|
|
|
|
]
|
2020-08-19 05:23:00 -07:00
|
|
|
|
|
|
|
return encode_yaml_stream(bridge_yaml)
|
|
|
|
|
2020-12-05 07:32:37 -08:00
|
|
|
k8s_yaml_with_ns(build_bridge_yaml())
|
2020-08-15 13:14:24 -07:00
|
|
|
|
2021-07-20 13:33:47 -07:00
|
|
|
k8s_resource("guardian", resource_deps = ["proto-gen", "solana-devnet"], port_forwards = [
|
|
|
|
port_forward(6060, name = "Debug/Status Server [:6060]"),
|
2021-07-30 16:18:53 -07:00
|
|
|
port_forward(7070, name = "Public gRPC [:7070]"),
|
|
|
|
port_forward(7071, name = "Public REST [:7071]"),
|
2020-11-27 15:46:37 -08:00
|
|
|
])
|
2020-08-15 13:14:24 -07:00
|
|
|
|
2021-05-12 23:11:18 -07:00
|
|
|
# publicRPC proxy that allows grpc over http1, for local development
|
|
|
|
|
|
|
|
k8s_yaml_with_ns("./devnet/envoy-proxy.yaml")
|
|
|
|
|
2021-07-20 13:33:47 -07:00
|
|
|
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
|
|
|
|
],
|
|
|
|
)
|
2021-05-12 23:11:18 -07:00
|
|
|
|
2021-07-20 13:39:32 -07:00
|
|
|
# solana client cli (used for devnet setup)
|
2020-08-15 13:14:24 -07:00
|
|
|
|
|
|
|
docker_build(
|
2021-07-20 13:39:32 -07:00
|
|
|
ref = "solana-client",
|
2021-07-20 13:33:47 -07:00
|
|
|
context = ".",
|
|
|
|
only = ["./proto", "./solana"],
|
2021-07-20 13:39:32 -07:00
|
|
|
dockerfile = "Dockerfile.client",
|
2020-08-16 06:02:11 -07:00
|
|
|
|
|
|
|
# Ignore target folders from local (non-container) development.
|
|
|
|
ignore = ["./solana/target", "./solana/agent/target", "./solana/cli/target"],
|
2020-08-15 13:14:24 -07:00
|
|
|
)
|
2020-08-15 14:54:44 -07:00
|
|
|
|
2020-08-20 09:56:26 -07:00
|
|
|
# solana smart contract
|
|
|
|
|
|
|
|
docker_build(
|
|
|
|
ref = "solana-contract",
|
|
|
|
context = "solana",
|
|
|
|
dockerfile = "solana/Dockerfile",
|
|
|
|
)
|
|
|
|
|
2020-08-15 14:54:44 -07:00
|
|
|
# solana local devnet
|
|
|
|
|
2020-12-05 07:32:37 -08:00
|
|
|
k8s_yaml_with_ns("devnet/solana-devnet.yaml")
|
2020-08-15 14:54:44 -07:00
|
|
|
|
2021-07-20 13:33:47 -07:00
|
|
|
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]"),
|
2020-11-10 10:39:32 -08:00
|
|
|
])
|
2020-08-15 16:38:10 -07:00
|
|
|
|
|
|
|
# eth devnet
|
|
|
|
|
|
|
|
docker_build(
|
|
|
|
ref = "eth-node",
|
2020-08-16 03:10:03 -07:00
|
|
|
context = "./ethereum",
|
|
|
|
dockerfile = "./ethereum/Dockerfile",
|
2020-08-16 02:17:35 -07:00
|
|
|
|
2020-08-16 03:10:03 -07:00
|
|
|
# ignore local node_modules (in case they're present)
|
|
|
|
ignore = ["./ethereum/node_modules"],
|
2020-08-17 07:31:48 -07:00
|
|
|
|
|
|
|
# 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"),
|
|
|
|
],
|
2020-08-15 16:38:10 -07:00
|
|
|
)
|
|
|
|
|
2020-12-05 07:32:37 -08:00
|
|
|
k8s_yaml_with_ns("devnet/eth-devnet.yaml")
|
2020-08-15 16:38:10 -07:00
|
|
|
|
2021-07-20 13:33:47 -07:00
|
|
|
k8s_resource("eth-devnet", port_forwards = [
|
|
|
|
port_forward(8545, name = "Ganache RPC [:8545]"),
|
2020-11-10 10:39:32 -08:00
|
|
|
])
|
|
|
|
|
2021-05-25 00:51:49 -07:00
|
|
|
# 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")
|
|
|
|
|
2021-07-20 13:33:47 -07:00
|
|
|
k8s_resource(
|
|
|
|
"explorer",
|
2021-07-21 10:04:04 -07:00
|
|
|
resource_deps = ["envoy-proxy", "proto-gen-web"],
|
2021-07-20 13:33:47 -07:00
|
|
|
port_forwards = [
|
|
|
|
port_forward(8001, name = "Explorer Web UI [:8001]"),
|
|
|
|
],
|
2021-05-25 00:51:49 -07:00
|
|
|
)
|
|
|
|
|
2020-11-16 04:28:07 -08:00
|
|
|
# terra devnet
|
|
|
|
|
2020-11-30 03:34:31 -08:00
|
|
|
docker_build(
|
|
|
|
ref = "terra-image",
|
2020-12-03 05:37:23 -08:00
|
|
|
context = "./terra/devnet",
|
|
|
|
dockerfile = "terra/devnet/Dockerfile",
|
|
|
|
)
|
|
|
|
|
|
|
|
docker_build(
|
|
|
|
ref = "terra-contracts",
|
|
|
|
context = "./terra",
|
|
|
|
dockerfile = "./terra/Dockerfile",
|
2020-11-30 03:34:31 -08:00
|
|
|
)
|
|
|
|
|
2020-12-05 07:32:37 -08:00
|
|
|
k8s_yaml_with_ns("devnet/terra-devnet.yaml")
|
2020-11-16 04:28:07 -08:00
|
|
|
|
2020-11-16 08:45:17 -08:00
|
|
|
k8s_resource(
|
|
|
|
"terra-lcd",
|
2021-07-20 13:33:47 -07:00
|
|
|
port_forwards = [port_forward(1317, name = "Terra LCD interface [:1317]")],
|
2020-11-16 08:45:17 -08:00
|
|
|
)
|
|
|
|
|
2020-11-27 16:33:57 -08:00
|
|
|
k8s_resource(
|
|
|
|
"terra-terrad",
|
2021-07-20 13:33:47 -07:00
|
|
|
port_forwards = [port_forward(26657, name = "Terra RPC [:26657]")],
|
2020-11-27 16:33:57 -08:00
|
|
|
)
|
2021-07-27 04:46:36 -07:00
|
|
|
|
|
|
|
k8s_resource(
|
|
|
|
"terra-fcd",
|
|
|
|
port_forwards = [port_forward(3060, name = "Terra FCD [:3060]")],
|
2021-07-30 15:12:28 -07:00
|
|
|
)
|