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

feat: introduce candid-extractor for candid export #424

Merged
merged 15 commits into from
Sep 18, 2023
Merged

Conversation

lwshang
Copy link
Contributor

@lwshang lwshang commented Sep 6, 2023

Description

SDK-1227

Rework the "Candid Export" support introduced in v0.10.

The new version needs no crate features in ic0 and ic-cdk-macros anymore.

And the canister can still invoke ic_cdk::export_candid!() at the end of source code.

Then candid-extractor can extract candid from the canister WASM (the same WASM module to be deployed on IC).

How Has This Been Tested?

Examples end-to-end tests.

Checklist:

  • The title of this PR complies with Conventional Commits.
  • I have edited the CHANGELOG accordingly.
  • I have made corresponding changes to the documentation.

@chenyan-dfinity
Copy link
Contributor

Interesting idea! There are two approaches to solve the double compilation problem with different pros and cons:

  1. As you proposed here, we can provide the ic imports in the wasmtime runtime.
  2. We can build a Wasm transformation that takes out the ic imports, so that it can run with regular wasmtime.

For 1), we need a special wasmtime (candid_extractor in this case), and the output candid function will be in the deployed canisters.
For 2), we need a regular wasmtime, which can also be used for Motoko unit testing as well. The transformation can be useful in other cases, e.g., when some crates accidentally import some non-ic modules, we can help remove them.

@lwshang
Copy link
Contributor Author

lwshang commented Sep 7, 2023

This is a intermediate stage of candid exporting epic. The candid_extractor CLI is a temporary component.
My next step is to integrate such specialized wasmtime into dfx. And add a config in dfx.json to let a canister opt in such candid export behavior.

As this will be built into dfx, developers won't need install other tools like wasmtime. And there will be only one WASM for both deploying and extracting candid.

@lwshang lwshang changed the title feat: sdk 1227 feat: introduce candid-extractor for candid export Sep 15, 2023
@lwshang lwshang marked this pull request as ready for review September 15, 2023 20:23
@lwshang lwshang requested a review from a team as a code owner September 18, 2023 15:18
@lwshang lwshang enabled auto-merge (squash) September 18, 2023 16:21
@lwshang lwshang merged commit b264573 into main Sep 18, 2023
14 checks passed
@lwshang lwshang deleted the lwshang/SDK-1227 branch September 18, 2023 16:28
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

Successfully merging this pull request may close these issues.

3 participants