Skip to content

Commit

Permalink
remove __get_candid_interface_tmp_hack endpoint (#4386)
Browse files Browse the repository at this point in the history
Now that candid are in the canister metadata for quite a while, `tmp_hack` is redundant. It also cannot be set to private like we do in metadata.
  • Loading branch information
chenyan-dfinity authored Feb 7, 2024
1 parent fae8386 commit 7e2421f
Show file tree
Hide file tree
Showing 13 changed files with 11 additions and 57 deletions.
6 changes: 6 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Motoko compiler changelog

## Unreleased

* motoko (`moc`)

* Remove `__get_candid_interface_tmp_hack` endpoint. Candid interface is already stored as canister metadata, this temporary endpoint is redundant, thus removed. (#4386)

## 0.10.4 (2024-01-10)

* motoko (`moc`)
Expand Down
19 changes: 1 addition & 18 deletions src/lowering/desugar.ml
Original file line number Diff line number Diff line change
Expand Up @@ -411,22 +411,6 @@ and build_candid ts obj_typ =
service = WithComments.string_of_prog prog;
}

and export_interface txt =
(* This is probably a temporary hack. *)
let open T in
let {lab;typ;_} = get_candid_interface_fld in
let v = "$"^lab in
let scope_con1 = Cons.fresh "T1" (Abs ([], scope_bound)) in
let scope_con2 = Cons.fresh "T2" (Abs ([], Any)) in
let bind1 = typ_arg scope_con1 Scope scope_bound in
let bind2 = typ_arg scope_con2 Scope scope_bound in
([ letD (var v typ) (
funcE v (Shared Query) Promises [bind1] [] [text] (
asyncE Type.Fut bind2 (textE txt) (Con (scope_con1, []))
)
)],
[{ it = I.{ name = lab; var = v }; at = no_region; note = typ }])

and export_footprint self_id expr =
let open T in
let {lab;typ;_} = motoko_stable_var_info_fld in
Expand Down Expand Up @@ -496,7 +480,6 @@ and build_actor at ts self_id es obj_typ =
let meta =
I.{ candid = candid;
sig_ = T.string_of_stab_sig sig_} in
let interface_d, interface_f = export_interface candid.I.service in
let with_stable_vars wrap =
let vs = fresh_vars "v" (List.map (fun f -> f.T.typ) fields) in
blockE
Expand All @@ -514,7 +497,7 @@ and build_actor at ts self_id es obj_typ =
) fields vs)
ty)) in
let footprint_d, footprint_f = export_footprint self_id (with_stable_vars (fun e -> e)) in
I.(ActorE (interface_d @ footprint_d @ ds', interface_f @ footprint_f @ fs,
I.(ActorE (footprint_d @ ds', footprint_f @ fs,
{ meta;
preupgrade = with_stable_vars (fun e -> primE (I.ICStableWrite ty) [e]);
postupgrade =
Expand Down
7 changes: 0 additions & 7 deletions src/mo_types/type.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1358,17 +1358,10 @@ let motoko_gc_trigger_fld =
src = empty_src;
}

let get_candid_interface_fld =
{ lab = "__get_candid_interface_tmp_hack";
typ = Func(Shared Query, Promises, [scope_bind], [], [text]);
src = empty_src;
}

let well_known_actor_fields = [
motoko_async_helper_fld;
motoko_stable_var_info_fld;
motoko_gc_trigger_fld;
get_candid_interface_fld
]

let decode_msg_typ tfs =
Expand Down
1 change: 0 additions & 1 deletion src/mo_types/type.mli
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,6 @@ val string_of_stab_sig : field list -> string
val motoko_async_helper_fld : field
val motoko_stable_var_info_fld : field
val motoko_gc_trigger_fld : field
val get_candid_interface_fld : field

val well_known_actor_fields : field list
val decode_msg_typ : field list -> typ
Expand Down
4 changes: 2 additions & 2 deletions test/bench/ok/heap-32.drun-run-opt.ok
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ingress Completed: Reply: 0x4449444c016c01b3c4b1f204680100010a00000000000000000101
ingress Completed: Reply: 0x4449444c0000
debug.print: (50_227, +30_261_252, 709_322_975)
debug.print: (50_070, +32_992_212, 766_414_006)
debug.print: (50_227, +30_261_252, 709_323_215)
debug.print: (50_070, +32_992_212, 766_414_086)
ingress Completed: Reply: 0x4449444c0000
4 changes: 2 additions & 2 deletions test/bench/ok/heap-32.drun-run.ok
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ingress Completed: Reply: 0x4449444c016c01b3c4b1f204680100010a00000000000000000101
ingress Completed: Reply: 0x4449444c0000
debug.print: (50_227, +30_261_252, 770_048_232)
debug.print: (50_070, +32_992_212, 830_127_686)
debug.print: (50_227, +30_261_252, 770_048_604)
debug.print: (50_070, +32_992_212, 830_127_810)
ingress Completed: Reply: 0x4449444c0000
1 change: 0 additions & 1 deletion test/run-drun/ok/query-footprint.drun-run.ok
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@ ingress Completed: Reply: 0x4449444c016c01c1c1cee2047801005118000000000000
Ok: Reply: 0x4449444c016c01c1c1cee2047801005118000000000000
ingress Completed: Reply: 0x4449444c0001785118000000000000
ingress Completed: Reply: 0x4449444c0001785118000000000000
Ok: Reply: 0x4449444c0001712973657276696365203a207b0a202064656c65676174653a202829202d3e20286e61743634293b0a7d0a
2 changes: 0 additions & 2 deletions test/run-drun/ok/query-footprint.ic-ref-run.ok
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,3 @@
<= replied: ((6225 : nat64))
=> update delegate()
<= replied: ((6225 : nat64))
=> query __get_candid_interface_tmp_hack()
<= replied: ("service : {\n delegate: () -> (nat64);\n}\n")
3 changes: 0 additions & 3 deletions test/run-drun/ok/self-describe.drun-run.ok

This file was deleted.

6 changes: 0 additions & 6 deletions test/run-drun/ok/self-describe.ic-ref-run.ok

This file was deleted.

1 change: 0 additions & 1 deletion test/run-drun/query-footprint.mo
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ actor footprint = {
//CALL query __motoko_stable_var_info "DIDL\x00\x00"
//CALL ingress delegate "DIDL\x00\x00"
//CALL ingress delegate "DIDL\x00\x00"
//CALL query __get_candid_interface_tmp_hack "DIDL\x00\x00"

//SKIP run
//SKIP run-ir
Expand Down
10 changes: 0 additions & 10 deletions test/run-drun/self-describe.mo

This file was deleted.

4 changes: 0 additions & 4 deletions test/run-drun/self-describe/types.mo

This file was deleted.

0 comments on commit 7e2421f

Please sign in to comment.