near/nearcore

WebAssembly contracts built with the Rust toolchain 1.70 or later cannot be deployed

nagisa opened this issue · 4 comments

nagisa commented

If you attempt to deploy a contract built with the Rust toolchain version 1.70 or later the deployment of the contract will likely fail with an error message along the lines of "deserialize".

This is because in Rust 1.70 the version of LLVM was upgraded to 16.0 series, and in this version of LLVM a WebAssembly proposal – sign extensions – was enabled by default. This proposal has introduced new instructions that aren't supported by the NEAR protocol contract runtime at this point in time. Whenever these instructions occur in the deployed WebAssembly module, the deployment will immediately fail.

There are a couple of approaches you can take in order to maintain the contract in a deployable state:

  1. Use Rust toolchain 1.69 or earlier;
  2. If you must use the Rust toolchain 1.70 or later, use a nightly toolchain and adjust the build command in one of the following ways (note the RUSTFLAGS environment variable and the -Zbuild-std cargo flag):
    • env RUSTFLAGS='-Ctarget-cpu=mvp' cargo build -Zbuild-std=panic_abort,std ...; or
    • env RUSTFLAGS='-Ctarget-feature=-sign-ext' cargo build -Zbuild-std=panic_abort,std ....
nagisa commented

NB: when the network deploys 1.35 and votes on the new protocol version the deploys should start working again.

Integration tests fail as well with rustc 1.70, so workspace-rs will have to be updated.

NB: when the network deploys 1.35 and votes on the new protocol version the deploys should start working again.

How can i know more about it? as far as i can see the 1.35 rc1 build has been released and the voting was expected to start on 27th. How can i know the outcome of the voting?

nagisa commented

The protocol upgrade has happened, so this should be resolved now. Your contracts built with newer versions of the Rust toolchain should work just fine.