From 5030d89738ceaaaf8192b82bdcbfb9e449beeaea Mon Sep 17 00:00:00 2001 From: Lucas Grasso Date: Fri, 24 Oct 2025 00:09:12 -0300 Subject: [PATCH 01/24] implement `gas_limit` host fn --- crates/env/src/api.rs | 5 +++ crates/env/src/backend.rs | 7 +++++ .../env/src/engine/on_chain/pallet_revive.rs | 4 +++ crates/ink/src/env_access.rs | 31 +++++++++++++++++++ .../ink/tests/ui/contract/pass/env-access.rs | 2 ++ 5 files changed, 49 insertions(+) diff --git a/crates/env/src/api.rs b/crates/env/src/api.rs index c4d1aaacec3..728f057da77 100644 --- a/crates/env/src/api.rs +++ b/crates/env/src/api.rs @@ -73,6 +73,11 @@ pub fn caller() -> Address { ::on_instance(TypedEnvBackend::caller) } +/// Returns the block ref_time limit. +pub fn gas_limit() -> u64 { + ::on_instance(TypedEnvBackend::gas_limit) +} + /// Returns the transferred value for the contract execution. /// /// # Errors diff --git a/crates/env/src/backend.rs b/crates/env/src/backend.rs index 71e63a9a4df..8735e3c5f05 100644 --- a/crates/env/src/backend.rs +++ b/crates/env/src/backend.rs @@ -228,6 +228,13 @@ pub trait TypedEnvBackend: EnvBackend { /// For more details visit: [`caller`][`crate::caller`] fn caller(&mut self) -> Address; + /// Returns the block ref_time limit. + /// + /// # Note + /// + /// For more details visit: [`gas_limit`][`crate::gas_limit`] + fn gas_limit(&mut self) -> u64; + /// Returns the transferred value for the contract execution. /// /// # Note diff --git a/crates/env/src/engine/on_chain/pallet_revive.rs b/crates/env/src/engine/on_chain/pallet_revive.rs index e06196b0cc5..a61d1e83879 100644 --- a/crates/env/src/engine/on_chain/pallet_revive.rs +++ b/crates/env/src/engine/on_chain/pallet_revive.rs @@ -887,6 +887,10 @@ impl TypedEnvBackend for EnvInstance { .expect("The executed contract must have a caller with a valid account id.") } + fn gas_limit(&mut self) -> u64 { + ext::gas_limit() + } + fn transferred_value(&mut self) -> U256 { let mut scope = self.scoped_buffer(); let u256: &mut [u8; 32] = scope.take(32).try_into().unwrap(); diff --git a/crates/ink/src/env_access.rs b/crates/ink/src/env_access.rs index d0544b0c539..6d5f8b0c814 100644 --- a/crates/ink/src/env_access.rs +++ b/crates/ink/src/env_access.rs @@ -108,6 +108,37 @@ where ink_env::caller() } + /// Returns the block ref_time limit. + /// + /// # Example + /// + /// ``` + /// #[ink::contract] + /// mod my_contract { + /// #[ink(storage)] + /// pub struct MyContract; + /// + /// impl MyContract { + /// #[ink(constructor)] + /// pub fn new() -> Self { + /// Self {} + /// } + /// + /// #[ink(message)] + /// pub fn get_limit(&self) -> u64 { + /// self.env().gas_limit() + /// } + /// } + /// } + /// ``` + /// + /// # Note + /// + /// For more details visit: [`ink_env::gas_limit`] + pub fn gas_limit(self) -> u64 { + ink_env::gas_limit() + } + /// Returns the transferred value for the contract execution. /// /// # Example diff --git a/crates/ink/tests/ui/contract/pass/env-access.rs b/crates/ink/tests/ui/contract/pass/env-access.rs index ce657d817e1..764c47103c7 100644 --- a/crates/ink/tests/ui/contract/pass/env-access.rs +++ b/crates/ink/tests/ui/contract/pass/env-access.rs @@ -14,6 +14,7 @@ mod contract { let _ = Self::env().block_number(); let _ = Self::env().caller(); let _ = Self::env().minimum_balance(); + let _ = Self::env().gas_limit(); let _ = Self::env().transferred_value(); let _ = Self::env().weight_to_fee(0); Self {} @@ -27,6 +28,7 @@ mod contract { let _ = self.env().block_number(); let _ = self.env().caller(); let _ = self.env().minimum_balance(); + let _ = Self.env().gas_limit(); let _ = self.env().transferred_value(); let _ = self.env().weight_to_fee(0); } From f04d729c045988a9de691608d8a7337002341544 Mon Sep 17 00:00:00 2001 From: Lucas Grasso Date: Fri, 24 Oct 2025 01:05:07 -0300 Subject: [PATCH 02/24] add tests for `gas_limit` host fn --- .../internal/gas-hostfns/Cargo.toml | 27 ++++++++ integration-tests/internal/gas-hostfns/lib.rs | 68 +++++++++++++++++++ 2 files changed, 95 insertions(+) create mode 100755 integration-tests/internal/gas-hostfns/Cargo.toml create mode 100644 integration-tests/internal/gas-hostfns/lib.rs diff --git a/integration-tests/internal/gas-hostfns/Cargo.toml b/integration-tests/internal/gas-hostfns/Cargo.toml new file mode 100755 index 00000000000..7ee2db9bc72 --- /dev/null +++ b/integration-tests/internal/gas-hostfns/Cargo.toml @@ -0,0 +1,27 @@ +[package] +name = "gas_hostfns" +description = "E2E tests for gas related host functions" +version = "6.0.0-alpha.1" +authors = ["Use Ink "] +edition = "2021" +publish = false + +[dependencies] +ink = { path = "../../../crates/ink", default-features = false, features = ["unstable-hostfn"] } + +[dev-dependencies] +ink_e2e = { path = "../../../crates/e2e" } + +[lib] +path = "lib.rs" + +[features] +default = ["std"] +std = [ + "ink/std", +] +ink-as-dependency = [] +e2e-tests = [] + +[package.metadata.ink-lang] +abi = "ink" diff --git a/integration-tests/internal/gas-hostfns/lib.rs b/integration-tests/internal/gas-hostfns/lib.rs new file mode 100644 index 00000000000..abc1dc15029 --- /dev/null +++ b/integration-tests/internal/gas-hostfns/lib.rs @@ -0,0 +1,68 @@ +#![cfg_attr(not(feature = "std"), no_std, no_main)] +#![allow(clippy::new_without_default)] + +#[ink::contract] +mod gas_hostfns { + #[ink(storage)] + pub struct GasHostfns {} + + impl GasHostfns { + #[ink(constructor)] + pub fn new() -> Self { + Self {} + } + + /// Checks that the host function `gas_limit` works + #[ink(message)] + pub fn gas_limit(self) { + self.env.gas_limit() + } + } + + #[cfg(test)] + mod tests { + use super::*; + + #[ink::test] + fn works() { + let contract = GasHostfns::new(); + contract.gas_limit(); + } + } + + #[cfg(all(test, feature = "e2e-tests"))] + mod e2e_tests { + use super::*; + use ink_e2e::ContractsBackend; + + type E2EResult = std::result::Result>; + + #[ink_e2e::test] + async fn e2e_gas_limit_works( + mut client: Client, + ) -> E2EResult<()> { + // given + let contract = client + .instantiate( + "gas_hostfns", + &ink_e2e::alice(), + &mut GasHostfnsRef::new(), + ) + .submit() + .await + .expect("instantiate failed"); + let call_builder = contract.call_builder::(); + + // then + let _call_res = client + .call(&ink_e2e::alice(), &call_builder.gas_limit()) + .submit() + .await + .unwrap_or_else(|err| { + panic!("call failed: {:#?}", err); + }); + + Ok(()) + } + } +} From 0eec69da8eb6e3d2b346723ae8fcdc62359d2d4c Mon Sep 17 00:00:00 2001 From: Lucas Grasso Date: Fri, 24 Oct 2025 11:37:30 -0300 Subject: [PATCH 03/24] remove off-chain tests for `gas_limit` --- crates/env/src/engine/off_chain/impls.rs | 5 +++++ integration-tests/internal/gas-hostfns/lib.rs | 17 ++++------------- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/crates/env/src/engine/off_chain/impls.rs b/crates/env/src/engine/off_chain/impls.rs index 930b92164a0..cb88e8ca1b1 100644 --- a/crates/env/src/engine/off_chain/impls.rs +++ b/crates/env/src/engine/off_chain/impls.rs @@ -550,6 +550,11 @@ impl TypedEnvBackend for EnvInstance { .unwrap_or_else(|error| panic!("could not read `caller` property: {error:?}")) } + fn gas_limit(&mut self) -> u64 { + // Panic because of future depecration / removal + panic!(); + } + fn transferred_value(&mut self) -> U256 { self.get_property(Engine::value_transferred) .unwrap_or_else(|error| { diff --git a/integration-tests/internal/gas-hostfns/lib.rs b/integration-tests/internal/gas-hostfns/lib.rs index abc1dc15029..0711cc6fdd5 100644 --- a/integration-tests/internal/gas-hostfns/lib.rs +++ b/integration-tests/internal/gas-hostfns/lib.rs @@ -14,22 +14,11 @@ mod gas_hostfns { /// Checks that the host function `gas_limit` works #[ink(message)] - pub fn gas_limit(self) { - self.env.gas_limit() + pub fn gas_limit(&self) -> u64 { + self.env().gas_limit() } } - #[cfg(test)] - mod tests { - use super::*; - - #[ink::test] - fn works() { - let contract = GasHostfns::new(); - contract.gas_limit(); - } - } - #[cfg(all(test, feature = "e2e-tests"))] mod e2e_tests { use super::*; @@ -61,6 +50,8 @@ mod gas_hostfns { .unwrap_or_else(|err| { panic!("call failed: {:#?}", err); }); + + assert!(_call_res.return_value() > 0); Ok(()) } From 95162a99e6a35faba495c556e7c09f018e01d022 Mon Sep 17 00:00:00 2001 From: Lucas Grasso Date: Fri, 24 Oct 2025 11:45:21 -0300 Subject: [PATCH 04/24] add changes to changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 56489af38e5..99b18543920 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 [Unreleased] ### Added +- Implements the API for the `pallet-revive` host function `gas_limit` - [#2691](https://github.com/use-ink/ink/pull/2691) - Implements the API for the `pallet-revive` host function `to_account_id` - [#2578](https://github.com/use-ink/ink/pull/2578) - Add `#[ink::contract_ref]` attribute - [#2648](https://github.com/use-ink/ink/pull/2648) - Add `ink_revive_types` (and remove `pallet-revive` dependency from `ink_e2e`) - [#2657](https://github.com/use-ink/ink/pull/2657) From 1e63416f20ef29c675f7ffcee8bac2a6d4f223b9 Mon Sep 17 00:00:00 2001 From: Lucas Grasso Date: Sat, 25 Oct 2025 21:11:49 -0300 Subject: [PATCH 05/24] run formatting --- crates/env/src/api.rs | 2 +- crates/ink/src/env_access.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/env/src/api.rs b/crates/env/src/api.rs index 728f057da77..a72868452bf 100644 --- a/crates/env/src/api.rs +++ b/crates/env/src/api.rs @@ -75,7 +75,7 @@ pub fn caller() -> Address { /// Returns the block ref_time limit. pub fn gas_limit() -> u64 { - ::on_instance(TypedEnvBackend::gas_limit) + ::on_instance(TypedEnvBackend::gas_limit) } /// Returns the transferred value for the contract execution. diff --git a/crates/ink/src/env_access.rs b/crates/ink/src/env_access.rs index 6d5f8b0c814..4f990d84865 100644 --- a/crates/ink/src/env_access.rs +++ b/crates/ink/src/env_access.rs @@ -117,13 +117,13 @@ where /// mod my_contract { /// #[ink(storage)] /// pub struct MyContract; - /// + /// /// impl MyContract { /// #[ink(constructor)] /// pub fn new() -> Self { /// Self {} /// } - /// + /// /// #[ink(message)] /// pub fn get_limit(&self) -> u64 { /// self.env().gas_limit() From 9c3ab4177e2bc37790048f019fc743a51dfa82ba Mon Sep 17 00:00:00 2001 From: Lucas Grasso Date: Sat, 25 Oct 2025 21:24:33 -0300 Subject: [PATCH 06/24] fix error in env-access ui test --- crates/ink/tests/ui/contract/pass/env-access.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/ink/tests/ui/contract/pass/env-access.rs b/crates/ink/tests/ui/contract/pass/env-access.rs index 764c47103c7..e2afe0b8b40 100644 --- a/crates/ink/tests/ui/contract/pass/env-access.rs +++ b/crates/ink/tests/ui/contract/pass/env-access.rs @@ -28,7 +28,7 @@ mod contract { let _ = self.env().block_number(); let _ = self.env().caller(); let _ = self.env().minimum_balance(); - let _ = Self.env().gas_limit(); + let _ = self.env().gas_limit(); let _ = self.env().transferred_value(); let _ = self.env().weight_to_fee(0); } From e0c83515a2a6035c2ca6c8dfb846f8eaea903f55 Mon Sep 17 00:00:00 2001 From: Lucas Grasso Date: Mon, 27 Oct 2025 13:27:46 -0300 Subject: [PATCH 07/24] run formatting --- integration-tests/internal/gas-hostfns/lib.rs | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/integration-tests/internal/gas-hostfns/lib.rs b/integration-tests/internal/gas-hostfns/lib.rs index 0711cc6fdd5..88e46d5ec5d 100644 --- a/integration-tests/internal/gas-hostfns/lib.rs +++ b/integration-tests/internal/gas-hostfns/lib.rs @@ -12,11 +12,11 @@ mod gas_hostfns { Self {} } - /// Checks that the host function `gas_limit` works - #[ink(message)] - pub fn gas_limit(&self) -> u64 { - self.env().gas_limit() - } + /// Checks that the host function `gas_limit` works + #[ink(message)] + pub fn gas_limit(&self) -> u64 { + self.env().gas_limit() + } } #[cfg(all(test, feature = "e2e-tests"))] @@ -32,11 +32,7 @@ mod gas_hostfns { ) -> E2EResult<()> { // given let contract = client - .instantiate( - "gas_hostfns", - &ink_e2e::alice(), - &mut GasHostfnsRef::new(), - ) + .instantiate("gas_hostfns", &ink_e2e::alice(), &mut GasHostfnsRef::new()) .submit() .await .expect("instantiate failed"); @@ -50,7 +46,7 @@ mod gas_hostfns { .unwrap_or_else(|err| { panic!("call failed: {:#?}", err); }); - + assert!(_call_res.return_value() > 0); Ok(()) From eb2f8a327f87433969dfcbe1343067035f46bd26 Mon Sep 17 00:00:00 2001 From: Lucas Grasso Date: Tue, 28 Oct 2025 12:07:05 -0300 Subject: [PATCH 08/24] 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 --- crates/env/src/api.rs | 4 +++- crates/env/src/backend.rs | 2 +- crates/env/src/engine/off_chain/impls.rs | 3 +-- integration-tests/internal/gas-hostfns/lib.rs | 4 ++-- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/crates/env/src/api.rs b/crates/env/src/api.rs index a72868452bf..8490199e7dd 100644 --- a/crates/env/src/api.rs +++ b/crates/env/src/api.rs @@ -73,7 +73,9 @@ pub fn caller() -> Address { ::on_instance(TypedEnvBackend::caller) } -/// Returns the block ref_time limit. +/// Returns the block's `ref_time` limit. +/// +/// See for more information. pub fn gas_limit() -> u64 { ::on_instance(TypedEnvBackend::gas_limit) } diff --git a/crates/env/src/backend.rs b/crates/env/src/backend.rs index 8735e3c5f05..3c02d58efb2 100644 --- a/crates/env/src/backend.rs +++ b/crates/env/src/backend.rs @@ -228,7 +228,7 @@ pub trait TypedEnvBackend: EnvBackend { /// For more details visit: [`caller`][`crate::caller`] fn caller(&mut self) -> Address; - /// Returns the block ref_time limit. + /// Returns the block's `ref_time` limit. /// /// # Note /// diff --git a/crates/env/src/engine/off_chain/impls.rs b/crates/env/src/engine/off_chain/impls.rs index cb88e8ca1b1..c7b3cfcc2ae 100644 --- a/crates/env/src/engine/off_chain/impls.rs +++ b/crates/env/src/engine/off_chain/impls.rs @@ -551,8 +551,7 @@ impl TypedEnvBackend for EnvInstance { } fn gas_limit(&mut self) -> u64 { - // Panic because of future depecration / removal - panic!(); + unimplemented!("not implemented, the off-chain environment will be removed"); } fn transferred_value(&mut self) -> U256 { diff --git a/integration-tests/internal/gas-hostfns/lib.rs b/integration-tests/internal/gas-hostfns/lib.rs index 88e46d5ec5d..8c5046541ac 100644 --- a/integration-tests/internal/gas-hostfns/lib.rs +++ b/integration-tests/internal/gas-hostfns/lib.rs @@ -39,7 +39,7 @@ mod gas_hostfns { let call_builder = contract.call_builder::(); // then - let _call_res = client + let call_res = client .call(&ink_e2e::alice(), &call_builder.gas_limit()) .submit() .await @@ -47,7 +47,7 @@ mod gas_hostfns { panic!("call failed: {:#?}", err); }); - assert!(_call_res.return_value() > 0); + assert!(call_res.return_value() > 0); Ok(()) } From 4a1f7e3cca03d017f640f1ba8ab8dacc94e43f48 Mon Sep 17 00:00:00 2001 From: Lucas Grasso Date: Tue, 28 Oct 2025 12:08:21 -0300 Subject: [PATCH 09/24] update versions in gas and misc hostfns internal tests --- integration-tests/internal/gas-hostfns/Cargo.toml | 2 +- integration-tests/internal/misc-hostfns/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/integration-tests/internal/gas-hostfns/Cargo.toml b/integration-tests/internal/gas-hostfns/Cargo.toml index 7ee2db9bc72..e85364d40ba 100755 --- a/integration-tests/internal/gas-hostfns/Cargo.toml +++ b/integration-tests/internal/gas-hostfns/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "gas_hostfns" description = "E2E tests for gas related host functions" -version = "6.0.0-alpha.1" +version = "6.0.0-alpha.4" authors = ["Use Ink "] edition = "2021" publish = false diff --git a/integration-tests/internal/misc-hostfns/Cargo.toml b/integration-tests/internal/misc-hostfns/Cargo.toml index 27e7b955c88..8ec9020bdc9 100755 --- a/integration-tests/internal/misc-hostfns/Cargo.toml +++ b/integration-tests/internal/misc-hostfns/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "misc_hostfns" description = "E2E tests for various host functions" -version = "6.0.0-alpha.1" +version = "6.0.0-alpha.4" authors = ["Use Ink "] edition = "2021" publish = false From 21a5e466f5503d321ac0e552557a954e4d407ac0 Mon Sep 17 00:00:00 2001 From: Lucas Grasso Date: Tue, 28 Oct 2025 23:58:19 -0300 Subject: [PATCH 10/24] impl `gas_price` hostfn --- crates/env/src/api.rs | 5 +++ crates/env/src/backend.rs | 7 +++++ crates/env/src/engine/off_chain/impls.rs | 4 +++ .../env/src/engine/on_chain/pallet_revive.rs | 4 +++ crates/ink/src/env_access.rs | 31 +++++++++++++++++++ 5 files changed, 51 insertions(+) diff --git a/crates/env/src/api.rs b/crates/env/src/api.rs index 8490199e7dd..bbd3956491d 100644 --- a/crates/env/src/api.rs +++ b/crates/env/src/api.rs @@ -80,6 +80,11 @@ pub fn gas_limit() -> u64 { ::on_instance(TypedEnvBackend::gas_limit) } +/// Returns the simulated ethereum `GASPRICE` value. +pub fn gas_price() -> u64 { + ::on_instance(TypedEnvBackend::gas_price) +} + /// Returns the transferred value for the contract execution. /// /// # Errors diff --git a/crates/env/src/backend.rs b/crates/env/src/backend.rs index 3c02d58efb2..0f3056d9cd8 100644 --- a/crates/env/src/backend.rs +++ b/crates/env/src/backend.rs @@ -235,6 +235,13 @@ pub trait TypedEnvBackend: EnvBackend { /// For more details visit: [`gas_limit`][`crate::gas_limit`] fn gas_limit(&mut self) -> u64; + /// Returns the simulated ethereum `GASPRICE` value. + /// + /// # Note + /// + /// For more details visit: [`gas_price`][`crate::gas_price`] + fn gas_price(&mut self) -> u64; + /// Returns the transferred value for the contract execution. /// /// # Note diff --git a/crates/env/src/engine/off_chain/impls.rs b/crates/env/src/engine/off_chain/impls.rs index c7b3cfcc2ae..9fd6e3bcb45 100644 --- a/crates/env/src/engine/off_chain/impls.rs +++ b/crates/env/src/engine/off_chain/impls.rs @@ -554,6 +554,10 @@ impl TypedEnvBackend for EnvInstance { unimplemented!("not implemented, the off-chain environment will be removed"); } + fn gas_price(&mut self) -> u64 { + unimplemented!("not implemented, the off-chain environment will be removed"); + } + fn transferred_value(&mut self) -> U256 { self.get_property(Engine::value_transferred) .unwrap_or_else(|error| { diff --git a/crates/env/src/engine/on_chain/pallet_revive.rs b/crates/env/src/engine/on_chain/pallet_revive.rs index a61d1e83879..81940f08612 100644 --- a/crates/env/src/engine/on_chain/pallet_revive.rs +++ b/crates/env/src/engine/on_chain/pallet_revive.rs @@ -891,6 +891,10 @@ impl TypedEnvBackend for EnvInstance { ext::gas_limit() } + fn gas_price(&mut self) -> u64 { + ext::gas_price() + } + fn transferred_value(&mut self) -> U256 { let mut scope = self.scoped_buffer(); let u256: &mut [u8; 32] = scope.take(32).try_into().unwrap(); diff --git a/crates/ink/src/env_access.rs b/crates/ink/src/env_access.rs index 4f990d84865..27a4c785fcd 100644 --- a/crates/ink/src/env_access.rs +++ b/crates/ink/src/env_access.rs @@ -139,6 +139,37 @@ where ink_env::gas_limit() } + /// Returns the simulated ethereum `GASPRICE` value. + /// + /// # Example + /// + /// ``` + /// #[ink::contract] + /// mod my_contract { + /// #[ink(storage)] + /// pub struct MyContract; + /// + /// impl MyContract { + /// #[ink(constructor)] + /// pub fn new() -> Self { + /// Self {} + /// } + /// + /// #[ink(message)] + /// pub fn get_gas_price(&self) -> u64 { + /// self.env().gas_price() + /// } + /// } + /// } + /// ``` + /// + /// # Note + /// + /// For more details visit: [`ink_env::gas_price`] + pub fn gas_price(self) -> u64 { + ink_env::gas_price() + } + /// Returns the transferred value for the contract execution. /// /// # Example From be3bf7aeda864b4e9d6ee1d29c029f28cebfd0b2 Mon Sep 17 00:00:00 2001 From: Lucas Grasso Date: Wed, 29 Oct 2025 00:01:51 -0300 Subject: [PATCH 11/24] test `gas_price` hostfn --- .../ink/tests/ui/contract/pass/env-access.rs | 2 ++ integration-tests/internal/gas-hostfns/lib.rs | 32 +++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/crates/ink/tests/ui/contract/pass/env-access.rs b/crates/ink/tests/ui/contract/pass/env-access.rs index e2afe0b8b40..699d69260b9 100644 --- a/crates/ink/tests/ui/contract/pass/env-access.rs +++ b/crates/ink/tests/ui/contract/pass/env-access.rs @@ -15,6 +15,7 @@ mod contract { let _ = Self::env().caller(); let _ = Self::env().minimum_balance(); let _ = Self::env().gas_limit(); + let _ = Self::env().gas_price(); let _ = Self::env().transferred_value(); let _ = Self::env().weight_to_fee(0); Self {} @@ -29,6 +30,7 @@ mod contract { let _ = self.env().caller(); let _ = self.env().minimum_balance(); let _ = self.env().gas_limit(); + let _ = self.env().gas_price(); let _ = self.env().transferred_value(); let _ = self.env().weight_to_fee(0); } diff --git a/integration-tests/internal/gas-hostfns/lib.rs b/integration-tests/internal/gas-hostfns/lib.rs index 8c5046541ac..a33afd30d96 100644 --- a/integration-tests/internal/gas-hostfns/lib.rs +++ b/integration-tests/internal/gas-hostfns/lib.rs @@ -17,6 +17,12 @@ mod gas_hostfns { pub fn gas_limit(&self) -> u64 { self.env().gas_limit() } + + /// Checks that the host function `gas_price` works + #[ink(message)] + pub fn gas_price(&self) -> u64 { + self.env().gas_price() + } } #[cfg(all(test, feature = "e2e-tests"))] @@ -51,5 +57,31 @@ mod gas_hostfns { Ok(()) } + + #[ink_e2e::test] + async fn e2e_gas_price_works( + mut client: Client, + ) -> E2EResult<()> { + // given + let contract = client + .instantiate("gas_hostfns", &ink_e2e::alice(), &mut GasHostfnsRef::new()) + .submit() + .await + .expect("instantiate failed"); + let call_builder = contract.call_builder::(); + + // then + let call_res = client + .call(&ink_e2e::alice(), &call_builder.gas_price()) + .submit() + .await + .unwrap_or_else(|err| { + panic!("call failed: {:#?}", err); + }); + + assert!(call_res.return_value() > 0); + + Ok(()) + } } } From b707359c14a95d19144661f9e7e673236580f6c8 Mon Sep 17 00:00:00 2001 From: Lucas Grasso Date: Wed, 29 Oct 2025 00:16:18 -0300 Subject: [PATCH 12/24] add changes to changelog --- CHANGELOG.md | 1518 +++++++++++++++++++++++++++----------------------- 1 file changed, 835 insertions(+), 683 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 99b18543920..8abd6ae3048 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,5 @@ # Changelog + All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), @@ -7,103 +8,117 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 [Unreleased] ### Added -- Implements the API for the `pallet-revive` host function `gas_limit` - [#2691](https://github.com/use-ink/ink/pull/2691) -- Implements the API for the `pallet-revive` host function `to_account_id` - [#2578](https://github.com/use-ink/ink/pull/2578) -- Add `#[ink::contract_ref]` attribute - [#2648](https://github.com/use-ink/ink/pull/2648) -- Add `ink_revive_types` (and remove `pallet-revive` dependency from `ink_e2e`) - [#2657](https://github.com/use-ink/ink/pull/2657) -- non-allocating Solidity ABI encoder - [#2655](https://github.com/use-ink/ink/pull/2655) + +- Implements the API for the `pallet-revive` host functions `gas_price`, `call_data_size`, `return_data_size`, `ref_time_left` - [#2694](https://github.com/use-ink/ink/pull/2694) +- Implements the API for the `pallet-revive` host function `gas_limit` - [#2691](https://github.com/use-ink/ink/pull/2691) +- Implements the API for the `pallet-revive` host function `to_account_id` - [#2578](https://github.com/use-ink/ink/pull/2578) +- Add `#[ink::contract_ref]` attribute - [#2648](https://github.com/use-ink/ink/pull/2648) +- Add `ink_revive_types` (and remove `pallet-revive` dependency from `ink_e2e`) - [#2657](https://github.com/use-ink/ink/pull/2657) +- non-allocating Solidity ABI encoder - [#2655](https://github.com/use-ink/ink/pull/2655) ### Changed -- Marks the `pallet-revive` host function `account_id` stable - [#2578](https://github.com/use-ink/ink/pull/2578) -- Stabilize `is_contract` - [#2654](https://github.com/use-ink/ink/pull/2654) -- Extract `sandbox` from `ink_e2e` into a new `ink_sandbox` crate - [#2659](https://github.com/use-ink/ink/pull/2659) -- Synchronize with `polkadot-sdk/1b1cef306d9ceebf963fd15a04b5c79ee2618bce` ‒ [2675](https://github.com/use-ink/ink/pull/2675) -- Refactor `AbiEncodeWith::encode_to_slice` - [#2676](https://github.com/use-ink/ink/pull/2676) -- Refactor `ArgumentList` encoding and abstractions - [#2678](https://github.com/use-ink/ink/pull/2678) -- More flexible `SolEncode` implementation for `ByteSlice` - [#2681](https://github.com/use-ink/ink/pull/2681) -- Synchronize with `polkadot-sdk/cbab8ed4be1941420dd25dc81102fb79d8e2a7f0` ‒ [2689](https://github.com/use-ink/ink/pull/2689) + +- Marks the `pallet-revive` host function `account_id` stable - [#2578](https://github.com/use-ink/ink/pull/2578) +- Stabilize `is_contract` - [#2654](https://github.com/use-ink/ink/pull/2654) +- Extract `sandbox` from `ink_e2e` into a new `ink_sandbox` crate - [#2659](https://github.com/use-ink/ink/pull/2659) +- Synchronize with `polkadot-sdk/1b1cef306d9ceebf963fd15a04b5c79ee2618bce` ‒ [2675](https://github.com/use-ink/ink/pull/2675) +- Refactor `AbiEncodeWith::encode_to_slice` - [#2676](https://github.com/use-ink/ink/pull/2676) +- Refactor `ArgumentList` encoding and abstractions - [#2678](https://github.com/use-ink/ink/pull/2678) +- More flexible `SolEncode` implementation for `ByteSlice` - [#2681](https://github.com/use-ink/ink/pull/2681) +- Synchronize with `polkadot-sdk/cbab8ed4be1941420dd25dc81102fb79d8e2a7f0` ‒ [2689](https://github.com/use-ink/ink/pull/2689) ### Fixed -- Fix decoding of `HostFn::minimum_balance` return value - [#2656](https://github.com/use-ink/ink/pull/2656) -- Fix handling of `HostFn::code_hash` and `HostFn::weight_to_fee` - [#2672](https://github.com/use-ink/ink/pull/2672) -- `name` override fixes for message id computation and trait definitions - [#2649](https://github.com/use-ink/ink/pull/2649) -- Add hotfix for `generic-array` breakage ([issue](https://github.com/fizyk20/generic-array/issues/158)) - [#2688](https://github.com/use-ink/ink/pull/2688) + +- Fix decoding of `HostFn::minimum_balance` return value - [#2656](https://github.com/use-ink/ink/pull/2656) +- Fix handling of `HostFn::code_hash` and `HostFn::weight_to_fee` - [#2672](https://github.com/use-ink/ink/pull/2672) +- `name` override fixes for message id computation and trait definitions - [#2649](https://github.com/use-ink/ink/pull/2649) +- Add hotfix for `generic-array` breakage ([issue](https://github.com/fizyk20/generic-array/issues/158)) - [#2688](https://github.com/use-ink/ink/pull/2688) ## Version 6.0.0-alpha.4 ### Added -- Add integration test for arithmetic overflow checks - [#2631](https://github.com/use-ink/ink/pull/2631) -- E2E: Misc quality of life improvements, new API functions, better debuggability ‒ [2634](https://github.com/use-ink/ink/pull/2634) + +- Add integration test for arithmetic overflow checks - [#2631](https://github.com/use-ink/ink/pull/2631) +- E2E: Misc quality of life improvements, new API functions, better debuggability ‒ [2634](https://github.com/use-ink/ink/pull/2634) ### Changed -- Error on message and constructor `selector` overrides in Solidity ABI mode - [#2638](https://github.com/use-ink/ink/pull/2638) -- Improve abstractions for Solidity ABI encoding `Result` types - [#2635](https://github.com/use-ink/ink/pull/2635) -- Feature gate `xcm` - [#2641](https://github.com/use-ink/ink/pull/2641) -- Refactor multi ABI interfaces for event emission via `ink_env` - [#2643](https://github.com/use-ink/ink/pull/2643) + +- Error on message and constructor `selector` overrides in Solidity ABI mode - [#2638](https://github.com/use-ink/ink/pull/2638) +- Improve abstractions for Solidity ABI encoding `Result` types - [#2635](https://github.com/use-ink/ink/pull/2635) +- Feature gate `xcm` - [#2641](https://github.com/use-ink/ink/pull/2641) +- Refactor multi ABI interfaces for event emission via `ink_env` - [#2643](https://github.com/use-ink/ink/pull/2643) ### Fixed -- Bring intended panic handler behavior back ‒ [2636](https://github.com/use-ink/ink/pull/2636) -- Support `name` attribute in trait definitions - [#2644](https://github.com/use-ink/ink/pull/2644) + +- Bring intended panic handler behavior back ‒ [2636](https://github.com/use-ink/ink/pull/2636) +- Support `name` attribute in trait definitions - [#2644](https://github.com/use-ink/ink/pull/2644) ## Version 6.0.0-alpha.3 Compatibility of this release: -* Rust >= 1.88 -* [`cargo-contract` `v6.0.0-alpha.3`](https://github.com/use-ink/cargo-contract/releases/tag/v6.0.0-alpha.3) -* [`ink-node` `v0.45.1`](https://github.com/use-ink/ink-node/releases/tag/v0.45.1) -* [`polkadot-sdk` from `use-ink/polkadot-sdk/a71ec19a94702ea71767ba5ac97603ea6c6305c1`](https://github.com/use-ink/polkadot-sdk/tree/pallet-revive-with-system-and-storage-precompiles) +- Rust >= 1.88 +- [`cargo-contract` `v6.0.0-alpha.3`](https://github.com/use-ink/cargo-contract/releases/tag/v6.0.0-alpha.3) +- [`ink-node` `v0.45.1`](https://github.com/use-ink/ink-node/releases/tag/v0.45.1) +- [`polkadot-sdk` from `use-ink/polkadot-sdk/a71ec19a94702ea71767ba5ac97603ea6c6305c1`](https://github.com/use-ink/polkadot-sdk/tree/pallet-revive-with-system-and-storage-precompiles) We have to use a slight fork of `polkadot-sdk` for the moment. It's just `polkadot-sdk/master` plus two commits on top with pre-compiles. Those two commits are PRs to `polkadot-sdk`. but haven't been merged yet. ### Added -- Support functions of the `Storage` and `System` pre-compiles ‒ [2619](https://github.com/use-ink/ink/pull/2619) + +- Support functions of the `Storage` and `System` pre-compiles ‒ [2619](https://github.com/use-ink/ink/pull/2619) ### Changed -- Synchronize with `polkadot-sdk/c40b36c3a7c208f9a6837b80812473af3d9ba7f7` ‒ [2589](https://github.com/use-ink/ink/pull/2589) -- Synchronize with `polkadot-sdk/a71ec19a94702ea71767ba5ac97603ea6c6305c1` ‒ [2619](https://github.com/use-ink/ink/pull/2619) -- Refactor multi ABI interfaces - [#2618](https://github.com/use-ink/ink/pull/2618) -- Upgrade to Rust edition 2024 - [#2624](https://github.com/use-ink/ink/pull/2624) + +- Synchronize with `polkadot-sdk/c40b36c3a7c208f9a6837b80812473af3d9ba7f7` ‒ [2589](https://github.com/use-ink/ink/pull/2589) +- Synchronize with `polkadot-sdk/a71ec19a94702ea71767ba5ac97603ea6c6305c1` ‒ [2619](https://github.com/use-ink/ink/pull/2619) +- Refactor multi ABI interfaces - [#2618](https://github.com/use-ink/ink/pull/2618) +- Upgrade to Rust edition 2024 - [#2624](https://github.com/use-ink/ink/pull/2624) ### Removed -- Removed functionalities around calling into the runtime and chain extensions ‒ [2621](https://github.com/use-ink/ink/pull/2621) -- Remove `Environment::MAX_EVENT_TOPICS` and remove `Environment` generic type from event abstractions - [#2622](https://github.com/use-ink/ink/pull/2622) + +- Removed functionalities around calling into the runtime and chain extensions ‒ [2621](https://github.com/use-ink/ink/pull/2621) +- Remove `Environment::MAX_EVENT_TOPICS` and remove `Environment` generic type from event abstractions - [#2622](https://github.com/use-ink/ink/pull/2622) ### Fixed -- E2E: Fixes around correct handling of storage deposit limit ‒ [#2589](https://github.com/use-ink/ink/pull/2589) -- Make `NativeToEthRatio` part of the `Environment` ‒ [#2604](https://github.com/use-ink/ink/pull/2604) -- E2E: Fix `ink_sandbox` gating - [#2626](https://github.com/use-ink/ink/pull/2626) + +- E2E: Fixes around correct handling of storage deposit limit ‒ [#2589](https://github.com/use-ink/ink/pull/2589) +- Make `NativeToEthRatio` part of the `Environment` ‒ [#2604](https://github.com/use-ink/ink/pull/2604) +- E2E: Fix `ink_sandbox` gating - [#2626](https://github.com/use-ink/ink/pull/2626) ## Version 6.0.0-alpha.1 ### Added -- Support ABI `cfg` flag in codegen - [#2501](https://github.com/use-ink/ink/pull/2501) -- Generate Solidity ABI compatibility metadata - [#2510](https://github.com/use-ink/ink/pull/2510) -- Improve Solidity ABI support in `codegen`, `ink_env` and `ink_e2e` - [#2517](https://github.com/use-ink/ink/pull/2517) -- Support Solidity ABI encoded constructor dispatch - [#2525](https://github.com/use-ink/ink/pull/2525) -- Export `Weight` with Solidity encoding - [#2540](https://github.com/use-ink/ink/pull/2540) -- Implement `SolEncode` and `SolDecode` for generated contract refs, call and message builders - [#2539](https://github.com/use-ink/ink/pull/2539) -- Abstractions for mapping Rust/ink! `Result` and error types to/from Solidity ABI error and result representations - [#2543](https://github.com/use-ink/ink/pull/2543) -- `Derive` macros for implementing `SolEncode` and `SolDecode` for arbitrary types - [#2549](https://github.com/use-ink/ink/pull/2549) -- Improve handling of Solidity constructor return and revert data - [#2552](https://github.com/use-ink/ink/pull/2552) -- Implement `SolEncode` and `SolDecode` for `Option` - [#2545](https://github.com/use-ink/ink/pull/2545) -- Allow writing E2E fuzz tests for contracts - [#2570](https://github.com/use-ink/ink/pull/2570) -- Item name/identifier overrides for overloading, selector computation and metadata - [#2577](https://github.com/use-ink/ink/pull/2577) -- Add custom errors to Solidity compatible metadata - [#2583](https://github.com/use-ink/ink/pull/2583) -- Efficient conversions and representations for byte sequence references for Solidity ABI encoding/decoding - [#2590](https://github.com/use-ink/ink/pull/2590) -- Add `#[ink::error]` attribute macro - [#2585](https://github.com/use-ink/ink/pull/2585) + +- Support ABI `cfg` flag in codegen - [#2501](https://github.com/use-ink/ink/pull/2501) +- Generate Solidity ABI compatibility metadata - [#2510](https://github.com/use-ink/ink/pull/2510) +- Improve Solidity ABI support in `codegen`, `ink_env` and `ink_e2e` - [#2517](https://github.com/use-ink/ink/pull/2517) +- Support Solidity ABI encoded constructor dispatch - [#2525](https://github.com/use-ink/ink/pull/2525) +- Export `Weight` with Solidity encoding - [#2540](https://github.com/use-ink/ink/pull/2540) +- Implement `SolEncode` and `SolDecode` for generated contract refs, call and message builders - [#2539](https://github.com/use-ink/ink/pull/2539) +- Abstractions for mapping Rust/ink! `Result` and error types to/from Solidity ABI error and result representations - [#2543](https://github.com/use-ink/ink/pull/2543) +- `Derive` macros for implementing `SolEncode` and `SolDecode` for arbitrary types - [#2549](https://github.com/use-ink/ink/pull/2549) +- Improve handling of Solidity constructor return and revert data - [#2552](https://github.com/use-ink/ink/pull/2552) +- Implement `SolEncode` and `SolDecode` for `Option` - [#2545](https://github.com/use-ink/ink/pull/2545) +- Allow writing E2E fuzz tests for contracts - [#2570](https://github.com/use-ink/ink/pull/2570) +- Item name/identifier overrides for overloading, selector computation and metadata - [#2577](https://github.com/use-ink/ink/pull/2577) +- Add custom errors to Solidity compatible metadata - [#2583](https://github.com/use-ink/ink/pull/2583) +- Efficient conversions and representations for byte sequence references for Solidity ABI encoding/decoding - [#2590](https://github.com/use-ink/ink/pull/2590) +- Add `#[ink::error]` attribute macro - [#2585](https://github.com/use-ink/ink/pull/2585) ### Changed -- Use marker trait for finding ink! storage `struct` during code analysis - [2499](https://github.com/use-ink/ink/pull/2499) -- Solidity ABI compatibility metadata improvements - [#2511](https://github.com/use-ink/ink/pull/2511) -- Share intermediate build artifacts across all contract builds in e2e tests - [#2531](https://github.com/use-ink/ink/pull/2531) -- Refactor Solidity bytes wrapper(s) - [#2569](https://github.com/use-ink/ink/pull/2569) -- Refactor events for `pallet-revive` and multiple ABI support - [#2580](https://github.com/use-ink/ink/pull/2580) + +- Use marker trait for finding ink! storage `struct` during code analysis - [2499](https://github.com/use-ink/ink/pull/2499) +- Solidity ABI compatibility metadata improvements - [#2511](https://github.com/use-ink/ink/pull/2511) +- Share intermediate build artifacts across all contract builds in e2e tests - [#2531](https://github.com/use-ink/ink/pull/2531) +- Refactor Solidity bytes wrapper(s) - [#2569](https://github.com/use-ink/ink/pull/2569) +- Refactor events for `pallet-revive` and multiple ABI support - [#2580](https://github.com/use-ink/ink/pull/2580) ### Fixed -- Update metadata version to version 6 ‒ [#2507](https://github.com/use-ink/ink/pull/2507) -- Ensure immutable messages are not payable - [#2535](https://github.com/use-ink/ink/pull/2535) + +- Update metadata version to version 6 ‒ [#2507](https://github.com/use-ink/ink/pull/2507) +- Ensure immutable messages are not payable - [#2535](https://github.com/use-ink/ink/pull/2535) ## Version 6.0.0-alpha @@ -121,10 +136,11 @@ We did a detailed write-up of the background to this development and the reasoni to reflect the new setup. Compatibility of this release: -* Rust >= 1.86 -* [`cargo-contract` `v6.0.0-alpha`](https://github.com/use-ink/cargo-contract/releases/tag/v6.0.0-alpha) -* [`ink-node/5f93093`](https://github.com/use-ink/ink-node/commit/5f93093dcffbbd2c2e44bfd2e457dc418c844623) -* [`polkadot-sdk/stable2503`](https://github.com/paritytech/polkadot-sdk/tree/stable2503) + +- Rust >= 1.86 +- [`cargo-contract` `v6.0.0-alpha`](https://github.com/use-ink/cargo-contract/releases/tag/v6.0.0-alpha) +- [`ink-node/5f93093`](https://github.com/use-ink/ink-node/commit/5f93093dcffbbd2c2e44bfd2e457dc418c844623) +- [`polkadot-sdk/stable2503`](https://github.com/paritytech/polkadot-sdk/tree/stable2503) In the following we'll describe some breaking changes on a high-level. The context to understand them is that the `pallet-revive` team has Ethereum/Solidity @@ -134,6 +150,7 @@ they don't want to maintain code that is unnecessary for that objective. _🚧 This is an alpha release, changes will still happen and there are rough edges. 🚧_ ### Cross-contract calling Solidity contracts + We are introducing a new attribute `abi` for the `#[ink::contract]` macro. These are the values it takes: @@ -157,15 +174,18 @@ and Solidity ABI. ### Types #### Contract Balance: `U256` + For the type of a contract's balance, `pallet-revive` uses depending on the context -* either the configured `pallet_revive::Config::Currency` type (which corresponds - to the `ink::Environment::Balance` type. -* or a hardcoded `U256` (which corresponds to what Ethereum uses). - In this alpha release we just adhere to requiring the types that `pallet-revive` uses. - In an upcoming beta release this could be simplified to reduce UX friction by just - using one type everywhere and converting to the `pallet-revive` one. + +- either the configured `pallet_revive::Config::Currency` type (which corresponds + to the `ink::Environment::Balance` type. +- or a hardcoded `U256` (which corresponds to what Ethereum uses). + In this alpha release we just adhere to requiring the types that `pallet-revive` uses. + In an upcoming beta release this could be simplified to reduce UX friction by just + using one type everywhere and converting to the `pallet-revive` one. #### Contract Address: `Address` / `H160` + For a contract's account, `pallet-revive` is using either the configured `AccountId` type of the `polkadot-sdk` runtime, or `H160`. @@ -189,11 +209,13 @@ Besides the publicly exposed crate functions, we've introduced a new subcommand Substrate `AccountId` which it is mapped to. #### Contract Hash: `H256` + For a contract's hash value, `pallet-revive` uses a fixed `H256`, Previously, the `ink::Environment::Hash` type referenced the hash type being used for the contract's hash. Now it's just a fixed `H256`. ### Contract delegates can no longer be done by code + In `pallet-contracts` (and hence up until ink! v5), a pattern for upgradeable contracts was to delegate the contract execution to a different code, e.g. to a new version of the contract's code. @@ -229,6 +251,7 @@ pub struct DelegateCall { ``` ### Feature `ink/unstable-hostfn` + In `pallet-revive` a number of functions can only be called by smart contracts if the chain that the pallet is running on has enabled the feature `pallet-revive/unstable-hostfn`. @@ -237,6 +260,7 @@ This feature is not enabled on Kusama or Westend! It is enabled for the `substrate-contracts-node` version that we linked above. ### New debugging workflow + Previously `pallet-contracts` returned a `debug_message` field with contract instantiations and dry-runs. Whenever `ink::env::debug_println` was invoked in a contract, ink! wrote debugging @@ -264,11 +288,12 @@ that would not be visible in the metadata (so e.g. on a block explorer). The relevant PR is [#2313](https://github.com/use-ink/ink/pull/2313). From ink! 6.0 on only these attributes are allowed in `#[cfg(…)]`: -- `test` -- `feature` (without `std`) -- `any` -- `not` -- `all` + +- `test` +- `feature` (without `std`) +- `any` +- `not` +- `all` ### Metadata Changes @@ -301,6 +326,7 @@ entry point for your smart contract. This is needed because PolkaVM uses a diffe entry point (the `deploy` function). ### `substrate-contracts-node` can no longer be used + The `substrate-contracts-node` is still maintained by Parity for ink! v5 and `pallet-contracts`, but it does not support `pallet-revive`. @@ -310,27 +336,30 @@ It contains `pallet-revive` in a default configuration. You can find binary releases of the node [here](https://github.com/use-ink/ink-node/releases). ### Changed -- Restrict which `cfg` attributes can be used ‒ [#2313](https://github.com/use-ink/ink/pull/2313) -- More idiomatic return types for metadata getters - [#2398](https://github.com/use-ink/ink/pull/2398) -- Define static distributed events slice in `ink` crate - [#2487](https://github.com/use-ink/ink/pull/2487) -- [E2E] Update `subxt` dependencies ‒ [#2504](https://github.com/use-ink/ink/pull/2504) + +- Restrict which `cfg` attributes can be used ‒ [#2313](https://github.com/use-ink/ink/pull/2313) +- More idiomatic return types for metadata getters - [#2398](https://github.com/use-ink/ink/pull/2398) +- Define static distributed events slice in `ink` crate - [#2487](https://github.com/use-ink/ink/pull/2487) +- [E2E] Update `subxt` dependencies ‒ [#2504](https://github.com/use-ink/ink/pull/2504) ### Added -- Support for `caller_is_root` - [#2332](https://github.com/use-ink/ink/pull/2332) -- Allow setting features for contract build in E2E tests - [#2460](https://github.com/use-ink/ink/pull/2460) -- Improve support for Solidity ABI calling conventions - [#2411](https://github.com/use-ink/ink/pull/2411) -- Implement contract invocation in off-chain environment engine - [#1957](https://github.com/paritytech/ink/pull/1988) -- Abstractions for mapping arbitrary Rust types to Solidity ABI compatible types - [#2441](https://github.com/use-ink/ink/pull/2441) -- Documentation for contract abi arg and provided Rust/ink! to Solidity type mappings - [2463](https://github.com/use-ink/ink/pull/2463) -- Implement `SolDecode`, `SolTypeDecode` and support `SolBytes` for boxed slices - [2476](https://github.com/use-ink/ink/pull/2476) + +- Support for `caller_is_root` - [#2332](https://github.com/use-ink/ink/pull/2332) +- Allow setting features for contract build in E2E tests - [#2460](https://github.com/use-ink/ink/pull/2460) +- Improve support for Solidity ABI calling conventions - [#2411](https://github.com/use-ink/ink/pull/2411) +- Implement contract invocation in off-chain environment engine - [#1957](https://github.com/paritytech/ink/pull/1988) +- Abstractions for mapping arbitrary Rust types to Solidity ABI compatible types - [#2441](https://github.com/use-ink/ink/pull/2441) +- Documentation for contract abi arg and provided Rust/ink! to Solidity type mappings - [2463](https://github.com/use-ink/ink/pull/2463) +- Implement `SolDecode`, `SolTypeDecode` and support `SolBytes` for boxed slices - [2476](https://github.com/use-ink/ink/pull/2476) ### Fixed -- [E2E] Have port parsing handle comma-separated list ‒ [#2336](https://github.com/use-ink/ink/pull/2336) -- Always use ink! ABI/ SCALE codec for constructor and instantiation related builders and utilities - [#2474](https://github.com/use-ink/ink/pull/2474) -- Get rid of "extrinsic for call failed: Pallet error: Revive::AccountAlreadyMapped" - [2483](https://github.com/use-ink/ink/pull/2483) -- CI disk usage via standardised toolchains: `stable` 1.86, `nightly` 2025-02-20 - [#2484](https://github.com/use-ink/ink/pull/2484) -- CI contract size submission - [#2490](https://github.com/use-ink/ink/pull/2490) -- CI relax criteria for `measurements-master` artifact lookup - [#2491](https://github.com/use-ink/ink/pull/2491) + +- [E2E] Have port parsing handle comma-separated list ‒ [#2336](https://github.com/use-ink/ink/pull/2336) +- Always use ink! ABI/ SCALE codec for constructor and instantiation related builders and utilities - [#2474](https://github.com/use-ink/ink/pull/2474) +- Get rid of "extrinsic for call failed: Pallet error: Revive::AccountAlreadyMapped" - [2483](https://github.com/use-ink/ink/pull/2483) +- CI disk usage via standardised toolchains: `stable` 1.86, `nightly` 2025-02-20 - [#2484](https://github.com/use-ink/ink/pull/2484) +- CI contract size submission - [#2490](https://github.com/use-ink/ink/pull/2490) +- CI relax criteria for `measurements-master` artifact lookup - [#2491](https://github.com/use-ink/ink/pull/2491) ## Version 5.1.0 @@ -365,8 +394,8 @@ We also added a new page on our documentation website: You can view the Rust docs of the two functions here: -* [`xcm_send`](https://docs.rs/ink_env/5.1.0/ink_env/fn.xcm_send.html) -* [`xcm_execute`](https://docs.rs/ink_env/5.1.0/ink_env/fn.xcm_execute.html) +- [`xcm_send`](https://docs.rs/ink_env/5.1.0/ink_env/fn.xcm_send.html) +- [`xcm_execute`](https://docs.rs/ink_env/5.1.0/ink_env/fn.xcm_execute.html) #### (2) Call an ink! contract from a `polkadot-sdk` runtime @@ -381,11 +410,11 @@ faster development iteration cycles. The limitations currently are: -* Contract calls can only be made to trait messages. This makes sense in the - `pallet-contracts` context, as it is better to depend on a trait rather - than a contract impl, since you are working against an interface. -* Only contract messages can be called currently, no constructors. -* The API could be nicer. +- Contract calls can only be made to trait messages. This makes sense in the + `pallet-contracts` context, as it is better to depend on a trait rather + than a contract impl, since you are working against an interface. +- Only contract messages can be called currently, no constructors. +- The API could be nicer. #### (3) E2E Testing @@ -409,12 +438,12 @@ Second, these are the two changes you have to make: The compatibility changes a bit to ink! 5.0: -- Rust: `>= 1.81` -- `cargo-contract`: `>= 5.0.0` -- `polkadot-sdk`: [>= v1.12.0](https://github.com/paritytech/polkadot-sdk/releases/tag/polkadot-v1.12.0) - (this release stabilized the `pallet-contracts` XCM functions that ink! uses) -- `substrate-contracts-node`: `>= 0.42.0` -- [DRink!](https://github.com/inkdevhub/drink): `>= 0.18.0` +- Rust: `>= 1.81` +- `cargo-contract`: `>= 5.0.0` +- `polkadot-sdk`: [>= v1.12.0](https://github.com/paritytech/polkadot-sdk/releases/tag/polkadot-v1.12.0) + (this release stabilized the `pallet-contracts` XCM functions that ink! uses) +- `substrate-contracts-node`: `>= 0.42.0` +- [DRink!](https://github.com/inkdevhub/drink): `>= 0.18.0` For the linter in `cargo-contract` the Rust toolchain version changed. To upgrade: @@ -427,27 +456,30 @@ rustup run $TOOLCHAIN_VERSION cargo install cargo-dylint dylint-link ``` ### Added -- [Runtime-to-Contract Calls] Environment agnostic contract invocation API, for calling contracts from runtime ‒ [#2219](https://github.com/use-ink/ink/pull/2219) -- [Runtime-to-Contract Calls] Add `no-panic-handler` feature ‒ [#2164](https://github.com/paritytech/ink/pull/2164) -- [Runtime-to-Contract Calls] Add example for calling a contract from a runtime pallet ‒ [#2189](https://github.com/paritytech/ink/pull/2189) -- [XCM] Add `xcm_execute` and `xcm_send` support ‒ [#1912](https://github.com/use-ink/ink/pull/1912) -- [Linter] Add links to detailed lint description ‒ [#2170](https://github.com/use-ink/ink/pull/2170) -- [E2E] Adds a message to SandboxErr to add context for easier debugging ‒ [#2218](https://github.com/use-ink/ink/pull/2218) -- [E2E] Add ability to take and restore snapshots ‒ [#2261](https://github.com/paritytech/ink/pull/2261) (thanks [@0xLucca](https://github.com/0xLucca)!) -- [E2E] Demonstrate usage of seeds for secret URIs in E2E test for chain snapshots ‒ [#2163](https://github.com/paritytech/ink/pull/2163) + +- [Runtime-to-Contract Calls] Environment agnostic contract invocation API, for calling contracts from runtime ‒ [#2219](https://github.com/use-ink/ink/pull/2219) +- [Runtime-to-Contract Calls] Add `no-panic-handler` feature ‒ [#2164](https://github.com/paritytech/ink/pull/2164) +- [Runtime-to-Contract Calls] Add example for calling a contract from a runtime pallet ‒ [#2189](https://github.com/paritytech/ink/pull/2189) +- [XCM] Add `xcm_execute` and `xcm_send` support ‒ [#1912](https://github.com/use-ink/ink/pull/1912) +- [Linter] Add links to detailed lint description ‒ [#2170](https://github.com/use-ink/ink/pull/2170) +- [E2E] Adds a message to SandboxErr to add context for easier debugging ‒ [#2218](https://github.com/use-ink/ink/pull/2218) +- [E2E] Add ability to take and restore snapshots ‒ [#2261](https://github.com/paritytech/ink/pull/2261) (thanks [@0xLucca](https://github.com/0xLucca)!) +- [E2E] Demonstrate usage of seeds for secret URIs in E2E test for chain snapshots ‒ [#2163](https://github.com/paritytech/ink/pull/2163) ### Changed -- Update repository URLs & references from `paritytech` GitHub organization to new `use-ink` one ‒ [#2220](https://github.com/use-ink/ink/pull/2220) and [#2248](https://github.com/use-ink/ink/pull/2248) -- [E2E] Update `subxt` and `polkadot-sdk` dependencies ‒ [#2174](https://github.com/use-ink/ink/pull/2174) -- [Drink backend] Replace `drink` sandbox with internal `ink_sandbox` ‒ [#2158](https://github.com/use-ink/ink/pull/2158) + +- Update repository URLs & references from `paritytech` GitHub organization to new `use-ink` one ‒ [#2220](https://github.com/use-ink/ink/pull/2220) and [#2248](https://github.com/use-ink/ink/pull/2248) +- [E2E] Update `subxt` and `polkadot-sdk` dependencies ‒ [#2174](https://github.com/use-ink/ink/pull/2174) +- [Drink backend] Replace `drink` sandbox with internal `ink_sandbox` ‒ [#2158](https://github.com/use-ink/ink/pull/2158) ### Fixed -- [XCM] Fix XCM-support to single encode the XCM message ‒ [#2278](https://github.com/use-ink/ink/pull/2278) -- [Examples] ERC-721: `burn()` clears token approval ‒ [#2099](https://github.com/paritytech/ink/pull/2099) -- [E2E] Fix outdated docs for `[ink_e2e::test]` ‒ [#2162](https://github.com/use-ink/ink/pull/2162) -- [E2E] Build contracts before initializing node rpc ‒ [#2168](https://github.com/use-ink/ink/pull/2162) -- [E2E] `set_account_balance` now can't set balance below existential deposit ‒ [#1983](https://github.com/paritytech/ink/pull/1983) (thanks [@0xLucca](https://github.com/0xLucca)!) -- [E2E] Fix outdated docs for `[ink_e2e::test]` ‒ [#2162](https://github.com/paritytech/ink/pull/2162) + +- [XCM] Fix XCM-support to single encode the XCM message ‒ [#2278](https://github.com/use-ink/ink/pull/2278) +- [Examples] ERC-721: `burn()` clears token approval ‒ [#2099](https://github.com/paritytech/ink/pull/2099) +- [E2E] Fix outdated docs for `[ink_e2e::test]` ‒ [#2162](https://github.com/use-ink/ink/pull/2162) +- [E2E] Build contracts before initializing node rpc ‒ [#2168](https://github.com/use-ink/ink/pull/2162) +- [E2E] `set_account_balance` now can't set balance below existential deposit ‒ [#1983](https://github.com/paritytech/ink/pull/1983) (thanks [@0xLucca](https://github.com/0xLucca)!) +- [E2E] Fix outdated docs for `[ink_e2e::test]` ‒ [#2162](https://github.com/paritytech/ink/pull/2162) ## Version 5.0.0 @@ -457,19 +489,21 @@ overview over all breaking changes and newly added features._ 👉 _You can view it [here](https://use.ink/faq/migrating-from-ink-4-to-5)._ ### Summary + This release addresses the rest of the severities described in the [OpenZeppelin security review](https://blog.openzeppelin.com/security-review-ink-cargo-contract) of ink! and `cargo-contract`. One of the notable addressed issues is the proxy selector clashing attack. As of this release, ink! only allows exactly one other message with a well-known reserved selector to be defined. You can read more about the change in the [#1827](https://github.com/use-ink/ink/pull/1827) and [#2031](https://github.com/use-ink/ink/pull/2031). ink! 5.0.0 features a significant number of new features: -- We have introduced a new API based on the calculated or specified selectors for the event definition. This allows events to be defined in separate files and modules, and be shared across multiple ink! contracts - [#1827](https://github.com/use-ink/ink/pull/1827) and [#2031](https://github.com/use-ink/ink/pull/2031). -- [@pmikolajczyk41](https://github.com/pmikolajczyk41) has introduced an alternative E2E testing framework, [DRink!](https://github.com/inkdevhub/drink?tab=readme-ov-file#as-an-alternative-backend-to-inks-e2e-testing-framework), that support quasi-testing model, it allows the test simulate a running node as part of the E2E test while improving debugging experience such as allowing to set breakpoint and step through each stage of execution cycle. -- Following improvements in E2E, we have added a call builder API that allows to easily build calls while significantly reducing boilerplate code - [#1917](https://github.com/use-ink/ink/pull/1917) and [#2075](https://github.com/use-ink/ink/pull/2075) -- Another notable introduction in 5.0.0 release is the support for multiple chain extensions that empower developers -to build even more sophisticated and advanced contracts for supported chains - [#1958](https://github.com/use-ink/ink/pull/1958). -- To further address our consideration of the intrinsic security of ink! smart contracts, -we have disallowed unchecked arithmetic expressions. `cargo-contract` will fail to compile the contract with the raw arithmetic operation - [#1831](https://github.com/use-ink/ink/pull/1831). + +- We have introduced a new API based on the calculated or specified selectors for the event definition. This allows events to be defined in separate files and modules, and be shared across multiple ink! contracts - [#1827](https://github.com/use-ink/ink/pull/1827) and [#2031](https://github.com/use-ink/ink/pull/2031). +- [@pmikolajczyk41](https://github.com/pmikolajczyk41) has introduced an alternative E2E testing framework, [DRink!](https://github.com/inkdevhub/drink?tab=readme-ov-file#as-an-alternative-backend-to-inks-e2e-testing-framework), that support quasi-testing model, it allows the test simulate a running node as part of the E2E test while improving debugging experience such as allowing to set breakpoint and step through each stage of execution cycle. +- Following improvements in E2E, we have added a call builder API that allows to easily build calls while significantly reducing boilerplate code - [#1917](https://github.com/use-ink/ink/pull/1917) and [#2075](https://github.com/use-ink/ink/pull/2075) +- Another notable introduction in 5.0.0 release is the support for multiple chain extensions that empower developers + to build even more sophisticated and advanced contracts for supported chains - [#1958](https://github.com/use-ink/ink/pull/1958). +- To further address our consideration of the intrinsic security of ink! smart contracts, + we have disallowed unchecked arithmetic expressions. `cargo-contract` will fail to compile the contract with the raw arithmetic operation - [#1831](https://github.com/use-ink/ink/pull/1831). These are the main features we have introduced in this release. We also encourage developers to have a look at more detailed changelog entries to find out about any breaking changes that may affect @@ -479,157 +513,168 @@ the development of new ink! contracts. See [the compatibility section](https://use.ink/faq/migrating-from-ink-4-to-5/#compatibility) of our migration guide for a detailed description. On a high level: -- Rust: `>= 1.70` -- `cargo-contract`: `>= 4.0.0` -- polkadot-sdk: [>= 0.9.3](https://github.com/paritytech/polkadot-sdk/releases/tag/polkadot-v0.9.3). But if using the new functions introduced in [#2123](https://github.com/use-ink/ink/pull/2123) and [#2077](https://github.com/use-ink/ink/pull/2077) [>= 1.8.0](https://github.com/paritytech/polkadot-sdk/releases/tag/polkadot-v1.8.0) and if using the new functions introduced in [#2076](https://github.com/use-ink/ink/pull/2076) [>= 1.9.0](https://github.com/paritytech/polkadot-sdk/releases/tag/polkadot-v1.8.0). -- `polkadot-js/api` and `polkadot-js/api-contract`: `>= 10.12.1` -- `substrate-contracts-node`: `>= 0.39.0` +- Rust: `>= 1.70` +- `cargo-contract`: `>= 4.0.0` +- polkadot-sdk: [>= 0.9.3](https://github.com/paritytech/polkadot-sdk/releases/tag/polkadot-v0.9.3). But if using the new functions introduced in [#2123](https://github.com/use-ink/ink/pull/2123) and [#2077](https://github.com/use-ink/ink/pull/2077) [>= 1.8.0](https://github.com/paritytech/polkadot-sdk/releases/tag/polkadot-v1.8.0) and if using the new functions introduced in [#2076](https://github.com/use-ink/ink/pull/2076) [>= 1.9.0](https://github.com/paritytech/polkadot-sdk/releases/tag/polkadot-v1.8.0). +- `polkadot-js/api` and `polkadot-js/api-contract`: `>= 10.12.1` +- `substrate-contracts-node`: `>= 0.39.0` ### Changelog #### Added -- Add Hash trait to Selector struct - [#2149](https://github.com/use-ink/ink/pull/2149) -- `instantiate_v2` with additional limit parameters [#2123](https://github.com/use-ink/ink/pull/2123) -- Custom signature topic in Events - [#2031](https://github.com/use-ink/ink/pull/2031) -- [Linter] `non_fallible_api` lint - [#2004](https://github.com/use-ink/ink/pull/2004) -- [Linter] Publish the linting crates on crates.io - [#2060](https://github.com/use-ink/ink/pull/2060) -- [E2E] Added `create_call_builder` for testing existing contracts - [#2075](https://github.com/use-ink/ink/pull/2075) -- `call_v2` cross-contract calls with additional limit parameters - [#2077](https://github.com/use-ink/ink/pull/2077) -- `delegate_dependency` api calls - [#2076](https://github.com/use-ink/ink/pull/2076) -- Allow mutable parameters in messages - [#2004](https://github.com/use-ink/ink/pull/2004) -- Clean E2E configuration parsing - [#1922](https://github.com/use-ink/ink/pull/1922) -- Make `set_code_hash` generic - [#1906](https://github.com/use-ink/ink/pull/1906) -- Provide a `StorageVec` datastructure built on top of `Lazy` - [#1995](https://github.com/use-ink/ink/pull/1995) -- Add fallible methods for `Mapping` and `Lazy` - [#1910](https://github.com/use-ink/ink/pull/1910) -- [E2E] Allow testing with live-chain state - [#1949](https://github.com/use-ink/ink/pull/1949) -- [E2E] Call builders and extra gas margin option - [#1917](https://github.com/use-ink/ink/pull/1917) -- [Linter] `storage_never_freed` lint - [#1932](https://github.com/use-ink/ink/pull/1932) -- [Linter] `strict_balance_equality` lint - [#1914](https://github.com/use-ink/ink/pull/1914) -- [Linter] `no_main` lint - [#2001](https://github.com/use-ink/ink/pull/2001) -- Reexport `scale` dependencies, introduce `#[ink::scale_derive]` - [#1890](https://github.com/use-ink/ink/pull/1890) -- Upgradeable contracts example - [#1889](https://github.com/use-ink/ink/pull/1889) -- Persist static buffer size in metadata - [#1880](https://github.com/use-ink/ink/pull/1880) -- Modify static buffer size via environmental variables - [#1869](https://github.com/use-ink/ink/pull/1869) -- Added `sr25519_verify` function to `ink_env` [#1840](https://github.com/use-ink/ink/pull/1840) -- Events `2.0` - [#1827](https://github.com/use-ink/ink/pull/1827) -- Add `set_block_number` to off-chain test api `Engine` - [#1806](https://github.com/use-ink/ink/pull/1806) -- Stabilize `call_runtime` ‒ [#1749](https://github.com/use-ink/ink/pull/1749) -- Schema generation - [#1765](https://github.com/use-ink/ink/pull/1765) -- Restrict wildcard selectors to have exactly one other message - [#1708](https://github.com/use-ink/ink/pull/1708) -- [Linter] Warn when primitive number is annotated as event topic - [#1837](https://github.com/use-ink/ink/pull/1837) -- [Drink backend] allow for arbitrary runtime - [#1892](https://github.com/use-ink/ink/pull/1892) -- [Drink backend] support runtime call - [#1891](https://github.com/use-ink/ink/pull/1891) -- [Drink backend] Make tests generic `E2EBackend` trait - [#1867](https://github.com/use-ink/ink/pull/1867) -- [Drink backend] Backend choice ‒ [#1864](https://github.com/use-ink/ink/pull/1864) -- [Drink backend] Backend traits - [#1857](https://github.com/use-ink/ink/pull/1857) -- [Drink backend] Abstract error and result structs - [#1844](https://github.com/use-ink/ink/pull/1844) + +- Add Hash trait to Selector struct - [#2149](https://github.com/use-ink/ink/pull/2149) +- `instantiate_v2` with additional limit parameters [#2123](https://github.com/use-ink/ink/pull/2123) +- Custom signature topic in Events - [#2031](https://github.com/use-ink/ink/pull/2031) +- [Linter] `non_fallible_api` lint - [#2004](https://github.com/use-ink/ink/pull/2004) +- [Linter] Publish the linting crates on crates.io - [#2060](https://github.com/use-ink/ink/pull/2060) +- [E2E] Added `create_call_builder` for testing existing contracts - [#2075](https://github.com/use-ink/ink/pull/2075) +- `call_v2` cross-contract calls with additional limit parameters - [#2077](https://github.com/use-ink/ink/pull/2077) +- `delegate_dependency` api calls - [#2076](https://github.com/use-ink/ink/pull/2076) +- Allow mutable parameters in messages - [#2004](https://github.com/use-ink/ink/pull/2004) +- Clean E2E configuration parsing - [#1922](https://github.com/use-ink/ink/pull/1922) +- Make `set_code_hash` generic - [#1906](https://github.com/use-ink/ink/pull/1906) +- Provide a `StorageVec` datastructure built on top of `Lazy` - [#1995](https://github.com/use-ink/ink/pull/1995) +- Add fallible methods for `Mapping` and `Lazy` - [#1910](https://github.com/use-ink/ink/pull/1910) +- [E2E] Allow testing with live-chain state - [#1949](https://github.com/use-ink/ink/pull/1949) +- [E2E] Call builders and extra gas margin option - [#1917](https://github.com/use-ink/ink/pull/1917) +- [Linter] `storage_never_freed` lint - [#1932](https://github.com/use-ink/ink/pull/1932) +- [Linter] `strict_balance_equality` lint - [#1914](https://github.com/use-ink/ink/pull/1914) +- [Linter] `no_main` lint - [#2001](https://github.com/use-ink/ink/pull/2001) +- Reexport `scale` dependencies, introduce `#[ink::scale_derive]` - [#1890](https://github.com/use-ink/ink/pull/1890) +- Upgradeable contracts example - [#1889](https://github.com/use-ink/ink/pull/1889) +- Persist static buffer size in metadata - [#1880](https://github.com/use-ink/ink/pull/1880) +- Modify static buffer size via environmental variables - [#1869](https://github.com/use-ink/ink/pull/1869) +- Added `sr25519_verify` function to `ink_env` [#1840](https://github.com/use-ink/ink/pull/1840) +- Events `2.0` - [#1827](https://github.com/use-ink/ink/pull/1827) +- Add `set_block_number` to off-chain test api `Engine` - [#1806](https://github.com/use-ink/ink/pull/1806) +- Stabilize `call_runtime` ‒ [#1749](https://github.com/use-ink/ink/pull/1749) +- Schema generation - [#1765](https://github.com/use-ink/ink/pull/1765) +- Restrict wildcard selectors to have exactly one other message - [#1708](https://github.com/use-ink/ink/pull/1708) +- [Linter] Warn when primitive number is annotated as event topic - [#1837](https://github.com/use-ink/ink/pull/1837) +- [Drink backend] allow for arbitrary runtime - [#1892](https://github.com/use-ink/ink/pull/1892) +- [Drink backend] support runtime call - [#1891](https://github.com/use-ink/ink/pull/1891) +- [Drink backend] Make tests generic `E2EBackend` trait - [#1867](https://github.com/use-ink/ink/pull/1867) +- [Drink backend] Backend choice ‒ [#1864](https://github.com/use-ink/ink/pull/1864) +- [Drink backend] Backend traits - [#1857](https://github.com/use-ink/ink/pull/1857) +- [Drink backend] Abstract error and result structs - [#1844](https://github.com/use-ink/ink/pull/1844) #### Changed -- Use name-only syntax for `anonymous` ink! event item configuration argument - [#2140](https://github.com/use-ink/ink/pull/2140) -- Restrict syntax for setting default ink! e2e test runtime-only emulator - [#2143](https://github.com/use-ink/ink/pull/2143) -- Restrict syntax for setting ink! e2e test node to auto - [#2146](https://github.com/use-ink/ink/pull/2146) -- Bump Substrate crates - [#2141](https://github.com/use-ink/ink/pull/2141) -- Minor fixes - [#2144](https://github.com/use-ink/ink/pull/2144), -[#2137](https://github.com/use-ink/ink/pull/2137), [#2132](https://github.com/use-ink/ink/pull/2132) -- Bump metadata version to 5 [#2126](https://github.com/use-ink/ink/pull/2126) -- Use `MaxEncodedLen` for output buffer size [#2128](https://github.com/use-ink/ink/pull/2128) -- `Mapping`: Reflect all possible failure cases in comments ‒ [#2079](https://github.com/use-ink/ink/pull/2079) -- [E2E] Rename `.call` to `.call_builder` ‒ [#2078](https://github.com/use-ink/ink/pull/2078) -- Improve syntax for ink! e2e `runtime_only` attribute argument - [#2083](https://github.com/use-ink/ink/pull/2083) -- [E2E] Remove `additional_contracts` parameter [#2098](https://github.com/use-ink/ink/pull/2098) -- [E2E] change node url backend config - [#2101](https://github.com/use-ink/ink/pull/2101) -- Messages return `TypeSpec` directly - [#1999](https://github.com/use-ink/ink/pull/1999) -- Fail when decoding from storage and not all bytes consumed - [#1897](https://github.com/use-ink/ink/pull/1897) -- Support multiple chain extensions - [#1958](https://github.com/use-ink/ink/pull/1958) - - New example of how to use multiple chain extensions in one contract. - - Affects the usage of the `#[ink::chain_extension]` macro and the definition of the chain extension. -- Split up `ink_linting` to mandatory and extra libraries - [#2032](https://github.com/use-ink/ink/pull/2032) -- [E2E] resolve DispatchError error details for dry-runs - [#1994](https://github.com/use-ink/ink/pull/1994) -- [E2E] update to new `drink` API - [#2005](https://github.com/use-ink/ink/pull/2005) -- Reexport `scale` dependencies, introduce `#[ink::scale_derive]` ‒ [#1890](https://github.com/use-ink/ink/pull/1890) -- Use of workspace dependencies and properties - [#1835](https://github.com/use-ink/ink/pull/1835) -- Remove of unchecked arithmetic - [#1831](https://github.com/use-ink/ink/pull/1831) -- Use `decode_all` for decoding cross contract call result - [#1810](https://github.com/use-ink/ink/pull/1810) -- [E2E] build contracts at runtime instead of during codegen - [#1881](https://github.com/use-ink/ink/pull/1881) -- [E2E] crate refactoring - [#1830](https://github.com/use-ink/ink/pull/1830) -- [E2E] improve call API, remove `build_message` + callback - [#1782](https://github.com/use-ink/ink/pull/1782) + +- Use name-only syntax for `anonymous` ink! event item configuration argument - [#2140](https://github.com/use-ink/ink/pull/2140) +- Restrict syntax for setting default ink! e2e test runtime-only emulator - [#2143](https://github.com/use-ink/ink/pull/2143) +- Restrict syntax for setting ink! e2e test node to auto - [#2146](https://github.com/use-ink/ink/pull/2146) +- Bump Substrate crates - [#2141](https://github.com/use-ink/ink/pull/2141) +- Minor fixes - [#2144](https://github.com/use-ink/ink/pull/2144), + [#2137](https://github.com/use-ink/ink/pull/2137), [#2132](https://github.com/use-ink/ink/pull/2132) +- Bump metadata version to 5 [#2126](https://github.com/use-ink/ink/pull/2126) +- Use `MaxEncodedLen` for output buffer size [#2128](https://github.com/use-ink/ink/pull/2128) +- `Mapping`: Reflect all possible failure cases in comments ‒ [#2079](https://github.com/use-ink/ink/pull/2079) +- [E2E] Rename `.call` to `.call_builder` ‒ [#2078](https://github.com/use-ink/ink/pull/2078) +- Improve syntax for ink! e2e `runtime_only` attribute argument - [#2083](https://github.com/use-ink/ink/pull/2083) +- [E2E] Remove `additional_contracts` parameter [#2098](https://github.com/use-ink/ink/pull/2098) +- [E2E] change node url backend config - [#2101](https://github.com/use-ink/ink/pull/2101) +- Messages return `TypeSpec` directly - [#1999](https://github.com/use-ink/ink/pull/1999) +- Fail when decoding from storage and not all bytes consumed - [#1897](https://github.com/use-ink/ink/pull/1897) +- Support multiple chain extensions - [#1958](https://github.com/use-ink/ink/pull/1958) + - New example of how to use multiple chain extensions in one contract. + - Affects the usage of the `#[ink::chain_extension]` macro and the definition of the chain extension. +- Split up `ink_linting` to mandatory and extra libraries - [#2032](https://github.com/use-ink/ink/pull/2032) +- [E2E] resolve DispatchError error details for dry-runs - [#1994](https://github.com/use-ink/ink/pull/1994) +- [E2E] update to new `drink` API - [#2005](https://github.com/use-ink/ink/pull/2005) +- Reexport `scale` dependencies, introduce `#[ink::scale_derive]` ‒ [#1890](https://github.com/use-ink/ink/pull/1890) +- Use of workspace dependencies and properties - [#1835](https://github.com/use-ink/ink/pull/1835) +- Remove of unchecked arithmetic - [#1831](https://github.com/use-ink/ink/pull/1831) +- Use `decode_all` for decoding cross contract call result - [#1810](https://github.com/use-ink/ink/pull/1810) +- [E2E] build contracts at runtime instead of during codegen - [#1881](https://github.com/use-ink/ink/pull/1881) +- [E2E] crate refactoring - [#1830](https://github.com/use-ink/ink/pull/1830) +- [E2E] improve call API, remove `build_message` + callback - [#1782](https://github.com/use-ink/ink/pull/1782) #### Fixed -- Fix alignment in allocator [#2100](https://github.com/use-ink/ink/pull/2100) -- Fix the `StorageVec` type by excluding the `len_cached` field from its type info - [#2052](https://github.com/use-ink/ink/pull/2052) -- Fix panic in `approve_for` in the ERC-721 example - [#2092](https://github.com/use-ink/ink/pull/2092) -- ERC-721: `transfer_token_from` now ensures the token owner is correct - [#2093](https://github.com/use-ink/ink/pull/2093) -- `RootLayout::new()` is generic again to allow using `ink_metadata` in pure `PortableForm` contexts - [#1989](https://github.com/use-ink/ink/pull/1989) + +- Fix alignment in allocator [#2100](https://github.com/use-ink/ink/pull/2100) +- Fix the `StorageVec` type by excluding the `len_cached` field from its type info - [#2052](https://github.com/use-ink/ink/pull/2052) +- Fix panic in `approve_for` in the ERC-721 example - [#2092](https://github.com/use-ink/ink/pull/2092) +- ERC-721: `transfer_token_from` now ensures the token owner is correct - [#2093](https://github.com/use-ink/ink/pull/2093) +- `RootLayout::new()` is generic again to allow using `ink_metadata` in pure `PortableForm` contexts - [#1989](https://github.com/use-ink/ink/pull/1989) ## Version 5.0.0-rc.3 ### Changed -- Use name-only syntax for `anonymous` ink! event item configuration argument - [#2140](https://github.com/use-ink/ink/pull/2140) -- Restrict syntax for setting default ink! e2e test runtime-only emulator - [#2143](https://github.com/use-ink/ink/pull/2143) -- Restrict syntax for setting ink! e2e test node to auto - [#2146](https://github.com/use-ink/ink/pull/2146) -- Bump Substrate crates - [#2141](https://github.com/use-ink/ink/pull/2141) -- Minor fixes - [#2144](https://github.com/use-ink/ink/pull/2144), -[#2137](https://github.com/use-ink/ink/pull/2137), [#2132](https://github.com/use-ink/ink/pull/2132) + +- Use name-only syntax for `anonymous` ink! event item configuration argument - [#2140](https://github.com/use-ink/ink/pull/2140) +- Restrict syntax for setting default ink! e2e test runtime-only emulator - [#2143](https://github.com/use-ink/ink/pull/2143) +- Restrict syntax for setting ink! e2e test node to auto - [#2146](https://github.com/use-ink/ink/pull/2146) +- Bump Substrate crates - [#2141](https://github.com/use-ink/ink/pull/2141) +- Minor fixes - [#2144](https://github.com/use-ink/ink/pull/2144), + [#2137](https://github.com/use-ink/ink/pull/2137), [#2132](https://github.com/use-ink/ink/pull/2132) ## Version 5.0.0-rc.2 ### Added -- `instantiate_v2` with additional limit parameters [#2123](https://github.com/use-ink/ink/pull/2123) + +- `instantiate_v2` with additional limit parameters [#2123](https://github.com/use-ink/ink/pull/2123) ### Changed -- Bump metadata version to 5 [#2126](https://github.com/use-ink/ink/pull/2126) -- Use `MaxEncodedLen` for output buffer size [#2128](https://github.com/use-ink/ink/pull/2128) + +- Bump metadata version to 5 [#2126](https://github.com/use-ink/ink/pull/2126) +- Use `MaxEncodedLen` for output buffer size [#2128](https://github.com/use-ink/ink/pull/2128) ### Fixed -- Fix alignment in allocator [#2100](https://github.com/use-ink/ink/pull/2100) + +- Fix alignment in allocator [#2100](https://github.com/use-ink/ink/pull/2100) ## Version 5.0.0-rc.1 ### Added -- Custom signature topic in Events - [#2031](https://github.com/use-ink/ink/pull/2031) -- [Linter] `non_fallible_api` lint - [#2004](https://github.com/use-ink/ink/pull/2004) -- [Linter] Publish the linting crates on crates.io - [#2060](https://github.com/use-ink/ink/pull/2060) -- [E2E] Added `create_call_builder` for testing existing contracts - [#2075](https://github.com/use-ink/ink/pull/2075) -- `call_v2` cross-contract calls with additional limit parameters - [#2077](https://github.com/use-ink/ink/pull/2077) -- `instantiate_v2` with additional limit parameters - [#2123](https://github.com/use-ink/ink/pull/2123) -- `delegate_dependency` api calls - [#2076](https://github.com/use-ink/ink/pull/2076) + +- Custom signature topic in Events - [#2031](https://github.com/use-ink/ink/pull/2031) +- [Linter] `non_fallible_api` lint - [#2004](https://github.com/use-ink/ink/pull/2004) +- [Linter] Publish the linting crates on crates.io - [#2060](https://github.com/use-ink/ink/pull/2060) +- [E2E] Added `create_call_builder` for testing existing contracts - [#2075](https://github.com/use-ink/ink/pull/2075) +- `call_v2` cross-contract calls with additional limit parameters - [#2077](https://github.com/use-ink/ink/pull/2077) +- `instantiate_v2` with additional limit parameters - [#2123](https://github.com/use-ink/ink/pull/2123) +- `delegate_dependency` api calls - [#2076](https://github.com/use-ink/ink/pull/2076) ### Changed -- `Mapping`: Reflect all possible failure cases in comments ‒ [#2079](https://github.com/use-ink/ink/pull/2079) -- [E2E] Rename `.call` to `.call_builder` ‒ [#2078](https://github.com/use-ink/ink/pull/2078) -- Improve syntax for ink! e2e `runtime_only` attribute argument - [#2083](https://github.com/use-ink/ink/pull/2083) -- [E2E] Remove `additional_contracts` parameter [#2098](https://github.com/use-ink/ink/pull/2098) -- [E2E] change node url backend config - [#2101](https://github.com/use-ink/ink/pull/2101) + +- `Mapping`: Reflect all possible failure cases in comments ‒ [#2079](https://github.com/use-ink/ink/pull/2079) +- [E2E] Rename `.call` to `.call_builder` ‒ [#2078](https://github.com/use-ink/ink/pull/2078) +- Improve syntax for ink! e2e `runtime_only` attribute argument - [#2083](https://github.com/use-ink/ink/pull/2083) +- [E2E] Remove `additional_contracts` parameter [#2098](https://github.com/use-ink/ink/pull/2098) +- [E2E] change node url backend config - [#2101](https://github.com/use-ink/ink/pull/2101) ### Fixed -- Fix the `StorageVec` type by excluding the `len_cached` field from its type info - [#2052](https://github.com/use-ink/ink/pull/2052) -- Fix panic in `approve_for` in the ERC-721 example - [#2092](https://github.com/use-ink/ink/pull/2092) -- ERC-721: `transfer_token_from` now ensures the token owner is correct - [#2093](https://github.com/use-ink/ink/pull/2093) + +- Fix the `StorageVec` type by excluding the `len_cached` field from its type info - [#2052](https://github.com/use-ink/ink/pull/2052) +- Fix panic in `approve_for` in the ERC-721 example - [#2092](https://github.com/use-ink/ink/pull/2092) +- ERC-721: `transfer_token_from` now ensures the token owner is correct - [#2093](https://github.com/use-ink/ink/pull/2093) ## Version 5.0.0-rc ### Added -- Allow mutable parameters in messages - [#2004](https://github.com/use-ink/ink/pull/2004) -- Clean E2E configuration parsing - [#1922](https://github.com/use-ink/ink/pull/1922) -- Make `set_code_hash` generic - [#1906](https://github.com/use-ink/ink/pull/1906) -- Provide a `StorageVec` datastructure built on top of `Lazy` - [#1995](https://github.com/use-ink/ink/pull/1995) -- Add fallible methods for `Mapping` and `Lazy` - [#1910](https://github.com/use-ink/ink/pull/1910) -- [E2E] Allow testing with live-chain state - [#1949](https://github.com/use-ink/ink/pull/1949) -- [E2E] Call builders and extra gas margin option - [#1917](https://github.com/use-ink/ink/pull/1917) -- [Linter] `storage_never_freed` lint - [#1932](https://github.com/use-ink/ink/pull/1932) -- [Linter] `strict_balance_equality` lint - [#1914](https://github.com/use-ink/ink/pull/1914) -- [Linter] `no_main` lint - [#2001](https://github.com/use-ink/ink/pull/2001) + +- Allow mutable parameters in messages - [#2004](https://github.com/use-ink/ink/pull/2004) +- Clean E2E configuration parsing - [#1922](https://github.com/use-ink/ink/pull/1922) +- Make `set_code_hash` generic - [#1906](https://github.com/use-ink/ink/pull/1906) +- Provide a `StorageVec` datastructure built on top of `Lazy` - [#1995](https://github.com/use-ink/ink/pull/1995) +- Add fallible methods for `Mapping` and `Lazy` - [#1910](https://github.com/use-ink/ink/pull/1910) +- [E2E] Allow testing with live-chain state - [#1949](https://github.com/use-ink/ink/pull/1949) +- [E2E] Call builders and extra gas margin option - [#1917](https://github.com/use-ink/ink/pull/1917) +- [Linter] `storage_never_freed` lint - [#1932](https://github.com/use-ink/ink/pull/1932) +- [Linter] `strict_balance_equality` lint - [#1914](https://github.com/use-ink/ink/pull/1914) +- [Linter] `no_main` lint - [#2001](https://github.com/use-ink/ink/pull/2001) ### Changed -- Messages return `TypeSpec` directly - [#1999](https://github.com/use-ink/ink/pull/1999) -- Fail when decoding from storage and not all bytes consumed - [#1897](https://github.com/use-ink/ink/pull/1897) -- Support multiple chain extensions - [#1958](https://github.com/use-ink/ink/pull/1958) - - New example of how to use multiple chain extensions in one contract. - - Affects the usage of the `#[ink::chain_extension]` macro and the definition of the chain extension. -- Split up `ink_linting` to mandatory and extra libraries - [#2032](https://github.com/use-ink/ink/pull/2032) -- [E2E] resolve DispatchError error details for dry-runs - [#1994](https://github.com/use-ink/ink/pull/1994) -- [E2E] update to new `drink` API - [#2005](https://github.com/use-ink/ink/pull/2005) +- Messages return `TypeSpec` directly - [#1999](https://github.com/use-ink/ink/pull/1999) +- Fail when decoding from storage and not all bytes consumed - [#1897](https://github.com/use-ink/ink/pull/1897) +- Support multiple chain extensions - [#1958](https://github.com/use-ink/ink/pull/1958) + - New example of how to use multiple chain extensions in one contract. + - Affects the usage of the `#[ink::chain_extension]` macro and the definition of the chain extension. +- Split up `ink_linting` to mandatory and extra libraries - [#2032](https://github.com/use-ink/ink/pull/2032) +- [E2E] resolve DispatchError error details for dry-runs - [#1994](https://github.com/use-ink/ink/pull/1994) +- [E2E] update to new `drink` API - [#2005](https://github.com/use-ink/ink/pull/2005) ## Version 5.0.0-alpha @@ -641,85 +686,94 @@ You can read more about the change in the [PR](https://github.com/use-ink/ink/pu Other notable changes: -- Rework of event definitions - [#1827](https://github.com/use-ink/ink/pull/1827). -- Updated upgradeable contract example illustrating `delegate_call` - [#1889](https://github.com/use-ink/ink/pull/1889). -- Removal of unchecked arithmetic. `cargo-contract` will fail compiling the contract with raw arithmetic operations - [#1831](https://github.com/use-ink/ink/pull/1831). -- Introduction of an alternative off-chain E2E testing backend, [DRink!](https://github.com/inkdevhub/drink?tab=readme-ov-file#as-an-alternative-backend-to-inks-e2e-testing-framework). -**Big thanks to [@pmikolajczyk41](https://github.com/pmikolajczyk41) for this massive contribution!** +- Rework of event definitions - [#1827](https://github.com/use-ink/ink/pull/1827). +- Updated upgradeable contract example illustrating `delegate_call` - [#1889](https://github.com/use-ink/ink/pull/1889). +- Removal of unchecked arithmetic. `cargo-contract` will fail compiling the contract with raw arithmetic operations - [#1831](https://github.com/use-ink/ink/pull/1831). +- Introduction of an alternative off-chain E2E testing backend, [DRink!](https://github.com/inkdevhub/drink?tab=readme-ov-file#as-an-alternative-backend-to-inks-e2e-testing-framework). + **Big thanks to [@pmikolajczyk41](https://github.com/pmikolajczyk41) for this massive contribution!** You can see a more detailed log of changes below: ### Added -- Reexport `scale` dependencies, introduce `#[ink::scale_derive]` - [#1890](https://github.com/use-ink/ink/pull/1890) -- Upgradeable contracts example - [#1889](https://github.com/use-ink/ink/pull/1889) -- Persist static buffer size in metadata - [#1880](https://github.com/use-ink/ink/pull/1880) -- Modify static buffer size via environmental variables - [#1869](https://github.com/use-ink/ink/pull/1869) -- Added `sr25519_verify` function to `ink_env` [#1840](https://github.com/use-ink/ink/pull/1840) -- Events `2.0` - [#1827](https://github.com/use-ink/ink/pull/1827) -- Add `set_block_number` to off-chain test api `Engine` - [#1806](https://github.com/use-ink/ink/pull/1806) -- Stabilize `call_runtime` ‒ [#1749](https://github.com/use-ink/ink/pull/1749) -- Schema generation - [#1765](https://github.com/use-ink/ink/pull/1765) -- Restrict wildcard selectors to have exactly one other message - [#1708](https://github.com/use-ink/ink/pull/1708) -- [Linter] Warn when primitive number is annotated as event topic - [#1837](https://github.com/use-ink/ink/pull/1837) -- [Drink backend] allow for arbitrary runtime - [#1892](https://github.com/use-ink/ink/pull/1892) -- [Drink backend] support runtime call - [#1891](https://github.com/use-ink/ink/pull/1891) -- [Drink backend] Make tests generic `E2EBackend` trait - [#1867](https://github.com/use-ink/ink/pull/1867) -- [Drink backend] Backend choice ‒ [#1864](https://github.com/use-ink/ink/pull/1864) -- [Drink backend] Backend traits - [#1857](https://github.com/use-ink/ink/pull/1857) -- [Drink backend] Abstract error and result structs - [#1844](https://github.com/use-ink/ink/pull/1844) + +- Reexport `scale` dependencies, introduce `#[ink::scale_derive]` - [#1890](https://github.com/use-ink/ink/pull/1890) +- Upgradeable contracts example - [#1889](https://github.com/use-ink/ink/pull/1889) +- Persist static buffer size in metadata - [#1880](https://github.com/use-ink/ink/pull/1880) +- Modify static buffer size via environmental variables - [#1869](https://github.com/use-ink/ink/pull/1869) +- Added `sr25519_verify` function to `ink_env` [#1840](https://github.com/use-ink/ink/pull/1840) +- Events `2.0` - [#1827](https://github.com/use-ink/ink/pull/1827) +- Add `set_block_number` to off-chain test api `Engine` - [#1806](https://github.com/use-ink/ink/pull/1806) +- Stabilize `call_runtime` ‒ [#1749](https://github.com/use-ink/ink/pull/1749) +- Schema generation - [#1765](https://github.com/use-ink/ink/pull/1765) +- Restrict wildcard selectors to have exactly one other message - [#1708](https://github.com/use-ink/ink/pull/1708) +- [Linter] Warn when primitive number is annotated as event topic - [#1837](https://github.com/use-ink/ink/pull/1837) +- [Drink backend] allow for arbitrary runtime - [#1892](https://github.com/use-ink/ink/pull/1892) +- [Drink backend] support runtime call - [#1891](https://github.com/use-ink/ink/pull/1891) +- [Drink backend] Make tests generic `E2EBackend` trait - [#1867](https://github.com/use-ink/ink/pull/1867) +- [Drink backend] Backend choice ‒ [#1864](https://github.com/use-ink/ink/pull/1864) +- [Drink backend] Backend traits - [#1857](https://github.com/use-ink/ink/pull/1857) +- [Drink backend] Abstract error and result structs - [#1844](https://github.com/use-ink/ink/pull/1844) ### Changed -- Reexport `scale` dependencies, introduce `#[ink::scale_derive]` ‒ [#1890](https://github.com/use-ink/ink/pull/1890) -- Use of workspace dependencies and properties - [#1835](https://github.com/use-ink/ink/pull/1835) -- Remove of unchecked arithmetic - [#1831](https://github.com/use-ink/ink/pull/1831) -- Use `decode_all` for decoding cross contract call result - [#1810](https://github.com/use-ink/ink/pull/1810) -- [E2E] build contracts at runtime instead of during codegen - [#1881](https://github.com/use-ink/ink/pull/1881) -- [E2E] crate refactoring - [#1830](https://github.com/use-ink/ink/pull/1830) -- [E2E] improve call API, remove `build_message` + callback - [#1782](https://github.com/use-ink/ink/pull/1782) + +- Reexport `scale` dependencies, introduce `#[ink::scale_derive]` ‒ [#1890](https://github.com/use-ink/ink/pull/1890) +- Use of workspace dependencies and properties - [#1835](https://github.com/use-ink/ink/pull/1835) +- Remove of unchecked arithmetic - [#1831](https://github.com/use-ink/ink/pull/1831) +- Use `decode_all` for decoding cross contract call result - [#1810](https://github.com/use-ink/ink/pull/1810) +- [E2E] build contracts at runtime instead of during codegen - [#1881](https://github.com/use-ink/ink/pull/1881) +- [E2E] crate refactoring - [#1830](https://github.com/use-ink/ink/pull/1830) +- [E2E] improve call API, remove `build_message` + callback - [#1782](https://github.com/use-ink/ink/pull/1782) ### Fixed -- `RootLayout::new()` is generic again to allow using `ink_metadata` in pure `PortableForm` contexts - [#1989](https://github.com/use-ink/ink/pull/1989) + +- `RootLayout::new()` is generic again to allow using `ink_metadata` in pure `PortableForm` contexts - [#1989](https://github.com/use-ink/ink/pull/1989) ## 4.3.0 ### Fixed -- Fix E2E tests for newer rust toolchain & contracts node - #[1884](https://github.com/use-ink/ink/pull/1884) -- Enable Rust >= `1.70`, update `subxt` and `contract-build` - [#1855](https://github.com/use-ink/ink/pull/1855) -- Fix unsupported `--ws-port` argument - [#1850](https://github.com/use-ink/ink/pull/1850) +- Fix E2E tests for newer rust toolchain & contracts node - #[1884](https://github.com/use-ink/ink/pull/1884) +- Enable Rust >= `1.70`, update `subxt` and `contract-build` - [#1855](https://github.com/use-ink/ink/pull/1855) +- Fix unsupported `--ws-port` argument - [#1850](https://github.com/use-ink/ink/pull/1850) ## Version 4.2.0 ### Added -- Persist `Environment` in metadata ‒ [#1741](https://github.com/use-ink/ink/pull/1741) -- Added possibility for `runtime_call` in E2E tests ‒ [#1736](https://github.com/use-ink/ink/pull/1736) -- Added `default` attribute to constructors and messages ‒ [#1724](https://github.com/use-ink/ink/pull/1724) -- Added clarification about `Mapping::size` unit ‒ [#1735](https://github.com/use-ink/ink/pull/1735) + +- Persist `Environment` in metadata ‒ [#1741](https://github.com/use-ink/ink/pull/1741) +- Added possibility for `runtime_call` in E2E tests ‒ [#1736](https://github.com/use-ink/ink/pull/1736) +- Added `default` attribute to constructors and messages ‒ [#1724](https://github.com/use-ink/ink/pull/1724) +- Added clarification about `Mapping::size` unit ‒ [#1735](https://github.com/use-ink/ink/pull/1735) ### Changed -- Upgraded `syn` to version `2` ‒ [#1731](https://github.com/use-ink/ink/pull/1731) -- Update `scale-info` requirement to `2.5` ‒ [#1733](https://github.com/use-ink/ink/pull/1733) -- Bump `subxt` to `0.28.0` ‒ [#1750](https://github.com/use-ink/ink/pull/1750) + +- Upgraded `syn` to version `2` ‒ [#1731](https://github.com/use-ink/ink/pull/1731) +- Update `scale-info` requirement to `2.5` ‒ [#1733](https://github.com/use-ink/ink/pull/1733) +- Bump `subxt` to `0.28.0` ‒ [#1750](https://github.com/use-ink/ink/pull/1750) ## Version 4.1.0 ### Added -- Basic support for `dyn Trait` to allow cross-contract calls only with trait - [#1673](https://github.com/use-ink/ink/pull/1673) -- E2E: auto detect contracts to be built - [#1691](https://github.com/use-ink/ink/pull/1691) -- Add `set_code_hash` to `EnvAccess` - [#1698](https://github.com/use-ink/ink/pull/1698) -- Add `set_block_timestamp` to off-chain test api `Engine` - [#1721](https://github.com/use-ink/ink/pull/1721) + +- Basic support for `dyn Trait` to allow cross-contract calls only with trait - [#1673](https://github.com/use-ink/ink/pull/1673) +- E2E: auto detect contracts to be built - [#1691](https://github.com/use-ink/ink/pull/1691) +- Add `set_code_hash` to `EnvAccess` - [#1698](https://github.com/use-ink/ink/pull/1698) +- Add `set_block_timestamp` to off-chain test api `Engine` - [#1721](https://github.com/use-ink/ink/pull/1721) ### Changed -- Support conditional compilation - [#1707](https://github.com/use-ink/ink/pull/1707) + +- Support conditional compilation - [#1707](https://github.com/use-ink/ink/pull/1707) ## Version 4.0.1 ### Fixed -- Fixing `ManualKey<0>` to act properly - [#1670](https://github.com/use-ink/ink/pull/1670) -- Indicated latest release of `cargo-contract` in `e2e` crate + +- Fixing `ManualKey<0>` to act properly - [#1670](https://github.com/use-ink/ink/pull/1670) +- Indicated latest release of `cargo-contract` in `e2e` crate ### Added -- Add `call-runtime` support - [#1641](https://github.com/use-ink/ink/pull/1641) + +- Add `call-runtime` support - [#1641](https://github.com/use-ink/ink/pull/1641) ## Version 4.0.0 @@ -729,10 +783,11 @@ This version brings a lot of usability improvements, making the language better for the needs of production parachains. A couple of highlights include: -- Changes to how contract storage works, which significantly reduced the sizes of - contract binaries -- A new end-to-end testing framework, letting you easily write integration tests -- Changes to the metadata format, which (in part) makes error handling more expressive + +- Changes to how contract storage works, which significantly reduced the sizes of + contract binaries +- A new end-to-end testing framework, letting you easily write integration tests +- Changes to the metadata format, which (in part) makes error handling more expressive There's a lot more to dig through, so take some time to poke around the `CHANGELOG` (including the `4.0.0-alpha` and `4.0.0-beta` releases). @@ -762,55 +817,58 @@ compatible with the ink! `4.0.0` release. For full compatibility requirements see the [migration guide](https://use.ink/faq/migrating-from-ink-3-to-4/#compatibility). -- Add `Mapping::contains(key)` and `Mapping::insert_return_size(key, val)` ‒ [#1224](https://github.com/use-ink/ink/pull/1224) -- Add [`payment-channel`](https://github.com/use-ink/ink-examples/tree/main/payment-channel) example ‒ [#1248](https://github.com/use-ink/ink/pull/1248) (thanks [@kanishkatn](https://github.com/kanishkatn)!) -- Add `version` field to ink! metadata ‒ [#1313](https://github.com/use-ink/ink/pull/1313) -- The `rand-extension` example has been adapted to an updated version of the `ChainExtension` API ‒ [#1356](https://github.com/use-ink/ink/pull/1356) -- Add `ink_env::pay_with_call!` helper macro for off-chain emulation of sending payments with contract message calls ‒ [#1379](https://github.com/use-ink/ink/pull/1379) -- Allow using `Result` as a return type in constructors ‒ [#1446](https://github.com/use-ink/ink/pull/1446) -- Add `Mapping::take()` function allowing to get a value removing it from storage ‒ [#1461](https://github.com/use-ink/ink/pull/1461) -- Add E2E testing framework MVP ‒ [#1395](https://github.com/use-ink/ink/pull/1395) -- Add E2E tests for `Mapping` functions - [#1492](https://github.com/use-ink/ink/pull/1492) -- E2E: expose call dry-run method ‒ [#1624](https://github.com/use-ink/ink/pull/1624) -- Make cross-contract callee non-optional ‒ [#1636](https://github.com/use-ink/ink/pull/1636) -- Support custom environment in E2E tests - [#1645](https://github.com/use-ink/ink/pull/1645) (thanks [@pmikolajczyk41](https://github.com/pmikolajczyk41)!) +- Add `Mapping::contains(key)` and `Mapping::insert_return_size(key, val)` ‒ [#1224](https://github.com/use-ink/ink/pull/1224) +- Add [`payment-channel`](https://github.com/use-ink/ink-examples/tree/main/payment-channel) example ‒ [#1248](https://github.com/use-ink/ink/pull/1248) (thanks [@kanishkatn](https://github.com/kanishkatn)!) +- Add `version` field to ink! metadata ‒ [#1313](https://github.com/use-ink/ink/pull/1313) +- The `rand-extension` example has been adapted to an updated version of the `ChainExtension` API ‒ [#1356](https://github.com/use-ink/ink/pull/1356) +- Add `ink_env::pay_with_call!` helper macro for off-chain emulation of sending payments with contract message calls ‒ [#1379](https://github.com/use-ink/ink/pull/1379) +- Allow using `Result` as a return type in constructors ‒ [#1446](https://github.com/use-ink/ink/pull/1446) +- Add `Mapping::take()` function allowing to get a value removing it from storage ‒ [#1461](https://github.com/use-ink/ink/pull/1461) +- Add E2E testing framework MVP ‒ [#1395](https://github.com/use-ink/ink/pull/1395) +- Add E2E tests for `Mapping` functions - [#1492](https://github.com/use-ink/ink/pull/1492) +- E2E: expose call dry-run method ‒ [#1624](https://github.com/use-ink/ink/pull/1624) +- Make cross-contract callee non-optional ‒ [#1636](https://github.com/use-ink/ink/pull/1636) +- Support custom environment in E2E tests - [#1645](https://github.com/use-ink/ink/pull/1645) (thanks [@pmikolajczyk41](https://github.com/pmikolajczyk41)!) ### Changed -- Contract size optimization in case contract doesn't accept payment ‒ [#1267](https://github.com/use-ink/ink/pull/1267) (thanks [@xgreenx](https://github.com/xgreenx)!) -- Move ink! linter into `ink` repository ‒ [#1361](https://github.com/use-ink/ink/pull/1267) -- Introduce `ink` entrance crate ‒ [#1223](https://github.com/use-ink/ink/pull/1223) -- Use `XXH32` instead of `sha256` for calculating storage keys ‒ [#1393](https://github.com/use-ink/ink/pull/1393) -- Storage Refactoring ‒ [#1331](https://github.com/use-ink/ink/pull/1331) -- Add support for language level errors (`LangError`) ‒ [#1450](https://github.com/use-ink/ink/pull/1450) -- Return `LangError`s from constructors ‒ [#1504](https://github.com/use-ink/ink/pull/1504) -- Update `scale-info` requirement to `2.3` ‒ [#1467](https://github.com/use-ink/ink/pull/1467) -- Merge `Mapping::insert(key, val)` and `Mapping::insert_return_size(key, val)` into one method - [#1463](https://github.com/use-ink/ink/pull/1463) -- FFI: no more `__unstable__` wasm import module ‒ [#1522](https://github.com/use-ink/ink/pull/1522) -- Clean up CallBuilder `return()` type ‒ [#1525](https://github.com/use-ink/ink/pull/1525) -- Fix trait message return type metadata ‒ [#1531](https://github.com/use-ink/ink/pull/1531) -- Bump Dylint dependencies ‒ [#1551](https://github.com/use-ink/ink/pull/1551) -- Stabilize `take_storage` ‒ [#1568](https://github.com/use-ink/ink/pull/1568) -- Chain Extension: Evaluation of method return type at compile time ‒ [#1569](https://github.com/use-ink/ink/pull/1569) -- Make more functions be const ‒ [#1574](https://github.com/use-ink/ink/pull/1574) (thanks [@yjhmelody](https://github.com/yjhmelody)!) -- Unify fallible and non fallible `instantiate` methods ‒ [#1591](https://github.com/use-ink/ink/pull/1591) -- Make `CallBuilder` and `CreateBuilder` error handling optional ‒ [#1602](https://github.com/use-ink/ink/pull/1602) -- Rename `CallBuilder::fire()` method to `invoke()` ‒ [#1604](https://github.com/use-ink/ink/pull/1604) -- chore: add minimum rust version to the ink crate ‒ [#1609](https://github.com/use-ink/ink/pull/1609) (thanks [@Kurtsley](https://github.com/Kurtsley)!) -- Rename `_checked` codegen call methods with `try_` ‒ [#1621](https://github.com/use-ink/ink/pull/1621) -- Bump Substrate and `subxt` dependencies ‒ [#1549](https://github.com/use-ink/ink/pull/1549) -- E2E: spawn a separate contracts node instance per test ‒ [#1642](https://github.com/use-ink/ink/pull/1642) + +- Contract size optimization in case contract doesn't accept payment ‒ [#1267](https://github.com/use-ink/ink/pull/1267) (thanks [@xgreenx](https://github.com/xgreenx)!) +- Move ink! linter into `ink` repository ‒ [#1361](https://github.com/use-ink/ink/pull/1267) +- Introduce `ink` entrance crate ‒ [#1223](https://github.com/use-ink/ink/pull/1223) +- Use `XXH32` instead of `sha256` for calculating storage keys ‒ [#1393](https://github.com/use-ink/ink/pull/1393) +- Storage Refactoring ‒ [#1331](https://github.com/use-ink/ink/pull/1331) +- Add support for language level errors (`LangError`) ‒ [#1450](https://github.com/use-ink/ink/pull/1450) +- Return `LangError`s from constructors ‒ [#1504](https://github.com/use-ink/ink/pull/1504) +- Update `scale-info` requirement to `2.3` ‒ [#1467](https://github.com/use-ink/ink/pull/1467) +- Merge `Mapping::insert(key, val)` and `Mapping::insert_return_size(key, val)` into one method - [#1463](https://github.com/use-ink/ink/pull/1463) +- FFI: no more `__unstable__` wasm import module ‒ [#1522](https://github.com/use-ink/ink/pull/1522) +- Clean up CallBuilder `return()` type ‒ [#1525](https://github.com/use-ink/ink/pull/1525) +- Fix trait message return type metadata ‒ [#1531](https://github.com/use-ink/ink/pull/1531) +- Bump Dylint dependencies ‒ [#1551](https://github.com/use-ink/ink/pull/1551) +- Stabilize `take_storage` ‒ [#1568](https://github.com/use-ink/ink/pull/1568) +- Chain Extension: Evaluation of method return type at compile time ‒ [#1569](https://github.com/use-ink/ink/pull/1569) +- Make more functions be const ‒ [#1574](https://github.com/use-ink/ink/pull/1574) (thanks [@yjhmelody](https://github.com/yjhmelody)!) +- Unify fallible and non fallible `instantiate` methods ‒ [#1591](https://github.com/use-ink/ink/pull/1591) +- Make `CallBuilder` and `CreateBuilder` error handling optional ‒ [#1602](https://github.com/use-ink/ink/pull/1602) +- Rename `CallBuilder::fire()` method to `invoke()` ‒ [#1604](https://github.com/use-ink/ink/pull/1604) +- chore: add minimum rust version to the ink crate ‒ [#1609](https://github.com/use-ink/ink/pull/1609) (thanks [@Kurtsley](https://github.com/Kurtsley)!) +- Rename `_checked` codegen call methods with `try_` ‒ [#1621](https://github.com/use-ink/ink/pull/1621) +- Bump Substrate and `subxt` dependencies ‒ [#1549](https://github.com/use-ink/ink/pull/1549) +- E2E: spawn a separate contracts node instance per test ‒ [#1642](https://github.com/use-ink/ink/pull/1642) ### Fixed -- Trim single whitespace prefix in the metadata `docs` field ‒ [#1385](https://github.com/use-ink/ink/pull/1385) -- Allow pay_with_call to take multiple arguments ‒ [#1401](https://github.com/use-ink/ink/pull/1401) -- Add Determinism enum from pallet-contracts ‒ [#1547](https://github.com/use-ink/ink/pull/1547) -- Added missed `WhereClosure` for the generics into `storage_item` ‒ [#1536](https://github.com/use-ink/ink/pull/1536) (thanks [@xgreenx](https://github.com/xgreenx)!) + +- Trim single whitespace prefix in the metadata `docs` field ‒ [#1385](https://github.com/use-ink/ink/pull/1385) +- Allow pay_with_call to take multiple arguments ‒ [#1401](https://github.com/use-ink/ink/pull/1401) +- Add Determinism enum from pallet-contracts ‒ [#1547](https://github.com/use-ink/ink/pull/1547) +- Added missed `WhereClosure` for the generics into `storage_item` ‒ [#1536](https://github.com/use-ink/ink/pull/1536) (thanks [@xgreenx](https://github.com/xgreenx)!) ### Removed -- Implement `ecdsa_to_eth_address()` and remove `eth_compatibility` crate ‒ [#1233](https://github.com/use-ink/ink/pull/1233) -- Remove `wee-alloc` ‒ [#1403](https://github.com/use-ink/ink/pull/1403) -- Remove `ink_env::random` function ‒ [#1442](https://github.com/use-ink/ink/pull/1442) -- Remove `Default` implementation for AccountId ‒ [#1255](https://github.com/use-ink/ink/pull/1255) + +- Implement `ecdsa_to_eth_address()` and remove `eth_compatibility` crate ‒ [#1233](https://github.com/use-ink/ink/pull/1233) +- Remove `wee-alloc` ‒ [#1403](https://github.com/use-ink/ink/pull/1403) +- Remove `ink_env::random` function ‒ [#1442](https://github.com/use-ink/ink/pull/1442) +- Remove `Default` implementation for AccountId ‒ [#1255](https://github.com/use-ink/ink/pull/1255) ## Version 4.0.0-rc @@ -830,17 +888,21 @@ breaking or otherwise. ([#1636](https://github.com/use-ink/ink/pull/1636)) ### Added -- E2E: expose call dry-run method ‒ [#1624](https://github.com/use-ink/ink/pull/1624) -- Make cross-contract callee non-optional ‒ [#1636](https://github.com/use-ink/ink/pull/1636) + +- E2E: expose call dry-run method ‒ [#1624](https://github.com/use-ink/ink/pull/1624) +- Make cross-contract callee non-optional ‒ [#1636](https://github.com/use-ink/ink/pull/1636) ### Changed -- Rename `_checked` codegen call methods with `try_` ‒ [#1621](https://github.com/use-ink/ink/pull/1621) -- Bump Substrate and `subxt` dependencies ‒ [#1549](https://github.com/use-ink/ink/pull/1549) + +- Rename `_checked` codegen call methods with `try_` ‒ [#1621](https://github.com/use-ink/ink/pull/1621) +- Bump Substrate and `subxt` dependencies ‒ [#1549](https://github.com/use-ink/ink/pull/1549) ### Removed -- Remove `Default` implementation for AccountId ‒ [#1255](https://github.com/use-ink/ink/pull/1255) + +- Remove `Default` implementation for AccountId ‒ [#1255](https://github.com/use-ink/ink/pull/1255) ## Version 4.0.0-beta.1 + The coolest feature included in this release is the first published version of ink!'s native ["end-to-end" (E2E) testing framework](https://github.com/use-ink/ink/issues/1234). @@ -848,6 +910,7 @@ This enables testing of a contract by deploying and calling it on a Substrate no `pallet-contracts`. See the [`erc20` example](./examples/erc20/lib.rs) for usage. ### Breaking Changes + This release includes a couple of breaking changes. 1. The `CallBuilder::returns()` method does not require an extra `MessageResult` anymore @@ -866,35 +929,39 @@ This release includes a couple of breaking changes. ([#1609](https://github.com/use-ink/ink/pull/1609)) ### Added -- Add E2E testing framework MVP ‒ [#1395](https://github.com/use-ink/ink/pull/1395) -- Add E2E tests for `Mapping` functions - [#1492](https://github.com/use-ink/ink/pull/1492) + +- Add E2E testing framework MVP ‒ [#1395](https://github.com/use-ink/ink/pull/1395) +- Add E2E tests for `Mapping` functions - [#1492](https://github.com/use-ink/ink/pull/1492) ### Fixed -- Add Determinism enum from pallet-contracts ‒ [#1547](https://github.com/use-ink/ink/pull/1547) -- Added missed `WhereClosure` for the generics into `storage_item` ‒ [#1536](https://github.com/use-ink/ink/pull/1536) (thanks [@xgreenx](https://github.com/xgreenx)) + +- Add Determinism enum from pallet-contracts ‒ [#1547](https://github.com/use-ink/ink/pull/1547) +- Added missed `WhereClosure` for the generics into `storage_item` ‒ [#1536](https://github.com/use-ink/ink/pull/1536) (thanks [@xgreenx](https://github.com/xgreenx)) ### Changed -- Handle `LangError` from instantiate ‒ [#1512](https://github.com/use-ink/ink/pull/1512) -- FFI: no more `__unstable__` wasm import module ‒ [#1522](https://github.com/use-ink/ink/pull/1522) -- Clean up CallBuilder `return()` type ‒ [#1525](https://github.com/use-ink/ink/pull/1525) -- Fix trait message return type metadata ‒ [#1531](https://github.com/use-ink/ink/pull/1531) -- Bump Dylint dependencies ‒ [#1551](https://github.com/use-ink/ink/pull/1551) -- Stabilize `take_storage` ‒ [#1568](https://github.com/use-ink/ink/pull/1568) -- Chain Extension: Evaluation of method return type at compile time ‒ [#1569](https://github.com/use-ink/ink/pull/1569) -- Make more functions be const ‒ [#1574](https://github.com/use-ink/ink/pull/1574) (thanks [@yjhmelody](https://github.com/yjhmelody)) -- Unify fallible and non fallible `instantiate` methods ‒ [#1591](https://github.com/use-ink/ink/pull/1591) -- Make `CallBuilder` and `CreateBuilder` error handling optional ‒ [#1602](https://github.com/use-ink/ink/pull/1602) -- Rename `CallBuilder::fire()` method to `invoke()` ‒ [#1604](https://github.com/use-ink/ink/pull/1604) -- chore: add minimum rust version to the ink crate ‒ [#1609](https://github.com/use-ink/ink/pull/1609) (thanks [@Kurtsley](https://github.com/Kurtsley)) + +- Handle `LangError` from instantiate ‒ [#1512](https://github.com/use-ink/ink/pull/1512) +- FFI: no more `__unstable__` wasm import module ‒ [#1522](https://github.com/use-ink/ink/pull/1522) +- Clean up CallBuilder `return()` type ‒ [#1525](https://github.com/use-ink/ink/pull/1525) +- Fix trait message return type metadata ‒ [#1531](https://github.com/use-ink/ink/pull/1531) +- Bump Dylint dependencies ‒ [#1551](https://github.com/use-ink/ink/pull/1551) +- Stabilize `take_storage` ‒ [#1568](https://github.com/use-ink/ink/pull/1568) +- Chain Extension: Evaluation of method return type at compile time ‒ [#1569](https://github.com/use-ink/ink/pull/1569) +- Make more functions be const ‒ [#1574](https://github.com/use-ink/ink/pull/1574) (thanks [@yjhmelody](https://github.com/yjhmelody)) +- Unify fallible and non fallible `instantiate` methods ‒ [#1591](https://github.com/use-ink/ink/pull/1591) +- Make `CallBuilder` and `CreateBuilder` error handling optional ‒ [#1602](https://github.com/use-ink/ink/pull/1602) +- Rename `CallBuilder::fire()` method to `invoke()` ‒ [#1604](https://github.com/use-ink/ink/pull/1604) +- chore: add minimum rust version to the ink crate ‒ [#1609](https://github.com/use-ink/ink/pull/1609) (thanks [@Kurtsley](https://github.com/Kurtsley)) ## Version 4.0.0-beta The focus of the first `beta` release is to establish the stable ABI for the final `4.0.0` release. It means that whilst subsequent `beta` releases may contain breaking contract -*code* changes, the ABI will remain the same so that any contract compiled and deployed +_code_ changes, the ABI will remain the same so that any contract compiled and deployed with `4.0.0-beta` continue to be compatible with all future `4.0.0` versions. ### Compatibility + In order to build contracts which use ink! `v4.0.0-beta` you need to use `cargo-contract` [`v2.0.0-beta`](https://github.com/use-ink/cargo-contract/releases/tag/v2.0.0-beta). @@ -935,15 +1002,18 @@ In order to make this error compatible with other languages we have also added a different error variants which languages may want to emit in the future. Related pull-requests: -- https://github.com/use-ink/ink/pull/1450 -- https://github.com/use-ink/ink/pull/1504 + +- https://github.com/use-ink/ink/pull/1450 +- https://github.com/use-ink/ink/pull/1504 Related discussions: -- https://github.com/use-ink/ink/issues/1207 -- https://github.com/paritytech/substrate/issues/11018 -- https://github.com/use-ink/ink/issues/1002 + +- https://github.com/use-ink/ink/issues/1207 +- https://github.com/paritytech/substrate/issues/11018 +- https://github.com/use-ink/ink/issues/1002 ## Random function removed + We had to remove [`ink_env::random`](https://docs.rs/ink_env/3.3.1/ink_env/fn.random.html) with [#1442](https://github.com/use-ink/ink/pull/1442). This function allowed contract developers getting random entropy. @@ -960,61 +1030,73 @@ best hope right now is that it could come back with [Sassafras](https://wiki.pol protocol for future versions of Polkadot. ### Added -- Allow using `Result` as a return type in constructors ‒ [#1446](https://github.com/use-ink/ink/pull/1446) -- Add `Mapping::take()` function allowing to get a value removing it from storage ‒ [#1461](https://github.com/use-ink/ink/pull/1461) + +- Allow using `Result` as a return type in constructors ‒ [#1446](https://github.com/use-ink/ink/pull/1446) +- Add `Mapping::take()` function allowing to get a value removing it from storage ‒ [#1461](https://github.com/use-ink/ink/pull/1461) ### Changed -- Add support for language level errors (`LangError`) ‒ [#1450](https://github.com/use-ink/ink/pull/1450) -- Return `LangError`s from constructors ‒ [#1504](https://github.com/use-ink/ink/pull/1504) -- Update `scale-info` requirement to `2.3` ‒ [#1467](https://github.com/use-ink/ink/pull/1467) -- Merge `Mapping::insert(key, val)` and `Mapping::insert_return_size(key, val)` into one method - [#1463](https://github.com/use-ink/ink/pull/1463) + +- Add support for language level errors (`LangError`) ‒ [#1450](https://github.com/use-ink/ink/pull/1450) +- Return `LangError`s from constructors ‒ [#1504](https://github.com/use-ink/ink/pull/1504) +- Update `scale-info` requirement to `2.3` ‒ [#1467](https://github.com/use-ink/ink/pull/1467) +- Merge `Mapping::insert(key, val)` and `Mapping::insert_return_size(key, val)` into one method - [#1463](https://github.com/use-ink/ink/pull/1463) ### Removed -- Remove `ink_env::random` function ‒ [#1442](https://github.com/use-ink/ink/pull/1442) + +- Remove `ink_env::random` function ‒ [#1442](https://github.com/use-ink/ink/pull/1442) ## Version 4.0.0-alpha.3 ### Breaking Changes #### New `ink` crate + The `ink_lang` crate has been replaced in [#1223](https://github.com/use-ink/ink/pull/1223) by a new top level `ink` crate. All existing sub-crates are reexported and should be used via the new `ink` crate, so e.g. `ink::env` instead of `ink_env`. Contract authors should now import the top level `ink` crate instead of the individual crates. ##### Migration -- In `Cargo.toml` Replace all individual `ink_*` crate dependencies with the `ink` crate. -- In the contract source: - - Remove the commonly used `use ink_lang as ink` idiom. - - Replace all usages of individual crates with reexports, e.g. `ink_env` ➜ `ink::env`. + +- In `Cargo.toml` Replace all individual `ink_*` crate dependencies with the `ink` crate. +- In the contract source: + - Remove the commonly used `use ink_lang as ink` idiom. + - Replace all usages of individual crates with reexports, e.g. `ink_env` ➜ `ink::env`. #### Storage Rework + [#1331](https://github.com/use-ink/ink/pull/1331) changes the way `ink!` works with contract storage. Storage keys are generated at compile-time, and user facing abstractions which determine how contract data is laid out in storage have changed. ##### Migration -- Initialize `Mapping` fields with `Mapping::default()` instead of `ink_lang::utils::initialize_contract` in -constructors. See [`erc20`](./examples/erc20/lib.rs) and other examples which use a `Mapping`. -- Remove `SpreadAllocate`, `SpreadLayout` and `PackedLayout` implementations. + +- Initialize `Mapping` fields with `Mapping::default()` instead of `ink_lang::utils::initialize_contract` in + constructors. See [`erc20`](./examples/erc20/lib.rs) and other examples which use a `Mapping`. +- Remove `SpreadAllocate`, `SpreadLayout` and `PackedLayout` implementations. #### Removal of `wee-alloc` support + ink! uses a bump allocator by default, additionally we supported another allocator (`wee-alloc`) through a feature flag. `wee-alloc` is no longer maintained and we removed support for it. ### Changed -- Introduce `ink` entrance crate ‒ [#1223](https://github.com/use-ink/ink/pull/1223) -- Use `XXH32` instead of `sha256` for calculating storage keys ‒ [#1393](https://github.com/use-ink/ink/pull/1393) -- Storage Refactoring ‒ [#1331](https://github.com/use-ink/ink/pull/1331) + +- Introduce `ink` entrance crate ‒ [#1223](https://github.com/use-ink/ink/pull/1223) +- Use `XXH32` instead of `sha256` for calculating storage keys ‒ [#1393](https://github.com/use-ink/ink/pull/1393) +- Storage Refactoring ‒ [#1331](https://github.com/use-ink/ink/pull/1331) ### Fixed -- Trim single whitespace prefix in the metadata `docs` field ‒ [#1385](https://github.com/use-ink/ink/pull/1385) -- Allow pay_with_call to take multiple arguments ‒ [#1401](https://github.com/use-ink/ink/pull/1401) + +- Trim single whitespace prefix in the metadata `docs` field ‒ [#1385](https://github.com/use-ink/ink/pull/1385) +- Allow pay_with_call to take multiple arguments ‒ [#1401](https://github.com/use-ink/ink/pull/1401) ### Added -- Add `ink_env::pay_with_call!` helper macro for off-chain emulation of sending payments with contract message calls ‒ [#1379](https://github.com/use-ink/ink/pull/1379) + +- Add `ink_env::pay_with_call!` helper macro for off-chain emulation of sending payments with contract message calls ‒ [#1379](https://github.com/use-ink/ink/pull/1379) ### Removed -- Remove `wee-alloc` ‒ [#1403](https://github.com/use-ink/ink/pull/1403) + +- Remove `wee-alloc` ‒ [#1403](https://github.com/use-ink/ink/pull/1403) ## Version 4.0.0-alpha.2 @@ -1026,6 +1108,7 @@ so small errors like this are learning experiences for us. ## Version 4.0.0-alpha.1 ### Compatibility + In order to build contracts which use ink! `v4.0.0-alpha.1` you need to use `cargo-contract` [`v2.0.0-alpha.1`](https://github.com/use-ink/cargo-contract/releases/tag/v2.0.0-alpha.1). @@ -1040,31 +1123,35 @@ later than [6b85535](https://github.com/paritytech/substrate/tree/6b8553511112af The compatibility issues will be with `ChainExtension`'s and the functions mentioned above. ### Breaking Changes + This release contains a few breaking changes. These are indicated with the :x: emoji. Most of these were initially introduced in `v3.1.0` and `v3.2.0` releases but compatibility was restored in `v3.3.0`. -- As part of [#1224](https://github.com/use-ink/ink/pull/1224) the return type of `ink_env::set_contract_storage()` was changed to -return an `Option` instead of `()`. -- As part of [#1233](https://github.com/use-ink/ink/pull/1233) the `eth_compatibility` crate was removed. The - `ecdsa_to_eth_address()` function from it can now be found in the `ink_env` crate. -- As part of [#1267](https://github.com/use-ink/ink/pull/1267) an argument to `ink_lang::codegen::execute_constructor()` (which is - used internally by the ink! macros) was removed. -- As part of [#1313](https://github.com/use-ink/ink/pull/1313) the ink! ABI was changed so that the version was specified using a - dedicated `version` key instead of an implicit key which wrapped the entire ABI. +- As part of [#1224](https://github.com/use-ink/ink/pull/1224) the return type of `ink_env::set_contract_storage()` was changed to + return an `Option` instead of `()`. +- As part of [#1233](https://github.com/use-ink/ink/pull/1233) the `eth_compatibility` crate was removed. The + `ecdsa_to_eth_address()` function from it can now be found in the `ink_env` crate. +- As part of [#1267](https://github.com/use-ink/ink/pull/1267) an argument to `ink_lang::codegen::execute_constructor()` (which is + used internally by the ink! macros) was removed. +- As part of [#1313](https://github.com/use-ink/ink/pull/1313) the ink! ABI was changed so that the version was specified using a + dedicated `version` key instead of an implicit key which wrapped the entire ABI. ### Added -- :x: Add `Mapping::contains(key)` and `Mapping::insert_return_size(key, val)` ‒ [#1224](https://github.com/use-ink/ink/pull/1224) -- Add [`payment-channel`](https://github.com/use-ink/ink-examples/tree/main/payment-channel) example ‒ [#1248](https://github.com/use-ink/ink/pull/1248) -- :x: Add `version` field to ink! metadata ‒ [#1313](https://github.com/use-ink/ink/pull/1313) -- The `rand-extension` example has been adapted to an updated version of the `ChainExtension` API ‒ [#1356](https://github.com/use-ink/ink/pull/1356) + +- :x: Add `Mapping::contains(key)` and `Mapping::insert_return_size(key, val)` ‒ [#1224](https://github.com/use-ink/ink/pull/1224) +- Add [`payment-channel`](https://github.com/use-ink/ink-examples/tree/main/payment-channel) example ‒ [#1248](https://github.com/use-ink/ink/pull/1248) +- :x: Add `version` field to ink! metadata ‒ [#1313](https://github.com/use-ink/ink/pull/1313) +- The `rand-extension` example has been adapted to an updated version of the `ChainExtension` API ‒ [#1356](https://github.com/use-ink/ink/pull/1356) ### Changed -- :x: Contract size optimization in case contract doesn't accept payment ‒ [#1267](https://github.com/use-ink/ink/pull/1267) (thanks [@xgreenx](https://github.com/xgreenx)). -- Move ink! linter into `ink` repository ‒ [#1361](https://github.com/use-ink/ink/pull/1267) + +- :x: Contract size optimization in case contract doesn't accept payment ‒ [#1267](https://github.com/use-ink/ink/pull/1267) (thanks [@xgreenx](https://github.com/xgreenx)). +- Move ink! linter into `ink` repository ‒ [#1361](https://github.com/use-ink/ink/pull/1267) ### Removed -- :x: Implement `ecdsa_to_eth_address()` and remove `eth_compatibility` crate ‒ [#1233](https://github.com/use-ink/ink/pull/1233) + +- :x: Implement `ecdsa_to_eth_address()` and remove `eth_compatibility` crate ‒ [#1233](https://github.com/use-ink/ink/pull/1233) ## Version 3.3.1 @@ -1083,36 +1170,41 @@ compatibility with the [`v0.13.0`](https://github.com/paritytech/substrate-contr release of the `substrate-contracts-node`. ### Compatibility -This version will work fine with *substrate-contracts-node* versions from + +This version will work fine with _substrate-contracts-node_ versions from [0.13.0](https://github.com/paritytech/substrate-contracts-node/releases/tag/v0.13.0) up to [0.16.0](https://github.com/paritytech/substrate-contracts-node/releases/tag/v0.16.0). ### Changed -*Context: user-reported issues on our SE unveiled backward incompatibility introduced in 3.1.0 release.* + +_Context: user-reported issues on our SE unveiled backward incompatibility introduced in 3.1.0 release._ + 1. [CodeRejected when using ink! v3.1.0](https://substrate.stackexchange.com/questions/2721/cargo-contract-3-0-1) 1. [Incompatibility between ink! v3.0.1 and v3.2.0 ](https://substrate.stackexchange.com/questions/2870/cargo-contract-throws-error-about-supplied-arguments-in-inkconstructor-f) The following has been done to restore backward compatibility: -- Reverted backward-incompatible piece of [#1224](https://github.com/use-ink/ink/pull/1224). - - 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/use-ink/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/use-ink/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. + +- Reverted backward-incompatible piece of [#1224](https://github.com/use-ink/ink/pull/1224). + - 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/use-ink/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/use-ink/ink/pull/1233). + - The removal of the `eth_compatibility` crate should have been done in a `MAJOR` + release. + +All these breaking changes are subjects to the upcoming MAJOR _ink!_ release 4.0.0. ## Version 3.2.0 ### Compatibility + We recommend using a version of the [`pallet-contracts`](https://github.com/paritytech/substrate/tree/master/frame/contracts) later than [c0ee2ad](https://github.com/paritytech/substrate/tree/c0ee2adaa54b22ee0df5d1592cd0430961afd95c) (May 23, 2022) in your node. @@ -1121,17 +1213,21 @@ 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/use-ink/ink/pull/1267) (thanks [@xgreenx](https://github.com/xgreenx)). + +- Contract size optimization in case contract doesn't accept payment ‒ [#1267](https://github.com/use-ink/ink/pull/1267) (thanks [@xgreenx](https://github.com/xgreenx)). ### Changed -- Two functions have been stabilized: [`ink_env::ecdsa_recover`](https://use-ink.github.io/ink/ink_env/fn.ecdsa_recover.html) and [`ink_env::ecdsa_to_eth_address`](https://use-ink.github.io/ink/ink_env/fn.ecdsa_to_eth_address.html) ‒ [#1270](https://github.com/use-ink/ink/pull/1270) [#1273](https://github.com/use-ink/ink/pull/1273) + +- Two functions have been stabilized: [`ink_env::ecdsa_recover`](https://use-ink.github.io/ink/ink_env/fn.ecdsa_recover.html) and [`ink_env::ecdsa_to_eth_address`](https://use-ink.github.io/ink/ink_env/fn.ecdsa_to_eth_address.html) ‒ [#1270](https://github.com/use-ink/ink/pull/1270) [#1273](https://github.com/use-ink/ink/pull/1273) ### Fixed -- Fixed bug with recent Rust and `cargo test` ‒ [#1272](https://github.com/use-ink/ink/pull/1272) (thanks [@xgreenx](https://github.com/xgreenx)). + +- Fixed bug with recent Rust and `cargo test` ‒ [#1272](https://github.com/use-ink/ink/pull/1272) (thanks [@xgreenx](https://github.com/xgreenx)). ## Version 3.1.0 ### Compatibility + We recommend using a version of the [`pallet-contracts`](https://github.com/paritytech/substrate/tree/master/frame/contracts) later than [7d233c2](https://github.com/paritytech/substrate/tree/7d233c2446b5a60662400a0a4bcfb78bb3b79ff7) (May 13, 2022) in your node. @@ -1141,31 +1237,34 @@ This is the case in the latest release of the [`substrate-contracts-node`](https the latest Polkadot release [v0.9.22](https://github.com/paritytech/polkadot/releases/tag/v0.9.22). ### Breaking Changes + There are two breaking changes in this release: -* As part of [#1235](https://github.com/use-ink/ink/pull/1235) the message selectors of - your contract may change. A change of selectors would affect your client, frontend, Dapp, etc.. -* As part of [#1233](https://github.com/use-ink/ink/pull/1235) we removed the `eth_compatibility` - crate.

- Its recovery functionality has been moved to `ink_env` now: [`ink_env::ecdsa_to_eth_address`](https://use-ink.github.io/ink/ink_env/fn.ecdsa_to_eth_address.html). - The reason for this change is that we moved the gas-expensive crypto operations into `pallet-contracts`.

- The crates `to_default_account_id` function has been removed; the reason for this change is that ink! - doesn't have knowledge about the specific Substrate types on the underlying chain. - If you want to retain the function in your contract and are just using standard Substrate types - you should add the prior functionality to your contract ‒ it was a simple - `::hash(&ecdsa_pubkey[u8; 33])`. +- As part of [#1235](https://github.com/use-ink/ink/pull/1235) the message selectors of + your contract may change. A change of selectors would affect your client, frontend, Dapp, etc.. +- As part of [#1233](https://github.com/use-ink/ink/pull/1235) we removed the `eth_compatibility` + crate.

+ Its recovery functionality has been moved to `ink_env` now: [`ink_env::ecdsa_to_eth_address`](https://use-ink.github.io/ink/ink_env/fn.ecdsa_to_eth_address.html). + The reason for this change is that we moved the gas-expensive crypto operations into `pallet-contracts`.

+ The crates `to_default_account_id` function has been removed; the reason for this change is that ink! + doesn't have knowledge about the specific Substrate types on the underlying chain. + If you want to retain the function in your contract and are just using standard Substrate types + you should add the prior functionality to your contract ‒ it was a simple + `::hash(&ecdsa_pubkey[u8; 33])`. ### New API functions + We added two new `Mapping` API functions: [`Mapping::contains`](https://use-ink.github.io/ink/ink_storage/struct.Mapping.html#method.contains) and [`Mapping::insert_return_size`](https://use-ink.github.io/ink/ink_storage/struct.Mapping.html#method.insert_return_size) ‒ [#1224](https://github.com/use-ink/ink/pull/1224). These are more gas-efficient than whatever you were using previously. Additionally there are a couple new `ink_env` functions now: -* [`ink_env::set_code_hash`](https://use-ink.github.io/ink/ink_env/fn.set_code_hash.html) -* [`ink_env::own_code_hash`](https://use-ink.github.io/ink/ink_env/fn.own_code_hash.html) -* [`ink_env::code_hash`](https://use-ink.github.io/ink/ink_env/fn.code_hash.html) -* [`ink_env::ecdsa_to_eth_address`](https://use-ink.github.io/ink/ink_env/fn.ecdsa_to_eth_address.html) + +- [`ink_env::set_code_hash`](https://use-ink.github.io/ink/ink_env/fn.set_code_hash.html) +- [`ink_env::own_code_hash`](https://use-ink.github.io/ink/ink_env/fn.own_code_hash.html) +- [`ink_env::code_hash`](https://use-ink.github.io/ink/ink_env/fn.code_hash.html) +- [`ink_env::ecdsa_to_eth_address`](https://use-ink.github.io/ink/ink_env/fn.ecdsa_to_eth_address.html) ### New Upgradeable Contract Example @@ -1175,25 +1274,30 @@ It illustrates how the newly added [`ink_env::set_code_hash`](https://use-ink.gi can be used to implement an upgradeable contract that replaces its own code. ### Added -- Implement `seal_code_hash` and `seal_own_code_hash` ‒ [#1205](https://github.com/use-ink/ink/pull/1205) -- Add `set_code_hash` function and example ‒ [#1203](https://github.com/use-ink/ink/pull/1203) -- Implement [`ink_env::ecdsa_to_eth_address`](https://use-ink.github.io/ink/ink_env/fn.ecdsa_to_eth_address.html) ‒ [#1233](https://github.com/use-ink/ink/pull/1233) -- Add [`Mapping::contains(key)`](https://use-ink.github.io/ink/ink_storage/struct.Mapping.html#method.contains) and [`Mapping::insert_return_size(key, val)`](https://use-ink.github.io/ink/ink_storage/struct.Mapping.html#method.insert_return_size) ‒ [#1224](https://github.com/use-ink/ink/pull/1224) + +- Implement `seal_code_hash` and `seal_own_code_hash` ‒ [#1205](https://github.com/use-ink/ink/pull/1205) +- Add `set_code_hash` function and example ‒ [#1203](https://github.com/use-ink/ink/pull/1203) +- Implement [`ink_env::ecdsa_to_eth_address`](https://use-ink.github.io/ink/ink_env/fn.ecdsa_to_eth_address.html) ‒ [#1233](https://github.com/use-ink/ink/pull/1233) +- Add [`Mapping::contains(key)`](https://use-ink.github.io/ink/ink_storage/struct.Mapping.html#method.contains) and [`Mapping::insert_return_size(key, val)`](https://use-ink.github.io/ink/ink_storage/struct.Mapping.html#method.insert_return_size) ‒ [#1224](https://github.com/use-ink/ink/pull/1224) ### Fixed -- Fix ordering of message ids if the trait is implemented before the inherent section ‒ [#1235](https://github.com/use-ink/ink/pull/1235) + +- Fix ordering of message ids if the trait is implemented before the inherent section ‒ [#1235](https://github.com/use-ink/ink/pull/1235) ### Removed -- Removed `eth_compatibility` crate and moved its functionality partly into `ink_env` ‒ [#1233](https://github.com/use-ink/ink/pull/1233) + +- Removed `eth_compatibility` crate and moved its functionality partly into `ink_env` ‒ [#1233](https://github.com/use-ink/ink/pull/1233) ## Version 3.0.1 ### Changed -- Improve upgradeable examples folder structure, explain differences ‒ [#1188](https://github.com/use-ink/ink/pull/1188) + +- Improve upgradeable examples folder structure, explain differences ‒ [#1188](https://github.com/use-ink/ink/pull/1188) ### Fixed -- Update codegen after SCALE v3.1.2 release ‒ [#1189](https://github.com/use-ink/ink/pull/1189) -- Stop using `CallData` in `multisig` example doc test ‒ [#1202](https://github.com/use-ink/ink/pull/1202) + +- Update codegen after SCALE v3.1.2 release ‒ [#1189](https://github.com/use-ink/ink/pull/1189) +- Stop using `CallData` in `multisig` example doc test ‒ [#1202](https://github.com/use-ink/ink/pull/1202) ## Version 3.0.0 @@ -1202,9 +1306,10 @@ This is the stable release for ink! 3.0. It took us a while to get here and going forward we want to do smaller releases more often. -*Please note that ink! has not been audited.* +_Please note that ink! has not been audited._ ### Compatibility + We recommend using a version of the `contracts` pallet later than [cc282f84ba53ed2a08374d2a655dc8f08cbc5e86](https://github.com/paritytech/substrate/tree/cc282f84ba53ed2a08374d2a655dc8f08cbc5e86) (March 15, 2022) in your node. @@ -1213,7 +1318,9 @@ This is the case in the latest release of the `substrate-contracts-node`: [v0.10.0](https://github.com/paritytech/substrate-contracts-node/releases/tag/v0.10.0). ### Breaking Changes + #### We replaced the default off-chain testing environment + The off-chain testing environment can be used to write unit tests for your smart contract with a simulated chain. We've now replaced the existing off-chain environment with a new @@ -1229,17 +1336,19 @@ can find more "template use-cases" there (e.g. for [chain extension testing](https://github.com/use-ink/ink-examples/tree/main/rand-extension)) #### We removed the dynamic storage allocator + More details on the reasoning behind this can be found in [#1148](https://github.com/use-ink/ink/pull/1148). #### `CallBuilder` API changed to support `delegate` calls + The `CallBuilder` API changed to now support two types of calls: -* `Call`: a cross-contract call.
- This was the default until this new API change. -* `DelegateCall`: a delegated call.
- This enables writing upgradeable contracts using - the `delegate` pattern. An example has been added to demonstrate this: - [`delegate-calls`](https://github.com/use-ink/ink-examples/tree/main/upgradeable-contracts). +- `Call`: a cross-contract call.
+ This was the default until this new API change. +- `DelegateCall`: a delegated call.
+ This enables writing upgradeable contracts using + the `delegate` pattern. An example has been added to demonstrate this: + [`delegate-calls`](https://github.com/use-ink/ink-examples/tree/main/upgradeable-contracts). This is a breaking change, users must now specify the `call_type` to the builder manually. @@ -1253,28 +1362,32 @@ The API for `eval_contract` and `invoke_contract` changed. You can read more about the change in [#1165](https://github.com/use-ink/ink/pull/1165). ### Added -- Added `keep_attr` to `#[ink::contract]` and `#[ink::trait_definition]` ‒ [#1145](https://github.com/use-ink/ink/pull/1145) (thanks [@xgreenx](https://github.com/xgreenx)).. -- Implemented the `seal_is_contract` and `seal_caller_is_origin` API ‒ [#1129](https://github.com/use-ink/ink/pull/1129) [#1166](https://github.com/use-ink/ink/pull/1166). -- Add tests in experimental off-chain env for `trait-erc20` ‒ [#1158](https://github.com/use-ink/ink/pull/1158). -- Add tests in experimental off-chain env for `erc721` ‒ [#1157](https://github.com/use-ink/ink/pull/1157). -- Add tests in experimental off-chain env for `multisig` ‒ [#1159](https://github.com/use-ink/ink/pull/1159). -- Add tests in experimental off-chain env for `dns` ‒ [#1156](https://github.com/use-ink/ink/pull/1156). -- Implemented chain extension testing in experimental off-chain env ‒ [#1152](https://github.com/use-ink/ink/pull/1152). + +- Added `keep_attr` to `#[ink::contract]` and `#[ink::trait_definition]` ‒ [#1145](https://github.com/use-ink/ink/pull/1145) (thanks [@xgreenx](https://github.com/xgreenx)).. +- Implemented the `seal_is_contract` and `seal_caller_is_origin` API ‒ [#1129](https://github.com/use-ink/ink/pull/1129) [#1166](https://github.com/use-ink/ink/pull/1166). +- Add tests in experimental off-chain env for `trait-erc20` ‒ [#1158](https://github.com/use-ink/ink/pull/1158). +- Add tests in experimental off-chain env for `erc721` ‒ [#1157](https://github.com/use-ink/ink/pull/1157). +- Add tests in experimental off-chain env for `multisig` ‒ [#1159](https://github.com/use-ink/ink/pull/1159). +- Add tests in experimental off-chain env for `dns` ‒ [#1156](https://github.com/use-ink/ink/pull/1156). +- Implemented chain extension testing in experimental off-chain env ‒ [#1152](https://github.com/use-ink/ink/pull/1152). ### Changed -- Replaced default off-chain testing engine with experimental one ‒ [#1144](https://github.com/use-ink/ink/pull/1144). -- Changed `CallBuilder` API to now support delegate calls ‒ [#1133](https://github.com/use-ink/ink/pull/1133) (thanks [@VargSupercolony](https://github.com/VargSupercolony) and [@xgreenx](https://github.com/xgreenx)). -- Unify `ink_env::{eval_contract, invoke_contract}` ‒ [#1165](https://github.com/use-ink/ink/pull/1165). + +- Replaced default off-chain testing engine with experimental one ‒ [#1144](https://github.com/use-ink/ink/pull/1144). +- Changed `CallBuilder` API to now support delegate calls ‒ [#1133](https://github.com/use-ink/ink/pull/1133) (thanks [@VargSupercolony](https://github.com/VargSupercolony) and [@xgreenx](https://github.com/xgreenx)). +- Unify `ink_env::{eval_contract, invoke_contract}` ‒ [#1165](https://github.com/use-ink/ink/pull/1165). ### Removed -- Removed the dynamic storage allocator ‒ [#1148](https://github.com/use-ink/ink/pull/1148). -- Removed `compile_as_dependency` config option ‒ [#1168](https://github.com/use-ink/ink/pull/1168). + +- Removed the dynamic storage allocator ‒ [#1148](https://github.com/use-ink/ink/pull/1148). +- Removed `compile_as_dependency` config option ‒ [#1168](https://github.com/use-ink/ink/pull/1168). ## Version 3.0-rc9 This is the 9th release candidate for ink! 3.0. ### Breaking Changes + #### We removed all data structures other than `Mapping` from the public ink! API This is a drastic breaking change; it was no easy decision for us. @@ -1299,27 +1412,32 @@ In this release candidate we upgraded `scale-info` and `parity-scale-codec`. You version in your contract's `Cargo.toml` as well; `cargo-contract` will throw an error otherwise. The `Cargo.toml` should contain + ``` scale-info = { version = "2", default-features = false, features = ["derive"], optional = true } scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive", "full"] } ``` ### Added -- Export `ink_lang::utils::initialize_contract(…)` - [#1077](https://github.com/use-ink/ink/pull/1077). -- Add `get_owner()` function to `dns` example contract - [#1118](https://github.com/use-ink/ink/pull/1118) (thanks [@agryaznov](https://github.com/agryaznov)). -- Improved usage documentation of `ink_storage::Mapping` - [#1138](https://github.com/use-ink/ink/pull/1138). + +- Export `ink_lang::utils::initialize_contract(…)` - [#1077](https://github.com/use-ink/ink/pull/1077). +- Add `get_owner()` function to `dns` example contract - [#1118](https://github.com/use-ink/ink/pull/1118) (thanks [@agryaznov](https://github.com/agryaznov)). +- Improved usage documentation of `ink_storage::Mapping` - [#1138](https://github.com/use-ink/ink/pull/1138). ### Changed -- Updated to `parity-scale-codec = "3"` and `scale-info = "2"` - [#1132](https://github.com/use-ink/ink/pull/1132). + +- Updated to `parity-scale-codec = "3"` and `scale-info = "2"` - [#1132](https://github.com/use-ink/ink/pull/1132). ### Removed -- Remove `collection` and `lazy` modules from public ink! API - [#1111](https://github.com/use-ink/ink/pull/1111). -- Remove `Memory` from public ink! API - [#1137](https://github.com/use-ink/ink/pull/1137). + +- Remove `collection` and `lazy` modules from public ink! API - [#1111](https://github.com/use-ink/ink/pull/1111). +- Remove `Memory` from public ink! API - [#1137](https://github.com/use-ink/ink/pull/1137). ### Fixed -- Fix bug with referencing two external trait definitions - [#1141](https://github.com/use-ink/ink/pull/1141). -- Explicitly specify trait in dispatching - [#1131](https://github.com/use-ink/ink/pull/1131) (thanks [@xgreenx](https://github.com/xgreenx)). -- Make `rust-analyzer` expand ink! macros without warning - [#1107](https://github.com/use-ink/ink/pull/1107). + +- Fix bug with referencing two external trait definitions - [#1141](https://github.com/use-ink/ink/pull/1141). +- Explicitly specify trait in dispatching - [#1131](https://github.com/use-ink/ink/pull/1131) (thanks [@xgreenx](https://github.com/xgreenx)). +- Make `rust-analyzer` expand ink! macros without warning - [#1107](https://github.com/use-ink/ink/pull/1107). ## Version 3.0-rc8 @@ -1340,18 +1458,23 @@ the user interface you are using. For `polkadot-js/api` and `polkadot-js/apps` t changes are supported since Jan 19, 2022. ### Metadata Changes + There are two metadata changes in this release candidate: #### For messages and constructors: `name: Array` ➔ `label: String` The messages and constructors exposed by a contract were previously denoted with + ```json "name": ["foo", "bar"] ``` + Now they are instead denoted with + ```json "label": "foo" ``` + For public contract methods that are implemented from a trait, the trait name is prefixed to the method name with `::` as the separator. So e.g. `trait_name::get_owner`. @@ -1359,6 +1482,7 @@ The ink! PR which implemented this is [#923](https://github.com/use-ink/ink/pull for the `polkadot-js/api` it was [polkadot-js/api#4255](https://github.com/polkadot-js/api/pull/4255). #### Constructors got a new field: `payable: bool` + Constructors now have to be specified `payable` if it's intended for them to receive value (i.e. tokens). This is a breaking change, beforehand they were by default payable, now they are by default non-payable. @@ -1367,17 +1491,19 @@ The ink! PR which implemented this is [#1065](https://github.com/use-ink/ink/pul metadata to V3 is [#1100](https://github.com/use-ink/ink/pull/1100), and for the `polkadot-js/api` it was [polkadot-js/api#4432](https://github.com/polkadot-js/api/pull/4432). ### Changed -- Update metadata to support payable constructors - [#1100](https://github.com/use-ink/ink/pull/1100). -- Make constructors non-payable by default, require specifying `payable` explicitly - [#1065](https://github.com/use-ink/ink/pull/1065). -- Renamed the error code `EcdsaRecoverFailed` to `EcdsaRecoveryFailed` ‒ [#1064](https://github.com/use-ink/ink/pull/1064). -- Renamed the `ink_env` function `transferred_balance()` to `transferred_value()` ‒ [#1063](https://github.com/use-ink/ink/pull/1063). -- Removed the error codes `BelowSubsistenceThreshold` and `NewContractNotFunded` ‒ [#1062](https://github.com/use-ink/ink/pull/1062). -- Updated ink! to use the most recent `contracts` pallet API ‒ [#1053](https://github.com/use-ink/ink/pull/1053). -- Explicitly link against `rlibc` to get non-buggy version of `memcpy` ‒ [#1049](https://github.com/use-ink/ink/pull/1049). -- Changed the metadata field `name` to `label` for messages and constructors ‒ [#923](https://github.com/use-ink/ink/pull/923) (thanks [@xgreenx](https://github.com/xgreenx)). + +- Update metadata to support payable constructors - [#1100](https://github.com/use-ink/ink/pull/1100). +- Make constructors non-payable by default, require specifying `payable` explicitly - [#1065](https://github.com/use-ink/ink/pull/1065). +- Renamed the error code `EcdsaRecoverFailed` to `EcdsaRecoveryFailed` ‒ [#1064](https://github.com/use-ink/ink/pull/1064). +- Renamed the `ink_env` function `transferred_balance()` to `transferred_value()` ‒ [#1063](https://github.com/use-ink/ink/pull/1063). +- Removed the error codes `BelowSubsistenceThreshold` and `NewContractNotFunded` ‒ [#1062](https://github.com/use-ink/ink/pull/1062). +- Updated ink! to use the most recent `contracts` pallet API ‒ [#1053](https://github.com/use-ink/ink/pull/1053). +- Explicitly link against `rlibc` to get non-buggy version of `memcpy` ‒ [#1049](https://github.com/use-ink/ink/pull/1049). +- Changed the metadata field `name` to `label` for messages and constructors ‒ [#923](https://github.com/use-ink/ink/pull/923) (thanks [@xgreenx](https://github.com/xgreenx)). ### Added -- Added a `remove` method to the `Mapping` data structure ‒ [#1023](https://github.com/use-ink/ink/pull/1023). + +- Added a `remove` method to the `Mapping` data structure ‒ [#1023](https://github.com/use-ink/ink/pull/1023). ## Version 3.0-rc7 @@ -1405,58 +1531,62 @@ Specifically you need to upgrade to at least the pallet version (or newer than Nov 24). ### Removed -- Removed the state rent API ‒ [#1036](https://github.com/use-ink/ink/pull/1036). + +- Removed the state rent API ‒ [#1036](https://github.com/use-ink/ink/pull/1036). ### Added -- Added support for wildcard selectors ‒ [#1020](https://github.com/use-ink/ink/pull/1020). - - This enables writing upgradeable smart contracts using the proxy/forward pattern. - - Annotating a wildcard selector in traits is not supported. -- The ink! codegen now heavily relies on static type information based on traits defined in `ink_lang` ‒ [#665](https://github.com/use-ink/ink/pull/665). - - Some of those traits and their carried information can be used for static reflection of ink! - smart contracts. Those types and traits reside in the new `ink_lang::reflect` module and is - publicly usable by ink! smart contract authors. + +- Added support for wildcard selectors ‒ [#1020](https://github.com/use-ink/ink/pull/1020). + - This enables writing upgradeable smart contracts using the proxy/forward pattern. + - Annotating a wildcard selector in traits is not supported. +- The ink! codegen now heavily relies on static type information based on traits defined in `ink_lang` ‒ [#665](https://github.com/use-ink/ink/pull/665). + - Some of those traits and their carried information can be used for static reflection of ink! + smart contracts. Those types and traits reside in the new `ink_lang::reflect` module and is + publicly usable by ink! smart contract authors. ### Changed -- Upgraded to the `seal_call` v1 API ‒ [#960](https://github.com/use-ink/ink/pull/960). - - This API now enables control over the behavior of cross-contract calls, e.g. to forward/clone input, - enable tail calls and control reentrancy. - The crate documentation contains more details on the [`CallFlags`](https://use-ink.github.io/ink/ink_env/struct.CallFlags.html). - - **Note:** The default behavior of cross-contract calls now disallows reentering the calling contract. -- ink! contract definitions via `#[ink::contract]` ‒ [#665](https://github.com/use-ink/ink/pull/665).
- For ink! smart contracts we now generate two contract types. Given `MyContract`: - - `MyContract` will still be the storage struct. - However, it can now additionally be used as static dependency in other smart contracts. - Static dependencies can be envisioned as being directly embedded into a smart contract. - - `MyContractRef` is pretty much the same of what we had gotten with the old `ink-as-dependency`. - It is a typed thin-wrapper around an `AccountId` that is mirroring the ink! smart contract's API - and implemented traits. -- ink! trait definitions via `#[ink::trait_definition]` ‒ [#665](https://github.com/use-ink/ink/pull/665). - - ink! trait definitions no longer can define trait constructors. - - ink! trait implementations now inherit `selector` and `payable` properties for trait messages. - - Now explicitly setting `selector` or `payable` property for an implemented ink! trait method - will only act as a guard that the set property is in fact the same as defined by the ink! - trait definition. -- Improved some ink! specific compile errors ‒ [#665](https://github.com/use-ink/ink/pull/665). - - For example, when using ink! messages and constructors which have inputs (or - outputs) that cannot be encoded (or decoded) using the SCALE codec. -- Simplified selector computation for ink! trait methods ‒ [#665](https://github.com/use-ink/ink/pull/665). - - Now selectors are encoded as `blake2b({namespace}::{trait_identifier}::{message_identifier})[0..4]`. - If no `namespace` is set for the ink! trait definition then the formula is - `blake2b({trait_identifier}::{message_identifier})[0..4]`. - Where `trait_identifier` and `message_identifier` both refer to the identifiers of the ink! trait - definition and ink! trait message respectively. -- We switched to Rust edition 2021 ‒ [#977](https://github.com/use-ink/ink/pull/977). -- Update chain extension example to show argument passing ‒ [#1029](https://github.com/use-ink/ink/pull/1029). + +- Upgraded to the `seal_call` v1 API ‒ [#960](https://github.com/use-ink/ink/pull/960). + - This API now enables control over the behavior of cross-contract calls, e.g. to forward/clone input, + enable tail calls and control reentrancy. + The crate documentation contains more details on the [`CallFlags`](https://use-ink.github.io/ink/ink_env/struct.CallFlags.html). + - **Note:** The default behavior of cross-contract calls now disallows reentering the calling contract. +- ink! contract definitions via `#[ink::contract]` ‒ [#665](https://github.com/use-ink/ink/pull/665).
+ For ink! smart contracts we now generate two contract types. Given `MyContract`: + - `MyContract` will still be the storage struct. + However, it can now additionally be used as static dependency in other smart contracts. + Static dependencies can be envisioned as being directly embedded into a smart contract. + - `MyContractRef` is pretty much the same of what we had gotten with the old `ink-as-dependency`. + It is a typed thin-wrapper around an `AccountId` that is mirroring the ink! smart contract's API + and implemented traits. +- ink! trait definitions via `#[ink::trait_definition]` ‒ [#665](https://github.com/use-ink/ink/pull/665). + - ink! trait definitions no longer can define trait constructors. + - ink! trait implementations now inherit `selector` and `payable` properties for trait messages. + - Now explicitly setting `selector` or `payable` property for an implemented ink! trait method + will only act as a guard that the set property is in fact the same as defined by the ink! + trait definition. +- Improved some ink! specific compile errors ‒ [#665](https://github.com/use-ink/ink/pull/665). + - For example, when using ink! messages and constructors which have inputs (or + outputs) that cannot be encoded (or decoded) using the SCALE codec. +- Simplified selector computation for ink! trait methods ‒ [#665](https://github.com/use-ink/ink/pull/665). + - Now selectors are encoded as `blake2b({namespace}::{trait_identifier}::{message_identifier})[0..4]`. + If no `namespace` is set for the ink! trait definition then the formula is + `blake2b({trait_identifier}::{message_identifier})[0..4]`. + Where `trait_identifier` and `message_identifier` both refer to the identifiers of the ink! trait + definition and ink! trait message respectively. +- We switched to Rust edition 2021 ‒ [#977](https://github.com/use-ink/ink/pull/977). +- Update chain extension example to show argument passing ‒ [#1029](https://github.com/use-ink/ink/pull/1029). ### Fixed -- Contracts now revert the transaction if an ink! message returns `Result::Err` ‒ [#975](https://github.com/use-ink/ink/pull/975), [#998](https://github.com/use-ink/ink/pull/998). - - It is still possible to match against a `Result` return type for a called dependency contract - ‒ i.e. a sub-contract specified in the contract's `Cargo.toml`. -- We implemented a number of Wasm contract size improvements: - - Simple Mapping Storage Primitive ‒ [#946](https://github.com/use-ink/ink/pull/946). - - Remove `always` from `inline` to allow compiler decide that to do ‒ [#1012](https://github.com/use-ink/ink/pull/1012) (thanks [@xgreenx](https://github.com/xgreenx)). - - Add a way to allocate a storage facility using spread (and packed) layouts ‒ [#978](https://github.com/use-ink/ink/pull/978). - - Extract non-generic part of `push_topic` to reduce code size ‒ [#1026](https://github.com/use-ink/ink/pull/1026). + +- Contracts now revert the transaction if an ink! message returns `Result::Err` ‒ [#975](https://github.com/use-ink/ink/pull/975), [#998](https://github.com/use-ink/ink/pull/998). + - It is still possible to match against a `Result` return type for a called dependency contract + ‒ i.e. a sub-contract specified in the contract's `Cargo.toml`. +- We implemented a number of Wasm contract size improvements: + - Simple Mapping Storage Primitive ‒ [#946](https://github.com/use-ink/ink/pull/946). + - Remove `always` from `inline` to allow compiler decide that to do ‒ [#1012](https://github.com/use-ink/ink/pull/1012) (thanks [@xgreenx](https://github.com/xgreenx)). + - Add a way to allocate a storage facility using spread (and packed) layouts ‒ [#978](https://github.com/use-ink/ink/pull/978). + - Extract non-generic part of `push_topic` to reduce code size ‒ [#1026](https://github.com/use-ink/ink/pull/1026). ## Version 3.0-rc6 @@ -1467,6 +1597,7 @@ This is the 6th release candidate for ink! 3.0. #### Please upgrade `cargo-contract` You need to update to the latest `cargo-contract` in order to use this release: + ``` cargo install cargo-contract --vers ^0.15 --force --locked ``` @@ -1481,6 +1612,7 @@ version in your contract's `Cargo.toml` as well; `cargo-contract` will throw an error otherwise. The `Cargo.toml` should contain + ``` scale-info = { version = "1.0", default-features = false, features = ["derive"], optional = true } scale = { package = "parity-scale-codec", version = "2", default-features = false, features = ["derive", "full"] } @@ -1490,31 +1622,34 @@ scale = { package = "parity-scale-codec", version = "2", default-features = fals There are breaking changes to the metadata format in this release. -- Removes top level `metadataVersion` field from the contract metadata (https://github.com/use-ink/cargo-contract/pull/342/files). -- Introduces new top level versioned metadata [enum](https://github.com/use-ink/ink/blob/master/crates/metadata/src/lib.rs#L68). -- Upgrades to `scale-info` version `1.0` (https://github.com/use-ink/ink/pull/845). - - The previous supported version was `0.6`, so check release notes for all changes since then: https://github.com/use-ink/ink/pull/845 - - One of the main changes to be aware of is the change to 0 based type lookup ids: https://github.com/paritytech/scale-info/pull/90 +- Removes top level `metadataVersion` field from the contract metadata (https://github.com/use-ink/cargo-contract/pull/342/files). +- Introduces new top level versioned metadata [enum](https://github.com/use-ink/ink/blob/master/crates/metadata/src/lib.rs#L68). +- Upgrades to `scale-info` version `1.0` (https://github.com/use-ink/ink/pull/845). + - The previous supported version was `0.6`, so check release notes for all changes since then: https://github.com/use-ink/ink/pull/845 + - One of the main changes to be aware of is the change to 0 based type lookup ids: https://github.com/paritytech/scale-info/pull/90 ### Added -- Added an Ethereum-compatibility function to recover a public key from an ECDSA signature and message hash - [#914](https://github.com/use-ink/ink/pull/914) (thanks [@xgreenx](https://github.com/xgreenx)). -- Added new utility proc. macros to `ink_lang` crate - [#947](https://github.com/use-ink/ink/pull/947): - - `blake2!`: Compute the BLAKE2b 256-bit hash of the given input literal string. - - `selector_bytes!`: Compute the ink! selector of the given input literal string and return it as `[u8; 4]`. - - `selector_id!`: Compute the ink! selector of the given input literal string and return it as `u32`. + +- Added an Ethereum-compatibility function to recover a public key from an ECDSA signature and message hash - [#914](https://github.com/use-ink/ink/pull/914) (thanks [@xgreenx](https://github.com/xgreenx)). +- Added new utility proc. macros to `ink_lang` crate - [#947](https://github.com/use-ink/ink/pull/947): + - `blake2!`: Compute the BLAKE2b 256-bit hash of the given input literal string. + - `selector_bytes!`: Compute the ink! selector of the given input literal string and return it as `[u8; 4]`. + - `selector_id!`: Compute the ink! selector of the given input literal string and return it as `u32`. ### Changed -- Update to `scale-info` 1.0 - [#845](https://github.com/use-ink/ink/pull/845). -- Message and constructor selectors no longer take their inputs as string, but as `u32` decodable integer - [#928](https://github.com/use-ink/ink/pull/928).
- For example: - - It is no longer possible to specify a selector as `#[ink(selector = "0xC0DECAFE")]`. - - The newly allowed formats are `#[ink(selector = 0xC0DECAFE)]` and `#[ink(selector = 42)]`. - - Smart contract authors are required to update their smart contracts for this change. -- Improved the `multisig` example - [#962](https://github.com/use-ink/ink/pull/962). -- Changed the link to our beginner's workshop to the migrated workshop on `substrate.io` - [#957](https://github.com/use-ink/ink/pull/957). + +- Update to `scale-info` 1.0 - [#845](https://github.com/use-ink/ink/pull/845). +- Message and constructor selectors no longer take their inputs as string, but as `u32` decodable integer - [#928](https://github.com/use-ink/ink/pull/928).
+ For example: + - It is no longer possible to specify a selector as `#[ink(selector = "0xC0DECAFE")]`. + - The newly allowed formats are `#[ink(selector = 0xC0DECAFE)]` and `#[ink(selector = 42)]`. + - Smart contract authors are required to update their smart contracts for this change. +- Improved the `multisig` example - [#962](https://github.com/use-ink/ink/pull/962). +- Changed the link to our beginner's workshop to the migrated workshop on `substrate.io` - [#957](https://github.com/use-ink/ink/pull/957). ### Fixed -- Fixed a mistake in the `ink_env::block_timestamp()` documentation - [#937](https://github.com/use-ink/ink/pull/937). + +- Fixed a mistake in the `ink_env::block_timestamp()` documentation - [#937](https://github.com/use-ink/ink/pull/937). ## Version 3.0-rc5 (2021-09-08) @@ -1525,6 +1660,7 @@ The list below shows the additions, changes and fixes that are visible to users ### Compatibility Make sure to use a recent Rust nightly and `cargo-contract` with the current release: + ``` cargo install cargo-contract --vers ^0.14 --force --locked && rustup update ``` @@ -1540,18 +1676,22 @@ It fulfills the same purpose the `canvas-node` did before ‒ it's a standalone just Substrate's [`node-template`](https://github.com/paritytech/substrate/tree/master/bin/node-template) modified to include [the `contracts` pallet](https://github.com/paritytech/substrate/tree/master/frame/contracts). You can install the newest version like this: + ``` cargo install contracts-node --git https://github.com/paritytech/substrate-contracts-node.git --force ``` + After you've installed the node it can be run via `substrate-contracts-node --tmp --dev`. ### Added -- Added example for mocking chain extensions in off-chain tests ‒ [#882](https://github.com/use-ink/ink/pull/882). -- Panic messages are now printed to debug buffer ‒ [#894](https://github.com/use-ink/ink/pull/894). + +- Added example for mocking chain extensions in off-chain tests ‒ [#882](https://github.com/use-ink/ink/pull/882). +- Panic messages are now printed to debug buffer ‒ [#894](https://github.com/use-ink/ink/pull/894). ### Changed -- Unlicensed smart contract examples ‒ [#888](https://github.com/use-ink/ink/pull/888). -- Stabilized `seal_debug_message` ‒ [#902](https://github.com/use-ink/ink/pull/902). + +- Unlicensed smart contract examples ‒ [#888](https://github.com/use-ink/ink/pull/888). +- Stabilized `seal_debug_message` ‒ [#902](https://github.com/use-ink/ink/pull/902). ## Version 3.0-rc4 (2021-07-19) @@ -1563,12 +1703,12 @@ The list below shows the additions, changes and fixes that are visible to users ink! 3.0-rc4 is compatible with -- The "ink! CLI" [`cargo-contract`](https://github.com/use-ink/cargo-contract) - version `0.13.0` or newer. - - Install the newest version using `cargo install --force cargo-contract`. -- Substrate version `4.0.0-dev` including the `contracts-pallet` version `4.0.0-dev`. -- [`substrate-contracts-node`](https://github.com/paritytech/substrate-contracts-node) version `0.1.0` or newer. - - Install the newest version using `cargo install contracts-node --git https://github.com/paritytech/substrate-contracts-node.git --force`. +- The "ink! CLI" [`cargo-contract`](https://github.com/use-ink/cargo-contract) + version `0.13.0` or newer. + - Install the newest version using `cargo install --force cargo-contract`. +- Substrate version `4.0.0-dev` including the `contracts-pallet` version `4.0.0-dev`. +- [`substrate-contracts-node`](https://github.com/paritytech/substrate-contracts-node) version `0.1.0` or newer. + - Install the newest version using `cargo install contracts-node --git https://github.com/paritytech/substrate-contracts-node.git --force`. The documentation on our [Documentation Portal](https://use.ink) is up-to-date with this release candidate. Since the last release candidate we notably @@ -1580,70 +1720,73 @@ there. In order to ensure a continuously high quality of our codebase we implemented a number of key improvements to our testing setup: -- We've put an emphasis on automated testing of the usage examples in our crate documentation. - Those are now tested in the context of a complete ink! contract. In the past this was not - always the case, sometimes usage examples were just isolated code snippets. -- We started our [`ink-waterfall`](https://github.com/use-ink/ink-waterfall) project, - which runs End-to-End tests through our entire stack. - All our examples are continuously built using the latest `cargo-contract`. They are - subsequently deployed on the latest `substrate-contracts-node` by emulating browser interactions with - both the [`canvas-ui`](https://use-ink.github.io/canvas-ui/#/) and the - [`polkadot-js`](https://polkadot.js.org/apps/#/) UI. - This testing setup enables us to detect bugs which only appear in the context of using - multiple components together early on. -- To improve the readability of our documentation we introduced automated grammar and spell - checking into our Continuous Integration environment. +- We've put an emphasis on automated testing of the usage examples in our crate documentation. + Those are now tested in the context of a complete ink! contract. In the past this was not + always the case, sometimes usage examples were just isolated code snippets. +- We started our [`ink-waterfall`](https://github.com/use-ink/ink-waterfall) project, + which runs End-to-End tests through our entire stack. + All our examples are continuously built using the latest `cargo-contract`. They are + subsequently deployed on the latest `substrate-contracts-node` by emulating browser interactions with + both the [`canvas-ui`](https://use-ink.github.io/canvas-ui/#/) and the + [`polkadot-js`](https://polkadot.js.org/apps/#/) UI. + This testing setup enables us to detect bugs which only appear in the context of using + multiple components together early on. +- To improve the readability of our documentation we introduced automated grammar and spell + checking into our Continuous Integration environment. ### Added -- Added support for the new `seal_random` API ‒ [#734](https://github.com/use-ink/ink/pull/734). -- Added missing documentation for the `ink_storage_derive` procedural macros ‒ [#711](https://github.com/use-ink/ink/pull/711). -- Implemented the (unstable) `seal_rent_params` API ‒ [#755](https://github.com/use-ink/ink/pull/755). -- Implemented the (unstable) `seal_rent_status` API ‒ [#798](https://github.com/use-ink/ink/pull/798). -- Implemented the (unstable) `seal_debug_message` API ‒ [#792](https://github.com/use-ink/ink/pull/792). - - Printing debug messages can now be achieved via `ink_env::debug_println!(…)`. - - See [our documentation](https://use.ink/faq#how-do-i-print-something-to-the-console-from-the-runtime) - for more information. - - The examples have been updated to reflect this new way of printing debug messages. -- Added usage comments with code examples to the `ink_env` API ‒ [#797](https://github.com/use-ink/ink/pull/797). - - The [published crate documentation](https://use-ink.github.io/ink/ink_lang/struct.EnvAccess.html) now contains - much more code examples for the methods behind `self.env()` and `Self::env()`. -- Added an example implementation for ERC-1155, a multi-token standard ‒ [#800](https://github.com/use-ink/ink/pull/800). -- Implemented binary search for `collections::Vec` ‒ [#836](https://github.com/use-ink/ink/pull/836). -- Added the ability of submitting payable transactions to the `multisig` example ‒ [#820](https://github.com/use-ink/ink/pull/820). -- Implemented `Decode` for `Error` types in the examples, enabling building them as dependencies ‒ [#761](https://github.com/use-ink/ink/pull/761). -- We started working on a new off-chain environment testing engine ‒ [#712](https://github.com/use-ink/ink/pull/712). - - The old testing environment has a number of limitations, which we are well aware of. - We're confident that with the new testing engine we will be able to conduct much more - elaborate testing in an emulated chain environment. - - For the moment, the new engine is unstable and only available behind a feature flag. - A number of examples have already been converted to support the new testing engine. + +- Added support for the new `seal_random` API ‒ [#734](https://github.com/use-ink/ink/pull/734). +- Added missing documentation for the `ink_storage_derive` procedural macros ‒ [#711](https://github.com/use-ink/ink/pull/711). +- Implemented the (unstable) `seal_rent_params` API ‒ [#755](https://github.com/use-ink/ink/pull/755). +- Implemented the (unstable) `seal_rent_status` API ‒ [#798](https://github.com/use-ink/ink/pull/798). +- Implemented the (unstable) `seal_debug_message` API ‒ [#792](https://github.com/use-ink/ink/pull/792). + - Printing debug messages can now be achieved via `ink_env::debug_println!(…)`. + - See [our documentation](https://use.ink/faq#how-do-i-print-something-to-the-console-from-the-runtime) + for more information. + - The examples have been updated to reflect this new way of printing debug messages. +- Added usage comments with code examples to the `ink_env` API ‒ [#797](https://github.com/use-ink/ink/pull/797). + - The [published crate documentation](https://use-ink.github.io/ink/ink_lang/struct.EnvAccess.html) now contains + much more code examples for the methods behind `self.env()` and `Self::env()`. +- Added an example implementation for ERC-1155, a multi-token standard ‒ [#800](https://github.com/use-ink/ink/pull/800). +- Implemented binary search for `collections::Vec` ‒ [#836](https://github.com/use-ink/ink/pull/836). +- Added the ability of submitting payable transactions to the `multisig` example ‒ [#820](https://github.com/use-ink/ink/pull/820). +- Implemented `Decode` for `Error` types in the examples, enabling building them as dependencies ‒ [#761](https://github.com/use-ink/ink/pull/761). +- We started working on a new off-chain environment testing engine ‒ [#712](https://github.com/use-ink/ink/pull/712). + - The old testing environment has a number of limitations, which we are well aware of. + We're confident that with the new testing engine we will be able to conduct much more + elaborate testing in an emulated chain environment. + - For the moment, the new engine is unstable and only available behind a feature flag. + A number of examples have already been converted to support the new testing engine. ### Changed -- To reduce a contract's space footprint we switched the default allocator to a bump allocator implementation ‒ [#831](https://github.com/use-ink/ink/pull/831). -- A couple of readme's have been reworked: - - Our main ink! readme ‒ [#774](https://github.com/use-ink/ink/pull/774). - - The `rand-extension` example readme ‒ [#793](https://github.com/use-ink/ink/pull/793). - - The `delegator` example readme ‒ [#766](https://github.com/use-ink/ink/pull/766). -- With the stabilization of Rust 1.51 we ware able to remove the `ink-unstable` feature, making - `collections::SmallVec` and `lazy::LazyArray` available by default ‒ [#746](https://github.com/use-ink/ink/pull/746). -- To resolve confusion, we migrated all usages of `#[test]` in our examples to `#[ink::test]` ‒ [#746](https://github.com/use-ink/ink/pull/746). - - The difference is that `#[ink::test]` spawns an emulated chain environment (an "off-chain" environment) - and hence comes with a bit of overhead. It was not always clear to users when they require - an off-chain environment, we decided to mitigate this confusion by using an emulated chain - environment for all our example tests. -- With the stabilization of Rust's `min_const_generics` we were able to replace the fixed - size implementations of `SpreadLayout` and `PackedLayout` for Arrays. These traits are - now implemented for all Arrays of size `usize` ‒ [#754](https://github.com/use-ink/ink/pull/754). -- We were able to remove the pinned `funty` dependency ‒ [#711](https://github.com/use-ink/ink/pull/711). -- The `contract-transfer` example has been improved for better UI support ‒ [#789](https://github.com/use-ink/ink/pull/789). -- The `contract-transfer` example has been improved for better error handling ‒ [#790](https://github.com/use-ink/ink/pull/790). + +- To reduce a contract's space footprint we switched the default allocator to a bump allocator implementation ‒ [#831](https://github.com/use-ink/ink/pull/831). +- A couple of readme's have been reworked: + - Our main ink! readme ‒ [#774](https://github.com/use-ink/ink/pull/774). + - The `rand-extension` example readme ‒ [#793](https://github.com/use-ink/ink/pull/793). + - The `delegator` example readme ‒ [#766](https://github.com/use-ink/ink/pull/766). +- With the stabilization of Rust 1.51 we ware able to remove the `ink-unstable` feature, making + `collections::SmallVec` and `lazy::LazyArray` available by default ‒ [#746](https://github.com/use-ink/ink/pull/746). +- To resolve confusion, we migrated all usages of `#[test]` in our examples to `#[ink::test]` ‒ [#746](https://github.com/use-ink/ink/pull/746). + - The difference is that `#[ink::test]` spawns an emulated chain environment (an "off-chain" environment) + and hence comes with a bit of overhead. It was not always clear to users when they require + an off-chain environment, we decided to mitigate this confusion by using an emulated chain + environment for all our example tests. +- With the stabilization of Rust's `min_const_generics` we were able to replace the fixed + size implementations of `SpreadLayout` and `PackedLayout` for Arrays. These traits are + now implemented for all Arrays of size `usize` ‒ [#754](https://github.com/use-ink/ink/pull/754). +- We were able to remove the pinned `funty` dependency ‒ [#711](https://github.com/use-ink/ink/pull/711). +- The `contract-transfer` example has been improved for better UI support ‒ [#789](https://github.com/use-ink/ink/pull/789). +- The `contract-transfer` example has been improved for better error handling ‒ [#790](https://github.com/use-ink/ink/pull/790). ### Fixed -- Catch illegal `struct` destructuring pattern in ink! message arguments ‒ [#846](https://github.com/use-ink/ink/pull/846). -- Removed an erroneous `Salt` type in code generation for cross-contract calls ‒ [#842](https://github.com/use-ink/ink/pull/842). -- Do not generate metadata if compiled as dependency ‒ [#811](https://github.com/use-ink/ink/pull/811). -- Fix execution context parameters in DNS example tests ‒ [#723](https://github.com/use-ink/ink/pull/723). -- Fixed the `Greeter` contract example from our doc comments ‒ [#773](https://github.com/use-ink/ink/pull/773). + +- Catch illegal `struct` destructuring pattern in ink! message arguments ‒ [#846](https://github.com/use-ink/ink/pull/846). +- Removed an erroneous `Salt` type in code generation for cross-contract calls ‒ [#842](https://github.com/use-ink/ink/pull/842). +- Do not generate metadata if compiled as dependency ‒ [#811](https://github.com/use-ink/ink/pull/811). +- Fix execution context parameters in DNS example tests ‒ [#723](https://github.com/use-ink/ink/pull/723). +- Fixed the `Greeter` contract example from our doc comments ‒ [#773](https://github.com/use-ink/ink/pull/773). ## Version 3.0-rc3 (2021-03-02) @@ -1655,45 +1798,45 @@ The list below shows the additions, changes and fixes that are visible to users ink! 3.0-rc3 is compatible with -- The `cargo-contract` CLI tool version `0.9.1` or newer. - - Install newest version using `cargo install --force cargo-contract`. -- Substrate version `3.0` including the `contracts-pallet` version `3.0`. +- The `cargo-contract` CLI tool version `0.9.1` or newer. + - Install newest version using `cargo install --force cargo-contract`. +- Substrate version `3.0` including the `contracts-pallet` version `3.0`. ### Added -- Implemented chain extensions feature for ink!. -- ink!'s official documentation portal: https://use.ink/ -- It is now possible to pass a `salt` argument to contract instantiations. -- Implemented fuzz testing for the ink! codebase. +- Implemented chain extensions feature for ink!. +- ink!'s official documentation portal: https://use.ink/ +- It is now possible to pass a `salt` argument to contract instantiations. +- Implemented fuzz testing for the ink! codebase. ### Changed -- Migrate `ink_storage::SmallVec` and `ink_storage::lazy::SmallLazyArray` to use `min_const_generics`. - - The `min_const_generics` feature is going to be stabilized in Rust 1.51. For now it was put behind - the `ink-unstable` crate feature of the `ink_storage` crate. -- Improve error reporting for conflicting ink! attributes. -- Improve error reporting for invalid constructor or message selector. (https://github.com/use-ink/ink/pull/561) -- Remove `iter_mut` for `ink_storage::BinaryHeap` data structure. -- Add documented demonstration how to properly mock `transferred_balance` calls: https://github.com/use-ink/ink/pull/555 -- Add contract example which uses `ext_transfer` and `ext_terminate`: https://github.com/use-ink/ink/pull/554 -- Improve documentation of `transfer` and `minimum_balance` APIs: https://github.com/use-ink/ink/pull/540 +- Migrate `ink_storage::SmallVec` and `ink_storage::lazy::SmallLazyArray` to use `min_const_generics`. + - The `min_const_generics` feature is going to be stabilized in Rust 1.51. For now it was put behind + the `ink-unstable` crate feature of the `ink_storage` crate. +- Improve error reporting for conflicting ink! attributes. +- Improve error reporting for invalid constructor or message selector. (https://github.com/use-ink/ink/pull/561) +- Remove `iter_mut` for `ink_storage::BinaryHeap` data structure. +- Add documented demonstration how to properly mock `transferred_balance` calls: https://github.com/use-ink/ink/pull/555 +- Add contract example which uses `ext_transfer` and `ext_terminate`: https://github.com/use-ink/ink/pull/554 +- Improve documentation of `transfer` and `minimum_balance` APIs: https://github.com/use-ink/ink/pull/540 ### Fixed -- The Delegator example contract now compiles properly using the `build-all.sh` bash script. -- Update crate dependencies: - - `scale-info 0.6` - - `parity-scale-codec 2.0` - - `rand 0.8` - - `itertools 0.10` -- Remove unused `tiny-keccak` dependency from `ink_primitives`. -- Changed the default `BlockNumber` type to `u32`. This is a fix since it now properly mirrors Substrate's default `BlockNumber` type. -- Ensure topics are unique: https://github.com/use-ink/ink/pull/594 -- Several fixes for `ink_storage` data structures, including: - - `Drop` implementation for `Pack` now works properly. (https://github.com/use-ink/ink/pull/600) - - `Drop` implementation for `Lazy` now always properly clean up storage. (https://github.com/use-ink/ink/pull/597) - - Nested `Lazy` now properly clears storage data. (https://github.com/use-ink/ink/pull/583) - - `Option` fields now properly clean up nested storage data. (https://github.com/use-ink/ink/pull/570) +- The Delegator example contract now compiles properly using the `build-all.sh` bash script. +- Update crate dependencies: + - `scale-info 0.6` + - `parity-scale-codec 2.0` + - `rand 0.8` + - `itertools 0.10` +- Remove unused `tiny-keccak` dependency from `ink_primitives`. +- Changed the default `BlockNumber` type to `u32`. This is a fix since it now properly mirrors Substrate's default `BlockNumber` type. +- Ensure topics are unique: https://github.com/use-ink/ink/pull/594 +- Several fixes for `ink_storage` data structures, including: + - `Drop` implementation for `Pack` now works properly. (https://github.com/use-ink/ink/pull/600) + - `Drop` implementation for `Lazy` now always properly clean up storage. (https://github.com/use-ink/ink/pull/597) + - Nested `Lazy` now properly clears storage data. (https://github.com/use-ink/ink/pull/583) + - `Option` fields now properly clean up nested storage data. (https://github.com/use-ink/ink/pull/570) ## Version 3.0-rc2 (2020-10-22) @@ -1702,25 +1845,25 @@ This is the 2nd release candidate for ink! 3.0. On top of the changes introduced in the first release candidate for ink! 3.0 we introduced the following improvements, new features and bug fixes: -- The `ink_storage` crate now comes with a new `BinaryHeap` data structure - that has a very similar interface to the well known Rust standard library - `BinaryHeap`. It features specific optimizations to reduce the storage reads - and writes required for its operations. -- Fixed a bug with `ink_storage::Lazy` that corrupted the storage of - other storage data structures if it was unused in a contract execution. -- The `ink_storage::alloc::Box` type now implements `scale_info::TypeInfo` which - now allows it to be fully used inside other storage data structures such as - `ink_storage::collections::Vec`. The missing of this implementation was - considered a bug. -- The `LazyHashMap` low-level storage abstraction is now re-exported from within - the `ink_storage::lazy` module and docs are inlined. -- Added note about the `ink_core` split into `ink_env` and `ink_storage` crates - to the release notes of ink! 3.0-rc1. -- The `Cargo.toml` documentation now properly links to the one deployed at docs.rs. - On top of that crate level documentation for the `ink_allocator` crate has been - added. -- Add new ERC-20 example contract based on a trait implementation. Also modernized - the old non-trait based ERC-20 example token contract. +- The `ink_storage` crate now comes with a new `BinaryHeap` data structure + that has a very similar interface to the well known Rust standard library + `BinaryHeap`. It features specific optimizations to reduce the storage reads + and writes required for its operations. +- Fixed a bug with `ink_storage::Lazy` that corrupted the storage of + other storage data structures if it was unused in a contract execution. +- The `ink_storage::alloc::Box` type now implements `scale_info::TypeInfo` which + now allows it to be fully used inside other storage data structures such as + `ink_storage::collections::Vec`. The missing of this implementation was + considered a bug. +- The `LazyHashMap` low-level storage abstraction is now re-exported from within + the `ink_storage::lazy` module and docs are inlined. +- Added note about the `ink_core` split into `ink_env` and `ink_storage` crates + to the release notes of ink! 3.0-rc1. +- The `Cargo.toml` documentation now properly links to the one deployed at docs.rs. + On top of that crate level documentation for the `ink_allocator` crate has been + added. +- Add new ERC-20 example contract based on a trait implementation. Also modernized + the old non-trait based ERC-20 example token contract. ## Version 3.0-rc1 (2020-10-09) @@ -1743,6 +1886,7 @@ now follows the natural Rust constructors scheme. So it is no longer possible to yourself in the foot by accidentally forgetting to initialize some important data structures. **Old ink! 2.0:** + ```rust #[ink(constructor)] fn new_erc20(&mut self, initial_supply: Balance) { @@ -1751,7 +1895,9 @@ fn new_erc20(&mut self, initial_supply: Balance) { self.balances.insert(caller, initial_supply); } ``` + **New ink! 3.0:** + ```rust #[ink(constructor)] pub fn new_erc20(initial_supply: Balance) -> Self { @@ -1801,6 +1947,7 @@ The new `ink_storage::Lazy` type is what corresponds the most to the old `ink_co Data types such as Rust primitives `i32` or Rust's very own `Vec` or data structures can also be used to operate on the contract's storage, however, they will load their contents eagerly which is often not what you want. An example follows with the below contract storage and a message that operates on either of the two fields. + ```rust #[ink(storage)] pub struct TwoValues { @@ -1822,6 +1969,7 @@ impl TwoValues { Whenever we call `TwoValues::set` always both `a` and `b` are loaded despite the fact the we only operate on one of them at a time. This is very costly since storage accesses are in fact database look-ups. In order to prevent this eager loading of storage contents we can make use of `ink_storage::Lazy` or other lazy data structures defined in that crate: + ```rust #[ink(storage)] pub struct TwoValues { @@ -1840,6 +1988,7 @@ impl TwoValues { } } ``` + Now `a` and `b` are only loaded when the contract really needs their values. Note that `offset` remained `i32` since it is always needed and could spare the minor overhead of the `ink_storage::Lazy` wrapper. @@ -1852,15 +2001,15 @@ However, their APIs look very different. Whereas the `HashMap` provides a rich a The fundamental difference of both data structures is that `HashMap` is aware of the keys that have been stored in it and thus can reconstruct exactly which elements and storage regions apply to it. This enables it to provide iteration and automated deletion as well as efficient way to defragment its underlying storage to free some storage space again. This goes very well in the vein of Substrate's storage rent model where contracts have to pay for the storage they are using. -| Data Structure | level of abstraction | caching | lazy | element type | container | -| :------------------ | :------------------: | :-----: | :---: | :------------------------: | :--------------------------: | -| `T` | - | yes | no | `T` | primitive value | -| `Lazy` | high-level | yes | yes | `T` | single element container | -| `LazyCell` | low-level | yes | yes | `Option` | single element, no container | -| `Vec` | high-level | yes | yes | `T` | Rust vector-like container | -| `LazyIndexMap` | low-level | yes | yes | `Option` | similar to Solidity mapping | -| `HashMap` | high-level | yes | yes | `V` (key type `K`) | Rust map-like container | -| `LazyHashMap` | low-level | yes | yes | `Option` (key type `K`) | similar to Solidity mapping | +| Data Structure | level of abstraction | caching | lazy | element type | container | +| :------------------ | :------------------: | :-----: | :--: | :------------------------: | :--------------------------: | +| `T` | - | yes | no | `T` | primitive value | +| `Lazy` | high-level | yes | yes | `T` | single element container | +| `LazyCell` | low-level | yes | yes | `Option` | single element, no container | +| `Vec` | high-level | yes | yes | `T` | Rust vector-like container | +| `LazyIndexMap` | low-level | yes | yes | `Option` | similar to Solidity mapping | +| `HashMap` | high-level | yes | yes | `V` (key type `K`) | Rust map-like container | +| `LazyHashMap` | low-level | yes | yes | `Option` (key type `K`) | similar to Solidity mapping | There are many more! For more information about the specifics please take a look into [the `ink_storage` crate documentation](https://use-ink.github.io/ink/ink_storage/). @@ -2024,6 +2173,7 @@ For a list of all the new storage data structure visit [`ink_storage`'s document For ink! 3.0 we have added some more useful ink! specific attributes to the table. All of these ink! attributes are available to specify inside an ink! module. An ink! module is the module that is flagged by `#[ink::contract]` containing all the ink! definitions: + ```rust use ink_lang as ink; @@ -2072,7 +2222,9 @@ pub fn transfer(&mut self, from: AccountId, to: AccountId, value: Balance) -> Re // actual implementation } ``` + We can also write the above ink! message definition in the following way: + ```rust #[ink(message, payable, selector = "0xCAFEBABE")] pub fn transfer(&mut self, from: AccountId, to: AccountId, value: Balance) -> Result<(), Error> { @@ -2169,12 +2321,12 @@ These limitations exist because of technical intricacies, however, please expect ## Version 2.1 (2020-03-25) -- Add built-in support for cryptographic hashes: - - Blake2 with 128-bit and 256-bit - - Sha2 with 256-bit - - Keccak with 256-bit -- Add `ink_core::hash` module for high-level API to the new built-in hashes. -- Update `runtime-storage` example ink! smart contract to demonstrate the new built-in hashes. +- Add built-in support for cryptographic hashes: + - Blake2 with 128-bit and 256-bit + - Sha2 with 256-bit + - Keccak with 256-bit +- Add `ink_core::hash` module for high-level API to the new built-in hashes. +- Update `runtime-storage` example ink! smart contract to demonstrate the new built-in hashes. ## Version 2.0 (2019-12-03) From ab655d135015a6abadd259d7508e07805df6157d Mon Sep 17 00:00:00 2001 From: Lucas Grasso Date: Wed, 29 Oct 2025 00:16:51 -0300 Subject: [PATCH 13/24] impl `call_data_size` hostfn --- crates/env/src/api.rs | 5 +++ crates/env/src/backend.rs | 7 +++++ crates/env/src/engine/off_chain/impls.rs | 4 +++ .../env/src/engine/on_chain/pallet_revive.rs | 4 +++ crates/ink/src/env_access.rs | 31 +++++++++++++++++++ .../ink/tests/ui/contract/pass/env-access.rs | 2 ++ 6 files changed, 53 insertions(+) diff --git a/crates/env/src/api.rs b/crates/env/src/api.rs index bbd3956491d..1f3448f3776 100644 --- a/crates/env/src/api.rs +++ b/crates/env/src/api.rs @@ -85,6 +85,11 @@ pub fn gas_price() -> u64 { ::on_instance(TypedEnvBackend::gas_price) } +/// Returns the total size of the contract call input data. +pub fn call_data_size() -> u64 { + ::on_instance(TypedEnvBackend::call_data_size) +} + /// Returns the transferred value for the contract execution. /// /// # Errors diff --git a/crates/env/src/backend.rs b/crates/env/src/backend.rs index 0f3056d9cd8..0c7a28a447f 100644 --- a/crates/env/src/backend.rs +++ b/crates/env/src/backend.rs @@ -242,6 +242,13 @@ pub trait TypedEnvBackend: EnvBackend { /// For more details visit: [`gas_price`][`crate::gas_price`] fn gas_price(&mut self) -> u64; + /// Returns the total size of the contract call input data. + /// + /// # Note + /// + /// For more details visit: [`call_data_size`][`crate::call_data_size] + fn call_data_size(&mut self) -> u64; + /// Returns the transferred value for the contract execution. /// /// # Note diff --git a/crates/env/src/engine/off_chain/impls.rs b/crates/env/src/engine/off_chain/impls.rs index 9fd6e3bcb45..8e265b59458 100644 --- a/crates/env/src/engine/off_chain/impls.rs +++ b/crates/env/src/engine/off_chain/impls.rs @@ -558,6 +558,10 @@ impl TypedEnvBackend for EnvInstance { unimplemented!("not implemented, the off-chain environment will be removed"); } + fn call_data_size(&mut self) -> u64 { + unimplemented!("not implemented, the off-chain environment will be removed"); + } + fn transferred_value(&mut self) -> U256 { self.get_property(Engine::value_transferred) .unwrap_or_else(|error| { diff --git a/crates/env/src/engine/on_chain/pallet_revive.rs b/crates/env/src/engine/on_chain/pallet_revive.rs index 81940f08612..abfd40adfd3 100644 --- a/crates/env/src/engine/on_chain/pallet_revive.rs +++ b/crates/env/src/engine/on_chain/pallet_revive.rs @@ -895,6 +895,10 @@ impl TypedEnvBackend for EnvInstance { ext::gas_price() } + fn call_data_size(&mut self) -> u64 { + ext::call_data_size() + } + fn transferred_value(&mut self) -> U256 { let mut scope = self.scoped_buffer(); let u256: &mut [u8; 32] = scope.take(32).try_into().unwrap(); diff --git a/crates/ink/src/env_access.rs b/crates/ink/src/env_access.rs index 27a4c785fcd..62ce9f79d11 100644 --- a/crates/ink/src/env_access.rs +++ b/crates/ink/src/env_access.rs @@ -170,6 +170,37 @@ where ink_env::gas_price() } + /// Returns the total size of the contract call input data. + /// + /// # Example + /// + /// ``` + /// #[ink::contract] + /// mod my_contract { + /// #[ink(storage)] + /// pub struct MyContract; + /// + /// impl MyContract { + /// #[ink(constructor)] + /// pub fn new() -> Self { + /// Self {} + /// } + /// + /// #[ink(message)] + /// pub fn get_call_data_size(&self) -> u64 { + /// self.env().call_data_size() + /// } + /// } + /// } + /// ``` + /// + /// # Note + /// + /// For more details visit: [`ink_env::call_data_size`] + pub fn call_data_size(self) -> u64 { + ink_env::call_data_size() + } + /// Returns the transferred value for the contract execution. /// /// # Example diff --git a/crates/ink/tests/ui/contract/pass/env-access.rs b/crates/ink/tests/ui/contract/pass/env-access.rs index 699d69260b9..9968cc21fe0 100644 --- a/crates/ink/tests/ui/contract/pass/env-access.rs +++ b/crates/ink/tests/ui/contract/pass/env-access.rs @@ -16,6 +16,7 @@ mod contract { let _ = Self::env().minimum_balance(); let _ = Self::env().gas_limit(); let _ = Self::env().gas_price(); + let _ = Self::env().call_data_size(); let _ = Self::env().transferred_value(); let _ = Self::env().weight_to_fee(0); Self {} @@ -31,6 +32,7 @@ mod contract { let _ = self.env().minimum_balance(); let _ = self.env().gas_limit(); let _ = self.env().gas_price(); + let _ = self.env().call_data_size(); let _ = self.env().transferred_value(); let _ = self.env().weight_to_fee(0); } From ce50625111bdf6adf9049b78d0445ebf3b73c104 Mon Sep 17 00:00:00 2001 From: Lucas Grasso Date: Wed, 29 Oct 2025 00:24:44 -0300 Subject: [PATCH 14/24] impl `return_data_size` hostfn --- crates/env/src/api.rs | 5 +++ crates/env/src/backend.rs | 7 +++++ crates/env/src/engine/off_chain/impls.rs | 4 +++ .../env/src/engine/on_chain/pallet_revive.rs | 4 +++ crates/ink/src/env_access.rs | 31 +++++++++++++++++++ .../ink/tests/ui/contract/pass/env-access.rs | 2 ++ 6 files changed, 53 insertions(+) diff --git a/crates/env/src/api.rs b/crates/env/src/api.rs index 1f3448f3776..7b2601405f2 100644 --- a/crates/env/src/api.rs +++ b/crates/env/src/api.rs @@ -90,6 +90,11 @@ pub fn call_data_size() -> u64 { ::on_instance(TypedEnvBackend::call_data_size) } +/// Returns the length of the data returned by the last runtime call +pub fn return_data_size() -> u64 { + ::on_instance(TypedEnvBackend::return_data_size) +} + /// Returns the transferred value for the contract execution. /// /// # Errors diff --git a/crates/env/src/backend.rs b/crates/env/src/backend.rs index 0c7a28a447f..923e1d513b6 100644 --- a/crates/env/src/backend.rs +++ b/crates/env/src/backend.rs @@ -249,6 +249,13 @@ pub trait TypedEnvBackend: EnvBackend { /// For more details visit: [`call_data_size`][`crate::call_data_size] fn call_data_size(&mut self) -> u64; + /// Returns the length of the data returned by the last runtime call + /// + /// # Note + /// + /// For more details visit: [`return_data_size`][`crate::return_data_size] + fn return_data_size(&mut self) -> u64; + /// Returns the transferred value for the contract execution. /// /// # Note diff --git a/crates/env/src/engine/off_chain/impls.rs b/crates/env/src/engine/off_chain/impls.rs index 8e265b59458..c3c9d8557f9 100644 --- a/crates/env/src/engine/off_chain/impls.rs +++ b/crates/env/src/engine/off_chain/impls.rs @@ -562,6 +562,10 @@ impl TypedEnvBackend for EnvInstance { unimplemented!("not implemented, the off-chain environment will be removed"); } + fn return_data_size(&mut self) -> u64 { + unimplemented!("not implemented, the off-chain environment will be removed"); + } + fn transferred_value(&mut self) -> U256 { self.get_property(Engine::value_transferred) .unwrap_or_else(|error| { diff --git a/crates/env/src/engine/on_chain/pallet_revive.rs b/crates/env/src/engine/on_chain/pallet_revive.rs index abfd40adfd3..2baa15536c9 100644 --- a/crates/env/src/engine/on_chain/pallet_revive.rs +++ b/crates/env/src/engine/on_chain/pallet_revive.rs @@ -899,6 +899,10 @@ impl TypedEnvBackend for EnvInstance { ext::call_data_size() } + fn return_data_size(&mut self) -> u64 { + ext::return_data_size() + } + fn transferred_value(&mut self) -> U256 { let mut scope = self.scoped_buffer(); let u256: &mut [u8; 32] = scope.take(32).try_into().unwrap(); diff --git a/crates/ink/src/env_access.rs b/crates/ink/src/env_access.rs index 62ce9f79d11..f9486a3cb6b 100644 --- a/crates/ink/src/env_access.rs +++ b/crates/ink/src/env_access.rs @@ -201,6 +201,37 @@ where ink_env::call_data_size() } + /// Returns the length of the data returned by the last runtime call + /// + /// # Example + /// + /// ``` + /// #[ink::contract] + /// mod my_contract { + /// #[ink(storage)] + /// pub struct MyContract; + /// + /// impl MyContract { + /// #[ink(constructor)] + /// pub fn new() -> Self { + /// Self {} + /// } + /// + /// #[ink(message)] + /// pub fn get_return_data_size(&self) -> u64 { + /// self.env().return_data_size() + /// } + /// } + /// } + /// ``` + /// + /// # Note + /// + /// For more details visit: [`ink_env::return_data_size`] + pub fn return_data_size(self) -> u64 { + ink_env::return_data_size() + } + /// Returns the transferred value for the contract execution. /// /// # Example diff --git a/crates/ink/tests/ui/contract/pass/env-access.rs b/crates/ink/tests/ui/contract/pass/env-access.rs index 9968cc21fe0..6b1958a78eb 100644 --- a/crates/ink/tests/ui/contract/pass/env-access.rs +++ b/crates/ink/tests/ui/contract/pass/env-access.rs @@ -17,6 +17,7 @@ mod contract { let _ = Self::env().gas_limit(); let _ = Self::env().gas_price(); let _ = Self::env().call_data_size(); + let _ = Self::env().return_data_size(); let _ = Self::env().transferred_value(); let _ = Self::env().weight_to_fee(0); Self {} @@ -33,6 +34,7 @@ mod contract { let _ = self.env().gas_limit(); let _ = self.env().gas_price(); let _ = self.env().call_data_size(); + let _ = self.env().return_data_size(); let _ = self.env().transferred_value(); let _ = self.env().weight_to_fee(0); } From 6dc1f7b4b8ed3a5f306b91677fb8a72805dd80f7 Mon Sep 17 00:00:00 2001 From: Lucas Grasso Date: Wed, 29 Oct 2025 00:32:59 -0300 Subject: [PATCH 15/24] test `call_data_size` and `return_data_size` --- .../internal/data-hostfns/Cargo.toml | 27 ++++++ .../internal/data-hostfns/lib.rs | 87 +++++++++++++++++++ 2 files changed, 114 insertions(+) create mode 100755 integration-tests/internal/data-hostfns/Cargo.toml create mode 100644 integration-tests/internal/data-hostfns/lib.rs diff --git a/integration-tests/internal/data-hostfns/Cargo.toml b/integration-tests/internal/data-hostfns/Cargo.toml new file mode 100755 index 00000000000..7897a057cf2 --- /dev/null +++ b/integration-tests/internal/data-hostfns/Cargo.toml @@ -0,0 +1,27 @@ +[package] +name = "data_hostfns" +description = "E2E tests for data related host functions" +version = "6.0.0-alpha.4" +authors = ["Use Ink "] +edition = "2021" +publish = false + +[dependencies] +ink = { path = "../../../crates/ink", default-features = false, features = ["unstable-hostfn"] } + +[dev-dependencies] +ink_e2e = { path = "../../../crates/e2e" } + +[lib] +path = "lib.rs" + +[features] +default = ["std"] +std = [ + "ink/std", +] +ink-as-dependency = [] +e2e-tests = [] + +[package.metadata.ink-lang] +abi = "ink" diff --git a/integration-tests/internal/data-hostfns/lib.rs b/integration-tests/internal/data-hostfns/lib.rs new file mode 100644 index 00000000000..48a960240ed --- /dev/null +++ b/integration-tests/internal/data-hostfns/lib.rs @@ -0,0 +1,87 @@ +#![cfg_attr(not(feature = "std"), no_std, no_main)] +#![allow(clippy::new_without_default)] + +#[ink::contract] +mod data_hostfns { + #[ink(storage)] + pub struct DataHostfns {} + + impl DataHostfns { + #[ink(constructor)] + pub fn new() -> Self { + Self {} + } + + /// Checks that the host function `call_data_size` works + #[ink(message)] + pub fn call_data_size(&self) -> u64 { + self.env().call_data_size() + } + + /// Checks that the host function `return_data_size` works + #[ink(message)] + pub fn return_data_size(&self) -> u64 { + self.env().return_data_size() + } + } + + #[cfg(all(test, feature = "e2e-tests"))] + mod e2e_tests { + use super::*; + use ink_e2e::ContractsBackend; + + type E2EResult = std::result::Result>; + + #[ink_e2e::test] + async fn e2e_call_data_size_works( + mut client: Client, + ) -> E2EResult<()> { + // given + let contract = client + .instantiate("data_hostfns", &ink_e2e::alice(), &mut DataHostfnsRef::new()) + .submit() + .await + .expect("instantiate failed"); + let call_builder = contract.call_builder::(); + + // then + let call_res = client + .call(&ink_e2e::alice(), &call_builder.call_data_size()) + .submit() + .await + .unwrap_or_else(|err| { + panic!("call failed: {:#?}", err); + }); + + assert!(call_res.return_value() > 0); + + Ok(()) + } + + #[ink_e2e::test] + async fn e2e_return_data_size_works( + mut client: Client, + ) -> E2EResult<()> { + // given + let contract = client + .instantiate("data_hostfns", &ink_e2e::alice(), &mut DataHostfnsRef::new()) + .submit() + .await + .expect("instantiate failed"); + let call_builder = contract.call_builder::(); + + // then + let call_res = client + .call(&ink_e2e::alice(), &call_builder.return_data_size()) + .submit() + .await + .unwrap_or_else(|err| { + panic!("call failed: {:#?}", err); + }); + + assert!(call_res.return_value() == 0); // no calls were made, thus is 0 + + Ok(()) + } + } +} From 08989e229831cad7d89c6a89fb9cd145e11b0416 Mon Sep 17 00:00:00 2001 From: Lucas Grasso Date: Wed, 29 Oct 2025 00:46:09 -0300 Subject: [PATCH 16/24] implement and test `ref_time_left` --- crates/env/src/api.rs | 5 +++ crates/env/src/backend.rs | 7 ++++ crates/env/src/engine/off_chain/impls.rs | 4 +++ .../env/src/engine/on_chain/pallet_revive.rs | 4 +++ crates/ink/src/env_access.rs | 31 ++++++++++++++++++ .../ink/tests/ui/contract/pass/env-access.rs | 2 ++ integration-tests/internal/gas-hostfns/lib.rs | 32 +++++++++++++++++++ 7 files changed, 85 insertions(+) diff --git a/crates/env/src/api.rs b/crates/env/src/api.rs index 7b2601405f2..778b5743b65 100644 --- a/crates/env/src/api.rs +++ b/crates/env/src/api.rs @@ -85,6 +85,11 @@ pub fn gas_price() -> u64 { ::on_instance(TypedEnvBackend::gas_price) } +/// Returns the amount of evm gas left. +pub fn ref_time_left() -> u64 { + ::on_instance(TypedEnvBackend::ref_time_left) +} + /// Returns the total size of the contract call input data. pub fn call_data_size() -> u64 { ::on_instance(TypedEnvBackend::call_data_size) diff --git a/crates/env/src/backend.rs b/crates/env/src/backend.rs index 923e1d513b6..f5da6bf5385 100644 --- a/crates/env/src/backend.rs +++ b/crates/env/src/backend.rs @@ -242,6 +242,13 @@ pub trait TypedEnvBackend: EnvBackend { /// For more details visit: [`gas_price`][`crate::gas_price`] fn gas_price(&mut self) -> u64; + /// Returns the amount of evm gas left. + /// + /// # Note + /// + /// For more details visit: [`ref_time_left`][`crate::ref_time_left`] + fn ref_time_left(&mut self) -> u64; + /// Returns the total size of the contract call input data. /// /// # Note diff --git a/crates/env/src/engine/off_chain/impls.rs b/crates/env/src/engine/off_chain/impls.rs index c3c9d8557f9..b1fe155c7e5 100644 --- a/crates/env/src/engine/off_chain/impls.rs +++ b/crates/env/src/engine/off_chain/impls.rs @@ -558,6 +558,10 @@ impl TypedEnvBackend for EnvInstance { unimplemented!("not implemented, the off-chain environment will be removed"); } + fn ref_time_left(&mut self) -> u64 { + unimplemented!("not implemented, the off-chain environment will be removed"); + } + fn call_data_size(&mut self) -> u64 { unimplemented!("not implemented, the off-chain environment will be removed"); } diff --git a/crates/env/src/engine/on_chain/pallet_revive.rs b/crates/env/src/engine/on_chain/pallet_revive.rs index 2baa15536c9..482f1cba9f8 100644 --- a/crates/env/src/engine/on_chain/pallet_revive.rs +++ b/crates/env/src/engine/on_chain/pallet_revive.rs @@ -895,6 +895,10 @@ impl TypedEnvBackend for EnvInstance { ext::gas_price() } + fn ref_time_left(&mut self) -> u64 { + ext::ref_time_left() + } + fn call_data_size(&mut self) -> u64 { ext::call_data_size() } diff --git a/crates/ink/src/env_access.rs b/crates/ink/src/env_access.rs index f9486a3cb6b..9a51878a657 100644 --- a/crates/ink/src/env_access.rs +++ b/crates/ink/src/env_access.rs @@ -170,6 +170,37 @@ where ink_env::gas_price() } + /// Returns the amount of evm gas left. + /// + /// # Example + /// + /// ``` + /// #[ink::contract] + /// mod my_contract { + /// #[ink(storage)] + /// pub struct MyContract; + /// + /// impl MyContract { + /// #[ink(constructor)] + /// pub fn new() -> Self { + /// Self {} + /// } + /// + /// #[ink(message)] + /// pub fn get_ref_time_left(&self) -> u64 { + /// self.env().ref_time_left() + /// } + /// } + /// } + /// ``` + /// + /// # Note + /// + /// For more details visit: [`ink_env::ref_time_left`] + pub fn ref_time_left(self) -> u64 { + ink_env::ref_time_left() + } + /// Returns the total size of the contract call input data. /// /// # Example diff --git a/crates/ink/tests/ui/contract/pass/env-access.rs b/crates/ink/tests/ui/contract/pass/env-access.rs index 6b1958a78eb..9e6810bad74 100644 --- a/crates/ink/tests/ui/contract/pass/env-access.rs +++ b/crates/ink/tests/ui/contract/pass/env-access.rs @@ -16,6 +16,7 @@ mod contract { let _ = Self::env().minimum_balance(); let _ = Self::env().gas_limit(); let _ = Self::env().gas_price(); + let _ = Self::env().ref_time_left(); let _ = Self::env().call_data_size(); let _ = Self::env().return_data_size(); let _ = Self::env().transferred_value(); @@ -33,6 +34,7 @@ mod contract { let _ = self.env().minimum_balance(); let _ = self.env().gas_limit(); let _ = self.env().gas_price(); + let _ = self.env().ref_time_left(); let _ = self.env().call_data_size(); let _ = self.env().return_data_size(); let _ = self.env().transferred_value(); diff --git a/integration-tests/internal/gas-hostfns/lib.rs b/integration-tests/internal/gas-hostfns/lib.rs index a33afd30d96..50b416c9dca 100644 --- a/integration-tests/internal/gas-hostfns/lib.rs +++ b/integration-tests/internal/gas-hostfns/lib.rs @@ -23,6 +23,12 @@ mod gas_hostfns { pub fn gas_price(&self) -> u64 { self.env().gas_price() } + + /// Checks that the host function `ref_time_left` works + #[ink(message)] + pub fn ref_time_left(&self) -> u64 { + self.env().ref_time_left() + } } #[cfg(all(test, feature = "e2e-tests"))] @@ -83,5 +89,31 @@ mod gas_hostfns { Ok(()) } + + #[ink_e2e::test] + async fn e2e_ref_time_left_works( + mut client: Client, + ) -> E2EResult<()> { + // given + let contract = client + .instantiate("gas_hostfns", &ink_e2e::alice(), &mut GasHostfnsRef::new()) + .submit() + .await + .expect("instantiate failed"); + let call_builder = contract.call_builder::(); + + // then + let call_res = client + .call(&ink_e2e::alice(), &call_builder.ref_time_left()) + .submit() + .await + .unwrap_or_else(|err| { + panic!("call failed: {:#?}", err); + }); + + assert!(call_res.return_value() > 0); + + Ok(()) + } } } From e1509fa44d70aff8b2ef7817810cb84b4d68d920 Mon Sep 17 00:00:00 2001 From: Lucas Grasso Date: Wed, 29 Oct 2025 00:47:43 -0300 Subject: [PATCH 17/24] run formatting --- integration-tests/internal/data-hostfns/lib.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/integration-tests/internal/data-hostfns/lib.rs b/integration-tests/internal/data-hostfns/lib.rs index 48a960240ed..a28b7921b00 100644 --- a/integration-tests/internal/data-hostfns/lib.rs +++ b/integration-tests/internal/data-hostfns/lib.rs @@ -38,7 +38,11 @@ mod data_hostfns { ) -> E2EResult<()> { // given let contract = client - .instantiate("data_hostfns", &ink_e2e::alice(), &mut DataHostfnsRef::new()) + .instantiate( + "data_hostfns", + &ink_e2e::alice(), + &mut DataHostfnsRef::new(), + ) .submit() .await .expect("instantiate failed"); @@ -64,7 +68,11 @@ mod data_hostfns { ) -> E2EResult<()> { // given let contract = client - .instantiate("data_hostfns", &ink_e2e::alice(), &mut DataHostfnsRef::new()) + .instantiate( + "data_hostfns", + &ink_e2e::alice(), + &mut DataHostfnsRef::new(), + ) .submit() .await .expect("instantiate failed"); From e02de044d81298b84830ec340b0ab185d6e0ce4a Mon Sep 17 00:00:00 2001 From: Lucas Grasso Date: Wed, 29 Oct 2025 22:10:17 -0300 Subject: [PATCH 18/24] revert changelog auto format --- CHANGELOG.md | 1520 +++++++++++++++++++++++--------------------------- 1 file changed, 685 insertions(+), 835 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8abd6ae3048..800d34a4b4d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,4 @@ # Changelog - All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), @@ -8,117 +7,105 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 [Unreleased] ### Added - - Implements the API for the `pallet-revive` host functions `gas_price`, `call_data_size`, `return_data_size`, `ref_time_left` - [#2694](https://github.com/use-ink/ink/pull/2694) -- Implements the API for the `pallet-revive` host function `gas_limit` - [#2691](https://github.com/use-ink/ink/pull/2691) -- Implements the API for the `pallet-revive` host function `to_account_id` - [#2578](https://github.com/use-ink/ink/pull/2578) -- Add `#[ink::contract_ref]` attribute - [#2648](https://github.com/use-ink/ink/pull/2648) -- Add `ink_revive_types` (and remove `pallet-revive` dependency from `ink_e2e`) - [#2657](https://github.com/use-ink/ink/pull/2657) -- non-allocating Solidity ABI encoder - [#2655](https://github.com/use-ink/ink/pull/2655) +- Implements the API for the `pallet-revive` host function `gas_limit` - [#2691](https://github.com/use-ink/ink/pull/2691) +- Implements the API for the `pallet-revive` host function `to_account_id` - [#2578](https://github.com/use-ink/ink/pull/2578) +- Add `#[ink::contract_ref]` attribute - [#2648](https://github.com/use-ink/ink/pull/2648) +- Add `ink_revive_types` (and remove `pallet-revive` dependency from `ink_e2e`) - [#2657](https://github.com/use-ink/ink/pull/2657) +- non-allocating Solidity ABI encoder - [#2655](https://github.com/use-ink/ink/pull/2655) +- Implement XCM precompile, stabilize XCM API - [#2687](https://github.com/use-ink/ink/pull/2687) ### Changed - -- Marks the `pallet-revive` host function `account_id` stable - [#2578](https://github.com/use-ink/ink/pull/2578) -- Stabilize `is_contract` - [#2654](https://github.com/use-ink/ink/pull/2654) -- Extract `sandbox` from `ink_e2e` into a new `ink_sandbox` crate - [#2659](https://github.com/use-ink/ink/pull/2659) -- Synchronize with `polkadot-sdk/1b1cef306d9ceebf963fd15a04b5c79ee2618bce` ‒ [2675](https://github.com/use-ink/ink/pull/2675) -- Refactor `AbiEncodeWith::encode_to_slice` - [#2676](https://github.com/use-ink/ink/pull/2676) -- Refactor `ArgumentList` encoding and abstractions - [#2678](https://github.com/use-ink/ink/pull/2678) -- More flexible `SolEncode` implementation for `ByteSlice` - [#2681](https://github.com/use-ink/ink/pull/2681) -- Synchronize with `polkadot-sdk/cbab8ed4be1941420dd25dc81102fb79d8e2a7f0` ‒ [2689](https://github.com/use-ink/ink/pull/2689) +- Marks the `pallet-revive` host function `account_id` stable - [#2578](https://github.com/use-ink/ink/pull/2578) +- Stabilize `is_contract` - [#2654](https://github.com/use-ink/ink/pull/2654) +- Extract `sandbox` from `ink_e2e` into a new `ink_sandbox` crate - [#2659](https://github.com/use-ink/ink/pull/2659) +- Synchronize with `polkadot-sdk/1b1cef306d9ceebf963fd15a04b5c79ee2618bce` ‒ [2675](https://github.com/use-ink/ink/pull/2675) +- Refactor `AbiEncodeWith::encode_to_slice` - [#2676](https://github.com/use-ink/ink/pull/2676) +- Refactor `ArgumentList` encoding and abstractions - [#2678](https://github.com/use-ink/ink/pull/2678) +- More flexible `SolEncode` implementation for `ByteSlice` - [#2681](https://github.com/use-ink/ink/pull/2681) +- Synchronize with `polkadot-sdk/cbab8ed4be1941420dd25dc81102fb79d8e2a7f0` ‒ [2689](https://github.com/use-ink/ink/pull/2689) ### Fixed - -- Fix decoding of `HostFn::minimum_balance` return value - [#2656](https://github.com/use-ink/ink/pull/2656) -- Fix handling of `HostFn::code_hash` and `HostFn::weight_to_fee` - [#2672](https://github.com/use-ink/ink/pull/2672) -- `name` override fixes for message id computation and trait definitions - [#2649](https://github.com/use-ink/ink/pull/2649) -- Add hotfix for `generic-array` breakage ([issue](https://github.com/fizyk20/generic-array/issues/158)) - [#2688](https://github.com/use-ink/ink/pull/2688) +- Fix decoding of `HostFn::minimum_balance` return value - [#2656](https://github.com/use-ink/ink/pull/2656) +- Fix handling of `HostFn::code_hash` and `HostFn::weight_to_fee` - [#2672](https://github.com/use-ink/ink/pull/2672) +- `name` override fixes for message id computation and trait definitions - [#2649](https://github.com/use-ink/ink/pull/2649) +- Add hotfix for `generic-array` breakage ([issue](https://github.com/fizyk20/generic-array/issues/158)) - [#2688](https://github.com/use-ink/ink/pull/2688) ## Version 6.0.0-alpha.4 ### Added - -- Add integration test for arithmetic overflow checks - [#2631](https://github.com/use-ink/ink/pull/2631) -- E2E: Misc quality of life improvements, new API functions, better debuggability ‒ [2634](https://github.com/use-ink/ink/pull/2634) +- Add integration test for arithmetic overflow checks - [#2631](https://github.com/use-ink/ink/pull/2631) +- E2E: Misc quality of life improvements, new API functions, better debuggability ‒ [2634](https://github.com/use-ink/ink/pull/2634) ### Changed - -- Error on message and constructor `selector` overrides in Solidity ABI mode - [#2638](https://github.com/use-ink/ink/pull/2638) -- Improve abstractions for Solidity ABI encoding `Result` types - [#2635](https://github.com/use-ink/ink/pull/2635) -- Feature gate `xcm` - [#2641](https://github.com/use-ink/ink/pull/2641) -- Refactor multi ABI interfaces for event emission via `ink_env` - [#2643](https://github.com/use-ink/ink/pull/2643) +- Error on message and constructor `selector` overrides in Solidity ABI mode - [#2638](https://github.com/use-ink/ink/pull/2638) +- Improve abstractions for Solidity ABI encoding `Result` types - [#2635](https://github.com/use-ink/ink/pull/2635) +- Feature gate `xcm` - [#2641](https://github.com/use-ink/ink/pull/2641) +- Refactor multi ABI interfaces for event emission via `ink_env` - [#2643](https://github.com/use-ink/ink/pull/2643) ### Fixed - -- Bring intended panic handler behavior back ‒ [2636](https://github.com/use-ink/ink/pull/2636) -- Support `name` attribute in trait definitions - [#2644](https://github.com/use-ink/ink/pull/2644) +- Bring intended panic handler behavior back ‒ [2636](https://github.com/use-ink/ink/pull/2636) +- Support `name` attribute in trait definitions - [#2644](https://github.com/use-ink/ink/pull/2644) ## Version 6.0.0-alpha.3 Compatibility of this release: -- Rust >= 1.88 -- [`cargo-contract` `v6.0.0-alpha.3`](https://github.com/use-ink/cargo-contract/releases/tag/v6.0.0-alpha.3) -- [`ink-node` `v0.45.1`](https://github.com/use-ink/ink-node/releases/tag/v0.45.1) -- [`polkadot-sdk` from `use-ink/polkadot-sdk/a71ec19a94702ea71767ba5ac97603ea6c6305c1`](https://github.com/use-ink/polkadot-sdk/tree/pallet-revive-with-system-and-storage-precompiles) +* Rust >= 1.88 +* [`cargo-contract` `v6.0.0-alpha.3`](https://github.com/use-ink/cargo-contract/releases/tag/v6.0.0-alpha.3) +* [`ink-node` `v0.45.1`](https://github.com/use-ink/ink-node/releases/tag/v0.45.1) +* [`polkadot-sdk` from `use-ink/polkadot-sdk/a71ec19a94702ea71767ba5ac97603ea6c6305c1`](https://github.com/use-ink/polkadot-sdk/tree/pallet-revive-with-system-and-storage-precompiles) We have to use a slight fork of `polkadot-sdk` for the moment. It's just `polkadot-sdk/master` plus two commits on top with pre-compiles. Those two commits are PRs to `polkadot-sdk`. but haven't been merged yet. ### Added - -- Support functions of the `Storage` and `System` pre-compiles ‒ [2619](https://github.com/use-ink/ink/pull/2619) +- Support functions of the `Storage` and `System` pre-compiles ‒ [2619](https://github.com/use-ink/ink/pull/2619) ### Changed - -- Synchronize with `polkadot-sdk/c40b36c3a7c208f9a6837b80812473af3d9ba7f7` ‒ [2589](https://github.com/use-ink/ink/pull/2589) -- Synchronize with `polkadot-sdk/a71ec19a94702ea71767ba5ac97603ea6c6305c1` ‒ [2619](https://github.com/use-ink/ink/pull/2619) -- Refactor multi ABI interfaces - [#2618](https://github.com/use-ink/ink/pull/2618) -- Upgrade to Rust edition 2024 - [#2624](https://github.com/use-ink/ink/pull/2624) +- Synchronize with `polkadot-sdk/c40b36c3a7c208f9a6837b80812473af3d9ba7f7` ‒ [2589](https://github.com/use-ink/ink/pull/2589) +- Synchronize with `polkadot-sdk/a71ec19a94702ea71767ba5ac97603ea6c6305c1` ‒ [2619](https://github.com/use-ink/ink/pull/2619) +- Refactor multi ABI interfaces - [#2618](https://github.com/use-ink/ink/pull/2618) +- Upgrade to Rust edition 2024 - [#2624](https://github.com/use-ink/ink/pull/2624) ### Removed - -- Removed functionalities around calling into the runtime and chain extensions ‒ [2621](https://github.com/use-ink/ink/pull/2621) -- Remove `Environment::MAX_EVENT_TOPICS` and remove `Environment` generic type from event abstractions - [#2622](https://github.com/use-ink/ink/pull/2622) +- Removed functionalities around calling into the runtime and chain extensions ‒ [2621](https://github.com/use-ink/ink/pull/2621) +- Remove `Environment::MAX_EVENT_TOPICS` and remove `Environment` generic type from event abstractions - [#2622](https://github.com/use-ink/ink/pull/2622) ### Fixed - -- E2E: Fixes around correct handling of storage deposit limit ‒ [#2589](https://github.com/use-ink/ink/pull/2589) -- Make `NativeToEthRatio` part of the `Environment` ‒ [#2604](https://github.com/use-ink/ink/pull/2604) -- E2E: Fix `ink_sandbox` gating - [#2626](https://github.com/use-ink/ink/pull/2626) +- E2E: Fixes around correct handling of storage deposit limit ‒ [#2589](https://github.com/use-ink/ink/pull/2589) +- Make `NativeToEthRatio` part of the `Environment` ‒ [#2604](https://github.com/use-ink/ink/pull/2604) +- E2E: Fix `ink_sandbox` gating - [#2626](https://github.com/use-ink/ink/pull/2626) ## Version 6.0.0-alpha.1 ### Added - -- Support ABI `cfg` flag in codegen - [#2501](https://github.com/use-ink/ink/pull/2501) -- Generate Solidity ABI compatibility metadata - [#2510](https://github.com/use-ink/ink/pull/2510) -- Improve Solidity ABI support in `codegen`, `ink_env` and `ink_e2e` - [#2517](https://github.com/use-ink/ink/pull/2517) -- Support Solidity ABI encoded constructor dispatch - [#2525](https://github.com/use-ink/ink/pull/2525) -- Export `Weight` with Solidity encoding - [#2540](https://github.com/use-ink/ink/pull/2540) -- Implement `SolEncode` and `SolDecode` for generated contract refs, call and message builders - [#2539](https://github.com/use-ink/ink/pull/2539) -- Abstractions for mapping Rust/ink! `Result` and error types to/from Solidity ABI error and result representations - [#2543](https://github.com/use-ink/ink/pull/2543) -- `Derive` macros for implementing `SolEncode` and `SolDecode` for arbitrary types - [#2549](https://github.com/use-ink/ink/pull/2549) -- Improve handling of Solidity constructor return and revert data - [#2552](https://github.com/use-ink/ink/pull/2552) -- Implement `SolEncode` and `SolDecode` for `Option` - [#2545](https://github.com/use-ink/ink/pull/2545) -- Allow writing E2E fuzz tests for contracts - [#2570](https://github.com/use-ink/ink/pull/2570) -- Item name/identifier overrides for overloading, selector computation and metadata - [#2577](https://github.com/use-ink/ink/pull/2577) -- Add custom errors to Solidity compatible metadata - [#2583](https://github.com/use-ink/ink/pull/2583) -- Efficient conversions and representations for byte sequence references for Solidity ABI encoding/decoding - [#2590](https://github.com/use-ink/ink/pull/2590) -- Add `#[ink::error]` attribute macro - [#2585](https://github.com/use-ink/ink/pull/2585) +- Support ABI `cfg` flag in codegen - [#2501](https://github.com/use-ink/ink/pull/2501) +- Generate Solidity ABI compatibility metadata - [#2510](https://github.com/use-ink/ink/pull/2510) +- Improve Solidity ABI support in `codegen`, `ink_env` and `ink_e2e` - [#2517](https://github.com/use-ink/ink/pull/2517) +- Support Solidity ABI encoded constructor dispatch - [#2525](https://github.com/use-ink/ink/pull/2525) +- Export `Weight` with Solidity encoding - [#2540](https://github.com/use-ink/ink/pull/2540) +- Implement `SolEncode` and `SolDecode` for generated contract refs, call and message builders - [#2539](https://github.com/use-ink/ink/pull/2539) +- Abstractions for mapping Rust/ink! `Result` and error types to/from Solidity ABI error and result representations - [#2543](https://github.com/use-ink/ink/pull/2543) +- `Derive` macros for implementing `SolEncode` and `SolDecode` for arbitrary types - [#2549](https://github.com/use-ink/ink/pull/2549) +- Improve handling of Solidity constructor return and revert data - [#2552](https://github.com/use-ink/ink/pull/2552) +- Implement `SolEncode` and `SolDecode` for `Option` - [#2545](https://github.com/use-ink/ink/pull/2545) +- Allow writing E2E fuzz tests for contracts - [#2570](https://github.com/use-ink/ink/pull/2570) +- Item name/identifier overrides for overloading, selector computation and metadata - [#2577](https://github.com/use-ink/ink/pull/2577) +- Add custom errors to Solidity compatible metadata - [#2583](https://github.com/use-ink/ink/pull/2583) +- Efficient conversions and representations for byte sequence references for Solidity ABI encoding/decoding - [#2590](https://github.com/use-ink/ink/pull/2590) +- Add `#[ink::error]` attribute macro - [#2585](https://github.com/use-ink/ink/pull/2585) ### Changed - -- Use marker trait for finding ink! storage `struct` during code analysis - [2499](https://github.com/use-ink/ink/pull/2499) -- Solidity ABI compatibility metadata improvements - [#2511](https://github.com/use-ink/ink/pull/2511) -- Share intermediate build artifacts across all contract builds in e2e tests - [#2531](https://github.com/use-ink/ink/pull/2531) -- Refactor Solidity bytes wrapper(s) - [#2569](https://github.com/use-ink/ink/pull/2569) -- Refactor events for `pallet-revive` and multiple ABI support - [#2580](https://github.com/use-ink/ink/pull/2580) +- Use marker trait for finding ink! storage `struct` during code analysis - [2499](https://github.com/use-ink/ink/pull/2499) +- Solidity ABI compatibility metadata improvements - [#2511](https://github.com/use-ink/ink/pull/2511) +- Share intermediate build artifacts across all contract builds in e2e tests - [#2531](https://github.com/use-ink/ink/pull/2531) +- Refactor Solidity bytes wrapper(s) - [#2569](https://github.com/use-ink/ink/pull/2569) +- Refactor events for `pallet-revive` and multiple ABI support - [#2580](https://github.com/use-ink/ink/pull/2580) ### Fixed - -- Update metadata version to version 6 ‒ [#2507](https://github.com/use-ink/ink/pull/2507) -- Ensure immutable messages are not payable - [#2535](https://github.com/use-ink/ink/pull/2535) +- Update metadata version to version 6 ‒ [#2507](https://github.com/use-ink/ink/pull/2507) +- Ensure immutable messages are not payable - [#2535](https://github.com/use-ink/ink/pull/2535) ## Version 6.0.0-alpha @@ -136,11 +123,10 @@ We did a detailed write-up of the background to this development and the reasoni to reflect the new setup. Compatibility of this release: - -- Rust >= 1.86 -- [`cargo-contract` `v6.0.0-alpha`](https://github.com/use-ink/cargo-contract/releases/tag/v6.0.0-alpha) -- [`ink-node/5f93093`](https://github.com/use-ink/ink-node/commit/5f93093dcffbbd2c2e44bfd2e457dc418c844623) -- [`polkadot-sdk/stable2503`](https://github.com/paritytech/polkadot-sdk/tree/stable2503) +* Rust >= 1.86 +* [`cargo-contract` `v6.0.0-alpha`](https://github.com/use-ink/cargo-contract/releases/tag/v6.0.0-alpha) +* [`ink-node/5f93093`](https://github.com/use-ink/ink-node/commit/5f93093dcffbbd2c2e44bfd2e457dc418c844623) +* [`polkadot-sdk/stable2503`](https://github.com/paritytech/polkadot-sdk/tree/stable2503) In the following we'll describe some breaking changes on a high-level. The context to understand them is that the `pallet-revive` team has Ethereum/Solidity @@ -150,7 +136,6 @@ they don't want to maintain code that is unnecessary for that objective. _🚧 This is an alpha release, changes will still happen and there are rough edges. 🚧_ ### Cross-contract calling Solidity contracts - We are introducing a new attribute `abi` for the `#[ink::contract]` macro. These are the values it takes: @@ -174,18 +159,15 @@ and Solidity ABI. ### Types #### Contract Balance: `U256` - For the type of a contract's balance, `pallet-revive` uses depending on the context - -- either the configured `pallet_revive::Config::Currency` type (which corresponds - to the `ink::Environment::Balance` type. -- or a hardcoded `U256` (which corresponds to what Ethereum uses). - In this alpha release we just adhere to requiring the types that `pallet-revive` uses. - In an upcoming beta release this could be simplified to reduce UX friction by just - using one type everywhere and converting to the `pallet-revive` one. +* either the configured `pallet_revive::Config::Currency` type (which corresponds + to the `ink::Environment::Balance` type. +* or a hardcoded `U256` (which corresponds to what Ethereum uses). + In this alpha release we just adhere to requiring the types that `pallet-revive` uses. + In an upcoming beta release this could be simplified to reduce UX friction by just + using one type everywhere and converting to the `pallet-revive` one. #### Contract Address: `Address` / `H160` - For a contract's account, `pallet-revive` is using either the configured `AccountId` type of the `polkadot-sdk` runtime, or `H160`. @@ -209,13 +191,11 @@ Besides the publicly exposed crate functions, we've introduced a new subcommand Substrate `AccountId` which it is mapped to. #### Contract Hash: `H256` - For a contract's hash value, `pallet-revive` uses a fixed `H256`, Previously, the `ink::Environment::Hash` type referenced the hash type being used for the contract's hash. Now it's just a fixed `H256`. ### Contract delegates can no longer be done by code - In `pallet-contracts` (and hence up until ink! v5), a pattern for upgradeable contracts was to delegate the contract execution to a different code, e.g. to a new version of the contract's code. @@ -251,7 +231,6 @@ pub struct DelegateCall { ``` ### Feature `ink/unstable-hostfn` - In `pallet-revive` a number of functions can only be called by smart contracts if the chain that the pallet is running on has enabled the feature `pallet-revive/unstable-hostfn`. @@ -260,7 +239,6 @@ This feature is not enabled on Kusama or Westend! It is enabled for the `substrate-contracts-node` version that we linked above. ### New debugging workflow - Previously `pallet-contracts` returned a `debug_message` field with contract instantiations and dry-runs. Whenever `ink::env::debug_println` was invoked in a contract, ink! wrote debugging @@ -288,12 +266,11 @@ that would not be visible in the metadata (so e.g. on a block explorer). The relevant PR is [#2313](https://github.com/use-ink/ink/pull/2313). From ink! 6.0 on only these attributes are allowed in `#[cfg(…)]`: - -- `test` -- `feature` (without `std`) -- `any` -- `not` -- `all` +- `test` +- `feature` (without `std`) +- `any` +- `not` +- `all` ### Metadata Changes @@ -326,7 +303,6 @@ entry point for your smart contract. This is needed because PolkaVM uses a diffe entry point (the `deploy` function). ### `substrate-contracts-node` can no longer be used - The `substrate-contracts-node` is still maintained by Parity for ink! v5 and `pallet-contracts`, but it does not support `pallet-revive`. @@ -336,30 +312,27 @@ It contains `pallet-revive` in a default configuration. You can find binary releases of the node [here](https://github.com/use-ink/ink-node/releases). ### Changed - -- Restrict which `cfg` attributes can be used ‒ [#2313](https://github.com/use-ink/ink/pull/2313) -- More idiomatic return types for metadata getters - [#2398](https://github.com/use-ink/ink/pull/2398) -- Define static distributed events slice in `ink` crate - [#2487](https://github.com/use-ink/ink/pull/2487) -- [E2E] Update `subxt` dependencies ‒ [#2504](https://github.com/use-ink/ink/pull/2504) +- Restrict which `cfg` attributes can be used ‒ [#2313](https://github.com/use-ink/ink/pull/2313) +- More idiomatic return types for metadata getters - [#2398](https://github.com/use-ink/ink/pull/2398) +- Define static distributed events slice in `ink` crate - [#2487](https://github.com/use-ink/ink/pull/2487) +- [E2E] Update `subxt` dependencies ‒ [#2504](https://github.com/use-ink/ink/pull/2504) ### Added - -- Support for `caller_is_root` - [#2332](https://github.com/use-ink/ink/pull/2332) -- Allow setting features for contract build in E2E tests - [#2460](https://github.com/use-ink/ink/pull/2460) -- Improve support for Solidity ABI calling conventions - [#2411](https://github.com/use-ink/ink/pull/2411) -- Implement contract invocation in off-chain environment engine - [#1957](https://github.com/paritytech/ink/pull/1988) -- Abstractions for mapping arbitrary Rust types to Solidity ABI compatible types - [#2441](https://github.com/use-ink/ink/pull/2441) -- Documentation for contract abi arg and provided Rust/ink! to Solidity type mappings - [2463](https://github.com/use-ink/ink/pull/2463) -- Implement `SolDecode`, `SolTypeDecode` and support `SolBytes` for boxed slices - [2476](https://github.com/use-ink/ink/pull/2476) +- Support for `caller_is_root` - [#2332](https://github.com/use-ink/ink/pull/2332) +- Allow setting features for contract build in E2E tests - [#2460](https://github.com/use-ink/ink/pull/2460) +- Improve support for Solidity ABI calling conventions - [#2411](https://github.com/use-ink/ink/pull/2411) +- Implement contract invocation in off-chain environment engine - [#1957](https://github.com/paritytech/ink/pull/1988) +- Abstractions for mapping arbitrary Rust types to Solidity ABI compatible types - [#2441](https://github.com/use-ink/ink/pull/2441) +- Documentation for contract abi arg and provided Rust/ink! to Solidity type mappings - [2463](https://github.com/use-ink/ink/pull/2463) +- Implement `SolDecode`, `SolTypeDecode` and support `SolBytes` for boxed slices - [2476](https://github.com/use-ink/ink/pull/2476) ### Fixed - -- [E2E] Have port parsing handle comma-separated list ‒ [#2336](https://github.com/use-ink/ink/pull/2336) -- Always use ink! ABI/ SCALE codec for constructor and instantiation related builders and utilities - [#2474](https://github.com/use-ink/ink/pull/2474) -- Get rid of "extrinsic for call failed: Pallet error: Revive::AccountAlreadyMapped" - [2483](https://github.com/use-ink/ink/pull/2483) -- CI disk usage via standardised toolchains: `stable` 1.86, `nightly` 2025-02-20 - [#2484](https://github.com/use-ink/ink/pull/2484) -- CI contract size submission - [#2490](https://github.com/use-ink/ink/pull/2490) -- CI relax criteria for `measurements-master` artifact lookup - [#2491](https://github.com/use-ink/ink/pull/2491) +- [E2E] Have port parsing handle comma-separated list ‒ [#2336](https://github.com/use-ink/ink/pull/2336) +- Always use ink! ABI/ SCALE codec for constructor and instantiation related builders and utilities - [#2474](https://github.com/use-ink/ink/pull/2474) +- Get rid of "extrinsic for call failed: Pallet error: Revive::AccountAlreadyMapped" - [2483](https://github.com/use-ink/ink/pull/2483) +- CI disk usage via standardised toolchains: `stable` 1.86, `nightly` 2025-02-20 - [#2484](https://github.com/use-ink/ink/pull/2484) +- CI contract size submission - [#2490](https://github.com/use-ink/ink/pull/2490) +- CI relax criteria for `measurements-master` artifact lookup - [#2491](https://github.com/use-ink/ink/pull/2491) ## Version 5.1.0 @@ -394,8 +367,8 @@ We also added a new page on our documentation website: You can view the Rust docs of the two functions here: -- [`xcm_send`](https://docs.rs/ink_env/5.1.0/ink_env/fn.xcm_send.html) -- [`xcm_execute`](https://docs.rs/ink_env/5.1.0/ink_env/fn.xcm_execute.html) +* [`xcm_send`](https://docs.rs/ink_env/5.1.0/ink_env/fn.xcm_send.html) +* [`xcm_execute`](https://docs.rs/ink_env/5.1.0/ink_env/fn.xcm_execute.html) #### (2) Call an ink! contract from a `polkadot-sdk` runtime @@ -410,11 +383,11 @@ faster development iteration cycles. The limitations currently are: -- Contract calls can only be made to trait messages. This makes sense in the - `pallet-contracts` context, as it is better to depend on a trait rather - than a contract impl, since you are working against an interface. -- Only contract messages can be called currently, no constructors. -- The API could be nicer. +* Contract calls can only be made to trait messages. This makes sense in the + `pallet-contracts` context, as it is better to depend on a trait rather + than a contract impl, since you are working against an interface. +* Only contract messages can be called currently, no constructors. +* The API could be nicer. #### (3) E2E Testing @@ -438,12 +411,12 @@ Second, these are the two changes you have to make: The compatibility changes a bit to ink! 5.0: -- Rust: `>= 1.81` -- `cargo-contract`: `>= 5.0.0` -- `polkadot-sdk`: [>= v1.12.0](https://github.com/paritytech/polkadot-sdk/releases/tag/polkadot-v1.12.0) - (this release stabilized the `pallet-contracts` XCM functions that ink! uses) -- `substrate-contracts-node`: `>= 0.42.0` -- [DRink!](https://github.com/inkdevhub/drink): `>= 0.18.0` +- Rust: `>= 1.81` +- `cargo-contract`: `>= 5.0.0` +- `polkadot-sdk`: [>= v1.12.0](https://github.com/paritytech/polkadot-sdk/releases/tag/polkadot-v1.12.0) + (this release stabilized the `pallet-contracts` XCM functions that ink! uses) +- `substrate-contracts-node`: `>= 0.42.0` +- [DRink!](https://github.com/inkdevhub/drink): `>= 0.18.0` For the linter in `cargo-contract` the Rust toolchain version changed. To upgrade: @@ -456,30 +429,27 @@ rustup run $TOOLCHAIN_VERSION cargo install cargo-dylint dylint-link ``` ### Added - -- [Runtime-to-Contract Calls] Environment agnostic contract invocation API, for calling contracts from runtime ‒ [#2219](https://github.com/use-ink/ink/pull/2219) -- [Runtime-to-Contract Calls] Add `no-panic-handler` feature ‒ [#2164](https://github.com/paritytech/ink/pull/2164) -- [Runtime-to-Contract Calls] Add example for calling a contract from a runtime pallet ‒ [#2189](https://github.com/paritytech/ink/pull/2189) -- [XCM] Add `xcm_execute` and `xcm_send` support ‒ [#1912](https://github.com/use-ink/ink/pull/1912) -- [Linter] Add links to detailed lint description ‒ [#2170](https://github.com/use-ink/ink/pull/2170) -- [E2E] Adds a message to SandboxErr to add context for easier debugging ‒ [#2218](https://github.com/use-ink/ink/pull/2218) -- [E2E] Add ability to take and restore snapshots ‒ [#2261](https://github.com/paritytech/ink/pull/2261) (thanks [@0xLucca](https://github.com/0xLucca)!) -- [E2E] Demonstrate usage of seeds for secret URIs in E2E test for chain snapshots ‒ [#2163](https://github.com/paritytech/ink/pull/2163) +- [Runtime-to-Contract Calls] Environment agnostic contract invocation API, for calling contracts from runtime ‒ [#2219](https://github.com/use-ink/ink/pull/2219) +- [Runtime-to-Contract Calls] Add `no-panic-handler` feature ‒ [#2164](https://github.com/paritytech/ink/pull/2164) +- [Runtime-to-Contract Calls] Add example for calling a contract from a runtime pallet ‒ [#2189](https://github.com/paritytech/ink/pull/2189) +- [XCM] Add `xcm_execute` and `xcm_send` support ‒ [#1912](https://github.com/use-ink/ink/pull/1912) +- [Linter] Add links to detailed lint description ‒ [#2170](https://github.com/use-ink/ink/pull/2170) +- [E2E] Adds a message to SandboxErr to add context for easier debugging ‒ [#2218](https://github.com/use-ink/ink/pull/2218) +- [E2E] Add ability to take and restore snapshots ‒ [#2261](https://github.com/paritytech/ink/pull/2261) (thanks [@0xLucca](https://github.com/0xLucca)!) +- [E2E] Demonstrate usage of seeds for secret URIs in E2E test for chain snapshots ‒ [#2163](https://github.com/paritytech/ink/pull/2163) ### Changed - -- Update repository URLs & references from `paritytech` GitHub organization to new `use-ink` one ‒ [#2220](https://github.com/use-ink/ink/pull/2220) and [#2248](https://github.com/use-ink/ink/pull/2248) -- [E2E] Update `subxt` and `polkadot-sdk` dependencies ‒ [#2174](https://github.com/use-ink/ink/pull/2174) -- [Drink backend] Replace `drink` sandbox with internal `ink_sandbox` ‒ [#2158](https://github.com/use-ink/ink/pull/2158) +- Update repository URLs & references from `paritytech` GitHub organization to new `use-ink` one ‒ [#2220](https://github.com/use-ink/ink/pull/2220) and [#2248](https://github.com/use-ink/ink/pull/2248) +- [E2E] Update `subxt` and `polkadot-sdk` dependencies ‒ [#2174](https://github.com/use-ink/ink/pull/2174) +- [Drink backend] Replace `drink` sandbox with internal `ink_sandbox` ‒ [#2158](https://github.com/use-ink/ink/pull/2158) ### Fixed - -- [XCM] Fix XCM-support to single encode the XCM message ‒ [#2278](https://github.com/use-ink/ink/pull/2278) -- [Examples] ERC-721: `burn()` clears token approval ‒ [#2099](https://github.com/paritytech/ink/pull/2099) -- [E2E] Fix outdated docs for `[ink_e2e::test]` ‒ [#2162](https://github.com/use-ink/ink/pull/2162) -- [E2E] Build contracts before initializing node rpc ‒ [#2168](https://github.com/use-ink/ink/pull/2162) -- [E2E] `set_account_balance` now can't set balance below existential deposit ‒ [#1983](https://github.com/paritytech/ink/pull/1983) (thanks [@0xLucca](https://github.com/0xLucca)!) -- [E2E] Fix outdated docs for `[ink_e2e::test]` ‒ [#2162](https://github.com/paritytech/ink/pull/2162) +- [XCM] Fix XCM-support to single encode the XCM message ‒ [#2278](https://github.com/use-ink/ink/pull/2278) +- [Examples] ERC-721: `burn()` clears token approval ‒ [#2099](https://github.com/paritytech/ink/pull/2099) +- [E2E] Fix outdated docs for `[ink_e2e::test]` ‒ [#2162](https://github.com/use-ink/ink/pull/2162) +- [E2E] Build contracts before initializing node rpc ‒ [#2168](https://github.com/use-ink/ink/pull/2162) +- [E2E] `set_account_balance` now can't set balance below existential deposit ‒ [#1983](https://github.com/paritytech/ink/pull/1983) (thanks [@0xLucca](https://github.com/0xLucca)!) +- [E2E] Fix outdated docs for `[ink_e2e::test]` ‒ [#2162](https://github.com/paritytech/ink/pull/2162) ## Version 5.0.0 @@ -489,21 +459,19 @@ overview over all breaking changes and newly added features._ 👉 _You can view it [here](https://use.ink/faq/migrating-from-ink-4-to-5)._ ### Summary - This release addresses the rest of the severities described in the [OpenZeppelin security review](https://blog.openzeppelin.com/security-review-ink-cargo-contract) of ink! and `cargo-contract`. One of the notable addressed issues is the proxy selector clashing attack. As of this release, ink! only allows exactly one other message with a well-known reserved selector to be defined. You can read more about the change in the [#1827](https://github.com/use-ink/ink/pull/1827) and [#2031](https://github.com/use-ink/ink/pull/2031). ink! 5.0.0 features a significant number of new features: - -- We have introduced a new API based on the calculated or specified selectors for the event definition. This allows events to be defined in separate files and modules, and be shared across multiple ink! contracts - [#1827](https://github.com/use-ink/ink/pull/1827) and [#2031](https://github.com/use-ink/ink/pull/2031). -- [@pmikolajczyk41](https://github.com/pmikolajczyk41) has introduced an alternative E2E testing framework, [DRink!](https://github.com/inkdevhub/drink?tab=readme-ov-file#as-an-alternative-backend-to-inks-e2e-testing-framework), that support quasi-testing model, it allows the test simulate a running node as part of the E2E test while improving debugging experience such as allowing to set breakpoint and step through each stage of execution cycle. -- Following improvements in E2E, we have added a call builder API that allows to easily build calls while significantly reducing boilerplate code - [#1917](https://github.com/use-ink/ink/pull/1917) and [#2075](https://github.com/use-ink/ink/pull/2075) -- Another notable introduction in 5.0.0 release is the support for multiple chain extensions that empower developers - to build even more sophisticated and advanced contracts for supported chains - [#1958](https://github.com/use-ink/ink/pull/1958). -- To further address our consideration of the intrinsic security of ink! smart contracts, - we have disallowed unchecked arithmetic expressions. `cargo-contract` will fail to compile the contract with the raw arithmetic operation - [#1831](https://github.com/use-ink/ink/pull/1831). +- We have introduced a new API based on the calculated or specified selectors for the event definition. This allows events to be defined in separate files and modules, and be shared across multiple ink! contracts - [#1827](https://github.com/use-ink/ink/pull/1827) and [#2031](https://github.com/use-ink/ink/pull/2031). +- [@pmikolajczyk41](https://github.com/pmikolajczyk41) has introduced an alternative E2E testing framework, [DRink!](https://github.com/inkdevhub/drink?tab=readme-ov-file#as-an-alternative-backend-to-inks-e2e-testing-framework), that support quasi-testing model, it allows the test simulate a running node as part of the E2E test while improving debugging experience such as allowing to set breakpoint and step through each stage of execution cycle. +- Following improvements in E2E, we have added a call builder API that allows to easily build calls while significantly reducing boilerplate code - [#1917](https://github.com/use-ink/ink/pull/1917) and [#2075](https://github.com/use-ink/ink/pull/2075) +- Another notable introduction in 5.0.0 release is the support for multiple chain extensions that empower developers +to build even more sophisticated and advanced contracts for supported chains - [#1958](https://github.com/use-ink/ink/pull/1958). +- To further address our consideration of the intrinsic security of ink! smart contracts, +we have disallowed unchecked arithmetic expressions. `cargo-contract` will fail to compile the contract with the raw arithmetic operation - [#1831](https://github.com/use-ink/ink/pull/1831). These are the main features we have introduced in this release. We also encourage developers to have a look at more detailed changelog entries to find out about any breaking changes that may affect @@ -513,168 +481,157 @@ the development of new ink! contracts. See [the compatibility section](https://use.ink/faq/migrating-from-ink-4-to-5/#compatibility) of our migration guide for a detailed description. On a high level: -- Rust: `>= 1.70` -- `cargo-contract`: `>= 4.0.0` -- polkadot-sdk: [>= 0.9.3](https://github.com/paritytech/polkadot-sdk/releases/tag/polkadot-v0.9.3). But if using the new functions introduced in [#2123](https://github.com/use-ink/ink/pull/2123) and [#2077](https://github.com/use-ink/ink/pull/2077) [>= 1.8.0](https://github.com/paritytech/polkadot-sdk/releases/tag/polkadot-v1.8.0) and if using the new functions introduced in [#2076](https://github.com/use-ink/ink/pull/2076) [>= 1.9.0](https://github.com/paritytech/polkadot-sdk/releases/tag/polkadot-v1.8.0). -- `polkadot-js/api` and `polkadot-js/api-contract`: `>= 10.12.1` -- `substrate-contracts-node`: `>= 0.39.0` +- Rust: `>= 1.70` +- `cargo-contract`: `>= 4.0.0` +- polkadot-sdk: [>= 0.9.3](https://github.com/paritytech/polkadot-sdk/releases/tag/polkadot-v0.9.3). But if using the new functions introduced in [#2123](https://github.com/use-ink/ink/pull/2123) and [#2077](https://github.com/use-ink/ink/pull/2077) [>= 1.8.0](https://github.com/paritytech/polkadot-sdk/releases/tag/polkadot-v1.8.0) and if using the new functions introduced in [#2076](https://github.com/use-ink/ink/pull/2076) [>= 1.9.0](https://github.com/paritytech/polkadot-sdk/releases/tag/polkadot-v1.8.0). +- `polkadot-js/api` and `polkadot-js/api-contract`: `>= 10.12.1` +- `substrate-contracts-node`: `>= 0.39.0` ### Changelog #### Added - -- Add Hash trait to Selector struct - [#2149](https://github.com/use-ink/ink/pull/2149) -- `instantiate_v2` with additional limit parameters [#2123](https://github.com/use-ink/ink/pull/2123) -- Custom signature topic in Events - [#2031](https://github.com/use-ink/ink/pull/2031) -- [Linter] `non_fallible_api` lint - [#2004](https://github.com/use-ink/ink/pull/2004) -- [Linter] Publish the linting crates on crates.io - [#2060](https://github.com/use-ink/ink/pull/2060) -- [E2E] Added `create_call_builder` for testing existing contracts - [#2075](https://github.com/use-ink/ink/pull/2075) -- `call_v2` cross-contract calls with additional limit parameters - [#2077](https://github.com/use-ink/ink/pull/2077) -- `delegate_dependency` api calls - [#2076](https://github.com/use-ink/ink/pull/2076) -- Allow mutable parameters in messages - [#2004](https://github.com/use-ink/ink/pull/2004) -- Clean E2E configuration parsing - [#1922](https://github.com/use-ink/ink/pull/1922) -- Make `set_code_hash` generic - [#1906](https://github.com/use-ink/ink/pull/1906) -- Provide a `StorageVec` datastructure built on top of `Lazy` - [#1995](https://github.com/use-ink/ink/pull/1995) -- Add fallible methods for `Mapping` and `Lazy` - [#1910](https://github.com/use-ink/ink/pull/1910) -- [E2E] Allow testing with live-chain state - [#1949](https://github.com/use-ink/ink/pull/1949) -- [E2E] Call builders and extra gas margin option - [#1917](https://github.com/use-ink/ink/pull/1917) -- [Linter] `storage_never_freed` lint - [#1932](https://github.com/use-ink/ink/pull/1932) -- [Linter] `strict_balance_equality` lint - [#1914](https://github.com/use-ink/ink/pull/1914) -- [Linter] `no_main` lint - [#2001](https://github.com/use-ink/ink/pull/2001) -- Reexport `scale` dependencies, introduce `#[ink::scale_derive]` - [#1890](https://github.com/use-ink/ink/pull/1890) -- Upgradeable contracts example - [#1889](https://github.com/use-ink/ink/pull/1889) -- Persist static buffer size in metadata - [#1880](https://github.com/use-ink/ink/pull/1880) -- Modify static buffer size via environmental variables - [#1869](https://github.com/use-ink/ink/pull/1869) -- Added `sr25519_verify` function to `ink_env` [#1840](https://github.com/use-ink/ink/pull/1840) -- Events `2.0` - [#1827](https://github.com/use-ink/ink/pull/1827) -- Add `set_block_number` to off-chain test api `Engine` - [#1806](https://github.com/use-ink/ink/pull/1806) -- Stabilize `call_runtime` ‒ [#1749](https://github.com/use-ink/ink/pull/1749) -- Schema generation - [#1765](https://github.com/use-ink/ink/pull/1765) -- Restrict wildcard selectors to have exactly one other message - [#1708](https://github.com/use-ink/ink/pull/1708) -- [Linter] Warn when primitive number is annotated as event topic - [#1837](https://github.com/use-ink/ink/pull/1837) -- [Drink backend] allow for arbitrary runtime - [#1892](https://github.com/use-ink/ink/pull/1892) -- [Drink backend] support runtime call - [#1891](https://github.com/use-ink/ink/pull/1891) -- [Drink backend] Make tests generic `E2EBackend` trait - [#1867](https://github.com/use-ink/ink/pull/1867) -- [Drink backend] Backend choice ‒ [#1864](https://github.com/use-ink/ink/pull/1864) -- [Drink backend] Backend traits - [#1857](https://github.com/use-ink/ink/pull/1857) -- [Drink backend] Abstract error and result structs - [#1844](https://github.com/use-ink/ink/pull/1844) +- Add Hash trait to Selector struct - [#2149](https://github.com/use-ink/ink/pull/2149) +- `instantiate_v2` with additional limit parameters [#2123](https://github.com/use-ink/ink/pull/2123) +- Custom signature topic in Events - [#2031](https://github.com/use-ink/ink/pull/2031) +- [Linter] `non_fallible_api` lint - [#2004](https://github.com/use-ink/ink/pull/2004) +- [Linter] Publish the linting crates on crates.io - [#2060](https://github.com/use-ink/ink/pull/2060) +- [E2E] Added `create_call_builder` for testing existing contracts - [#2075](https://github.com/use-ink/ink/pull/2075) +- `call_v2` cross-contract calls with additional limit parameters - [#2077](https://github.com/use-ink/ink/pull/2077) +- `delegate_dependency` api calls - [#2076](https://github.com/use-ink/ink/pull/2076) +- Allow mutable parameters in messages - [#2004](https://github.com/use-ink/ink/pull/2004) +- Clean E2E configuration parsing - [#1922](https://github.com/use-ink/ink/pull/1922) +- Make `set_code_hash` generic - [#1906](https://github.com/use-ink/ink/pull/1906) +- Provide a `StorageVec` datastructure built on top of `Lazy` - [#1995](https://github.com/use-ink/ink/pull/1995) +- Add fallible methods for `Mapping` and `Lazy` - [#1910](https://github.com/use-ink/ink/pull/1910) +- [E2E] Allow testing with live-chain state - [#1949](https://github.com/use-ink/ink/pull/1949) +- [E2E] Call builders and extra gas margin option - [#1917](https://github.com/use-ink/ink/pull/1917) +- [Linter] `storage_never_freed` lint - [#1932](https://github.com/use-ink/ink/pull/1932) +- [Linter] `strict_balance_equality` lint - [#1914](https://github.com/use-ink/ink/pull/1914) +- [Linter] `no_main` lint - [#2001](https://github.com/use-ink/ink/pull/2001) +- Reexport `scale` dependencies, introduce `#[ink::scale_derive]` - [#1890](https://github.com/use-ink/ink/pull/1890) +- Upgradeable contracts example - [#1889](https://github.com/use-ink/ink/pull/1889) +- Persist static buffer size in metadata - [#1880](https://github.com/use-ink/ink/pull/1880) +- Modify static buffer size via environmental variables - [#1869](https://github.com/use-ink/ink/pull/1869) +- Added `sr25519_verify` function to `ink_env` [#1840](https://github.com/use-ink/ink/pull/1840) +- Events `2.0` - [#1827](https://github.com/use-ink/ink/pull/1827) +- Add `set_block_number` to off-chain test api `Engine` - [#1806](https://github.com/use-ink/ink/pull/1806) +- Stabilize `call_runtime` ‒ [#1749](https://github.com/use-ink/ink/pull/1749) +- Schema generation - [#1765](https://github.com/use-ink/ink/pull/1765) +- Restrict wildcard selectors to have exactly one other message - [#1708](https://github.com/use-ink/ink/pull/1708) +- [Linter] Warn when primitive number is annotated as event topic - [#1837](https://github.com/use-ink/ink/pull/1837) +- [Drink backend] allow for arbitrary runtime - [#1892](https://github.com/use-ink/ink/pull/1892) +- [Drink backend] support runtime call - [#1891](https://github.com/use-ink/ink/pull/1891) +- [Drink backend] Make tests generic `E2EBackend` trait - [#1867](https://github.com/use-ink/ink/pull/1867) +- [Drink backend] Backend choice ‒ [#1864](https://github.com/use-ink/ink/pull/1864) +- [Drink backend] Backend traits - [#1857](https://github.com/use-ink/ink/pull/1857) +- [Drink backend] Abstract error and result structs - [#1844](https://github.com/use-ink/ink/pull/1844) #### Changed - -- Use name-only syntax for `anonymous` ink! event item configuration argument - [#2140](https://github.com/use-ink/ink/pull/2140) -- Restrict syntax for setting default ink! e2e test runtime-only emulator - [#2143](https://github.com/use-ink/ink/pull/2143) -- Restrict syntax for setting ink! e2e test node to auto - [#2146](https://github.com/use-ink/ink/pull/2146) -- Bump Substrate crates - [#2141](https://github.com/use-ink/ink/pull/2141) -- Minor fixes - [#2144](https://github.com/use-ink/ink/pull/2144), - [#2137](https://github.com/use-ink/ink/pull/2137), [#2132](https://github.com/use-ink/ink/pull/2132) -- Bump metadata version to 5 [#2126](https://github.com/use-ink/ink/pull/2126) -- Use `MaxEncodedLen` for output buffer size [#2128](https://github.com/use-ink/ink/pull/2128) -- `Mapping`: Reflect all possible failure cases in comments ‒ [#2079](https://github.com/use-ink/ink/pull/2079) -- [E2E] Rename `.call` to `.call_builder` ‒ [#2078](https://github.com/use-ink/ink/pull/2078) -- Improve syntax for ink! e2e `runtime_only` attribute argument - [#2083](https://github.com/use-ink/ink/pull/2083) -- [E2E] Remove `additional_contracts` parameter [#2098](https://github.com/use-ink/ink/pull/2098) -- [E2E] change node url backend config - [#2101](https://github.com/use-ink/ink/pull/2101) -- Messages return `TypeSpec` directly - [#1999](https://github.com/use-ink/ink/pull/1999) -- Fail when decoding from storage and not all bytes consumed - [#1897](https://github.com/use-ink/ink/pull/1897) -- Support multiple chain extensions - [#1958](https://github.com/use-ink/ink/pull/1958) - - New example of how to use multiple chain extensions in one contract. - - Affects the usage of the `#[ink::chain_extension]` macro and the definition of the chain extension. -- Split up `ink_linting` to mandatory and extra libraries - [#2032](https://github.com/use-ink/ink/pull/2032) -- [E2E] resolve DispatchError error details for dry-runs - [#1994](https://github.com/use-ink/ink/pull/1994) -- [E2E] update to new `drink` API - [#2005](https://github.com/use-ink/ink/pull/2005) -- Reexport `scale` dependencies, introduce `#[ink::scale_derive]` ‒ [#1890](https://github.com/use-ink/ink/pull/1890) -- Use of workspace dependencies and properties - [#1835](https://github.com/use-ink/ink/pull/1835) -- Remove of unchecked arithmetic - [#1831](https://github.com/use-ink/ink/pull/1831) -- Use `decode_all` for decoding cross contract call result - [#1810](https://github.com/use-ink/ink/pull/1810) -- [E2E] build contracts at runtime instead of during codegen - [#1881](https://github.com/use-ink/ink/pull/1881) -- [E2E] crate refactoring - [#1830](https://github.com/use-ink/ink/pull/1830) -- [E2E] improve call API, remove `build_message` + callback - [#1782](https://github.com/use-ink/ink/pull/1782) +- Use name-only syntax for `anonymous` ink! event item configuration argument - [#2140](https://github.com/use-ink/ink/pull/2140) +- Restrict syntax for setting default ink! e2e test runtime-only emulator - [#2143](https://github.com/use-ink/ink/pull/2143) +- Restrict syntax for setting ink! e2e test node to auto - [#2146](https://github.com/use-ink/ink/pull/2146) +- Bump Substrate crates - [#2141](https://github.com/use-ink/ink/pull/2141) +- Minor fixes - [#2144](https://github.com/use-ink/ink/pull/2144), +[#2137](https://github.com/use-ink/ink/pull/2137), [#2132](https://github.com/use-ink/ink/pull/2132) +- Bump metadata version to 5 [#2126](https://github.com/use-ink/ink/pull/2126) +- Use `MaxEncodedLen` for output buffer size [#2128](https://github.com/use-ink/ink/pull/2128) +- `Mapping`: Reflect all possible failure cases in comments ‒ [#2079](https://github.com/use-ink/ink/pull/2079) +- [E2E] Rename `.call` to `.call_builder` ‒ [#2078](https://github.com/use-ink/ink/pull/2078) +- Improve syntax for ink! e2e `runtime_only` attribute argument - [#2083](https://github.com/use-ink/ink/pull/2083) +- [E2E] Remove `additional_contracts` parameter [#2098](https://github.com/use-ink/ink/pull/2098) +- [E2E] change node url backend config - [#2101](https://github.com/use-ink/ink/pull/2101) +- Messages return `TypeSpec` directly - [#1999](https://github.com/use-ink/ink/pull/1999) +- Fail when decoding from storage and not all bytes consumed - [#1897](https://github.com/use-ink/ink/pull/1897) +- Support multiple chain extensions - [#1958](https://github.com/use-ink/ink/pull/1958) + - New example of how to use multiple chain extensions in one contract. + - Affects the usage of the `#[ink::chain_extension]` macro and the definition of the chain extension. +- Split up `ink_linting` to mandatory and extra libraries - [#2032](https://github.com/use-ink/ink/pull/2032) +- [E2E] resolve DispatchError error details for dry-runs - [#1994](https://github.com/use-ink/ink/pull/1994) +- [E2E] update to new `drink` API - [#2005](https://github.com/use-ink/ink/pull/2005) +- Reexport `scale` dependencies, introduce `#[ink::scale_derive]` ‒ [#1890](https://github.com/use-ink/ink/pull/1890) +- Use of workspace dependencies and properties - [#1835](https://github.com/use-ink/ink/pull/1835) +- Remove of unchecked arithmetic - [#1831](https://github.com/use-ink/ink/pull/1831) +- Use `decode_all` for decoding cross contract call result - [#1810](https://github.com/use-ink/ink/pull/1810) +- [E2E] build contracts at runtime instead of during codegen - [#1881](https://github.com/use-ink/ink/pull/1881) +- [E2E] crate refactoring - [#1830](https://github.com/use-ink/ink/pull/1830) +- [E2E] improve call API, remove `build_message` + callback - [#1782](https://github.com/use-ink/ink/pull/1782) #### Fixed - -- Fix alignment in allocator [#2100](https://github.com/use-ink/ink/pull/2100) -- Fix the `StorageVec` type by excluding the `len_cached` field from its type info - [#2052](https://github.com/use-ink/ink/pull/2052) -- Fix panic in `approve_for` in the ERC-721 example - [#2092](https://github.com/use-ink/ink/pull/2092) -- ERC-721: `transfer_token_from` now ensures the token owner is correct - [#2093](https://github.com/use-ink/ink/pull/2093) -- `RootLayout::new()` is generic again to allow using `ink_metadata` in pure `PortableForm` contexts - [#1989](https://github.com/use-ink/ink/pull/1989) +- Fix alignment in allocator [#2100](https://github.com/use-ink/ink/pull/2100) +- Fix the `StorageVec` type by excluding the `len_cached` field from its type info - [#2052](https://github.com/use-ink/ink/pull/2052) +- Fix panic in `approve_for` in the ERC-721 example - [#2092](https://github.com/use-ink/ink/pull/2092) +- ERC-721: `transfer_token_from` now ensures the token owner is correct - [#2093](https://github.com/use-ink/ink/pull/2093) +- `RootLayout::new()` is generic again to allow using `ink_metadata` in pure `PortableForm` contexts - [#1989](https://github.com/use-ink/ink/pull/1989) ## Version 5.0.0-rc.3 ### Changed - -- Use name-only syntax for `anonymous` ink! event item configuration argument - [#2140](https://github.com/use-ink/ink/pull/2140) -- Restrict syntax for setting default ink! e2e test runtime-only emulator - [#2143](https://github.com/use-ink/ink/pull/2143) -- Restrict syntax for setting ink! e2e test node to auto - [#2146](https://github.com/use-ink/ink/pull/2146) -- Bump Substrate crates - [#2141](https://github.com/use-ink/ink/pull/2141) -- Minor fixes - [#2144](https://github.com/use-ink/ink/pull/2144), - [#2137](https://github.com/use-ink/ink/pull/2137), [#2132](https://github.com/use-ink/ink/pull/2132) +- Use name-only syntax for `anonymous` ink! event item configuration argument - [#2140](https://github.com/use-ink/ink/pull/2140) +- Restrict syntax for setting default ink! e2e test runtime-only emulator - [#2143](https://github.com/use-ink/ink/pull/2143) +- Restrict syntax for setting ink! e2e test node to auto - [#2146](https://github.com/use-ink/ink/pull/2146) +- Bump Substrate crates - [#2141](https://github.com/use-ink/ink/pull/2141) +- Minor fixes - [#2144](https://github.com/use-ink/ink/pull/2144), +[#2137](https://github.com/use-ink/ink/pull/2137), [#2132](https://github.com/use-ink/ink/pull/2132) ## Version 5.0.0-rc.2 ### Added - -- `instantiate_v2` with additional limit parameters [#2123](https://github.com/use-ink/ink/pull/2123) +- `instantiate_v2` with additional limit parameters [#2123](https://github.com/use-ink/ink/pull/2123) ### Changed - -- Bump metadata version to 5 [#2126](https://github.com/use-ink/ink/pull/2126) -- Use `MaxEncodedLen` for output buffer size [#2128](https://github.com/use-ink/ink/pull/2128) +- Bump metadata version to 5 [#2126](https://github.com/use-ink/ink/pull/2126) +- Use `MaxEncodedLen` for output buffer size [#2128](https://github.com/use-ink/ink/pull/2128) ### Fixed - -- Fix alignment in allocator [#2100](https://github.com/use-ink/ink/pull/2100) +- Fix alignment in allocator [#2100](https://github.com/use-ink/ink/pull/2100) ## Version 5.0.0-rc.1 ### Added - -- Custom signature topic in Events - [#2031](https://github.com/use-ink/ink/pull/2031) -- [Linter] `non_fallible_api` lint - [#2004](https://github.com/use-ink/ink/pull/2004) -- [Linter] Publish the linting crates on crates.io - [#2060](https://github.com/use-ink/ink/pull/2060) -- [E2E] Added `create_call_builder` for testing existing contracts - [#2075](https://github.com/use-ink/ink/pull/2075) -- `call_v2` cross-contract calls with additional limit parameters - [#2077](https://github.com/use-ink/ink/pull/2077) -- `instantiate_v2` with additional limit parameters - [#2123](https://github.com/use-ink/ink/pull/2123) -- `delegate_dependency` api calls - [#2076](https://github.com/use-ink/ink/pull/2076) +- Custom signature topic in Events - [#2031](https://github.com/use-ink/ink/pull/2031) +- [Linter] `non_fallible_api` lint - [#2004](https://github.com/use-ink/ink/pull/2004) +- [Linter] Publish the linting crates on crates.io - [#2060](https://github.com/use-ink/ink/pull/2060) +- [E2E] Added `create_call_builder` for testing existing contracts - [#2075](https://github.com/use-ink/ink/pull/2075) +- `call_v2` cross-contract calls with additional limit parameters - [#2077](https://github.com/use-ink/ink/pull/2077) +- `instantiate_v2` with additional limit parameters - [#2123](https://github.com/use-ink/ink/pull/2123) +- `delegate_dependency` api calls - [#2076](https://github.com/use-ink/ink/pull/2076) ### Changed - -- `Mapping`: Reflect all possible failure cases in comments ‒ [#2079](https://github.com/use-ink/ink/pull/2079) -- [E2E] Rename `.call` to `.call_builder` ‒ [#2078](https://github.com/use-ink/ink/pull/2078) -- Improve syntax for ink! e2e `runtime_only` attribute argument - [#2083](https://github.com/use-ink/ink/pull/2083) -- [E2E] Remove `additional_contracts` parameter [#2098](https://github.com/use-ink/ink/pull/2098) -- [E2E] change node url backend config - [#2101](https://github.com/use-ink/ink/pull/2101) +- `Mapping`: Reflect all possible failure cases in comments ‒ [#2079](https://github.com/use-ink/ink/pull/2079) +- [E2E] Rename `.call` to `.call_builder` ‒ [#2078](https://github.com/use-ink/ink/pull/2078) +- Improve syntax for ink! e2e `runtime_only` attribute argument - [#2083](https://github.com/use-ink/ink/pull/2083) +- [E2E] Remove `additional_contracts` parameter [#2098](https://github.com/use-ink/ink/pull/2098) +- [E2E] change node url backend config - [#2101](https://github.com/use-ink/ink/pull/2101) ### Fixed - -- Fix the `StorageVec` type by excluding the `len_cached` field from its type info - [#2052](https://github.com/use-ink/ink/pull/2052) -- Fix panic in `approve_for` in the ERC-721 example - [#2092](https://github.com/use-ink/ink/pull/2092) -- ERC-721: `transfer_token_from` now ensures the token owner is correct - [#2093](https://github.com/use-ink/ink/pull/2093) +- Fix the `StorageVec` type by excluding the `len_cached` field from its type info - [#2052](https://github.com/use-ink/ink/pull/2052) +- Fix panic in `approve_for` in the ERC-721 example - [#2092](https://github.com/use-ink/ink/pull/2092) +- ERC-721: `transfer_token_from` now ensures the token owner is correct - [#2093](https://github.com/use-ink/ink/pull/2093) ## Version 5.0.0-rc ### Added - -- Allow mutable parameters in messages - [#2004](https://github.com/use-ink/ink/pull/2004) -- Clean E2E configuration parsing - [#1922](https://github.com/use-ink/ink/pull/1922) -- Make `set_code_hash` generic - [#1906](https://github.com/use-ink/ink/pull/1906) -- Provide a `StorageVec` datastructure built on top of `Lazy` - [#1995](https://github.com/use-ink/ink/pull/1995) -- Add fallible methods for `Mapping` and `Lazy` - [#1910](https://github.com/use-ink/ink/pull/1910) -- [E2E] Allow testing with live-chain state - [#1949](https://github.com/use-ink/ink/pull/1949) -- [E2E] Call builders and extra gas margin option - [#1917](https://github.com/use-ink/ink/pull/1917) -- [Linter] `storage_never_freed` lint - [#1932](https://github.com/use-ink/ink/pull/1932) -- [Linter] `strict_balance_equality` lint - [#1914](https://github.com/use-ink/ink/pull/1914) -- [Linter] `no_main` lint - [#2001](https://github.com/use-ink/ink/pull/2001) +- Allow mutable parameters in messages - [#2004](https://github.com/use-ink/ink/pull/2004) +- Clean E2E configuration parsing - [#1922](https://github.com/use-ink/ink/pull/1922) +- Make `set_code_hash` generic - [#1906](https://github.com/use-ink/ink/pull/1906) +- Provide a `StorageVec` datastructure built on top of `Lazy` - [#1995](https://github.com/use-ink/ink/pull/1995) +- Add fallible methods for `Mapping` and `Lazy` - [#1910](https://github.com/use-ink/ink/pull/1910) +- [E2E] Allow testing with live-chain state - [#1949](https://github.com/use-ink/ink/pull/1949) +- [E2E] Call builders and extra gas margin option - [#1917](https://github.com/use-ink/ink/pull/1917) +- [Linter] `storage_never_freed` lint - [#1932](https://github.com/use-ink/ink/pull/1932) +- [Linter] `strict_balance_equality` lint - [#1914](https://github.com/use-ink/ink/pull/1914) +- [Linter] `no_main` lint - [#2001](https://github.com/use-ink/ink/pull/2001) ### Changed +- Messages return `TypeSpec` directly - [#1999](https://github.com/use-ink/ink/pull/1999) +- Fail when decoding from storage and not all bytes consumed - [#1897](https://github.com/use-ink/ink/pull/1897) +- Support multiple chain extensions - [#1958](https://github.com/use-ink/ink/pull/1958) + - New example of how to use multiple chain extensions in one contract. + - Affects the usage of the `#[ink::chain_extension]` macro and the definition of the chain extension. +- Split up `ink_linting` to mandatory and extra libraries - [#2032](https://github.com/use-ink/ink/pull/2032) +- [E2E] resolve DispatchError error details for dry-runs - [#1994](https://github.com/use-ink/ink/pull/1994) +- [E2E] update to new `drink` API - [#2005](https://github.com/use-ink/ink/pull/2005) -- Messages return `TypeSpec` directly - [#1999](https://github.com/use-ink/ink/pull/1999) -- Fail when decoding from storage and not all bytes consumed - [#1897](https://github.com/use-ink/ink/pull/1897) -- Support multiple chain extensions - [#1958](https://github.com/use-ink/ink/pull/1958) - - New example of how to use multiple chain extensions in one contract. - - Affects the usage of the `#[ink::chain_extension]` macro and the definition of the chain extension. -- Split up `ink_linting` to mandatory and extra libraries - [#2032](https://github.com/use-ink/ink/pull/2032) -- [E2E] resolve DispatchError error details for dry-runs - [#1994](https://github.com/use-ink/ink/pull/1994) -- [E2E] update to new `drink` API - [#2005](https://github.com/use-ink/ink/pull/2005) ## Version 5.0.0-alpha @@ -686,94 +643,85 @@ You can read more about the change in the [PR](https://github.com/use-ink/ink/pu Other notable changes: -- Rework of event definitions - [#1827](https://github.com/use-ink/ink/pull/1827). -- Updated upgradeable contract example illustrating `delegate_call` - [#1889](https://github.com/use-ink/ink/pull/1889). -- Removal of unchecked arithmetic. `cargo-contract` will fail compiling the contract with raw arithmetic operations - [#1831](https://github.com/use-ink/ink/pull/1831). -- Introduction of an alternative off-chain E2E testing backend, [DRink!](https://github.com/inkdevhub/drink?tab=readme-ov-file#as-an-alternative-backend-to-inks-e2e-testing-framework). - **Big thanks to [@pmikolajczyk41](https://github.com/pmikolajczyk41) for this massive contribution!** +- Rework of event definitions - [#1827](https://github.com/use-ink/ink/pull/1827). +- Updated upgradeable contract example illustrating `delegate_call` - [#1889](https://github.com/use-ink/ink/pull/1889). +- Removal of unchecked arithmetic. `cargo-contract` will fail compiling the contract with raw arithmetic operations - [#1831](https://github.com/use-ink/ink/pull/1831). +- Introduction of an alternative off-chain E2E testing backend, [DRink!](https://github.com/inkdevhub/drink?tab=readme-ov-file#as-an-alternative-backend-to-inks-e2e-testing-framework). +**Big thanks to [@pmikolajczyk41](https://github.com/pmikolajczyk41) for this massive contribution!** You can see a more detailed log of changes below: ### Added - -- Reexport `scale` dependencies, introduce `#[ink::scale_derive]` - [#1890](https://github.com/use-ink/ink/pull/1890) -- Upgradeable contracts example - [#1889](https://github.com/use-ink/ink/pull/1889) -- Persist static buffer size in metadata - [#1880](https://github.com/use-ink/ink/pull/1880) -- Modify static buffer size via environmental variables - [#1869](https://github.com/use-ink/ink/pull/1869) -- Added `sr25519_verify` function to `ink_env` [#1840](https://github.com/use-ink/ink/pull/1840) -- Events `2.0` - [#1827](https://github.com/use-ink/ink/pull/1827) -- Add `set_block_number` to off-chain test api `Engine` - [#1806](https://github.com/use-ink/ink/pull/1806) -- Stabilize `call_runtime` ‒ [#1749](https://github.com/use-ink/ink/pull/1749) -- Schema generation - [#1765](https://github.com/use-ink/ink/pull/1765) -- Restrict wildcard selectors to have exactly one other message - [#1708](https://github.com/use-ink/ink/pull/1708) -- [Linter] Warn when primitive number is annotated as event topic - [#1837](https://github.com/use-ink/ink/pull/1837) -- [Drink backend] allow for arbitrary runtime - [#1892](https://github.com/use-ink/ink/pull/1892) -- [Drink backend] support runtime call - [#1891](https://github.com/use-ink/ink/pull/1891) -- [Drink backend] Make tests generic `E2EBackend` trait - [#1867](https://github.com/use-ink/ink/pull/1867) -- [Drink backend] Backend choice ‒ [#1864](https://github.com/use-ink/ink/pull/1864) -- [Drink backend] Backend traits - [#1857](https://github.com/use-ink/ink/pull/1857) -- [Drink backend] Abstract error and result structs - [#1844](https://github.com/use-ink/ink/pull/1844) +- Reexport `scale` dependencies, introduce `#[ink::scale_derive]` - [#1890](https://github.com/use-ink/ink/pull/1890) +- Upgradeable contracts example - [#1889](https://github.com/use-ink/ink/pull/1889) +- Persist static buffer size in metadata - [#1880](https://github.com/use-ink/ink/pull/1880) +- Modify static buffer size via environmental variables - [#1869](https://github.com/use-ink/ink/pull/1869) +- Added `sr25519_verify` function to `ink_env` [#1840](https://github.com/use-ink/ink/pull/1840) +- Events `2.0` - [#1827](https://github.com/use-ink/ink/pull/1827) +- Add `set_block_number` to off-chain test api `Engine` - [#1806](https://github.com/use-ink/ink/pull/1806) +- Stabilize `call_runtime` ‒ [#1749](https://github.com/use-ink/ink/pull/1749) +- Schema generation - [#1765](https://github.com/use-ink/ink/pull/1765) +- Restrict wildcard selectors to have exactly one other message - [#1708](https://github.com/use-ink/ink/pull/1708) +- [Linter] Warn when primitive number is annotated as event topic - [#1837](https://github.com/use-ink/ink/pull/1837) +- [Drink backend] allow for arbitrary runtime - [#1892](https://github.com/use-ink/ink/pull/1892) +- [Drink backend] support runtime call - [#1891](https://github.com/use-ink/ink/pull/1891) +- [Drink backend] Make tests generic `E2EBackend` trait - [#1867](https://github.com/use-ink/ink/pull/1867) +- [Drink backend] Backend choice ‒ [#1864](https://github.com/use-ink/ink/pull/1864) +- [Drink backend] Backend traits - [#1857](https://github.com/use-ink/ink/pull/1857) +- [Drink backend] Abstract error and result structs - [#1844](https://github.com/use-ink/ink/pull/1844) ### Changed - -- Reexport `scale` dependencies, introduce `#[ink::scale_derive]` ‒ [#1890](https://github.com/use-ink/ink/pull/1890) -- Use of workspace dependencies and properties - [#1835](https://github.com/use-ink/ink/pull/1835) -- Remove of unchecked arithmetic - [#1831](https://github.com/use-ink/ink/pull/1831) -- Use `decode_all` for decoding cross contract call result - [#1810](https://github.com/use-ink/ink/pull/1810) -- [E2E] build contracts at runtime instead of during codegen - [#1881](https://github.com/use-ink/ink/pull/1881) -- [E2E] crate refactoring - [#1830](https://github.com/use-ink/ink/pull/1830) -- [E2E] improve call API, remove `build_message` + callback - [#1782](https://github.com/use-ink/ink/pull/1782) +- Reexport `scale` dependencies, introduce `#[ink::scale_derive]` ‒ [#1890](https://github.com/use-ink/ink/pull/1890) +- Use of workspace dependencies and properties - [#1835](https://github.com/use-ink/ink/pull/1835) +- Remove of unchecked arithmetic - [#1831](https://github.com/use-ink/ink/pull/1831) +- Use `decode_all` for decoding cross contract call result - [#1810](https://github.com/use-ink/ink/pull/1810) +- [E2E] build contracts at runtime instead of during codegen - [#1881](https://github.com/use-ink/ink/pull/1881) +- [E2E] crate refactoring - [#1830](https://github.com/use-ink/ink/pull/1830) +- [E2E] improve call API, remove `build_message` + callback - [#1782](https://github.com/use-ink/ink/pull/1782) ### Fixed - -- `RootLayout::new()` is generic again to allow using `ink_metadata` in pure `PortableForm` contexts - [#1989](https://github.com/use-ink/ink/pull/1989) +- `RootLayout::new()` is generic again to allow using `ink_metadata` in pure `PortableForm` contexts - [#1989](https://github.com/use-ink/ink/pull/1989) ## 4.3.0 ### Fixed -- Fix E2E tests for newer rust toolchain & contracts node - #[1884](https://github.com/use-ink/ink/pull/1884) -- Enable Rust >= `1.70`, update `subxt` and `contract-build` - [#1855](https://github.com/use-ink/ink/pull/1855) -- Fix unsupported `--ws-port` argument - [#1850](https://github.com/use-ink/ink/pull/1850) +- Fix E2E tests for newer rust toolchain & contracts node - #[1884](https://github.com/use-ink/ink/pull/1884) +- Enable Rust >= `1.70`, update `subxt` and `contract-build` - [#1855](https://github.com/use-ink/ink/pull/1855) +- Fix unsupported `--ws-port` argument - [#1850](https://github.com/use-ink/ink/pull/1850) ## Version 4.2.0 ### Added - -- Persist `Environment` in metadata ‒ [#1741](https://github.com/use-ink/ink/pull/1741) -- Added possibility for `runtime_call` in E2E tests ‒ [#1736](https://github.com/use-ink/ink/pull/1736) -- Added `default` attribute to constructors and messages ‒ [#1724](https://github.com/use-ink/ink/pull/1724) -- Added clarification about `Mapping::size` unit ‒ [#1735](https://github.com/use-ink/ink/pull/1735) +- Persist `Environment` in metadata ‒ [#1741](https://github.com/use-ink/ink/pull/1741) +- Added possibility for `runtime_call` in E2E tests ‒ [#1736](https://github.com/use-ink/ink/pull/1736) +- Added `default` attribute to constructors and messages ‒ [#1724](https://github.com/use-ink/ink/pull/1724) +- Added clarification about `Mapping::size` unit ‒ [#1735](https://github.com/use-ink/ink/pull/1735) ### Changed - -- Upgraded `syn` to version `2` ‒ [#1731](https://github.com/use-ink/ink/pull/1731) -- Update `scale-info` requirement to `2.5` ‒ [#1733](https://github.com/use-ink/ink/pull/1733) -- Bump `subxt` to `0.28.0` ‒ [#1750](https://github.com/use-ink/ink/pull/1750) +- Upgraded `syn` to version `2` ‒ [#1731](https://github.com/use-ink/ink/pull/1731) +- Update `scale-info` requirement to `2.5` ‒ [#1733](https://github.com/use-ink/ink/pull/1733) +- Bump `subxt` to `0.28.0` ‒ [#1750](https://github.com/use-ink/ink/pull/1750) ## Version 4.1.0 ### Added - -- Basic support for `dyn Trait` to allow cross-contract calls only with trait - [#1673](https://github.com/use-ink/ink/pull/1673) -- E2E: auto detect contracts to be built - [#1691](https://github.com/use-ink/ink/pull/1691) -- Add `set_code_hash` to `EnvAccess` - [#1698](https://github.com/use-ink/ink/pull/1698) -- Add `set_block_timestamp` to off-chain test api `Engine` - [#1721](https://github.com/use-ink/ink/pull/1721) +- Basic support for `dyn Trait` to allow cross-contract calls only with trait - [#1673](https://github.com/use-ink/ink/pull/1673) +- E2E: auto detect contracts to be built - [#1691](https://github.com/use-ink/ink/pull/1691) +- Add `set_code_hash` to `EnvAccess` - [#1698](https://github.com/use-ink/ink/pull/1698) +- Add `set_block_timestamp` to off-chain test api `Engine` - [#1721](https://github.com/use-ink/ink/pull/1721) ### Changed - -- Support conditional compilation - [#1707](https://github.com/use-ink/ink/pull/1707) +- Support conditional compilation - [#1707](https://github.com/use-ink/ink/pull/1707) ## Version 4.0.1 ### Fixed - -- Fixing `ManualKey<0>` to act properly - [#1670](https://github.com/use-ink/ink/pull/1670) -- Indicated latest release of `cargo-contract` in `e2e` crate +- Fixing `ManualKey<0>` to act properly - [#1670](https://github.com/use-ink/ink/pull/1670) +- Indicated latest release of `cargo-contract` in `e2e` crate ### Added - -- Add `call-runtime` support - [#1641](https://github.com/use-ink/ink/pull/1641) +- Add `call-runtime` support - [#1641](https://github.com/use-ink/ink/pull/1641) ## Version 4.0.0 @@ -783,11 +731,10 @@ This version brings a lot of usability improvements, making the language better for the needs of production parachains. A couple of highlights include: - -- Changes to how contract storage works, which significantly reduced the sizes of - contract binaries -- A new end-to-end testing framework, letting you easily write integration tests -- Changes to the metadata format, which (in part) makes error handling more expressive +- Changes to how contract storage works, which significantly reduced the sizes of + contract binaries +- A new end-to-end testing framework, letting you easily write integration tests +- Changes to the metadata format, which (in part) makes error handling more expressive There's a lot more to dig through, so take some time to poke around the `CHANGELOG` (including the `4.0.0-alpha` and `4.0.0-beta` releases). @@ -817,58 +764,55 @@ compatible with the ink! `4.0.0` release. For full compatibility requirements see the [migration guide](https://use.ink/faq/migrating-from-ink-3-to-4/#compatibility). -- Add `Mapping::contains(key)` and `Mapping::insert_return_size(key, val)` ‒ [#1224](https://github.com/use-ink/ink/pull/1224) -- Add [`payment-channel`](https://github.com/use-ink/ink-examples/tree/main/payment-channel) example ‒ [#1248](https://github.com/use-ink/ink/pull/1248) (thanks [@kanishkatn](https://github.com/kanishkatn)!) -- Add `version` field to ink! metadata ‒ [#1313](https://github.com/use-ink/ink/pull/1313) -- The `rand-extension` example has been adapted to an updated version of the `ChainExtension` API ‒ [#1356](https://github.com/use-ink/ink/pull/1356) -- Add `ink_env::pay_with_call!` helper macro for off-chain emulation of sending payments with contract message calls ‒ [#1379](https://github.com/use-ink/ink/pull/1379) -- Allow using `Result` as a return type in constructors ‒ [#1446](https://github.com/use-ink/ink/pull/1446) -- Add `Mapping::take()` function allowing to get a value removing it from storage ‒ [#1461](https://github.com/use-ink/ink/pull/1461) -- Add E2E testing framework MVP ‒ [#1395](https://github.com/use-ink/ink/pull/1395) -- Add E2E tests for `Mapping` functions - [#1492](https://github.com/use-ink/ink/pull/1492) -- E2E: expose call dry-run method ‒ [#1624](https://github.com/use-ink/ink/pull/1624) -- Make cross-contract callee non-optional ‒ [#1636](https://github.com/use-ink/ink/pull/1636) -- Support custom environment in E2E tests - [#1645](https://github.com/use-ink/ink/pull/1645) (thanks [@pmikolajczyk41](https://github.com/pmikolajczyk41)!) +- Add `Mapping::contains(key)` and `Mapping::insert_return_size(key, val)` ‒ [#1224](https://github.com/use-ink/ink/pull/1224) +- Add [`payment-channel`](https://github.com/use-ink/ink-examples/tree/main/payment-channel) example ‒ [#1248](https://github.com/use-ink/ink/pull/1248) (thanks [@kanishkatn](https://github.com/kanishkatn)!) +- Add `version` field to ink! metadata ‒ [#1313](https://github.com/use-ink/ink/pull/1313) +- The `rand-extension` example has been adapted to an updated version of the `ChainExtension` API ‒ [#1356](https://github.com/use-ink/ink/pull/1356) +- Add `ink_env::pay_with_call!` helper macro for off-chain emulation of sending payments with contract message calls ‒ [#1379](https://github.com/use-ink/ink/pull/1379) +- Allow using `Result` as a return type in constructors ‒ [#1446](https://github.com/use-ink/ink/pull/1446) +- Add `Mapping::take()` function allowing to get a value removing it from storage ‒ [#1461](https://github.com/use-ink/ink/pull/1461) +- Add E2E testing framework MVP ‒ [#1395](https://github.com/use-ink/ink/pull/1395) +- Add E2E tests for `Mapping` functions - [#1492](https://github.com/use-ink/ink/pull/1492) +- E2E: expose call dry-run method ‒ [#1624](https://github.com/use-ink/ink/pull/1624) +- Make cross-contract callee non-optional ‒ [#1636](https://github.com/use-ink/ink/pull/1636) +- Support custom environment in E2E tests - [#1645](https://github.com/use-ink/ink/pull/1645) (thanks [@pmikolajczyk41](https://github.com/pmikolajczyk41)!) ### Changed - -- Contract size optimization in case contract doesn't accept payment ‒ [#1267](https://github.com/use-ink/ink/pull/1267) (thanks [@xgreenx](https://github.com/xgreenx)!) -- Move ink! linter into `ink` repository ‒ [#1361](https://github.com/use-ink/ink/pull/1267) -- Introduce `ink` entrance crate ‒ [#1223](https://github.com/use-ink/ink/pull/1223) -- Use `XXH32` instead of `sha256` for calculating storage keys ‒ [#1393](https://github.com/use-ink/ink/pull/1393) -- Storage Refactoring ‒ [#1331](https://github.com/use-ink/ink/pull/1331) -- Add support for language level errors (`LangError`) ‒ [#1450](https://github.com/use-ink/ink/pull/1450) -- Return `LangError`s from constructors ‒ [#1504](https://github.com/use-ink/ink/pull/1504) -- Update `scale-info` requirement to `2.3` ‒ [#1467](https://github.com/use-ink/ink/pull/1467) -- Merge `Mapping::insert(key, val)` and `Mapping::insert_return_size(key, val)` into one method - [#1463](https://github.com/use-ink/ink/pull/1463) -- FFI: no more `__unstable__` wasm import module ‒ [#1522](https://github.com/use-ink/ink/pull/1522) -- Clean up CallBuilder `return()` type ‒ [#1525](https://github.com/use-ink/ink/pull/1525) -- Fix trait message return type metadata ‒ [#1531](https://github.com/use-ink/ink/pull/1531) -- Bump Dylint dependencies ‒ [#1551](https://github.com/use-ink/ink/pull/1551) -- Stabilize `take_storage` ‒ [#1568](https://github.com/use-ink/ink/pull/1568) -- Chain Extension: Evaluation of method return type at compile time ‒ [#1569](https://github.com/use-ink/ink/pull/1569) -- Make more functions be const ‒ [#1574](https://github.com/use-ink/ink/pull/1574) (thanks [@yjhmelody](https://github.com/yjhmelody)!) -- Unify fallible and non fallible `instantiate` methods ‒ [#1591](https://github.com/use-ink/ink/pull/1591) -- Make `CallBuilder` and `CreateBuilder` error handling optional ‒ [#1602](https://github.com/use-ink/ink/pull/1602) -- Rename `CallBuilder::fire()` method to `invoke()` ‒ [#1604](https://github.com/use-ink/ink/pull/1604) -- chore: add minimum rust version to the ink crate ‒ [#1609](https://github.com/use-ink/ink/pull/1609) (thanks [@Kurtsley](https://github.com/Kurtsley)!) -- Rename `_checked` codegen call methods with `try_` ‒ [#1621](https://github.com/use-ink/ink/pull/1621) -- Bump Substrate and `subxt` dependencies ‒ [#1549](https://github.com/use-ink/ink/pull/1549) -- E2E: spawn a separate contracts node instance per test ‒ [#1642](https://github.com/use-ink/ink/pull/1642) +- Contract size optimization in case contract doesn't accept payment ‒ [#1267](https://github.com/use-ink/ink/pull/1267) (thanks [@xgreenx](https://github.com/xgreenx)!) +- Move ink! linter into `ink` repository ‒ [#1361](https://github.com/use-ink/ink/pull/1267) +- Introduce `ink` entrance crate ‒ [#1223](https://github.com/use-ink/ink/pull/1223) +- Use `XXH32` instead of `sha256` for calculating storage keys ‒ [#1393](https://github.com/use-ink/ink/pull/1393) +- Storage Refactoring ‒ [#1331](https://github.com/use-ink/ink/pull/1331) +- Add support for language level errors (`LangError`) ‒ [#1450](https://github.com/use-ink/ink/pull/1450) +- Return `LangError`s from constructors ‒ [#1504](https://github.com/use-ink/ink/pull/1504) +- Update `scale-info` requirement to `2.3` ‒ [#1467](https://github.com/use-ink/ink/pull/1467) +- Merge `Mapping::insert(key, val)` and `Mapping::insert_return_size(key, val)` into one method - [#1463](https://github.com/use-ink/ink/pull/1463) +- FFI: no more `__unstable__` wasm import module ‒ [#1522](https://github.com/use-ink/ink/pull/1522) +- Clean up CallBuilder `return()` type ‒ [#1525](https://github.com/use-ink/ink/pull/1525) +- Fix trait message return type metadata ‒ [#1531](https://github.com/use-ink/ink/pull/1531) +- Bump Dylint dependencies ‒ [#1551](https://github.com/use-ink/ink/pull/1551) +- Stabilize `take_storage` ‒ [#1568](https://github.com/use-ink/ink/pull/1568) +- Chain Extension: Evaluation of method return type at compile time ‒ [#1569](https://github.com/use-ink/ink/pull/1569) +- Make more functions be const ‒ [#1574](https://github.com/use-ink/ink/pull/1574) (thanks [@yjhmelody](https://github.com/yjhmelody)!) +- Unify fallible and non fallible `instantiate` methods ‒ [#1591](https://github.com/use-ink/ink/pull/1591) +- Make `CallBuilder` and `CreateBuilder` error handling optional ‒ [#1602](https://github.com/use-ink/ink/pull/1602) +- Rename `CallBuilder::fire()` method to `invoke()` ‒ [#1604](https://github.com/use-ink/ink/pull/1604) +- chore: add minimum rust version to the ink crate ‒ [#1609](https://github.com/use-ink/ink/pull/1609) (thanks [@Kurtsley](https://github.com/Kurtsley)!) +- Rename `_checked` codegen call methods with `try_` ‒ [#1621](https://github.com/use-ink/ink/pull/1621) +- Bump Substrate and `subxt` dependencies ‒ [#1549](https://github.com/use-ink/ink/pull/1549) +- E2E: spawn a separate contracts node instance per test ‒ [#1642](https://github.com/use-ink/ink/pull/1642) ### Fixed - -- Trim single whitespace prefix in the metadata `docs` field ‒ [#1385](https://github.com/use-ink/ink/pull/1385) -- Allow pay_with_call to take multiple arguments ‒ [#1401](https://github.com/use-ink/ink/pull/1401) -- Add Determinism enum from pallet-contracts ‒ [#1547](https://github.com/use-ink/ink/pull/1547) -- Added missed `WhereClosure` for the generics into `storage_item` ‒ [#1536](https://github.com/use-ink/ink/pull/1536) (thanks [@xgreenx](https://github.com/xgreenx)!) +- Trim single whitespace prefix in the metadata `docs` field ‒ [#1385](https://github.com/use-ink/ink/pull/1385) +- Allow pay_with_call to take multiple arguments ‒ [#1401](https://github.com/use-ink/ink/pull/1401) +- Add Determinism enum from pallet-contracts ‒ [#1547](https://github.com/use-ink/ink/pull/1547) +- Added missed `WhereClosure` for the generics into `storage_item` ‒ [#1536](https://github.com/use-ink/ink/pull/1536) (thanks [@xgreenx](https://github.com/xgreenx)!) ### Removed - -- Implement `ecdsa_to_eth_address()` and remove `eth_compatibility` crate ‒ [#1233](https://github.com/use-ink/ink/pull/1233) -- Remove `wee-alloc` ‒ [#1403](https://github.com/use-ink/ink/pull/1403) -- Remove `ink_env::random` function ‒ [#1442](https://github.com/use-ink/ink/pull/1442) -- Remove `Default` implementation for AccountId ‒ [#1255](https://github.com/use-ink/ink/pull/1255) +- Implement `ecdsa_to_eth_address()` and remove `eth_compatibility` crate ‒ [#1233](https://github.com/use-ink/ink/pull/1233) +- Remove `wee-alloc` ‒ [#1403](https://github.com/use-ink/ink/pull/1403) +- Remove `ink_env::random` function ‒ [#1442](https://github.com/use-ink/ink/pull/1442) +- Remove `Default` implementation for AccountId ‒ [#1255](https://github.com/use-ink/ink/pull/1255) ## Version 4.0.0-rc @@ -888,21 +832,17 @@ breaking or otherwise. ([#1636](https://github.com/use-ink/ink/pull/1636)) ### Added - -- E2E: expose call dry-run method ‒ [#1624](https://github.com/use-ink/ink/pull/1624) -- Make cross-contract callee non-optional ‒ [#1636](https://github.com/use-ink/ink/pull/1636) +- E2E: expose call dry-run method ‒ [#1624](https://github.com/use-ink/ink/pull/1624) +- Make cross-contract callee non-optional ‒ [#1636](https://github.com/use-ink/ink/pull/1636) ### Changed - -- Rename `_checked` codegen call methods with `try_` ‒ [#1621](https://github.com/use-ink/ink/pull/1621) -- Bump Substrate and `subxt` dependencies ‒ [#1549](https://github.com/use-ink/ink/pull/1549) +- Rename `_checked` codegen call methods with `try_` ‒ [#1621](https://github.com/use-ink/ink/pull/1621) +- Bump Substrate and `subxt` dependencies ‒ [#1549](https://github.com/use-ink/ink/pull/1549) ### Removed - -- Remove `Default` implementation for AccountId ‒ [#1255](https://github.com/use-ink/ink/pull/1255) +- Remove `Default` implementation for AccountId ‒ [#1255](https://github.com/use-ink/ink/pull/1255) ## Version 4.0.0-beta.1 - The coolest feature included in this release is the first published version of ink!'s native ["end-to-end" (E2E) testing framework](https://github.com/use-ink/ink/issues/1234). @@ -910,7 +850,6 @@ This enables testing of a contract by deploying and calling it on a Substrate no `pallet-contracts`. See the [`erc20` example](./examples/erc20/lib.rs) for usage. ### Breaking Changes - This release includes a couple of breaking changes. 1. The `CallBuilder::returns()` method does not require an extra `MessageResult` anymore @@ -929,39 +868,35 @@ This release includes a couple of breaking changes. ([#1609](https://github.com/use-ink/ink/pull/1609)) ### Added - -- Add E2E testing framework MVP ‒ [#1395](https://github.com/use-ink/ink/pull/1395) -- Add E2E tests for `Mapping` functions - [#1492](https://github.com/use-ink/ink/pull/1492) +- Add E2E testing framework MVP ‒ [#1395](https://github.com/use-ink/ink/pull/1395) +- Add E2E tests for `Mapping` functions - [#1492](https://github.com/use-ink/ink/pull/1492) ### Fixed - -- Add Determinism enum from pallet-contracts ‒ [#1547](https://github.com/use-ink/ink/pull/1547) -- Added missed `WhereClosure` for the generics into `storage_item` ‒ [#1536](https://github.com/use-ink/ink/pull/1536) (thanks [@xgreenx](https://github.com/xgreenx)) +- Add Determinism enum from pallet-contracts ‒ [#1547](https://github.com/use-ink/ink/pull/1547) +- Added missed `WhereClosure` for the generics into `storage_item` ‒ [#1536](https://github.com/use-ink/ink/pull/1536) (thanks [@xgreenx](https://github.com/xgreenx)) ### Changed - -- Handle `LangError` from instantiate ‒ [#1512](https://github.com/use-ink/ink/pull/1512) -- FFI: no more `__unstable__` wasm import module ‒ [#1522](https://github.com/use-ink/ink/pull/1522) -- Clean up CallBuilder `return()` type ‒ [#1525](https://github.com/use-ink/ink/pull/1525) -- Fix trait message return type metadata ‒ [#1531](https://github.com/use-ink/ink/pull/1531) -- Bump Dylint dependencies ‒ [#1551](https://github.com/use-ink/ink/pull/1551) -- Stabilize `take_storage` ‒ [#1568](https://github.com/use-ink/ink/pull/1568) -- Chain Extension: Evaluation of method return type at compile time ‒ [#1569](https://github.com/use-ink/ink/pull/1569) -- Make more functions be const ‒ [#1574](https://github.com/use-ink/ink/pull/1574) (thanks [@yjhmelody](https://github.com/yjhmelody)) -- Unify fallible and non fallible `instantiate` methods ‒ [#1591](https://github.com/use-ink/ink/pull/1591) -- Make `CallBuilder` and `CreateBuilder` error handling optional ‒ [#1602](https://github.com/use-ink/ink/pull/1602) -- Rename `CallBuilder::fire()` method to `invoke()` ‒ [#1604](https://github.com/use-ink/ink/pull/1604) -- chore: add minimum rust version to the ink crate ‒ [#1609](https://github.com/use-ink/ink/pull/1609) (thanks [@Kurtsley](https://github.com/Kurtsley)) +- Handle `LangError` from instantiate ‒ [#1512](https://github.com/use-ink/ink/pull/1512) +- FFI: no more `__unstable__` wasm import module ‒ [#1522](https://github.com/use-ink/ink/pull/1522) +- Clean up CallBuilder `return()` type ‒ [#1525](https://github.com/use-ink/ink/pull/1525) +- Fix trait message return type metadata ‒ [#1531](https://github.com/use-ink/ink/pull/1531) +- Bump Dylint dependencies ‒ [#1551](https://github.com/use-ink/ink/pull/1551) +- Stabilize `take_storage` ‒ [#1568](https://github.com/use-ink/ink/pull/1568) +- Chain Extension: Evaluation of method return type at compile time ‒ [#1569](https://github.com/use-ink/ink/pull/1569) +- Make more functions be const ‒ [#1574](https://github.com/use-ink/ink/pull/1574) (thanks [@yjhmelody](https://github.com/yjhmelody)) +- Unify fallible and non fallible `instantiate` methods ‒ [#1591](https://github.com/use-ink/ink/pull/1591) +- Make `CallBuilder` and `CreateBuilder` error handling optional ‒ [#1602](https://github.com/use-ink/ink/pull/1602) +- Rename `CallBuilder::fire()` method to `invoke()` ‒ [#1604](https://github.com/use-ink/ink/pull/1604) +- chore: add minimum rust version to the ink crate ‒ [#1609](https://github.com/use-ink/ink/pull/1609) (thanks [@Kurtsley](https://github.com/Kurtsley)) ## Version 4.0.0-beta The focus of the first `beta` release is to establish the stable ABI for the final `4.0.0` release. It means that whilst subsequent `beta` releases may contain breaking contract -_code_ changes, the ABI will remain the same so that any contract compiled and deployed +*code* changes, the ABI will remain the same so that any contract compiled and deployed with `4.0.0-beta` continue to be compatible with all future `4.0.0` versions. ### Compatibility - In order to build contracts which use ink! `v4.0.0-beta` you need to use `cargo-contract` [`v2.0.0-beta`](https://github.com/use-ink/cargo-contract/releases/tag/v2.0.0-beta). @@ -1002,18 +937,15 @@ In order to make this error compatible with other languages we have also added a different error variants which languages may want to emit in the future. Related pull-requests: - -- https://github.com/use-ink/ink/pull/1450 -- https://github.com/use-ink/ink/pull/1504 +- https://github.com/use-ink/ink/pull/1450 +- https://github.com/use-ink/ink/pull/1504 Related discussions: - -- https://github.com/use-ink/ink/issues/1207 -- https://github.com/paritytech/substrate/issues/11018 -- https://github.com/use-ink/ink/issues/1002 +- https://github.com/use-ink/ink/issues/1207 +- https://github.com/paritytech/substrate/issues/11018 +- https://github.com/use-ink/ink/issues/1002 ## Random function removed - We had to remove [`ink_env::random`](https://docs.rs/ink_env/3.3.1/ink_env/fn.random.html) with [#1442](https://github.com/use-ink/ink/pull/1442). This function allowed contract developers getting random entropy. @@ -1030,73 +962,61 @@ best hope right now is that it could come back with [Sassafras](https://wiki.pol protocol for future versions of Polkadot. ### Added - -- Allow using `Result` as a return type in constructors ‒ [#1446](https://github.com/use-ink/ink/pull/1446) -- Add `Mapping::take()` function allowing to get a value removing it from storage ‒ [#1461](https://github.com/use-ink/ink/pull/1461) +- Allow using `Result` as a return type in constructors ‒ [#1446](https://github.com/use-ink/ink/pull/1446) +- Add `Mapping::take()` function allowing to get a value removing it from storage ‒ [#1461](https://github.com/use-ink/ink/pull/1461) ### Changed - -- Add support for language level errors (`LangError`) ‒ [#1450](https://github.com/use-ink/ink/pull/1450) -- Return `LangError`s from constructors ‒ [#1504](https://github.com/use-ink/ink/pull/1504) -- Update `scale-info` requirement to `2.3` ‒ [#1467](https://github.com/use-ink/ink/pull/1467) -- Merge `Mapping::insert(key, val)` and `Mapping::insert_return_size(key, val)` into one method - [#1463](https://github.com/use-ink/ink/pull/1463) +- Add support for language level errors (`LangError`) ‒ [#1450](https://github.com/use-ink/ink/pull/1450) +- Return `LangError`s from constructors ‒ [#1504](https://github.com/use-ink/ink/pull/1504) +- Update `scale-info` requirement to `2.3` ‒ [#1467](https://github.com/use-ink/ink/pull/1467) +- Merge `Mapping::insert(key, val)` and `Mapping::insert_return_size(key, val)` into one method - [#1463](https://github.com/use-ink/ink/pull/1463) ### Removed - -- Remove `ink_env::random` function ‒ [#1442](https://github.com/use-ink/ink/pull/1442) +- Remove `ink_env::random` function ‒ [#1442](https://github.com/use-ink/ink/pull/1442) ## Version 4.0.0-alpha.3 ### Breaking Changes #### New `ink` crate - The `ink_lang` crate has been replaced in [#1223](https://github.com/use-ink/ink/pull/1223) by a new top level `ink` crate. All existing sub-crates are reexported and should be used via the new `ink` crate, so e.g. `ink::env` instead of `ink_env`. Contract authors should now import the top level `ink` crate instead of the individual crates. ##### Migration - -- In `Cargo.toml` Replace all individual `ink_*` crate dependencies with the `ink` crate. -- In the contract source: - - Remove the commonly used `use ink_lang as ink` idiom. - - Replace all usages of individual crates with reexports, e.g. `ink_env` ➜ `ink::env`. +- In `Cargo.toml` Replace all individual `ink_*` crate dependencies with the `ink` crate. +- In the contract source: + - Remove the commonly used `use ink_lang as ink` idiom. + - Replace all usages of individual crates with reexports, e.g. `ink_env` ➜ `ink::env`. #### Storage Rework - [#1331](https://github.com/use-ink/ink/pull/1331) changes the way `ink!` works with contract storage. Storage keys are generated at compile-time, and user facing abstractions which determine how contract data is laid out in storage have changed. ##### Migration - -- Initialize `Mapping` fields with `Mapping::default()` instead of `ink_lang::utils::initialize_contract` in - constructors. See [`erc20`](./examples/erc20/lib.rs) and other examples which use a `Mapping`. -- Remove `SpreadAllocate`, `SpreadLayout` and `PackedLayout` implementations. +- Initialize `Mapping` fields with `Mapping::default()` instead of `ink_lang::utils::initialize_contract` in +constructors. See [`erc20`](./examples/erc20/lib.rs) and other examples which use a `Mapping`. +- Remove `SpreadAllocate`, `SpreadLayout` and `PackedLayout` implementations. #### Removal of `wee-alloc` support - ink! uses a bump allocator by default, additionally we supported another allocator (`wee-alloc`) through a feature flag. `wee-alloc` is no longer maintained and we removed support for it. ### Changed - -- Introduce `ink` entrance crate ‒ [#1223](https://github.com/use-ink/ink/pull/1223) -- Use `XXH32` instead of `sha256` for calculating storage keys ‒ [#1393](https://github.com/use-ink/ink/pull/1393) -- Storage Refactoring ‒ [#1331](https://github.com/use-ink/ink/pull/1331) +- Introduce `ink` entrance crate ‒ [#1223](https://github.com/use-ink/ink/pull/1223) +- Use `XXH32` instead of `sha256` for calculating storage keys ‒ [#1393](https://github.com/use-ink/ink/pull/1393) +- Storage Refactoring ‒ [#1331](https://github.com/use-ink/ink/pull/1331) ### Fixed - -- Trim single whitespace prefix in the metadata `docs` field ‒ [#1385](https://github.com/use-ink/ink/pull/1385) -- Allow pay_with_call to take multiple arguments ‒ [#1401](https://github.com/use-ink/ink/pull/1401) +- Trim single whitespace prefix in the metadata `docs` field ‒ [#1385](https://github.com/use-ink/ink/pull/1385) +- Allow pay_with_call to take multiple arguments ‒ [#1401](https://github.com/use-ink/ink/pull/1401) ### Added - -- Add `ink_env::pay_with_call!` helper macro for off-chain emulation of sending payments with contract message calls ‒ [#1379](https://github.com/use-ink/ink/pull/1379) +- Add `ink_env::pay_with_call!` helper macro for off-chain emulation of sending payments with contract message calls ‒ [#1379](https://github.com/use-ink/ink/pull/1379) ### Removed - -- Remove `wee-alloc` ‒ [#1403](https://github.com/use-ink/ink/pull/1403) +- Remove `wee-alloc` ‒ [#1403](https://github.com/use-ink/ink/pull/1403) ## Version 4.0.0-alpha.2 @@ -1108,7 +1028,6 @@ so small errors like this are learning experiences for us. ## Version 4.0.0-alpha.1 ### Compatibility - In order to build contracts which use ink! `v4.0.0-alpha.1` you need to use `cargo-contract` [`v2.0.0-alpha.1`](https://github.com/use-ink/cargo-contract/releases/tag/v2.0.0-alpha.1). @@ -1123,35 +1042,31 @@ later than [6b85535](https://github.com/paritytech/substrate/tree/6b8553511112af The compatibility issues will be with `ChainExtension`'s and the functions mentioned above. ### Breaking Changes - This release contains a few breaking changes. These are indicated with the :x: emoji. Most of these were initially introduced in `v3.1.0` and `v3.2.0` releases but compatibility was restored in `v3.3.0`. -- As part of [#1224](https://github.com/use-ink/ink/pull/1224) the return type of `ink_env::set_contract_storage()` was changed to - return an `Option` instead of `()`. -- As part of [#1233](https://github.com/use-ink/ink/pull/1233) the `eth_compatibility` crate was removed. The - `ecdsa_to_eth_address()` function from it can now be found in the `ink_env` crate. -- As part of [#1267](https://github.com/use-ink/ink/pull/1267) an argument to `ink_lang::codegen::execute_constructor()` (which is - used internally by the ink! macros) was removed. -- As part of [#1313](https://github.com/use-ink/ink/pull/1313) the ink! ABI was changed so that the version was specified using a - dedicated `version` key instead of an implicit key which wrapped the entire ABI. +- As part of [#1224](https://github.com/use-ink/ink/pull/1224) the return type of `ink_env::set_contract_storage()` was changed to +return an `Option` instead of `()`. +- As part of [#1233](https://github.com/use-ink/ink/pull/1233) the `eth_compatibility` crate was removed. The + `ecdsa_to_eth_address()` function from it can now be found in the `ink_env` crate. +- As part of [#1267](https://github.com/use-ink/ink/pull/1267) an argument to `ink_lang::codegen::execute_constructor()` (which is + used internally by the ink! macros) was removed. +- As part of [#1313](https://github.com/use-ink/ink/pull/1313) the ink! ABI was changed so that the version was specified using a + dedicated `version` key instead of an implicit key which wrapped the entire ABI. ### Added - -- :x: Add `Mapping::contains(key)` and `Mapping::insert_return_size(key, val)` ‒ [#1224](https://github.com/use-ink/ink/pull/1224) -- Add [`payment-channel`](https://github.com/use-ink/ink-examples/tree/main/payment-channel) example ‒ [#1248](https://github.com/use-ink/ink/pull/1248) -- :x: Add `version` field to ink! metadata ‒ [#1313](https://github.com/use-ink/ink/pull/1313) -- The `rand-extension` example has been adapted to an updated version of the `ChainExtension` API ‒ [#1356](https://github.com/use-ink/ink/pull/1356) +- :x: Add `Mapping::contains(key)` and `Mapping::insert_return_size(key, val)` ‒ [#1224](https://github.com/use-ink/ink/pull/1224) +- Add [`payment-channel`](https://github.com/use-ink/ink-examples/tree/main/payment-channel) example ‒ [#1248](https://github.com/use-ink/ink/pull/1248) +- :x: Add `version` field to ink! metadata ‒ [#1313](https://github.com/use-ink/ink/pull/1313) +- The `rand-extension` example has been adapted to an updated version of the `ChainExtension` API ‒ [#1356](https://github.com/use-ink/ink/pull/1356) ### Changed - -- :x: Contract size optimization in case contract doesn't accept payment ‒ [#1267](https://github.com/use-ink/ink/pull/1267) (thanks [@xgreenx](https://github.com/xgreenx)). -- Move ink! linter into `ink` repository ‒ [#1361](https://github.com/use-ink/ink/pull/1267) +- :x: Contract size optimization in case contract doesn't accept payment ‒ [#1267](https://github.com/use-ink/ink/pull/1267) (thanks [@xgreenx](https://github.com/xgreenx)). +- Move ink! linter into `ink` repository ‒ [#1361](https://github.com/use-ink/ink/pull/1267) ### Removed - -- :x: Implement `ecdsa_to_eth_address()` and remove `eth_compatibility` crate ‒ [#1233](https://github.com/use-ink/ink/pull/1233) +- :x: Implement `ecdsa_to_eth_address()` and remove `eth_compatibility` crate ‒ [#1233](https://github.com/use-ink/ink/pull/1233) ## Version 3.3.1 @@ -1170,41 +1085,36 @@ compatibility with the [`v0.13.0`](https://github.com/paritytech/substrate-contr release of the `substrate-contracts-node`. ### Compatibility - -This version will work fine with _substrate-contracts-node_ versions from +This version will work fine with *substrate-contracts-node* versions from [0.13.0](https://github.com/paritytech/substrate-contracts-node/releases/tag/v0.13.0) up to [0.16.0](https://github.com/paritytech/substrate-contracts-node/releases/tag/v0.16.0). ### Changed - -_Context: user-reported issues on our SE unveiled backward incompatibility introduced in 3.1.0 release._ - +*Context: user-reported issues on our SE unveiled backward incompatibility introduced in 3.1.0 release.* 1. [CodeRejected when using ink! v3.1.0](https://substrate.stackexchange.com/questions/2721/cargo-contract-3-0-1) 1. [Incompatibility between ink! v3.0.1 and v3.2.0 ](https://substrate.stackexchange.com/questions/2870/cargo-contract-throws-error-about-supplied-arguments-in-inkconstructor-f) The following has been done to restore backward compatibility: - -- Reverted backward-incompatible piece of [#1224](https://github.com/use-ink/ink/pull/1224). - - 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/use-ink/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/use-ink/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. +- Reverted backward-incompatible piece of [#1224](https://github.com/use-ink/ink/pull/1224). + - 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/use-ink/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/use-ink/ink/pull/1233). + - The removal of the `eth_compatibility` crate should have been done in a `MAJOR` + release. + +All these breaking changes are subjects to the upcoming MAJOR *ink!* release 4.0.0. ## Version 3.2.0 ### Compatibility - We recommend using a version of the [`pallet-contracts`](https://github.com/paritytech/substrate/tree/master/frame/contracts) later than [c0ee2ad](https://github.com/paritytech/substrate/tree/c0ee2adaa54b22ee0df5d1592cd0430961afd95c) (May 23, 2022) in your node. @@ -1213,21 +1123,17 @@ 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/use-ink/ink/pull/1267) (thanks [@xgreenx](https://github.com/xgreenx)). +- Contract size optimization in case contract doesn't accept payment ‒ [#1267](https://github.com/use-ink/ink/pull/1267) (thanks [@xgreenx](https://github.com/xgreenx)). ### Changed - -- Two functions have been stabilized: [`ink_env::ecdsa_recover`](https://use-ink.github.io/ink/ink_env/fn.ecdsa_recover.html) and [`ink_env::ecdsa_to_eth_address`](https://use-ink.github.io/ink/ink_env/fn.ecdsa_to_eth_address.html) ‒ [#1270](https://github.com/use-ink/ink/pull/1270) [#1273](https://github.com/use-ink/ink/pull/1273) +- Two functions have been stabilized: [`ink_env::ecdsa_recover`](https://use-ink.github.io/ink/ink_env/fn.ecdsa_recover.html) and [`ink_env::ecdsa_to_eth_address`](https://use-ink.github.io/ink/ink_env/fn.ecdsa_to_eth_address.html) ‒ [#1270](https://github.com/use-ink/ink/pull/1270) [#1273](https://github.com/use-ink/ink/pull/1273) ### Fixed - -- Fixed bug with recent Rust and `cargo test` ‒ [#1272](https://github.com/use-ink/ink/pull/1272) (thanks [@xgreenx](https://github.com/xgreenx)). +- Fixed bug with recent Rust and `cargo test` ‒ [#1272](https://github.com/use-ink/ink/pull/1272) (thanks [@xgreenx](https://github.com/xgreenx)). ## Version 3.1.0 ### Compatibility - We recommend using a version of the [`pallet-contracts`](https://github.com/paritytech/substrate/tree/master/frame/contracts) later than [7d233c2](https://github.com/paritytech/substrate/tree/7d233c2446b5a60662400a0a4bcfb78bb3b79ff7) (May 13, 2022) in your node. @@ -1237,34 +1143,31 @@ This is the case in the latest release of the [`substrate-contracts-node`](https the latest Polkadot release [v0.9.22](https://github.com/paritytech/polkadot/releases/tag/v0.9.22). ### Breaking Changes - There are two breaking changes in this release: -- As part of [#1235](https://github.com/use-ink/ink/pull/1235) the message selectors of - your contract may change. A change of selectors would affect your client, frontend, Dapp, etc.. -- As part of [#1233](https://github.com/use-ink/ink/pull/1235) we removed the `eth_compatibility` - crate.

- Its recovery functionality has been moved to `ink_env` now: [`ink_env::ecdsa_to_eth_address`](https://use-ink.github.io/ink/ink_env/fn.ecdsa_to_eth_address.html). - The reason for this change is that we moved the gas-expensive crypto operations into `pallet-contracts`.

- The crates `to_default_account_id` function has been removed; the reason for this change is that ink! - doesn't have knowledge about the specific Substrate types on the underlying chain. - If you want to retain the function in your contract and are just using standard Substrate types - you should add the prior functionality to your contract ‒ it was a simple - `::hash(&ecdsa_pubkey[u8; 33])`. +* As part of [#1235](https://github.com/use-ink/ink/pull/1235) the message selectors of + your contract may change. A change of selectors would affect your client, frontend, Dapp, etc.. +* As part of [#1233](https://github.com/use-ink/ink/pull/1235) we removed the `eth_compatibility` + crate.

+ Its recovery functionality has been moved to `ink_env` now: [`ink_env::ecdsa_to_eth_address`](https://use-ink.github.io/ink/ink_env/fn.ecdsa_to_eth_address.html). + The reason for this change is that we moved the gas-expensive crypto operations into `pallet-contracts`.

+ The crates `to_default_account_id` function has been removed; the reason for this change is that ink! + doesn't have knowledge about the specific Substrate types on the underlying chain. + If you want to retain the function in your contract and are just using standard Substrate types + you should add the prior functionality to your contract ‒ it was a simple + `::hash(&ecdsa_pubkey[u8; 33])`. ### New API functions - We added two new `Mapping` API functions: [`Mapping::contains`](https://use-ink.github.io/ink/ink_storage/struct.Mapping.html#method.contains) and [`Mapping::insert_return_size`](https://use-ink.github.io/ink/ink_storage/struct.Mapping.html#method.insert_return_size) ‒ [#1224](https://github.com/use-ink/ink/pull/1224). These are more gas-efficient than whatever you were using previously. Additionally there are a couple new `ink_env` functions now: - -- [`ink_env::set_code_hash`](https://use-ink.github.io/ink/ink_env/fn.set_code_hash.html) -- [`ink_env::own_code_hash`](https://use-ink.github.io/ink/ink_env/fn.own_code_hash.html) -- [`ink_env::code_hash`](https://use-ink.github.io/ink/ink_env/fn.code_hash.html) -- [`ink_env::ecdsa_to_eth_address`](https://use-ink.github.io/ink/ink_env/fn.ecdsa_to_eth_address.html) +* [`ink_env::set_code_hash`](https://use-ink.github.io/ink/ink_env/fn.set_code_hash.html) +* [`ink_env::own_code_hash`](https://use-ink.github.io/ink/ink_env/fn.own_code_hash.html) +* [`ink_env::code_hash`](https://use-ink.github.io/ink/ink_env/fn.code_hash.html) +* [`ink_env::ecdsa_to_eth_address`](https://use-ink.github.io/ink/ink_env/fn.ecdsa_to_eth_address.html) ### New Upgradeable Contract Example @@ -1274,30 +1177,25 @@ It illustrates how the newly added [`ink_env::set_code_hash`](https://use-ink.gi can be used to implement an upgradeable contract that replaces its own code. ### Added - -- Implement `seal_code_hash` and `seal_own_code_hash` ‒ [#1205](https://github.com/use-ink/ink/pull/1205) -- Add `set_code_hash` function and example ‒ [#1203](https://github.com/use-ink/ink/pull/1203) -- Implement [`ink_env::ecdsa_to_eth_address`](https://use-ink.github.io/ink/ink_env/fn.ecdsa_to_eth_address.html) ‒ [#1233](https://github.com/use-ink/ink/pull/1233) -- Add [`Mapping::contains(key)`](https://use-ink.github.io/ink/ink_storage/struct.Mapping.html#method.contains) and [`Mapping::insert_return_size(key, val)`](https://use-ink.github.io/ink/ink_storage/struct.Mapping.html#method.insert_return_size) ‒ [#1224](https://github.com/use-ink/ink/pull/1224) +- Implement `seal_code_hash` and `seal_own_code_hash` ‒ [#1205](https://github.com/use-ink/ink/pull/1205) +- Add `set_code_hash` function and example ‒ [#1203](https://github.com/use-ink/ink/pull/1203) +- Implement [`ink_env::ecdsa_to_eth_address`](https://use-ink.github.io/ink/ink_env/fn.ecdsa_to_eth_address.html) ‒ [#1233](https://github.com/use-ink/ink/pull/1233) +- Add [`Mapping::contains(key)`](https://use-ink.github.io/ink/ink_storage/struct.Mapping.html#method.contains) and [`Mapping::insert_return_size(key, val)`](https://use-ink.github.io/ink/ink_storage/struct.Mapping.html#method.insert_return_size) ‒ [#1224](https://github.com/use-ink/ink/pull/1224) ### Fixed - -- Fix ordering of message ids if the trait is implemented before the inherent section ‒ [#1235](https://github.com/use-ink/ink/pull/1235) +- Fix ordering of message ids if the trait is implemented before the inherent section ‒ [#1235](https://github.com/use-ink/ink/pull/1235) ### Removed - -- Removed `eth_compatibility` crate and moved its functionality partly into `ink_env` ‒ [#1233](https://github.com/use-ink/ink/pull/1233) +- Removed `eth_compatibility` crate and moved its functionality partly into `ink_env` ‒ [#1233](https://github.com/use-ink/ink/pull/1233) ## Version 3.0.1 ### Changed - -- Improve upgradeable examples folder structure, explain differences ‒ [#1188](https://github.com/use-ink/ink/pull/1188) +- Improve upgradeable examples folder structure, explain differences ‒ [#1188](https://github.com/use-ink/ink/pull/1188) ### Fixed - -- Update codegen after SCALE v3.1.2 release ‒ [#1189](https://github.com/use-ink/ink/pull/1189) -- Stop using `CallData` in `multisig` example doc test ‒ [#1202](https://github.com/use-ink/ink/pull/1202) +- Update codegen after SCALE v3.1.2 release ‒ [#1189](https://github.com/use-ink/ink/pull/1189) +- Stop using `CallData` in `multisig` example doc test ‒ [#1202](https://github.com/use-ink/ink/pull/1202) ## Version 3.0.0 @@ -1306,10 +1204,9 @@ This is the stable release for ink! 3.0. It took us a while to get here and going forward we want to do smaller releases more often. -_Please note that ink! has not been audited._ +*Please note that ink! has not been audited.* ### Compatibility - We recommend using a version of the `contracts` pallet later than [cc282f84ba53ed2a08374d2a655dc8f08cbc5e86](https://github.com/paritytech/substrate/tree/cc282f84ba53ed2a08374d2a655dc8f08cbc5e86) (March 15, 2022) in your node. @@ -1318,9 +1215,7 @@ This is the case in the latest release of the `substrate-contracts-node`: [v0.10.0](https://github.com/paritytech/substrate-contracts-node/releases/tag/v0.10.0). ### Breaking Changes - #### We replaced the default off-chain testing environment - The off-chain testing environment can be used to write unit tests for your smart contract with a simulated chain. We've now replaced the existing off-chain environment with a new @@ -1336,19 +1231,17 @@ can find more "template use-cases" there (e.g. for [chain extension testing](https://github.com/use-ink/ink-examples/tree/main/rand-extension)) #### We removed the dynamic storage allocator - More details on the reasoning behind this can be found in [#1148](https://github.com/use-ink/ink/pull/1148). #### `CallBuilder` API changed to support `delegate` calls - The `CallBuilder` API changed to now support two types of calls: -- `Call`: a cross-contract call.
- This was the default until this new API change. -- `DelegateCall`: a delegated call.
- This enables writing upgradeable contracts using - the `delegate` pattern. An example has been added to demonstrate this: - [`delegate-calls`](https://github.com/use-ink/ink-examples/tree/main/upgradeable-contracts). +* `Call`: a cross-contract call.
+ This was the default until this new API change. +* `DelegateCall`: a delegated call.
+ This enables writing upgradeable contracts using + the `delegate` pattern. An example has been added to demonstrate this: + [`delegate-calls`](https://github.com/use-ink/ink-examples/tree/main/upgradeable-contracts). This is a breaking change, users must now specify the `call_type` to the builder manually. @@ -1362,32 +1255,28 @@ The API for `eval_contract` and `invoke_contract` changed. You can read more about the change in [#1165](https://github.com/use-ink/ink/pull/1165). ### Added - -- Added `keep_attr` to `#[ink::contract]` and `#[ink::trait_definition]` ‒ [#1145](https://github.com/use-ink/ink/pull/1145) (thanks [@xgreenx](https://github.com/xgreenx)).. -- Implemented the `seal_is_contract` and `seal_caller_is_origin` API ‒ [#1129](https://github.com/use-ink/ink/pull/1129) [#1166](https://github.com/use-ink/ink/pull/1166). -- Add tests in experimental off-chain env for `trait-erc20` ‒ [#1158](https://github.com/use-ink/ink/pull/1158). -- Add tests in experimental off-chain env for `erc721` ‒ [#1157](https://github.com/use-ink/ink/pull/1157). -- Add tests in experimental off-chain env for `multisig` ‒ [#1159](https://github.com/use-ink/ink/pull/1159). -- Add tests in experimental off-chain env for `dns` ‒ [#1156](https://github.com/use-ink/ink/pull/1156). -- Implemented chain extension testing in experimental off-chain env ‒ [#1152](https://github.com/use-ink/ink/pull/1152). +- Added `keep_attr` to `#[ink::contract]` and `#[ink::trait_definition]` ‒ [#1145](https://github.com/use-ink/ink/pull/1145) (thanks [@xgreenx](https://github.com/xgreenx)).. +- Implemented the `seal_is_contract` and `seal_caller_is_origin` API ‒ [#1129](https://github.com/use-ink/ink/pull/1129) [#1166](https://github.com/use-ink/ink/pull/1166). +- Add tests in experimental off-chain env for `trait-erc20` ‒ [#1158](https://github.com/use-ink/ink/pull/1158). +- Add tests in experimental off-chain env for `erc721` ‒ [#1157](https://github.com/use-ink/ink/pull/1157). +- Add tests in experimental off-chain env for `multisig` ‒ [#1159](https://github.com/use-ink/ink/pull/1159). +- Add tests in experimental off-chain env for `dns` ‒ [#1156](https://github.com/use-ink/ink/pull/1156). +- Implemented chain extension testing in experimental off-chain env ‒ [#1152](https://github.com/use-ink/ink/pull/1152). ### Changed - -- Replaced default off-chain testing engine with experimental one ‒ [#1144](https://github.com/use-ink/ink/pull/1144). -- Changed `CallBuilder` API to now support delegate calls ‒ [#1133](https://github.com/use-ink/ink/pull/1133) (thanks [@VargSupercolony](https://github.com/VargSupercolony) and [@xgreenx](https://github.com/xgreenx)). -- Unify `ink_env::{eval_contract, invoke_contract}` ‒ [#1165](https://github.com/use-ink/ink/pull/1165). +- Replaced default off-chain testing engine with experimental one ‒ [#1144](https://github.com/use-ink/ink/pull/1144). +- Changed `CallBuilder` API to now support delegate calls ‒ [#1133](https://github.com/use-ink/ink/pull/1133) (thanks [@VargSupercolony](https://github.com/VargSupercolony) and [@xgreenx](https://github.com/xgreenx)). +- Unify `ink_env::{eval_contract, invoke_contract}` ‒ [#1165](https://github.com/use-ink/ink/pull/1165). ### Removed - -- Removed the dynamic storage allocator ‒ [#1148](https://github.com/use-ink/ink/pull/1148). -- Removed `compile_as_dependency` config option ‒ [#1168](https://github.com/use-ink/ink/pull/1168). +- Removed the dynamic storage allocator ‒ [#1148](https://github.com/use-ink/ink/pull/1148). +- Removed `compile_as_dependency` config option ‒ [#1168](https://github.com/use-ink/ink/pull/1168). ## Version 3.0-rc9 This is the 9th release candidate for ink! 3.0. ### Breaking Changes - #### We removed all data structures other than `Mapping` from the public ink! API This is a drastic breaking change; it was no easy decision for us. @@ -1412,32 +1301,27 @@ In this release candidate we upgraded `scale-info` and `parity-scale-codec`. You version in your contract's `Cargo.toml` as well; `cargo-contract` will throw an error otherwise. The `Cargo.toml` should contain - ``` scale-info = { version = "2", default-features = false, features = ["derive"], optional = true } scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive", "full"] } ``` ### Added - -- Export `ink_lang::utils::initialize_contract(…)` - [#1077](https://github.com/use-ink/ink/pull/1077). -- Add `get_owner()` function to `dns` example contract - [#1118](https://github.com/use-ink/ink/pull/1118) (thanks [@agryaznov](https://github.com/agryaznov)). -- Improved usage documentation of `ink_storage::Mapping` - [#1138](https://github.com/use-ink/ink/pull/1138). +- Export `ink_lang::utils::initialize_contract(…)` - [#1077](https://github.com/use-ink/ink/pull/1077). +- Add `get_owner()` function to `dns` example contract - [#1118](https://github.com/use-ink/ink/pull/1118) (thanks [@agryaznov](https://github.com/agryaznov)). +- Improved usage documentation of `ink_storage::Mapping` - [#1138](https://github.com/use-ink/ink/pull/1138). ### Changed - -- Updated to `parity-scale-codec = "3"` and `scale-info = "2"` - [#1132](https://github.com/use-ink/ink/pull/1132). +- Updated to `parity-scale-codec = "3"` and `scale-info = "2"` - [#1132](https://github.com/use-ink/ink/pull/1132). ### Removed - -- Remove `collection` and `lazy` modules from public ink! API - [#1111](https://github.com/use-ink/ink/pull/1111). -- Remove `Memory` from public ink! API - [#1137](https://github.com/use-ink/ink/pull/1137). +- Remove `collection` and `lazy` modules from public ink! API - [#1111](https://github.com/use-ink/ink/pull/1111). +- Remove `Memory` from public ink! API - [#1137](https://github.com/use-ink/ink/pull/1137). ### Fixed - -- Fix bug with referencing two external trait definitions - [#1141](https://github.com/use-ink/ink/pull/1141). -- Explicitly specify trait in dispatching - [#1131](https://github.com/use-ink/ink/pull/1131) (thanks [@xgreenx](https://github.com/xgreenx)). -- Make `rust-analyzer` expand ink! macros without warning - [#1107](https://github.com/use-ink/ink/pull/1107). +- Fix bug with referencing two external trait definitions - [#1141](https://github.com/use-ink/ink/pull/1141). +- Explicitly specify trait in dispatching - [#1131](https://github.com/use-ink/ink/pull/1131) (thanks [@xgreenx](https://github.com/xgreenx)). +- Make `rust-analyzer` expand ink! macros without warning - [#1107](https://github.com/use-ink/ink/pull/1107). ## Version 3.0-rc8 @@ -1458,23 +1342,18 @@ the user interface you are using. For `polkadot-js/api` and `polkadot-js/apps` t changes are supported since Jan 19, 2022. ### Metadata Changes - There are two metadata changes in this release candidate: #### For messages and constructors: `name: Array` ➔ `label: String` The messages and constructors exposed by a contract were previously denoted with - ```json "name": ["foo", "bar"] ``` - Now they are instead denoted with - ```json "label": "foo" ``` - For public contract methods that are implemented from a trait, the trait name is prefixed to the method name with `::` as the separator. So e.g. `trait_name::get_owner`. @@ -1482,7 +1361,6 @@ The ink! PR which implemented this is [#923](https://github.com/use-ink/ink/pull for the `polkadot-js/api` it was [polkadot-js/api#4255](https://github.com/polkadot-js/api/pull/4255). #### Constructors got a new field: `payable: bool` - Constructors now have to be specified `payable` if it's intended for them to receive value (i.e. tokens). This is a breaking change, beforehand they were by default payable, now they are by default non-payable. @@ -1491,19 +1369,17 @@ The ink! PR which implemented this is [#1065](https://github.com/use-ink/ink/pul metadata to V3 is [#1100](https://github.com/use-ink/ink/pull/1100), and for the `polkadot-js/api` it was [polkadot-js/api#4432](https://github.com/polkadot-js/api/pull/4432). ### Changed - -- Update metadata to support payable constructors - [#1100](https://github.com/use-ink/ink/pull/1100). -- Make constructors non-payable by default, require specifying `payable` explicitly - [#1065](https://github.com/use-ink/ink/pull/1065). -- Renamed the error code `EcdsaRecoverFailed` to `EcdsaRecoveryFailed` ‒ [#1064](https://github.com/use-ink/ink/pull/1064). -- Renamed the `ink_env` function `transferred_balance()` to `transferred_value()` ‒ [#1063](https://github.com/use-ink/ink/pull/1063). -- Removed the error codes `BelowSubsistenceThreshold` and `NewContractNotFunded` ‒ [#1062](https://github.com/use-ink/ink/pull/1062). -- Updated ink! to use the most recent `contracts` pallet API ‒ [#1053](https://github.com/use-ink/ink/pull/1053). -- Explicitly link against `rlibc` to get non-buggy version of `memcpy` ‒ [#1049](https://github.com/use-ink/ink/pull/1049). -- Changed the metadata field `name` to `label` for messages and constructors ‒ [#923](https://github.com/use-ink/ink/pull/923) (thanks [@xgreenx](https://github.com/xgreenx)). +- Update metadata to support payable constructors - [#1100](https://github.com/use-ink/ink/pull/1100). +- Make constructors non-payable by default, require specifying `payable` explicitly - [#1065](https://github.com/use-ink/ink/pull/1065). +- Renamed the error code `EcdsaRecoverFailed` to `EcdsaRecoveryFailed` ‒ [#1064](https://github.com/use-ink/ink/pull/1064). +- Renamed the `ink_env` function `transferred_balance()` to `transferred_value()` ‒ [#1063](https://github.com/use-ink/ink/pull/1063). +- Removed the error codes `BelowSubsistenceThreshold` and `NewContractNotFunded` ‒ [#1062](https://github.com/use-ink/ink/pull/1062). +- Updated ink! to use the most recent `contracts` pallet API ‒ [#1053](https://github.com/use-ink/ink/pull/1053). +- Explicitly link against `rlibc` to get non-buggy version of `memcpy` ‒ [#1049](https://github.com/use-ink/ink/pull/1049). +- Changed the metadata field `name` to `label` for messages and constructors ‒ [#923](https://github.com/use-ink/ink/pull/923) (thanks [@xgreenx](https://github.com/xgreenx)). ### Added - -- Added a `remove` method to the `Mapping` data structure ‒ [#1023](https://github.com/use-ink/ink/pull/1023). +- Added a `remove` method to the `Mapping` data structure ‒ [#1023](https://github.com/use-ink/ink/pull/1023). ## Version 3.0-rc7 @@ -1531,62 +1407,58 @@ Specifically you need to upgrade to at least the pallet version (or newer than Nov 24). ### Removed - -- Removed the state rent API ‒ [#1036](https://github.com/use-ink/ink/pull/1036). +- Removed the state rent API ‒ [#1036](https://github.com/use-ink/ink/pull/1036). ### Added - -- Added support for wildcard selectors ‒ [#1020](https://github.com/use-ink/ink/pull/1020). - - This enables writing upgradeable smart contracts using the proxy/forward pattern. - - Annotating a wildcard selector in traits is not supported. -- The ink! codegen now heavily relies on static type information based on traits defined in `ink_lang` ‒ [#665](https://github.com/use-ink/ink/pull/665). - - Some of those traits and their carried information can be used for static reflection of ink! - smart contracts. Those types and traits reside in the new `ink_lang::reflect` module and is - publicly usable by ink! smart contract authors. +- Added support for wildcard selectors ‒ [#1020](https://github.com/use-ink/ink/pull/1020). + - This enables writing upgradeable smart contracts using the proxy/forward pattern. + - Annotating a wildcard selector in traits is not supported. +- The ink! codegen now heavily relies on static type information based on traits defined in `ink_lang` ‒ [#665](https://github.com/use-ink/ink/pull/665). + - Some of those traits and their carried information can be used for static reflection of ink! + smart contracts. Those types and traits reside in the new `ink_lang::reflect` module and is + publicly usable by ink! smart contract authors. ### Changed - -- Upgraded to the `seal_call` v1 API ‒ [#960](https://github.com/use-ink/ink/pull/960). - - This API now enables control over the behavior of cross-contract calls, e.g. to forward/clone input, - enable tail calls and control reentrancy. - The crate documentation contains more details on the [`CallFlags`](https://use-ink.github.io/ink/ink_env/struct.CallFlags.html). - - **Note:** The default behavior of cross-contract calls now disallows reentering the calling contract. -- ink! contract definitions via `#[ink::contract]` ‒ [#665](https://github.com/use-ink/ink/pull/665).
- For ink! smart contracts we now generate two contract types. Given `MyContract`: - - `MyContract` will still be the storage struct. - However, it can now additionally be used as static dependency in other smart contracts. - Static dependencies can be envisioned as being directly embedded into a smart contract. - - `MyContractRef` is pretty much the same of what we had gotten with the old `ink-as-dependency`. - It is a typed thin-wrapper around an `AccountId` that is mirroring the ink! smart contract's API - and implemented traits. -- ink! trait definitions via `#[ink::trait_definition]` ‒ [#665](https://github.com/use-ink/ink/pull/665). - - ink! trait definitions no longer can define trait constructors. - - ink! trait implementations now inherit `selector` and `payable` properties for trait messages. - - Now explicitly setting `selector` or `payable` property for an implemented ink! trait method - will only act as a guard that the set property is in fact the same as defined by the ink! - trait definition. -- Improved some ink! specific compile errors ‒ [#665](https://github.com/use-ink/ink/pull/665). - - For example, when using ink! messages and constructors which have inputs (or - outputs) that cannot be encoded (or decoded) using the SCALE codec. -- Simplified selector computation for ink! trait methods ‒ [#665](https://github.com/use-ink/ink/pull/665). - - Now selectors are encoded as `blake2b({namespace}::{trait_identifier}::{message_identifier})[0..4]`. - If no `namespace` is set for the ink! trait definition then the formula is - `blake2b({trait_identifier}::{message_identifier})[0..4]`. - Where `trait_identifier` and `message_identifier` both refer to the identifiers of the ink! trait - definition and ink! trait message respectively. -- We switched to Rust edition 2021 ‒ [#977](https://github.com/use-ink/ink/pull/977). -- Update chain extension example to show argument passing ‒ [#1029](https://github.com/use-ink/ink/pull/1029). +- Upgraded to the `seal_call` v1 API ‒ [#960](https://github.com/use-ink/ink/pull/960). + - This API now enables control over the behavior of cross-contract calls, e.g. to forward/clone input, + enable tail calls and control reentrancy. + The crate documentation contains more details on the [`CallFlags`](https://use-ink.github.io/ink/ink_env/struct.CallFlags.html). + - **Note:** The default behavior of cross-contract calls now disallows reentering the calling contract. +- ink! contract definitions via `#[ink::contract]` ‒ [#665](https://github.com/use-ink/ink/pull/665).
+ For ink! smart contracts we now generate two contract types. Given `MyContract`: + - `MyContract` will still be the storage struct. + However, it can now additionally be used as static dependency in other smart contracts. + Static dependencies can be envisioned as being directly embedded into a smart contract. + - `MyContractRef` is pretty much the same of what we had gotten with the old `ink-as-dependency`. + It is a typed thin-wrapper around an `AccountId` that is mirroring the ink! smart contract's API + and implemented traits. +- ink! trait definitions via `#[ink::trait_definition]` ‒ [#665](https://github.com/use-ink/ink/pull/665). + - ink! trait definitions no longer can define trait constructors. + - ink! trait implementations now inherit `selector` and `payable` properties for trait messages. + - Now explicitly setting `selector` or `payable` property for an implemented ink! trait method + will only act as a guard that the set property is in fact the same as defined by the ink! + trait definition. +- Improved some ink! specific compile errors ‒ [#665](https://github.com/use-ink/ink/pull/665). + - For example, when using ink! messages and constructors which have inputs (or + outputs) that cannot be encoded (or decoded) using the SCALE codec. +- Simplified selector computation for ink! trait methods ‒ [#665](https://github.com/use-ink/ink/pull/665). + - Now selectors are encoded as `blake2b({namespace}::{trait_identifier}::{message_identifier})[0..4]`. + If no `namespace` is set for the ink! trait definition then the formula is + `blake2b({trait_identifier}::{message_identifier})[0..4]`. + Where `trait_identifier` and `message_identifier` both refer to the identifiers of the ink! trait + definition and ink! trait message respectively. +- We switched to Rust edition 2021 ‒ [#977](https://github.com/use-ink/ink/pull/977). +- Update chain extension example to show argument passing ‒ [#1029](https://github.com/use-ink/ink/pull/1029). ### Fixed - -- Contracts now revert the transaction if an ink! message returns `Result::Err` ‒ [#975](https://github.com/use-ink/ink/pull/975), [#998](https://github.com/use-ink/ink/pull/998). - - It is still possible to match against a `Result` return type for a called dependency contract - ‒ i.e. a sub-contract specified in the contract's `Cargo.toml`. -- We implemented a number of Wasm contract size improvements: - - Simple Mapping Storage Primitive ‒ [#946](https://github.com/use-ink/ink/pull/946). - - Remove `always` from `inline` to allow compiler decide that to do ‒ [#1012](https://github.com/use-ink/ink/pull/1012) (thanks [@xgreenx](https://github.com/xgreenx)). - - Add a way to allocate a storage facility using spread (and packed) layouts ‒ [#978](https://github.com/use-ink/ink/pull/978). - - Extract non-generic part of `push_topic` to reduce code size ‒ [#1026](https://github.com/use-ink/ink/pull/1026). +- Contracts now revert the transaction if an ink! message returns `Result::Err` ‒ [#975](https://github.com/use-ink/ink/pull/975), [#998](https://github.com/use-ink/ink/pull/998). + - It is still possible to match against a `Result` return type for a called dependency contract + ‒ i.e. a sub-contract specified in the contract's `Cargo.toml`. +- We implemented a number of Wasm contract size improvements: + - Simple Mapping Storage Primitive ‒ [#946](https://github.com/use-ink/ink/pull/946). + - Remove `always` from `inline` to allow compiler decide that to do ‒ [#1012](https://github.com/use-ink/ink/pull/1012) (thanks [@xgreenx](https://github.com/xgreenx)). + - Add a way to allocate a storage facility using spread (and packed) layouts ‒ [#978](https://github.com/use-ink/ink/pull/978). + - Extract non-generic part of `push_topic` to reduce code size ‒ [#1026](https://github.com/use-ink/ink/pull/1026). ## Version 3.0-rc6 @@ -1597,7 +1469,6 @@ This is the 6th release candidate for ink! 3.0. #### Please upgrade `cargo-contract` You need to update to the latest `cargo-contract` in order to use this release: - ``` cargo install cargo-contract --vers ^0.15 --force --locked ``` @@ -1612,7 +1483,6 @@ version in your contract's `Cargo.toml` as well; `cargo-contract` will throw an error otherwise. The `Cargo.toml` should contain - ``` scale-info = { version = "1.0", default-features = false, features = ["derive"], optional = true } scale = { package = "parity-scale-codec", version = "2", default-features = false, features = ["derive", "full"] } @@ -1622,34 +1492,31 @@ scale = { package = "parity-scale-codec", version = "2", default-features = fals There are breaking changes to the metadata format in this release. -- Removes top level `metadataVersion` field from the contract metadata (https://github.com/use-ink/cargo-contract/pull/342/files). -- Introduces new top level versioned metadata [enum](https://github.com/use-ink/ink/blob/master/crates/metadata/src/lib.rs#L68). -- Upgrades to `scale-info` version `1.0` (https://github.com/use-ink/ink/pull/845). - - The previous supported version was `0.6`, so check release notes for all changes since then: https://github.com/use-ink/ink/pull/845 - - One of the main changes to be aware of is the change to 0 based type lookup ids: https://github.com/paritytech/scale-info/pull/90 +- Removes top level `metadataVersion` field from the contract metadata (https://github.com/use-ink/cargo-contract/pull/342/files). +- Introduces new top level versioned metadata [enum](https://github.com/use-ink/ink/blob/master/crates/metadata/src/lib.rs#L68). +- Upgrades to `scale-info` version `1.0` (https://github.com/use-ink/ink/pull/845). + - The previous supported version was `0.6`, so check release notes for all changes since then: https://github.com/use-ink/ink/pull/845 + - One of the main changes to be aware of is the change to 0 based type lookup ids: https://github.com/paritytech/scale-info/pull/90 ### Added - -- Added an Ethereum-compatibility function to recover a public key from an ECDSA signature and message hash - [#914](https://github.com/use-ink/ink/pull/914) (thanks [@xgreenx](https://github.com/xgreenx)). -- Added new utility proc. macros to `ink_lang` crate - [#947](https://github.com/use-ink/ink/pull/947): - - `blake2!`: Compute the BLAKE2b 256-bit hash of the given input literal string. - - `selector_bytes!`: Compute the ink! selector of the given input literal string and return it as `[u8; 4]`. - - `selector_id!`: Compute the ink! selector of the given input literal string and return it as `u32`. +- Added an Ethereum-compatibility function to recover a public key from an ECDSA signature and message hash - [#914](https://github.com/use-ink/ink/pull/914) (thanks [@xgreenx](https://github.com/xgreenx)). +- Added new utility proc. macros to `ink_lang` crate - [#947](https://github.com/use-ink/ink/pull/947): + - `blake2!`: Compute the BLAKE2b 256-bit hash of the given input literal string. + - `selector_bytes!`: Compute the ink! selector of the given input literal string and return it as `[u8; 4]`. + - `selector_id!`: Compute the ink! selector of the given input literal string and return it as `u32`. ### Changed - -- Update to `scale-info` 1.0 - [#845](https://github.com/use-ink/ink/pull/845). -- Message and constructor selectors no longer take their inputs as string, but as `u32` decodable integer - [#928](https://github.com/use-ink/ink/pull/928).
- For example: - - It is no longer possible to specify a selector as `#[ink(selector = "0xC0DECAFE")]`. - - The newly allowed formats are `#[ink(selector = 0xC0DECAFE)]` and `#[ink(selector = 42)]`. - - Smart contract authors are required to update their smart contracts for this change. -- Improved the `multisig` example - [#962](https://github.com/use-ink/ink/pull/962). -- Changed the link to our beginner's workshop to the migrated workshop on `substrate.io` - [#957](https://github.com/use-ink/ink/pull/957). +- Update to `scale-info` 1.0 - [#845](https://github.com/use-ink/ink/pull/845). +- Message and constructor selectors no longer take their inputs as string, but as `u32` decodable integer - [#928](https://github.com/use-ink/ink/pull/928).
+ For example: + - It is no longer possible to specify a selector as `#[ink(selector = "0xC0DECAFE")]`. + - The newly allowed formats are `#[ink(selector = 0xC0DECAFE)]` and `#[ink(selector = 42)]`. + - Smart contract authors are required to update their smart contracts for this change. +- Improved the `multisig` example - [#962](https://github.com/use-ink/ink/pull/962). +- Changed the link to our beginner's workshop to the migrated workshop on `substrate.io` - [#957](https://github.com/use-ink/ink/pull/957). ### Fixed - -- Fixed a mistake in the `ink_env::block_timestamp()` documentation - [#937](https://github.com/use-ink/ink/pull/937). +- Fixed a mistake in the `ink_env::block_timestamp()` documentation - [#937](https://github.com/use-ink/ink/pull/937). ## Version 3.0-rc5 (2021-09-08) @@ -1660,7 +1527,6 @@ The list below shows the additions, changes and fixes that are visible to users ### Compatibility Make sure to use a recent Rust nightly and `cargo-contract` with the current release: - ``` cargo install cargo-contract --vers ^0.14 --force --locked && rustup update ``` @@ -1676,22 +1542,18 @@ It fulfills the same purpose the `canvas-node` did before ‒ it's a standalone just Substrate's [`node-template`](https://github.com/paritytech/substrate/tree/master/bin/node-template) modified to include [the `contracts` pallet](https://github.com/paritytech/substrate/tree/master/frame/contracts). You can install the newest version like this: - ``` cargo install contracts-node --git https://github.com/paritytech/substrate-contracts-node.git --force ``` - After you've installed the node it can be run via `substrate-contracts-node --tmp --dev`. ### Added - -- Added example for mocking chain extensions in off-chain tests ‒ [#882](https://github.com/use-ink/ink/pull/882). -- Panic messages are now printed to debug buffer ‒ [#894](https://github.com/use-ink/ink/pull/894). +- Added example for mocking chain extensions in off-chain tests ‒ [#882](https://github.com/use-ink/ink/pull/882). +- Panic messages are now printed to debug buffer ‒ [#894](https://github.com/use-ink/ink/pull/894). ### Changed - -- Unlicensed smart contract examples ‒ [#888](https://github.com/use-ink/ink/pull/888). -- Stabilized `seal_debug_message` ‒ [#902](https://github.com/use-ink/ink/pull/902). +- Unlicensed smart contract examples ‒ [#888](https://github.com/use-ink/ink/pull/888). +- Stabilized `seal_debug_message` ‒ [#902](https://github.com/use-ink/ink/pull/902). ## Version 3.0-rc4 (2021-07-19) @@ -1703,12 +1565,12 @@ The list below shows the additions, changes and fixes that are visible to users ink! 3.0-rc4 is compatible with -- The "ink! CLI" [`cargo-contract`](https://github.com/use-ink/cargo-contract) - version `0.13.0` or newer. - - Install the newest version using `cargo install --force cargo-contract`. -- Substrate version `4.0.0-dev` including the `contracts-pallet` version `4.0.0-dev`. -- [`substrate-contracts-node`](https://github.com/paritytech/substrate-contracts-node) version `0.1.0` or newer. - - Install the newest version using `cargo install contracts-node --git https://github.com/paritytech/substrate-contracts-node.git --force`. +- The "ink! CLI" [`cargo-contract`](https://github.com/use-ink/cargo-contract) + version `0.13.0` or newer. + - Install the newest version using `cargo install --force cargo-contract`. +- Substrate version `4.0.0-dev` including the `contracts-pallet` version `4.0.0-dev`. +- [`substrate-contracts-node`](https://github.com/paritytech/substrate-contracts-node) version `0.1.0` or newer. + - Install the newest version using `cargo install contracts-node --git https://github.com/paritytech/substrate-contracts-node.git --force`. The documentation on our [Documentation Portal](https://use.ink) is up-to-date with this release candidate. Since the last release candidate we notably @@ -1720,73 +1582,70 @@ there. In order to ensure a continuously high quality of our codebase we implemented a number of key improvements to our testing setup: -- We've put an emphasis on automated testing of the usage examples in our crate documentation. - Those are now tested in the context of a complete ink! contract. In the past this was not - always the case, sometimes usage examples were just isolated code snippets. -- We started our [`ink-waterfall`](https://github.com/use-ink/ink-waterfall) project, - which runs End-to-End tests through our entire stack. - All our examples are continuously built using the latest `cargo-contract`. They are - subsequently deployed on the latest `substrate-contracts-node` by emulating browser interactions with - both the [`canvas-ui`](https://use-ink.github.io/canvas-ui/#/) and the - [`polkadot-js`](https://polkadot.js.org/apps/#/) UI. - This testing setup enables us to detect bugs which only appear in the context of using - multiple components together early on. -- To improve the readability of our documentation we introduced automated grammar and spell - checking into our Continuous Integration environment. +- We've put an emphasis on automated testing of the usage examples in our crate documentation. + Those are now tested in the context of a complete ink! contract. In the past this was not + always the case, sometimes usage examples were just isolated code snippets. +- We started our [`ink-waterfall`](https://github.com/use-ink/ink-waterfall) project, + which runs End-to-End tests through our entire stack. + All our examples are continuously built using the latest `cargo-contract`. They are + subsequently deployed on the latest `substrate-contracts-node` by emulating browser interactions with + both the [`canvas-ui`](https://use-ink.github.io/canvas-ui/#/) and the + [`polkadot-js`](https://polkadot.js.org/apps/#/) UI. + This testing setup enables us to detect bugs which only appear in the context of using + multiple components together early on. +- To improve the readability of our documentation we introduced automated grammar and spell + checking into our Continuous Integration environment. ### Added - -- Added support for the new `seal_random` API ‒ [#734](https://github.com/use-ink/ink/pull/734). -- Added missing documentation for the `ink_storage_derive` procedural macros ‒ [#711](https://github.com/use-ink/ink/pull/711). -- Implemented the (unstable) `seal_rent_params` API ‒ [#755](https://github.com/use-ink/ink/pull/755). -- Implemented the (unstable) `seal_rent_status` API ‒ [#798](https://github.com/use-ink/ink/pull/798). -- Implemented the (unstable) `seal_debug_message` API ‒ [#792](https://github.com/use-ink/ink/pull/792). - - Printing debug messages can now be achieved via `ink_env::debug_println!(…)`. - - See [our documentation](https://use.ink/faq#how-do-i-print-something-to-the-console-from-the-runtime) - for more information. - - The examples have been updated to reflect this new way of printing debug messages. -- Added usage comments with code examples to the `ink_env` API ‒ [#797](https://github.com/use-ink/ink/pull/797). - - The [published crate documentation](https://use-ink.github.io/ink/ink_lang/struct.EnvAccess.html) now contains - much more code examples for the methods behind `self.env()` and `Self::env()`. -- Added an example implementation for ERC-1155, a multi-token standard ‒ [#800](https://github.com/use-ink/ink/pull/800). -- Implemented binary search for `collections::Vec` ‒ [#836](https://github.com/use-ink/ink/pull/836). -- Added the ability of submitting payable transactions to the `multisig` example ‒ [#820](https://github.com/use-ink/ink/pull/820). -- Implemented `Decode` for `Error` types in the examples, enabling building them as dependencies ‒ [#761](https://github.com/use-ink/ink/pull/761). -- We started working on a new off-chain environment testing engine ‒ [#712](https://github.com/use-ink/ink/pull/712). - - The old testing environment has a number of limitations, which we are well aware of. - We're confident that with the new testing engine we will be able to conduct much more - elaborate testing in an emulated chain environment. - - For the moment, the new engine is unstable and only available behind a feature flag. - A number of examples have already been converted to support the new testing engine. +- Added support for the new `seal_random` API ‒ [#734](https://github.com/use-ink/ink/pull/734). +- Added missing documentation for the `ink_storage_derive` procedural macros ‒ [#711](https://github.com/use-ink/ink/pull/711). +- Implemented the (unstable) `seal_rent_params` API ‒ [#755](https://github.com/use-ink/ink/pull/755). +- Implemented the (unstable) `seal_rent_status` API ‒ [#798](https://github.com/use-ink/ink/pull/798). +- Implemented the (unstable) `seal_debug_message` API ‒ [#792](https://github.com/use-ink/ink/pull/792). + - Printing debug messages can now be achieved via `ink_env::debug_println!(…)`. + - See [our documentation](https://use.ink/faq#how-do-i-print-something-to-the-console-from-the-runtime) + for more information. + - The examples have been updated to reflect this new way of printing debug messages. +- Added usage comments with code examples to the `ink_env` API ‒ [#797](https://github.com/use-ink/ink/pull/797). + - The [published crate documentation](https://use-ink.github.io/ink/ink_lang/struct.EnvAccess.html) now contains + much more code examples for the methods behind `self.env()` and `Self::env()`. +- Added an example implementation for ERC-1155, a multi-token standard ‒ [#800](https://github.com/use-ink/ink/pull/800). +- Implemented binary search for `collections::Vec` ‒ [#836](https://github.com/use-ink/ink/pull/836). +- Added the ability of submitting payable transactions to the `multisig` example ‒ [#820](https://github.com/use-ink/ink/pull/820). +- Implemented `Decode` for `Error` types in the examples, enabling building them as dependencies ‒ [#761](https://github.com/use-ink/ink/pull/761). +- We started working on a new off-chain environment testing engine ‒ [#712](https://github.com/use-ink/ink/pull/712). + - The old testing environment has a number of limitations, which we are well aware of. + We're confident that with the new testing engine we will be able to conduct much more + elaborate testing in an emulated chain environment. + - For the moment, the new engine is unstable and only available behind a feature flag. + A number of examples have already been converted to support the new testing engine. ### Changed - -- To reduce a contract's space footprint we switched the default allocator to a bump allocator implementation ‒ [#831](https://github.com/use-ink/ink/pull/831). -- A couple of readme's have been reworked: - - Our main ink! readme ‒ [#774](https://github.com/use-ink/ink/pull/774). - - The `rand-extension` example readme ‒ [#793](https://github.com/use-ink/ink/pull/793). - - The `delegator` example readme ‒ [#766](https://github.com/use-ink/ink/pull/766). -- With the stabilization of Rust 1.51 we ware able to remove the `ink-unstable` feature, making - `collections::SmallVec` and `lazy::LazyArray` available by default ‒ [#746](https://github.com/use-ink/ink/pull/746). -- To resolve confusion, we migrated all usages of `#[test]` in our examples to `#[ink::test]` ‒ [#746](https://github.com/use-ink/ink/pull/746). - - The difference is that `#[ink::test]` spawns an emulated chain environment (an "off-chain" environment) - and hence comes with a bit of overhead. It was not always clear to users when they require - an off-chain environment, we decided to mitigate this confusion by using an emulated chain - environment for all our example tests. -- With the stabilization of Rust's `min_const_generics` we were able to replace the fixed - size implementations of `SpreadLayout` and `PackedLayout` for Arrays. These traits are - now implemented for all Arrays of size `usize` ‒ [#754](https://github.com/use-ink/ink/pull/754). -- We were able to remove the pinned `funty` dependency ‒ [#711](https://github.com/use-ink/ink/pull/711). -- The `contract-transfer` example has been improved for better UI support ‒ [#789](https://github.com/use-ink/ink/pull/789). -- The `contract-transfer` example has been improved for better error handling ‒ [#790](https://github.com/use-ink/ink/pull/790). +- To reduce a contract's space footprint we switched the default allocator to a bump allocator implementation ‒ [#831](https://github.com/use-ink/ink/pull/831). +- A couple of readme's have been reworked: + - Our main ink! readme ‒ [#774](https://github.com/use-ink/ink/pull/774). + - The `rand-extension` example readme ‒ [#793](https://github.com/use-ink/ink/pull/793). + - The `delegator` example readme ‒ [#766](https://github.com/use-ink/ink/pull/766). +- With the stabilization of Rust 1.51 we ware able to remove the `ink-unstable` feature, making + `collections::SmallVec` and `lazy::LazyArray` available by default ‒ [#746](https://github.com/use-ink/ink/pull/746). +- To resolve confusion, we migrated all usages of `#[test]` in our examples to `#[ink::test]` ‒ [#746](https://github.com/use-ink/ink/pull/746). + - The difference is that `#[ink::test]` spawns an emulated chain environment (an "off-chain" environment) + and hence comes with a bit of overhead. It was not always clear to users when they require + an off-chain environment, we decided to mitigate this confusion by using an emulated chain + environment for all our example tests. +- With the stabilization of Rust's `min_const_generics` we were able to replace the fixed + size implementations of `SpreadLayout` and `PackedLayout` for Arrays. These traits are + now implemented for all Arrays of size `usize` ‒ [#754](https://github.com/use-ink/ink/pull/754). +- We were able to remove the pinned `funty` dependency ‒ [#711](https://github.com/use-ink/ink/pull/711). +- The `contract-transfer` example has been improved for better UI support ‒ [#789](https://github.com/use-ink/ink/pull/789). +- The `contract-transfer` example has been improved for better error handling ‒ [#790](https://github.com/use-ink/ink/pull/790). ### Fixed - -- Catch illegal `struct` destructuring pattern in ink! message arguments ‒ [#846](https://github.com/use-ink/ink/pull/846). -- Removed an erroneous `Salt` type in code generation for cross-contract calls ‒ [#842](https://github.com/use-ink/ink/pull/842). -- Do not generate metadata if compiled as dependency ‒ [#811](https://github.com/use-ink/ink/pull/811). -- Fix execution context parameters in DNS example tests ‒ [#723](https://github.com/use-ink/ink/pull/723). -- Fixed the `Greeter` contract example from our doc comments ‒ [#773](https://github.com/use-ink/ink/pull/773). +- Catch illegal `struct` destructuring pattern in ink! message arguments ‒ [#846](https://github.com/use-ink/ink/pull/846). +- Removed an erroneous `Salt` type in code generation for cross-contract calls ‒ [#842](https://github.com/use-ink/ink/pull/842). +- Do not generate metadata if compiled as dependency ‒ [#811](https://github.com/use-ink/ink/pull/811). +- Fix execution context parameters in DNS example tests ‒ [#723](https://github.com/use-ink/ink/pull/723). +- Fixed the `Greeter` contract example from our doc comments ‒ [#773](https://github.com/use-ink/ink/pull/773). ## Version 3.0-rc3 (2021-03-02) @@ -1798,45 +1657,45 @@ The list below shows the additions, changes and fixes that are visible to users ink! 3.0-rc3 is compatible with -- The `cargo-contract` CLI tool version `0.9.1` or newer. - - Install newest version using `cargo install --force cargo-contract`. -- Substrate version `3.0` including the `contracts-pallet` version `3.0`. +- The `cargo-contract` CLI tool version `0.9.1` or newer. + - Install newest version using `cargo install --force cargo-contract`. +- Substrate version `3.0` including the `contracts-pallet` version `3.0`. ### Added -- Implemented chain extensions feature for ink!. -- ink!'s official documentation portal: https://use.ink/ -- It is now possible to pass a `salt` argument to contract instantiations. -- Implemented fuzz testing for the ink! codebase. +- Implemented chain extensions feature for ink!. +- ink!'s official documentation portal: https://use.ink/ +- It is now possible to pass a `salt` argument to contract instantiations. +- Implemented fuzz testing for the ink! codebase. ### Changed -- Migrate `ink_storage::SmallVec` and `ink_storage::lazy::SmallLazyArray` to use `min_const_generics`. - - The `min_const_generics` feature is going to be stabilized in Rust 1.51. For now it was put behind - the `ink-unstable` crate feature of the `ink_storage` crate. -- Improve error reporting for conflicting ink! attributes. -- Improve error reporting for invalid constructor or message selector. (https://github.com/use-ink/ink/pull/561) -- Remove `iter_mut` for `ink_storage::BinaryHeap` data structure. -- Add documented demonstration how to properly mock `transferred_balance` calls: https://github.com/use-ink/ink/pull/555 -- Add contract example which uses `ext_transfer` and `ext_terminate`: https://github.com/use-ink/ink/pull/554 -- Improve documentation of `transfer` and `minimum_balance` APIs: https://github.com/use-ink/ink/pull/540 +- Migrate `ink_storage::SmallVec` and `ink_storage::lazy::SmallLazyArray` to use `min_const_generics`. + - The `min_const_generics` feature is going to be stabilized in Rust 1.51. For now it was put behind + the `ink-unstable` crate feature of the `ink_storage` crate. +- Improve error reporting for conflicting ink! attributes. +- Improve error reporting for invalid constructor or message selector. (https://github.com/use-ink/ink/pull/561) +- Remove `iter_mut` for `ink_storage::BinaryHeap` data structure. +- Add documented demonstration how to properly mock `transferred_balance` calls: https://github.com/use-ink/ink/pull/555 +- Add contract example which uses `ext_transfer` and `ext_terminate`: https://github.com/use-ink/ink/pull/554 +- Improve documentation of `transfer` and `minimum_balance` APIs: https://github.com/use-ink/ink/pull/540 ### Fixed -- The Delegator example contract now compiles properly using the `build-all.sh` bash script. -- Update crate dependencies: - - `scale-info 0.6` - - `parity-scale-codec 2.0` - - `rand 0.8` - - `itertools 0.10` -- Remove unused `tiny-keccak` dependency from `ink_primitives`. -- Changed the default `BlockNumber` type to `u32`. This is a fix since it now properly mirrors Substrate's default `BlockNumber` type. -- Ensure topics are unique: https://github.com/use-ink/ink/pull/594 -- Several fixes for `ink_storage` data structures, including: - - `Drop` implementation for `Pack` now works properly. (https://github.com/use-ink/ink/pull/600) - - `Drop` implementation for `Lazy` now always properly clean up storage. (https://github.com/use-ink/ink/pull/597) - - Nested `Lazy` now properly clears storage data. (https://github.com/use-ink/ink/pull/583) - - `Option` fields now properly clean up nested storage data. (https://github.com/use-ink/ink/pull/570) +- The Delegator example contract now compiles properly using the `build-all.sh` bash script. +- Update crate dependencies: + - `scale-info 0.6` + - `parity-scale-codec 2.0` + - `rand 0.8` + - `itertools 0.10` +- Remove unused `tiny-keccak` dependency from `ink_primitives`. +- Changed the default `BlockNumber` type to `u32`. This is a fix since it now properly mirrors Substrate's default `BlockNumber` type. +- Ensure topics are unique: https://github.com/use-ink/ink/pull/594 +- Several fixes for `ink_storage` data structures, including: + - `Drop` implementation for `Pack` now works properly. (https://github.com/use-ink/ink/pull/600) + - `Drop` implementation for `Lazy` now always properly clean up storage. (https://github.com/use-ink/ink/pull/597) + - Nested `Lazy` now properly clears storage data. (https://github.com/use-ink/ink/pull/583) + - `Option` fields now properly clean up nested storage data. (https://github.com/use-ink/ink/pull/570) ## Version 3.0-rc2 (2020-10-22) @@ -1845,25 +1704,25 @@ This is the 2nd release candidate for ink! 3.0. On top of the changes introduced in the first release candidate for ink! 3.0 we introduced the following improvements, new features and bug fixes: -- The `ink_storage` crate now comes with a new `BinaryHeap` data structure - that has a very similar interface to the well known Rust standard library - `BinaryHeap`. It features specific optimizations to reduce the storage reads - and writes required for its operations. -- Fixed a bug with `ink_storage::Lazy` that corrupted the storage of - other storage data structures if it was unused in a contract execution. -- The `ink_storage::alloc::Box` type now implements `scale_info::TypeInfo` which - now allows it to be fully used inside other storage data structures such as - `ink_storage::collections::Vec`. The missing of this implementation was - considered a bug. -- The `LazyHashMap` low-level storage abstraction is now re-exported from within - the `ink_storage::lazy` module and docs are inlined. -- Added note about the `ink_core` split into `ink_env` and `ink_storage` crates - to the release notes of ink! 3.0-rc1. -- The `Cargo.toml` documentation now properly links to the one deployed at docs.rs. - On top of that crate level documentation for the `ink_allocator` crate has been - added. -- Add new ERC-20 example contract based on a trait implementation. Also modernized - the old non-trait based ERC-20 example token contract. +- The `ink_storage` crate now comes with a new `BinaryHeap` data structure + that has a very similar interface to the well known Rust standard library + `BinaryHeap`. It features specific optimizations to reduce the storage reads + and writes required for its operations. +- Fixed a bug with `ink_storage::Lazy` that corrupted the storage of + other storage data structures if it was unused in a contract execution. +- The `ink_storage::alloc::Box` type now implements `scale_info::TypeInfo` which + now allows it to be fully used inside other storage data structures such as + `ink_storage::collections::Vec`. The missing of this implementation was + considered a bug. +- The `LazyHashMap` low-level storage abstraction is now re-exported from within + the `ink_storage::lazy` module and docs are inlined. +- Added note about the `ink_core` split into `ink_env` and `ink_storage` crates + to the release notes of ink! 3.0-rc1. +- The `Cargo.toml` documentation now properly links to the one deployed at docs.rs. + On top of that crate level documentation for the `ink_allocator` crate has been + added. +- Add new ERC-20 example contract based on a trait implementation. Also modernized + the old non-trait based ERC-20 example token contract. ## Version 3.0-rc1 (2020-10-09) @@ -1886,7 +1745,6 @@ now follows the natural Rust constructors scheme. So it is no longer possible to yourself in the foot by accidentally forgetting to initialize some important data structures. **Old ink! 2.0:** - ```rust #[ink(constructor)] fn new_erc20(&mut self, initial_supply: Balance) { @@ -1895,9 +1753,7 @@ fn new_erc20(&mut self, initial_supply: Balance) { self.balances.insert(caller, initial_supply); } ``` - **New ink! 3.0:** - ```rust #[ink(constructor)] pub fn new_erc20(initial_supply: Balance) -> Self { @@ -1947,7 +1803,6 @@ The new `ink_storage::Lazy` type is what corresponds the most to the old `ink_co Data types such as Rust primitives `i32` or Rust's very own `Vec` or data structures can also be used to operate on the contract's storage, however, they will load their contents eagerly which is often not what you want. An example follows with the below contract storage and a message that operates on either of the two fields. - ```rust #[ink(storage)] pub struct TwoValues { @@ -1969,7 +1824,6 @@ impl TwoValues { Whenever we call `TwoValues::set` always both `a` and `b` are loaded despite the fact the we only operate on one of them at a time. This is very costly since storage accesses are in fact database look-ups. In order to prevent this eager loading of storage contents we can make use of `ink_storage::Lazy` or other lazy data structures defined in that crate: - ```rust #[ink(storage)] pub struct TwoValues { @@ -1988,7 +1842,6 @@ impl TwoValues { } } ``` - Now `a` and `b` are only loaded when the contract really needs their values. Note that `offset` remained `i32` since it is always needed and could spare the minor overhead of the `ink_storage::Lazy` wrapper. @@ -2001,15 +1854,15 @@ However, their APIs look very different. Whereas the `HashMap` provides a rich a The fundamental difference of both data structures is that `HashMap` is aware of the keys that have been stored in it and thus can reconstruct exactly which elements and storage regions apply to it. This enables it to provide iteration and automated deletion as well as efficient way to defragment its underlying storage to free some storage space again. This goes very well in the vein of Substrate's storage rent model where contracts have to pay for the storage they are using. -| Data Structure | level of abstraction | caching | lazy | element type | container | -| :------------------ | :------------------: | :-----: | :--: | :------------------------: | :--------------------------: | -| `T` | - | yes | no | `T` | primitive value | -| `Lazy` | high-level | yes | yes | `T` | single element container | -| `LazyCell` | low-level | yes | yes | `Option` | single element, no container | -| `Vec` | high-level | yes | yes | `T` | Rust vector-like container | -| `LazyIndexMap` | low-level | yes | yes | `Option` | similar to Solidity mapping | -| `HashMap` | high-level | yes | yes | `V` (key type `K`) | Rust map-like container | -| `LazyHashMap` | low-level | yes | yes | `Option` (key type `K`) | similar to Solidity mapping | +| Data Structure | level of abstraction | caching | lazy | element type | container | +| :------------------ | :------------------: | :-----: | :---: | :------------------------: | :--------------------------: | +| `T` | - | yes | no | `T` | primitive value | +| `Lazy` | high-level | yes | yes | `T` | single element container | +| `LazyCell` | low-level | yes | yes | `Option` | single element, no container | +| `Vec` | high-level | yes | yes | `T` | Rust vector-like container | +| `LazyIndexMap` | low-level | yes | yes | `Option` | similar to Solidity mapping | +| `HashMap` | high-level | yes | yes | `V` (key type `K`) | Rust map-like container | +| `LazyHashMap` | low-level | yes | yes | `Option` (key type `K`) | similar to Solidity mapping | There are many more! For more information about the specifics please take a look into [the `ink_storage` crate documentation](https://use-ink.github.io/ink/ink_storage/). @@ -2173,7 +2026,6 @@ For a list of all the new storage data structure visit [`ink_storage`'s document For ink! 3.0 we have added some more useful ink! specific attributes to the table. All of these ink! attributes are available to specify inside an ink! module. An ink! module is the module that is flagged by `#[ink::contract]` containing all the ink! definitions: - ```rust use ink_lang as ink; @@ -2222,9 +2074,7 @@ pub fn transfer(&mut self, from: AccountId, to: AccountId, value: Balance) -> Re // actual implementation } ``` - We can also write the above ink! message definition in the following way: - ```rust #[ink(message, payable, selector = "0xCAFEBABE")] pub fn transfer(&mut self, from: AccountId, to: AccountId, value: Balance) -> Result<(), Error> { @@ -2321,12 +2171,12 @@ These limitations exist because of technical intricacies, however, please expect ## Version 2.1 (2020-03-25) -- Add built-in support for cryptographic hashes: - - Blake2 with 128-bit and 256-bit - - Sha2 with 256-bit - - Keccak with 256-bit -- Add `ink_core::hash` module for high-level API to the new built-in hashes. -- Update `runtime-storage` example ink! smart contract to demonstrate the new built-in hashes. +- Add built-in support for cryptographic hashes: + - Blake2 with 128-bit and 256-bit + - Sha2 with 256-bit + - Keccak with 256-bit +- Add `ink_core::hash` module for high-level API to the new built-in hashes. +- Update `runtime-storage` example ink! smart contract to demonstrate the new built-in hashes. ## Version 2.0 (2019-12-03) @@ -2784,4 +2634,4 @@ impl Contract { This is useful if the `impl` block itself does not contain any ink! constructors or messages, but you still need to access some of the "magic" provided by ink!. In the example above, you would not have -access to `emit_event` without `#[ink(impl)]`. +access to `emit_event` without `#[ink(impl)]`. \ No newline at end of file From 3aa2e5430d501fb5c80e04d59c691c452925d70e Mon Sep 17 00:00:00 2001 From: Lucas Grasso Date: Tue, 4 Nov 2025 11:19:31 -0300 Subject: [PATCH 19/24] ref_time_left -> gas_left --- CHANGELOG.md | 2 +- crates/env/src/api.rs | 4 ++-- crates/env/src/backend.rs | 4 ++-- crates/env/src/engine/off_chain/impls.rs | 2 +- crates/env/src/engine/on_chain/pallet_revive.rs | 4 ++-- crates/ink/src/env_access.rs | 10 +++++----- crates/ink/tests/ui/contract/pass/env-access.rs | 4 ++-- integration-tests/internal/gas-hostfns/lib.rs | 10 +++++----- 8 files changed, 20 insertions(+), 20 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 26f1006ff5d..5c969c2f3f5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Version 6.0.0-beta ### Added -- Implements the API for the `pallet-revive` host functions `gas_price`, `call_data_size`, `return_data_size`, `ref_time_left` - [#2694](https://github.com/use-ink/ink/pull/2694) +- Implements the API for the `pallet-revive` host functions `gas_price`, `call_data_size`, `return_data_size`, `gas_left` - [#2694](https://github.com/use-ink/ink/pull/2694) - Implements the API for the `pallet-revive` host function `gas_limit` - [#2691](https://github.com/use-ink/ink/pull/2691) - Implements the API for the `pallet-revive` host function `to_account_id` - [#2578](https://github.com/use-ink/ink/pull/2578) - Add `#[ink::contract_ref]` attribute - [#2648](https://github.com/use-ink/ink/pull/2648) diff --git a/crates/env/src/api.rs b/crates/env/src/api.rs index 6e8d83cf7f2..fa7e29c9507 100644 --- a/crates/env/src/api.rs +++ b/crates/env/src/api.rs @@ -88,8 +88,8 @@ pub fn gas_price() -> u64 { } /// Returns the amount of evm gas left. -pub fn ref_time_left() -> u64 { - ::on_instance(TypedEnvBackend::ref_time_left) +pub fn gas_left() -> u64 { + ::on_instance(TypedEnvBackend::gas_left) } /// Returns the total size of the contract call input data. diff --git a/crates/env/src/backend.rs b/crates/env/src/backend.rs index dff672ee233..47be05a9405 100644 --- a/crates/env/src/backend.rs +++ b/crates/env/src/backend.rs @@ -248,8 +248,8 @@ pub trait TypedEnvBackend: EnvBackend { /// /// # Note /// - /// For more details visit: [`ref_time_left`][`crate::ref_time_left`] - fn ref_time_left(&mut self) -> u64; + /// For more details visit: [`gas_left`][`crate::gas_left`] + fn gas_left(&mut self) -> u64; /// Returns the total size of the contract call input data. /// diff --git a/crates/env/src/engine/off_chain/impls.rs b/crates/env/src/engine/off_chain/impls.rs index 427976764b2..2a2b018e1d6 100644 --- a/crates/env/src/engine/off_chain/impls.rs +++ b/crates/env/src/engine/off_chain/impls.rs @@ -560,7 +560,7 @@ impl TypedEnvBackend for EnvInstance { unimplemented!("not implemented, the off-chain environment will be removed"); } - fn ref_time_left(&mut self) -> u64 { + fn gas_left(&mut self) -> u64 { unimplemented!("not implemented, the off-chain environment will be removed"); } diff --git a/crates/env/src/engine/on_chain/pallet_revive.rs b/crates/env/src/engine/on_chain/pallet_revive.rs index 5e5411917f6..ea00f7b7e19 100644 --- a/crates/env/src/engine/on_chain/pallet_revive.rs +++ b/crates/env/src/engine/on_chain/pallet_revive.rs @@ -941,8 +941,8 @@ impl TypedEnvBackend for EnvInstance { ext::gas_price() } - fn ref_time_left(&mut self) -> u64 { - ext::ref_time_left() + fn gas_left(&mut self) -> u64 { + ext::gas_left() } fn call_data_size(&mut self) -> u64 { diff --git a/crates/ink/src/env_access.rs b/crates/ink/src/env_access.rs index c953d5ed0e7..c0233b16f22 100644 --- a/crates/ink/src/env_access.rs +++ b/crates/ink/src/env_access.rs @@ -189,8 +189,8 @@ where /// } /// /// #[ink(message)] - /// pub fn get_ref_time_left(&self) -> u64 { - /// self.env().ref_time_left() + /// pub fn get_gas_left(&self) -> u64 { + /// self.env().gas_left() /// } /// } /// } @@ -198,9 +198,9 @@ where /// /// # Note /// - /// For more details visit: [`ink_env::ref_time_left`] - pub fn ref_time_left(self) -> u64 { - ink_env::ref_time_left() + /// For more details visit: [`ink_env::gas_left`] + pub fn gas_left(self) -> u64 { + ink_env::gas_left() } /// Returns the total size of the contract call input data. diff --git a/crates/ink/tests/ui/contract/pass/env-access.rs b/crates/ink/tests/ui/contract/pass/env-access.rs index 9e6810bad74..0d515966a68 100644 --- a/crates/ink/tests/ui/contract/pass/env-access.rs +++ b/crates/ink/tests/ui/contract/pass/env-access.rs @@ -16,7 +16,7 @@ mod contract { let _ = Self::env().minimum_balance(); let _ = Self::env().gas_limit(); let _ = Self::env().gas_price(); - let _ = Self::env().ref_time_left(); + let _ = Self::env().gas_left(); let _ = Self::env().call_data_size(); let _ = Self::env().return_data_size(); let _ = Self::env().transferred_value(); @@ -34,7 +34,7 @@ mod contract { let _ = self.env().minimum_balance(); let _ = self.env().gas_limit(); let _ = self.env().gas_price(); - let _ = self.env().ref_time_left(); + let _ = self.env().gas_left(); let _ = self.env().call_data_size(); let _ = self.env().return_data_size(); let _ = self.env().transferred_value(); diff --git a/integration-tests/internal/gas-hostfns/lib.rs b/integration-tests/internal/gas-hostfns/lib.rs index 50b416c9dca..ea9ad1416f5 100644 --- a/integration-tests/internal/gas-hostfns/lib.rs +++ b/integration-tests/internal/gas-hostfns/lib.rs @@ -24,10 +24,10 @@ mod gas_hostfns { self.env().gas_price() } - /// Checks that the host function `ref_time_left` works + /// Checks that the host function `gas_left` works #[ink(message)] - pub fn ref_time_left(&self) -> u64 { - self.env().ref_time_left() + pub fn gas_left(&self) -> u64 { + self.env().gas_left() } } @@ -91,7 +91,7 @@ mod gas_hostfns { } #[ink_e2e::test] - async fn e2e_ref_time_left_works( + async fn e2e_gas_left_works( mut client: Client, ) -> E2EResult<()> { // given @@ -104,7 +104,7 @@ mod gas_hostfns { // then let call_res = client - .call(&ink_e2e::alice(), &call_builder.ref_time_left()) + .call(&ink_e2e::alice(), &call_builder.gas_left()) .submit() .await .unwrap_or_else(|err| { From 62d027d85586c7e644f60274fc75ed6621827073 Mon Sep 17 00:00:00 2001 From: Lucas Grasso Date: Tue, 4 Nov 2025 12:19:16 -0300 Subject: [PATCH 20/24] Update crates/env/src/engine/on_chain/pallet_revive.rs Co-authored-by: David Semakula --- crates/env/src/engine/on_chain/pallet_revive.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/env/src/engine/on_chain/pallet_revive.rs b/crates/env/src/engine/on_chain/pallet_revive.rs index ea00f7b7e19..889e6e80979 100644 --- a/crates/env/src/engine/on_chain/pallet_revive.rs +++ b/crates/env/src/engine/on_chain/pallet_revive.rs @@ -942,7 +942,9 @@ impl TypedEnvBackend for EnvInstance { } fn gas_left(&mut self) -> u64 { - ext::gas_left() + // TODO: Change to `ext::gas_left()` when `pallet-revive-uapi` is updated + // Ref: https://github.com/paritytech/polkadot-sdk/pull/9968 + ext::ref_time_left() } fn call_data_size(&mut self) -> u64 { From 06fce276646804b718a01243578969ccada8d119 Mon Sep 17 00:00:00 2001 From: Lucas Grasso Date: Tue, 4 Nov 2025 14:45:58 -0300 Subject: [PATCH 21/24] apply proposed comment changes --- crates/env/src/api.rs | 7 +++++-- crates/env/src/backend.rs | 7 +++++-- crates/env/src/engine/on_chain/pallet_revive.rs | 2 +- crates/ink/src/env_access.rs | 7 +++++-- 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/crates/env/src/api.rs b/crates/env/src/api.rs index fa7e29c9507..5cd9bd30c53 100644 --- a/crates/env/src/api.rs +++ b/crates/env/src/api.rs @@ -82,7 +82,10 @@ pub fn gas_limit() -> u64 { ::on_instance(TypedEnvBackend::gas_limit) } -/// Returns the simulated ethereum `GASPRICE` value. +/// Returns the price per `ref_time`, akin to the EVM +/// [GASPRICE](https://www.evm.codes/?fork=cancun#3a) opcode. +/// +/// See for more information. pub fn gas_price() -> u64 { ::on_instance(TypedEnvBackend::gas_price) } @@ -97,7 +100,7 @@ pub fn call_data_size() -> u64 { ::on_instance(TypedEnvBackend::call_data_size) } -/// Returns the length of the data returned by the last runtime call +/// Returns the length of the data returned by the last runtime call. pub fn return_data_size() -> u64 { ::on_instance(TypedEnvBackend::return_data_size) } diff --git a/crates/env/src/backend.rs b/crates/env/src/backend.rs index 47be05a9405..b539d00a18a 100644 --- a/crates/env/src/backend.rs +++ b/crates/env/src/backend.rs @@ -237,7 +237,10 @@ pub trait TypedEnvBackend: EnvBackend { /// For more details visit: [`gas_limit`][`crate::gas_limit`] fn gas_limit(&mut self) -> u64; - /// Returns the simulated ethereum `GASPRICE` value. + /// Returns the price per `ref_time`, akin to the EVM + /// [GASPRICE](https://www.evm.codes/?fork=cancun#3a) opcode. + /// + /// See for more information. /// /// # Note /// @@ -258,7 +261,7 @@ pub trait TypedEnvBackend: EnvBackend { /// For more details visit: [`call_data_size`][`crate::call_data_size] fn call_data_size(&mut self) -> u64; - /// Returns the length of the data returned by the last runtime call + /// Returns the length of the data returned by the last runtime call. /// /// # Note /// diff --git a/crates/env/src/engine/on_chain/pallet_revive.rs b/crates/env/src/engine/on_chain/pallet_revive.rs index 889e6e80979..853c2f31787 100644 --- a/crates/env/src/engine/on_chain/pallet_revive.rs +++ b/crates/env/src/engine/on_chain/pallet_revive.rs @@ -942,7 +942,7 @@ impl TypedEnvBackend for EnvInstance { } fn gas_left(&mut self) -> u64 { - // TODO: Change to `ext::gas_left()` when `pallet-revive-uapi` is updated + // TODO: Change to `ext::gas_left()` when `pallet-revive-uapi` is updated. // Ref: https://github.com/paritytech/polkadot-sdk/pull/9968 ext::ref_time_left() } diff --git a/crates/ink/src/env_access.rs b/crates/ink/src/env_access.rs index c0233b16f22..579fd4f0987 100644 --- a/crates/ink/src/env_access.rs +++ b/crates/ink/src/env_access.rs @@ -141,7 +141,10 @@ where ink_env::gas_limit() } - /// Returns the simulated ethereum `GASPRICE` value. + /// Returns the price per `ref_time`, akin to the EVM + /// [GASPRICE](https://www.evm.codes/?fork=cancun#3a) opcode. + /// + /// See for more information. /// /// # Example /// @@ -234,7 +237,7 @@ where ink_env::call_data_size() } - /// Returns the length of the data returned by the last runtime call + /// Returns the length of the data returned by the last runtime call. /// /// # Example /// From b307f3c52b218abd91eb49290bd50242a81b2ce6 Mon Sep 17 00:00:00 2001 From: Lucas Grasso Date: Tue, 4 Nov 2025 14:57:52 -0300 Subject: [PATCH 22/24] modify gas_limit comments --- crates/env/src/api.rs | 10 ++++++++-- crates/env/src/backend.rs | 9 +++++++-- crates/ink/src/env_access.rs | 11 ++++++++--- 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/crates/env/src/api.rs b/crates/env/src/api.rs index 5cd9bd30c53..12c4393a55b 100644 --- a/crates/env/src/api.rs +++ b/crates/env/src/api.rs @@ -76,6 +76,7 @@ pub fn caller() -> Address { } /// Returns the block's `ref_time` limit. +/// [GASLIMIT](https://www.evm.codes/?fork=cancun#45) opcode. /// /// See for more information. pub fn gas_limit() -> u64 { @@ -90,17 +91,22 @@ pub fn gas_price() -> u64 { ::on_instance(TypedEnvBackend::gas_price) } -/// Returns the amount of evm gas left. +/// Returns the amount of gas left. +/// This is the `ref_time` left. +/// +/// See for more information. pub fn gas_left() -> u64 { ::on_instance(TypedEnvBackend::gas_left) } /// Returns the total size of the contract call input data. +/// [CALLDATASIZE](https://www.evm.codes/?fork=cancun#36) opcode. pub fn call_data_size() -> u64 { ::on_instance(TypedEnvBackend::call_data_size) } -/// Returns the length of the data returned by the last runtime call. +/// Returns the size of the returned data of the last contract call or instantiation. +/// [RETURNDATASIZE](https://www.evm.codes/?fork=cancun#3d) opcode. pub fn return_data_size() -> u64 { ::on_instance(TypedEnvBackend::return_data_size) } diff --git a/crates/env/src/backend.rs b/crates/env/src/backend.rs index b539d00a18a..566e93d2f6f 100644 --- a/crates/env/src/backend.rs +++ b/crates/env/src/backend.rs @@ -231,6 +231,7 @@ pub trait TypedEnvBackend: EnvBackend { fn caller(&mut self) -> Address; /// Returns the block's `ref_time` limit. + /// [GASLIMIT](https://www.evm.codes/?fork=cancun#45) opcode. /// /// # Note /// @@ -247,7 +248,10 @@ pub trait TypedEnvBackend: EnvBackend { /// For more details visit: [`gas_price`][`crate::gas_price`] fn gas_price(&mut self) -> u64; - /// Returns the amount of evm gas left. + /// Returns the amount of gas left. + /// This is the `ref_time` left. + /// + /// See for more information. /// /// # Note /// @@ -261,7 +265,8 @@ pub trait TypedEnvBackend: EnvBackend { /// For more details visit: [`call_data_size`][`crate::call_data_size] fn call_data_size(&mut self) -> u64; - /// Returns the length of the data returned by the last runtime call. + /// Returns the size of the returned data of the last contract call or instantiation. + /// [RETURNDATASIZE](https://www.evm.codes/?fork=cancun#3d) opcode. /// /// # Note /// diff --git a/crates/ink/src/env_access.rs b/crates/ink/src/env_access.rs index 579fd4f0987..0c00eb5b636 100644 --- a/crates/ink/src/env_access.rs +++ b/crates/ink/src/env_access.rs @@ -110,7 +110,8 @@ where ink_env::caller() } - /// Returns the block ref_time limit. + /// Returns the block's `ref_time` limit. + /// [GASLIMIT](https://www.evm.codes/?fork=cancun#45) opcode. /// /// # Example /// @@ -175,7 +176,10 @@ where ink_env::gas_price() } - /// Returns the amount of evm gas left. + /// Returns the amount of gas left. + /// This is the `ref_time` left. + /// + /// See for more information. /// /// # Example /// @@ -237,7 +241,8 @@ where ink_env::call_data_size() } - /// Returns the length of the data returned by the last runtime call. + /// Returns the size of the returned data of the last contract call or instantiation. + /// [RETURNDATASIZE](https://www.evm.codes/?fork=cancun#3d) opcode. /// /// # Example /// From 4317e6f4186242a4a135e756a67b63c0b9a4e66e Mon Sep 17 00:00:00 2001 From: Lucas Grasso Date: Tue, 4 Nov 2025 15:04:14 -0300 Subject: [PATCH 23/24] add CALLDATASIZE opcode --- crates/env/src/backend.rs | 1 + crates/ink/src/env_access.rs | 1 + 2 files changed, 2 insertions(+) diff --git a/crates/env/src/backend.rs b/crates/env/src/backend.rs index 566e93d2f6f..2bea27b4cd4 100644 --- a/crates/env/src/backend.rs +++ b/crates/env/src/backend.rs @@ -259,6 +259,7 @@ pub trait TypedEnvBackend: EnvBackend { fn gas_left(&mut self) -> u64; /// Returns the total size of the contract call input data. + /// [CALLDATASIZE](https://www.evm.codes/?fork=cancun#36) opcode. /// /// # Note /// diff --git a/crates/ink/src/env_access.rs b/crates/ink/src/env_access.rs index 0c00eb5b636..0b5c47f6e23 100644 --- a/crates/ink/src/env_access.rs +++ b/crates/ink/src/env_access.rs @@ -211,6 +211,7 @@ where } /// Returns the total size of the contract call input data. + /// [CALLDATASIZE](https://www.evm.codes/?fork=cancun#36) opcode. /// /// # Example /// From 8edc1ad02f282abf1ae5837e2954fcd340aea354 Mon Sep 17 00:00:00 2001 From: Lucas Grasso Date: Thu, 6 Nov 2025 17:23:21 -0300 Subject: [PATCH 24/24] 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 --- crates/env/src/api.rs | 6 +++--- crates/env/src/backend.rs | 6 +++--- crates/ink/src/env_access.rs | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/crates/env/src/api.rs b/crates/env/src/api.rs index 12c4393a55b..a64c58cdd44 100644 --- a/crates/env/src/api.rs +++ b/crates/env/src/api.rs @@ -99,14 +99,14 @@ pub fn gas_left() -> u64 { ::on_instance(TypedEnvBackend::gas_left) } -/// Returns the total size of the contract call input data. +/// Returns the total size of the contract call input data, akin to the EVM /// [CALLDATASIZE](https://www.evm.codes/?fork=cancun#36) opcode. pub fn call_data_size() -> u64 { ::on_instance(TypedEnvBackend::call_data_size) } -/// Returns the size of the returned data of the last contract call or instantiation. -/// [RETURNDATASIZE](https://www.evm.codes/?fork=cancun#3d) opcode. +/// Returns the size of the returned data of the last contract call or instantiation, +/// akin to the EVM [RETURNDATASIZE](https://www.evm.codes/?fork=cancun#3d) opcode. pub fn return_data_size() -> u64 { ::on_instance(TypedEnvBackend::return_data_size) } diff --git a/crates/env/src/backend.rs b/crates/env/src/backend.rs index 2bea27b4cd4..a9b695abb51 100644 --- a/crates/env/src/backend.rs +++ b/crates/env/src/backend.rs @@ -231,7 +231,7 @@ pub trait TypedEnvBackend: EnvBackend { fn caller(&mut self) -> Address; /// Returns the block's `ref_time` limit. - /// [GASLIMIT](https://www.evm.codes/?fork=cancun#45) opcode. + /// This is akin to the EVM [GASLIMIT](https://www.evm.codes/?fork=cancun#45) opcode. /// /// # Note /// @@ -259,7 +259,7 @@ pub trait TypedEnvBackend: EnvBackend { fn gas_left(&mut self) -> u64; /// Returns the total size of the contract call input data. - /// [CALLDATASIZE](https://www.evm.codes/?fork=cancun#36) opcode. + /// This is akin to the EVM [CALLDATASIZE](https://www.evm.codes/?fork=cancun#36) opcode. /// /// # Note /// @@ -267,7 +267,7 @@ pub trait TypedEnvBackend: EnvBackend { fn call_data_size(&mut self) -> u64; /// Returns the size of the returned data of the last contract call or instantiation. - /// [RETURNDATASIZE](https://www.evm.codes/?fork=cancun#3d) opcode. + /// This is akin to the EVM [RETURNDATASIZE](https://www.evm.codes/?fork=cancun#3d) opcode. /// /// # Note /// diff --git a/crates/ink/src/env_access.rs b/crates/ink/src/env_access.rs index 0b5c47f6e23..81866edf60a 100644 --- a/crates/ink/src/env_access.rs +++ b/crates/ink/src/env_access.rs @@ -110,7 +110,7 @@ where ink_env::caller() } - /// Returns the block's `ref_time` limit. + /// Returns the block's `ref_time` limit, akin to the EVM /// [GASLIMIT](https://www.evm.codes/?fork=cancun#45) opcode. /// /// # Example @@ -211,7 +211,7 @@ where } /// Returns the total size of the contract call input data. - /// [CALLDATASIZE](https://www.evm.codes/?fork=cancun#36) opcode. + /// This is akin to the EVM [CALLDATASIZE](https://www.evm.codes/?fork=cancun#36) opcode. /// /// # Example /// @@ -243,7 +243,7 @@ where } /// Returns the size of the returned data of the last contract call or instantiation. - /// [RETURNDATASIZE](https://www.evm.codes/?fork=cancun#3d) opcode. + /// This is akin to the EVM [RETURNDATASIZE](https://www.evm.codes/?fork=cancun#3d) opcode. /// /// # Example ///