Unverified Commit 22b3014a authored by Hero Bird's avatar Hero Bird Committed by GitHub
Browse files

Misc fixes for ink! 3.0-rc1 (#530)

* [benches] fix lazy benchmarks

* [*] fix Cargo.toml documentation links

* [readme] show CI status of master branch always

* [readme] misc improvements

* [storage] make re-export of LazyHashMap inline

* [releases] add notes about ink_core split

* [allocator] add some crate level docs

* [storage] impl scale_info::TypeInfo for ink_storage::alloc::Box

* [metadata] improve docs slightly

* [storage] re-introduce StorageLayout impl for storage::Box
parent 2c1904fe
Pipeline #111433 passed with stages
in 7 minutes and 17 seconds
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
| [![linux][a1]][a2] | [![codecov][c1]][c2] | [![coveralls][d1]][d2] | [![loc][e1]][e2] | | [![linux][a1]][a2] | [![codecov][c1]][c2] | [![coveralls][d1]][d2] | [![loc][e1]][e2] |
[a1]: https://gitlab.parity.io/parity/ink/badges/master/pipeline.svg [a1]: https://gitlab.parity.io/parity/ink/badges/master/pipeline.svg
[a2]: https://gitlab.parity.io/parity/ink/pipelines [a2]: https://gitlab.parity.io/parity/ink/pipelines?ref=master
[c1]: https://codecov.io/gh/paritytech/ink/branch/master/graph/badge.svg [c1]: https://codecov.io/gh/paritytech/ink/branch/master/graph/badge.svg
[c2]: https://codecov.io/gh/paritytech/ink/branch/master [c2]: https://codecov.io/gh/paritytech/ink/branch/master
[d1]: https://coveralls.io/repos/github/paritytech/ink/badge.svg?branch=master [d1]: https://coveralls.io/repos/github/paritytech/ink/badge.svg?branch=master
...@@ -23,11 +23,9 @@ ...@@ -23,11 +23,9 @@
[j1]: https://img.shields.io/badge/docs-lang-blue.svg [j1]: https://img.shields.io/badge/docs-lang-blue.svg
[j2]: https://paritytech.github.io/ink/ink_lang [j2]: https://paritytech.github.io/ink/ink_lang
**IMPORTANT NOTE:** WORK IN PROGRESS! Do not expect this to be working.
ink! is an [eDSL](https://wiki.haskell.org/Embedded_domain_specific_language) to write WebAssembly based smart contracts using the Rust programming language targeting Substrate blockchains. ink! is an [eDSL](https://wiki.haskell.org/Embedded_domain_specific_language) to write WebAssembly based smart contracts using the Rust programming language targeting Substrate blockchains.
For more information please visit [the ink! tutorial](https://substrate.dev/substrate-contracts-workshop/#/0/building-your-contract). For a guided workshop targeting beginners please visit [the ink! tutorial](https://substrate.dev/substrate-contracts-workshop/#/0/building-your-contract).
## Developer Documentation ## Developer Documentation
......
...@@ -20,7 +20,7 @@ yourself in the foot by accidentally forgetting to initialize some important dat ...@@ -20,7 +20,7 @@ yourself in the foot by accidentally forgetting to initialize some important dat
**Old ink! 2.0:** **Old ink! 2.0:**
```rust ```rust
#[ink(storage)] #[ink(constructor)]
fn new_erc20(&mut self, initial_supply: Balance) { fn new_erc20(&mut self, initial_supply: Balance) {
let caller = self.env().caller(); let caller = self.env().caller();
self.total_supply.set(initial_supply); self.total_supply.set(initial_supply);
...@@ -29,7 +29,7 @@ fn new_erc20(&mut self, initial_supply: Balance) { ...@@ -29,7 +29,7 @@ fn new_erc20(&mut self, initial_supply: Balance) {
``` ```
**New ink! 3.0:** **New ink! 3.0:**
```rust ```rust
#[ink(storage)] #[ink(constructor)]
pub fn new_erc20(initial_supply: Balance) -> Self { pub fn new_erc20(initial_supply: Balance) -> Self {
let caller = self.env().caller(); let caller = self.env().caller();
let mut balances = ink_storage::HashMap::new(); let mut balances = ink_storage::HashMap::new();
...@@ -45,6 +45,14 @@ Also ink! 3.0 no longer requires a mandatory `version` field in the header of th ...@@ -45,6 +45,14 @@ Also ink! 3.0 no longer requires a mandatory `version` field in the header of th
Syntactically this is all it takes to port your current ink! smart contracts over to ink! 3.0 syntax. Syntactically this is all it takes to port your current ink! smart contracts over to ink! 3.0 syntax.
## Split of ink_core
The `ink_core` crate no longer exists. It has been split into the new `ink_env` and `ink_storage` crates.
Everything that was previously accessed through `ink_core::env` now lives in `ink_env` and everything
that was previously accessed through `ink_core::storage` now lives in `ink_storage`. Both crates keep
the responsibilities of their former originating `ink_core` modules.
## New Storage Module ## New Storage Module
The storage module has been reworked entirely. The storage module has been reworked entirely.
......
...@@ -7,7 +7,7 @@ edition = "2018" ...@@ -7,7 +7,7 @@ edition = "2018"
license = "Apache-2.0" license = "Apache-2.0"
readme = "README.md" readme = "README.md"
repository = "https://github.com/paritytech/ink" repository = "https://github.com/paritytech/ink"
documentation = "https://substrate.dev/substrate-contracts-workshop/#/" documentation = "https://docs.rs/ink_allocator/"
homepage = "https://www.parity.io/" homepage = "https://www.parity.io/"
description = "[ink!] Bindings to the Wasm heap memory allocator." description = "[ink!] Bindings to the Wasm heap memory allocator."
keywords = ["wasm", "parity", "webassembly", "blockchain", "edsl"] keywords = ["wasm", "parity", "webassembly", "blockchain", "edsl"]
......
...@@ -12,6 +12,11 @@ ...@@ -12,6 +12,11 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
//! Crate providing `WEE_ALLOC` support for all Wasm compilations of ink! smart contract.
//!
//! The Wee allocator is an allocator specifically designed to have a low footprint albeith
//! being less efficient for allocation and deallocation operations.
#![cfg_attr(not(feature = "std"), no_std)] #![cfg_attr(not(feature = "std"), no_std)]
#![cfg_attr(not(feature = "std"), feature(alloc_error_handler, core_intrinsics))] #![cfg_attr(not(feature = "std"), feature(alloc_error_handler, core_intrinsics))]
......
...@@ -7,7 +7,7 @@ edition = "2018" ...@@ -7,7 +7,7 @@ edition = "2018"
license = "Apache-2.0" license = "Apache-2.0"
readme = "README.md" readme = "README.md"
repository = "https://github.com/paritytech/ink" repository = "https://github.com/paritytech/ink"
documentation = "https://substrate.dev/substrate-contracts-workshop/#/" documentation = "https://docs.rs/ink_env/"
homepage = "https://www.parity.io/" homepage = "https://www.parity.io/"
description = "[ink!] Low-level interface for interacting with the smart contract Wasm executor." description = "[ink!] Low-level interface for interacting with the smart contract Wasm executor."
keywords = ["wasm", "parity", "webassembly", "blockchain", "edsl"] keywords = ["wasm", "parity", "webassembly", "blockchain", "edsl"]
......
...@@ -7,7 +7,7 @@ edition = "2018" ...@@ -7,7 +7,7 @@ edition = "2018"
license = "Apache-2.0" license = "Apache-2.0"
readme = "README.md" readme = "README.md"
repository = "https://github.com/paritytech/ink" repository = "https://github.com/paritytech/ink"
documentation = "https://substrate.dev/substrate-contracts-workshop/#/" documentation = "https://docs.rs/ink_lang/"
homepage = "https://www.parity.io/" homepage = "https://www.parity.io/"
description = "[ink!] Rust based eDSL for writing smart contracts for Substrate" description = "[ink!] Rust based eDSL for writing smart contracts for Substrate"
keywords = ["wasm", "parity", "webassembly", "blockchain", "edsl"] keywords = ["wasm", "parity", "webassembly", "blockchain", "edsl"]
......
...@@ -7,7 +7,7 @@ edition = "2018" ...@@ -7,7 +7,7 @@ edition = "2018"
license = "Apache-2.0" license = "Apache-2.0"
readme = "README.md" readme = "README.md"
repository = "https://github.com/paritytech/ink" repository = "https://github.com/paritytech/ink"
documentation = "https://substrate.dev/substrate-contracts-workshop/#/" documentation = "https://docs.rs/ink_lang_codegen/"
homepage = "https://www.parity.io/" homepage = "https://www.parity.io/"
description = "data structures and algorithms for generating ink! IR code" description = "data structures and algorithms for generating ink! IR code"
keywords = ["wasm", "parity", "webassembly", "blockchain", "edsl"] keywords = ["wasm", "parity", "webassembly", "blockchain", "edsl"]
......
...@@ -7,7 +7,7 @@ edition = "2018" ...@@ -7,7 +7,7 @@ edition = "2018"
license = "Apache-2.0" license = "Apache-2.0"
readme = "README.md" readme = "README.md"
repository = "https://github.com/paritytech/ink" repository = "https://github.com/paritytech/ink"
documentation = "https://substrate.dev/substrate-contracts-workshop/#/" documentation = "https://docs.rs/ink_lang_ir/"
homepage = "https://www.parity.io/" homepage = "https://www.parity.io/"
description = "data structures and algorithms for ink! intermediate representation" description = "data structures and algorithms for ink! intermediate representation"
keywords = ["wasm", "parity", "webassembly", "blockchain", "edsl"] keywords = ["wasm", "parity", "webassembly", "blockchain", "edsl"]
......
...@@ -7,7 +7,7 @@ edition = "2018" ...@@ -7,7 +7,7 @@ edition = "2018"
license = "Apache-2.0" license = "Apache-2.0"
readme = "README.md" readme = "README.md"
repository = "https://github.com/paritytech/ink" repository = "https://github.com/paritytech/ink"
documentation = "https://substrate.dev/substrate-contracts-workshop/#/" documentation = "https://docs.rs/ink_lang_macro/"
homepage = "https://www.parity.io/" homepage = "https://www.parity.io/"
description = "[ink!] Rust based eDSL for writing smart contracts for Substrate" description = "[ink!] Rust based eDSL for writing smart contracts for Substrate"
keywords = ["wasm", "parity", "webassembly", "blockchain", "edsl"] keywords = ["wasm", "parity", "webassembly", "blockchain", "edsl"]
......
...@@ -7,7 +7,7 @@ edition = "2018" ...@@ -7,7 +7,7 @@ edition = "2018"
license = "Apache-2.0" license = "Apache-2.0"
readme = "README.md" readme = "README.md"
repository = "https://github.com/paritytech/ink" repository = "https://github.com/paritytech/ink"
documentation = "https://substrate.dev/substrate-contracts-workshop/#/" documentation = "https://docs.rs/ink_metadata/"
homepage = "https://www.parity.io/" homepage = "https://www.parity.io/"
description = "[ink!] Metadata definitions for ink! smart contracts." description = "[ink!] Metadata definitions for ink! smart contracts."
keywords = ["wasm", "parity", "webassembly", "blockchain", "edsl"] keywords = ["wasm", "parity", "webassembly", "blockchain", "edsl"]
......
...@@ -120,7 +120,7 @@ impl LayoutKey { ...@@ -120,7 +120,7 @@ impl LayoutKey {
} }
} }
/// An encoded cell. /// A SCALE encoded cell.
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, From, Serialize, Deserialize)] #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, From, Serialize, Deserialize)]
#[serde(bound( #[serde(bound(
serialize = "F::Type: Serialize, F::String: Serialize", serialize = "F::Type: Serialize, F::String: Serialize",
......
...@@ -6,15 +6,12 @@ edition = "2018" ...@@ -6,15 +6,12 @@ edition = "2018"
license = "Apache-2.0" license = "Apache-2.0"
readme = "README.md" readme = "README.md"
repository = "https://github.com/paritytech/ink" repository = "https://github.com/paritytech/ink"
documentation = "https://substrate.dev/substrate-contracts-workshop/#/" documentation = "https://docs.rs/ink_prelude/"
homepage = "https://www.parity.io/" homepage = "https://www.parity.io/"
description = "[ink!] Common API for no_std and std to access alloc crate types." description = "[ink!] Common API for no_std and std to access alloc crate types."
keywords = ["wasm", "parity", "webassembly", "blockchain", "edsl"] keywords = ["wasm", "parity", "webassembly", "blockchain", "edsl"]
categories = ["no-std", "embedded"] categories = ["no-std", "embedded"]
include = ["/Cargo.toml", "src/**/*.rs", "/README.md", "/LICENSE"] include = ["/Cargo.toml", "src/**/*.rs", "/README.md", "/LICENSE"]
[dependencies] [dependencies]
......
...@@ -6,15 +6,12 @@ edition = "2018" ...@@ -6,15 +6,12 @@ edition = "2018"
license = "Apache-2.0" license = "Apache-2.0"
readme = "README.md" readme = "README.md"
repository = "https://github.com/paritytech/ink" repository = "https://github.com/paritytech/ink"
documentation = "https://substrate.dev/substrate-contracts-workshop/#/" documentation = "https://docs.rs/ink_primitives/"
homepage = "https://www.parity.io/" homepage = "https://www.parity.io/"
description = "[ink!] Fundamental primitive types for ink! smart contracts." description = "[ink!] Fundamental primitive types for ink! smart contracts."
keywords = ["wasm", "parity", "webassembly", "blockchain", "edsl"] keywords = ["wasm", "parity", "webassembly", "blockchain", "edsl"]
categories = ["no-std", "embedded"] categories = ["no-std", "embedded"]
include = ["/Cargo.toml", "src/**/*.rs", "/README.md", "/LICENSE"] include = ["/Cargo.toml", "src/**/*.rs", "/README.md", "/LICENSE"]
[dependencies] [dependencies]
......
...@@ -7,7 +7,7 @@ edition = "2018" ...@@ -7,7 +7,7 @@ edition = "2018"
license = "Apache-2.0" license = "Apache-2.0"
readme = "README.md" readme = "README.md"
repository = "https://github.com/paritytech/ink" repository = "https://github.com/paritytech/ink"
documentation = "https://substrate.dev/substrate-contracts-workshop/#/" documentation = "https://docs.rs/ink_storage/"
homepage = "https://www.parity.io/" homepage = "https://www.parity.io/"
description = "[ink!] Data structures to organize and manipulate ink! contract storage." description = "[ink!] Data structures to organize and manipulate ink! contract storage."
keywords = ["wasm", "parity", "webassembly", "blockchain", "edsl"] keywords = ["wasm", "parity", "webassembly", "blockchain", "edsl"]
......
...@@ -64,7 +64,7 @@ fn bench_set_populated_cache(c: &mut Criterion) { ...@@ -64,7 +64,7 @@ fn bench_set_populated_cache(c: &mut Criterion) {
fn push_storage_lazy(value: i32) -> Lazy<i32> { fn push_storage_lazy(value: i32) -> Lazy<i32> {
let root_key = Key::from([0x00; 32]); let root_key = Key::from([0x00; 32]);
SpreadLayout::push_spread(&Lazy::new(value), &mut KeyPtr::from(root_key)); SpreadLayout::push_spread(&Lazy::new(value), &mut KeyPtr::from(root_key));
<Lazy<i32>>::lazy(root_key) SpreadLayout::pull_spread(&mut KeyPtr::from(root_key))
} }
mod empty_cache { mod empty_cache {
......
...@@ -46,6 +46,30 @@ const _: () = { ...@@ -46,6 +46,30 @@ const _: () = {
))) )))
} }
} }
impl<T> scale_info::TypeInfo for StorageBox<T>
where
T: SpreadLayout,
{
fn type_info() -> scale_info::Type {
scale_info::Type::builder()
.path(
scale_info::Path::from_segments(vec!["ink_storage", "alloc", "Box"])
.expect("encountered invalid Rust path"),
)
// Unfortunately we cannot encode the type parameters of the box since they
// have to be `T: scale::Codec`. However, them not requiring to be encodable
// is the purpose of the storage `Box<T>`.
// Until we found a solution to this problem we cannot uncomment the below
// line of code:
//
// .type_params(vec![scale_info::MetaType::new::<T>()])
.composite(
scale_info::build::Fields::named()
.field_of::<DynamicAllocation>("allocation"),
)
}
}
}; };
impl<T> SpreadLayout for StorageBox<T> impl<T> SpreadLayout for StorageBox<T>
......
...@@ -39,6 +39,7 @@ use self::{ ...@@ -39,6 +39,7 @@ use self::{
StorageEntry, StorageEntry,
}, },
}; };
#[doc(inline)]
pub use self::{ pub use self::{
lazy_array::{ lazy_array::{
LazyArray, LazyArray,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment