Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
18 changes: 9 additions & 9 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ jobs:
steps:
- uses: actions/checkout@v3
- run: rustup update
- uses: stellar/binaries@v30
- uses: stellar/binaries@v37
with:
name: cargo-semver-checks
version: 0.35.0
version: 0.40.0
- run: cargo semver-checks

build-and-test:
Expand Down Expand Up @@ -103,19 +103,19 @@ jobs:
- run: rustup update
- run: cargo version
- run: rustup target add ${{ matrix.sys.target }}
- run: rustup target add wasm32-unknown-unknown
- uses: stellar/binaries@v18
- run: rustup target add wasm32v1-none
- uses: stellar/binaries@v37
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
run: rm -fr **/test_snapshots
- name: Build for wasm
run: cargo-hack hack build --target wasm32-unknown-unknown --profile release
run: cargo-hack hack build --target wasm32v1-none --profile release --workspace --exclude soroban-spec --exclude soroban-spec-rust --exclude soroban-ledger-snapshot
- name: Wasm Size
run: |
cd target/wasm32-unknown-unknown/release/ && \
cd target/wasm32v1-none/release/ && \
for i in *.wasm ; do \
ls -l "$i"; \
done
Expand All @@ -138,10 +138,10 @@ jobs:
- uses: actions/checkout@v3
- uses: stellar/actions/rust-cache@main
- run: rustup install nightly
- uses: stellar/binaries@v15
- uses: stellar/binaries@v37
with:
name: cargo-fuzz
version: 0.11.2
version: 0.12.0
- run: make build-fuzz
- name: Check no diffs exist
run: git add -N . && git diff HEAD --exit-code
Expand Down Expand Up @@ -182,7 +182,7 @@ jobs:
matrix:
sys:
- os: ubuntu-latest
target: wasm32-unknown-unknown
target: wasm32v1-none
cargo-hack-feature-options: ''
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
Install rust stable:
```
rustup install stable
rustup +stable target add wasm32-unknown-unknown
rustup +stable target add wasm32v1-none
rustup +stable component add rust-src
```

Install rust nightly:
```
rustup install nightly
rustup +nightly target add wasm32-unknown-unknown
rustup +nightly target add wasm32v1-none
rustup +nightly component add rust-src
```

Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ members = [

[workspace.package]
version = "22.0.7"
rust-version = "1.79.0"
rust-version = "1.84.0"

[workspace.dependencies]
soroban-sdk = { version = "22.0.7", path = "soroban-sdk" }
Expand Down
10 changes: 7 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ all: check test
export RUSTFLAGS=-Dwarnings

CARGO_DOC_ARGS?=--open
NATIVE_ONLY_CRATES:=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
Expand All @@ -12,15 +15,16 @@ test: fmt build
cargo hack --feature-powerset --ignore-unknown-features --features testutils --exclude-features docs test

build: fmt
cargo hack build --target wasm32-unknown-unknown --release
cd target/wasm32-unknown-unknown/release/ && \
cargo hack build --release $(NATIVE_PACKAGE_ARGS)
cargo hack build --target wasm32v1-none --release --workspace $(WASM_EXCLUDE_ARGS)
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 wasm32-unknown-unknown
cargo hack check --release --target wasm32v1-none --workspace $(WASM_EXCLUDE_ARGS)

build-fuzz:
cd tests/fuzz/fuzz && cargo +nightly fuzz check
Expand Down
2 changes: 1 addition & 1 deletion deny.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
# list here is effectively saying which targets you are building for.
targets = [
{ triple = "x86_64-unknown-linux-gnu" },
{ triple = "wasm32-unknown-unknown" }
{ triple = "wasm32v1-none" }
# The triple can be any string, but only the target triples built in to
# rustc (as of 1.40) can be checked against actual config expressions
#{ triple = "x86_64-unknown-linux-musl" },
Expand Down
4 changes: 2 additions & 2 deletions rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[toolchain]
channel = "1.81"
targets = ["wasm32-unknown-unknown"]
channel = "stable"
targets = ["wasm32v1-none"]
components = ["rustc", "cargo", "rustfmt", "clippy", "rust-src"]
1 change: 1 addition & 0 deletions soroban-sdk/src/alloc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ pub struct BumpPointer;

unsafe impl GlobalAlloc for BumpPointer {
#[inline(always)]
#[allow(static_mut_refs)]
unsafe fn alloc(&self, layout: Layout) -> *mut u8 {
let (bytes, align) = (layout.size(), layout.align());
let ptr = LOCAL_ALLOCATOR.alloc(bytes, align);
Expand Down
24 changes: 1 addition & 23 deletions soroban-sdk/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,34 +59,12 @@ pub mod _migrating;
compile_error!("'testutils' feature is not supported on 'wasm' target");

// When used in a no_std contract, provide a panic handler as one is required.
#[cfg(all(not(feature = "alloc"), target_family = "wasm"))]
#[cfg(target_family = "wasm")]
#[panic_handler]
fn handle_panic(_: &core::panic::PanicInfo) -> ! {
core::arch::wasm32::unreachable()
}

// This is a bit subtle: we want to provide a narrowly-scoped feature `"alloc"`
// that provides support for the `alloc` crate and its types, while using our
// allocator (defined below in module `alloc`). We want to do this without
// changing the user-interface a lot (in particular keeping users writing
// `#[no_std]` and mostly not-using the stdlib casually, because it has many
// components that produce large code footprint).
//
// This is _almost_ possible without involving `std` but unfortunately there's
// still an allocation-error handler (`alloc_error_handler`) that there's no
// stable way to install if one only uses the `alloc` crate, so we pull in a
// dependency on `std` here (for now). When the stabilization of the allocation
// error handler registration function happens in some future Rust version, or
// it gets removed which it looks like work is heading towards instead, we can
// remove std.
//
// See these issues for more details:
// - https://github.com/rust-lang/rust/issues/51540
// - https://github.com/rust-lang/rust/issues/66740
// - https://github.com/rust-lang/rust/issues/66741
#[cfg(all(feature = "alloc", target_family = "wasm"))]
extern crate std;

// Here we provide a `#[global_allocator]` that is a minimal non-freeing bump
// allocator, appropriate for a WASM blob that runs a single contract call.
#[cfg(all(feature = "alloc", target_family = "wasm"))]
Expand Down
8 changes: 2 additions & 6 deletions soroban-sdk/src/tests/contractimport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,12 @@ use stellar_xdr::{ScSpecEntry, ScSpecFunctionInputV0, ScSpecFunctionV0, ScSpecTy

mod addcontract {
use crate as soroban_sdk;
soroban_sdk::contractimport!(
file = "../target/wasm32-unknown-unknown/release/test_add_u64.wasm"
);
soroban_sdk::contractimport!(file = "../target/wasm32v1-none/release/test_add_u64.wasm");
}

mod addcontract_u128 {
use crate as soroban_sdk;
soroban_sdk::contractimport!(
file = "../target/wasm32-unknown-unknown/release/test_add_u128.wasm"
);
soroban_sdk::contractimport!(file = "../target/wasm32v1-none/release/test_add_u128.wasm");
}

mod subcontract {
Expand Down
4 changes: 1 addition & 3 deletions soroban-sdk/src/tests/contractimport_with_error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ use soroban_sdk::{contract, contractimpl, symbol_short, Address, Env, Symbol};

mod errcontract {
use crate as soroban_sdk;
soroban_sdk::contractimport!(
file = "../target/wasm32-unknown-unknown/release/test_errors.wasm"
);
soroban_sdk::contractimport!(file = "../target/wasm32v1-none/release/test_errors.wasm");
}

#[contract]
Expand Down
3 changes: 1 addition & 2 deletions soroban-spec-rust/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,7 @@ mod test {
use super::{generate, ToFormattedString};
use soroban_spec::read::from_wasm;

const EXAMPLE_WASM: &[u8] =
include_bytes!("../../target/wasm32-unknown-unknown/release/test_udt.wasm");
const EXAMPLE_WASM: &[u8] = include_bytes!("../../target/wasm32v1-none/release/test_udt.wasm");

#[test]
fn example() {
Expand Down
4 changes: 1 addition & 3 deletions tests/alloc/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ use soroban_sdk::{testutils::EnvTestConfig, vec, Env};
use crate::{Contract, ContractClient};

mod imported {
soroban_sdk::contractimport!(
file = "../../target/wasm32-unknown-unknown/release/test_alloc.wasm"
);
soroban_sdk::contractimport!(file = "../../target/wasm32v1-none/release/test_alloc.wasm");
}

macro_rules! tests {
Expand Down
4 changes: 1 addition & 3 deletions tests/import_contract/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
use soroban_sdk::{contract, contractimpl, Address, Env};

mod addcontract {
soroban_sdk::contractimport!(
file = "../../target/wasm32-unknown-unknown/release/test_add_u64.wasm"
);
soroban_sdk::contractimport!(file = "../../target/wasm32v1-none/release/test_add_u64.wasm");
}

#[contract]
Expand Down