Why aren’t there any docs regarding the local deployment of CMC?
I have a function to test in my rust backend, called obtain_cycles_for_canister
which is obtaining cycles from user for top up of a canister created.
So, I’ll be using icp ledger in local but the library I’m using uses CMC and how do I deploy that in local? there’s no clear docs or step by step instructions for beginners. It’ll be really helpful, if anyone can give any reference here, thank you.
Also, there’s a way apparently to install all canisters using dfx nns install, but that’ll install some other canisters also apart from CMC, which I do not wish for. So, if there’s any other method other than this, It would be really nice.
I’ve been there, installing the CMC is a bit of a nightmare .
There is maybe no documentation because to install the CMC, you need to perform an installation and submit a proposal. By extension, you also need the Governance canister, which similarly requires both an installation and a proposal. Additionally, both depend on the ICP ledger. In summary, it needs three canisters and two proposals being executed.
Therefore, if you don’t want to spend time writing deployment scripts and you’re already using dfx
, the dfx nns install
command might be a more straightforward option.
However, if you really, really want to set up this canister yourself, and while it is not a documentation, you can take a look at how I handle it in Juno Docker - more precisely the CMC and Governance modules. Maybe it will provide you with some information on the process.
Probably not useful yet, but if you want to contribute a little bit I may have an easier solution: In the cycles ledger repo we have a fake CMC (downloadable in the repo releases) intended to make local development convenient. I’d gladly give you a few pointers and review a PR if you want to add an endpoint
@Severin
I’d love to do that, please provide these pointers you were talking about. Let’s make this happen!
Here’s some brain dumping:
- Please add the endpoint in this file. Please put types in lib.rs next to it.
- create_canister could be some useful inspiration with how one can provoke errors for testing
- This is the function on the real CMC that you are trying to mimic.
- It first checks if memo and destination account of the ledger TX is set correctly
- Then it tops up the target canister. The fake CMC can’t mint cycles. Just assume it was installed with enough cycles to send them over
- Then it memorizes the result of the call. If the same ledger TX is used to notify again the cached result will be returned. Feel free to skip this functionality (and leave a comment about it) if you don’t need it
- The crate
ic-ledger-types
could be very helpful - Please also update the did file
Happy to help some more, just ask if you need anything. And if you have even a mediocre PR ready please let me know!