fix: injective-cosmwasm-stargate-example test fixes for chain 1.18#264
Conversation
- Pin Rust toolchain to 1.86.0 to avoid bulk-memory wasm-opt failures - Fix spot market query to use ExchangeQuerierV2 (InjectiveQuerier broken in 1.18) - Fix test_query_derivative_market_mid_price_and_tob: switch to v2 query path and update assertions for human-readable price format - Add workspace root build.sh with contract aliases (stargate, mock, atomic, dummy) - Add contract-level build.sh for injective-cosmwasm-stargate-example
📝 WalkthroughWalkthroughThis pull request introduces infrastructure improvements and API migrations. The root build script is refactored to support contract alias resolution with architecture detection and Docker optimization, a new build script is added for ARM64-specific compilation, derivative query types are migrated from v1beta1 to v2, and Rust toolchain version is downgraded. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant build.sh as build.sh Script
participant resolve_alias as resolve_alias()
participant validate as Validation
participant Docker as Docker Runner
participant Optimizer as cosmwasm/optimizer
User->>build.sh: Invoke with contract alias/path
build.sh->>build.sh: Check if argument provided
alt No argument
build.sh->>User: Print usage & available contracts
else Argument provided
build.sh->>resolve_alias: Pass argument
activate resolve_alias
resolve_alias->>resolve_alias: Match against aliases
resolve_alias-->>build.sh: Return contract directory
deactivate resolve_alias
build.sh->>validate: Check contract dir exists
alt Invalid directory
validate-->>User: Print error message
else Valid
validate-->>build.sh: Proceed
build.sh->>build.sh: Detect host architecture
build.sh->>Docker: Prepare mount paths & optimizer tag
Docker->>Optimizer: Run container with detected arch
Optimizer-->>Docker: Return optimized WASM
Docker-->>User: Build complete
end
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Tip Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs). Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@contracts/injective-cosmwasm-stargate-example/build.sh`:
- Around line 4-6: The architecture check currently only tests for "arm64" via
`arch` and misses Linux `aarch64`; update the detection in the build scripts so
they test for both "arm64" and "aarch64" (or use `uname -m` equivalently) and
set ARCH=-arm64 when either is present; apply the same change to the occurrences
in the three build scripts referenced, targeting the conditional that sets ARCH
and the use of `arch`/`uname -m`.
ℹ️ Review info
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
.gitignorebuild.shcontracts/injective-cosmwasm-stargate-example/build.shcontracts/injective-cosmwasm-stargate-example/src/query.rscontracts/injective-cosmwasm-stargate-example/src/testing/test_exchange_derivative.rsrust-toolchain.toml
| if [[ $(arch) = "arm64" ]]; then | ||
| ARCH=-arm64 | ||
| fi |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Verify architecture detection in build scripts
echo "=== Checking contracts/injective-cosmwasm-stargate-example/build.sh ==="
if [ -f "contracts/injective-cosmwasm-stargate-example/build.sh" ]; then
echo "File exists. Content (first 30 lines):"
head -n 30 contracts/injective-cosmwasm-stargate-example/build.sh | cat -n
else
echo "File not found"
fi
echo ""
echo "=== Checking root build.sh ==="
if [ -f "build.sh" ]; then
echo "File exists. Content (first 30 lines):"
head -n 30 build.sh | cat -n
else
echo "File not found"
fi
echo ""
echo "=== All shell scripts with 'arch' references ==="
rg -l "arch" --type sh 2>/dev/null | head -20Repository: InjectiveLabs/cw-injective
Length of output: 1900
🏁 Script executed:
#!/bin/bash
# Check for other architecture detection patterns and verify behavior
echo "=== Searching for other architecture/platform detection patterns ==="
rg "(arch|aarch64|uname)" --type sh -A 2 -B 2 | head -80
echo ""
echo "=== Check if there are any Docker-related files that specify images ==="
rg "cosmwasm/optimizer" --type sh --type dockerRepository: InjectiveLabs/cw-injective
Length of output: 1016
🌐 Web query:
arch command output aarch64 vs arm64 Linux ARM64 systems
💡 Result:
On Linux, arch is essentially equivalent to uname -m (it prints the machine hardware name of the running kernel/userspace environment, not a distro “marketing” name). On ARM 64-bit systems you’ll commonly see either aarch64 or arm64, but in practice they refer to the same ISA/CPU execution state (ARMv8+ 64-bit). (en.wikipedia.org)
Why you often see aarch64 on Linux
aarch64is the canonical GNU/ELF/GCC naming (e.g., toolchain triplets likeaarch64-linux-gnu) and is what many Linux environments report viauname -m/arch. (lwn.net)- The Linux kernel port is commonly referred to as
arm64(a kernel-community naming choice), even thoughuname/archmay still sayaarch64. (lwn.net)
How distros use the names
- Debian/Ubuntu package architecture:
arm64 - Debian multiarch GNU triplet:
aarch64-linux-gnu(wiki.debian.org)
Practical interpretation (Linux)
arch/uname -m→aarch64⇒ you’re in a 64-bit ARM environment.arch/uname -m→armv7l(etc.) ⇒ you’re in a 32-bit ARM environment.
Also note: in containers/VMs, arch reflects the container/guest environment’s kernel view, which can differ from what you think you’re targeting. (geekchamp.com)
Citations:
- 1: https://en.wikipedia.org/wiki/AArch64?utm_source=openai
- 2: https://lwn.net/Articles/514062/?utm_source=openai
- 3: https://lwn.net/Articles/514062/?utm_source=openai
- 4: https://wiki.debian.org/Multiarch/Tuples?utm_source=openai
- 5: https://geekchamp.com/how-to-check-linux-architecture-a-step-by-step-guide/?utm_source=openai
🏁 Script executed:
#!/bin/bash
# Search for any comments about Docker image variants or cosmwasm/optimizer documentation
echo "=== Search for comments about optimizer image variants ==="
rg "optimizer" -A 3 -B 3 --type sh | head -40
echo ""
echo "=== Check if there are README or doc files that mention architecture ==="
find . -maxdepth 2 -type f \( -name "README*" -o -name "*.md" \) | head -10Repository: InjectiveLabs/cw-injective
Length of output: 1357
🏁 Script executed:
#!/bin/bash
# Check README and look for cosmwasm/optimizer image documentation
echo "=== README content (relevant sections) ==="
cat README.md | head -100
echo ""
echo "=== Search for build-related instructions in README ==="
rg -i "build|docker|arm" README.md -A 2 -B 2 | head -60Repository: InjectiveLabs/cw-injective
Length of output: 5755
🌐 Web query:
cosmwasm/optimizer docker image arm64 aarch64 variants
💡 Result:
- There isn’t a single multi-arch
cosmwasm/optimizerimage that automatically servesarm64/aarch64. CosmWasm publishes separate ARM64 images with an-arm64suffix.aarch64==arm64in Docker platform terms. [1] - ARM64/AArch64 variants you can use:
cosmwasm/optimizer-arm64(combined image; ARM, marked experimental) [1][2]- Deprecated but still listed:
cosmwasm/rust-optimizer-arm64,cosmwasm/workspace-optimizer-arm64[1][2]
- Important note: the project warns the native ARM images can produce different wasm artifacts than the x86_64 images, so they’re discouraged for reproducible/production releases (primarily meant for Apple Silicon dev/testing). [1]
- Publishing/building detail: releases are done separately (e.g.,
make publish-x86_64andmake publish-arm64). [3]
Sources: [1] CosmWasm/optimizer README, [2] Docker Hub cosmwasm org image list, [3] CosmWasm/optimizer “Releasing” wiki.
Architecture detection is too narrow and fails on Linux ARM64 hosts.
The arch command on Linux ARM64 systems returns aarch64, not arm64, so the current check never activates and ARM runners pull the wrong optimizer image. This issue exists in three files: contracts/injective-cosmwasm-stargate-example/build.sh (lines 4–6), build.sh (lines 10–13), and build_release.sh.
Suggested fix (apply to all three files)
-ARCH=""
-
-if [[ $(arch) = "arm64" ]]; then
- ARCH=-arm64
-fi
+ARCH=""
+case "$(uname -m)" in
+ arm64|aarch64) ARCH="-arm64" ;;
+esacNote: CosmWasm publishes separate ARM64 images (cosmwasm/optimizer-arm64), but these can produce different wasm artifacts than x86_64 images and are not recommended for production releases.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| if [[ $(arch) = "arm64" ]]; then | |
| ARCH=-arm64 | |
| fi | |
| case "$(uname -m)" in | |
| arm64|aarch64) ARCH="-arm64" ;; | |
| esac |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@contracts/injective-cosmwasm-stargate-example/build.sh` around lines 4 - 6,
The architecture check currently only tests for "arm64" via `arch` and misses
Linux `aarch64`; update the detection in the build scripts so they test for both
"arm64" and "aarch64" (or use `uname -m` equivalently) and set ARCH=-arm64 when
either is present; apply the same change to the occurrences in the three build
scripts referenced, targeting the conditional that sets ARCH and the use of
`arch`/`uname -m`.
Summary by CodeRabbit
Build & Infrastructure
Build Tools