Skip to content

Commit

Permalink
Fix cli
Browse files Browse the repository at this point in the history
  • Loading branch information
liorbond committed Sep 3, 2023
1 parent f674bb2 commit 673a99e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 64 deletions.
2 changes: 1 addition & 1 deletion deployment/dockerfiles/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ ENV FEATURES=${FEATURES}
ENV FEATURES_U=${FEATURES_U}
ENV MITIGATION_CVE_2020_0551=${MITIGATION_CVE_2020_0551}

RUN git clone --branch v1.11.3 --depth 1 https://github.com/scrtlabs/tm-secret-enclave.git
RUN git clone --branch v1.11.5 --depth 1 https://github.com/scrtlabs/tm-secret-enclave.git

WORKDIR tm-secret-enclave

Expand Down
69 changes: 8 additions & 61 deletions docs/upgrades/1.11/test-v1.11-upgrade-handler.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,59 +59,6 @@ secretd query compute query $ADDR '{"get": {}}'
Expected result should be:
{"get":{"count":23}}

## Step 3

Run the secret.js tests from the `master` branch on the `secret.js` repo.
This will create state on the chain before the upgrade.

First delete `globalSetup` & `globalTeardown` (because we already launched the chain manually):

```bash
echo 'import { SecretNetworkClient } from "../src";
import { sleep } from "./utils";
require("ts-node").register({ transpileOnly: true });
module.exports = async () => {
await waitForBlocks();
console.log(`LocalSecret is running`);
};
async function waitForBlocks() {
while (true) {
const secretjs = new SecretNetworkClient({
url: "http://localhost:1317",
chainId: "secretdev-1",
});
try {
const { block } = await secretjs.query.tendermint.getLatestBlock({});
if (Number(block?.header?.height) >= 1) {
break;
}
} catch (e) {
// console.eerror(e);
}
await sleep(250);
}
}
' > test/globalSetup.ts
```

```bash
echo '//@ts-ignore
require("ts-node").register({ transpileOnly: true });
module.exports = async () => {};' > test/globalTeardown.js
```

Then run the tests:

```bash
yarn test
```

## Step 4

Propose a software upgrade on the v1.10 chain.
Expand Down Expand Up @@ -145,15 +92,15 @@ FEATURES="light-client-validation,random" SGX_MODE=SW make build-linux
docker exec bootstrap bash -c 'rm -rf /tmp/upgrade-bin && mkdir -p /tmp/upgrade-bin'
docker exec node bash -c 'rm -rf /tmp/upgrade-bin && mkdir -p /tmp/upgrade-bin'

docker cp secretd bootstrap:/tmp/upgrade-bin
docker cp go-cosmwasm/librust_cosmwasm_enclave.signed.so bootstrap:/tmp/upgrade-bin
docker cp go-cosmwasm/api/libgo_cosmwasm.so bootstrap:/tmp/upgrade-bin
docker cp secretd node:/tmp/upgrade-bin
docker cp go-cosmwasm/librust_cosmwasm_enclave.signed.so node:/tmp/upgrade-bin
docker cp go-cosmwasm/api/libgo_cosmwasm.so node:/tmp/upgrade-bin
docker cp usr/local/bin/secretd bootstrap:/tmp/upgrade-bin
docker cp usr/lib/librust_cosmwasm_enclave.signed.so bootstrap:/tmp/upgrade-bin
docker cp usr/lib/libgo_cosmwasm.so bootstrap:/tmp/upgrade-bin
docker cp usr/local/bin/secretd node:/tmp/upgrade-bin
docker cp usr/lib/librust_cosmwasm_enclave.signed.so node:/tmp/upgrade-bin
docker cp usr/lib/libgo_cosmwasm.so node:/tmp/upgrade-bin
# These two should be brought from the external repo or from a previous localsecret
docker cp docs/librandom_api.so node:/usr/lib
docker cp docs/tendermint_enclave.signed.so node:/usr/lib
docker cp usr/lib/librandom_api.so node:/usr/lib
docker cp usr/lib/tendermint_enclave.signed.so node:/usr/lib

docker exec node bash -c 'pkill -9 secretd'

Expand Down
14 changes: 12 additions & 2 deletions x/compute/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -462,14 +462,24 @@ func parseMigrateContractArgs(args []string, cliCtx client.Context) (types.MsgMi
if err != nil {
return types.MsgMigrateContract{}, sdkerrors.Wrap(err, "code id")
}
migrateMsg := types.SecretMsg{}

migrateMsg := args[2]
migrateMsg.CodeHash, err = GetCodeHashByCodeId(cliCtx, args[1])
if err != nil {
return types.MsgMigrateContract{}, sdkerrors.Wrap(err, "code hash")
}

migrateMsg.Msg = []byte(args[2])
wasmCtx := wasmUtils.WASMContext{CLIContext: cliCtx}
encryptedMsg, err := wasmCtx.Encrypt(migrateMsg.Serialize())
if err != nil {
return types.MsgMigrateContract{}, sdkerrors.Wrap(err, "encrypt")
}
msg := types.MsgMigrateContract{
Sender: cliCtx.GetFromAddress().String(),
Contract: args[0],
CodeID: codeID,
Msg: []byte(migrateMsg),
Msg: encryptedMsg,
}
return msg, nil
}
Expand Down

0 comments on commit 673a99e

Please sign in to comment.