1

I am exposing some external functions to ink! contracts via a chain-extension in pallet-contracts. I am essentially passing a vector of bytes as a parameter to a contract method and directly forwarding it to the chain-extension method that also accepts a vector. The return value is also a vector of bytes that I encode via the SCALE codec when I write it to the environment.

What I am wondering is how I can increase the maximum allowed input/output sizes such that I can pass in/return bigger vectors. As I increase the vectors, at some point I get OutputBufferTooSmall and I can trace it to:

https://github.com/paritytech/substrate/blob/master/frame/contracts/src/wasm/runtime.rs#L614

I tried changing Schedule limits (such as parameter count, memory pages, etc.), but it doesn't have an impact. As far as I see, it is a runtime limitation that is not related to chain-extension (but I might be wrong). How can I increase the sandbox memory size and what is the preferred way of doing so? Maybe via config and not changing code. I couldn't find where the value pointed to by out_len_ptr is set. Any significant side effects of increasing it?

Thank you!

1 Answer 1

0

The size of the output buffer is defined by the contract calling the chain extension. It passes a pointer to the length of the buffer in the out_len_ptr parameter. The contracts pallet doesn't enforce any limit on this buffer except for the maximum amount of linear memory a contract can have.

ink! uses 16KiB for this buffer. What you probably want is a way to have this buffer configurable in ink!.

2
  • Oh, thank you! Maybe a feature can be added that controls it at compile time. I can open a PR if that seems reasonable to you. May 13 at 14:55
  • Yes please open a PR and mention chain extensions there. May 13 at 21:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.