No internet connection
  1. Home
  2. WASM

Where is the stack size allocated for the WASM smart contract?

By Orkun Külçe @orkunkl2020-07-27 10:00:22.725Z

Is it directly inside the contract.wasm binary, in the spirit of linear memory?

Solved in post #4, click to view
  • 3 replies
  1. Orkun Külçe @orkunkl2020-07-27 10:00:32.023Z

    Stack size limit is determined by the host (i.e. Wasmer+singlepass). See this spec discussion as well: I’m not aware if and which stack size limit is in place. Feel free to attack this and let us know your findings.

    Linear memory is the implementation for heap storage, so this has nothing to do with the stack.

    1. In reply toorkunkl:
      Orkun Külçe @orkunkl2020-07-27 10:00:40.476Z

      Ah I see -- so is there limited heap memory for each wasm code uploaded that is bound by the size of the binary?

      1. In reply toorkunkl:
        Orkun Külçe @orkunkl2020-07-27 10:00:59.071Z

        Right now there is one linear memory for each instance that is bound by the 32 bit address space in the Wasm sandbox (4GB)
        A contract can allocate those 4GB but due to gas limit cannot write so much data. In practice I was not able to trigger a high memory usage on the host