From 08a5f78f25a35ad9608f7bec8a0296996eaf559c Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Tue, 14 Nov 2023 10:55:08 +0100 Subject: [PATCH 1/4] Use cosmwasm/optimizer:0.15.0 --- .circleci/config.yml | 18 ++++++++++++++++-- README.md | 8 ++++---- contracts/README.md | 22 +++++++++++----------- packages/vm/README.md | 8 ++++---- 4 files changed, 35 insertions(+), 21 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 6412da3308..2ff3fd5c24 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1020,15 +1020,29 @@ jobs: name: Build development contracts command: | echo "Building all contracts under ./contracts" - export GLOBIGNORE="./contracts/floaty/" - docker run --volumes-from with_code cosmwasm/rust-optimizer:0.12.13 ./contracts/*/ + export GLOBIGNORE="contracts/floaty" + for contract_dir in contracts/*; do + if [ -d "$contract_dir" ]; then + echo "Building '$contract_dir' ..." + docker run --volumes-from with_code cosmwasm/optimizer:0.15.0 "$contract_dir" + fi + done - run: name: Check development contracts command: | echo "Checking all contracts under ./artifacts" docker run --volumes-from with_code rust:1.70.0 \ /bin/bash -e -c 'cd ./code; cargo run --bin cosmwasm-check artifacts/*.wasm' + - run: + name: Export development contracts + command: | + # copy into host docker cp with_code:/code/artifacts . + cd ./artifacts + ls -lA . + # Check checksums + cat checksums.txt + sha256sum -c checksums.txt - run: name: Publish artifacts on GitHub command: | diff --git a/README.md b/README.md index 3964683bb2..d79dabc345 100644 --- a/README.md +++ b/README.md @@ -397,16 +397,16 @@ from the published rust code. For that, we have a separate repo, [rust-optimizer](https://github.com/CosmWasm/rust-optimizer) that provides a -[docker image](https://hub.docker.com/r/CosmWasm/rust-optimizer/tags) for -building. For more info, look at +[docker image](https://hub.docker.com/r/CosmWasm/optimizer/tags) for building. +For more info, look at [rust-optimizer README](https://github.com/CosmWasm/rust-optimizer/blob/master/README.md#usage), but the quickstart guide is: ```sh docker run --rm -v "$(pwd)":/code \ - --mount type=volume,source="$(basename "$(pwd)")_cache",target=/code/target \ + --mount type=volume,source="$(basename "$(pwd)")_cache",target=/target \ --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \ - cosmwasm/rust-optimizer:0.12.13 + cosmwasm/optimizer:0.15.0 ``` It will output a highly size-optimized build as `contract.wasm` in `$CODE`. With diff --git a/contracts/README.md b/contracts/README.md index 35a60dd720..f4444cc913 100644 --- a/contracts/README.md +++ b/contracts/README.md @@ -55,57 +55,57 @@ reason, use the following commands: docker run --rm -v "$(pwd)":/code \ --mount type=volume,source="devcontract_cache_burner",target=/code/contracts/burner/target \ --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \ - cosmwasm/rust-optimizer:0.12.13 ./contracts/burner + cosmwasm/optimizer:0.15.0 ./contracts/burner docker run --rm -v "$(pwd)":/code \ --mount type=volume,source="devcontract_cache_crypto_verify",target=/code/contracts/crypto-verify/target \ --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \ - cosmwasm/rust-optimizer:0.12.13 ./contracts/crypto-verify + cosmwasm/optimizer:0.15.0 ./contracts/crypto-verify docker run --rm -v "$(pwd)":/code \ --mount type=volume,source="devcontract_cache_floaty",target=/code/contracts/floaty/target \ --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \ - cosmwasm/rust-optimizer:0.12.13 ./contracts/floaty + cosmwasm/optimizer:0.15.0 ./contracts/floaty docker run --rm -v "$(pwd)":/code \ --mount type=volume,source="devcontract_cache_hackatom",target=/code/contracts/hackatom/target \ --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \ - cosmwasm/rust-optimizer:0.12.13 ./contracts/hackatom + cosmwasm/optimizer:0.15.0 ./contracts/hackatom docker run --rm -v "$(pwd)":/code \ --mount type=volume,source="devcontract_cache_ibc_reflect",target=/code/contracts/ibc-reflect/target \ --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \ - cosmwasm/rust-optimizer:0.12.13 ./contracts/ibc-reflect + cosmwasm/optimizer:0.15.0 ./contracts/ibc-reflect docker run --rm -v "$(pwd)":/code \ --mount type=volume,source="devcontract_cache_ibc_reflect_send",target=/code/contracts/ibc-reflect-send/target \ --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \ - cosmwasm/rust-optimizer:0.12.13 ./contracts/ibc-reflect-send + cosmwasm/optimizer:0.15.0 ./contracts/ibc-reflect-send docker run --rm -v "$(pwd)":/code \ --mount type=volume,source="devcontract_cache_queue",target=/code/contracts/queue/target \ --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \ - cosmwasm/rust-optimizer:0.12.13 ./contracts/queue + cosmwasm/optimizer:0.15.0 ./contracts/queue docker run --rm -v "$(pwd)":/code \ --mount type=volume,source="devcontract_cache_reflect",target=/code/contracts/reflect/target \ --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \ - cosmwasm/rust-optimizer:0.12.13 ./contracts/reflect + cosmwasm/optimizer:0.15.0 ./contracts/reflect docker run --rm -v "$(pwd)":/code \ --mount type=volume,source="devcontract_cache_staking",target=/code/contracts/staking/target \ --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \ - cosmwasm/rust-optimizer:0.12.13 ./contracts/staking + cosmwasm/optimizer:0.15.0 ./contracts/staking docker run --rm -v "$(pwd)":/code \ --mount type=volume,source="devcontract_cache_virus",target=/code/contracts/virus/target \ --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \ - cosmwasm/rust-optimizer:0.12.13 ./contracts/virus + cosmwasm/optimizer:0.15.0 ./contracts/virus docker run --rm -v "$(pwd)":/code \ --mount type=volume,source="devcontract_cache_empty",target=/code/contracts/empty/target \ --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \ - cosmwasm/rust-optimizer:0.12.13 ./contracts/empty + cosmwasm/optimizer:0.15.0 ./contracts/empty ``` ## Entry points diff --git a/packages/vm/README.md b/packages/vm/README.md index 8ed9ad94df..b4166c5652 100644 --- a/packages/vm/README.md +++ b/packages/vm/README.md @@ -53,25 +53,25 @@ To rebuild the test contracts, go to the repo root and do docker run --rm -v "$(pwd)":/code \ --mount type=volume,source="devcontract_cache_cyberpunk",target=/code/contracts/cyberpunk/target \ --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \ - cosmwasm/rust-optimizer:0.12.13 ./contracts/cyberpunk \ + cosmwasm/optimizer:0.15.0 ./contracts/cyberpunk \ && cp artifacts/cyberpunk.wasm packages/vm/testdata/cyberpunk.wasm docker run --rm -v "$(pwd)":/code \ --mount type=volume,source="devcontract_cache_hackatom",target=/code/contracts/hackatom/target \ --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \ - cosmwasm/rust-optimizer:0.12.13 ./contracts/hackatom \ + cosmwasm/optimizer:0.15.0 ./contracts/hackatom \ && cp artifacts/hackatom.wasm packages/vm/testdata/hackatom_1.2.wasm docker run --rm -v "$(pwd)":/code \ --mount type=volume,source="devcontract_cache_ibc_reflect",target=/code/contracts/ibc-reflect/target \ --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \ - cosmwasm/rust-optimizer:0.12.13 ./contracts/ibc-reflect \ + cosmwasm/optimizer:0.15.0 ./contracts/ibc-reflect \ && cp artifacts/ibc_reflect.wasm packages/vm/testdata/ibc_reflect_1.2.wasm docker run --rm -v "$(pwd)":/code \ --mount type=volume,source="devcontract_cache_empty",target=/code/contracts/empty/target \ --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \ - cosmwasm/rust-optimizer:0.12.13 ./contracts/empty \ + cosmwasm/optimizer:0.15.0 ./contracts/empty \ && cp artifacts/empty.wasm packages/vm/testdata/empty.wasm ``` From b1656ed0be3f1455cb3e40a12223e45f9b431491 Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Tue, 14 Nov 2023 17:11:02 +0100 Subject: [PATCH 2/4] Add comment on correct directory in README --- contracts/README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/contracts/README.md b/contracts/README.md index f4444cc913..12758384f3 100644 --- a/contracts/README.md +++ b/contracts/README.md @@ -52,6 +52,8 @@ the CI for every release tag. In case you need to build them manually for some reason, use the following commands: ```sh +# cd to the repo root first + docker run --rm -v "$(pwd)":/code \ --mount type=volume,source="devcontract_cache_burner",target=/code/contracts/burner/target \ --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \ From 9b8382324e2c3e61f66129a0d668f13e875f142e Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Tue, 14 Nov 2023 17:15:44 +0100 Subject: [PATCH 3/4] Add $CIRCLE_TAG check to deployment This allows us to test the CI job without creating a release. --- .circleci/config.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 2ff3fd5c24..5d6d832922 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1046,6 +1046,12 @@ jobs: - run: name: Publish artifacts on GitHub command: | + # This safety measure allows us to run the job until here for testing. + if [ -z "$CIRCLE_TAG" ]; then + echo "Not a tag build" + exit 1 + fi + TAG="$CIRCLE_TAG" TITLE="$TAG" BODY="The release notes are available in [CHANGELOG.md](https://github.com/CosmWasm/cosmwasm/blob/$TAG/CHANGELOG.md). For upgrading contracts also consult [MIGRATING.md](https://github.com/CosmWasm/cosmwasm/blob/$TAG/MIGRATING.md).\n\nAttached there are some build artifacts generated at this tag. Those are for development purposes only! Please use crates.io to find the packages of this release." From 45c14b5ab94ff37723672ebd9babbe478595087a Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Sat, 18 Nov 2023 10:51:33 +0100 Subject: [PATCH 4/4] Mount /target for cosmwasm/optimizer --- contracts/README.md | 22 +++++++++++----------- packages/vm/README.md | 8 ++++---- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/contracts/README.md b/contracts/README.md index 12758384f3..84795914e2 100644 --- a/contracts/README.md +++ b/contracts/README.md @@ -55,57 +55,57 @@ reason, use the following commands: # cd to the repo root first docker run --rm -v "$(pwd)":/code \ - --mount type=volume,source="devcontract_cache_burner",target=/code/contracts/burner/target \ + --mount type=volume,source="devcontract_cache_burner",target=/target \ --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \ cosmwasm/optimizer:0.15.0 ./contracts/burner docker run --rm -v "$(pwd)":/code \ - --mount type=volume,source="devcontract_cache_crypto_verify",target=/code/contracts/crypto-verify/target \ + --mount type=volume,source="devcontract_cache_crypto_verify",target=/target \ --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \ cosmwasm/optimizer:0.15.0 ./contracts/crypto-verify docker run --rm -v "$(pwd)":/code \ - --mount type=volume,source="devcontract_cache_floaty",target=/code/contracts/floaty/target \ + --mount type=volume,source="devcontract_cache_floaty",target=/target \ --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \ cosmwasm/optimizer:0.15.0 ./contracts/floaty docker run --rm -v "$(pwd)":/code \ - --mount type=volume,source="devcontract_cache_hackatom",target=/code/contracts/hackatom/target \ + --mount type=volume,source="devcontract_cache_hackatom",target=/target \ --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \ cosmwasm/optimizer:0.15.0 ./contracts/hackatom docker run --rm -v "$(pwd)":/code \ - --mount type=volume,source="devcontract_cache_ibc_reflect",target=/code/contracts/ibc-reflect/target \ + --mount type=volume,source="devcontract_cache_ibc_reflect",target=/target \ --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \ cosmwasm/optimizer:0.15.0 ./contracts/ibc-reflect docker run --rm -v "$(pwd)":/code \ - --mount type=volume,source="devcontract_cache_ibc_reflect_send",target=/code/contracts/ibc-reflect-send/target \ + --mount type=volume,source="devcontract_cache_ibc_reflect_send",target=/target \ --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \ cosmwasm/optimizer:0.15.0 ./contracts/ibc-reflect-send docker run --rm -v "$(pwd)":/code \ - --mount type=volume,source="devcontract_cache_queue",target=/code/contracts/queue/target \ + --mount type=volume,source="devcontract_cache_queue",target=/target \ --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \ cosmwasm/optimizer:0.15.0 ./contracts/queue docker run --rm -v "$(pwd)":/code \ - --mount type=volume,source="devcontract_cache_reflect",target=/code/contracts/reflect/target \ + --mount type=volume,source="devcontract_cache_reflect",target=/target \ --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \ cosmwasm/optimizer:0.15.0 ./contracts/reflect docker run --rm -v "$(pwd)":/code \ - --mount type=volume,source="devcontract_cache_staking",target=/code/contracts/staking/target \ + --mount type=volume,source="devcontract_cache_staking",target=/target \ --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \ cosmwasm/optimizer:0.15.0 ./contracts/staking docker run --rm -v "$(pwd)":/code \ - --mount type=volume,source="devcontract_cache_virus",target=/code/contracts/virus/target \ + --mount type=volume,source="devcontract_cache_virus",target=/target \ --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \ cosmwasm/optimizer:0.15.0 ./contracts/virus docker run --rm -v "$(pwd)":/code \ - --mount type=volume,source="devcontract_cache_empty",target=/code/contracts/empty/target \ + --mount type=volume,source="devcontract_cache_empty",target=/target \ --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \ cosmwasm/optimizer:0.15.0 ./contracts/empty ``` diff --git a/packages/vm/README.md b/packages/vm/README.md index b4166c5652..aa440a7960 100644 --- a/packages/vm/README.md +++ b/packages/vm/README.md @@ -51,25 +51,25 @@ To rebuild the test contracts, go to the repo root and do ```sh docker run --rm -v "$(pwd)":/code \ - --mount type=volume,source="devcontract_cache_cyberpunk",target=/code/contracts/cyberpunk/target \ + --mount type=volume,source="devcontract_cache_cyberpunk",target=/target \ --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \ cosmwasm/optimizer:0.15.0 ./contracts/cyberpunk \ && cp artifacts/cyberpunk.wasm packages/vm/testdata/cyberpunk.wasm docker run --rm -v "$(pwd)":/code \ - --mount type=volume,source="devcontract_cache_hackatom",target=/code/contracts/hackatom/target \ + --mount type=volume,source="devcontract_cache_hackatom",target=/target \ --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \ cosmwasm/optimizer:0.15.0 ./contracts/hackatom \ && cp artifacts/hackatom.wasm packages/vm/testdata/hackatom_1.2.wasm docker run --rm -v "$(pwd)":/code \ - --mount type=volume,source="devcontract_cache_ibc_reflect",target=/code/contracts/ibc-reflect/target \ + --mount type=volume,source="devcontract_cache_ibc_reflect",target=/target \ --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \ cosmwasm/optimizer:0.15.0 ./contracts/ibc-reflect \ && cp artifacts/ibc_reflect.wasm packages/vm/testdata/ibc_reflect_1.2.wasm docker run --rm -v "$(pwd)":/code \ - --mount type=volume,source="devcontract_cache_empty",target=/code/contracts/empty/target \ + --mount type=volume,source="devcontract_cache_empty",target=/target \ --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \ cosmwasm/optimizer:0.15.0 ./contracts/empty \ && cp artifacts/empty.wasm packages/vm/testdata/empty.wasm