Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove support for wee-alloc #1403

Merged
merged 6 commits into from
Sep 20, 2022
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
22 changes: 18 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -60,7 +74,7 @@ return an `Option<u32>` 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

Expand Down Expand Up @@ -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)
Expand Down
2 changes: 0 additions & 2 deletions crates/allocator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -25,5 +24,4 @@ quickcheck_macros = "1"
[features]
default = ["std"]
std = []
wee-alloc = ["wee_alloc"]
ink-fuzz-tests = ["std"]
2 changes: 1 addition & 1 deletion crates/allocator/src/bump.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}

Expand Down
22 changes: 4 additions & 18 deletions crates/allocator/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
1 change: 0 additions & 1 deletion crates/env/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,3 @@ std = [
]
# Enable contract debug messages via `debug_print!` and `debug_println!`.
ink-debug = []
wee-alloc = ["ink_allocator/wee-alloc"]