Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

__motoko_runtime_information not properly displayed in dfx #4819

Open
luc-blaeser opened this issue Dec 12, 2024 · 8 comments
Open

__motoko_runtime_information not properly displayed in dfx #4819

luc-blaeser opened this issue Dec 12, 2024 · 8 comments

Comments

@luc-blaeser
Copy link
Contributor

When calling:

dfx canister call backend __motoko_runtime_information "()"

users now don't see field names with recent Motoko/dfx versions:

(
  record {
    57_464_665 = false;
    555_875_341 = 32_760 : nat;
    840_817_809 = 0 : nat;
    846_809_255 = "0.1";
    1_189_611_882 = 256 : nat;
    1_859_442_917 = 2_097_152 : nat;
    1_942_499_641 = "0.13.4-4-g6603c0ac2";
    2_211_011_332 = 32_760 : nat;
    2_443_866_118 = 0 : nat;
    3_253_100_504 = "default";
    3_814_221_704 = 0 : nat;
    3_844_882_150 = 0 : nat;
    4_056_661_757 = 0 : nat;
    4_069_829_730 = 2_228_224 : nat;
  },
)
@crusso
Copy link
Contributor

crusso commented Dec 12, 2024

I suspect this never worked when called from dfx unless it had some special support that was removed.

The internal tests just cast the motoko actor to an actor type exposing the function at the correct type.

If we want this to work in general, I think we would need to add this method and perhaps other well-known methods to the candid interface.

Related PR #4635

@ggreif
Copy link
Contributor

ggreif commented Dec 12, 2024

@ByronBecker Try the dfx option:

      --candid <CANDID>
          Provide the .did file with which to decode the response.  Overrides value from
          dfx.json for project canisters

It might just work!

@ggreif ggreif changed the title __motoko_runtime_information not properly displayed in DFX __motoko_runtime_information not properly displayed in dfx Dec 12, 2024
@ByronBecker
Copy link

Trying this out with

dfx canister --ic call <my_canister> __motoko_runtime_information --candid internal_stats.did

Where the internal_stats.did file is 👇

type RuntimeInformation = record {
  compilerVersion : Text;
  rtsVersion : Text;
  garbageCollector : Text;
  memorySize : Nat;
  heapSize : Nat;
  totalAllocation : Nat;
  reclaimed : Nat;
  maxLiveSize : Nat;
  stableMemorySize : Nat;
  logicalStableMemorySize : Nat;
  maxStackSize : Nat;
  callbackTableCount : Nat;
  callbackTableSize : Nat;
};

service : {
  __motoko_runtime_information : () -> (RuntimeInformation) query;
}

And I'm receiving this back:

(
  record {
    57_464_665 = false;
    555_875_341 = 157_746_608 : nat;
    840_817_809 = 139_597_484 : nat;
    846_809_255 = "0.1";
    1_189_611_882 = 256 : nat;
    1_859_442_917 = 2_097_152 : nat;
    1_942_499_641 = "0.12.1";
    2_211_011_332 = 241_247_228 : nat;
    2_443_866_118 = 0 : nat;
    3_253_100_504 = "copying";
    3_814_221_704 = 83_500_620 : nat;
    3_844_882_150 = 0 : nat;
    4_056_661_757 = 848 : nat;
    4_069_829_730 = 366_673_920 : nat;
  },
)

Anything you can see from first glance that might be off?

@ByronBecker
Copy link

@ggreif

@ggreif
Copy link
Contributor

ggreif commented Dec 12, 2024

That's sad. Did you try with

service : {
  __motoko_runtime_information : () -> (record {
  compilerVersion : Text;
  rtsVersion : Text;
  garbageCollector : Text;
  memorySize : Nat;
  heapSize : Nat;
  totalAllocation : Nat;
  reclaimed : Nat;
  maxLiveSize : Nat;
  stableMemorySize : Nat;
  logicalStableMemorySize : Nat;
  maxStackSize : Nat;
  callbackTableCount : Nat;
  callbackTableSize : Nat;
}) query;
}

@ByronBecker
Copy link

@ggreif Nope, didn't make a difference. Same output. Tried with both dfx 0.24.0 and 0.24.3.

Maybe you can try deploying a canister to mainnet and seeing if the response is clean on your side?

I think we would need to add this method and perhaps other well-known methods to the candid interface

Yes, or glue together the candid with dfx?

@crusso This gets to another point that I'd like to bring up, which is allowing Motoko canisters to explictly specify private APIs that aren't meant to be discoverable or viewable from the dashboard. Specifically for product/team administrators.

@ggreif
Copy link
Contributor

ggreif commented Dec 14, 2024

I filed an issue in SDK's internal Jira. The suspicion is that when the metadata retrieval was implemented the --candid option became dysfunctional.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants