Skip to content

Commit

Permalink
Merge pull request #2065 from CosmWasm/run-cosmwasm-check-in-ci
Browse files Browse the repository at this point in the history
Run cosmwasm-check in CI and add cosmwasm_2_1 feature
  • Loading branch information
webmaster128 authored Mar 26, 2024
2 parents 8a30e33 + 2aeeb6e commit d078d40
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 19 deletions.
56 changes: 43 additions & 13 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ orbs:

commands:
check_contract:
parameters:
min_version:
type: string
skip_cosmwasm_check:
type: boolean
default: false
steps:
- run:
name: Add wasm32 target
Expand All @@ -22,7 +28,17 @@ commands:
- run:
name: Build wasm binary
command: cargo wasm --locked
# After wasm build to ensure target/wasm32-unknown-unknown/release/<contract>.wasm exists
- when:
condition:
not: << parameters.skip_cosmwasm_check >>
steps:
- run:
name: Run cosmwasm-check (<< parameters.min_version >>)
command: |
cargo install cosmwasm-check@~<< parameters.min_version >> --locked --force
cosmwasm-check --version
cosmwasm-check target/wasm32-unknown-unknown/release/*.wasm
# Run clippy after wasm build to ensure target/wasm32-unknown-unknown/release/<contract>.wasm exists
- run:
name: Clippy
command: cargo clippy --all-targets -- -D warnings
Expand Down Expand Up @@ -472,7 +488,8 @@ jobs:
- restore_cache:
keys:
- cargocache-v2-contract_burner-rust:1.73-{{ checksum "Cargo.lock" }}
- check_contract
- check_contract:
min_version: "1.4"
- save_cache:
paths:
- /usr/local/cargo/registry
Expand All @@ -499,7 +516,10 @@ jobs:
- restore_cache:
keys:
- cargocache-v2-contract_crypto_verify-rust:1.73-{{ checksum "Cargo.lock" }}
- check_contract
# TODO: Enable this once 2.1 has been released to crates.io
- check_contract:
min_version: "2.1"
skip_cosmwasm_check: true
- save_cache:
paths:
- /usr/local/cargo/registry
Expand All @@ -526,7 +546,8 @@ jobs:
- restore_cache:
keys:
- cargocache-v2-contract_cyberpunk-rust:1.73-{{ checksum "Cargo.lock" }}
- check_contract
- check_contract:
min_version: "1.3"
- save_cache:
paths:
- /usr/local/cargo/registry
Expand All @@ -553,7 +574,8 @@ jobs:
- restore_cache:
keys:
- cargocache-v2-contract_hackatom-rust:1.73-{{ checksum "Cargo.lock" }}
- check_contract
- check_contract:
min_version: "1.4"
- save_cache:
paths:
- /usr/local/cargo/registry
Expand All @@ -580,7 +602,8 @@ jobs:
- restore_cache:
keys:
- cargocache-v2-contract_ibc_reflect-rust:1.73-{{ checksum "Cargo.lock" }}
- check_contract
- check_contract:
min_version: "2.0"
- save_cache:
paths:
- /usr/local/cargo/registry
Expand All @@ -607,7 +630,8 @@ jobs:
- restore_cache:
keys:
- cargocache-v2-contract_ibc_reflect_send-rust:1.73-{{ checksum "Cargo.lock" }}
- check_contract
- check_contract:
min_version: "1.4"
- save_cache:
paths:
- /usr/local/cargo/registry
Expand All @@ -634,7 +658,8 @@ jobs:
- restore_cache:
keys:
- cargocache-v2-contract_floaty-rust:1.73-{{ checksum "Cargo.lock" }}
- check_contract
- check_contract:
min_version: "1.4"
- save_cache:
paths:
- /usr/local/cargo/registry
Expand All @@ -661,7 +686,8 @@ jobs:
- restore_cache:
keys:
- cargocache-v2-contract_queue-rust:1.73-{{ checksum "Cargo.lock" }}
- check_contract
- check_contract:
min_version: "1.4"
- save_cache:
paths:
- /usr/local/cargo/registry
Expand All @@ -688,7 +714,8 @@ jobs:
- restore_cache:
keys:
- cargocache-v2-contract_reflect-rust:1.73-{{ checksum "Cargo.lock" }}
- check_contract
- check_contract:
min_version: "2.0"
- save_cache:
paths:
- /usr/local/cargo/registry
Expand All @@ -715,7 +742,8 @@ jobs:
- restore_cache:
keys:
- cargocache-v2-contract_staking-rust:1.73-{{ checksum "Cargo.lock" }}
- check_contract
- check_contract:
min_version: "1.4"
- save_cache:
paths:
- /usr/local/cargo/registry
Expand All @@ -742,7 +770,8 @@ jobs:
- restore_cache:
keys:
- cargocache-v2-contract_virus-rust:1.73-{{ checksum "Cargo.lock" }}
- check_contract
- check_contract:
min_version: "1.4"
- save_cache:
paths:
- /usr/local/cargo/registry
Expand All @@ -769,7 +798,8 @@ jobs:
- restore_cache:
keys:
- cargocache-v2-contract_empty-rust:1.73-{{ checksum "Cargo.lock" }}
- check_contract
- check_contract:
min_version: "2.0"
- save_cache:
paths:
- /usr/local/cargo/registry
Expand Down
8 changes: 3 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,12 @@ jobs:
working-directory: ./contracts/hackatom
steps:
- name: Checkout sources
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Install Rust
uses: actions-rs/toolchain@v1
uses: dtolnay/rust-toolchain@master
with:
toolchain: 1.73.0
target: wasm32-unknown-unknown
profile: minimal
override: true
targets: wasm32-unknown-unknown
- name: Build hackatom wasm
run: cargo wasm --locked
- name: Unit Test hackatom
Expand Down
2 changes: 1 addition & 1 deletion contracts/crypto-verify/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ cranelift = ["cosmwasm-vm/cranelift"]

[dependencies]
cosmwasm-schema = { path = "../../packages/schema" }
cosmwasm-std = { path = "../../packages/std", features = ["iterator"] }
cosmwasm-std = { path = "../../packages/std", features = ["cosmwasm_2_1", "iterator"] }
hex = "0.4"
rlp = "0.5"
schemars = "0.8.12"
Expand Down
3 changes: 3 additions & 0 deletions packages/std/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ cosmwasm_1_4 = ["cosmwasm_1_3"]
# This enables functionality that is only available on 2.0 chains.
# It adds `CosmosMsg::Any`, replacing `CosmosMsg::Stargate`. It also adds `QueryRequest::Grpc`.
cosmwasm_2_0 = ["cosmwasm_1_4"]
# This enables functionality that is only available on 2.1 chains.
# It adds verification and key recovery for the secp256r1 elliptic curve.
cosmwasm_2_1 = ["cosmwasm_2_0"]

[dependencies]
base64 = "0.21.0"
Expand Down
4 changes: 4 additions & 0 deletions packages/std/src/imports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,10 @@ extern "C" {
/// secp256r1 ECDSA parametrization.
/// Returns 0 on verification success, 1 on verification failure, and values
/// greater than 1 in case of error.
#[cfg(feature = "cosmwasm_2_1")]
fn secp256r1_verify(message_hash_ptr: u32, signature_ptr: u32, public_key_ptr: u32) -> u32;

#[cfg(feature = "cosmwasm_2_1")]
fn secp256r1_recover_pubkey(
message_hash_ptr: u32,
signature_ptr: u32,
Expand Down Expand Up @@ -419,6 +421,7 @@ impl Api for ExternalApi {
}
}

#[cfg(feature = "cosmwasm_2_1")]
fn secp256r1_verify(
&self,
message_hash: &[u8],
Expand All @@ -445,6 +448,7 @@ impl Api for ExternalApi {
}
}

#[cfg(feature = "cosmwasm_2_1")]
fn secp256r1_recover_pubkey(
&self,
message_hash: &[u8],
Expand Down

0 comments on commit d078d40

Please sign in to comment.