From 85523a823a403b0c17f646bfa3a8cf18105a874c Mon Sep 17 00:00:00 2001 From: Michael Mueller Date: Tue, 20 Sep 2022 08:12:02 +0200 Subject: [PATCH 1/5] Remove `wee-alloc` It is no longer maintained. --- crates/allocator/Cargo.toml | 2 -- crates/allocator/src/lib.rs | 22 ++++------------------ crates/env/Cargo.toml | 1 - 3 files changed, 4 insertions(+), 21 deletions(-) diff --git a/crates/allocator/Cargo.toml b/crates/allocator/Cargo.toml index 5d1253663d2..03be8d0dd73 100644 --- a/crates/allocator/Cargo.toml +++ b/crates/allocator/Cargo.toml @@ -16,7 +16,6 @@ include = ["Cargo.toml", "src/**/*.rs", "README.md", "LICENSE"] [dependencies] cfg-if = "1.0" -wee_alloc = { version = "0.4", default-features = false, optional = true } [dev-dependencies] quickcheck = "1" @@ -25,5 +24,4 @@ quickcheck_macros = "1" [features] default = ["std"] std = [] -wee-alloc = ["wee_alloc"] ink-fuzz-tests = ["std"] diff --git a/crates/allocator/src/lib.rs b/crates/allocator/src/lib.rs index 063fb085700..02e89b34275 100644 --- a/crates/allocator/src/lib.rs +++ b/crates/allocator/src/lib.rs @@ -14,36 +14,22 @@ //! Crate providing allocator support for all Wasm compilations of ink! smart contracts. //! -//! The default allocator is a bump allocator whose goal is to have a small size footprint. If you -//! are not concerned about the size of your final Wasm binaries you may opt into using the more -//! full-featured `wee_alloc` allocator by activating the `wee-alloc` crate feature. +//! The allocator is a bump allocator whose goal is to have a small size footprint. +//! It never frees memory, having this logic in place would increase the size footprint +//! of each contract. #![cfg_attr(not(feature = "std"), no_std)] #![cfg_attr(not(feature = "std"), feature(alloc_error_handler))] -// We use `wee_alloc` as the global allocator since it is optimized for binary file size -// so that contracts compiled with it as allocator do not grow too much in size. #[cfg(not(feature = "std"))] -#[cfg(feature = "wee-alloc")] -#[global_allocator] -static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT; - -#[cfg(not(feature = "std"))] -#[cfg(not(feature = "wee-alloc"))] #[global_allocator] static mut ALLOC: bump::BumpAllocator = bump::BumpAllocator {}; -#[cfg(not(feature = "wee-alloc"))] mod bump; #[cfg(not(feature = "std"))] mod handlers; -#[cfg(all( - test, - feature = "std", - feature = "ink-fuzz-tests", - not(feature = "wee-alloc") -))] +#[cfg(all(test, feature = "std", feature = "ink-fuzz-tests",))] #[macro_use(quickcheck)] extern crate quickcheck_macros; diff --git a/crates/env/Cargo.toml b/crates/env/Cargo.toml index 6c49cff2a1a..5b7af85966a 100644 --- a/crates/env/Cargo.toml +++ b/crates/env/Cargo.toml @@ -72,4 +72,3 @@ std = [ ] # Enable contract debug messages via `debug_print!` and `debug_println!`. ink-debug = [] -wee-alloc = ["ink_allocator/wee-alloc"] From b3103dfadc7b1789bceecd4d483980e8ac4200dd Mon Sep 17 00:00:00 2001 From: Michael Mueller Date: Tue, 20 Sep 2022 08:13:52 +0200 Subject: [PATCH 2/5] Fix `clippy::nonminimal_bool` --- crates/allocator/src/bump.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/allocator/src/bump.rs b/crates/allocator/src/bump.rs index 3fd374f2018..719900faa75 100644 --- a/crates/allocator/src/bump.rs +++ b/crates/allocator/src/bump.rs @@ -468,7 +468,7 @@ mod fuzz_tests { // We want to explicitly test for the case where a series of allocations eventually // runs out of pages of memory - if !(pages_required > max_pages) { + if pages_required <= max_pages { return TestResult::discard() } From 0f21d6cf9ed8338b8c17b18ee0195d001a482576 Mon Sep 17 00:00:00 2001 From: Michael Mueller Date: Tue, 20 Sep 2022 08:28:59 +0200 Subject: [PATCH 3/5] Update changelog --- CHANGELOG.md | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e4031a2c500..771f398ce0d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,8 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Breaking Changes #### New `ink` crate -The `ink_lang` crate has been replaced in [#1223](https://github.com/paritytech/ink/pull/1223) by a new top level `ink` -crate. All existing sub-crates are reexported and should be used via the new `ink` crate, so e.g. `ink::env` instead of +The `ink_lang` crate has been replaced in [#1223](https://github.com/paritytech/ink/pull/1223) by a new top level `ink` +crate. All existing sub-crates are reexported and should be used via the new `ink` crate, so e.g. `ink::env` instead of `ink_env`. Contract authors should now import the top level `ink` crate instead of the individual crates. ##### Migration @@ -19,6 +19,20 @@ crate. All existing sub-crates are reexported and should be used via the new `in - Remove the commonly used `use ink_lang as ink` idiom. - Replace all usages of individual crates with reexports, e.g. `ink_env` ➜ `ink::env`. +#### Removal of `wee-alloc` support +ink! uses a bump allocator by default, additionally we supported another allocator (`wee-alloc`) +through a feature flag. `wee-alloc` is no longer maintained and we removed support for it. + +### Changed +- Introduce `ink` entrance crate ‒ [#1223](https://github.com/paritytech/ink/pull/1223) +- Use `XXH32` instead of `sha256` for calculating storage keys ‒ [#1393](https://github.com/paritytech/ink/pull/1393) + +### Fixed +- Trim single whitespace prefix in the metadata `docs` field ‒ [#1385](https://github.com/paritytech/ink/pull/1385) + +### Removed +- Remove `wee-alloc` ‒ [#1403](https://github.com/paritytech/ink/pull/1403) + ## Version 4.0.0-alpha.1 ### Compatibility @@ -60,7 +74,7 @@ return an `Option` instead of `()`. - Move ink! linter into `ink` repository ‒ [#1361](https://github.com/paritytech/ink/pull/1267) ### Removed -- :x: Implement ecdsa_to_eth_address() and remove eth_compatibility crate ‒ [#1233](https://github.com/paritytech/ink/pull/1233) +- :x: Implement `ecdsa_to_eth_address()` and remove `eth_compatibility` crate ‒ [#1233](https://github.com/paritytech/ink/pull/1233) ## Version 3.3.1 @@ -157,7 +171,7 @@ We added two new `Mapping` API functions: [`Mapping::insert_return_size`](https://paritytech.github.io/ink/ink_storage/struct.Mapping.html#method.insert_return_size) ‒ [#1224](https://github.com/paritytech/ink/pull/1224). These are more gas-efficient than whatever you were using previously. -Additionaly there are a couple new `ink_env` functions now: +Additionally there are a couple new `ink_env` functions now: * [`ink_env::set_code_hash`](https://paritytech.github.io/ink/ink_env/fn.set_code_hash.html) * [`ink_env::own_code_hash`](https://paritytech.github.io/ink/ink_env/fn.own_code_hash.html) * [`ink_env::code_hash`](https://paritytech.github.io/ink/ink_env/fn.code_hash.html) From 054b85fd15836cdf16b0dafa4ddb378e42c96061 Mon Sep 17 00:00:00 2001 From: Michael Mueller Date: Tue, 20 Sep 2022 09:21:59 +0200 Subject: [PATCH 4/5] Use `nightly` for `codecov` CI stage --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 7250ced4682..35c40e84b2b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -320,8 +320,8 @@ codecov: - find . -name "*.gcda" -type f -delete script: # RUSTFLAGS are the cause target cache can't be used here - - cargo build --verbose --all-features --workspace - - cargo test --verbose --all-features --no-fail-fast --workspace + - cargo +nightly build --verbose --all-features --workspace + - cargo +nightly test --verbose --all-features --no-fail-fast --workspace # coverage with branches - grcov . --binary-path ./target/debug/ --source-dir . --output-type lcov --llvm --branch --ignore-not-existing --ignore "/*" --ignore "tests/*" --output-path lcov-w-branch.info From fc3b31865db1746118ccd318d0a66d9d3dd14641 Mon Sep 17 00:00:00 2001 From: Michael Mueller Date: Tue, 20 Sep 2022 09:37:07 +0200 Subject: [PATCH 5/5] Revert "Use `nightly` for `codecov` CI stage" This reverts commit 054b85fd15836cdf16b0dafa4ddb378e42c96061. --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 35c40e84b2b..7250ced4682 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -320,8 +320,8 @@ codecov: - find . -name "*.gcda" -type f -delete script: # RUSTFLAGS are the cause target cache can't be used here - - cargo +nightly build --verbose --all-features --workspace - - cargo +nightly test --verbose --all-features --no-fail-fast --workspace + - cargo build --verbose --all-features --workspace + - cargo test --verbose --all-features --no-fail-fast --workspace # coverage with branches - grcov . --binary-path ./target/debug/ --source-dir . --output-type lcov --llvm --branch --ignore-not-existing --ignore "/*" --ignore "tests/*" --output-path lcov-w-branch.info