Install_code from canister limited to 2mb as well?

It’s probably a stupid question but, out of nowhere, I have a doubt for no reason.

Can a canister that holds some wasm code as a blob (e.g. Vec<u8>) and calls install_code targeting another canister install more than 2 MB?

5 Likes

It’s possible, but some work would need to be done, in comparison to DFX, which will handle the chunked upload for you. You need to use install_chunked_code after upload_chunk.

2 Likes

Thanks Nathan so, to answer concretlly my question: if a canister holds e.g. 5mb of wasm it cannot call install_code targeting another canister because as for any install_code it will hit the 2mb message limitation. Correct?

In other words, regardless where you call install_code, the 2mb limit absolutely always apply.

1 Like

Yes there is still the 2mb message limit on install_code. The same is also true for upload_chunk and install_chunked_code.

A 5mb WASM would need to be uploaded with 3 separate calls (each less than 2mb) to the target canister’s blob storage using upload_chunk and then installed using install_chunked_code.

4 Likes

Thanks for the confirmation. I don’t know why I had some doubt but, “there is no such thing as stupid question” isn’t :wink: .

2 Likes

IIRC the 2mb limit is only there for ingress messages and cross-net calls, if a canister calls another canister in the same subnet then the limit is 10mb (source).

3 Likes

Nice, I didn’t know about that. Thanks!

1 Like

Thanks Kepler, that’s good to know!

Btw. install_chunked_code is also limited to 10mb right? Looks like it is not documented on the website. MAX_CHUNKS_IN_LARGE_WASM and CHUNK_STORE_SIZE are referenced but their effective values is not displayed unless I missed an information :man_shrugging:.

1 Like

Each chunk must be at most 1MiB. That is documented here. But ideally this would be added to the resource limits table as well.

Additionally, not mentioned in the spec: The resulting wasm must be at most 100 chunks / MiB, with the additional restriction that the code section must be no larger than 10MiB. But this leaves room to bundle in assets and metadata larger than 10MiB.

@bogwar: Could you please confirm the above numbers?

4 Likes

Thanks @frederikrothenberger; the limits are indeed as you stated them. I’ll see it to add the limits to the resource limit table.