dfinity / sdk

IC SDK: a Software Development Kit for creating and managing canister smart contracts on the ICP blockchain.
https://internetcomputer.org/developers
Apache License 2.0
175 stars 85 forks source link

Make installing ledger locally simple #1982

Open roman-kashitsyn opened 2 years ago

roman-kashitsyn commented 2 years ago

Currently, installing the ledger canister locally is a long and complicated procedure: https://github.com/dfinity/ic/tree/a65a3624d504f870f9924f9467dcad9538a85d85/rs/rosetta-api/ledger_canister#deploying-locally

This is too high of a barrier for smart contract developers. Installing the ledger locally should be as easy as

dfx ledger install --minting-account <acc>

The install should happen in such a way that dfx ledger balance and dfx ledger transfer can work with the local instance.

chenyan-dfinity commented 2 years ago

Same for II canister. Either we treat these canisters specially or design a general way to work with external canisters.

roman-kashitsyn commented 2 years ago

Same for II canister. Either we treat these canisters specially or design a general way to work with external canisters.

Ledger, CMC, Governance, and II have to be treated specially because they are all tied together. E.g., CMC hardcodes the canister id of the Ledger and the Governance. To install these canisters properly, we need to follow a strict init procedure. For everything else, we might develop a more general and scalable approach.

How I'd implement ledger/CMC/Governance/II setup: DFX creates a bunch of canisters (~10) when it first starts the local replica to make sure that first IDs won't be taken by the user canisters. When we issue dfx ledger install or dfx install-system-canister ledger or whatever the command will be, we invoke install_code on the preallocated canister id that the Ledger has on the mainnet.

bitdivine commented 2 years ago

I'd like to register as an interested party. For nns-dapp we have a script to install the governance canisters, Internet Identity and now also SNS canisters. I get requests to replicate this setup for other projects and I suspect that this would be of use to external parties as well. I'd be interested in making such a tool available for general consumption, not necessarily in its current form. E.g. creating a dozen canisters right at the beginning makes a lot of sense in the general case; we don't need that but in a general form it would be good. The common SNS canisters, that live on the NNS and are used by all SNS instances, might be challenging unless they end up being allocated to low canister IDs in production.

bitdivine commented 2 years ago

I would like to volunteer to implement dfx start --with-nns which would be like dfx start --clean but that installs the nns canisters after starting. This would have to be approved by the sdk team, of course.

The nns canisters include the ledger (requested by @roman-kashitsyn ).

sesi200 commented 2 years ago

After discussing with the team: Yes, please, @bitdivine, that would be wonderful! I'll reach out to you so we can discuss some implementation details; we have some suggestions for that.