stellar / rs-soroban-sdk

Rust SDK for Soroban contracts.
Apache License 2.0
128 stars 67 forks source link

Contract deploying and invoking result in `xdr processing error: xdr value invalid` whenever anything is changed slightly from examples #1276

Closed Melbourneandrew closed 6 months ago

Melbourneandrew commented 6 months ago

Also detailed in this stack exchange post

What version are you using?

soroban 20.3.4 (f30a47fc58ace4437b0252919420838550481420) soroban-env 20.3.0 (befdf4b2b6061bd6da20b0f93d539d6ad8d8be22) soroban-env interface version 85899345920 stellar-xdr 20.1.0 (8b9d623ef40423a8462442b86997155f2c04d3a1) xdr curr (b96148cd4acc372cc9af17b909ffe4b12c43ecb6)

What did you do?

Clone an example / setup hello world with soroban contract init ./ --with-example increment

Running through the following commands with the code unedited results in expected behavior. Changing something as slight as count+=1 to count+=2 results in the error.

soroban contract build
soroban contract install \
  --network testnet \
  --source alice \
  --wasm target/wasm32-unknown-unknown/release/soroban_increment_contract.wasm
soroban contract deploy \
  --wasm-hash <output previous command> \
  --source alice \
  --network testnet

(error occurs here but if you run the deploy command again, it goes through and returns a C address)

soroban contract invoke \
  --id <output from previous command> \
  --source alice \
  --network testnet \
  -- \
  increment

Error occurs here no matter how many times you run the command

> xdr processing error: xdr value invalid

What did you expect to see?

The result of the increment routine being called.

What did you see instead?

xdr processing error: xdr value invalid

leighmcculloch commented 6 months ago

Hi! Thanks for reporting this issue. It looks like in your example that the transaction is being submitted to testnet which is currently running XDR v21, however the CLI in use is v20.

You'll need to install the CLI v21 with:

cargo install --locked stellar-cli --version 21.0.0-rc.1
Melbourneandrew commented 6 months ago

I am still encountering this error :(

I have run

cargo install --locked stellar-cli --version 21.0.0-rc.1

and

cargo install --locked stellar-xdr --version 21.0.1 --features="cli"

Running cargo install --list shows

soroban-cli v20.3.4:
    soroban
stellar-cli v21.0.0-rc.1:
    stellar
stellar-xdr v21.0.1:
    stellar-xdr

But running soroban version shows

soroban 20.3.4 (f30a47fc58ace4437b0252919420838550481420)
soroban-env 20.3.0 (befdf4b2b6061bd6da20b0f93d539d6ad8d8be22)
soroban-env interface version 85899345920
stellar-xdr 20.1.0 (8b9d623ef40423a8462442b86997155f2c04d3a1)
xdr curr (b96148cd4acc372cc9af17b909ffe4b12c43ecb6)
leighmcculloch commented 6 months ago

Ah install the last Soroban CLI with:

cargo install --locked soroban-cli --version 21.0.0-rc.1

We're renaming it to stellar-cli and I gave you the install command for it but you are running the Soroban command.

Melbourneandrew commented 6 months ago

I got it working using this command provided to me by the great dev relations folks at the Consensus Agenda hackathon! Shout out to @Julian-dev28 and @kalepail!

cargo install --git https://github.com/stellar/stellar-cli soroban-cli