Skip to content

Commit 564722d

Browse files
committed
Add docs for 1.15->1.16 upgrade
1 parent 22d88a8 commit 564722d

File tree

7 files changed

+315
-0
lines changed

7 files changed

+315
-0
lines changed

docs/upgrades/1.16/cleanup.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
set -o xtrace
3+
4+
sudo rm -fr /tmp/secretd
5+
sudo rm -fr /tmp/secretcli
6+
mkdir /tmp/secretd
7+
mkdir /tmp/secretcli

docs/upgrades/1.16/contract.wasm

722 KB
Binary file not shown.
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# docker compose file that sets up a network for beta testing
2+
3+
version: "3"
4+
5+
services:
6+
bootstrap:
7+
image: ghcr.io/scrtlabs/localsecret:v1.15.1
8+
container_name: bootstrap
9+
volumes:
10+
- /tmp/secretd:/root/.secretd
11+
- /tmp/secretcli:/root/.secretcli
12+
stdin_open: true
13+
tty: true
14+
environment:
15+
- http_proxy
16+
- https_proxy
17+
- SECRET_NODE_TYPE=BOOTSTRAP
18+
- LOG_LEVEL=trace
19+
- CHAINID=secretdev-1
20+
- SGX_MODE=SW
21+
expose:
22+
- 26656
23+
- 26657
24+
ports:
25+
- "5000:5000"
26+
entrypoint: /bin/bash
27+
28+
node:
29+
image: ghcr.io/scrtlabs/localsecret:v1.15.1
30+
container_name: node
31+
depends_on:
32+
- bootstrap
33+
volumes:
34+
- /tmp/secretd:/tmp/.secretd
35+
- /tmp/secretcli:/root/.secretcli
36+
stdin_open: true
37+
tty: true
38+
ports:
39+
- "1317:1317"
40+
- "9091:9091"
41+
environment:
42+
- http_proxy
43+
- https_proxy
44+
- SECRET_NODE_TYPE=node
45+
- LOG_LEVEL=trace
46+
- CHAINID=secretdev-1
47+
- RPC_URL=bootstrap:26657
48+
- PERSISTENT_PEERS=115aa0a629f5d70dd1d464bc7e42799e00f4edae@bootstrap:26656
49+
- FAUCET_URL=bootstrap:5000
50+
- SCRT_SGX_STORAGE=/root
51+
- SGX_MODE=SW
52+
entrypoint: /bin/bash
53+
deploy:
54+
restart_policy:
55+
condition: on-failure
56+
delay: 10s
57+
max_attempts: 10
58+
window: 123s
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
set -ox xtrace
3+
4+
UPGRADE_BLOCK="$(docker exec node bash -c 'secretd status | jq "(.sync_info.latest_block_height | tonumber) + 30"')"
5+
# Propose upgrade
6+
TX_HASH="$(docker exec node bash -c "secretd tx upgrade software-upgrade v1.16 --upgrade-height $UPGRADE_BLOCK --title blabla --summary yolo --deposit 1000000000uscrt --no-verify --from a -y | jq '.txhash'")"
7+
sleep 10
8+
PROPOSAL_ID="$(docker exec node bash -c "secretd q tx $TX_HASH | jq '.events[] | select(.type == \"submit_proposal\") | .attributes[] | select(.key == \"proposal_id\") | .value | tonumber'")"
9+
# Vote yes (voting period is 90 seconds)
10+
docker exec node bash -c "secretd tx gov vote ${PROPOSAL_ID} yes --from validator -y"
11+
12+
echo "PROPOSAL_ID = ${PROPOSAL_ID}"
13+
echo "UPGRADE_BLOCK = ${UPGRADE_BLOCK}"

docs/upgrades/1.16/node_init.sh

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
#!/usr/bin/env bash
2+
3+
set -euvox pipefail
4+
5+
# init the node
6+
# rm -rf ~/.secret*
7+
#secretd config chain-id enigma-testnet
8+
#secretd config indent true
9+
#secretd config trust-node true
10+
#secretd config keyring-backend test
11+
# rm -rf ~/.secretd
12+
13+
mkdir -p /root/.secretd/.node
14+
secretd config set client chain-id secretdev-1
15+
secretd config set client keyring-backend test
16+
secretd config set client node http://bootstrap:26657
17+
secretd config set client output json
18+
19+
mkdir -p /root/.secretd/.node
20+
21+
secretd init "$(hostname)" --chain-id secretdev-1 || true
22+
23+
PERSISTENT_PEERS=115aa0a629f5d70dd1d464bc7e42799e00f4edae@bootstrap:26656
24+
25+
sed -i 's/persistent_peers = ""/persistent_peers = "'$PERSISTENT_PEERS'"/g' ~/.secretd/config/config.toml
26+
sed -i 's/trust_period = "168h0m0s"/trust_period = "168h"/g' ~/.secretd/config/config.toml
27+
echo "Set persistent_peers: $PERSISTENT_PEERS"
28+
29+
echo "Waiting for bootstrap to start..."
30+
sleep 10
31+
32+
secretd q block --type=height 1
33+
34+
cp /tmp/.secretd/keyring-test /root/.secretd/ -r
35+
36+
# MASTER_KEY="$(secretd q register secret-network-params 2> /dev/null | cut -c 3- )"
37+
38+
#echo "Master key: $MASTER_KEY"
39+
40+
SGX_MODE=SW secretd init-enclave --reset
41+
42+
PUBLIC_KEY=$(SGX_MODE=SW secretd parse /root/attestation_cert.der | cut -c 3- )
43+
44+
echo "Public key: $PUBLIC_KEY"
45+
46+
SGX_MODE=SW secretd parse /root/attestation_cert.der
47+
cat /root/attestation_cert.der
48+
#tx_hash="$(SGX_MODE=SW secretd tx register auth /root/attestation_cert.der -y --from a --gas-prices 0.25uscrt | jq -r '.txhash')"
49+
SGX_MODE=SW secretd tx register auth /root/attestation_combined.bin -y --from a --gas-prices 0.25uscrt --gas 5000000
50+
51+
#secretd q tx "$tx_hash"
52+
sleep 10
53+
# SGX_MODE=SW secretd q tx "$tx_hash"
54+
55+
SEED="$(SGX_MODE=SW secretd q register seed "$PUBLIC_KEY" | cut -c 3-)"
56+
echo "SEED: $SEED"
57+
#exit
58+
59+
SGX_MODE=SW secretd q register secret-network-params
60+
61+
SGX_MODE=SW secretd configure-secret node-master-key.txt "$SEED"
62+
63+
cp /tmp/.secretd/config/genesis.json /root/.secretd/config/genesis.json
64+
65+
SGX_MODE=SW secretd genesis validate
66+
67+
RUST_BACKTRACE=1 SGX_MODE=SW secretd start --rpc.laddr tcp://0.0.0.0:26657
68+
69+
# ./wasmi-sgx-test.sh
Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
# How to test the v1.16 upgrade with LocalSecret
2+
3+
__NOTE__: Always work in docs/upgrades/1.16 directory
4+
5+
## Step 1
6+
7+
Start a v1.15 chain.
8+
9+
```bash
10+
docker compose -f docker-compose-115.yml up -d
11+
```
12+
We use modified node_init.sh script to start a regular node.
13+
Let's copy this script over into the node container
14+
```bash
15+
docker cp node_init.sh node:/root/
16+
```
17+
18+
(For convenience) Open a new terminal window:
19+
20+
```bash
21+
docker exec -it bootstrap bash
22+
```
23+
24+
, and start a bootstrap instance:
25+
```bash
26+
./bootstrap_init.sh
27+
```
28+
29+
__Note__: If for whatever reason, bootstrap_init.sh fails to start reporting an illigal instraction,
30+
most likely cause is /tmp/secretd left from the previous run. Try to remove and recreate this directory
31+
if the script fails to run, restart the compose.
32+
33+
Open yet another terminal window where you will start a regular node:
34+
35+
```bash
36+
docker exec -it node bash
37+
```
38+
39+
To start a node instance
40+
```bash
41+
chmod 0777 node_init.sh
42+
./node_init.sh
43+
```
44+
45+
## Step 2 (Test basic contract)
46+
47+
Copy a contract to node container:
48+
```bash
49+
docker cp ./contract.wasm node:/root/
50+
```
51+
52+
Shell into the node container:
53+
```bash
54+
docker exec -it node bash
55+
```
56+
57+
Store, instantiate, and execute the contract:
58+
```bash
59+
secretd config node http://0.0.0.0:26657
60+
secretd tx compute store contract.wasm --from a --gas 5000000 -y
61+
sleep 5
62+
INIT='{"counter":{"counter":10, "expires":100000}}'
63+
secretd tx compute instantiate 1 "$INIT" --from a --label "c" -y
64+
sleep 5
65+
ADDR=`secretd q compute list-contract-by-code 1 | jq -r '.[0].contract_address'`
66+
67+
secretd tx compute execute $ADDR '{"increment":{"addition": 13}}' --from a -y
68+
sleep 5
69+
secretd query compute query $ADDR '{"get": {}}'
70+
```
71+
72+
Expected result should be:
73+
```json
74+
{"get":{"count":23}}
75+
```
76+
77+
## Step 3
78+
79+
Propose a software upgrade on the v1.15 chain:
80+
We request an upgrade to take place at +30blocks (@10block/min)
81+
```bash
82+
./init_proposal.sh
83+
```
84+
85+
## Step 4
86+
87+
Perform the upgrade:
88+
At the upgrade block height you will see `ERR CONSENSUS FAILURE!!! err="UPGRADE \"v1.15\" NEEDED at height` for both containers: bootstrap and node.
89+
90+
At this point, the chain is waiting for the upgrade to be performed
91+
92+
__Special note__: If you run Ubuntu 22.04 or higher, you should consider building a localsecret target, which will produce a docker image for your active branch. We assume that you are on branch with tag v1.15.0 or cosmos-sdk-0.50.x-merged as of this writing.
93+
94+
Option A: Either build locally, if you are on Ubuntu 20.04
95+
```bash
96+
FEATURES="light-client-validation,random" SGX_MODE=SW make build-linux
97+
```
98+
Option B: build a docker image if you are on Ubuntu 22.04 or higher
99+
```bash
100+
make localsecret
101+
```
102+
103+
After the build is done, assemble the binary artefacts.
104+
You will need the following binaries:
105+
* secretd
106+
* librust_cosmwasm_enclave.signed.so
107+
* libgo_cosmwasm.so
108+
* librandom_api.so
109+
* tendermint_enclave.signed.so
110+
111+
If you chose option B, you can access the binaries in the container and copy them to a host dir,
112+
e.g. SecretNetwork/docs/upgrades/1.15/bin by running update_binaries.sh:
113+
```bash
114+
./update_binaries.sh
115+
```
116+
117+
Restart node:
118+
```bash
119+
source /opt/sgxsdk/environment && RUST_BACKTRACE=1 LOG_LEVEL="trace" secretd start --rpc.laddr tcp://0.0.0.0:26657
120+
```
121+
122+
The log file will print out `INF applying upgrade "v1.15" at height`
123+
124+
If the upgrade process was successful, the blockchain will resume generating new blocks after the height at which the upgrade was requested.
125+
126+
Chck that the previously deployed contract is still present
127+
Query the value of the counter:
128+
```bash
129+
secretd query compute query $ADDR '{"get": {}}'
130+
```
131+
Expected result should be:
132+
```json
133+
{"get":{"count":23}}
134+
```
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/bin/bash
2+
set -o xtrace
3+
4+
docker exec bootstrap bash -c 'rm -rf /tmp/upgrade-bin && mkdir -p /tmp/upgrade-bin'
5+
docker exec node bash -c 'rm -rf /tmp/upgrade-bin && mkdir -p /tmp/upgrade-bin'
6+
mkdir -p ./bin/
7+
docker cp localsecret:/usr/bin/secretd ./bin/
8+
docker cp localsecret:/usr/lib/librust_cosmwasm_enclave.signed.so ./bin/
9+
docker cp localsecret:/usr/lib/libgo_cosmwasm.so ./bin/
10+
docker cp localsecret:/usr/lib/librandom_api.so ./bin/
11+
docker cp localsecret:/usr/lib/tendermint_enclave.signed.so ./bin/
12+
# update bootstrap
13+
docker cp ./bin/secretd bootstrap:/tmp/upgrade-bin
14+
docker cp ./bin/librust_cosmwasm_enclave.signed.so bootstrap:/tmp/upgrade-bin
15+
docker cp ./bin/libgo_cosmwasm.so bootstrap:/tmp/upgrade-bin
16+
# update node
17+
docker cp ./bin/secretd node:/tmp/upgrade-bin
18+
docker cp ./bin/librust_cosmwasm_enclave.signed.so node:/tmp/upgrade-bin
19+
docker cp ./bin/libgo_cosmwasm.so node:/tmp/upgrade-bin
20+
docker cp ./bin/librandom_api.so node:/tmp/upgrade-bin
21+
docker cp ./bin/tendermint_enclave.signed.so node:/tmp/upgrade-bin
22+
# stop node's secretd
23+
docker exec node bash -c 'pkill -9 secretd'
24+
# copy over updated binaries
25+
docker exec bootstrap bash -c 'cp /tmp/upgrade-bin/librust_cosmwasm_enclave.signed.so /usr/lib/'
26+
docker exec bootstrap bash -c 'cp /tmp/upgrade-bin/libgo_cosmwasm.so /usr/lib/'
27+
docker exec node bash -c 'cp /tmp/upgrade-bin/secretd /usr/bin/'
28+
docker exec node bash -c 'cp /tmp/upgrade-bin/librust_cosmwasm_enclave.signed.so /usr/lib/'
29+
docker exec node bash -c 'cp /tmp/upgrade-bin/libgo_cosmwasm.so /usr/lib/'
30+
31+
# prepare a tmp dir to store validator's private key
32+
rm -rf /tmp/upgrade-bin && mkdir -p /tmp/upgrade-bin
33+
docker cp bootstrap:/root/.secretd/config/priv_validator_key.json /tmp/upgrade-bin/.
34+
docker cp /tmp/upgrade-bin/priv_validator_key.json node:/root/.secretd/config/priv_validator_key.json

0 commit comments

Comments
 (0)