2020-08-15 13:14:24 -07:00
|
|
|
# Developing the bridge
|
|
|
|
|
|
|
|
## Local Devnet
|
|
|
|
|
|
|
|
The following dependencies are required for local development:
|
|
|
|
|
2021-08-30 07:42:32 -07:00
|
|
|
- [Go](https://golang.org/dl/) >= 1.17.0
|
2021-06-22 11:21:13 -07:00
|
|
|
- [Tilt](http://tilt.dev/) >= 0.20.8
|
2021-05-25 00:51:49 -07:00
|
|
|
- Any of the local Kubernetes clusters supported by Tilt.
|
2021-08-26 03:09:03 -07:00
|
|
|
We strongly recommend [minikube](https://kubernetes.io/docs/setup/learning-environment/minikube/) >=
|
|
|
|
v1.21.0 with the kvm2 driver.
|
|
|
|
- Tilt will use Minikube's embedded Docker server. If Minikube is not used, a local instance of
|
|
|
|
[Docker](https://docs.docker.com/engine/install/) / moby-engine >= 19.03 is required.
|
2020-08-15 13:14:24 -07:00
|
|
|
|
|
|
|
See the [Tilt docs](https://docs.tilt.dev/install.html) docs on how to set up your local cluster -
|
2020-11-10 07:31:05 -08:00
|
|
|
it won't take more than a few minutes to set up! Example minikube invocation, adjust limits as needed:
|
|
|
|
|
|
|
|
minikube start --cpus=8 --memory=8G --disk-size=50G --driver=kvm2
|
2020-08-15 13:14:24 -07:00
|
|
|
|
2020-11-10 10:39:32 -08:00
|
|
|
npm wants to set up an insane number of inotify watches in the web container which may exceed kernel limits.
|
|
|
|
The minikube default is too low, adjust it like this:
|
|
|
|
|
|
|
|
minikube ssh 'echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p'
|
|
|
|
|
2021-08-30 07:42:32 -07:00
|
|
|
This should work on Linux, MacOS and Windows.
|
2020-08-15 13:14:24 -07:00
|
|
|
|
2020-12-05 07:32:37 -08:00
|
|
|
By default, the devnet is deployed to the `wormhole` namespace rather than `default`. This makes it easy to clean up the
|
|
|
|
entire deployment by simply removing the namespace, which isn't possible with `default`. Change your default namespace
|
|
|
|
to avoid having to specify `-n wormhole` for all commands:
|
|
|
|
|
|
|
|
kubectl config set-context --current --namespace=wormhole
|
|
|
|
|
2021-06-22 11:21:13 -07:00
|
|
|
After installing all dependencies, just run `tilt up`.
|
2020-08-15 13:14:24 -07:00
|
|
|
Whenever you modify a file, the devnet is automatically rebuilt and a rolling update is done.
|
|
|
|
|
2020-12-05 07:32:37 -08:00
|
|
|
Launch the devnet while specifying the number of guardians nodes to run (default is five):
|
2020-08-19 05:23:00 -07:00
|
|
|
|
2021-06-22 11:21:13 -07:00
|
|
|
tilt up -- --num=1
|
2020-08-19 05:23:00 -07:00
|
|
|
|
2020-11-10 13:53:54 -08:00
|
|
|
If you want to work on non-consensus parts of the code, running with a single guardian is easiest since
|
|
|
|
you won't have to wait for k8s to restart all pods.
|
|
|
|
|
2020-11-10 10:39:32 -08:00
|
|
|
## Usage
|
|
|
|
|
2020-08-19 05:23:00 -07:00
|
|
|
Watch pod status in your cluster:
|
|
|
|
|
|
|
|
kubectl get pod -A -w
|
2021-05-25 00:51:49 -07:00
|
|
|
|
2020-08-19 05:23:00 -07:00
|
|
|
Get logs for single guardian node:
|
|
|
|
|
|
|
|
kubectl logs guardian-0
|
|
|
|
|
2020-08-19 09:01:21 -07:00
|
|
|
Restart a specific pod:
|
|
|
|
|
|
|
|
kubectl delete pod guardian-0
|
|
|
|
|
2021-01-23 09:25:00 -08:00
|
|
|
Adjust number of nodes in running cluster: (this is only useful if you want to test scenarios where the number
|
|
|
|
of nodes diverges from the guardian set - otherwise, `tilt down --delete-namespaces` and restart the cluster)
|
2020-08-19 08:38:55 -07:00
|
|
|
|
|
|
|
tilt args -- --num=2
|
2020-12-05 07:32:37 -08:00
|
|
|
|
|
|
|
Tear down cluster:
|
|
|
|
|
|
|
|
tilt down --delete-namespaces
|
2020-08-19 08:38:55 -07:00
|
|
|
|
2020-08-15 13:14:24 -07:00
|
|
|
Once you're done, press Ctrl-C. Run `tilt down` to tear down the devnet.
|
2021-07-28 09:33:12 -07:00
|
|
|
|
|
|
|
|
|
|
|
### Post messages
|
|
|
|
|
|
|
|
To Solana:
|
|
|
|
|
|
|
|
kubectl exec solana-devnet-0 -c setup -- client post-message Bridge1p5gheXUvJ6jGWGeCsgPKgnE3YgdGKRVCMY9o 1 confirmed ffff
|
2021-07-29 09:31:12 -07:00
|
|
|
|
|
|
|
To Solana as CPI instruction:
|
|
|
|
|
|
|
|
kubectl exec solana-devnet-0 -c setup -- client post-message --proxy CP1co2QMMoDPbsmV7PGcUTLFwyhgCgTXt25gLQ5LewE1 Bridge1p5gheXUvJ6jGWGeCsgPKgnE3YgdGKRVCMY9o 1 confirmed ffff
|
2021-07-30 15:12:28 -07:00
|
|
|
|
|
|
|
|
|
|
|
## IntelliJ Protobuf Autocompletion
|
|
|
|
|
|
|
|
Set the include path:
|
|
|
|
|
|
|
|
![](https://i.imgur.com/bDij6Cu.png)
|
2021-07-07 02:39:48 -07:00
|
|
|
|
|
|
|
|
|
|
|
## BigTable event persistence
|
|
|
|
|
2021-08-23 23:01:00 -07:00
|
|
|
Guardian events can be persisted to a cloud BigTable instance by passing a GCP project and service account key to Tilt.
|
|
|
|
Launch the devnet with flags supplying your database info to forward events to your cloud BigTable, rather than the local devnet BigTable emulator:
|
2021-07-07 02:39:48 -07:00
|
|
|
|
2021-08-23 23:01:00 -07:00
|
|
|
tilt up -- --num=1 --gcpProject=your-project-id --bigTableKeyPath=./your-service-account-key.json
|