Skip to content

Commit

Permalink
Update agent and playground for mgmt canister changes
Browse files Browse the repository at this point in the history
  • Loading branch information
adamspofford-dfinity committed Jan 29, 2025
1 parent be760cc commit 9495933
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 13 deletions.
10 changes: 5 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ license = "Apache-2.0"
candid = "0.10.11"
candid_parser = "0.1.4"
dfx-core = { path = "src/dfx-core", version = "0.1.0" }
ic-agent = { version = "0.39", git = "https://github.com/dfinity/agent-rs", rev = "a96022bd185e97f52c5cde1c82c7592abddcff86" }
ic-agent = { version = "0.39", git = "https://github.com/dfinity/agent-rs", rev = "9ebf6314ce2fcb36772c7d81d6d414b4628d6101" }
ic-asset = { path = "src/canisters/frontend/ic-asset", version = "0.21.0" }
ic-cdk = "0.13.1"
ic-identity-hsm = { version = "0.39", git = "https://github.com/dfinity/agent-rs", rev = "a96022bd185e97f52c5cde1c82c7592abddcff86" }
ic-utils = { version = "0.39", git = "https://github.com/dfinity/agent-rs", rev = "a96022bd185e97f52c5cde1c82c7592abddcff86" }
ic-identity-hsm = { version = "0.39", git = "https://github.com/dfinity/agent-rs", rev = "9ebf6314ce2fcb36772c7d81d6d414b4628d6101" }
ic-utils = { version = "0.39", git = "https://github.com/dfinity/agent-rs", rev = "9ebf6314ce2fcb36772c7d81d6d414b4628d6101" }

aes-gcm = "0.10.3"
anyhow = "1.0.56"
Expand Down
1 change: 1 addition & 0 deletions e2e/assets/playground_backend/mops.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ splay = "0.1.0"
[[canister]]
candid = "service/wasm-utils/wasm-utils.did"
output = "service/pool/Wasm-utils.mo"

21 changes: 19 additions & 2 deletions e2e/assets/playground_backend/service/pool/IC.mo
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ module {
#reinstall;
#upgrade : ?{
wasm_memory_persistence : ?{
#Keep;
#Replace;
#keep;
#replace;
};
};
#install;
Expand Down Expand Up @@ -85,6 +85,22 @@ module {
message_hash : Blob;
};
public type sign_with_ecdsa_result = { signature : Blob };
public type schnorr_algorithm = {
#bip340secp256k1;
#ed25519;
};
public type schnorr_aux = {
#bip341: {
merkle_root_hash: Blob
}
};
public type sign_with_schnorr_args = {
message : Blob;
derivation_path : [Blob];
key_id : { algorithm : schnorr_algorithm; name : Text };
aux: ?schnorr_aux;
};
public type sign_with_schnorr_result = { signature : Blob };
public type user_id = Principal;
public type wasm_module = Blob;
public type Self = actor {
Expand Down Expand Up @@ -116,6 +132,7 @@ module {
} -> async ();
raw_rand : shared () -> async Blob;
sign_with_ecdsa : shared sign_with_ecdsa_args -> async sign_with_ecdsa_result;
sign_with_schnorr : shared sign_with_schnorr_args -> async sign_with_schnorr_result;
start_canister : shared { canister_id : canister_id } -> async ();
stop_canister : shared { canister_id : canister_id } -> async ();
uninstall_code : shared { canister_id : canister_id } -> async ();
Expand Down
9 changes: 8 additions & 1 deletion e2e/assets/playground_backend/service/pool/Main.mo
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,6 @@ shared (creator) actor class Self(opt_params : ?Types.InitParams) = this {
mode = args.mode;
canister_id = args.canister_id;
};
Debug.print("install mode: " # debug_show(args.mode));
await IC.install_code newArgs;
stats := Logs.updateStats(stats, #install);

Expand Down Expand Up @@ -710,6 +709,12 @@ shared (creator) actor class Self(opt_params : ?Types.InitParams) = this {
await* pool.addCycles(caller, #refund);
res
};
public shared ({ caller }) func sign_with_schnorr(arg: ICType.sign_with_schnorr_args) : async ICType.sign_with_schnorr_result {
await* pool.addCycles(caller, #method "sign_with_schnorr");
let res = await IC.sign_with_schnorr(arg);
await* pool.addCycles(caller, #refund);
res
};
public shared ({ caller }) func _ttp_request(request : ICType.http_request_args) : async ICType.http_request_result {
await* pool.addCycles(caller, #method "http_request");
let new_request = switch (request.transform) {
Expand Down Expand Up @@ -832,6 +837,7 @@ shared (creator) actor class Self(opt_params : ?Types.InitParams) = this {
#_ttp_request : Any;
#__transform : Any;
#sign_with_ecdsa: Any;
#sign_with_schnorr: Any;
#eth_call: Any;
#eth_feeHistory: Any;
#eth_getBlockByNumber: Any;
Expand All @@ -856,6 +862,7 @@ shared (creator) actor class Self(opt_params : ?Types.InitParams) = this {
case (#_ttp_request _) false;
case (#__transform _) false;
case (#sign_with_ecdsa _) false;
case (#sign_with_schnorr _) false;
case (#eth_call _) false;
case (#eth_feeHistory _) false;
case (#eth_getBlockByNumber _) false;
Expand Down
3 changes: 2 additions & 1 deletion e2e/assets/playground_backend/wasm-utils.did
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
type Config = record {
profiling : bool;
profiling : opt record { start_page: opt nat32; page_limit: opt nat32 };
remove_cycles_add : bool;
limit_stable_memory_page : opt nat32;
limit_heap_memory_page : opt nat32;
backend_canister_id : opt principal;
};

Expand Down
Binary file modified e2e/assets/playground_backend/wasm-utils.wasm
100644 → 100755
Binary file not shown.
1 change: 1 addition & 0 deletions src/dfx/src/lib/operations/canister/install_canister.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ pub async fn install_canister(
installed_module_hash.is_some(),
wasm_memory_persistence_embedded,
);
// .canonicalize();

// let mode = mode.unwrap_or_else(|| {
// if installed_module_hash.is_some() {
Expand Down
7 changes: 6 additions & 1 deletion src/dfx/src/lib/operations/canister/motoko_playground.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ impl TryFrom<InstallMode> for PlaygroundInstallMode {
..
})
| None,
// ) => Ok(Self::Upgrade(Some(PlaygroundCanisterUpgradeOptions {
// wasm_memory_persistence: Some(WasmMemoryPersistence::Replace),
// }))),
) => Ok(Self::Upgrade(None)),
InstallMode::Upgrade(Some(CanisterUpgradeOptions {
wasm_memory_persistence: Some(WasmMemoryPersistence::Keep),
Expand Down Expand Up @@ -241,7 +244,9 @@ pub async fn playground_install_code(
}

fn convert_mode(mode: InstallMode, wasm_module: &[u8]) -> DfxResult<PlaygroundInstallMode> {
let converted_mode: PlaygroundInstallMode = mode.try_into()?;
let converted_mode: PlaygroundInstallMode = mode
// .canonicalize()
.try_into()?;
// Motoko EOP requires `wasm_memory_persistence: Keep` for canister upgrades.
// Usually, this option is auto-set if the installed wasm has the private metadata `enhanced-orthogonal-persistence` set.
// However, in the playground setting, the playground is the controller. So we can't read that metadata section and will set `wasm_memory_persistence: Replace` as a fallback.
Expand Down

0 comments on commit 9495933

Please sign in to comment.