# Vara deployment
## Pre requirements
### 1. Build deps
#### Ubuntu/Debian
```bash!
sudo apt update
# May prompt for location information
sudo apt install -y git clang curl libssl-dev llvm libudev-dev cmake protobuf-compiler
```
#### MacOS
```bash!
# Install Homebrew if necessary https://brew.sh/
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
# Make sure Homebrew is up-to-date, install openssl
brew update
brew install openssl
```
Additionally, if you use Apple Silicon (M1/M1 Pro/M1 Max), install Rosetta:
```bash!
/usr/sbin/softwareupdate --install-rosetta --agree-to-license
```
#### Windows
Windows 10 is supported with WSL!
- Install WSL and upgrade it to version 2 use instructions from https://docs.microsoft.com/en-us/windows/wsl/install-win10.
- Ensure VM feature is enabled in bios in processor advanced menu.
- Install Ubuntu 20.04 LTS https://www.microsoft.com/store/apps/9n6svws3rx71.
- Launch installed app and setup root user - exit ubuntu app (first time launch takes time).
- Install windows terminal from app store or use VSCode with remote plugin (auto suggested once wsl is detected by VSCode).
- Follow instructions for linux.
### 2. Rust and all toolchains
Rustup if not installed:
```bash!
# Install
curl https://sh.rustup.rs -sSf | sh
# Configure
source ~/.cargo/env
```
Toolchains:
```bash\
rustup default stable
rustup update
rustup update nightly
rustup target add wasm32-unknown-unknown --toolchain nightly
```
### 3. Build node or download node
```bash!
git pull https://github.com/gear-tech/gear
cd gear
cargo build --profile production --locked
```
binary file will be located at `target/production/gear`
or you can find pre-built binaries at <https://get.gear.rs>
```bash!
wget https://get.gear.rs/vara-nightly-linux-x86_64.tar.xz
sudo tar -xvf gear-nightly-linux-x86_64.tar.xz -C /root
rm gear-nightly-linux-x86_64.tar.xz
```
## Get json spec
### 1. Build spec
```bash!
cargo build --locked --no-default-features --features vara-native,lazy-pages --profile production
gear build-spec --raw --disable-default-bootnode --chain vara > node/res/vara.json
```
### 2. Add default bootnodes section
```json!
"bootNodes": [
"/dns4/ec2-50-18-67-143.us-west-1.compute.amazonaws.com/tcp/30333/p2p/12D3KooWLyfgFSnm9CVaQTrZDqhBkLrRriPi9tPZSsps46FW2gZs",
"/dns4/ec2-54-183-230-232.us-west-1.compute.amazonaws.com/tcp/30333/p2p/12D3KooWLrzg5UMN9sGyACv5tq5QWjh5gyArga9aL8R3ns7DucBH",
"/dns4/ec2-54-215-37-66.us-west-1.compute.amazonaws.com/tcp/30333/p2p/12D3KooWAJDc4mPixLfTZFfaa4upCRbjw9uawr82Qd9FuEPGUHag",
"/dns4/ec2-3-101-21-213.us-west-1.compute.amazonaws.com/tcp/30333/p2p/12D3KooWJHbU1FKuzpciDhqHqZ922fyXxy7imDSvy46WYgynVVZv",
"/dns4/ec2-54-153-114-109.us-west-1.compute.amazonaws.com/tcp/30333/p2p/12D3KooWKrqWcnC9TSAXxGbo9ekdwPspDhqzWSDr4ciMH7xtZp1H",
"/dns4/ec2-52-53-151-206.us-west-1.compute.amazonaws.com/tcp/30333/p2p/12D3KooWKHPuceJGuKGHS1nhuEyuJ8Gmh479GCRHdZFoWDAC9WYG",
"/dns4/ec2-13-56-230-247.us-west-1.compute.amazonaws.com/tcp/30333/p2p/12D3KooWAajkTBWFnpRbYJNnvjvKMZYCMCGBnh95Qdj4o7FQ8hNE",
"/dns4/ec2-54-177-38-215.us-west-1.compute.amazonaws.com/tcp/30333/p2p/12D3KooWJsGsFdGerMu4LaYy5bv4csGVY6P85zLPZgkWCKEVwzjv"
],
```
### Download latest json spec from vara-stage-1
```bash!
wget https://github.com/gear-tech/gear/raw/vara-stage-1/node/res/vara.json
```
## Start node and conect to Vara network
```bash!
gear --telemetry-url "wss://telemetry.rs/submit 0" --name "YourNodeName" --chain path/to/vara.json
```
## Revert panic runtime
### 1. Stop validator nodes
### 2. Add the id of the block that causes the panic to `badBlocks` in the chain spec.
```json!
"forkBlocks": null,
"badBlocks": [
"0x3f7bbfa116e1b8e912dc26bd69575d34002ef69ff81649b898d210d434fe76ab"
],
"lightSyncState": null,
```
### 3. Revert non-finalized blocks
```bash!
gear revert --chain gear/vara.json
```
### 4. Start validator nodes
## Upgrade runtime
### 1. Preimage
#### 1. Save preimage hash with runtime upgrade
`utility.with_weight(system.setCode(runtime))`

#### 2. Submit preimage which whitelists the upgrade call
`preimage.notePreimage(call: whitelist.whitelistCall(utility.with_weight(upgrade call hash))`

### 2. Fellowship
Hold a fellowship referenda (account must have a rank > 0).
With preimage from #1.
Origin = `1 / Fellows : Origins : Fellows`

### 3. Referenda
Once the upgrade call is whitelisted hold a referendum to execute it.
Submit preimage:

Submit referenda:
Origin = `1 / Whitelisted Caller : Origins : WhitelistedCaller`
