Issues with too large wasm build

Hey,

My team and I are developing a comprehensive smart contract on the Concordium platform.

We are at the stage, where we wanted to deploy to the testnet. However, our smart contract size is ~150 kb, which is too large for the limit of ~65 kb.

Therefore, we tried to follow recommended steps to minify wasm, like using:

  • wasm-strip
  • wasm-opt
  • removing unwrap and vec.push panics through rewriting our code and making a unwrap_abort function, that calls trap() instead
  • using profile.release opt-levels

Though we can’t seem to get under ~98 kb, without removing essential third-party libraries like k256.

Any ideas/help of what we can do from here are appreciated!

We are considering attempting to split our contract in 2 or figure out if its possible to depend less on the library, though this is far from ideal.

1 Like

Hi

First of all,
The upcoming release will include a new version of the smart contracts where the size is not constrained to 65 kb.
Further the new version of smart contracts will also support sync-calls for inter-communication between smart contracts.

Currently given your already taken actions and without looking at your current contract then I believe your best option right now would indeed be to split up your contract into multiple ones.

/Emil

1 Like

To add to that, V1 contracts will have 512kB size limit.

Alright, we’ll try to split our contract. Do you have a specific timeline for the upcoming release you can share?

1 Like

Hi,

I’m afraid I cannot share any exact dates with you at the moment.

You are welcome to follow the progress here: https://github.com/Concordium/concordium-node/pull/243

/Emil

Hello.

When you have to split the contract, how would you go about calling the other contract from the first one, and ensuring the other is callable?

Thanks.

1 Like

Hi,
For the current version you would do this in an ‘async’ manner.
https://developer.concordium.software/en/mainnet/smart-contracts/references/host-fns.html#concordium.send

You can e.g. look at the cis1-nft example here:

In the upcoming release we will also support sync calls which will suspend the execution of the calling contract and resume again when the called one has terminated.
You can look at the new-contract-state branch for an example:

/Emil