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

Release 3.3.0 with backwards compatibility fixes #1284

Merged
merged 27 commits into from
Jun 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
80d302e
Fix links in release notes (#1277)
cmichi May 25, 2022
0a96173
Revert "Optimise deny_payment. Use eerywhere semantic of deny. (#1267)"
agryaznov Jun 5, 2022
cd26767
Revert backward-incompatible piece of #1224: dependency on `[seal1] s…
agryaznov Jun 6, 2022
061c94e
Revert backward-incompatible piece of #1233: removal of eth_compatibi…
agryaznov Jun 6, 2022
b17e8af
bump crate versions + update RELEASES.md
agryaznov Jun 6, 2022
5ae4bc1
Mapping::insert_return_size is back, having now both `seal1` and `sea…
agryaznov Jun 6, 2022
5633392
set_storage_silent -> set_storage_compat renaming
agryaznov Jun 6, 2022
4be7403
spell fix
agryaznov Jun 10, 2022
ee532c8
Apply suggestions from code review
agryaznov Jun 15, 2022
b0daa41
Apply suggestions from code review
agryaznov Jun 15, 2022
fa6d2c8
Update crates/env/src/backend.rs
agryaznov Jun 15, 2022
e0f2259
doc comments enhanced
agryaznov Jun 15, 2022
3fb9c76
`Mapping::insert()` to use backwards compatible seal fn
agryaznov Jun 15, 2022
06bedc4
unreleased changes planned for 4.x removed from 3.x
agryaznov Jun 15, 2022
f5f6bc9
Add more details to the release notes
HCastano Jun 15, 2022
609236a
fix catched issue with changed api function signature
agryaznov Jun 16, 2022
5a03407
fix storage trait dependent func
agryaznov Jun 16, 2022
dbee0ab
Apply new versions naming policy: step1. Old versions to keep their n…
agryaznov Jun 16, 2022
7e14d0b
Apply new versions naming policy: step2. Add `deprecated` attr and `#…
agryaznov Jun 16, 2022
b1a7393
Apply suggestions from code review
agryaznov Jun 17, 2022
9171c38
fixes after next review round
agryaznov Jun 17, 2022
89b94fc
Merge branch 'v3.x.x' into ag-3.3.0-hotfixes
agryaznov Jun 17, 2022
05f7e82
more fixes after the review round
agryaznov Jun 20, 2022
2466027
fmt
agryaznov Jun 20, 2022
180af6c
Merge branch 'v3.x.x' into ag-3.3.0-hotfixes
agryaznov Jun 20, 2022
ddebf6c
spellcheck config fix
agryaznov Jun 20, 2022
28ee702
Small wording fixes
HCastano Jun 21, 2022
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
2 changes: 0 additions & 2 deletions .config/cargo_spellcheck.dic
Original file line number Diff line number Diff line change
Expand Up @@ -104,5 +104,3 @@ natively
payability
unpayable
initializer

^#[0-9a-fA-F]{5,}$
1 change: 1 addition & 0 deletions .config/cargo_spellcheck.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ use_builtin = true
[Hunspell.quirks]
allow_concatenation = true
allow_dashes = true
transform_regex = ["^[0-9a-fA-F]{5,}$"]
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ members = [
"crates/primitives",
"crates/engine",
"crates/env",
"crates/eth_compatibility",
"crates/storage",
"crates/storage/derive",
]
Expand Down
38 changes: 36 additions & 2 deletions RELEASES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,39 @@
# [Unreleased]

# Version 3.3.0

This release restores SemVer compatibility in the `v3.x` series of releases, as well as
compatibility with the [`v0.13.0`](https://github.com/paritytech/substrate-contracts-node/releases/tag/v0.13.0)
release of the `substrate-contracts-node`.

## Compatibility
This version will work fine with *substrate-contracts-node* versions from
[0.13.0](https://github.com/paritytech/substrate-contracts-node/releases/tag/v0.13.0) up
to [0.16.0](https://github.com/paritytech/substrate-contracts-node/releases/tag/v0.16.0).

## Changed
*Context: user-reported issues on our SE unveiled backward incompatibility introduced in 3.1.0 release.*
1. [CodeRejected when using ink! v3.1.0](https://substrate.stackexchange.com/questions/2721/cargo-contract-3-0-1)
1. [Incompatibility between ink! v3.0.1 and v3.2.0 ](https://substrate.stackexchange.com/questions/2870/cargo-contract-throws-error-about-supplied-arguments-in-inkconstructor-f)

The following has been done to restore backward compatibility:
- Reverted backward-incompatible piece of [#1224](https://github.com/paritytech/ink/pull/1224).
- The return signature of `ink_env::set_contract_storage()` was changed to return an
`Option<u32>`. This could have broken existing code, so this should've been done in
a `MAJOR` release.
- Under the hood the PR also changed `Mapping::insert()` to use a new SEAL API
(`[seal1] seal_set_storage`), which resulted in `CodeRejected` errors in nodes which
did not have this API (e.g `substrate-contracts-node@0.13.0`).
- Reverted "Optimise deny_payment. Use everywhere semantic of deny ([#1267](https://github.com/paritytech/ink/pull/1267))"
- This one is to restore compatibility between minor versions of ink! crates; see
@HCastano's SE [answer](https://substrate.stackexchange.com/a/3000/472) in this
regard.
- Reverted backward-incompatible piece of [#1233](https://github.com/paritytech/ink/pull/1233).
- The removal of the `eth_compatibility` crate should have been done in a `MAJOR`
release.

All these breaking changes are subjects to the upcoming MAJOR *ink!* release 4.0.0.

# Version 3.2.0

## Compatibility
Expand All @@ -11,13 +45,13 @@ This is the case in the latest release of the [`substrate-contracts-node`](https
[v0.16.0](https://github.com/paritytech/substrate-contracts-node/releases/tag/v0.16.0).

## Added
- Contract size optimization in case contract doesn't accept payment ‒ [#1267](https://github.com/paritytech/ink/pull/1270) [#1273](https://github.com/paritytech/ink/pull/1267) (thanks [@xgreenx](https://github.com/xgreenx)).
- Contract size optimization in case contract doesn't accept payment ‒ [#1267](https://github.com/paritytech/ink/pull/1267) (thanks [@xgreenx](https://github.com/xgreenx)).

## Changed
- Two functions have been stabilized: [`ink_env::ecdsa_recover`](https://paritytech.github.io/ink/ink_env/fn.ecdsa_recover.html) and [`ink_env::ecdsa_to_eth_address`](https://paritytech.github.io/ink/ink_env/fn.ecdsa_to_eth_address.html) ‒ [#1270](https://github.com/paritytech/ink/pull/1270) [#1273](https://github.com/paritytech/ink/pull/1273)

## Fixed
- Fixed bug with recent Rust and `cargo test` ‒ [#1272](https://github.com/paritytech/ink/pull/1270) [#1273](https://github.com/paritytech/ink/pull/1272) (thanks [@xgreenx](https://github.com/xgreenx)).
- Fixed bug with recent Rust and `cargo test` ‒ [#1272](https://github.com/paritytech/ink/pull/1272) (thanks [@xgreenx](https://github.com/xgreenx)).

# Version 3.1.0

Expand Down
2 changes: 1 addition & 1 deletion crates/allocator/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ink_allocator"
version = "3.2.0"
version = "3.3.0"
authors = ["Parity Technologies <admin@parity.io>", "Robin Freyler <robin@parity.io>"]
edition = "2021"

Expand Down
2 changes: 1 addition & 1 deletion crates/engine/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ink_engine"
version = "3.2.0"
version = "3.3.0"
authors = ["Parity Technologies <admin@parity.io>", "Michael Müller <michi@parity.io>"]
edition = "2021"

Expand Down
28 changes: 27 additions & 1 deletion crates/engine/src/ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,35 @@ impl Engine {
});
}

/// Writes the encoded value into the storage at the given key.
pub fn set_storage(&mut self, key: &[u8; 32], encoded_value: &[u8]) {
let callee = self.get_callee();
let account_id = AccountId::from_bytes(&callee[..]);

self.debug_info.inc_writes(account_id.clone());
self.debug_info
.record_cell_for_account(account_id, key.to_vec());

// We ignore if storage is already set for this key
let _ = self.database.insert_into_contract_storage(
&callee,
key,
encoded_value.to_vec(),
);
}

/// Writes the encoded value into the storage at the given key.
/// Returns the size of the previously stored value at the key if any.
pub fn set_storage(&mut self, key: &[u8; 32], encoded_value: &[u8]) -> Option<u32> {
///
/// # Note
///
/// This is an equivalent to the [`set_storage`][`Self::set_storage`] method,
/// but gives the information on the pre-existing value size.
pub fn set_storage_return_size(
&mut self,
key: &[u8; 32],
encoded_value: &[u8],
) -> Option<u32> {
let callee = self.get_callee();
let account_id = AccountId::from_bytes(&callee[..]);

Expand Down
12 changes: 6 additions & 6 deletions crates/env/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ink_env"
version = "3.2.0"
version = "3.3.0"
authors = ["Parity Technologies <admin@parity.io>", "Robin Freyler <robin@parity.io>"]
edition = "2021"

Expand All @@ -15,10 +15,10 @@ categories = ["no-std", "embedded"]
include = ["Cargo.toml", "src/**/*.rs", "README.md", "LICENSE"]

[dependencies]
ink_metadata = { version = "3.2.0", path = "../metadata/", default-features = false, features = ["derive"], optional = true }
ink_allocator = { version = "3.2.0", path = "../allocator/", default-features = false }
ink_primitives = { version = "3.2.0", path = "../primitives/", default-features = false }
ink_prelude = { version = "3.2.0", path = "../prelude/", default-features = false }
ink_metadata = { version = "3.3.0", path = "../metadata/", default-features = false, features = ["derive"], optional = true }
ink_allocator = { version = "3.3.0", path = "../allocator/", default-features = false }
ink_primitives = { version = "3.3.0", path = "../primitives/", default-features = false }
ink_prelude = { version = "3.3.0", path = "../prelude/", default-features = false }

scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive", "full"] }
derive_more = { version = "0.99", default-features = false, features = ["from", "display"] }
Expand All @@ -32,7 +32,7 @@ static_assertions = "1.1"
rlibc = "1"

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
ink_engine = { version = "3.2.0", path = "../engine/", optional = true }
ink_engine = { version = "3.3.0", path = "../engine/", optional = true }

# Hashes for the off-chain environment.
sha2 = { version = "0.10", optional = true }
Expand Down
35 changes: 32 additions & 3 deletions crates/env/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,18 +183,47 @@ where
})
}

/// Writes the value to the contract storage under the given key and returns
/// the size of pre-existing value at the specified key if any.
/// Writes the value to the contract storage under the given key.
///
/// # Panics
///
/// - If the encode length of value exceeds the configured maximum value length of a storage entry.
pub fn set_contract_storage<V>(key: &Key, value: &V) -> Option<u32>
#[deprecated(
since = "3.3.0",
note = "`set_contract_storage_return_size()` provides more information, and will be made the standard in the future."
)]
pub fn set_contract_storage<V>(key: &Key, value: &V)
where
V: scale::Encode,
{
<EnvInstance as OnInstance>::on_instance(|instance| {
EnvBackend::set_contract_storage::<V>(instance, key, value)
});
}

/// Writes the value to the contract storage under the given key and returns
/// the size of the pre-existing value at the specified key if any.
///
/// # Compatibility
///
/// This function requires minimum `substrate-contracts-node` version [`v0.15.1`](https://github.com/paritytech/substrate-contracts-node/releases/tag/v0.15.1),
/// or any node built with Substrate version later than
/// [#7d233c2](https://github.com/paritytech/substrate/tree/7d233c2446b5a60662400a0a4bcfb78bb3b79ff7).
///
/// # Panics
///
/// - If the encode length of value exceeds the configured maximum value length of a storage entry.
///
/// # Note
///
/// This is equivalent to the [`set_contract_storage`] method,
/// but gives the information on the pre-existing value size.
pub fn set_contract_storage_return_size<V>(key: &Key, value: &V) -> Option<u32>
where
V: scale::Encode,
{
<EnvInstance as OnInstance>::on_instance(|instance| {
EnvBackend::set_contract_storage_return_size::<V>(instance, key, value)
})
}

Expand Down
16 changes: 15 additions & 1 deletion crates/env/src/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,23 @@ impl CallFlags {

/// Environmental contract functionality that does not require `Environment`.
pub trait EnvBackend {
/// Writes the value to the contract storage under the given key.
fn set_contract_storage<V>(&mut self, key: &Key, value: &V)
where
V: scale::Encode;

/// Writes the value to the contract storage under the given key and returns
/// the size of the pre-existing value at the specified key if any.
fn set_contract_storage<V>(&mut self, key: &Key, value: &V) -> Option<u32>
///
/// # Note
///
/// This is an equivalent to the [`set_contract_storage`][`Self::set_contract_storage`] method,
/// but gives the information on the pre-existing value size.
fn set_contract_storage_return_size<V>(
&mut self,
key: &Key,
value: &V,
) -> Option<u32>
where
V: scale::Encode;

Expand Down
12 changes: 10 additions & 2 deletions crates/env/src/engine/off_chain/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,12 +184,20 @@ impl EnvInstance {
}

impl EnvBackend for EnvInstance {
fn set_contract_storage<V>(&mut self, key: &Key, value: &V) -> Option<u32>
fn set_contract_storage<V>(&mut self, key: &Key, value: &V)
where
V: scale::Encode,
{
let v = scale::Encode::encode(value);
self.engine.set_storage(key.as_ref(), &v[..])
self.engine.set_storage(key.as_ref(), &v[..]);
}

fn set_contract_storage_return_size<V>(&mut self, key: &Key, value: &V) -> Option<u32>
where
V: scale::Encode,
{
let v = scale::Encode::encode(value);
self.engine.set_storage_return_size(key.as_ref(), &v[..])
}

fn get_contract_storage<R>(&mut self, key: &Key) -> Result<Option<R>>
Expand Down
23 changes: 20 additions & 3 deletions crates/env/src/engine/on_chain/ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,12 @@ mod sys {
data_len: u32,
);

pub fn seal_set_storage(
key_ptr: Ptr32<[u8]>,
value_ptr: Ptr32<[u8]>,
value_len: u32,
);

pub fn seal_get_storage(
key_ptr: Ptr32<[u8]>,
output_ptr: Ptr32Mut<[u8]>,
Expand Down Expand Up @@ -375,7 +381,8 @@ mod sys {
output_len_ptr: Ptr32Mut<u32>,
) -> ReturnCode;

pub fn seal_set_storage(
#[link_name = "seal_set_storage"]
HCastano marked this conversation as resolved.
Show resolved Hide resolved
pub fn seal_set_storage_return_size(
key_ptr: Ptr32<[u8]>,
value_ptr: Ptr32<[u8]>,
value_len: u32,
Expand Down Expand Up @@ -495,13 +502,23 @@ pub fn deposit_event(topics: &[u8], data: &[u8]) {
}
}

pub fn set_storage(key: &[u8], encoded_value: &[u8]) -> Option<u32> {
let ret_code = unsafe {
pub fn set_storage(key: &[u8], encoded_value: &[u8]) {
unsafe {
sys::seal_set_storage(
Ptr32::from_slice(key),
Ptr32::from_slice(encoded_value),
encoded_value.len() as u32,
)
}
}

pub fn set_storage_return_size(key: &[u8], encoded_value: &[u8]) -> Option<u32> {
let ret_code = unsafe {
sys::seal_set_storage_return_size(
Ptr32::from_slice(key),
Ptr32::from_slice(encoded_value),
encoded_value.len() as u32,
)
};
ret_code.into()
}
Expand Down
12 changes: 10 additions & 2 deletions crates/env/src/engine/on_chain/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,12 +219,20 @@ impl EnvInstance {
}

impl EnvBackend for EnvInstance {
fn set_contract_storage<V>(&mut self, key: &Key, value: &V) -> Option<u32>
fn set_contract_storage<V>(&mut self, key: &Key, value: &V)
where
V: scale::Encode,
{
let buffer = self.scoped_buffer().take_encoded(value);
ext::set_storage(key.as_ref(), buffer)
ext::set_storage(key.as_ref(), buffer);
}

fn set_contract_storage_return_size<V>(&mut self, key: &Key, value: &V) -> Option<u32>
where
V: scale::Encode,
{
let buffer = self.scoped_buffer().take_encoded(value);
ext::set_storage_return_size(key.as_ref(), buffer)
}

fn get_contract_storage<R>(&mut self, key: &Key) -> Result<Option<R>>
Expand Down
30 changes: 30 additions & 0 deletions crates/eth_compatibility/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
[package]
name = "ink_eth_compatibility"
version = "3.0.1"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2021"

license = "Apache-2.0"
readme = "README.md"
repository = "https://github.com/paritytech/ink"
documentation = "https://docs.rs/ink_eth_compatibility/"
homepage = "https://www.parity.io/"
description = "[ink!] Ethereum related stuff."
keywords = ["wasm", "parity", "webassembly", "blockchain", "ethereum"]
categories = ["no-std", "embedded"]
include = ["Cargo.toml", "src/**/*.rs", "/README.md", "/LICENSE"]

[dependencies]
ink_env = { version = "3.0.1", path = "../env", default-features = false }

[target.'cfg(not(target_os = "windows"))'.dependencies]
# We do not include `libsecp256k1` on Windows, since it's incompatible.
# We have https://github.com/paritytech/ink/issues/1068 for removing
# this dependency altogether.
libsecp256k1 = { version = "0.7.0", default-features = false }

[features]
default = ["std"]
std = [
"ink_env/std",
]
1 change: 1 addition & 0 deletions crates/eth_compatibility/LICENSE
1 change: 1 addition & 0 deletions crates/eth_compatibility/README.md
Loading