Skip to content

Contract compiled with Rust 1.70.0 not working #2009

@think-in-universe

Description

@think-in-universe

Problem

After creating a new Rust contract with create-near-app with latest Rust version 1.70.0, and following the steps to deploy contract, developer failed to view function with near view <dev-account> get_greeting.

This issue is reported by developers in community who are learning how to build on NEAR today.

How to Reproduce

(1) Install the latest Rust version 1.70.0. For example,

stable-x86_64-unknown-linux-gnu (default)
rustc 1.70.0 (90c541806 2023-05-31)

(2) Create a new project with create-near-app command

npx create-near-app my-project --contract rust --frontend none --tests rust

(3) Deploy contract to testnet

cd ./my-project
npm i
npm run deploy

(4) View call function get_greeting

near view <dev-account> get_greeting

View call failed and you'll encounter the error as below.

$ near view dev-1685967486834-62115280035912 get_greeting
View call: dev-1685967486834-62115280035912.get_greeting()
An error occured
Error: Querying [object Object] failed: wasm execution failed with error: CompilationError(PrepareError(Deserialization)).
{
  "block_hash": "5cdGPvRvN8JGKs7AfEPjVJaoVZjhhS35H1WgxrvxmNXR",
  "block_height": 128323323,
  "error": "wasm execution failed with error: CompilationError(PrepareError(Deserialization))",
  "logs": []
}
    at JsonRpcProvider.query (/usr/local/share/nvm/versions/node/v19.9.0/lib/node_modules/near-cli/node_modules/near-api-js/lib/providers/json-rpc-provider.js:123:19)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Account.viewFunction (/usr/local/share/nvm/versions/node/v19.9.0/lib/node_modules/near-cli/node_modules/near-api-js/lib/account.js:366:24)
    at async exports.callViewFunction (/usr/local/share/nvm/versions/node/v19.9.0/lib/node_modules/near-cli/index.js:103:48)
    at async Object.handler (/usr/local/share/nvm/versions/node/v19.9.0/lib/node_modules/near-cli/utils/exit-on-error.js:52:9)
TypedError: Querying [object Object] failed: wasm execution failed with error: CompilationError(PrepareError(Deserialization)).
{
  "block_hash": "5cdGPvRvN8JGKs7AfEPjVJaoVZjhhS35H1WgxrvxmNXR",
  "block_height": 128323323,
  "error": "wasm execution failed with error: CompilationError(PrepareError(Deserialization))",
  "logs": []
}
    at JsonRpcProvider.query (/usr/local/share/nvm/versions/node/v19.9.0/lib/node_modules/near-cli/node_modules/near-api-js/lib/providers/json-rpc-provider.js:123:19)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Account.viewFunction (/usr/local/share/nvm/versions/node/v19.9.0/lib/node_modules/near-cli/node_modules/near-api-js/lib/account.js:366:24)
    at async exports.callViewFunction (/usr/local/share/nvm/versions/node/v19.9.0/lib/node_modules/near-cli/index.js:103:48)
    at async Object.handler (/usr/local/share/nvm/versions/node/v19.9.0/lib/node_modules/near-cli/utils/exit-on-error.js:52:9) {
  type: 'UntypedError',
  context: undefined
}

Notes

This is probably a compatibility issue of Rust SDK 4.0.0 with Rust 1.70.0.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions