From 80d302eb9b9cddb726200a9a86c71ae344d1b042 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20M=C3=BCller?= Date: Wed, 25 May 2022 11:07:00 +0200 Subject: [PATCH 01/25] Fix links in release notes (#1277) --- RELEASES.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/RELEASES.md b/RELEASES.md index f3ff4064c1..cab41baf49 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -11,13 +11,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 From 0a96173f22129e4022dac9e1d294eb17a5bc1df4 Mon Sep 17 00:00:00 2001 From: Alexander Gryaznov Date: Sun, 5 Jun 2022 16:39:46 +0100 Subject: [PATCH 02/25] Revert "Optimise deny_payment. Use eerywhere semantic of deny. (#1267)" This reverts commit 1bfccc77cd16503c574f224279f01721d38592b3. --- crates/lang/codegen/src/generator/dispatch.rs | 19 +++++++------------ crates/lang/src/codegen/dispatch/execution.rs | 15 ++++++++++++++- crates/lang/src/codegen/dispatch/mod.rs | 1 + crates/lang/src/codegen/mod.rs | 1 + 4 files changed, 23 insertions(+), 13 deletions(-) diff --git a/crates/lang/codegen/src/generator/dispatch.rs b/crates/lang/codegen/src/generator/dispatch.rs index c9b05580c4..fee922033e 100644 --- a/crates/lang/codegen/src/generator/dispatch.rs +++ b/crates/lang/codegen/src/generator/dispatch.rs @@ -532,8 +532,6 @@ impl Dispatch<'_> { } } }; - let any_constructor_accept_payment = - self.any_constructor_accepts_payment_expr(constructor_spans); let constructor_execute = (0..count_constructors).map(|index| { let constructor_span = constructor_spans[index]; @@ -545,8 +543,9 @@ impl Dispatch<'_> { }>>::IDS[#index] }>>::CALLABLE ); - let deny_payment = quote_spanned!(constructor_span=> - !<#storage_ident as ::ink_lang::reflect::DispatchableConstructorInfo<{ + let accepts_payment = quote_spanned!(constructor_span=> + false || + <#storage_ident as ::ink_lang::reflect::DispatchableConstructorInfo<{ <#storage_ident as ::ink_lang::reflect::ContractDispatchableConstructors<{ <#storage_ident as ::ink_lang::reflect::ContractAmountDispatchables>::CONSTRUCTORS }>>::IDS[#index] @@ -555,12 +554,10 @@ impl Dispatch<'_> { quote_spanned!(constructor_span=> Self::#constructor_ident(input) => { - if #any_constructor_accept_payment && #deny_payment { - ::ink_lang::codegen::deny_payment::< - <#storage_ident as ::ink_lang::reflect::ContractEnv>::Env>()?; - } - ::ink_lang::codegen::execute_constructor::<#storage_ident, _, _>( + ::ink_lang::codegen::ExecuteConstructorConfig { + payable: #accepts_payment, + }, move || { #constructor_callable(input) } ) } @@ -695,8 +692,6 @@ impl Dispatch<'_> { } } }; - let any_message_accept_payment = - self.any_message_accepts_payment_expr(message_spans); let message_execute = (0..count_messages).map(|index| { let message_span = message_spans[index]; @@ -734,7 +729,7 @@ impl Dispatch<'_> { Self::#message_ident(input) => { use ::core::default::Default; - if #any_message_accept_payment && #deny_payment { + if #deny_payment { ::ink_lang::codegen::deny_payment::< <#storage_ident as ::ink_lang::reflect::ContractEnv>::Env>()?; } diff --git a/crates/lang/src/codegen/dispatch/execution.rs b/crates/lang/src/codegen/dispatch/execution.rs index 749b1d841d..41cfe88c1a 100644 --- a/crates/lang/src/codegen/dispatch/execution.rs +++ b/crates/lang/src/codegen/dispatch/execution.rs @@ -64,6 +64,13 @@ where Ok(()) } +/// Configuration for execution of ink! constructor. +#[derive(Debug, Copy, Clone)] +pub struct ExecuteConstructorConfig { + /// Yields `true` if the ink! constructor accepts payment. + pub payable: bool, +} + /// Executes the given ink! constructor. /// /// # Note @@ -71,13 +78,19 @@ where /// The closure is supposed to already contain all the arguments that the real /// constructor message requires and forwards them. #[inline] -pub fn execute_constructor(f: F) -> Result<(), DispatchError> +pub fn execute_constructor( + config: ExecuteConstructorConfig, + f: F, +) -> Result<(), DispatchError> where Contract: SpreadLayout + ContractRootKey + ContractEnv, F: FnOnce() -> R, as ConstructorReturnType>::ReturnValue: scale::Encode, private::Seal: ConstructorReturnType, { + if !config.payable { + deny_payment::<::Env>()?; + } let result = ManuallyDrop::new(private::Seal(f())); match result.as_result() { Ok(contract) => { diff --git a/crates/lang/src/codegen/dispatch/mod.rs b/crates/lang/src/codegen/dispatch/mod.rs index 3908e094fb..93429dddfe 100644 --- a/crates/lang/src/codegen/dispatch/mod.rs +++ b/crates/lang/src/codegen/dispatch/mod.rs @@ -22,6 +22,7 @@ pub use self::{ execute_constructor, initialize_contract, ContractRootKey, + ExecuteConstructorConfig, }, info::ContractCallBuilder, type_check::{ diff --git a/crates/lang/src/codegen/mod.rs b/crates/lang/src/codegen/mod.rs index e22b007902..b11c5ca71c 100644 --- a/crates/lang/src/codegen/mod.rs +++ b/crates/lang/src/codegen/mod.rs @@ -30,6 +30,7 @@ pub use self::{ ContractRootKey, DispatchInput, DispatchOutput, + ExecuteConstructorConfig, }, env::{ Env, From cd267675e27fa329e510feb0e8d42602a259e704 Mon Sep 17 00:00:00 2001 From: Alexander Gryaznov Date: Mon, 6 Jun 2022 11:38:14 +0100 Subject: [PATCH 03/25] Revert backward-incompatible piece of #1224: dependency on `[seal1] seal_set_storage` --- crates/engine/src/ext.rs | 12 +++++++----- crates/env/src/api.rs | 5 ++--- crates/env/src/backend.rs | 5 ++--- crates/env/src/engine/off_chain/impls.rs | 4 ++-- crates/env/src/engine/on_chain/ext.rs | 19 +++++++++---------- crates/env/src/engine/on_chain/impls.rs | 8 ++------ crates/storage/src/lazy/mapping.rs | 12 ------------ crates/storage/src/traits/impls/mod.rs | 2 +- crates/storage/src/traits/mod.rs | 4 ++-- 9 files changed, 27 insertions(+), 44 deletions(-) diff --git a/crates/engine/src/ext.rs b/crates/engine/src/ext.rs index d784d12094..2d77f34561 100644 --- a/crates/engine/src/ext.rs +++ b/crates/engine/src/ext.rs @@ -228,8 +228,7 @@ impl Engine { } /// 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 { + pub fn set_storage(&mut self, key: &[u8; 32], encoded_value: &[u8]) { let callee = self.get_callee(); let account_id = AccountId::from_bytes(&callee[..]); @@ -237,9 +236,12 @@ impl Engine { self.debug_info .record_cell_for_account(account_id, key.to_vec()); - self.database - .insert_into_contract_storage(&callee, key, encoded_value.to_vec()) - .map(|v| ::try_from(v.len()).expect("usize to u32 conversion failed")) + // We ignore if storage is already set for this key + let _ = self.database.insert_into_contract_storage( + &callee, + key, + encoded_value.to_vec(), + ); } /// Returns the decoded contract storage at the key if any. diff --git a/crates/env/src/api.rs b/crates/env/src/api.rs index 581d7dabb4..633f0c53b2 100644 --- a/crates/env/src/api.rs +++ b/crates/env/src/api.rs @@ -183,13 +183,12 @@ 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(key: &Key, value: &V) -> Option +pub fn set_contract_storage(key: &Key, value: &V) where V: scale::Encode, { diff --git a/crates/env/src/backend.rs b/crates/env/src/backend.rs index 43ee325233..e43cbbfed4 100644 --- a/crates/env/src/backend.rs +++ b/crates/env/src/backend.rs @@ -162,9 +162,8 @@ impl CallFlags { /// Environmental contract functionality that does not require `Environment`. pub trait EnvBackend { - /// 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(&mut self, key: &Key, value: &V) -> Option + /// Writes the value to the contract storage under the given key. + fn set_contract_storage(&mut self, key: &Key, value: &V) where V: scale::Encode; diff --git a/crates/env/src/engine/off_chain/impls.rs b/crates/env/src/engine/off_chain/impls.rs index 26e1e3b4f1..ee8560e562 100644 --- a/crates/env/src/engine/off_chain/impls.rs +++ b/crates/env/src/engine/off_chain/impls.rs @@ -184,12 +184,12 @@ impl EnvInstance { } impl EnvBackend for EnvInstance { - fn set_contract_storage(&mut self, key: &Key, value: &V) -> Option + fn set_contract_storage(&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 get_contract_storage(&mut self, key: &Key) -> Result> diff --git a/crates/env/src/engine/on_chain/ext.rs b/crates/env/src/engine/on_chain/ext.rs index 0ab029e22c..c668b7e0d3 100644 --- a/crates/env/src/engine/on_chain/ext.rs +++ b/crates/env/src/engine/on_chain/ext.rs @@ -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]>, @@ -374,12 +380,6 @@ mod sys { output_ptr: Ptr32Mut<[u8]>, output_len_ptr: Ptr32Mut, ) -> ReturnCode; - - pub fn seal_set_storage( - key_ptr: Ptr32<[u8]>, - value_ptr: Ptr32<[u8]>, - value_len: u32, - ) -> ReturnCode; } } @@ -495,15 +495,14 @@ pub fn deposit_event(topics: &[u8], data: &[u8]) { } } -pub fn set_storage(key: &[u8], encoded_value: &[u8]) -> Option { - 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, ) - }; - ret_code.into() + } } pub fn clear_storage(key: &[u8]) { diff --git a/crates/env/src/engine/on_chain/impls.rs b/crates/env/src/engine/on_chain/impls.rs index e8a98d71c6..84ea9d679c 100644 --- a/crates/env/src/engine/on_chain/impls.rs +++ b/crates/env/src/engine/on_chain/impls.rs @@ -219,12 +219,12 @@ impl EnvInstance { } impl EnvBackend for EnvInstance { - fn set_contract_storage(&mut self, key: &Key, value: &V) -> Option + fn set_contract_storage(&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 get_contract_storage(&mut self, key: &Key) -> Result> @@ -241,10 +241,6 @@ impl EnvBackend for EnvInstance { Ok(Some(decoded)) } - fn contract_storage_contains(&mut self, key: &Key) -> Option { - ext::storage_contains(key.as_ref()) - } - fn clear_contract_storage(&mut self, key: &Key) { ext::clear_storage(key.as_ref()) } diff --git a/crates/storage/src/lazy/mapping.rs b/crates/storage/src/lazy/mapping.rs index c1d5b78ba6..f9812a9274 100644 --- a/crates/storage/src/lazy/mapping.rs +++ b/crates/storage/src/lazy/mapping.rs @@ -134,18 +134,6 @@ where push_packed_root(value, &self.storage_key(&key)); } - /// Insert the given `value` to the contract storage. - /// - /// Returns the size of the pre-existing value at the specified key if any. - #[inline] - pub fn insert_return_size(&mut self, key: Q, value: &R) -> Option - where - Q: scale::EncodeLike, - R: scale::EncodeLike + PackedLayout, - { - push_packed_root(value, &self.storage_key(&key)) - } - /// Get the `value` at `key` from the contract storage. /// /// Returns `None` if no `value` exists at the given `key`. diff --git a/crates/storage/src/traits/impls/mod.rs b/crates/storage/src/traits/impls/mod.rs index 3467e81660..185953b71a 100644 --- a/crates/storage/src/traits/impls/mod.rs +++ b/crates/storage/src/traits/impls/mod.rs @@ -162,7 +162,7 @@ pub fn forward_push_packed(entity: &T, ptr: &mut KeyPtr) where T: PackedLayout, { - push_packed_root::(entity, ptr.next_for::()); + push_packed_root::(entity, ptr.next_for::()) } /// Clears an instance of type `T` in packed fashion from the contract storage. diff --git a/crates/storage/src/traits/mod.rs b/crates/storage/src/traits/mod.rs index f89c1f580b..456e81e6d6 100644 --- a/crates/storage/src/traits/mod.rs +++ b/crates/storage/src/traits/mod.rs @@ -196,12 +196,12 @@ where /// packed layout. /// - Users should prefer using this function directly instead of using the /// trait methods on [`PackedLayout`]. -pub fn push_packed_root(entity: &T, root_key: &Key) -> Option +pub fn push_packed_root(entity: &T, root_key: &Key) where T: PackedLayout, { ::push_packed(entity, root_key); - ink_env::set_contract_storage(root_key, entity) + ink_env::set_contract_storage(root_key, entity); } /// Clears the entity from the contract storage using packed layout. From 061c94e65946270930938be50543d91dbd5f9108 Mon Sep 17 00:00:00 2001 From: Alexander Gryaznov Date: Mon, 6 Jun 2022 11:53:28 +0100 Subject: [PATCH 04/25] Revert backward-incompatible piece of #1233: removal of eth_compatibility crate --- Cargo.toml | 1 + crates/eth_compatibility/Cargo.toml | 30 ++++++ crates/eth_compatibility/LICENSE | 1 + crates/eth_compatibility/README.md | 1 + crates/eth_compatibility/src/lib.rs | 150 ++++++++++++++++++++++++++++ 5 files changed, 183 insertions(+) create mode 100644 crates/eth_compatibility/Cargo.toml create mode 120000 crates/eth_compatibility/LICENSE create mode 120000 crates/eth_compatibility/README.md create mode 100644 crates/eth_compatibility/src/lib.rs diff --git a/Cargo.toml b/Cargo.toml index 154fbd1a1a..ded10b8e9d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,6 +12,7 @@ members = [ "crates/primitives", "crates/engine", "crates/env", + "crates/eth_compatibility", "crates/storage", "crates/storage/derive", ] diff --git a/crates/eth_compatibility/Cargo.toml b/crates/eth_compatibility/Cargo.toml new file mode 100644 index 0000000000..2c30a464b5 --- /dev/null +++ b/crates/eth_compatibility/Cargo.toml @@ -0,0 +1,30 @@ +[package] +name = "ink_eth_compatibility" +version = "3.0.1" +authors = ["Parity Technologies "] +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", +] diff --git a/crates/eth_compatibility/LICENSE b/crates/eth_compatibility/LICENSE new file mode 120000 index 0000000000..30cff7403d --- /dev/null +++ b/crates/eth_compatibility/LICENSE @@ -0,0 +1 @@ +../../LICENSE \ No newline at end of file diff --git a/crates/eth_compatibility/README.md b/crates/eth_compatibility/README.md new file mode 120000 index 0000000000..fe84005413 --- /dev/null +++ b/crates/eth_compatibility/README.md @@ -0,0 +1 @@ +../../README.md \ No newline at end of file diff --git a/crates/eth_compatibility/src/lib.rs b/crates/eth_compatibility/src/lib.rs new file mode 100644 index 0000000000..f08dba141b --- /dev/null +++ b/crates/eth_compatibility/src/lib.rs @@ -0,0 +1,150 @@ +// Copyright 2018-2022 Parity Technologies (UK) Ltd. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#![no_std] + +use ink_env::{ + DefaultEnvironment, + Environment, +}; + +/// The ECDSA compressed public key. +#[derive(Debug, Copy, Clone)] +pub struct ECDSAPublicKey([u8; 33]); + +impl Default for ECDSAPublicKey { + fn default() -> Self { + // Default is not implemented for [u8; 33], so we can't derive it for ECDSAPublicKey + // But clippy thinks that it is possible. So it is workaround for clippy. + let empty = [0; 33]; + Self(empty) + } +} + +impl AsRef<[u8; 33]> for ECDSAPublicKey { + fn as_ref(&self) -> &[u8; 33] { + &self.0 + } +} + +impl AsMut<[u8; 33]> for ECDSAPublicKey { + fn as_mut(&mut self) -> &mut [u8; 33] { + &mut self.0 + } +} + +impl From<[u8; 33]> for ECDSAPublicKey { + fn from(bytes: [u8; 33]) -> Self { + Self(bytes) + } +} + +/// The address of an Ethereum account. +#[derive(Debug, Default, Copy, Clone)] +pub struct EthereumAddress([u8; 20]); + +impl AsRef<[u8; 20]> for EthereumAddress { + fn as_ref(&self) -> &[u8; 20] { + &self.0 + } +} + +impl AsMut<[u8; 20]> for EthereumAddress { + fn as_mut(&mut self) -> &mut [u8; 20] { + &mut self.0 + } +} + +impl From<[u8; 20]> for EthereumAddress { + fn from(bytes: [u8; 20]) -> Self { + Self(bytes) + } +} + +impl ECDSAPublicKey { + /// Returns Ethereum address from the ECDSA compressed public key. + /// + /// # Example + /// + /// ``` + /// use ink_eth_compatibility::{ECDSAPublicKey, EthereumAddress}; + /// let pub_key: ECDSAPublicKey = [ + /// 2, 121, 190, 102, 126, 249, 220, 187, 172, 85, 160, 98, 149, 206, 135, 11, + /// 7, 2, 155, 252, 219, 45, 206, 40, 217, 89, 242, 129, 91, 22, 248, 23, + /// 152, + /// ].into(); + /// + /// let EXPECTED_ETH_ADDRESS: EthereumAddress = [ + /// 126, 95, 69, 82, 9, 26, 105, 18, 93, 93, 252, 183, 184, 194, 101, 144, 41, 57, 91, 223 + /// ].into(); + /// + /// assert_eq!(pub_key.to_eth_address().as_ref(), EXPECTED_ETH_ADDRESS.as_ref()); + /// ``` + // We do not include this function on Windows, since it depends on `libsecp256k1`, + // which is incompatible with Windows. + // We have https://github.com/paritytech/ink/issues/1068 for removing this + // dependency altogether. + #[cfg(not(target_os = "windows"))] + pub fn to_eth_address(&self) -> EthereumAddress { + use ink_env::hash; + use libsecp256k1::PublicKey; + + // Transform compressed public key into uncompressed. + let pub_key = PublicKey::parse_compressed(&self.0) + .expect("Unable to parse the compressed ECDSA public key"); + let uncompressed = pub_key.serialize(); + + // Hash the uncompressed public key by Keccak256 algorithm. + let mut hash = ::Type::default(); + // The first byte indicates that the public key is uncompressed. + // Let's skip it for hashing the public key directly. + ink_env::hash_bytes::(&uncompressed[1..], &mut hash); + + // Take the last 20 bytes as an Address + let mut result = EthereumAddress::default(); + result.as_mut().copy_from_slice(&hash[12..]); + + result + } + + /// Returns the default Substrate's `AccountId` from the ECDSA compressed public key. + /// It hashes the compressed public key with the `blake2b_256` algorithm like in substrate. + /// + /// # Example + /// + /// ``` + /// use ink_eth_compatibility::ECDSAPublicKey; + /// let pub_key: ECDSAPublicKey = [ + /// 2, 121, 190, 102, 126, 249, 220, 187, 172, 85, 160, 98, 149, 206, 135, 11, + /// 7, 2, 155, 252, 219, 45, 206, 40, 217, 89, 242, 129, 91, 22, 248, 23, + /// 152, + /// ].into(); + /// + /// const EXPECTED_ACCOUNT_ID: [u8; 32] = [ + /// 41, 117, 241, 210, 139, 146, 182, 232, 68, 153, 184, 59, 7, 151, 239, 82, + /// 53, 85, 62, 235, 126, 218, 160, 206, 162, 67, 193, 18, 140, 47, 231, 55, + /// ]; + /// + /// assert_eq!(pub_key.to_default_account_id(), EXPECTED_ACCOUNT_ID.into()); + pub fn to_default_account_id( + &self, + ) -> ::AccountId { + use ink_env::hash; + + let mut output = ::Type::default(); + ink_env::hash_bytes::(&self.0[..], &mut output); + + output.into() + } +} From b17e8af58d4e12f303fd8eeadbc2e9bb395cffea Mon Sep 17 00:00:00 2001 From: Alexander Gryaznov Date: Mon, 6 Jun 2022 12:42:49 +0100 Subject: [PATCH 05/25] bump crate versions + update RELEASES.md --- RELEASES.md | 22 +++++++++++++++++++ crates/allocator/Cargo.toml | 2 +- crates/engine/Cargo.toml | 2 +- crates/env/Cargo.toml | 12 +++++----- crates/lang/Cargo.toml | 18 +++++++-------- crates/lang/codegen/Cargo.toml | 4 ++-- crates/lang/ir/Cargo.toml | 2 +- crates/lang/macro/Cargo.toml | 16 +++++++------- crates/metadata/Cargo.toml | 6 ++--- crates/prelude/Cargo.toml | 2 +- crates/primitives/Cargo.toml | 4 ++-- crates/storage/Cargo.toml | 14 ++++++------ crates/storage/derive/Cargo.toml | 12 +++++----- examples/contract-terminate/Cargo.toml | 2 +- examples/contract-transfer/Cargo.toml | 2 +- examples/delegator/Cargo.toml | 2 +- examples/delegator/accumulator/Cargo.toml | 2 +- examples/delegator/adder/Cargo.toml | 2 +- examples/delegator/subber/Cargo.toml | 2 +- examples/dns/Cargo.toml | 2 +- examples/erc1155/Cargo.toml | 2 +- examples/erc20/Cargo.toml | 2 +- examples/erc721/Cargo.toml | 2 +- examples/flipper/Cargo.toml | 2 +- examples/incrementer/Cargo.toml | 2 +- examples/multisig/Cargo.toml | 2 +- examples/rand-extension/Cargo.toml | 2 +- examples/trait-erc20/Cargo.toml | 2 +- examples/trait-flipper/Cargo.toml | 2 +- examples/trait-incrementer/Cargo.toml | 2 +- examples/trait-incrementer/traits/Cargo.toml | 2 +- .../delegate-calls/Cargo.toml | 2 +- .../upgradeable-flipper/Cargo.toml | 2 +- .../forward-calls/Cargo.toml | 2 +- .../set-code-hash/Cargo.toml | 2 +- .../updated-incrementer/Cargo.toml | 2 +- 36 files changed, 92 insertions(+), 70 deletions(-) diff --git a/RELEASES.md b/RELEASES.md index cab41baf49..127e260e4c 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -1,4 +1,26 @@ # [Unreleased] +- Backward-incompatible piece of [#1233](https://github.com/paritytech/ink/pull/1233): removal of `eth_compatibility crate` +- Backward-incompatible piece of [#1224](https://github.com/paritytech/ink/pull/1224): dependency on `[seal1] seal_set_storage` +- Backward-incompatible "Optimise deny_payment. Use eerywhere semantic of deny. ([#1267](https://github.com/paritytech/ink/pull/1267))" + (see @HCastano SE [answer](https://substrate.stackexchange.com/a/3000/472) in this regard) + +# Version 3.3.0 + +This release is to make *ink!* 3.x.x backward compatible with *substrate-contracts-node* version [0.13.0](https://github.com/paritytech/substrate-contracts-node/releases/tag/v0.13.0) again. + +## Compatibility +This version should 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 ([first](https://substrate.stackexchange.com/questions/2721/cargo-contract-3-0-1) and [second](https://substrate.stackexchange.com/questions/2870/cargo-contract-throws-error-about-supplied-arguments-in-inkconstructor-f)) unveiled backward incompatibility introduced in 3.1.0 release.* + +The following has been done to restore backward compatibility: +- Reverted backward-incompatible piece of [#1233](https://github.com/paritytech/ink/pull/1233): removal of `eth_compatibility crate` +- Reverted backward-incompatible piece of [#1224](https://github.com/paritytech/ink/pull/1224): dependency on `[seal1] seal_set_storage` +- Reverted "Optimise deny_payment. Use eerywhere semantic of deny. ([#1267](https://github.com/paritytech/ink/pull/1267))" + (this one is to restore compatibiliy between minor versions of ink! crates; see @HCastano SE [answer](https://substrate.stackexchange.com/a/3000/472) in this regard) + +All these breaking changes are subjects to the upcoming MAJOR *ink!* release 4.0.0. # Version 3.2.0 diff --git a/crates/allocator/Cargo.toml b/crates/allocator/Cargo.toml index 98f83f6038..9c773f7966 100644 --- a/crates/allocator/Cargo.toml +++ b/crates/allocator/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ink_allocator" -version = "3.2.0" +version = "3.3.0" authors = ["Parity Technologies ", "Robin Freyler "] edition = "2021" diff --git a/crates/engine/Cargo.toml b/crates/engine/Cargo.toml index a688ce568b..a3a808678f 100644 --- a/crates/engine/Cargo.toml +++ b/crates/engine/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ink_engine" -version = "3.2.0" +version = "3.3.0" authors = ["Parity Technologies ", "Michael Müller "] edition = "2021" diff --git a/crates/env/Cargo.toml b/crates/env/Cargo.toml index 82ab3cc2ea..8dc34d28ce 100644 --- a/crates/env/Cargo.toml +++ b/crates/env/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ink_env" -version = "3.2.0" +version = "3.3.0" authors = ["Parity Technologies ", "Robin Freyler "] edition = "2021" @@ -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"] } @@ -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 } diff --git a/crates/lang/Cargo.toml b/crates/lang/Cargo.toml index e91f01ffb3..dfc2c3ee82 100644 --- a/crates/lang/Cargo.toml +++ b/crates/lang/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ink_lang" -version = "3.2.0" +version = "3.3.0" authors = ["Parity Technologies ", "Robin Freyler "] edition = "2021" @@ -15,19 +15,19 @@ categories = ["no-std", "embedded"] include = ["Cargo.toml", "src/**/*.rs", "README.md", "LICENSE"] [dependencies] -ink_env = { version = "3.2.0", path = "../env", default-features = false } -ink_storage = { version = "3.2.0", path = "../storage", default-features = false } -ink_primitives = { version = "3.2.0", path = "../primitives", default-features = false } -ink_metadata = { version = "3.2.0", path = "../metadata", default-features = false, optional = true } -ink_prelude = { version = "3.2.0", path = "../prelude", default-features = false } -ink_lang_macro = { version = "3.2.0", path = "macro", default-features = false } +ink_env = { version = "3.3.0", path = "../env", default-features = false } +ink_storage = { version = "3.3.0", path = "../storage", default-features = false } +ink_primitives = { version = "3.3.0", path = "../primitives", default-features = false } +ink_metadata = { version = "3.3.0", path = "../metadata", default-features = false, optional = true } +ink_prelude = { version = "3.3.0", path = "../prelude", default-features = false } +ink_lang_macro = { version = "3.3.0", path = "macro", 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"] } [dev-dependencies] -ink_lang_ir = { version = "3.2.0", path = "ir" } -ink_metadata = { version = "3.2.0", default-features = false, path = "../metadata" } +ink_lang_ir = { version = "3.3.0", path = "ir" } +ink_metadata = { version = "3.3.0", default-features = false, path = "../metadata" } trybuild = { version = "1.0.60", features = ["diff"] } # Required for the doctest of `env_access::EnvAccess::instantiate_contract` diff --git a/crates/lang/codegen/Cargo.toml b/crates/lang/codegen/Cargo.toml index 46b771c02a..d9378d603b 100644 --- a/crates/lang/codegen/Cargo.toml +++ b/crates/lang/codegen/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ink_lang_codegen" -version = "3.2.0" +version = "3.3.0" authors = ["Parity Technologies ", "Robin Freyler "] edition = "2021" @@ -18,7 +18,7 @@ include = ["Cargo.toml", "src/**/*.rs", "README.md", "LICENSE"] name = "ink_lang_codegen" [dependencies] -ir = { version = "3.2.0", package = "ink_lang_ir", path = "../ir", default-features = false } +ir = { version = "3.3.0", package = "ink_lang_ir", path = "../ir", default-features = false } quote = "1" syn = { version = "1.0", features = ["parsing", "full", "extra-traits"] } proc-macro2 = "1.0" diff --git a/crates/lang/ir/Cargo.toml b/crates/lang/ir/Cargo.toml index d4c67874ef..b019c9a8c4 100644 --- a/crates/lang/ir/Cargo.toml +++ b/crates/lang/ir/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ink_lang_ir" -version = "3.2.0" +version = "3.3.0" authors = ["Parity Technologies ", "Robin Freyler "] edition = "2021" diff --git a/crates/lang/macro/Cargo.toml b/crates/lang/macro/Cargo.toml index 033ba02ba1..1a26e8f858 100644 --- a/crates/lang/macro/Cargo.toml +++ b/crates/lang/macro/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ink_lang_macro" -version = "3.2.0" +version = "3.3.0" authors = ["Parity Technologies ", "Robin Freyler "] edition = "2021" @@ -15,19 +15,19 @@ categories = ["no-std", "embedded"] include = ["Cargo.toml", "src/**/*.rs", "README.md", "LICENSE"] [dependencies] -ink_lang_ir = { version = "3.2.0", path = "../ir", default-features = false } -ink_lang_codegen = { version = "3.2.0", path = "../codegen", default-features = false } -ink_primitives = { version = "3.2.0", path = "../../primitives/", default-features = false } +ink_lang_ir = { version = "3.3.0", path = "../ir", default-features = false } +ink_lang_codegen = { version = "3.3.0", path = "../codegen", default-features = false } +ink_primitives = { version = "3.3.0", path = "../../primitives/", default-features = false } scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] } syn = "1" proc-macro2 = "1" [dev-dependencies] -ink_metadata = { version = "3.2.0", path = "../../metadata/" } -ink_env = { version = "3.2.0", path = "../../env/" } -ink_storage = { version = "3.2.0", path = "../../storage/" } -ink_lang = { version = "3.2.0", path = ".." } +ink_metadata = { version = "3.3.0", path = "../../metadata/" } +ink_env = { version = "3.3.0", path = "../../env/" } +ink_storage = { version = "3.3.0", path = "../../storage/" } +ink_lang = { version = "3.3.0", path = ".." } scale-info = { version = "2", default-features = false, features = ["derive"] } [lib] diff --git a/crates/metadata/Cargo.toml b/crates/metadata/Cargo.toml index e9e780945f..0da3de9d69 100644 --- a/crates/metadata/Cargo.toml +++ b/crates/metadata/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ink_metadata" -version = "3.2.0" +version = "3.3.0" authors = ["Parity Technologies ", "Robin Freyler "] edition = "2021" @@ -15,8 +15,8 @@ categories = ["no-std", "embedded"] include = ["Cargo.toml", "src/**/*.rs", "README.md", "LICENSE"] [dependencies] -ink_prelude = { version = "3.2.0", path = "../prelude/", default-features = false } -ink_primitives = { version = "3.2.0", path = "../primitives/", default-features = false } +ink_prelude = { version = "3.3.0", path = "../prelude/", default-features = false } +ink_primitives = { version = "3.3.0", path = "../primitives/", default-features = false } serde = { version = "1.0", default-features = false, features = ["derive", "alloc"] } impl-serde = "0.3.1" diff --git a/crates/prelude/Cargo.toml b/crates/prelude/Cargo.toml index 62cff59607..34fbd4b349 100644 --- a/crates/prelude/Cargo.toml +++ b/crates/prelude/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ink_prelude" -version = "3.2.0" +version = "3.3.0" authors = ["Parity Technologies ", "Robin Freyler "] edition = "2021" diff --git a/crates/primitives/Cargo.toml b/crates/primitives/Cargo.toml index 63ab4f06eb..45e2cc283c 100644 --- a/crates/primitives/Cargo.toml +++ b/crates/primitives/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ink_primitives" -version = "3.2.0" +version = "3.3.0" authors = ["Parity Technologies ", "Robin Freyler "] edition = "2021" @@ -15,7 +15,7 @@ categories = ["no-std", "embedded"] include = ["/Cargo.toml", "src/**/*.rs", "/README.md", "/LICENSE"] [dependencies] -ink_prelude = { version = "3.2.0", path = "../prelude/", 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"] } scale-info = { version = "2", default-features = false, features = ["derive"], optional = true } cfg-if = "1" diff --git a/crates/storage/Cargo.toml b/crates/storage/Cargo.toml index fa4f6832a0..c574554d68 100644 --- a/crates/storage/Cargo.toml +++ b/crates/storage/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ink_storage" -version = "3.2.0" +version = "3.3.0" authors = ["Parity Technologies ", "Robin Freyler "] edition = "2021" @@ -15,11 +15,11 @@ categories = ["no-std", "embedded"] include = ["Cargo.toml", "src/**/*.rs", "README.md", "LICENSE"] [dependencies] -ink_env = { version = "3.2.0", path = "../env/", default-features = false } -ink_metadata = { version = "3.2.0", path = "../metadata/", default-features = false, features = ["derive"], optional = true } -ink_primitives = { version = "3.2.0", path = "../primitives/", default-features = false } -ink_storage_derive = { version = "3.2.0", path = "derive", default-features = false } -ink_prelude = { version = "3.2.0", path = "../prelude/", default-features = false } +ink_env = { version = "3.3.0", path = "../env/", default-features = false } +ink_metadata = { version = "3.3.0", path = "../metadata/", default-features = false, features = ["derive"], optional = true } +ink_primitives = { version = "3.3.0", path = "../primitives/", default-features = false } +ink_storage_derive = { version = "3.3.0", path = "derive", 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"] } @@ -33,7 +33,7 @@ quickcheck_macros = "1.0" itertools = "0.10" paste = "1.0" -ink_lang = { version = "3.2.0", path = "../lang/", default-features = false } +ink_lang = { version = "3.3.0", path = "../lang/", default-features = false } [features] default = ["std"] diff --git a/crates/storage/derive/Cargo.toml b/crates/storage/derive/Cargo.toml index 66ba233965..100cb7da59 100644 --- a/crates/storage/derive/Cargo.toml +++ b/crates/storage/derive/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ink_storage_derive" -version = "3.2.0" +version = "3.3.0" authors = ["Parity Technologies ", "Robin Freyler "] edition = "2021" @@ -25,8 +25,8 @@ synstructure = "0.12.4" [dev-dependencies] scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive", "full"] } -ink_env = { version = "3.2.0", path = "../../env" } -ink_primitives = { version = "3.2.0", path = "../../primitives" } -ink_metadata = { version = "3.2.0", path = "../../metadata" } -ink_prelude = { version = "3.2.0", path = "../../prelude/" } -ink_storage = { version = "3.2.0", path = ".." } +ink_env = { version = "3.3.0", path = "../../env" } +ink_primitives = { version = "3.3.0", path = "../../primitives" } +ink_metadata = { version = "3.3.0", path = "../../metadata" } +ink_prelude = { version = "3.3.0", path = "../../prelude/" } +ink_storage = { version = "3.3.0", path = ".." } diff --git a/examples/contract-terminate/Cargo.toml b/examples/contract-terminate/Cargo.toml index 93037a5da1..61c1f9a809 100644 --- a/examples/contract-terminate/Cargo.toml +++ b/examples/contract-terminate/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "contract_terminate" -version = "3.2.0" +version = "3.3.0" authors = ["Parity Technologies "] edition = "2021" publish = false diff --git a/examples/contract-transfer/Cargo.toml b/examples/contract-transfer/Cargo.toml index c5683626fa..29aa9361d1 100644 --- a/examples/contract-transfer/Cargo.toml +++ b/examples/contract-transfer/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "contract_transfer" -version = "3.2.0" +version = "3.3.0" authors = ["Parity Technologies "] edition = "2021" publish = false diff --git a/examples/delegator/Cargo.toml b/examples/delegator/Cargo.toml index 003547185e..132e151b56 100644 --- a/examples/delegator/Cargo.toml +++ b/examples/delegator/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "delegator" -version = "3.2.0" +version = "3.3.0" authors = ["Parity Technologies "] edition = "2021" publish = false diff --git a/examples/delegator/accumulator/Cargo.toml b/examples/delegator/accumulator/Cargo.toml index 2423ea2e81..27d704df05 100644 --- a/examples/delegator/accumulator/Cargo.toml +++ b/examples/delegator/accumulator/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "accumulator" -version = "3.2.0" +version = "3.3.0" authors = ["Parity Technologies "] edition = "2021" diff --git a/examples/delegator/adder/Cargo.toml b/examples/delegator/adder/Cargo.toml index bd54fbd9a7..88f2ae527c 100644 --- a/examples/delegator/adder/Cargo.toml +++ b/examples/delegator/adder/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "adder" -version = "3.2.0" +version = "3.3.0" authors = ["Parity Technologies "] edition = "2021" diff --git a/examples/delegator/subber/Cargo.toml b/examples/delegator/subber/Cargo.toml index 4376c7b6ad..8ac033a1f2 100644 --- a/examples/delegator/subber/Cargo.toml +++ b/examples/delegator/subber/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "subber" -version = "3.2.0" +version = "3.3.0" authors = ["Parity Technologies "] edition = "2021" diff --git a/examples/dns/Cargo.toml b/examples/dns/Cargo.toml index 67945cf059..8b09c34d26 100644 --- a/examples/dns/Cargo.toml +++ b/examples/dns/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "dns" -version = "3.2.0" +version = "3.3.0" authors = ["Parity Technologies "] edition = "2021" publish = false diff --git a/examples/erc1155/Cargo.toml b/examples/erc1155/Cargo.toml index 59e800b444..c281884f6e 100644 --- a/examples/erc1155/Cargo.toml +++ b/examples/erc1155/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "erc1155" -version = "3.2.0" +version = "3.3.0" authors = ["Parity Technologies "] edition = "2021" publish = false diff --git a/examples/erc20/Cargo.toml b/examples/erc20/Cargo.toml index 1125b46212..4d42b87d6c 100644 --- a/examples/erc20/Cargo.toml +++ b/examples/erc20/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "erc20" -version = "3.2.0" +version = "3.3.0" authors = ["Parity Technologies "] edition = "2021" publish = false diff --git a/examples/erc721/Cargo.toml b/examples/erc721/Cargo.toml index 90ee3bdbaa..a3c0ca60fb 100644 --- a/examples/erc721/Cargo.toml +++ b/examples/erc721/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "erc721" -version = "3.2.0" +version = "3.3.0" authors = ["Parity Technologies "] edition = "2021" publish = false diff --git a/examples/flipper/Cargo.toml b/examples/flipper/Cargo.toml index 2117d38f5e..b728b6dbf7 100644 --- a/examples/flipper/Cargo.toml +++ b/examples/flipper/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "flipper" -version = "3.2.0" +version = "3.3.0" authors = ["Parity Technologies "] edition = "2021" publish = false diff --git a/examples/incrementer/Cargo.toml b/examples/incrementer/Cargo.toml index 46b62df511..798c573372 100644 --- a/examples/incrementer/Cargo.toml +++ b/examples/incrementer/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "incrementer" -version = "3.2.0" +version = "3.3.0" authors = ["Parity Technologies "] edition = "2021" publish = false diff --git a/examples/multisig/Cargo.toml b/examples/multisig/Cargo.toml index 1346bf6391..3cff2ca4a3 100755 --- a/examples/multisig/Cargo.toml +++ b/examples/multisig/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "multisig" -version = "3.2.0" +version = "3.3.0" authors = ["Parity Technologies "] edition = "2021" publish = false diff --git a/examples/rand-extension/Cargo.toml b/examples/rand-extension/Cargo.toml index 58808a267b..76abed6a9f 100755 --- a/examples/rand-extension/Cargo.toml +++ b/examples/rand-extension/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rand_extension" -version = "3.2.0" +version = "3.3.0" authors = ["Parity Technologies "] edition = "2021" publish = false diff --git a/examples/trait-erc20/Cargo.toml b/examples/trait-erc20/Cargo.toml index d328b24cf5..54e1567f41 100644 --- a/examples/trait-erc20/Cargo.toml +++ b/examples/trait-erc20/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "trait_erc20" -version = "3.2.0" +version = "3.3.0" authors = ["Parity Technologies "] edition = "2021" publish = false diff --git a/examples/trait-flipper/Cargo.toml b/examples/trait-flipper/Cargo.toml index ccdfcc532a..3886952b16 100644 --- a/examples/trait-flipper/Cargo.toml +++ b/examples/trait-flipper/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "trait_flipper" -version = "3.2.0" +version = "3.3.0" authors = ["Parity Technologies "] edition = "2021" publish = false diff --git a/examples/trait-incrementer/Cargo.toml b/examples/trait-incrementer/Cargo.toml index 6f9c5a4313..b7887de3ef 100644 --- a/examples/trait-incrementer/Cargo.toml +++ b/examples/trait-incrementer/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "trait-incrementer" -version = "3.2.0" +version = "3.3.0" authors = ["Parity Technologies "] edition = "2021" publish = false diff --git a/examples/trait-incrementer/traits/Cargo.toml b/examples/trait-incrementer/traits/Cargo.toml index 68b4306640..fcac96888f 100644 --- a/examples/trait-incrementer/traits/Cargo.toml +++ b/examples/trait-incrementer/traits/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "traits" -version = "3.2.0" +version = "3.3.0" authors = ["Parity Technologies "] edition = "2021" publish = false diff --git a/examples/upgradeable-contracts/delegate-calls/Cargo.toml b/examples/upgradeable-contracts/delegate-calls/Cargo.toml index 53f65f0b75..87502bc174 100644 --- a/examples/upgradeable-contracts/delegate-calls/Cargo.toml +++ b/examples/upgradeable-contracts/delegate-calls/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "delegate_calls" -version = "3.2.0" +version = "3.3.0" authors = ["Parity Technologies "] edition = "2021" publish = false diff --git a/examples/upgradeable-contracts/delegate-calls/upgradeable-flipper/Cargo.toml b/examples/upgradeable-contracts/delegate-calls/upgradeable-flipper/Cargo.toml index d1d3d5abc0..536c924adf 100644 --- a/examples/upgradeable-contracts/delegate-calls/upgradeable-flipper/Cargo.toml +++ b/examples/upgradeable-contracts/delegate-calls/upgradeable-flipper/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "upgradeable_flipper" -version = "3.2.0" +version = "3.3.0" authors = ["Parity Technologies "] edition = "2021" publish = false diff --git a/examples/upgradeable-contracts/forward-calls/Cargo.toml b/examples/upgradeable-contracts/forward-calls/Cargo.toml index b607befb9f..f02a2f160d 100644 --- a/examples/upgradeable-contracts/forward-calls/Cargo.toml +++ b/examples/upgradeable-contracts/forward-calls/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "forward_calls" -version = "3.2.0" +version = "3.3.0" authors = ["Parity Technologies "] edition = "2021" publish = false diff --git a/examples/upgradeable-contracts/set-code-hash/Cargo.toml b/examples/upgradeable-contracts/set-code-hash/Cargo.toml index 96430ba8cf..62112f54e3 100644 --- a/examples/upgradeable-contracts/set-code-hash/Cargo.toml +++ b/examples/upgradeable-contracts/set-code-hash/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "incrementer" -version = "3.2.0" +version = "3.3.0" edition = "2021" authors = ["Parity Technologies "] publish = false diff --git a/examples/upgradeable-contracts/set-code-hash/updated-incrementer/Cargo.toml b/examples/upgradeable-contracts/set-code-hash/updated-incrementer/Cargo.toml index 71578227cc..3b60fce05b 100644 --- a/examples/upgradeable-contracts/set-code-hash/updated-incrementer/Cargo.toml +++ b/examples/upgradeable-contracts/set-code-hash/updated-incrementer/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "updated-incrementer" -version = "3.2.0" +version = "3.3.0" edition = "2021" authors = ["Parity Technologies "] publish = false From 5ae4bc1fa9432c11836f6de5c1144e371bc6ff20 Mon Sep 17 00:00:00 2001 From: Alexander Gryaznov Date: Mon, 6 Jun 2022 16:31:39 +0100 Subject: [PATCH 06/25] Mapping::insert_return_size is back, having now both `seal1` and `seal0` seal_set_storage versions used --- crates/engine/src/ext.rs | 19 +++++++++++++++++-- crates/env/src/api.rs | 17 ++++++++++++++++- crates/env/src/backend.rs | 7 ++++++- crates/env/src/engine/off_chain/impls.rs | 12 ++++++++++-- crates/env/src/engine/on_chain/ext.rs | 24 +++++++++++++++++++++--- crates/env/src/engine/on_chain/impls.rs | 16 ++++++++++++++-- crates/storage/src/lazy/mapping.rs | 12 ++++++++++++ crates/storage/src/traits/impls/mod.rs | 4 ++-- crates/storage/src/traits/mod.rs | 16 ++++++++++++++-- 9 files changed, 112 insertions(+), 15 deletions(-) diff --git a/crates/engine/src/ext.rs b/crates/engine/src/ext.rs index 2d77f34561..d4cb8d3e1e 100644 --- a/crates/engine/src/ext.rs +++ b/crates/engine/src/ext.rs @@ -227,8 +227,8 @@ 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]) { + /// Silently writes the encoded value into the storage at the given key. + pub fn set_storage_silent(&mut self, key: &[u8; 32], encoded_value: &[u8]) { let callee = self.get_callee(); let account_id = AccountId::from_bytes(&callee[..]); @@ -244,6 +244,21 @@ impl Engine { ); } + /// 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 { + 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()); + + self.database + .insert_into_contract_storage(&callee, key, encoded_value.to_vec()) + .map(|v| ::try_from(v.len()).expect("usize to u32 conversion failed")) + } + /// Returns the decoded contract storage at the key if any. pub fn get_storage(&mut self, key: &[u8; 32], output: &mut &mut [u8]) -> Result { let callee = self.get_callee(); diff --git a/crates/env/src/api.rs b/crates/env/src/api.rs index 633f0c53b2..1b8fd120fc 100644 --- a/crates/env/src/api.rs +++ b/crates/env/src/api.rs @@ -183,12 +183,27 @@ where }) } +/// The elder version of the function which is equivalent to the new one +/// but returns nothing. +/// +/// # Panics +/// +/// - If the encode length of value exceeds the configured maximum value length of a storage entry. +pub fn set_contract_storage_silent(key: &Key, value: &V) +where + V: scale::Encode, +{ + ::on_instance(|instance| { + EnvBackend::set_contract_storage_silent::(instance, key, value) + }); +} + /// 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(key: &Key, value: &V) +pub fn set_contract_storage(key: &Key, value: &V) -> Option where V: scale::Encode, { diff --git a/crates/env/src/backend.rs b/crates/env/src/backend.rs index e43cbbfed4..63e69eba6e 100644 --- a/crates/env/src/backend.rs +++ b/crates/env/src/backend.rs @@ -162,8 +162,13 @@ impl CallFlags { /// Environmental contract functionality that does not require `Environment`. pub trait EnvBackend { + /// Eqivalent to the newer version but returns nothing. + fn set_contract_storage_silent(&mut self, key: &Key, value: &V) + where + V: scale::Encode; + /// Writes the value to the contract storage under the given key. - fn set_contract_storage(&mut self, key: &Key, value: &V) + fn set_contract_storage(&mut self, key: &Key, value: &V) -> Option where V: scale::Encode; diff --git a/crates/env/src/engine/off_chain/impls.rs b/crates/env/src/engine/off_chain/impls.rs index ee8560e562..2ccff5fccc 100644 --- a/crates/env/src/engine/off_chain/impls.rs +++ b/crates/env/src/engine/off_chain/impls.rs @@ -184,12 +184,20 @@ impl EnvInstance { } impl EnvBackend for EnvInstance { - fn set_contract_storage(&mut self, key: &Key, value: &V) + fn set_contract_storage_silent(&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_silent(key.as_ref(), &v[..]); + } + + fn set_contract_storage(&mut self, key: &Key, value: &V) -> Option + where + V: scale::Encode, + { + let v = scale::Encode::encode(value); + self.engine.set_storage(key.as_ref(), &v[..]) } fn get_contract_storage(&mut self, key: &Key) -> Result> diff --git a/crates/env/src/engine/on_chain/ext.rs b/crates/env/src/engine/on_chain/ext.rs index c668b7e0d3..550b3ff3d1 100644 --- a/crates/env/src/engine/on_chain/ext.rs +++ b/crates/env/src/engine/on_chain/ext.rs @@ -231,7 +231,8 @@ mod sys { data_len: u32, ); - pub fn seal_set_storage( + #[link_name = "seal_set_storage"] + pub fn seal_set_storage_silent( key_ptr: Ptr32<[u8]>, value_ptr: Ptr32<[u8]>, value_len: u32, @@ -380,6 +381,12 @@ mod sys { output_ptr: Ptr32Mut<[u8]>, output_len_ptr: Ptr32Mut, ) -> ReturnCode; + + pub fn seal_set_storage( + key_ptr: Ptr32<[u8]>, + value_ptr: Ptr32<[u8]>, + value_len: u32, + ) -> ReturnCode; } } @@ -495,9 +502,9 @@ pub fn deposit_event(topics: &[u8], data: &[u8]) { } } -pub fn set_storage(key: &[u8], encoded_value: &[u8]) { +pub fn set_storage_silent(key: &[u8], encoded_value: &[u8]) { unsafe { - sys::seal_set_storage( + sys::seal_set_storage_silent( Ptr32::from_slice(key), Ptr32::from_slice(encoded_value), encoded_value.len() as u32, @@ -505,6 +512,17 @@ pub fn set_storage(key: &[u8], encoded_value: &[u8]) { } } +pub fn set_storage(key: &[u8], encoded_value: &[u8]) -> Option { + let ret_code = unsafe { + sys::seal_set_storage( + Ptr32::from_slice(key), + Ptr32::from_slice(encoded_value), + encoded_value.len() as u32, + ) + }; + ret_code.into() +} + pub fn clear_storage(key: &[u8]) { unsafe { sys::seal_clear_storage(Ptr32::from_slice(key)) } } diff --git a/crates/env/src/engine/on_chain/impls.rs b/crates/env/src/engine/on_chain/impls.rs index 84ea9d679c..a145cde2aa 100644 --- a/crates/env/src/engine/on_chain/impls.rs +++ b/crates/env/src/engine/on_chain/impls.rs @@ -219,12 +219,20 @@ impl EnvInstance { } impl EnvBackend for EnvInstance { - fn set_contract_storage(&mut self, key: &Key, value: &V) + fn set_contract_storage_silent(&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_silent(key.as_ref(), buffer); + } + + fn set_contract_storage(&mut self, key: &Key, value: &V) -> Option + where + V: scale::Encode, + { + let buffer = self.scoped_buffer().take_encoded(value); + ext::set_storage(key.as_ref(), buffer) } fn get_contract_storage(&mut self, key: &Key) -> Result> @@ -241,6 +249,10 @@ impl EnvBackend for EnvInstance { Ok(Some(decoded)) } + fn contract_storage_contains(&mut self, key: &Key) -> Option { + ext::storage_contains(key.as_ref()) + } + fn clear_contract_storage(&mut self, key: &Key) { ext::clear_storage(key.as_ref()) } diff --git a/crates/storage/src/lazy/mapping.rs b/crates/storage/src/lazy/mapping.rs index f9812a9274..c1d5b78ba6 100644 --- a/crates/storage/src/lazy/mapping.rs +++ b/crates/storage/src/lazy/mapping.rs @@ -134,6 +134,18 @@ where push_packed_root(value, &self.storage_key(&key)); } + /// Insert the given `value` to the contract storage. + /// + /// Returns the size of the pre-existing value at the specified key if any. + #[inline] + pub fn insert_return_size(&mut self, key: Q, value: &R) -> Option + where + Q: scale::EncodeLike, + R: scale::EncodeLike + PackedLayout, + { + push_packed_root(value, &self.storage_key(&key)) + } + /// Get the `value` at `key` from the contract storage. /// /// Returns `None` if no `value` exists at the given `key`. diff --git a/crates/storage/src/traits/impls/mod.rs b/crates/storage/src/traits/impls/mod.rs index 185953b71a..d65d7c2b2c 100644 --- a/crates/storage/src/traits/impls/mod.rs +++ b/crates/storage/src/traits/impls/mod.rs @@ -100,7 +100,7 @@ use super::{ allocate_packed_root, clear_packed_root, pull_packed_root, - push_packed_root, + push_packed_root_silent, PackedAllocate, PackedLayout, }; @@ -162,7 +162,7 @@ pub fn forward_push_packed(entity: &T, ptr: &mut KeyPtr) where T: PackedLayout, { - push_packed_root::(entity, ptr.next_for::()) + push_packed_root_silent::(entity, ptr.next_for::()); } /// Clears an instance of type `T` in packed fashion from the contract storage. diff --git a/crates/storage/src/traits/mod.rs b/crates/storage/src/traits/mod.rs index 456e81e6d6..38da5fa6b3 100644 --- a/crates/storage/src/traits/mod.rs +++ b/crates/storage/src/traits/mod.rs @@ -187,6 +187,18 @@ where /// Pushes the entity to the contract storage using packed layout. /// +/// This is the silent equivalent to the newer version. +pub fn push_packed_root_silent(entity: &T, root_key: &Key) +where + T: PackedLayout, +{ + ::push_packed(entity, root_key); + ink_env::set_contract_storage_silent(root_key, entity); +} + +/// Pushes the entity to the contract storage using packed layout and +/// returns the size of the pre-existing value if any. +/// /// The root key denotes the offset into the contract storage where the /// instance of type `T` is being pushed to. /// @@ -196,12 +208,12 @@ where /// packed layout. /// - Users should prefer using this function directly instead of using the /// trait methods on [`PackedLayout`]. -pub fn push_packed_root(entity: &T, root_key: &Key) +pub fn push_packed_root(entity: &T, root_key: &Key) -> Option where T: PackedLayout, { ::push_packed(entity, root_key); - ink_env::set_contract_storage(root_key, entity); + ink_env::set_contract_storage(root_key, entity) } /// Clears the entity from the contract storage using packed layout. From 56333929844d595e35e84cb53c05f12c2f9d964c Mon Sep 17 00:00:00 2001 From: Alexander Gryaznov Date: Mon, 6 Jun 2022 16:54:11 +0100 Subject: [PATCH 07/25] set_storage_silent -> set_storage_compat renaming --- crates/engine/src/ext.rs | 2 +- crates/env/src/api.rs | 4 ++-- crates/env/src/backend.rs | 2 +- crates/env/src/engine/off_chain/impls.rs | 4 ++-- crates/env/src/engine/on_chain/ext.rs | 6 +++--- crates/env/src/engine/on_chain/impls.rs | 4 ++-- crates/storage/src/traits/impls/mod.rs | 4 ++-- crates/storage/src/traits/mod.rs | 4 ++-- 8 files changed, 15 insertions(+), 15 deletions(-) diff --git a/crates/engine/src/ext.rs b/crates/engine/src/ext.rs index d4cb8d3e1e..b685550a7e 100644 --- a/crates/engine/src/ext.rs +++ b/crates/engine/src/ext.rs @@ -228,7 +228,7 @@ impl Engine { } /// Silently writes the encoded value into the storage at the given key. - pub fn set_storage_silent(&mut self, key: &[u8; 32], encoded_value: &[u8]) { + pub fn set_storage_compat(&mut self, key: &[u8; 32], encoded_value: &[u8]) { let callee = self.get_callee(); let account_id = AccountId::from_bytes(&callee[..]); diff --git a/crates/env/src/api.rs b/crates/env/src/api.rs index 1b8fd120fc..bc48b9dadd 100644 --- a/crates/env/src/api.rs +++ b/crates/env/src/api.rs @@ -189,12 +189,12 @@ where /// # Panics /// /// - If the encode length of value exceeds the configured maximum value length of a storage entry. -pub fn set_contract_storage_silent(key: &Key, value: &V) +pub fn set_contract_storage_compat(key: &Key, value: &V) where V: scale::Encode, { ::on_instance(|instance| { - EnvBackend::set_contract_storage_silent::(instance, key, value) + EnvBackend::set_contract_storage_compat::(instance, key, value) }); } diff --git a/crates/env/src/backend.rs b/crates/env/src/backend.rs index 63e69eba6e..55c33fdb1e 100644 --- a/crates/env/src/backend.rs +++ b/crates/env/src/backend.rs @@ -163,7 +163,7 @@ impl CallFlags { /// Environmental contract functionality that does not require `Environment`. pub trait EnvBackend { /// Eqivalent to the newer version but returns nothing. - fn set_contract_storage_silent(&mut self, key: &Key, value: &V) + fn set_contract_storage_compat(&mut self, key: &Key, value: &V) where V: scale::Encode; diff --git a/crates/env/src/engine/off_chain/impls.rs b/crates/env/src/engine/off_chain/impls.rs index 2ccff5fccc..22a13942f3 100644 --- a/crates/env/src/engine/off_chain/impls.rs +++ b/crates/env/src/engine/off_chain/impls.rs @@ -184,12 +184,12 @@ impl EnvInstance { } impl EnvBackend for EnvInstance { - fn set_contract_storage_silent(&mut self, key: &Key, value: &V) + fn set_contract_storage_compat(&mut self, key: &Key, value: &V) where V: scale::Encode, { let v = scale::Encode::encode(value); - self.engine.set_storage_silent(key.as_ref(), &v[..]); + self.engine.set_storage_compat(key.as_ref(), &v[..]); } fn set_contract_storage(&mut self, key: &Key, value: &V) -> Option diff --git a/crates/env/src/engine/on_chain/ext.rs b/crates/env/src/engine/on_chain/ext.rs index 550b3ff3d1..478106c1c9 100644 --- a/crates/env/src/engine/on_chain/ext.rs +++ b/crates/env/src/engine/on_chain/ext.rs @@ -232,7 +232,7 @@ mod sys { ); #[link_name = "seal_set_storage"] - pub fn seal_set_storage_silent( + pub fn seal_set_storage_compat( key_ptr: Ptr32<[u8]>, value_ptr: Ptr32<[u8]>, value_len: u32, @@ -502,9 +502,9 @@ pub fn deposit_event(topics: &[u8], data: &[u8]) { } } -pub fn set_storage_silent(key: &[u8], encoded_value: &[u8]) { +pub fn set_storage_compat(key: &[u8], encoded_value: &[u8]) { unsafe { - sys::seal_set_storage_silent( + sys::seal_set_storage_compat( Ptr32::from_slice(key), Ptr32::from_slice(encoded_value), encoded_value.len() as u32, diff --git a/crates/env/src/engine/on_chain/impls.rs b/crates/env/src/engine/on_chain/impls.rs index a145cde2aa..394c8f31df 100644 --- a/crates/env/src/engine/on_chain/impls.rs +++ b/crates/env/src/engine/on_chain/impls.rs @@ -219,12 +219,12 @@ impl EnvInstance { } impl EnvBackend for EnvInstance { - fn set_contract_storage_silent(&mut self, key: &Key, value: &V) + fn set_contract_storage_compat(&mut self, key: &Key, value: &V) where V: scale::Encode, { let buffer = self.scoped_buffer().take_encoded(value); - ext::set_storage_silent(key.as_ref(), buffer); + ext::set_storage_compat(key.as_ref(), buffer); } fn set_contract_storage(&mut self, key: &Key, value: &V) -> Option diff --git a/crates/storage/src/traits/impls/mod.rs b/crates/storage/src/traits/impls/mod.rs index d65d7c2b2c..099910a36e 100644 --- a/crates/storage/src/traits/impls/mod.rs +++ b/crates/storage/src/traits/impls/mod.rs @@ -100,7 +100,7 @@ use super::{ allocate_packed_root, clear_packed_root, pull_packed_root, - push_packed_root_silent, + push_packed_root_compat, PackedAllocate, PackedLayout, }; @@ -162,7 +162,7 @@ pub fn forward_push_packed(entity: &T, ptr: &mut KeyPtr) where T: PackedLayout, { - push_packed_root_silent::(entity, ptr.next_for::()); + push_packed_root_compat::(entity, ptr.next_for::()); } /// Clears an instance of type `T` in packed fashion from the contract storage. diff --git a/crates/storage/src/traits/mod.rs b/crates/storage/src/traits/mod.rs index 38da5fa6b3..d8b99ca0dc 100644 --- a/crates/storage/src/traits/mod.rs +++ b/crates/storage/src/traits/mod.rs @@ -188,12 +188,12 @@ where /// Pushes the entity to the contract storage using packed layout. /// /// This is the silent equivalent to the newer version. -pub fn push_packed_root_silent(entity: &T, root_key: &Key) +pub fn push_packed_root_compat(entity: &T, root_key: &Key) where T: PackedLayout, { ::push_packed(entity, root_key); - ink_env::set_contract_storage_silent(root_key, entity); + ink_env::set_contract_storage_compat(root_key, entity); } /// Pushes the entity to the contract storage using packed layout and From 4be74035004e5d4992bab2cebce928b1fa6dfec4 Mon Sep 17 00:00:00 2001 From: Alexander Gryaznov Date: Fri, 10 Jun 2022 11:46:13 +0300 Subject: [PATCH 08/25] spell fix --- crates/env/src/backend.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/env/src/backend.rs b/crates/env/src/backend.rs index 55c33fdb1e..ef09d143ef 100644 --- a/crates/env/src/backend.rs +++ b/crates/env/src/backend.rs @@ -162,7 +162,7 @@ impl CallFlags { /// Environmental contract functionality that does not require `Environment`. pub trait EnvBackend { - /// Eqivalent to the newer version but returns nothing. + /// Equivalent to the newer version but returns nothing. fn set_contract_storage_compat(&mut self, key: &Key, value: &V) where V: scale::Encode; From ee532c806420b852b51f6d4ec58f83f3c79ba680 Mon Sep 17 00:00:00 2001 From: Alexander Gryaznov Date: Wed, 15 Jun 2022 17:32:48 +0300 Subject: [PATCH 09/25] Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Michael Müller Co-authored-by: Hernando Castano --- RELEASES.md | 4 ++-- crates/env/src/api.rs | 8 ++++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/RELEASES.md b/RELEASES.md index 127e260e4c..33cc8e0f84 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -6,10 +6,10 @@ # Version 3.3.0 -This release is to make *ink!* 3.x.x backward compatible with *substrate-contracts-node* version [0.13.0](https://github.com/paritytech/substrate-contracts-node/releases/tag/v0.13.0) again. +This release is to make ink! 3.x.x backwards compatible with `substrate-contracts-node` version [0.13.0](https://github.com/paritytech/substrate-contracts-node/releases/tag/v0.13.0) again. ## Compatibility -This version should 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) +This version should 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 ([first](https://substrate.stackexchange.com/questions/2721/cargo-contract-3-0-1) and [second](https://substrate.stackexchange.com/questions/2870/cargo-contract-throws-error-about-supplied-arguments-in-inkconstructor-f)) unveiled backward incompatibility introduced in 3.1.0 release.* diff --git a/crates/env/src/api.rs b/crates/env/src/api.rs index bc48b9dadd..eec37d67a1 100644 --- a/crates/env/src/api.rs +++ b/crates/env/src/api.rs @@ -183,12 +183,16 @@ where }) } -/// The elder version of the function which is equivalent to the new one -/// but returns nothing. +/// 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. +/// +/// # Developer Note +/// +/// This is equivalent to the new [`set_contract_storage`] method, but in order to maintain old +/// behavior it returns nothing. pub fn set_contract_storage_compat(key: &Key, value: &V) where V: scale::Encode, From b0daa41d1946056edbd2c1fbe72cb202c4788fee Mon Sep 17 00:00:00 2001 From: Alexander Gryaznov Date: Wed, 15 Jun 2022 17:34:40 +0300 Subject: [PATCH 10/25] Apply suggestions from code review Co-authored-by: Hernando Castano --- RELEASES.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/RELEASES.md b/RELEASES.md index 33cc8e0f84..60119766d8 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -15,10 +15,10 @@ This version should work fine with *substrate-contracts-node* versions from [0.1 *Context: user-reported issues on our SE ([first](https://substrate.stackexchange.com/questions/2721/cargo-contract-3-0-1) and [second](https://substrate.stackexchange.com/questions/2870/cargo-contract-throws-error-about-supplied-arguments-in-inkconstructor-f)) unveiled backward incompatibility introduced in 3.1.0 release.* The following has been done to restore backward compatibility: -- Reverted backward-incompatible piece of [#1233](https://github.com/paritytech/ink/pull/1233): removal of `eth_compatibility crate` -- Reverted backward-incompatible piece of [#1224](https://github.com/paritytech/ink/pull/1224): dependency on `[seal1] seal_set_storage` +- Reverted backward-incompatible piece of [#1233](https://github.com/paritytech/ink/pull/1233). This removed the `eth_compatibility crate`. +- Reverted backward-incompatible piece of [#1224](https://github.com/paritytech/ink/pull/1224). An old method depended on a new SEAL API (`[seal1] seal_set_storage`). - Reverted "Optimise deny_payment. Use eerywhere semantic of deny. ([#1267](https://github.com/paritytech/ink/pull/1267))" - (this one is to restore compatibiliy between minor versions of ink! crates; see @HCastano SE [answer](https://substrate.stackexchange.com/a/3000/472) in this regard) + 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. All these breaking changes are subjects to the upcoming MAJOR *ink!* release 4.0.0. From fa6d2c85c9fb73a3c04adcba87907c5fc71fa260 Mon Sep 17 00:00:00 2001 From: Alexander Gryaznov Date: Wed, 15 Jun 2022 17:37:46 +0300 Subject: [PATCH 11/25] Update crates/env/src/backend.rs Co-authored-by: Hernando Castano --- crates/env/src/backend.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/crates/env/src/backend.rs b/crates/env/src/backend.rs index ef09d143ef..8927e6af08 100644 --- a/crates/env/src/backend.rs +++ b/crates/env/src/backend.rs @@ -162,7 +162,12 @@ impl CallFlags { /// Environmental contract functionality that does not require `Environment`. pub trait EnvBackend { - /// Equivalent to the newer version but returns nothing. + /// Writes the value to the contract storage under the given key. + /// + /// # Developer Note + /// + /// This is equivalent to the new [`set_contract_storage`] method, but in order to maintain old + /// behavior it returns nothing. fn set_contract_storage_compat(&mut self, key: &Key, value: &V) where V: scale::Encode; From e0f2259521b7c72e0039b4c4d5077df2dc2fe386 Mon Sep 17 00:00:00 2001 From: Alexander Gryaznov Date: Wed, 15 Jun 2022 17:56:44 +0300 Subject: [PATCH 12/25] doc comments enhanced --- crates/engine/src/ext.rs | 7 ++++++- crates/env/src/api.rs | 2 +- crates/env/src/backend.rs | 4 ++-- crates/storage/src/traits/mod.rs | 5 ++++- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/crates/engine/src/ext.rs b/crates/engine/src/ext.rs index b685550a7e..0f56aa342f 100644 --- a/crates/engine/src/ext.rs +++ b/crates/engine/src/ext.rs @@ -227,7 +227,12 @@ impl Engine { }); } - /// Silently writes the encoded value into the storage at the given key. + /// Writes the encoded value into the storage at the given key. + /// + /// # Note + /// + /// This is an equivalent to the new [`set_storage`][`Self::set_storage`] method, but in order to maintain old + /// behavior it returns nothing. pub fn set_storage_compat(&mut self, key: &[u8; 32], encoded_value: &[u8]) { let callee = self.get_callee(); let account_id = AccountId::from_bytes(&callee[..]); diff --git a/crates/env/src/api.rs b/crates/env/src/api.rs index eec37d67a1..2228b11c6a 100644 --- a/crates/env/src/api.rs +++ b/crates/env/src/api.rs @@ -189,7 +189,7 @@ where /// /// - If the encode length of value exceeds the configured maximum value length of a storage entry. /// -/// # Developer Note +/// # Note /// /// This is equivalent to the new [`set_contract_storage`] method, but in order to maintain old /// behavior it returns nothing. diff --git a/crates/env/src/backend.rs b/crates/env/src/backend.rs index 8927e6af08..c7125927ad 100644 --- a/crates/env/src/backend.rs +++ b/crates/env/src/backend.rs @@ -164,9 +164,9 @@ impl CallFlags { pub trait EnvBackend { /// Writes the value to the contract storage under the given key. /// - /// # Developer Note + /// # Note /// - /// This is equivalent to the new [`set_contract_storage`] method, but in order to maintain old + /// This is an equivalent to the new [`set_contract_storage`][`Self::set_contract_storage`] method, but in order to maintain old /// behavior it returns nothing. fn set_contract_storage_compat(&mut self, key: &Key, value: &V) where diff --git a/crates/storage/src/traits/mod.rs b/crates/storage/src/traits/mod.rs index d8b99ca0dc..1b3aec65f0 100644 --- a/crates/storage/src/traits/mod.rs +++ b/crates/storage/src/traits/mod.rs @@ -187,7 +187,10 @@ where /// Pushes the entity to the contract storage using packed layout. /// -/// This is the silent equivalent to the newer version. +/// # Note +/// +/// This is an equivalent to the new [`push_packed_root`], but in order to maintain old +/// behavior it returns nothing. pub fn push_packed_root_compat(entity: &T, root_key: &Key) where T: PackedLayout, From 3fb9c760ca5e49d7d275bea3a5243d61a002d213 Mon Sep 17 00:00:00 2001 From: Alexander Gryaznov Date: Wed, 15 Jun 2022 17:59:16 +0300 Subject: [PATCH 13/25] `Mapping::insert()` to use backwards compatible seal fn --- crates/storage/src/lazy/mapping.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/storage/src/lazy/mapping.rs b/crates/storage/src/lazy/mapping.rs index c1d5b78ba6..4559c5f2ce 100644 --- a/crates/storage/src/lazy/mapping.rs +++ b/crates/storage/src/lazy/mapping.rs @@ -22,6 +22,7 @@ use crate::traits::{ pull_packed_root_opt, push_packed_root, + push_packed_root_compat, ExtKeyPtr, KeyPtr, PackedLayout, @@ -131,7 +132,7 @@ where Q: scale::EncodeLike, R: scale::EncodeLike + PackedLayout, { - push_packed_root(value, &self.storage_key(&key)); + push_packed_root_compat(value, &self.storage_key(&key)); } /// Insert the given `value` to the contract storage. From 06bedc4d01cb81c51312c030e49f3b667d2aed83 Mon Sep 17 00:00:00 2001 From: Alexander Gryaznov Date: Wed, 15 Jun 2022 18:05:43 +0300 Subject: [PATCH 14/25] unreleased changes planned for 4.x removed from 3.x --- RELEASES.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/RELEASES.md b/RELEASES.md index 60119766d8..243bc96c69 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -1,8 +1,4 @@ # [Unreleased] -- Backward-incompatible piece of [#1233](https://github.com/paritytech/ink/pull/1233): removal of `eth_compatibility crate` -- Backward-incompatible piece of [#1224](https://github.com/paritytech/ink/pull/1224): dependency on `[seal1] seal_set_storage` -- Backward-incompatible "Optimise deny_payment. Use eerywhere semantic of deny. ([#1267](https://github.com/paritytech/ink/pull/1267))" - (see @HCastano SE [answer](https://substrate.stackexchange.com/a/3000/472) in this regard) # Version 3.3.0 From f5f6bc9fc42cf5e132836231c8bffe1f0425fbfb Mon Sep 17 00:00:00 2001 From: Hernando Castano Date: Wed, 15 Jun 2022 15:44:39 -0400 Subject: [PATCH 15/25] Add more details to the release notes --- RELEASES.md | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/RELEASES.md b/RELEASES.md index 243bc96c69..b3cea61f4d 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -2,19 +2,32 @@ # Version 3.3.0 -This release is to make ink! 3.x.x backwards compatible with `substrate-contracts-node` version [0.13.0](https://github.com/paritytech/substrate-contracts-node/releases/tag/v0.13.0) again. +This release restores SemVer compatibility in the 3.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 should 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) +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 ([first](https://substrate.stackexchange.com/questions/2721/cargo-contract-3-0-1) and [second](https://substrate.stackexchange.com/questions/2870/cargo-contract-throws-error-about-supplied-arguments-in-inkconstructor-f)) unveiled backward incompatibility introduced in 3.1.0 release.* +*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 [#1233](https://github.com/paritytech/ink/pull/1233). This removed the `eth_compatibility crate`. -- Reverted backward-incompatible piece of [#1224](https://github.com/paritytech/ink/pull/1224). An old method depended on a new SEAL API (`[seal1] seal_set_storage`). -- Reverted "Optimise deny_payment. Use eerywhere 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 [#1224](https://github.com/paritytech/ink/pull/1224). + - Under the hood this 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. From 609236ae64042ef6eafd1a6c964468208fd84942 Mon Sep 17 00:00:00 2001 From: Alexander Gryaznov Date: Thu, 16 Jun 2022 13:59:07 +0300 Subject: [PATCH 16/25] fix catched issue with changed api function signature --- crates/env/src/api.rs | 11 ++++++----- crates/env/src/backend.rs | 7 ++++--- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/crates/env/src/api.rs b/crates/env/src/api.rs index 2228b11c6a..ea882eb436 100644 --- a/crates/env/src/api.rs +++ b/crates/env/src/api.rs @@ -191,9 +191,9 @@ where /// /// # Note /// -/// This is equivalent to the new [`set_contract_storage`] method, but in order to maintain old -/// behavior it returns nothing. -pub fn set_contract_storage_compat(key: &Key, value: &V) +/// This is equivalent to the new [`set_contract_storage_return_old_size`] method, +/// but in order to maintain legacy behavior it returns nothing. +pub fn set_contract_storage(key: &Key, value: &V) where V: scale::Encode, { @@ -202,12 +202,13 @@ where }); } -/// Writes the value to the contract storage under the given key. +/// 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. /// /// # Panics /// /// - If the encode length of value exceeds the configured maximum value length of a storage entry. -pub fn set_contract_storage(key: &Key, value: &V) -> Option +pub fn set_contract_storage_return_old_size(key: &Key, value: &V) -> Option where V: scale::Encode, { diff --git a/crates/env/src/backend.rs b/crates/env/src/backend.rs index c7125927ad..81138eca52 100644 --- a/crates/env/src/backend.rs +++ b/crates/env/src/backend.rs @@ -166,13 +166,14 @@ pub trait EnvBackend { /// /// # Note /// - /// This is an equivalent to the new [`set_contract_storage`][`Self::set_contract_storage`] method, but in order to maintain old - /// behavior it returns nothing. + /// This is an equivalent to the new [`set_contract_storage`][`Self::set_contract_storage`] method, + /// but in order to maintain legacy behavior it returns nothing. fn set_contract_storage_compat(&mut self, key: &Key, value: &V) where V: scale::Encode; - /// Writes the value to the contract storage under the given key. + /// 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(&mut self, key: &Key, value: &V) -> Option where V: scale::Encode; From 5a03407331290b43aa050b240cf8e8cc6936f943 Mon Sep 17 00:00:00 2001 From: Alexander Gryaznov Date: Thu, 16 Jun 2022 14:08:55 +0300 Subject: [PATCH 17/25] fix storage trait dependent func --- crates/storage/src/traits/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/storage/src/traits/mod.rs b/crates/storage/src/traits/mod.rs index 1b3aec65f0..ab1889263b 100644 --- a/crates/storage/src/traits/mod.rs +++ b/crates/storage/src/traits/mod.rs @@ -196,7 +196,7 @@ where T: PackedLayout, { ::push_packed(entity, root_key); - ink_env::set_contract_storage_compat(root_key, entity); + ink_env::set_contract_storage(root_key, entity); } /// Pushes the entity to the contract storage using packed layout and @@ -216,7 +216,7 @@ where T: PackedLayout, { ::push_packed(entity, root_key); - ink_env::set_contract_storage(root_key, entity) + ink_env::set_contract_storage_return_old_size(root_key, entity) } /// Clears the entity from the contract storage using packed layout. From dbee0ab28eb75e7c7c9e9a63bf3b1974af43e146 Mon Sep 17 00:00:00 2001 From: Alexander Gryaznov Date: Thu, 16 Jun 2022 17:33:32 +0300 Subject: [PATCH 18/25] Apply new versions naming policy: step1. Old versions to keep their names. --- crates/engine/src/ext.rs | 10 +++++++--- crates/env/src/api.rs | 6 +++--- crates/env/src/backend.rs | 4 ++-- crates/env/src/engine/off_chain/impls.rs | 8 ++++---- crates/env/src/engine/on_chain/ext.rs | 14 +++++++------- crates/env/src/engine/on_chain/impls.rs | 8 ++++---- crates/storage/src/lazy/mapping.rs | 8 ++++---- crates/storage/src/traits/impls/mod.rs | 4 ++-- crates/storage/src/traits/mod.rs | 6 +++--- 9 files changed, 36 insertions(+), 32 deletions(-) diff --git a/crates/engine/src/ext.rs b/crates/engine/src/ext.rs index 0f56aa342f..ac5a249d35 100644 --- a/crates/engine/src/ext.rs +++ b/crates/engine/src/ext.rs @@ -231,9 +231,9 @@ impl Engine { /// /// # Note /// - /// This is an equivalent to the new [`set_storage`][`Self::set_storage`] method, but in order to maintain old + /// This is an equivalent to the new [`set_storage_inform`][`Self::set_storage_inform`] method, but in order to maintain old /// behavior it returns nothing. - pub fn set_storage_compat(&mut self, key: &[u8; 32], encoded_value: &[u8]) { + pub fn set_storage(&mut self, key: &[u8; 32], encoded_value: &[u8]) { let callee = self.get_callee(); let account_id = AccountId::from_bytes(&callee[..]); @@ -251,7 +251,11 @@ impl Engine { /// 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 { + pub fn set_storage_inform( + &mut self, + key: &[u8; 32], + encoded_value: &[u8], + ) -> Option { let callee = self.get_callee(); let account_id = AccountId::from_bytes(&callee[..]); diff --git a/crates/env/src/api.rs b/crates/env/src/api.rs index ea882eb436..e8dfbec63f 100644 --- a/crates/env/src/api.rs +++ b/crates/env/src/api.rs @@ -198,7 +198,7 @@ where V: scale::Encode, { ::on_instance(|instance| { - EnvBackend::set_contract_storage_compat::(instance, key, value) + EnvBackend::set_contract_storage::(instance, key, value) }); } @@ -208,12 +208,12 @@ where /// # Panics /// /// - If the encode length of value exceeds the configured maximum value length of a storage entry. -pub fn set_contract_storage_return_old_size(key: &Key, value: &V) -> Option +pub fn set_contract_storage_inform(key: &Key, value: &V) -> Option where V: scale::Encode, { ::on_instance(|instance| { - EnvBackend::set_contract_storage::(instance, key, value) + EnvBackend::set_contract_storage_inform::(instance, key, value) }) } diff --git a/crates/env/src/backend.rs b/crates/env/src/backend.rs index 81138eca52..afdb67a33b 100644 --- a/crates/env/src/backend.rs +++ b/crates/env/src/backend.rs @@ -168,13 +168,13 @@ pub trait EnvBackend { /// /// This is an equivalent to the new [`set_contract_storage`][`Self::set_contract_storage`] method, /// but in order to maintain legacy behavior it returns nothing. - fn set_contract_storage_compat(&mut self, key: &Key, value: &V) + fn set_contract_storage(&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(&mut self, key: &Key, value: &V) -> Option + fn set_contract_storage_inform(&mut self, key: &Key, value: &V) -> Option where V: scale::Encode; diff --git a/crates/env/src/engine/off_chain/impls.rs b/crates/env/src/engine/off_chain/impls.rs index 22a13942f3..e2125613b8 100644 --- a/crates/env/src/engine/off_chain/impls.rs +++ b/crates/env/src/engine/off_chain/impls.rs @@ -184,20 +184,20 @@ impl EnvInstance { } impl EnvBackend for EnvInstance { - fn set_contract_storage_compat(&mut self, key: &Key, value: &V) + fn set_contract_storage(&mut self, key: &Key, value: &V) where V: scale::Encode, { let v = scale::Encode::encode(value); - self.engine.set_storage_compat(key.as_ref(), &v[..]); + self.engine.set_storage(key.as_ref(), &v[..]); } - fn set_contract_storage(&mut self, key: &Key, value: &V) -> Option + fn set_contract_storage_inform(&mut self, key: &Key, value: &V) -> Option where V: scale::Encode, { let v = scale::Encode::encode(value); - self.engine.set_storage(key.as_ref(), &v[..]) + self.engine.set_storage_inform(key.as_ref(), &v[..]) } fn get_contract_storage(&mut self, key: &Key) -> Result> diff --git a/crates/env/src/engine/on_chain/ext.rs b/crates/env/src/engine/on_chain/ext.rs index 478106c1c9..7885c714f2 100644 --- a/crates/env/src/engine/on_chain/ext.rs +++ b/crates/env/src/engine/on_chain/ext.rs @@ -231,8 +231,7 @@ mod sys { data_len: u32, ); - #[link_name = "seal_set_storage"] - pub fn seal_set_storage_compat( + pub fn seal_set_storage( key_ptr: Ptr32<[u8]>, value_ptr: Ptr32<[u8]>, value_len: u32, @@ -382,7 +381,8 @@ mod sys { output_len_ptr: Ptr32Mut, ) -> ReturnCode; - pub fn seal_set_storage( + #[link_name = "seal_set_storage"] + pub fn seal_set_storage_inform( key_ptr: Ptr32<[u8]>, value_ptr: Ptr32<[u8]>, value_len: u32, @@ -502,9 +502,9 @@ pub fn deposit_event(topics: &[u8], data: &[u8]) { } } -pub fn set_storage_compat(key: &[u8], encoded_value: &[u8]) { +pub fn set_storage(key: &[u8], encoded_value: &[u8]) { unsafe { - sys::seal_set_storage_compat( + sys::seal_set_storage( Ptr32::from_slice(key), Ptr32::from_slice(encoded_value), encoded_value.len() as u32, @@ -512,9 +512,9 @@ pub fn set_storage_compat(key: &[u8], encoded_value: &[u8]) { } } -pub fn set_storage(key: &[u8], encoded_value: &[u8]) -> Option { +pub fn set_storage_inform(key: &[u8], encoded_value: &[u8]) -> Option { let ret_code = unsafe { - sys::seal_set_storage( + sys::seal_set_storage_inform( Ptr32::from_slice(key), Ptr32::from_slice(encoded_value), encoded_value.len() as u32, diff --git a/crates/env/src/engine/on_chain/impls.rs b/crates/env/src/engine/on_chain/impls.rs index 394c8f31df..9662a9c1dc 100644 --- a/crates/env/src/engine/on_chain/impls.rs +++ b/crates/env/src/engine/on_chain/impls.rs @@ -219,20 +219,20 @@ impl EnvInstance { } impl EnvBackend for EnvInstance { - fn set_contract_storage_compat(&mut self, key: &Key, value: &V) + fn set_contract_storage(&mut self, key: &Key, value: &V) where V: scale::Encode, { let buffer = self.scoped_buffer().take_encoded(value); - ext::set_storage_compat(key.as_ref(), buffer); + ext::set_storage(key.as_ref(), buffer); } - fn set_contract_storage(&mut self, key: &Key, value: &V) -> Option + fn set_contract_storage_inform(&mut self, key: &Key, value: &V) -> Option where V: scale::Encode, { let buffer = self.scoped_buffer().take_encoded(value); - ext::set_storage(key.as_ref(), buffer) + ext::set_storage_inform(key.as_ref(), buffer) } fn get_contract_storage(&mut self, key: &Key) -> Result> diff --git a/crates/storage/src/lazy/mapping.rs b/crates/storage/src/lazy/mapping.rs index 4559c5f2ce..b8da8ed9f8 100644 --- a/crates/storage/src/lazy/mapping.rs +++ b/crates/storage/src/lazy/mapping.rs @@ -22,7 +22,7 @@ use crate::traits::{ pull_packed_root_opt, push_packed_root, - push_packed_root_compat, + push_packed_root_inform, ExtKeyPtr, KeyPtr, PackedLayout, @@ -132,19 +132,19 @@ where Q: scale::EncodeLike, R: scale::EncodeLike + PackedLayout, { - push_packed_root_compat(value, &self.storage_key(&key)); + push_packed_root(value, &self.storage_key(&key)); } /// Insert the given `value` to the contract storage. /// /// Returns the size of the pre-existing value at the specified key if any. #[inline] - pub fn insert_return_size(&mut self, key: Q, value: &R) -> Option + pub fn insert_inform(&mut self, key: Q, value: &R) -> Option where Q: scale::EncodeLike, R: scale::EncodeLike + PackedLayout, { - push_packed_root(value, &self.storage_key(&key)) + push_packed_root_inform(value, &self.storage_key(&key)) } /// Get the `value` at `key` from the contract storage. diff --git a/crates/storage/src/traits/impls/mod.rs b/crates/storage/src/traits/impls/mod.rs index 099910a36e..cf0d46a377 100644 --- a/crates/storage/src/traits/impls/mod.rs +++ b/crates/storage/src/traits/impls/mod.rs @@ -100,7 +100,7 @@ use super::{ allocate_packed_root, clear_packed_root, pull_packed_root, - push_packed_root_compat, + push_packed_root_inform, PackedAllocate, PackedLayout, }; @@ -162,7 +162,7 @@ pub fn forward_push_packed(entity: &T, ptr: &mut KeyPtr) where T: PackedLayout, { - push_packed_root_compat::(entity, ptr.next_for::()); + push_packed_root_inform::(entity, ptr.next_for::()); } /// Clears an instance of type `T` in packed fashion from the contract storage. diff --git a/crates/storage/src/traits/mod.rs b/crates/storage/src/traits/mod.rs index ab1889263b..001d8f5208 100644 --- a/crates/storage/src/traits/mod.rs +++ b/crates/storage/src/traits/mod.rs @@ -191,7 +191,7 @@ where /// /// This is an equivalent to the new [`push_packed_root`], but in order to maintain old /// behavior it returns nothing. -pub fn push_packed_root_compat(entity: &T, root_key: &Key) +pub fn push_packed_root(entity: &T, root_key: &Key) where T: PackedLayout, { @@ -211,12 +211,12 @@ where /// packed layout. /// - Users should prefer using this function directly instead of using the /// trait methods on [`PackedLayout`]. -pub fn push_packed_root(entity: &T, root_key: &Key) -> Option +pub fn push_packed_root_inform(entity: &T, root_key: &Key) -> Option where T: PackedLayout, { ::push_packed(entity, root_key); - ink_env::set_contract_storage_return_old_size(root_key, entity) + ink_env::set_contract_storage_inform(root_key, entity) } /// Clears the entity from the contract storage using packed layout. From 7e14d0b5b0051f6b705462c56228a970a6310fce Mon Sep 17 00:00:00 2001 From: Alexander Gryaznov Date: Thu, 16 Jun 2022 18:52:52 +0300 Subject: [PATCH 19/25] Apply new versions naming policy: step2. Add `deprecated` attr and `# Compatibility` docs section --- crates/env/src/api.rs | 12 +++++++++++- crates/storage/src/traits/mod.rs | 1 + 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/crates/env/src/api.rs b/crates/env/src/api.rs index e8dfbec63f..aacee2fff2 100644 --- a/crates/env/src/api.rs +++ b/crates/env/src/api.rs @@ -191,8 +191,12 @@ where /// /// # Note /// -/// This is equivalent to the new [`set_contract_storage_return_old_size`] method, +/// This is equivalent to the new [`set_contract_storage_inform`] method, /// but in order to maintain legacy behavior it returns nothing. +#[deprecated( + since = "3.3.0", + note = "New `set_contract_storage_inform()` is preferrable" +)] pub fn set_contract_storage(key: &Key, value: &V) where V: scale::Encode, @@ -205,6 +209,12 @@ where /// 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`, +/// or any node built with `substrate` version later than +/// [#7d233c2446b5a60662400a0a4bcfb78bb3b79ff7](https://github.com/paritytech/substrate/tree/7d233c2446b5a60662400a0a4bcfb78bb3b79ff7). +/// /// # Panics /// /// - If the encode length of value exceeds the configured maximum value length of a storage entry. diff --git a/crates/storage/src/traits/mod.rs b/crates/storage/src/traits/mod.rs index 001d8f5208..07a4ecb4e2 100644 --- a/crates/storage/src/traits/mod.rs +++ b/crates/storage/src/traits/mod.rs @@ -22,6 +22,7 @@ //! The `PackedLayout` trait can then be implemented on top of the `SpreadLayout` //! for types that further allow to be stored in the contract storage in a more //! compressed format to a single storage cell. +#![allow(deprecated)] mod impls; mod keyptr; From b1a73936c429f3ebf4b9f49017b35d77efdf2715 Mon Sep 17 00:00:00 2001 From: Alexander Gryaznov Date: Fri, 17 Jun 2022 13:04:28 +0300 Subject: [PATCH 20/25] Apply suggestions from code review Co-authored-by: Hernando Castano --- crates/env/src/api.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/env/src/api.rs b/crates/env/src/api.rs index aacee2fff2..32dc3c5b6e 100644 --- a/crates/env/src/api.rs +++ b/crates/env/src/api.rs @@ -195,7 +195,7 @@ where /// but in order to maintain legacy behavior it returns nothing. #[deprecated( since = "3.3.0", - note = "New `set_contract_storage_inform()` is preferrable" + note = "`set_contract_storage_inform()` is provides more information, and will be made the standard in the future." )] pub fn set_contract_storage(key: &Key, value: &V) where @@ -212,8 +212,8 @@ where /// # Compatibility /// /// This function requires minimum `substrate-contracts-node` version `v0.15.1`, -/// or any node built with `substrate` version later than -/// [#7d233c2446b5a60662400a0a4bcfb78bb3b79ff7](https://github.com/paritytech/substrate/tree/7d233c2446b5a60662400a0a4bcfb78bb3b79ff7). +/// or any node built with Substrate version later than +/// [#7d233c2](https://github.com/paritytech/substrate/tree/7d233c2446b5a60662400a0a4bcfb78bb3b79ff7). /// /// # Panics /// From 9171c38dbff79e4e7eb0d06114a7cf8543b63d02 Mon Sep 17 00:00:00 2001 From: Alexander Gryaznov Date: Fri, 17 Jun 2022 13:39:45 +0300 Subject: [PATCH 21/25] fixes after next review round --- crates/env/src/api.rs | 12 ++++++------ crates/env/src/backend.rs | 10 +++++----- crates/storage/src/traits/impls/mod.rs | 4 ++-- crates/storage/src/traits/mod.rs | 14 +++++++------- 4 files changed, 20 insertions(+), 20 deletions(-) diff --git a/crates/env/src/api.rs b/crates/env/src/api.rs index 32dc3c5b6e..5b0a4f231d 100644 --- a/crates/env/src/api.rs +++ b/crates/env/src/api.rs @@ -188,11 +188,6 @@ where /// # Panics /// /// - If the encode length of value exceeds the configured maximum value length of a storage entry. -/// -/// # Note -/// -/// This is equivalent to the new [`set_contract_storage_inform`] method, -/// but in order to maintain legacy behavior it returns nothing. #[deprecated( since = "3.3.0", note = "`set_contract_storage_inform()` is provides more information, and will be made the standard in the future." @@ -211,13 +206,18 @@ where /// /// # Compatibility /// -/// This function requires minimum `substrate-contracts-node` version `v0.15.1`, +/// 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_inform(key: &Key, value: &V) -> Option where V: scale::Encode, diff --git a/crates/env/src/backend.rs b/crates/env/src/backend.rs index afdb67a33b..2d0792a96a 100644 --- a/crates/env/src/backend.rs +++ b/crates/env/src/backend.rs @@ -163,17 +163,17 @@ impl CallFlags { /// Environmental contract functionality that does not require `Environment`. pub trait EnvBackend { /// Writes the value to the contract storage under the given key. - /// - /// # Note - /// - /// This is an equivalent to the new [`set_contract_storage`][`Self::set_contract_storage`] method, - /// but in order to maintain legacy behavior it returns nothing. fn set_contract_storage(&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. + /// + /// # 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_inform(&mut self, key: &Key, value: &V) -> Option where V: scale::Encode; diff --git a/crates/storage/src/traits/impls/mod.rs b/crates/storage/src/traits/impls/mod.rs index cf0d46a377..3467e81660 100644 --- a/crates/storage/src/traits/impls/mod.rs +++ b/crates/storage/src/traits/impls/mod.rs @@ -100,7 +100,7 @@ use super::{ allocate_packed_root, clear_packed_root, pull_packed_root, - push_packed_root_inform, + push_packed_root, PackedAllocate, PackedLayout, }; @@ -162,7 +162,7 @@ pub fn forward_push_packed(entity: &T, ptr: &mut KeyPtr) where T: PackedLayout, { - push_packed_root_inform::(entity, ptr.next_for::()); + push_packed_root::(entity, ptr.next_for::()); } /// Clears an instance of type `T` in packed fashion from the contract storage. diff --git a/crates/storage/src/traits/mod.rs b/crates/storage/src/traits/mod.rs index 07a4ecb4e2..096f2b58ef 100644 --- a/crates/storage/src/traits/mod.rs +++ b/crates/storage/src/traits/mod.rs @@ -22,7 +22,6 @@ //! The `PackedLayout` trait can then be implemented on top of the `SpreadLayout` //! for types that further allow to be stored in the contract storage in a more //! compressed format to a single storage cell. -#![allow(deprecated)] mod impls; mod keyptr; @@ -190,8 +189,11 @@ where /// /// # Note /// -/// This is an equivalent to the new [`push_packed_root`], but in order to maintain old -/// behavior it returns nothing. +/// - The routine will push the given entity to the contract storage using +/// packed layout. +/// - Users should prefer using this function directly instead of using the +/// trait methods on [`PackedLayout`]. +#[allow(deprecated)] pub fn push_packed_root(entity: &T, root_key: &Key) where T: PackedLayout, @@ -208,10 +210,8 @@ where /// /// # Note /// -/// - The routine will push the given entity to the contract storage using -/// packed layout. -/// - Users should prefer using this function directly instead of using the -/// trait methods on [`PackedLayout`]. +/// This is an equivalent to the new [`push_packed_root`], +/// but gives the information on the pre-existing value size. pub fn push_packed_root_inform(entity: &T, root_key: &Key) -> Option where T: PackedLayout, From 05f7e82643b5e8e197739670259f640192bbaba1 Mon Sep 17 00:00:00 2001 From: Alexander Gryaznov Date: Mon, 20 Jun 2022 22:29:04 +0300 Subject: [PATCH 22/25] more fixes after the review round --- crates/engine/src/ext.rs | 12 ++++++------ crates/env/src/api.rs | 6 +++--- crates/env/src/backend.rs | 2 +- crates/env/src/engine/off_chain/impls.rs | 4 ++-- crates/env/src/engine/on_chain/ext.rs | 6 +++--- crates/env/src/engine/on_chain/impls.rs | 4 ++-- crates/storage/src/lazy/mapping.rs | 6 +++--- crates/storage/src/traits/mod.rs | 9 +++++---- 8 files changed, 25 insertions(+), 24 deletions(-) diff --git a/crates/engine/src/ext.rs b/crates/engine/src/ext.rs index ac5a249d35..df003ac7ea 100644 --- a/crates/engine/src/ext.rs +++ b/crates/engine/src/ext.rs @@ -228,11 +228,6 @@ impl Engine { } /// Writes the encoded value into the storage at the given key. - /// - /// # Note - /// - /// This is an equivalent to the new [`set_storage_inform`][`Self::set_storage_inform`] method, but in order to maintain old - /// behavior it returns nothing. pub fn set_storage(&mut self, key: &[u8; 32], encoded_value: &[u8]) { let callee = self.get_callee(); let account_id = AccountId::from_bytes(&callee[..]); @@ -251,7 +246,12 @@ impl Engine { /// 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_inform( + /// + /// # Note + /// + /// This is an equivalent to the new [`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], diff --git a/crates/env/src/api.rs b/crates/env/src/api.rs index 5b0a4f231d..fc5acd3bfc 100644 --- a/crates/env/src/api.rs +++ b/crates/env/src/api.rs @@ -190,7 +190,7 @@ where /// - If the encode length of value exceeds the configured maximum value length of a storage entry. #[deprecated( since = "3.3.0", - note = "`set_contract_storage_inform()` is provides more information, and will be made the standard in the future." + note = "`set_contract_storage_return_size()` provides more information, and will be made the standard in the future." )] pub fn set_contract_storage(key: &Key, value: &V) where @@ -218,12 +218,12 @@ where /// /// This is equivalent to the [`set_contract_storage`] method, /// but gives the information on the pre-existing value size. -pub fn set_contract_storage_inform(key: &Key, value: &V) -> Option +pub fn set_contract_storage_return_size(key: &Key, value: &V) -> Option where V: scale::Encode, { ::on_instance(|instance| { - EnvBackend::set_contract_storage_inform::(instance, key, value) + EnvBackend::set_contract_storage_return_size::(instance, key, value) }) } diff --git a/crates/env/src/backend.rs b/crates/env/src/backend.rs index 2d0792a96a..e7ca7606df 100644 --- a/crates/env/src/backend.rs +++ b/crates/env/src/backend.rs @@ -174,7 +174,7 @@ pub trait EnvBackend { /// /// 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_inform(&mut self, key: &Key, value: &V) -> Option + fn set_contract_storage_return_size(&mut self, key: &Key, value: &V) -> Option where V: scale::Encode; diff --git a/crates/env/src/engine/off_chain/impls.rs b/crates/env/src/engine/off_chain/impls.rs index e2125613b8..75bd599309 100644 --- a/crates/env/src/engine/off_chain/impls.rs +++ b/crates/env/src/engine/off_chain/impls.rs @@ -192,12 +192,12 @@ impl EnvBackend for EnvInstance { self.engine.set_storage(key.as_ref(), &v[..]); } - fn set_contract_storage_inform(&mut self, key: &Key, value: &V) -> Option + fn set_contract_storage_return_size(&mut self, key: &Key, value: &V) -> Option where V: scale::Encode, { let v = scale::Encode::encode(value); - self.engine.set_storage_inform(key.as_ref(), &v[..]) + self.engine.set_storage_return_size(key.as_ref(), &v[..]) } fn get_contract_storage(&mut self, key: &Key) -> Result> diff --git a/crates/env/src/engine/on_chain/ext.rs b/crates/env/src/engine/on_chain/ext.rs index 7885c714f2..5f75272bd1 100644 --- a/crates/env/src/engine/on_chain/ext.rs +++ b/crates/env/src/engine/on_chain/ext.rs @@ -382,7 +382,7 @@ mod sys { ) -> ReturnCode; #[link_name = "seal_set_storage"] - pub fn seal_set_storage_inform( + pub fn seal_set_storage_return_size( key_ptr: Ptr32<[u8]>, value_ptr: Ptr32<[u8]>, value_len: u32, @@ -512,9 +512,9 @@ pub fn set_storage(key: &[u8], encoded_value: &[u8]) { } } -pub fn set_storage_inform(key: &[u8], encoded_value: &[u8]) -> Option { +pub fn set_storage_return_size(key: &[u8], encoded_value: &[u8]) -> Option { let ret_code = unsafe { - sys::seal_set_storage_inform( + sys::seal_set_storage_return_size( Ptr32::from_slice(key), Ptr32::from_slice(encoded_value), encoded_value.len() as u32, diff --git a/crates/env/src/engine/on_chain/impls.rs b/crates/env/src/engine/on_chain/impls.rs index 9662a9c1dc..225279a587 100644 --- a/crates/env/src/engine/on_chain/impls.rs +++ b/crates/env/src/engine/on_chain/impls.rs @@ -227,12 +227,12 @@ impl EnvBackend for EnvInstance { ext::set_storage(key.as_ref(), buffer); } - fn set_contract_storage_inform(&mut self, key: &Key, value: &V) -> Option + fn set_contract_storage_return_size(&mut self, key: &Key, value: &V) -> Option where V: scale::Encode, { let buffer = self.scoped_buffer().take_encoded(value); - ext::set_storage_inform(key.as_ref(), buffer) + ext::set_storage_return_size(key.as_ref(), buffer) } fn get_contract_storage(&mut self, key: &Key) -> Result> diff --git a/crates/storage/src/lazy/mapping.rs b/crates/storage/src/lazy/mapping.rs index b8da8ed9f8..7d6ad46c4c 100644 --- a/crates/storage/src/lazy/mapping.rs +++ b/crates/storage/src/lazy/mapping.rs @@ -22,7 +22,7 @@ use crate::traits::{ pull_packed_root_opt, push_packed_root, - push_packed_root_inform, + push_packed_root_return_size, ExtKeyPtr, KeyPtr, PackedLayout, @@ -139,12 +139,12 @@ where /// /// Returns the size of the pre-existing value at the specified key if any. #[inline] - pub fn insert_inform(&mut self, key: Q, value: &R) -> Option + pub fn insert_return_size(&mut self, key: Q, value: &R) -> Option where Q: scale::EncodeLike, R: scale::EncodeLike + PackedLayout, { - push_packed_root_inform(value, &self.storage_key(&key)) + push_packed_root_return_size(value, &self.storage_key(&key)) } /// Get the `value` at `key` from the contract storage. diff --git a/crates/storage/src/traits/mod.rs b/crates/storage/src/traits/mod.rs index 096f2b58ef..09cb770206 100644 --- a/crates/storage/src/traits/mod.rs +++ b/crates/storage/src/traits/mod.rs @@ -193,12 +193,13 @@ where /// packed layout. /// - Users should prefer using this function directly instead of using the /// trait methods on [`PackedLayout`]. -#[allow(deprecated)] pub fn push_packed_root(entity: &T, root_key: &Key) where T: PackedLayout, { ::push_packed(entity, root_key); + + #[allow(deprecated)] ink_env::set_contract_storage(root_key, entity); } @@ -210,14 +211,14 @@ where /// /// # Note /// -/// This is an equivalent to the new [`push_packed_root`], +/// This is an equivalent to [`push_packed_root`], /// but gives the information on the pre-existing value size. -pub fn push_packed_root_inform(entity: &T, root_key: &Key) -> Option +pub fn push_packed_root_return_size(entity: &T, root_key: &Key) -> Option where T: PackedLayout, { ::push_packed(entity, root_key); - ink_env::set_contract_storage_inform(root_key, entity) + ink_env::set_contract_storage_return_size(root_key, entity) } /// Clears the entity from the contract storage using packed layout. From 24660275000165da8b7aac6980dbf1e1a8e19b81 Mon Sep 17 00:00:00 2001 From: Alexander Gryaznov Date: Mon, 20 Jun 2022 22:33:04 +0300 Subject: [PATCH 23/25] fmt --- crates/env/src/backend.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/crates/env/src/backend.rs b/crates/env/src/backend.rs index e7ca7606df..2c8f56207c 100644 --- a/crates/env/src/backend.rs +++ b/crates/env/src/backend.rs @@ -174,7 +174,11 @@ pub trait EnvBackend { /// /// 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(&mut self, key: &Key, value: &V) -> Option + fn set_contract_storage_return_size( + &mut self, + key: &Key, + value: &V, + ) -> Option where V: scale::Encode; From ddebf6c12d283589c297d45900f49682917d6b1e Mon Sep 17 00:00:00 2001 From: Alexander Gryaznov Date: Mon, 20 Jun 2022 23:07:10 +0300 Subject: [PATCH 24/25] spellcheck config fix --- .config/cargo_spellcheck.dic | 2 -- .config/cargo_spellcheck.toml | 1 + 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.config/cargo_spellcheck.dic b/.config/cargo_spellcheck.dic index eb424cac9b..6a430c8bc3 100644 --- a/.config/cargo_spellcheck.dic +++ b/.config/cargo_spellcheck.dic @@ -104,5 +104,3 @@ natively payability unpayable initializer - -^#[0-9a-fA-F]{5,}$ \ No newline at end of file diff --git a/.config/cargo_spellcheck.toml b/.config/cargo_spellcheck.toml index f5c0b7b3dc..58ceb4556f 100644 --- a/.config/cargo_spellcheck.toml +++ b/.config/cargo_spellcheck.toml @@ -16,3 +16,4 @@ use_builtin = true [Hunspell.quirks] allow_concatenation = true allow_dashes = true +transform_regex = ["^[0-9a-fA-F]{5,}$"] From 28ee702433e9b9fd96e092ada75182a5edbe9456 Mon Sep 17 00:00:00 2001 From: Hernando Castano Date: Tue, 21 Jun 2022 15:17:36 -0400 Subject: [PATCH 25/25] Small wording fixes --- RELEASES.md | 7 +++++-- crates/engine/src/ext.rs | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/RELEASES.md b/RELEASES.md index b3cea61f4d..6eb255b731 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -2,7 +2,7 @@ # Version 3.3.0 -This release restores SemVer compatibility in the 3.x series of releases, as well as +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`. @@ -18,7 +18,10 @@ to [0.16.0](https://github.com/paritytech/substrate-contracts-node/releases/tag/ The following has been done to restore backward compatibility: - Reverted backward-incompatible piece of [#1224](https://github.com/paritytech/ink/pull/1224). - - Under the hood this changed `Mapping::insert()` to use a new SEAL API + - The return signature of `ink_env::set_contract_storage()` was changed to return an + `Option`. 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))" diff --git a/crates/engine/src/ext.rs b/crates/engine/src/ext.rs index df003ac7ea..2a6cc01de1 100644 --- a/crates/engine/src/ext.rs +++ b/crates/engine/src/ext.rs @@ -249,7 +249,7 @@ impl Engine { /// /// # Note /// - /// This is an equivalent to the new [`set_storage`][`Self::set_storage`] method, + /// 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,