owned this note
owned this note
Published
Linked with GitHub
# Running the demo
## Repositories:
- Visualisation: https://github.com/elevate-web3/tezos-rollup-celebration
- Demo orchestrator: https://gitlab.com/tezos/tezos
- branch: `emturner@demo-orchestrator`
- Wasm demo: https://gitlab.com/trili/wasm-demo
- branch: `emturner@ssh-orchestrator`
## Initial Setup
At the start, we'll stick to ensuring everything is working locally.
### Visualisation
Visualisation is split into two parts, the `collector` and the `aggregator`.
The `collector` runs on the same machine as the rollup node, and scrapes the kernel's debug-log.
The `aggregator` connects to every running collector, and retrieves the logs, which is then displayed as pixel-updates in the aggregator UI.
#### Building
To build the aggregator run the following:
On Linux:
```
make build-collector-docker
make build-aggregator-docker
```
On Mac:
```
brew install clojure
cd clojure-front-and-aggregator
make download-deps
make build-prod-cljs
cd ..
cd collector && cargo build --release
cd .. && cp collector/target/release/collector ./collector-bin
```
#### Running
Add a `config.json` file in the root of the visualisation repo:
```
[
{
"host": "0.0.0.0",
"port": 20000,
"row": 0,
"column": 0
}
]
```
This tells the aggregator how to connect to any running collectors.
Then create a logfile: `touch kernel-0.log`.
We can then start running the collector.
On linux:
```
docker run \
--name collector \
-net=host \
-v $PWD:/logs \
collector:demo \
0 0 20000 /logs/kernel-0.log
```
On Mac:
```
./collector-bin --log-path kernel-0.log \
--port 20000 \
--row 0 \
--col 0
```
From a new terminal, then run the aggregator.
On Linux:
```
make run-aggregator-docker
```
On Mac:
```
cd clojure-front-and-aggregator
make run-aggregator
```
You should now be able to navigate to `localhost:9000` in your browser, to see the visualisation.
#### Testing the visualisation
There is a program to randomly generate kernel logs in the `wasm-demo` directory (under `debug_log`, or under `mockup_log` in the visualisation repo).
Ensure that the aggregator & collector are running, and then run:
```
cd mockup_log
cargo build --release
cargo run --release -- ../kernel-0.log
```
You should now see random pixel updates in the visualisation. This may be blocky in updates, due to internal batching in the collector & aggregator.
### Kernel Messages
Message generation takes place in the Wasm Demo repository.
The messages are ultimately changes of pixel colours. Each block, a transition from one image to the next takes place.
The images supported, should be in the `.ppm` format, and must be _2500x2000_ pixels in size (corresponding to a 15 mega-pixel image) with RGB channels only. These should be placed in the `imgs` subdirectory, and named:
`0.ppm`, `1.ppm`, etc. The first `0.ppm` image should be completely black (every pixels R,G & B values set to `0`).
#### Calculate image diffs
Create the image diffs for each rollup by running the following:
```
cd image-diff
./generate.sh
```
This will build the `image-diff` program, and produce output in `image-diff/level*.diff` folders.
#### Generating kernel messages
The kernel messages are generated from the image diffs above. From the top-level of the wasm-demo repo:
```
cd account_diff_to_tx
./generate.sh
```
This will take a while... it's producing many messages.
> **NB** on Mac you may have to edit the `generate.sh` file, to change
> `wait -n` to `wait`
## Deploying GCP machines
Navigate to `wasm-demo` repository, to the `terraform/` directory.
Open the `README.md` file there, and ensure your have the requirements setup.
On Mac:
* Install gcloud
```bash
brew install --cask google-cloud-sdk
```
* Install packer
```
brew install packer
```
* Install terraform
```
brew install terraform
```
### Create the packer image
In the wasm-demo repository. Edit the `terraform/scripts/install_script.sh` to set the [latest Mondaynet docker image](https://teztnets.xyz/mondaynet-about), and remove the custom docker image (tezos:demo) - this may be included later if a custom mondaynet image is required. This script is used by the packer build to generate the custom image.
Then follow the [README instructions](https://gitlab.com/trili/wasm-demo/-/blob/main/terraform/README.md) to build the packer image.
This will ouput a disk image name `custom-cos-*`, make a note of this.
### Authenticate with terraform
You can login with
```
gcloud auth application-default login
```
after which you can run `terraform init` and `terraform plan`. If you run into an authentication problems because credentials cannot be parsed,
you might need to modify the file `terraform/providers.tf` and remove the line `credentials=vars.gcp_credentials`. Then run `terraform init` and `terraform plan` again.
Removing the `credentials` line in the `providers.tf` file will cause terraform to default to the credentials listed in `$HOME/.config/gcloud/application_default.json`, which have been initialised with the `gclooud auth application-default login` command.
See more info here: https://stackoverflow.com/questions/57453468/google-cloud-credentials-with-terraform
### Create machines with terraform
Before running the terraform, there are a couple of things to edit.
`locals.tf`: set `source_image` to the disk image name from the [previous step](https://hackmd.io/W-_MZ45MRZ6KJW78FR5V6g?both#Create-the-packer-image).
`variables.tf`: set `target_size` to the number of machines you want to deploy. Elswhere in the file, are the number of rollups/dacs per machine - you'll want the total number to match of each.
There are other variables that are explained in the [README](https://gitlab.com/trili/wasm-demo/-/blob/main/terraform/README.md#variables).
You then need to edit `scripts/startup_script.sh`, `scripts/startup_dac.sh`:
- set the docker image to the mondaynet image.
- set the mounted directory from `/home/emma` to `/home/<username>` (your current username on your localmachine).
- set the ssh public key to your ssh public key
Run `terraform apply` to deploy the machines.
> NB please always run `terraform destroy` when you're finished with your machines!!
#### Debugging
You can `ssh` into machines using the gcloud command (from the google compute console, you can retrieve the ssh command).
Check the correct images are running with `docker ps`, and you can see the startup script logs by running:
```
sudo journalctl -u google-startup-scripts.service
```
When you run terraform apply, you'll see an output of IP addresses.
#### Setting up the aggregator
In the wasm-demo repo, terraform directory
Run the following to setup the aggregator:
```
./scripts/collector-config.sh
```
> Ensure that the 'rollups_per_machine' variable in
> `scripts/collector-config.sh` matches the `rollup_per_machine` in
> `variables.tf`.
Then copy the resulting `config.json` to the top-level of the visualisation repo.
Then [run the aggregator](https://hackmd.io/W-_MZ45MRZ6KJW78FR5V6g?both#Running). It should connect to the collectors running on GCP.
#### Setting up the orchestrator
In the tezos repository, on the demo branch. Copy the `address` fields of the terraform output, and then go to the orchestrator `main.ml` file (src/bin_1mtps_demo_orchestrator/main.ml).
Then replace the adddress variables at the top level.
Replace the `ssh_id` variable with the path to your ssh key.
There are some paths you will need to fix in the `Local` module to point them
to the required repositories on your machine.
Download the latest mondaynet snapshot - you dont need to run this everytime, as it gets updated twice a day, and the tezt orchestrator snapshots a later version everytime you run.
```
curl http://mondaynet.snapshots.s3-website.eu-central-1.amazonaws.com/mondaynet-rolling-snapshot \
--output src/bin_1mtps_demo_orchestrator/artifacts/snapshot.rolling
```
Run the demo nodes first:
```
echo nodes | dune exec src/bin_1mtps_demo_orchestrator/main.exe -- --verbose
```
Then in a different terminal you can run the dac nodes and messages!
```
echo rest | dune exec src/bin_1mtps_demo_orchestrator/main.exe -- --verbose
```
## Running the demo
Get the name of the latest *Mondaynet* docker container from [teztnets](https://teztnets.xyz/mondaynet-about).
Then navigate to `src/bin_1mtps_demo_orchestrator/main.ml` in `tezos/tezos`.
There are a few variables that you'll need to adjust:
```
let ssh_id = "<path to ssh key file>"
let network = "<latest mondaynet network>"
```