cdk-rs icon indicating copy to clipboard operation
cdk-rs copied to clipboard

cdk wasm public metadata

Open lastmjs opened this issue 2 years ago • 4 comments

I've been pushing for some standardization around a cdk namespace for Wasm public metadata as discussed here: https://forum.dfinity.org/t/rfc-canister-metadata-standard/16280

I'm wondering if it would make sense to get the major CDKs to start adopting their own public metadata conventions before standardizing. Azle and Kybra are both willing to do this, I'm also opening an issue with Motoko.

One of the great benefits of adopting this public metadata convention would be to allow canister indexing services like IC Dashboard to give near real-time statistics on exactly how many canisters are deployed on the IC per cdk/language. These stats would be very valuable for what I think are obvious reasons.

My proposal is this:

cdk:name

This is the name of the CDK that was used to produce the canister’s Wasm module binary e.g. motoko, cdk-rs, azle, kybra, icpp.

cdk:languages

This is a list of strings indicating the source code languages that the CDK supports e.g. motoko, rust, typescript; javascript, python, c++

cdk:version

This is the version of the CDK that was used to produce the canister’s Wasm module binary e.g. 1.2.3, 0.16.2, 2.3

lastmjs avatar Jul 05 '23 20:07 lastmjs

It turns out that there is a limit on the number of metadata sections that a canister can have. As a result, for dfx, we are using a single metadata entry with key dfx, the value of which is a json object.

https://github.com/dfinity/sdk/blob/master/src/dfx/src/lib/metadata/dfx.rs#L13

I would suggest the same here: a single metadata element with key cdk, the value of which is a json object with the fields you suggest.

ghost avatar Jul 05 '23 20:07 ghost

That sounds reasonable, but is candid going to do that? And how would this work with asking for the specific key that you want?

What would this return?

dfx canister metadata rust_canister cdk:name

Would that not work?

lastmjs avatar Jul 05 '23 20:07 lastmjs

The candid and moc fields were already being set as separate fields when this limitation came about, so we haven't yet addressed making changes to them.

I would like to make it so that in the example you gave, dfx canister metadata rust_canister cdk:name, dfx would:

  • notice there is no metadata with key cdk:name
  • look for metadata with key cdk
  • see if it is JSON with a field name
  • output that value
$ dfx canister metadata rust_canister cdk:name
azle

ghost avatar Jul 05 '23 20:07 ghost

Okay, if that's the case then for cdk-rs the cdk public metadata field would look something like this:

{
    "name": "ic-cdk",
    "languages": "rust",
    "version": "0.9.2"
}

lastmjs avatar Jul 05 '23 20:07 lastmjs

Fulfilled by recent work on tech_stack. https://github.com/dfinity/sdk/pull/3670

lwshang avatar Apr 12 '24 16:04 lwshang