According to the Doc / Development / Getting Started / compile-and-deploy page
Copy the “makefile” from the “Secret Template Repository” at GitHub - SecretFoundation/secret-template: Quickstart template to get started writing your own cosmwasm contracts
run this command: make build-mainnet-reproducible
which is
docker run --rm -v "$$(pwd)":/contract \
--mount type=volume,source="$$(basename "$$(pwd)")_cache",target=/code/target \
--mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \
mr7uca/wasm-contract-optimizer:0.0.10
mv ./optimized-wasm/*.wasm.gz ./contract.wasm.gz
Then I got error: failed to parse manifest at /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/base64ct-1.8.0/Cargo.toml
Caused by: feature edition2024 is required
The package requires the Cargo feature called edition2024, but that feature is not stabilized in this version of Cargo (1.80.0 (376290515 2024-07-16)).
Consider trying a newer version of Cargo (this may require the nightly release).
Replacing mr7uca/wasm-contract-optimizer:0.0.10 with ghcr.io/scrtlabs/secretnetwork-dev:latest makes the building process work.
Then mv ./optimized-wasm/*.wasm.gz ./contract.wasm.gz complains about missing file.
Where is the compiled and optimized wasm?
is that located at ./target/wasm32-unknown-unknown/release/xyz.wasm ?
That is not optimized and compressed with gz ??
Then I tried another command from “GitHub - CosmWasm/optimizer: Dockerfile and script to produce the smallest possible Wasm for Rust contract”
docker run --rm -v "$(pwd)":/code \
--mount type=volume,source="$(basename "$(pwd)")_cache",target=/target \
--mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \
cosmwasm/optimizer:0.17.0
That gives me: Compiling digest v0.10.7
warning: secp256k1-sys@0.8.1: Compiler family detection failed due to error: ToolNotFound: Failed to find tool. Is clang installed?
warning: secp256k1-sys@0.8.1: Compiler family detection failed due to error: ToolNotFound: Failed to find tool. Is clang installed?
warning: secp256k1-sys@0.8.1: Compiler family detection failed due to error: ToolNotFound: Failed to find tool. Is clang installed?
warning: secp256k1-sys@0.8.1: Compiler family detection failed due to error: ToolNotFound: Failed to find tool. Is clang installed?
error: failed to run custom build command for secp256k1-sys v0.8.1
Caused by:
process didn’t exit successfully: /target/release/build/secp256k1-sys-8373fe03b509ef4e/build-script-build (exit status: 1)
— stdout
OUT_DIR = Some(/target/wasm32-unknown-unknown/release/build/secp256k1-sys-bbde91b3055b3c54/out)
TARGET = Some(wasm32-unknown-unknown)
OPT_LEVEL = Some(3)
HOST = Some(x86_64-unknown-linux-musl)
cargo:rerun-if-env-changed=CC_wasm32-unknown-unknown
CC_wasm32-unknown-unknown = None
cargo:rerun-if-env-changed=CC_wasm32_unknown_unknown
CC_wasm32_unknown_unknown = None
cargo:rerun-if-env-changed=TARGET_CC
TARGET_CC = None
cargo:rerun-if-env-changed=CC
CC = None
cargo:rerun-if-env-changed=CC_ENABLE_DEBUG_OUTPUT
cargo:warning=Compiler family detection failed due to error: ToolNotFound: Failed to find tool. Is clang installed?
RUSTC_WRAPPER = None
cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
CRATE_CC_NO_DEFAULTS = None
cargo:rerun-if-env-changed=WASI_SYSROOT
WASI_SYSROOT = None
DEBUG = Some(false)
cargo:rerun-if-env-changed=CFLAGS_wasm32-unknown-unknown
CFLAGS_wasm32-unknown-unknown = None
cargo:rerun-if-env-changed=CFLAGS_wasm32_unknown_unknown
CFLAGS_wasm32_unknown_unknown = None
cargo:rerun-if-env-changed=TARGET_CFLAGS
TARGET_CFLAGS = None
cargo:rerun-if-env-changed=CFLAGS
CFLAGS = None
OUT_DIR = Some(/target/wasm32-unknown-unknown/release/build/secp256k1-sys-bbde91b3055b3c54/out)
cargo:rerun-if-env-changed=CC_ENABLE_DEBUG_OUTPUT
cargo:warning=Compiler family detection failed due to error: ToolNotFound: Failed to find tool. Is clang installed?
cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
CRATE_CC_NO_DEFAULTS = None
cargo:rerun-if-env-changed=WASI_SYSROOT
WASI_SYSROOT = None
cargo:rerun-if-env-changed=CFLAGS_wasm32-unknown-unknown
CFLAGS_wasm32-unknown-unknown = None
cargo:rerun-if-env-changed=CFLAGS_wasm32_unknown_unknown
CFLAGS_wasm32_unknown_unknown = None
cargo:rerun-if-env-changed=TARGET_CFLAGS
TARGET_CFLAGS = None
cargo:rerun-if-env-changed=CFLAGS
CFLAGS = None
cargo:warning=Compiler family detection failed due to error: ToolNotFound: Failed to find tool. Is clang installed?
OUT_DIR = Some(/target/wasm32-unknown-unknown/release/build/secp256k1-sys-bbde91b3055b3c54/out)
cargo:rerun-if-env-changed=CC_ENABLE_DEBUG_OUTPUT
cargo:warning=Compiler family detection failed due to error: ToolNotFound: Failed to find tool. Is clang installed?
cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
CRATE_CC_NO_DEFAULTS = None
cargo:rerun-if-env-changed=WASI_SYSROOT
WASI_SYSROOT = None
cargo:rerun-if-env-changed=CFLAGS_wasm32-unknown-unknown
CFLAGS_wasm32-unknown-unknown = None
cargo:rerun-if-env-changed=CFLAGS_wasm32_unknown_unknown
CFLAGS_wasm32_unknown_unknown = None
cargo:rerun-if-env-changed=TARGET_CFLAGS
TARGET_CFLAGS = None
cargo:rerun-if-env-changed=CFLAGS
CFLAGS = None
— stderr
error occurred: Failed to find tool. Is clang installed?
warning: build failed, waiting for other jobs to finish…
thread ‘main’ panicked at src/pkg_build.rs:79:9:
My machine has clang installed, but is the docker image up to date???
Or should I just use make build, which is:
RUSTFLAGS='-C link-arg=-s' cargo build --release --target wasm32-unknown-unknown
cp ./target/wasm32-unknown-unknown/release/*.wasm ./contract.wasm
cat ./contract.wasm | gzip -9 > ./contract.wasm.gz