near / near-workspaces-js

Write tests once, run them both on NEAR TestNet and a controlled NEAR Sandbox local environment
https://near.github.io/near-workspaces-js/
GNU General Public License v3.0
42 stars 22 forks source link

Contract fails with error `{"CompilationError":{"PrepareError":"Deserialization"}}}` #225

Closed fadeevab closed 5 months ago

fadeevab commented 7 months ago

I'm trying to build, deploy, and run a simple project (https://github.com/NEARFoundation/near-smart-contract-rust-template) on near-workspaces JS.

Deployment code snippet:

  // Deploy passes successfully
  const contract = await root.devDeploy(config.wasmPath, {
    initialBalance: NEAR.parse('30 N').toJSON(),
  });

  // Throws an ERROR
  await owner.call(contract, 'new', { owner_id: owner.accountId });

I get the following error on a function call:

Click me for more error logs ```json "result": { "receipts_outcome": [ { "block_hash": "3zbHTEui45Hf9WJCh5yw6UN7PDw2Exb4VJeTRfbhYLZJ", "id": "BjooygTASH8QEazVHx1buA2QWY2QEzzXvG7nupZeqRfn", "outcome": { "executor_id": "dev-83854-55840.test.near", "gas_burnt": 2427994785822, "logs": [], "metadata": { "gas_profile": [], "version": 1 }, "receipt_ids": [ "4JNTEHbG2q3U4qfGNQ7euTpQkrk68jr8CWDYCAhjB8nd" ], "status": { "Failure": { "ActionError": { "index": 0, "kind": { "FunctionCallError": { "CompilationError": { "PrepareError": "Deserialization" } } } } } }, "tokens_burnt": "242799478582200000000" }, "proof": [] }, { "block_hash": "9kAMfdUEKhSyy71pvT3Fdp3AtUjs3erV9H6jb6siTZZb", "id": "4JNTEHbG2q3U4qfGNQ7euTpQkrk68jr8CWDYCAhjB8nd", "outcome": { "executor_id": "owner.test.near", "gas_burnt": 223182562500, "logs": [], "metadata": { "gas_profile": [], "version": 1 }, "receipt_ids": [], "status": { "SuccessValue": "" }, "tokens_burnt": "0" }, "proof": [] } ], "status": { "Failure": { "ActionError": { "index": 0, "kind": { "FunctionCallError": { "CompilationError": { "PrepareError": "Deserialization" } } } } } }, "transaction": { "actions": [ { "FunctionCall": { "args": "eyJvd25lcl9pZCI6Im93bmVyLnRlc3QubmVhciJ9", "deposit": "0", "gas": 30000000000000, "method_name": "new" } } ], "hash": "6ZmhkZAod8eStQdPEZEDPWaLp29yseeTXKVzP7u5hoqC", "nonce": 2000001, "public_key": "ed25519:6iS8Hs33NS2A4aph7u7qt7j3yq3qh15hFSaG1jEWYoqs", "receiver_id": "dev-83854-55840.test.near", "signature": "ed25519:3JG6Hts53K45G9TsZJcQjpeqERC2rAEryBBcrkMXeNRfCmMsgxxgUxtMpH6CYg93LeRVr52BrZbP6B8DypyVwzTk", "signer_id": "owner.test.near" }, "transaction_outcome": { "block_hash": "AJ6Vk6YSU2uYLTBzpmYLBBcN2HNR6ZW32SUTPuNZHwpT", "id": "6ZmhkZAod8eStQdPEZEDPWaLp29yseeTXKVzP7u5hoqC", "outcome": { "executor_id": "owner.test.near", "gas_burnt": 2427994785822, "logs": [], "metadata": { "gas_profile": null, "version": 1 }, "receipt_ids": [ "BjooygTASH8QEazVHx1buA2QWY2QEzzXvG7nupZeqRfn" ], "status": { "SuccessReceiptId": "BjooygTASH8QEazVHx1buA2QWY2QEzzXvG7nupZeqRfn" }, "tokens_burnt": "242799478582200000000" }, "proof": [] } }, "startMs": 1700296986086, "endMs": 1700296988632, "config": { "network": "sandbox", "rootAccountId": "test.near", "rpcAddr": "http://localhost:7433", "initialBalance": "100000000000000000000000000", "homeDir": "/tmp/sandbox/35b8fc25-8938-4a1b-b074-c7efe1382c5c", "port": 7433, "rm": false, "refDir": null } ```
"FunctionCallError": {
  "CompilationError": {
    "PrepareError": "Deserialization"
  }
}

Cargo.toml:

[package]
# ...

[dependencies]
near-contract-standards = "4.1.1"
near-sdk = "4.1.1"
near-sdk-contract-tools = "2.1.0"

[lib]
crate-type = ["cdylib"]

[profile.release]
codegen-units = 1
debug = false
lto = true
opt-level = "z"
overflow-checks = true
panic = "abort"

# ...

Toolchain versions I tried:

  1. 1.70
  2. 1.74

NOTE: near dev-deploy on the actual testnet works fine. NOTE2: Smart contract successfully deploys on the "near-sandbox": "^0.0.17".

tifrel commented 6 months ago

I would like to second this issue, however I tried every minor between 1.66.0 and 1.74.0. Also using near-sandbox 0.0.17 does not fix it for me.

None of these solutions seem to work for me.

tifrel commented 6 months ago

@fadeevab I just figured out that installing near-sandbox 0.0.17 leaves a copy of 0.0.14 in the node_modules of near-workspaces. Symlinking the latter to the former leaves me with a weird error in the beforeEach hook:

  Rejected promise returned by test. Reason:

  Error {
    code: null,
    signal: 'SIGABRT',
    stderr: `dyld: Symbol not found: __ZNSt3__115basic_stringbufIcNS_11char_traitsIcEENS_9allocatorIcEEE7seekoffExNS_8ios_base7seekdirEj␊
      Referenced from: /Users/mint/build/mb-contracts/tests/node_modules/near-sandbox/bin/near-sandbox (which was built for Mac OS X 12.0)␊
      Expected in: /usr/lib/libc++.1.dylib␊
     in /Users/mint/build/mb-contracts/tests/node_modules/near-sandbox/bin/near-sandbox␊
    `,
    stdout: '',
    message: 'Process was killed with SIGABRT',
  }

  › ChildProcess.done (node_modules/promisify-child-process/index.cjs:72:19)
edwardchew97 commented 6 months ago

Experienced the same issue and pinning rust to 1.69 fixed it for me.

think-in-universe commented 5 months ago

@ailisp Hey Bo, as reported by devs from community, quite some are suffering with this issue when testing with workspaces-js, when using Rust before 1.70.0.

We may need to upgrade the sandbox version in workspaces-js to fix this. It should have been fixed in nearcore: https://github.com/near/create-near-app/issues/2009

fospring commented 5 months ago

release a new version: 3.4.1