near / near-workspaces-rs

Write tests once, run them both on NEAR TestNet and a controlled NEAR Sandbox local environment via Rust
84 stars 50 forks source link

`view_state` stopped working #281

Closed Tarnadas closed 12 months ago

Tarnadas commented 1 year ago

Hey,

I have a script to deploy my contract. As preparation I read all keys to clean up storage for a redeployment and I use workspaces for this. However just recently the call to view_state returns an error:

Error: unable to fulfill the query request

Caused by:
    error while parsing method call result: [data did not match any variant of untagged enum QueryResponse]

I changed my code to manually call the RPC server via this query and it works:

{
  "jsonrpc": "2.0",
  "id": "dontcare",
  "method": "query",
  "params": {
    "request_type": "view_state",
    "finality": "final",
    "account_id": "app4.orderly-spot.testnet",
    "prefix_base64": ""
  }
}

So it seems like the error must be in the workspaces crate.

frol commented 1 year ago

@Tarnadas Did you compile your contract / workspaces-rs project with Rust <= 1.69? See this issue for more details: https://github.com/near/nearcore/issues/9143

Tarnadas commented 1 year ago

Hey @frol, yes I'm aware of the issue and use Rust 1.69. But why should the Rust version that I use for compilation affect this? Isn't workspaces doing an RPC call and not doing anything on chain in my case?

frol commented 1 year ago

@Tarnadas If you use workspaces-rs to compile your smart contract, it will compile it with whatever Rust compiler it finds and deploy it (actually, hard to tell without looking at the code of the test you wrote), and then it will fail to be executed on nearcore.

Tarnadas commented 1 year ago

Ah ok, that makes it clear. But I don't use workspaces to compile my code. I have a build script and just load the wasm file for deployment.

In this particular case I don't use workspaces for integration tests, but instead I have a deploy program for testnet. I read the existing contract state to delete existing keys and do a deployment afterwards.

frol commented 1 year ago

@Tarnadas If you don't use workspaces-rs, submit your issue somewhere it belongs to and provide more details with the code you run, otherwise it is impossible to help you.

Tarnadas commented 1 year ago

I wrote in the issue that I use ‘view_state‘ from workspaces: https://docs.rs/workspaces/0.7.0/workspaces/struct.Worker.html#method.view_state

ghost commented 1 year ago

Is this issue still relevant, If it is stale we can close it.

frol commented 12 months ago

@Tarnadas Please, try using the latest near-workspaces 0.9 release and feel free to reopen this issue if it still fails for you