Hey y’all.
As I continue to evolve my ruby-on-icp demo and quickstart, I find myself reaching for gems like rack and roda, so I can handle some basic requests, query params and so on.
As an interpreted language, it seems to me that installing the gems into stable memory at /data/lib gets my around the wasm size and instruction count limitations.
Put another way, the wasm holds the ruby interpreter (including rust-cdk), and the gems at /data/lib. Only pure ruby gems, nothing compiled or containing c-extensions.
One consequence of this is that That means a call to put can add code the canister will then run, so I need to protect this method call. Right now, I’m approaching this as follows:
- Only a controller may write. Any other caller gets a refusal (the call traps and nothing is written).
- Writes stay in
/data/lib. A path with.., an absolute path, or anything that resolves outside it is refused.
Some questions I have that I’d love to hear some community feedback on:
- Is “controllers only” appropriate & enough? The asset canister has its own permission model separate from controllers. Would a separate permission for installing code (granted by a controller) be closer to what people expect?
- Adding gems at runtime voids the value of the module hash. With Installed code,
module_hashand a reproducible build verify the Ruby runtime, not the app on top of it, and installing code doesn’t go throughinstall_code, so it leaves no entry in the canister history. Does the canister history (especially/specifically install & update) play a big role in any of your canister lifecycle management? I haven’t yet looked into what it’d take to try n register my own log entries at that level, or like post addition info toinstall_code. Is there a convention for this already? - Upgrades. Installed files survive an upgrade because they live in stable memory, but icp-cli’s Candid compatibility check only sees the packed interface. Has anyone dealt with code that changes outside the upgrade path, any encountered issues?
- Prior art. Has any other canister on a runtime loaded code sent after deploy? How is it working for you?
Between PocketIC and the quickstart, things seem to be running fairly well so far in the limited functionality I’ve verified.
Cheers!