Skip to content

v5.0.0

Latest
Compare
Choose a tag to compare
@SkymanOne SkymanOne released this 13 Mar 10:21
· 128 commits to master since this release
v5.0.0
1645903

ℹ️ We have created a migration guide from ink! 4 to ink! 5. It also contains an overview over all breaking changes and newly added features.
You can view it here.

Summary

This release addresses the rest of the severities described in the OpenZeppelin security review 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 and #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 and #2031.
  • @pmikolajczyk41 has introduced an alternative E2E testing framework, DRink!, 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 and #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.
  • 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.

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
the development of new ink! contracts.

Compatibility

See the compatibility section 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. But if using the new functions introduced in #2123 and #2077 >= 1.8.0 and if using the new functions introduced in #2076 >= 1.9.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
  • instantiate_v2 with additional limit parameters #2123
  • Custom signature topic in Events - #2031
  • [Linter] non_fallible_api lint - #2004
  • [Linter] Publish the linting crates on crates.io - #2060
  • [E2E] Added create_call_builder for testing existing contracts - #2075
  • call_v2 cross-contract calls with additional limit parameters - #2077
  • delegate_dependency api calls - #2076
  • Allow mutable parameters in messages - #2004
  • Clean E2E configuration parsing - #1922
  • Make set_code_hash generic - #1906
  • Provide a StorageVec datastructure built on top of Lazy - #1995
  • Add fallible methods for Mapping and Lazy - #1910
  • [E2E] Allow testing with live-chain state - #1949
  • [E2E] Call builders and extra gas margin option - #1917
  • [Linter] storage_never_freed lint - #1932
  • [Linter] strict_balance_equality lint - #1914
  • [Linter] no_main lint - #2001
  • Reexport scale dependencies, introduce #[ink::scale_derive] - #1890
  • Upgradeable contracts example - #1889
  • Persist static buffer size in metadata - #1880
  • Modify static buffer size via environmental variables - #1869
  • Added sr25519_verify function to ink_env #1840
  • Events 2.0 - #1827
  • Add set_block_number to off-chain test api Engine - #1806
  • Stabilize call_runtime#1749
  • Schema generation - #1765
  • Restrict wildcard selectors to have exactly one other message - #1708
  • [Linter] Warn when primitive number is annotated as event topic - #1837
  • [Drink backend] allow for arbitrary runtime - #1892
  • [Drink backend] support runtime call - #1891
  • [Drink backend] Make tests generic E2EBackend trait - #1867
  • [Drink backend] Backend choice ‒ #1864
  • [Drink backend] Backend traits - #1857
  • [Drink backend] Abstract error and result structs - #1844

Changed

  • Use name-only syntax for anonymous ink! event item configuration argument - #2140
  • Restrict syntax for setting default ink! e2e test runtime-only emulator - #2143
  • Restrict syntax for setting ink! e2e test node to auto - #2146
  • Bump Substrate crates - #2141
  • Minor fixes - #2144,
    #2137, #2132
  • Bump metadata version to 5 #2126
  • Use MaxEncodedLen for output buffer size #2128
  • Mapping: Reflect all possible failure cases in comments ‒ #2079
  • [E2E] Rename .call to .call_builder#2078
  • Improve syntax for ink! e2e runtime_only attribute argument - #2083
  • [E2E] Remove additional_contracts parameter #2098
  • [E2E] change node url backend config - #2101
  • Messages return TypeSpec directly - #1999
  • Fail when decoding from storage and not all bytes consumed - #1897
  • Support multiple chain extensions - #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
  • [E2E] resolve DispatchError error details for dry-runs - #1994
  • [E2E] update to new drink API - #2005
  • Reexport scale dependencies, introduce #[ink::scale_derive]#1890
  • Use of workspace dependencies and properties - #1835
  • Remove of unchecked arithmetic - #1831
  • Use decode_all for decoding cross contract call result - #1810
  • [E2E] build contracts at runtime instead of during codegen - #1881
  • [E2E] crate refactoring - #1830
  • [E2E] improve call API, remove build_message + callback - #1782

Fixed

  • Fix alignment in allocator #2100
  • Fix the StorageVec type by excluding the len_cached field from its type info - #2052
  • Fix panic in approve_for in the ERC-721 example - #2092
  • ERC-721: transfer_token_from now ensures the token owner is correct - #2093
  • RootLayout::new() is generic again to allow using ink_metadata in pure PortableForm contexts - #1989