Search code examples
multiversx

VecMapper `extend_from_slice` - differences between testnet and devnet


I found some differences between the testnet and the devnet on how the extend_from_slice on VecMapper works. It works ok on the devnet, but the same endpoint/function in the same SC breaks on the testnet. I wonder why.

Here is the function which fails: https://github.com/juliancwirko/elven-nft-minter-sc/blob/main/src/lib.rs#L273

What is strange, on the testnet, it breaks only for the passed value bigger than 64.

Here are the results of the same Smart Contract, the same code, the same endpoint, and sent data :

What works for both environments is not using the extend_from_slice but instead pushing directly to the VecMapper, which consumes a lot of gas, over two times more.

The error data:

  • identifier: signalError
  • in topics: execution failed

Solution

  • Here is a response from a group where the question was also asked :

    There are some limitations regarding Rust's dynamic allocation, which can cause some sc calls to fail. We recommend using managed types instead, which only allocate memory inside the VM, or use static buffers