Releases: use-ink/ink
v4.0.1
v4.0.0
Version 4.0.0
The latest stable release of ink! is here 🥳
This version brings a lot of usability improvements, making the language better suited 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
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).
You may notice there have been a few breaking changes. No need to be scared though, we wrote up a migration guide covering all of the breaking changes and how to update your ink! 3.x contract accordingly.
Thanks to everyone that helped make this release possible ❤️
Compatibility
In order to build contracts which use ink! v4.0.0
you need to use cargo-contract
v2.0.0
. You can install it as follows:
cargo install cargo-contract --forced --locked
You will also need to use a version of pallet-contracts
later than polkadot-v0.9.37 in your node.
The v0.24.0
release of the substrate-contracts-node
is compatible with the ink! 4.0.0
release.
For full compatibility requirements see the migration guide.
Added
- Add
Mapping::contains(key)
andMapping::insert_return_size(key, val)
‒ #1224 - Add
payment-channel
example ‒ #1248 (thanks @kanishkatn!) - Add
version
field to ink! metadata ‒ #1313 - The
rand-extension
example has been adapted to an updated version of theChainExtension
API ‒ #1356 - Add
ink_env::pay_with_call!
helper macro for off-chain emulation of sending payments with contract message calls ‒ #1379 - Allow using
Result<Self, Error>
as a return type in constructors ‒ #1446 - Add
Mapping::take()
function allowing to get a value removing it from storage ‒ #1461 - Add E2E testing framework MVP ‒ #1395
- Add E2E tests for
Mapping
functions - #1492 - E2E: expose call dry-run method ‒ #1624
- Make cross-contract callee non-optional ‒ #1636
- Support custom environment in E2E tests - #1645 (thanks @pmikolajczyk41!)
Changed
- Contract size optimization in case contract doesn't accept payment ‒ #1267 (thanks @xgreenx!)
- Move ink! linter into
ink
repository ‒ #1361 - Introduce
ink
entrance crate ‒ #1223 - Use
XXH32
instead ofsha256
for calculating storage keys ‒ #1393 - Storage Refactoring ‒ #1331
- Add support for language level errors (
LangError
) ‒ #1450 - Return
LangError
s from constructors ‒ #1504 - Update
scale-info
requirement to2.3
‒ #1467 - Merge
Mapping::insert(key, val)
andMapping::insert_return_size(key, val)
into one method - #1463 - FFI: no more
__unstable__
wasm import module ‒ #1522 - Clean up CallBuilder
return()
type ‒ #1525 - Fix trait message return type metadata ‒ #1531
- Bump Dylint dependencies ‒ #1551
- Stabilize
take_storage
‒ #1568 - Chain Extension: Evaluation of method return type at compile time ‒ #1569
- Make more functions be const ‒ #1574 (thanks @yjhmelody!)
- Unify fallible and non fallible
instantiate
methods ‒ #1591 - Make
CallBuilder
andCreateBuilder
error handling optional ‒ #1602 - Rename
CallBuilder::fire()
method toinvoke()
‒ #1604 - chore: add minimum rust version to the ink crate ‒ #1609 (thanks @Kurtsley!)
- Rename
_checked
codegen call methods withtry_
‒ #1621 - Bump Substrate and
subxt
dependencies ‒ #1549 - E2E: spawn a separate contracts node instance per test ‒ #1642
Fixed
- Trim single whitespace prefix in the metadata
docs
field ‒ #1385 - Allow pay_with_call to take multiple arguments ‒ #1401
- Add Determinism enum from pallet-contracts ‒ #1547
- Added missed
WhereClosure
for the generics intostorage_item
‒ #1536 (thanks @xgreenx!)
Removed
v4.0.0-rc
The first release candidate is here! This is the first release which could become the final
v4.0.0
. Any subsequent release candidates should only contain bug fixes: no API changes,
breaking or otherwise.
Breaking Changes
- We've renamed some of the generated message methods on the
ContractRef
struct. They
have been changed from_checked
totry_
(#1621) - We have removed the
Default
implementation forAccountId
s. This is because of
security concerns around the use of the zero address which has a known private key in
thesr25519
anded25519
curves (#1255). - We have replaced the
CallBuilder::callee()
method with acall()
method and also
added adelegate()
method. This streamlines theCall
andDelegateCall
workflows
(#1636)
Added
Changed
- Rename
_checked
codegen call methods withtry_
‒ #1621 - Bump Substrate and
subxt
dependencies ‒ #1549
Removed
- Remove
Default
implementation for AccountId ‒ #1255
v4.0.0-beta.1
This supersedes #1590, but RC coming soon™
Version 4.0.0-beta.1
The coolest feature included in this release is the first first published version of
ink!'s native "end-to-end" (E2E) testing framework.
This enables testing of a contract by deploying and calling it on a Substrate node with
pallet-contracts
. See the erc20
example for usage.
Breaking Changes
This release includes a couple of breaking changes.
- The
CallBuilder::returns()
method does not require an extraMessageResult
anymore
as the type is now added under the hood (#1525) - The
CallBuilder::invoke()
andCreateBuilder::instantiate()
methods now unwrap the
Result
frompallet-contracts
under the hood (#1602)
If you wish to handle the error use the newtry_
variants of those methods instead. - The
CallBuilder::fire()
method has been renamed toinvoke()
(#1604) - The
returns_result
flag has been removed from the#[ink(extension = …)]
attribute
(#1569)
We now infer this information at compile time. Ifhandle_status
is set totrue
,
the return type will still be wrapped intoResult
as before. - The Minimum Supported Rust Version (MSRV) has been set to
1.63.0
. This was already
the case, but previously it was enforced bycargo-contract
instead of ink!
(#1609)
Added
Fixed
- Add Determinism enum from pallet-contracts ‒ #1547
- Added missed
WhereClosure
for the generics intostorage_item
‒ #1536 (thanks @xgreenx)
Changed
- Handle
LangError
from instantiate ‒ #1512 - FFI: no more
__unstable__
wasm import module ‒ #1522 - Clean up CallBuilder
return()
type ‒ #1525 - Fix trait message return type metadata ‒ #1531
- Bump Dylint dependencies ‒ #1551
- Stabilize
take_storage
‒ #1568 - Chain Extension: Evaluation of method return type at compile time ‒ #1569
- Make more functions be const ‒ #1574 (thanks @yjhmelody)
- Unify fallible and non fallible
instantiate
methods ‒ #1591 - Make
CallBuilder
andCreateBuilder
error handling optional ‒ #1602 - Rename
CallBuilder::fire()
method toinvoke()
‒ #1604 - chore: add minimum rust version to the ink crate ‒ #1609 (thanks @Kurtsley)
v4.0.0-beta
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
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
.
You can install it as follows:
cargo install cargo-contract --version 2.0.0-beta
You will also need to use a version of pallet-contracts
later than 265e3f1 (Nov 3, 2022)
in your node.
The v0.22.1
release of the substrate-contracts-node
is
compatible with the ink! 4.0.0-beta
release.
Breaking Changes
Constructors and Messages now return LangError
s
We have added a way to handle errors that are neither specific to a particular contract,
nor from the underlying execution environment (e.g pallet-contracts
). Instead these are
errors that may come from the smart contracting language itself.
For example, take the case where a contract message is called using an invalid selector.
This is not something a smart contract author should need to define as failure case, nor
is it something that the Contracts pallet needs to be aware of.
Previously, the contract execution would trap if an invalid selector was used, leaving
callers with no way to handle the error gracefully. This can now be handled with the help
of the newly added LangError
.
In short, this change means that all ink! messages and constructors now return a
Result<R, LangError>
, where R
is the original return type. Contract callers can
choose to handle the LangError
.
In order to make this error compatible with other languages we have also added a
lang_error
field to the metadata format. This will be the central registry of all the
different error variants which languages may want to emit in the future.
Related pull-requests:
Related discussions:
Random function removed
We had to remove ink_env::random
with #1442.
This function allowed contract developers getting random entropy.
There is unfortunately no way how this can be done safely enough
with built-in Substrate primitives on-chain currently. We're
following the recommendation of our auditors to remove it.
The alternative right now is to provide random entropy off-chain to
the contract, to use a random entropy oracle, or to have a chain-extension
that does this, in case the chain has a possibility to do so.
We hope to bring this function back in a future release of ink!, the
best hope right now is that it could come back with Sassafras, a block production
protocol for future versions of Polkadot.
Added
- Allow using
Result<Self, Error>
as a return type in constructors ‒ #1446 - Add
Mapping::take()
function allowing to get a value removing it from storage ‒ #1461
Changed
- Add support for language level errors (
LangError
) ‒ #1450 - Return
LangError
s from constructors ‒ #1504 - Update
scale-info
requirement to2.3
‒ #1467 - Merge
Mapping::insert(key, val)
andMapping::insert_return_size(key, val)
into one method - #1463
Removed
- Remove
ink_env::random
function ‒ #1442
v3.4.0
Version 3.4.0
We keep ink! v3 updated with nice features and fixes from the master
branch.
This release:
- Introduces the
ink_env::pay_with_call!
helper macro for the emulation of invoking payble messages in off-chain tests.
As response to ink! developers request on the Substrate StackExchange. - Fixes contracts compilation error with the latest Rust
+nightly
‒ #1417 (thanks @xgreenx).
See the back portation PR #1439 for details.
v4.0.0-alpha.3
4.0.0-alpha.2 was skipped because of an error in the release process
Breaking Changes
New ink
crate
The ink_lang
crate has been replaced in #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 individualink_*
crate dependencies with theink
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
.
- Remove the commonly used
Storage Rework
#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 withMapping::default()
instead ofink_lang::utils::initialize_contract
in
constructors. Seeerc20
and other examples which use aMapping
. - Remove
SpreadAllocate
,SpreadLayout
andPackedLayout
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 - Use
XXH32
instead ofsha256
for calculating storage keys ‒ #1393
Fixed
- Trim single whitespace prefix in the metadata
docs
field ‒ #1385 - Allow pay_with_call to take multiple arguments ‒ #1401
Added
- Add
ink_env::pay_with_call!
helper macro for off-chain emulation of sending payments with contract message calls ‒ #1379
Removed
- Remove
wee-alloc
‒ #1403
v4.0.0-alpha.1
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
. You can install it as follows:
cargo install cargo-contract --version 2.0.0-alpha.1
We recommend using a version of the pallet-contracts
later than 6b85535
(Aug 12, 2022) in your node.
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 ❌ emoji.
Most of these were intitially introduced in v3.1.0
and v3.2.0
releases but
compatibility was restored in v3.3.0
.
- As part of #1224 the return type of
ink_env::set_contract_storage()
was changed to
return anOption<u32>
instead of()
. - As part of #1233 the
eth_compatibility
crate was removed. The
ecdsa_to_eth_address()
function from it can now be found in theink_env
crate. - As part of #1267 an argument to
ink_lang::codegen::execute_constructor()
(which is
used internally by the ink! macros) was removed. - As part of #1313 the ink! ABI was changed so that the version was specified using a
dedicatedversion
key instead of an implicit key which wrapped the entire ABI.
Added
- ❌ Add
Mapping::contains(key)
andMapping::insert_return_size(key, val)
‒ #1224 - Add
payment-channel
example ‒ #1248 - ❌ Add
version
field to ink! metadata ‒ #1313 - The
rand-extension
example has been adapted to an updated version of theChainExtension
API ‒ #1356
Changed
- ❌ Contract size optimization in case contract doesn't accept payment ‒ #1267 (thanks @xgreenx).
- Move ink! linter into
ink
repository ‒ #1361
Removed
- ❌ Implement ecdsa_to_eth_address() and remove eth_compatibility crate ‒ #1233
v3.3.1
Version 3.3.1
At the moment teams which use both Substrate and ink! in the same codebase are
experiencing some issues with updating to Substrate's polkadot-0.9.27
branch.
This is because that branch uses the secp256k1@0.24
, which is incompatible with
secp256k1@0.22
This release bumps the secp256k1
version from v0.22
to v0.24
.
v3.3.0
Version 3.3.0
This release restores SemVer compatibility in the v3.x
series of releases, as well as compatibility with the v0.13.0
release of the substrate-contracts-node
.
Compatibility
This version will work fine with substrate-contracts-node versions from 0.13.0 up to 0.16.0.
Changed
Context: user-reported issues on our SE unveiled backward incompatibility introduced in 3.1.0 release.
The following has been done to restore backward compatibility:
- Reverted backward-incompatible piece of #1224.
- The return signature of
ink_env::set_contract_storage()
was changed to return anOption<u32>
.
This could have broken existing code, so this should've been done in aMAJOR
release. - Under the hood the PR also changed
Mapping::insert()
to use a new SEAL API
([seal1] seal_set_storage
), which resulted inCodeRejected
errors in nodes which did not have this API (e.gsubstrate-contracts-node@0.13.0
).
- The return signature of
- Reverted "Optimise deny_payment. Use everywhere semantic of deny (#1267)"
- Reverted backward-incompatible piece of #1233.
- The removal of the
eth_compatibility
crate should have been done in aMAJOR
release.
- The removal of the
All these breaking changes are subjects to the upcoming MAJOR ink! release 4.0.0.