Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
2713efe
make the test vectors builds more stable
leighmcculloch Sep 29, 2025
579fcea
update sdk version metadata comment to clarify test wasm hash concerns
leighmcculloch Sep 29, 2025
0f7623b
update ci
leighmcculloch Sep 29, 2025
d63cefd
upd
leighmcculloch Sep 29, 2025
41b38c0
update rustflags config for wasm build
leighmcculloch Sep 29, 2025
7dbe5e4
upd
leighmcculloch Sep 29, 2025
5d14810
update stellar binaries version to v41 and cargo-semver-checks to 0.44.0
leighmcculloch Sep 29, 2025
b742eff
build with msrv
leighmcculloch Sep 29, 2025
dd4abb4
test with test-wasms from msrv build only
leighmcculloch Sep 29, 2025
a1bbcbf
remove and re-add test snapshot cleanup step
leighmcculloch Sep 29, 2025
2a8c9f6
separate build and test in ci
leighmcculloch Sep 29, 2025
b0d22d9
add build dependency to test job
leighmcculloch Sep 29, 2025
d05aa9c
update github workflow to use build and test jobs instead of build-an…
leighmcculloch Sep 29, 2025
091a8ba
remove build-test-wasms workflow job
leighmcculloch Sep 29, 2025
4fce28f
add clippy and rustfmt components to workflow
leighmcculloch Sep 29, 2025
72271c5
update makefile to use cargo-hack instead of cargo hack
leighmcculloch Sep 29, 2025
082a899
update cargo-hack invocations to use cargo command
leighmcculloch Sep 29, 2025
144d88b
debug
leighmcculloch Sep 29, 2025
c631348
debug
leighmcculloch Sep 29, 2025
5917b91
debug
leighmcculloch Sep 29, 2025
9a40682
debug
leighmcculloch Sep 29, 2025
51f9d26
debug
leighmcculloch Sep 29, 2025
7824b43
debug
leighmcculloch Sep 29, 2025
c51a16a
debug
leighmcculloch Sep 29, 2025
5b2a826
debug
leighmcculloch Sep 29, 2025
06cc0aa
debug
leighmcculloch Sep 29, 2025
2b9f5f3
debug
leighmcculloch Sep 29, 2025
96dd57d
remove debug
leighmcculloch Sep 29, 2025
73968f0
debug
leighmcculloch Sep 29, 2025
52d405b
debug
leighmcculloch Sep 29, 2025
0de3525
fix binaries install
leighmcculloch Sep 29, 2025
a596b93
fix jq match for windows
leighmcculloch Sep 29, 2025
3dbd353
update cargo-fuzz version to 0.13.1gp
leighmcculloch Sep 29, 2025
c1e3526
update makefile to use contains instead of test for tests directory d…
leighmcculloch Sep 29, 2025
d50774e
update makefile to use test_ prefix for test crates
leighmcculloch Sep 29, 2025
9ad86da
update test crate rust version variable
leighmcculloch Sep 29, 2025
88d53cc
update test wasm build to use explicit rust version
leighmcculloch Sep 29, 2025
c190002
update test wasm build to use rustup toolchain
leighmcculloch Sep 29, 2025
85a9a1d
add rustfmt component to clippy installation
leighmcculloch Sep 29, 2025
c5f1a9c
Merge branch 'main' into i1465-stable-test-vectors
leighmcculloch Sep 29, 2025
13e0511
update test vectors and workflow os targets
leighmcculloch Sep 29, 2025
3b46746
remove print-features target from makefile
leighmcculloch Sep 29, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
113 changes: 72 additions & 41 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ concurrency:
group: ${{ github.workflow }}-${{ github.ref_protected == 'true' && github.sha || github.ref }}-{{ github.event_name }}
cancel-in-progress: true

env:
ARTIFACT_RETENTION_DAYS_FOR_TEST_WASMS: 7

defaults:
run:
shell: bash
Expand All @@ -18,7 +21,7 @@ jobs:

complete:
if: always()
needs: [fmt, check-git-rev-deps, semver-checks, build-and-test, build-fuzz, docs, readme, migration-docs]
needs: [fmt, check-git-rev-deps, semver-checks, build, test, build-fuzz, docs, readme, migration-docs]
runs-on: ubuntu-latest
steps:
- if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')
Expand Down Expand Up @@ -57,7 +60,7 @@ jobs:
steps:
- uses: actions/checkout@v3
- run: rustup update
- uses: stellar/binaries@v41
- uses: stellar/binaries@v45
with:
name: cargo-semver-checks
version: 0.44.0
Expand All @@ -67,26 +70,68 @@ jobs:
--exclude soroban-token-spec
--exclude stellar-asset-spec

build-and-test:
build:
strategy:
fail-fast: false
matrix:
rust: [msrv, latest]
sys:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
- os: ubuntu-24.04-arm
target: aarch64-unknown-linux-gnu
- os: macos-15-intel
target: x86_64-apple-darwin
- os: macos-latest
target: aarch64-apple-darwin
- os: windows-latest
target: x86_64-pc-windows-msvc
runs-on: ${{ matrix.sys.os }}
steps:
- uses: actions/checkout@v3
- uses: stellar/actions/rust-cache@main
- name: Use the minimum supported Rust version
if: matrix.rust == 'msrv'
run: |
msrv="$(cargo metadata --format-version 1 --no-deps | jq -r '.packages | map(.rust_version) | map(values) | min')"
rustup override set $msrv
rustup component add clippy rustfmt
- name: Error on warnings only for msrv
if: matrix.rust == 'msrv'
run: echo RUSTFLAGS='-Dwarnings' >> $GITHUB_ENV
- run: rustup update
- run: cargo version
- run: rustup target add ${{ matrix.sys.target }}
- run: rustup target add wasm32v1-none
- run: echo CARGO_BUILD_TARGET='${{ matrix.sys.target }}' >> $GITHUB_ENV
- uses: stellar/binaries@v45
with:
name: cargo-hack
version: 0.5.28
- run: make build-libs
- run: make build-test-wasms TEST_CRATES_RUSTUP_TOOLCHAIN=
- name: Upload test wasms
uses: actions/upload-artifact@v4
with:
name: test-wasms-${{ matrix.rust }}-${{ matrix.sys.target }}
path: target/wasm32v1-none/release/test_*.wasm
retention-days: ${{ env.ARTIFACT_RETENTION_DAYS_FOR_TEST_WASMS }}

test:
needs: build
strategy:
fail-fast: false
matrix:
rust: [msrv, latest]
sys:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
- os: ubuntu-24.04-arm
target: aarch64-unknown-linux-gnu
# Fix #1011 by avoiding the use of crate-type = ["cdylib"] in native
# builds that cross-compile. It causes linker errors. The root cause
# is rust-lang/cargo#4133. This workaround uses rustc to build for a
# specific crate-type, lib, such that the Cargo.toml crate-type is
# ignored.
cdylib-cross-compile-workaround: true
# - os: macos-latest
# target: x86_64-apple-darwin
# - os: macos-latest
# target: aarch64-apple-darwin
- os: macos-15-intel
target: x86_64-apple-darwin
- os: macos-latest
target: aarch64-apple-darwin
- os: windows-latest
target: x86_64-pc-windows-msvc
runs-on: ${{ matrix.sys.os }}
Expand All @@ -98,42 +143,28 @@ jobs:
run: |
msrv="$(cargo metadata --format-version 1 --no-deps | jq -r '.packages | map(.rust_version) | map(values) | min')"
rustup override set $msrv
rustup component add clippy --toolchain $msrv
- name: Error on warnings and clippy checks
# Only error on warnings and checks for the msrv, because new versions of
# Rust will frequently add new warnings and checks.
rustup component add clippy rustfmt
- name: Error on warnings only for msrv
if: matrix.rust == 'msrv'
run: echo RUSTFLAGS='-Dwarnings' >> $GITHUB_ENV
- run: rustup update
- run: cargo version
- run: rustup target add ${{ matrix.sys.target }}
- run: rustup target add wasm32v1-none
- uses: stellar/binaries@v37
- run: echo CARGO_BUILD_TARGET='${{ matrix.sys.target }}' >> $GITHUB_ENV
- uses: stellar/binaries@v45
with:
name: cargo-hack
version: 0.5.28
- if: startsWith(matrix.sys.target, 'x86_64')
name: Clear test snapshots for checking no diffs exists after test run
- name: Restore test wasms for tests from one of the msrv builds
uses: actions/download-artifact@v5
with:
name: test-wasms-msrv-x86_64-unknown-linux-gnu
path: target/wasm32v1-none/release/
- name: Clear test snapshots for checking no diffs exists after test run
run: rm -fr **/test_snapshots
- name: Build for wasm
run: cargo-hack hack build --target wasm32v1-none --profile release --workspace --exclude soroban-meta --exclude soroban-spec --exclude soroban-spec-rust --exclude soroban-ledger-snapshot
- name: Wasm Size
run: |
cd target/wasm32v1-none/release/ && \
for i in *.wasm ; do \
ls -l "$i"; \
done
- if: "!matrix.sys.cdylib-cross-compile-workaround"
name: Build for native
run: cargo-hack hack --feature-powerset --exclude-features docs build --target ${{ matrix.sys.target }}
- if: "matrix.sys.cdylib-cross-compile-workaround"
name: Build for native
run: cargo-hack hack --feature-powerset --exclude-features docs rustc --workspace --exclude soroban-sdk-macros --exclude proc_macros --crate-type lib --target ${{ matrix.sys.target }}
- if: startsWith(matrix.sys.target, 'x86_64')
name: Run tests
run: cargo-hack hack --feature-powerset --ignore-unknown-features --features testutils --exclude-features docs test --target ${{ matrix.sys.target }}
- if: startsWith(matrix.sys.target, 'x86_64')
name: Check no diffs exist
- run: make test
- name: Check no diffs exist
run: git add -N . && git diff HEAD --exit-code

build-fuzz:
Expand All @@ -142,10 +173,10 @@ jobs:
- uses: actions/checkout@v3
- uses: stellar/actions/rust-cache@main
- run: rustup install nightly
- uses: stellar/binaries@v37
- uses: stellar/binaries@v45
with:
name: cargo-fuzz
version: 0.12.0
version: 0.13.1
- run: make build-fuzz
- name: Check no diffs exist
run: git add -N . && git diff HEAD --exit-code
Expand Down
33 changes: 20 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,31 +1,38 @@
LIB_CRATES = $(shell cargo metadata --no-deps --format-version 1 | jq -r '.packages[] | select(.name | startswith("test_") | not) | .name' | tr '\n' ' ')
TEST_CRATES = $(shell cargo metadata --no-deps --format-version 1 | jq -r '.packages[] | select(.name | startswith("test_")) | .name' | tr '\n' ' ')

MSRV = $(shell cargo metadata --no-deps --format-version 1 | jq -r '.packages[] | select(.name == "soroban-sdk") | .rust_version')
TEST_CRATES_RUSTUP_TOOLCHAIN?=$(MSRV)

all: check test

export RUSTFLAGS=-Dwarnings

CARGO_DOC_ARGS?=--open
NATIVE_ONLY_CRATES:=soroban-meta soroban-spec soroban-spec-rust soroban-ledger-snapshot
NATIVE_PACKAGE_ARGS:=$(foreach i,$(NATIVE_ONLY_CRATES), --package $(i))
WASM_EXCLUDE_ARGS:=$(foreach i,$(NATIVE_ONLY_CRATES), --exclude $(i))

doc: fmt
cargo test --doc -p soroban-sdk -p soroban-sdk-macros --features testutils,hazmat
cargo +nightly doc -p soroban-sdk --no-deps --all-features $(CARGO_DOC_ARGS)
cargo test --doc $(foreach c,$(LIB_CRATES),--package $(c)) --features testutils,alloc,hazmat
cargo +nightly doc --no-deps $(foreach c,$(LIB_CRATES),--package $(c)) --all-features $(CARGO_DOC_ARGS)

test: fmt build
test: fmt build-test-wasms
cargo hack --feature-powerset --ignore-unknown-features --features testutils --exclude-features docs test

build: fmt
cargo hack build --release $(NATIVE_PACKAGE_ARGS)
cargo hack build --target wasm32v1-none --release --workspace $(WASM_EXCLUDE_ARGS)
build: build-libs build-test-wasms

build-libs: fmt
cargo hack build --release $(foreach c,$(LIB_CRATES),--package $(c))

build-test-wasms: fmt
# Build the test wasms with MSRV by default, with some meta disabled for
# binary stability for tests.
RUSTUP_TOOLCHAIN=$(TEST_CRATES_RUSTUP_TOOLCHAIN) \
RUSTFLAGS='--cfg soroban_sdk_internal_no_rssdkver_meta' \
cargo hack build --release --target wasm32v1-none $(foreach c,$(TEST_CRATES),--package $(c)) ; \
cd target/wasm32v1-none/release/ && \
for i in *.wasm ; do \
ls -l "$$i"; \
done

check: build fmt
cargo hack --feature-powerset --exclude-features docs check
cargo hack check --release --target wasm32v1-none --workspace $(WASM_EXCLUDE_ARGS)

build-fuzz:
cd tests/fuzz/fuzz && cargo +nightly fuzz check

Expand Down
4 changes: 2 additions & 2 deletions soroban-meta/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ fn test_from_wasm() {
ScMetaEntry::ScMetaV0(v0) => v0.key.to_string(),
})
.collect::<Vec<_>>();
assert_eq!(keys, ["rsver", "rssdkver"]);
assert_eq!(keys, ["rsver"]);
}

#[test]
Expand Down Expand Up @@ -58,5 +58,5 @@ fn test_multiple_metadata_sections() {
ScMetaEntry::ScMetaV0(v0) => v0.key.to_string(),
})
.collect::<Vec<_>>();
assert_eq!(keys, ["rsver", "rssdkver", "mykey"]);
assert_eq!(keys, ["rsver", "mykey"]);
}
6 changes: 6 additions & 0 deletions soroban-sdk/build.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
pub fn main() {
// Inform the compiler that the soroban_sdk_internal_no_rssdkver_meta cfg is valid.
// The cfg is used when building the test vectors in this repository, to disable the embedding
// of the rssdkver meta to increase the stability of the build wasms and therefore their wasm
// hash.
println!("cargo::rustc-check-cfg=cfg(soroban_sdk_internal_no_rssdkver_meta)");

#[cfg(all(target_family = "wasm", target_os = "unknown"))]
if let Ok(version) = rustc_version::version() {
if version.major == 1 && version.minor >= 82 {
Expand Down
7 changes: 6 additions & 1 deletion soroban-sdk/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,12 @@ const _: () = {
// Rustc version.
contractmeta!(key = "rsver", val = env!("RUSTC_VERSION"),);

// Rust Soroban SDK version.
// Rust Soroban SDK version. Don't emit when the cfg is set. The cfg is set when building test
// wasms in this repository, so that every commit in this repo does not cause the test wasms in
// this repo to have a new hash due to the revision being embedded. The wasm hash gets embedded
// into a few places, such as test snapshots, or get used in test themselves where if they are
// constantly changing creates repetitive diffs.
#[cfg(not(soroban_sdk_internal_no_rssdkver_meta))]
contractmeta!(
key = "rssdkver",
val = concat!(env!("CARGO_PKG_VERSION"), "#", env!("GIT_REVISION")),
Expand Down
11 changes: 3 additions & 8 deletions soroban-sdk/src/tests/address.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use crate::{self as soroban_sdk};
use sha2::{Digest, Sha256};
use soroban_sdk::{
address::Executable, contract, env::EnvTestConfig, testutils::Address as _, Address, Bytes,
BytesN, Env, String, TryIntoVal,
address::Executable, contract, testutils::Address as _, Address, Bytes, BytesN, Env, String,
TryIntoVal,
};

#[contract]
Expand Down Expand Up @@ -86,12 +86,7 @@ fn test_get_existing_contract_address_executable_wasm() {
const EXAMPLE_WASM: &[u8] =
include_bytes!("../../../target/wasm32v1-none/release/test_udt.wasm");

let env = Env::new_with_config(EnvTestConfig {
// Disable test snapshots because the tests in this repo will run across
// multiple hosts, and this test uses a wasm file that won't build consistently
// across different hosts.
capture_snapshot_at_drop: false,
});
let env = Env::default();

let contract_address = env.register(EXAMPLE_WASM, ());
let contract_executable = contract_address.executable();
Expand Down
8 changes: 1 addition & 7 deletions soroban-sdk/src/tests/crypto_bls12_381.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use crate::{self as soroban_sdk};
use soroban_sdk::{
bytes, bytesn, contract, contractimpl,
crypto::bls12_381::{Bls12_381, Fp, Fp2, Fr, G1Affine, G2Affine},
env::EnvTestConfig,
vec, Address, Bytes, BytesN, Env, Vec, U256,
};

Expand Down Expand Up @@ -254,12 +253,7 @@ impl Contract {

#[test]
fn test_invoke_contract() {
let e = Env::new_with_config(EnvTestConfig {
// Disable test snapshots because the tests in this repo will run across
// multiple hosts, and this test uses a wasm file that won't build consistently
// across different hosts.
capture_snapshot_at_drop: false,
});
let e = Env::default();

let bls_contract_id = e.register(blscontract::WASM, ());

Expand Down
Loading
Loading