Releases: use-ink/cargo-contract
v6.0.0-alpha
This is our first alpha release for cargo-contract
v6. We release it together
with ink! v6.0.0-alpha
.
The biggest change is that we are in the process of migrating from pallet-contracts
+
WebAssembly (executed in wasmi
) to pallet-revive
+
RISC-V (executed in PolkaVM).
This is a major breaking change, cargo-contract
will only be compatible with ink! >= v6
and chains that include pallet-revive
.
We did a detailed write-up of the background to this development and the reasoning
here.
Compatibility of this release:
- ink!
v6.0.0-alpha
substrate-contracts-node/9c020a2
polkadot-sdk/f8c90b2a01ec77579bccd21ae17bd6ff2eeffd6a
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
support as the number one priority. All their design decisions derive from that,
they don't want to maintain code that is unnecessary for that objective.
Updated structs + function arguments
We had to change a number of structs and function arguments. Some notable ones:
SourceWasm -> SourceContractBytecode
dest_wasm -> dest_polkavm
optimization_result -> linker_size_result
And v5 ExecuteArgs
→
v6.0.0-alpha ExecuteArgs
.
We won't describe the other ones here. The best course is to see if you encounter
compilation errors upon upgrading to 6.0.0-alpha. If so, please check our Rust
docs or the cargo-contract
source code for how the new format looks and what
the comments say.
The commit that applied the majority of naming changes was
this one.
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 theink::Environment::Balance
type. - or a hardcoded
U256
(which corresponds to what Ethereum uses).
In this alpha release we just adhere to requiring the types thatpallet-revive
uses.
In an upcoming beta release this could be simplified to reduce UX friction by just
using one type everywhere and converting to thepallet-revive
one.
Contract Address: H160
For a contract's account, pallet-revive
is using either the configured AccountId
type
of the polkadot-sdk
runtime, or H160
.
Finding the H160
for an AccountId
is done via an address derivation scheme derived in
#7662.
After instantiating a contract, the address is no longer returned by pallet-revive
.
Instead one has to derive it from given parameters (see the linked PR). cargo-contract
does that automatically.
For contract instantiations and contract calls the pallet requires that a 1-to-1 mapping
of an AccountId
to a H160
has been created. This can be done via the map_account
/
unmap_account
API.
The PR #6096 contains more
information.
Besides the publicly exposed crate functions, we've introduced a new subcommand
cargo contract account
that allows resolving the H160
contract address to the
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 H160
.
Events
In #7164, Parity removed
most smart-contract-specific events: Called
, ContractCodeUpdated, CodeStored
,
CodeRemoved
, Terminated
, Instantiated
, DelegateCalled
,
StorageDepositTransferredAndHeld
, StorageDepositTransferredAndReleased
.
The ContractEmitted
event (for events a contract emits) is still available.
Debugging
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
info to this field. This functionality has been removed. Instead pallet-revive
now
supports other means of debugging.
The most relevant for this release is the tracing API. There are a number of PRs
that implemented it, so we won't link a specific one here. A good starting point
to look deeper into it is the tracing.rs
.
We have implemented barebones support for this tracing API in the 6.0.0-alpha
versions of ink! + cargo-contract
. But it's really barebones and should
certainly be improved before a production release.
Detection of contract language disabled
The heuristic detection of a contract's language in cargo contract info
has been temporarily disabled; it's not yet implemented.
Contract sizes
Contracts compiled with v6.0.0-alpha
will have a large file size. This is due to a number
of bugs in PolkaVM that prohibit us from using e.g. LTO. The contract sizes will eventually
get much smaller again, once those bugs are fixed.
Linting
Linting of a contract can be executed by running the lint
command:
➜ cargo contract lint --help
Lint a contract
Usage: cargo contract lint [OPTIONS]
Options:
--manifest-path <MANIFEST_PATH>
Path to the `Cargo.toml` of the contract to build
--quiet
No output printed to stdout
--verbose
Use verbose output
--extra-lints
Performs extra linting checks during the build process. Basic clippy lints are deemed important and run anyway.
-h, --help
Print help (see a summary with '-h')
Or can be executed programmatically:
let crate_metadata = CrateMetadata::collect(manifest_path)?;
let verbosity = TryFrom::<&VerbosityFlags>::try_from(&self.verbosity)?;
contract_build::lint(extra_lint, &crate_metadata, &verbosity);
Please see #2013 for more information.
Ability to generate Solidity metadata for a contract
ink! v6 will have the ability to speak Solidity, you'll be able to integrate
with tools like Metamask and call ink! contracts from Solidity as if they were
a pre-compile.
We added a new subcommand for this:
cargo contract build ---metadata <ink|solidity>
Please see #1930 for more information.
Changed
- Target
pallet-revive
instead ofpallet-contracts
- #1851 - Retrieve PolkaVM target spec from linker - #1939
Added
- Add option to generate Solidity compatible metadata (via
cargo contract build ---metadata <ink|solidity>
) - #1930 - Deny overflowing (and lossy) integer type cast operations - #1895
- Remove linting by default,
--skip-linting
and--lint
flag incargo contract build
and add a new commandlint
- #2013
Fixed
- Resolved verifiable-build image failures within
release-verifiable-image
workflow - #2018
v5.0.3
v5.0.2
v5.0.1
v5.0.0
This release concludes the migration of ink! from Parity to the outside world. It doesn't come with any new features, we just:
- …changed the Parity URLs to ones for our new GitHub organization
@use-ink. - …upgraded many dependencies to newer versions, which results in two particular
breaking changes regarding compatibility:- We had to remove support for Substrate metadata that is below
V14
in #1722. Metadata formats belowV14
are quite old and we hope this doesn't affect anyone. cargo-contract
v5 works only with Rust >= 1.81.
- We had to remove support for Substrate metadata that is below
For the linter in cargo-contract
the Rust toolchain version changed. To upgrade:
export TOOLCHAIN_VERSION=nightly-2024-09-05
rustup install $TOOLCHAIN_VERSION
rustup component add rust-src --toolchain $TOOLCHAIN_VERSION
rustup run $TOOLCHAIN_VERSION cargo install cargo-dylint dylint-link
Changed
- Updated the toolchain version used by
ink_linting
- #1616 - Update repository URLs & references from
paritytech
GitHub organization to newuse-ink
one ‒ #1663 - Bump the version of
subxt
andsubxt-signer
- #1722
Removed
- Remove support for
V11
metadata #1722
v4.1.3
v4.1.2
v5.0.0-alpha
What's Changed
Fixed
- Remove parity-wasm dependency from contract-build crate - #1594
- chore: Update toolchain for
ink_linting
- #1616 - chore: bump
subxt
andsubxt-signer
versions - #1722
Added
- Add support for cargo build --verifiable --lint command - #1512
- Add new image deployment repo - #1620
- Switch to useink image in verifiable build command - #1622
Full Changelog: v4.1.1...v5.0.0-alpha