|
| 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 | +``` |
0 commit comments