From f72f9313b09d14caf73fd259c4f2d8daec14bd0a Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Fri, 28 Jul 2023 08:10:16 +0200 Subject: [PATCH 1/6] Bump binaryen version to 114 (latest) --- CHANGELOG.md | 2 ++ Dockerfile | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a6cd34f..7762443 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## [Unreleased] +- Update to binaryen v114. + ## [0.13.0] - 2023-06-20 ### Changed diff --git a/Dockerfile b/Dockerfile index 5a621ab..117bef8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,7 +4,7 @@ ARG BUILDPLATFORM ARG TARGETPLATFORM ARG TARGETARCH -ARG BINARYEN_VERSION="version_110" +ARG BINARYEN_VERSION="version_114" RUN echo "Running on $BUILDPLATFORM, building for $TARGETPLATFORM" From 63cee6d0dbf4d46df1d3a8c1b4795e77eb80e298 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Fri, 28 Jul 2023 08:13:36 +0200 Subject: [PATCH 2/6] Bump Rust to v1.71.0 --- CHANGELOG.md | 1 + Dockerfile | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7762443..d263622 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## [Unreleased] - Update to binaryen v114. +- Bump Rust to current stable v1.71.0 ## [0.13.0] - 2023-06-20 diff --git a/Dockerfile b/Dockerfile index 117bef8..00e75f4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM rust:1.69.0-alpine as targetarch +FROM rust:1.71.0-alpine as targetarch ARG BUILDPLATFORM ARG TARGETPLATFORM @@ -88,7 +88,7 @@ RUN cd build_workspace && \ # # base-optimizer # -FROM rust:1.69.0-alpine as base-optimizer +FROM rust:1.71.0-alpine as base-optimizer # Download the crates.io index using the new sparse protocol to improve performance ENV CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse From 6588b8c94368e35080dc568048d87217150b8c48 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Fri, 28 Jul 2023 08:17:29 +0200 Subject: [PATCH 3/6] Update comment --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 0530728..f95347d 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,7 @@ DOCKER_TAG := 0.13.0 # Native arch BUILDARCH := $(shell uname -m) -# Build multi-CPU architecture images and publish them. rust alpine images support the linux/amd64 and linux/arm64/v8 architectures. +# Build the native CPU arch images and publish them. Rust alpine images support the linux/amd64 and linux/arm64/v8 architectures. build: build-rust-optimizer build-workspace-optimizer build-rust-optimizer-x86_64: From 79663f2ef4fc69c60e4ce553b6d308ed059c40da Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Fri, 28 Jul 2023 08:34:28 +0200 Subject: [PATCH 4/6] Add --signext-lowering to wasm-opt --- CHANGELOG.md | 3 ++- optimize.sh | 4 ++-- optimize_workspace.sh | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d263622..6f81dae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,8 @@ ## [Unreleased] - Update to binaryen v114. -- Bump Rust to current stable v1.71.0 +- Bump Rust to current stable v1.71.0. +- Add the `--signext-lowering`` flag to `wasm-opt`. ([#127]) ## [0.13.0] - 2023-06-20 diff --git a/optimize.sh b/optimize.sh index f79d0ee..3a086ea 100755 --- a/optimize.sh +++ b/optimize.sh @@ -20,7 +20,7 @@ mkdir -p artifacts rm -f artifacts/checksums_intermediate.txt # There are two cases here -# 1. All contracts (or one) are included in the root workspace (eg. `cosmwasm-template`, `cosmwasm-examples`, `cosmwasm-plus`) +# 1. All contracts (or one) are included in the root workspace (eg. `cosmwasm-template`, `cosmwasm-examples`, `cosmwasm-plus`) # In this case, we pass no argument, just mount the proper directory. # 2. Contracts are excluded from the root workspace, but import relative paths from other packages (only `cosmwasm`). # In this case, we mount root workspace and pass in a path `docker run ./contracts/hackatom` @@ -44,7 +44,7 @@ for CONTRACTDIR in "$@"; do echo "Creating intermediate hash for $NAME ..." sha256sum -- "$WASM" | tee -a artifacts/checksums_intermediate.txt echo "Optimizing $NAME ..." - wasm-opt -Os "$WASM" -o "artifacts/$NAME" + wasm-opt -Os --signext-lowering "$WASM" -o "artifacts/$NAME" done done diff --git a/optimize_workspace.sh b/optimize_workspace.sh index 0b84b12..0d6ef29 100644 --- a/optimize_workspace.sh +++ b/optimize_workspace.sh @@ -65,7 +65,7 @@ TMPARTIFACTS=$(mktemp -p "$(pwd)" -d artifacts.XXXXXX) echo "$INTERMEDIATE_SHA" >>"$INTERMEDIATE_SHAS" echo "Optimizing ${BASENAME}..." - wasm-opt -Os "$WASM" -o "$OPTIMIZED_WASM" + wasm-opt -Os --signext-lowering "$WASM" -o "$OPTIMIZED_WASM" echo "Moving ${OPTIMIZED_WASM}..." mv "$OPTIMIZED_WASM" ../artifacts fi From ed0ef8afbef4846a683026d4c1dce12347f64772 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Fri, 28 Jul 2023 11:53:43 +0200 Subject: [PATCH 5/6] Fix typo Co-authored-by: Simon Warta <2603011+webmaster128@users.noreply.github.com> --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6f81dae..37d2bd7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ - Update to binaryen v114. - Bump Rust to current stable v1.71.0. -- Add the `--signext-lowering`` flag to `wasm-opt`. ([#127]) +- Add the `--signext-lowering` flag to `wasm-opt`. ([#127]) ## [0.13.0] - 2023-06-20 From bc393bacfecf24190c79772349f5193f8b70d0cc Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Fri, 28 Jul 2023 11:52:55 +0200 Subject: [PATCH 6/6] Add signext-lowering comment --- optimize.sh | 1 + optimize_workspace.sh | 1 + 2 files changed, 2 insertions(+) diff --git a/optimize.sh b/optimize.sh index 3a086ea..71f84be 100755 --- a/optimize.sh +++ b/optimize.sh @@ -44,6 +44,7 @@ for CONTRACTDIR in "$@"; do echo "Creating intermediate hash for $NAME ..." sha256sum -- "$WASM" | tee -a artifacts/checksums_intermediate.txt echo "Optimizing $NAME ..." + # --signext-lowering is needed to support blockchains runnning CosmWasm < 1.3. It can be removed eventually wasm-opt -Os --signext-lowering "$WASM" -o "artifacts/$NAME" done done diff --git a/optimize_workspace.sh b/optimize_workspace.sh index 0d6ef29..cc18426 100644 --- a/optimize_workspace.sh +++ b/optimize_workspace.sh @@ -65,6 +65,7 @@ TMPARTIFACTS=$(mktemp -p "$(pwd)" -d artifacts.XXXXXX) echo "$INTERMEDIATE_SHA" >>"$INTERMEDIATE_SHAS" echo "Optimizing ${BASENAME}..." + # --signext-lowering is needed to support blockchains runnning CosmWasm < 1.3. It can be removed eventually wasm-opt -Os --signext-lowering "$WASM" -o "$OPTIMIZED_WASM" echo "Moving ${OPTIMIZED_WASM}..." mv "$OPTIMIZED_WASM" ../artifacts