4

Ink! 3.1.0 has been released today, and it seems that it has been automatically embed/used in the cargo-contract command. The result is that newly compiled contract are no more compatible with node that run 3.0 contracts pallet.

Is there a way to keep version 3.0.1 when compiling ink! contracts ?

Thanks for your help !

Edit : found the -Z original-manifest cargo-contract option that preserves cargo.toml versions values :)
But the build failed at the metadata generation...

Steps to reproduce:

  • Download and uncompress precompile contract node v0.13
  • Launch dev node :
./substrate-contracts-node-v0.13 --dev
  • Build flipper contract sample :
cargo contract new flipper
cd flipper
cargo +nightly contract build
  • Use Contracts UI to instantiate the flipper contract
  • Instantiation failed with 'ExtrinsicFailed'
  • Debug log shows :
DEBUG ThreadId(46) runtime::contracts: CodeRejected: module imports a
  non-existent function

Same contract is instantiated correctly on recent contracts node v0.14 and v0.15.

Same flipper contract built a few days before (using ink! 3.0.1), instantiation is correct on v0.13.

I saw that upgrading my node version to polkadot v0.9.22 should resolve this issue. But the cumulus pallet is still on polkadot v0.9.20.

That's why I asked initially how to stick to ink! 3.0.1 when compiling contract.

2
  • Can you please include more details about how you set up your project and the specific error you are facing?
    – Shawn Tabrizi
    May 18, 2022 at 22:51
  • Thanks @ShawnTabrizi and Alexander, I just added some informations.
    – LaurentTrk
    May 18, 2022 at 23:00

5 Answers 5

5

Could you try hardcoding version = "=3.0.1"?

The "=x.x.x" will pin this very version.

5
  • 1
    You're the boss @cmichi ! With version = "=3.0.1", contract are instantiated correctly in node v0.13. Thanks for your help.
    – LaurentTrk
    May 19, 2022 at 6:00
  • 1
    Just want to add that I experienced the same issue (trying to deploy other example contracts) and it was solved as @cmichi said.
    – Iker
    May 24, 2022 at 8:29
  • @cmichi weirdly I am getting error[E0061]: this function takes 2 arguments but 1 argument was supplied, an argument of type ExecuteConstructorConfig is missing on constructors using version = "=3.0.1"
    – mastro
    May 26, 2022 at 8:59
  • 1
    others are experiencing same issue: substrate.stackexchange.com/questions/2870/…
    – mastro
    May 26, 2022 at 9:44
  • Add one more dependency in Cargo.toml ink_lang_codegen = { version = "=3.0.1", default-features = false } Jun 16, 2022 at 4:25
2

Thanks for the issue reporting! Its origin is that with ink! 3.1.0 a number of backwards incompatible changes were introduced. That unpleasant mistake is now fixed and with ink! 3.3.0 release being published everything should work smoothly again even for contracts using ink! 3.0.1.

1

There is a lot of transitive dependencies (pallets that ink pallets themselves depend on), as you can check by inspecting Cargo.lock - it will pull the most recent versions for those (3.2.0 as of now). That is because for the Cargo resolver these are within the semver compatibility range (when in fact they are not compatible, they contain non-compatible, breaking changes).

For now you might try to explicitely lock the version of ink_lang_codegen too.

1
  • Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
    – Community Bot
    Jun 6, 2022 at 10:44
0

Have you tried to hardcode version = "3.0.1" in all ink_* dependencies in your contract's Cargo.toml file?

3
  • Thanks Artur, that's what I did, but no luck... The first step of the build (1/5 dev [unoptimized + debuginfo]) is using 3.0.1, but the release build (2/5) is using 3.1.0.
    – LaurentTrk
    May 18, 2022 at 21:03
  • Please add a link in your original posting to the repo which you try to compile. Can't really help without the code. May 18, 2022 at 21:36
  • Could you try hardcoding version = "=3.0.1" in your Cargo.toml? The "=x.x.x" will pin this very version.
    – cmichi
    May 19, 2022 at 4:10
0

I received this error and was able to get rid of it by upgrading the substrate contracts node from 0.12.0 to 0.14.0.

Here's a more detailed view of my setup in an issue on github

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.