dfinity / cdk-rs

Rust canister development kit for the Internet Computer.
Apache License 2.0
201 stars 90 forks source link

cdk wasm public metadata #410

Closed lastmjs closed 7 months ago

lastmjs commented 1 year ago

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

ericswanson-dfinity commented 1 year ago

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.

lastmjs commented 1 year ago

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?

ericswanson-dfinity commented 1 year ago

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:

$ dfx canister metadata rust_canister cdk:name
azle
lastmjs commented 1 year ago

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"
}
lwshang commented 7 months ago

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