Skip to content

Latest commit

 

History

History

nns

Network Nervous System (NNS)

This directory is intended to contain the various canisters, and possibly command-line tools, used for decentralized control of the Internet Computer.

Deploying the NNS canisters

Before using the NNS a range of canisters must be deployed into the NNS subnet.

To production and testnets, the NNS canisters are deployed by Ansible onto the NNS subnet.

Choose a target replica

There are two possibilities:

  • Use a local replica. This can be done with, from rs/nns:

dfx start --host 127.0.0.1:8080
  • Use a remote replica on an NNS subnet.

Deploy from local build to a local replica

After running the command to build the canisters (cargo build -p registry-canister…​) run the following command, from rs/:

cargo run --bin ic-nns-init -- --url https://localhost:8080/ --wasm-dir=./target/wasm32-unknown-unknown/release

Run cargo run --bin ic-nns-init -- --help for the usage and all available options.

Manual interactions with dfx and the Candid web server

An easy way to interact with the NNS for manual testing is through the Candid web UI and/or the dfx canister command.

All commands in these instructions assume that the NNS dir rs/nns is the current dir.

Interacting with an existing NNS

To interact with the NNS on <testnet>, on which the NNS canisters have already been deployed:

  1. Add the network in dfx.json. Point at a machine from the NNS subnet from env/<testnet>/hosts. It’s already done for the NNS testnet. .Depending on the type of "network", dfx will expect the mapping between canister names and ids to either be in ./canister_ids.json (the current dir must be the NNS dir), or ./.dfx/<networkname>/canister_ids.json.

  2. Add entries for each canister in canister_ids.json: duplicate the existing one, and just change the network name. The canister ids are identical of all subnets.

  3. For each canister, copy its .did file under .dfx/<networkname>/canisters/<canister_name>/<canister_name.did>

Start the Candid web server

Run dfx bootstrap. If you test against a remote replica, run dfx bootstrap --network=nnstestnet instead. The webserver starts by default on https://localhost:8081

Check the web UIs:

There is no web UI for the registry, because it’s API is not Candid-based.

An example of a demo scenario for upgrades

Show the content of a neuron

dfx canister call neurons get_neuron_info --type=idl '( 449479075714955186 )'

Create proposal (web UI) Demo get_proposal_info and get_pending_proposals Vote (CLI)

dfx canister call neurons forward_vote --type=idl '( 449479075714955186, 1, variant{Yes} )'
dfx canister call neurons forward_vote --type=idl '( 4368585614685248742, 1, variant{No} )'

Change deadline, execute proposal.

Check blessed versions:

cargo run --bin ic-admin -- --nns-url=https://localhost:8080 get-blessed-replica-versions

An example of a demo scenario for subnet creation

Show the content of a neuron

dfx canister call neurons get_neuron_info --type=idl '( 449479075714955186 )'

Create proposal (web UI) Demo get_proposal_info and get_pending_proposals

# create key material
cargo run --bin ic-prep --release -- --working-dir /tmp/replicas --replica-version 0.8.0 --release-package-url <download url> --node idx:1,subnet_idx:1,xnet_api:"[::1]:2497",public_api:"[::1]:8080" --node idx:2,subnet_idx:1,xnet_api:"[::1]:2497",public_api:"[::1]:8080" --node idx:3,subnet_idx:1,xnet_api:"[::1]:2497",public_api:"[::1]:8080"

# upload the key material to the registry
cargo run --bin ic-admin -- --registry-url https://localhost:8080 add-all-pb-files-in-path /tmp/replicas/node-1
cargo run --bin ic-admin -- --registry-url https://localhost:8080 add-all-pb-files-in-path /tmp/replicas/node-2
cargo run --bin ic-admin -- --registry-url https://localhost:8080 add-all-pb-files-in-path /tmp/replicas/node-3

# create the proposal
cargo run --bin ic-admin -- \
  --nns-url https://localhost:8080 \
  propose-to-create-subnet \
  --summary "Creating subnet" \
  --subnet-handler 3llps-yifaa-aaaaa-aaaaj-waiaa-aaaaa-aaaaa-q \
  3jo2y-lqbaa-aaaaa-aaaap-2ai gfvbo-licaa-aaaaa-aaaap-2ai 32uhy-eydaa-aaaaa-aaaap-2ai

Vote (CLI)

dfx canister call neurons forward_vote --type=idl '( 449479075714955186 )'
dfx canister call neurons forward_vote --type=idl '( 4368585614685248742 )'

Change deadline — since the form requires an epoch time in nano-seconds, execute the following command to get the current time:

echo "$(date +%s)000000000"

Then, execute proposal.

Get the subnet list to verify that the new subnet has been added:

cargo run --bin ic-admin -- --nns-url=https://localhost:8080 get-subnet-list