# Swisstronik v7 Testnet

## Upgrade plan for v1.0.7

Upcoming v1.0.7 upgrade contains the following:

* Update x/compliance module for ZK-SDI
* Add MsgConvertCredential to convert V1 (non-ZK) credentials to ZK-SDI format
* Add MsgAttachHolderPublicKey to set holder public key during conversion to ZK format
* Add migration for seamless deploy of Arachnid Deterministic Proxy
* Update compliance precompile at address(1028) to support V2 credentials
* Minor bug fixes

### Important notes

{% hint style="warning" %}
NOTE: Please ensure that downloaded `swisstronikd` have commit `9c6c939f249df6268becb3cfe54fa4f4b5da57c7`. You can do it by running `swisstronikd version --long`. Updated binary contains hotfix for `exceeds max voting power` issue.
{% endhint %}

If you're already downloaded binaries, you can just replace `swisstronikd`binary with new one. `libsgx_wrapper_v1.0.7.x86_64.so`and `v1.0.7_enclave.signed.so`can be the same.

### Backup

Prior to the upgrade, validators are encouraged to take a full data snapshot. Snapshotting depends heavily on infrastructure, but generally this can be done by backing up the `.swisstronik` directory. If you use Cosmovisor to upgrade, by default, Cosmovisor will backup your data upon upgrade. See below upgrade by cosmovisor section.

It is critically important for validator operators to back-up the `.swisstronik/data/priv_validator_state.json` file after stopping the swisstronikd process. This file is updated every block as your validator participates in consensus rounds. It is a critical file needed to prevent double-signing, in case the upgrade fails and the previous chain needs to be restarted.

#### Manually

If you're not using cosmovisor, you can perform the upgrade manually.

**Prepare new binary**

Download new binary:

```
wget https://github.com/SigmaGmbH/swisstronik-chain/releases/download/testnet-v1.0.7/swisstronikd.zip
```

{% hint style="warning" %}
NOTE: Please ensure that downloaded `swisstronikd` have commit `9c6c939f249df6268becb3cfe54fa4f4b5da57c7`. You can do it by running `swisstronikd version --long`. Updated binary contains hotfix for `exceeds max voting power` issue.
{% endhint %}

Extract downloaded archive:

```
unzip swisstronikd.zip
```

In `bin` folder you will be able to find required files.

Copy `libsgx_wrapper_v1.0.7.x86_64.so` lib:

```
sudo cp bin/libsgx_wrapper_v1.0.7.x86_64.so /usr/lib
```

Copy `v1.0.7_enclave.signed.so` to `ENCLAVE_HOME` directory (by default it is `$HOME/.swisstronik-enclave`):

```
cp bin/v1.0.7_enclave.signed.so $ENCLAVE_HOME
```

**DURING UPGRADE: Modify your .service file**

{% hint style="warning" %}
NOTE: Please ensure that downloaded `swisstronikd` have commit `9c6c939f249df6268becb3cfe54fa4f4b5da57c7`. You can do it by running `swisstronikd version --long`. Updated binary contains hotfix for `exceeds max voting power` issue.
{% endhint %}

Once your validator reach upgrade height, it will stop produce new blocks automatically. After your node stopped, switch the binary you're using to `swisstronikd` v1.0.7 at `ExecStart` in your `.service` file.

NOTE: `swisstronikd` v1.0.7 is located in `bin` folder from previous step with unpacking `.zip` archive.

Then run:

```
sudo systemctl daemon-reload
```

Then you should restart your validator

#### Using cosmovisor

If you're running your node using cosmovisor, please follow next steps.

**Download binaries**

Download new binary:

```
wget https://github.com/SigmaGmbH/swisstronik-chain/releases/download/testnet-v1.0.7/swisstronikd.zip
```

Extract downloaded archive:

```
unzip swisstronikd.zip
```

In `bin` folder you will be able to find required files.

Copy `libsgx_wrapper_v1.0.7.x86_64.so` lib:

```
sudo cp bin/libsgx_wrapper_v1.0.7.x86_64.so /usr/lib
```

Copy `v1.0.7_enclave.signed.so` to `ENCLAVE_HOME` directory (by default it is `$HOME/.swisstronik-enclave`):

```
cp bin/v1.0.7_enclave.signed.so $ENCLAVE_HOME
```

**Setup cosmovisor**

If you haven't configured cosmovisor before, do the following steps.

Install the latest version of Cosmovisor (1.5.0):

```
go install cosmossdk.io/tools/cosmovisor/cmd/cosmovisor@latest
cosmovisor version
# cosmovisor version: v1.5.0
```

Copy old `swisstronikd` binary:

```
cp $(whereis swisstronikd) .
```

Initialize cosmovisor:

```
export DAEMON_HOME=/path/to/.swisstronik
export DAEMON_NAME=swisstronikd

cosmovisor init swisstronikd
```

**Put v1.0.7 binaries**

{% hint style="warning" %}
NOTE: Please ensure that downloaded `swisstronikd` have commit `9c6c939f249df6268becb3cfe54fa4f4b5da57c7`. You can do it by running `swisstronikd version --long`. Updated binary contains hotfix for `exceeds max voting power` issue.
{% endhint %}

Copy `swisstronikd` v1.0.7 to $HOME/.swisstronik/cosmovisor/upgrades/v1.0.7/bin

```
mkdir -p  $HOME/.swisstronik/cosmovisor/upgrades/v1.0.7/bin
cp swisstronikd $HOME/.swisstronik/cosmovisor/upgrades/v1.0.7/bin
```

NOTE: `swisstronikd` v1.0.7 is located in `bin` folder from previous step with unpacking `.zip` archive.

**Check folder structure**

At this moment, you should have the following structure:

```
.
├── current -> genesis or upgrades/<name>
├── genesis
│   └── bin
│       └── swisstronikd  # old: v1.0.6
└── upgrades
    └── v1.0.7
        └── bin
            └── swisstronikd  # new: v1.0.7
```

Export the environmental variables:

```
export DAEMON_NAME=swisstronikd
# please change to your own swisstronik home dir
# please note `DAEMON_HOME` has to be absolute path
export DAEMON_HOME=$HOME/.swisstronik
export DAEMON_RESTART_AFTER_UPGRADE=true
```

**Disable auto downloading of binaries**

Set `DAEMON_ALLOW_DOWNLOAD_BINARIES` to `false` to avoid cosmovisor trying to download binaries.

**Start the node**

Start the node:

```
cosmovisor run start --x-crisis-skip-assert-invariants --home $DAEMON_HOME
```

Skipping the invariant checks is strongly encouraged since it decreases the upgrade time significantly and since there are some other improvements coming to the crisis module in the next release of the Cosmos SDK.
