Hey, so we’ve come across a weird, and hard to diagnose bug with the newest version of dfx. I have no idea what to do other than just use an older version.
What we do is embed wasm into a root canister (now that the wasm limit has been lifted)
"root": {
"type": "custom",
"candid": ".dfx/local/canisters/root/root.did",
"build": "bash -c './backend/scripts/build.sh root'",
"wasm": ".dfx/local/canisters/root/root.wasm",
"shrink": true,
"gzip": true,
"metadata": [
{
"name": "candid:service"
}
],
"dependencies": [
"asset",
"game_config",
"game_state",
"player_hub",
"world",
"world_builder"
]
},
and then the code we call on root is
api::include_wasm!(ASSET_WASM, "asset");
api::include_wasm!(GAME_CONFIG_WASM, "game_config");
api::include_wasm!(GAME_STATE_WASM, "game_state");
api::include_wasm!(PLAYER_HUB_WASM, "player_hub");
api::include_wasm!(WORLD_WASM, "world");
api::include_wasm!(WORLD_BUILDER_WASM, "world_builder");
// create_canisters
#[update]
async fn create_canisters() -> Result<(), Error> {
api::guard_whitelist!(caller()).await?;
// temporary measure until we have a better system
const DB_CYCLES: u128 = 5_000_000_000_000;
const PLAYER_HUB_CYCLES: u128 = 50_000_000_000_000;
// install
let installations = vec![
(CanisterType::Asset, ASSET_WASM, DB_CYCLES),
(CanisterType::GameConfig, GAME_CONFIG_WASM, DB_CYCLES),
(CanisterType::GameState, GAME_STATE_WASM, DB_CYCLES),
(CanisterType::PlayerHub, PLAYER_HUB_WASM, PLAYER_HUB_CYCLES),
(CanisterType::World, WORLD_WASM, DB_CYCLES),
(CanisterType::WorldBuilder, WORLD_BUILDER_WASM, DB_CYCLES),
];
for (canister_type, wasm, cycles) in installations {
if let Err(e) = ::api::root_canister_install!(canister_type, wasm, cycles).await {
::lib_ic::println!("Error installing canister {:?}: {:?}", canister_type, e);
continue;
}
}
Ok(())
}
On dfx 0.17.0, installing the canister gives us the following error :
Fabricated 9000000000000000 cycles, updated balance: 341_843_084_913_409_176 cycles
Reinstalling code for canister root, with canister ID a4tbr-q4aaa-aaaaa-qaafq-cai
Error: Failed to install wasm module to canister 'root'.
Caused by: Failed to install wasm module to canister 'root'.
Failed during wasm installation call: Candid returned an error: input: 4449444c026d016d7b010005_2001ed7d50652029e5a37bc0287e8748e14f7ae152e36c9cdf23ee73362cc207ab205a20bb7bbc71a940a95504696d901f8cc70bfee74574f409992cc5c52225df532073bf9834c5ff674af647e93a442920247408f3b228e9ee95c0667d9b6af68a4a20dd0b15f25ee75ecb696e63e52b93002dc47ad5e0f68565cac355e62b5c89d37020ff042bd7a6f7f8bb523dc21b659271cb676f25fa51bdd9c83c9b9b8a1069d707
table: type table0 = vec table1
type table1 = vec nat8
wire_type: vec nat8, expect_type: unknown
Thanks!