Difference between revisions of "How-to: Verify SNS decentralization swap proposal"

From Internet Computer Wiki
Jump to: navigation, search
(Replaced content with "'''This page refers to a legacy flow of how an SNS is launched that was deprecated in October 2023. A new page how to verify the new flow will be created shortly and link...")
 
(5 intermediate revisions by 2 users not shown)
Line 1: Line 1:
The process of launching an SNS for a dapp goes through the following main stages:
+
'''This page refers to a legacy flow of how an SNS is launched that was deprecated in October 2023.  
* '''Stage 1:''' An NNS proposal is created to add a principal (a cycles wallet) to a privileged list on the SNS wasm modules canister (SNS-W) on the NNS. By adopting this proposal, the NNS community agrees that this SNS launch should proceed. Technically, if the proposal is adopted, the principal is allowed to perform the next step exactly once.
+
A new page how to verify the new flow will be created shortly and linked to from here. Please find more context on the current SNS launch process [https://internetcomputer.org/docs/current/developer-docs/integrations/sns/launching/ here].'''
* '''Stage 2:''' The principal from Stage 1 makes a call to SNS-W which installs the SNS canisters with pre-approved WASMs that are stored in SNS-W and with chosen initial parameters (e.g., initial neurons, number of tokens). The developers can then hand over the control of the dapp to the SNS.
 
* '''Stage 3:''' An NNS proposal is created to start a decentralization swap for the SNS. In this decentralization swap, participants can contribute ICP in exchange for a share of the initial SNS tokens. This proposal defines the conditions for the decentralization swap.
 
* '''Stage 4:''' By adopting this proposal, the NNS community accepts the swap conditions from Stage 3 and the SNS parameters that were chosen in Stage 2. If the NNS proposal is adopted, the decentralization swap starts after a delay (that was also defined in the proposal in Stage 3).  
 
 
 
This page contains information for NNS neuron holders to consider when voting in '''Stage 3''. Specifically, it explains how the parameters in the NNS proposals can be interpreted and verified, and how SNS canisters can be queried to learn whether the SNS's configurations are valid.
 
All this information is available on chain and can be accessed via (as yet) a manual process where there are two options to interact with the relevant canister: using the [https://internetcomputer.org/docs/current/developer-docs/build/install-upgrade-remove DFX tool], or using the [https://dashboard.internetcomputer.org/ Internet Computer Dashboard]. Below, there are step by step instructions describing how to proceed and, whenever canister calls are involved, explanations for DFX and dashboard interactions are given.
 
 
 
There is also more general information on [https://wiki.internetcomputer.org/wiki/SNS_decentralization_sale_trust the trust and verification required when participating in an SNS decentralization swap].
 
 
 
== Step 1: Verify the Parameters for the Decentralization Swap in the NNS proposal==
 
You will find SNS decentralization swap proposals on the NNS Frontend dapp under the [https://nns.ic0.app/launchpad/ Launchpad tab]. These proposals will also appear in the [https://nns.ic0.app/proposals/ Voting tab] and can be found easily by filtering by the 'SNS & Community Fund' topic.
 
 
 
As mentioned above, some of the parameters for the decentralization swap are set in the NNS proposal. To verify them, you can look at the field Params in the NNS proposal (e.g. in the NNS frontend dapp or on the dashboard). These parameters are submitted as part of the proposal and represent the information with which the NNS governance canister will open the decentralization swap if the proposal is adopted. You can check if the parameters match with those submitted in the proposal summary. In contrast to the parameters here, the summary-part of the proposal can be freely chosen by the proposer and should not be trusted.
 
 
 
This is what the different entries in the proposal mean:
 
* '''minParticipantsIcpE8s''' is the minimum amount of ICP that a swap participant has to invest for a valid participation. The value is given in fractions of 10E-8 of an ICP, which means that you have to remove eight zeros to convert this to an ICP value: In the example, 10000000 e8s = 0.1 ICP.
 
* '''maxIcpE8s''' is the maximum number of ICP that the decentralization swap will collect. If this maximum is reached, the swap will be finished. The value is given in fractions of 10E-8 of an ICP.
 
* '''swapDueTimestampSeconds''' denotes a timestamp when the decentralization swap (previously called “swap”) will be finished in case that the maximum ICP is not reached before this time. The unit of this parameter is in seconds from the Unix epoch. You can use an [https://www.epochconverter.com/ online converter] to convert this to a human readable date and time.
 
* '''minParticipants''' is the minimum number of swap participants for the decentralization swap to be considered successful. If the swap ends and there are less participants, the swap failed.
 
* '''snsTokensE8s''' is the number of SNS tokens that are swapped in the initial decentralization swap. The value is given in fractions of 10E-8 of an SNS token. This value should match the “swap supply allocated to initial decentralization swap” that the SNS was initialized with. This can be checked in Step 3.
 
* '''maxParticipantIcpE8s''' is the maximum contribution that an individual swap participant can make. The value is given in fractions of 10E-8 of an ICP.
 
* '''minIcpE8s''' is the minimum number of ICP that the decentralization swap will collect. The value is given in fractions of 10E-8 of an ICP.
 
* '''communityFundInvestmentE8s''' is the amount that the community fund will collectively spend in maturity on the decentralization swap.
 
* '''targetSwapCanisterId'''
 
* '''neuronBasketCount''' defines the number of neurons each swap participants will receive after a successful decentralization swap. The total SNS tokens that a participant will get are distributed evenly across these neurons.
 
* '''neuronBasketDissolveDelayIntervalSeconds''' this is the difference in dissolve delays between the different neurons in the neuron basket that a swap participant gets. Every swap participant will get a neuron with dissolve delay zero and then with a dissolve delay defined by this parameter, and (in case the neuron basked consists of more than two neurons) with a neuron that is twice this parameter etc..
 
* '''saleDelaySeconds''' defines an optional delay, so that the swap does not get opened immediately after the adoption of the swap proposal, which gives users time to prepare for the swap start.
 
 
 
 
 
== Step 2: Verifying the SNS canisters ==
 
The proposal payload contains the canister ID of the decentralization swap that it will call if the proposal is adopted. A good proposal summary will contain the canister IDs of the other SNS canisters as well as that of the dapp controlled by the SNS.
 
The next step is to verify that the provided decentralization swap is indeed part of an SNS composed of the canisters claimed in the proposal summary. These steps are outlined in the [[How-to: Interact with SNS canisters]] page, but they are repeated below for convenience.
 
 
 
=== 1. Preparation ===
 
 
 
==== DFX ====
 
If you want to use DFX, download these snippets into an empty repo so that DFX can point at the correct canisters. This will allow you to call the canisters and read the output in a human friendly way. Snippet 1: [https://gitlab.com/-/snippets/2431348 dfx.json and candid files]
 
 
 
=== 2. Get the SNS root canister. ===
 
The SNS root canister is the SNS canister that knows about and controls all the other SNS canisters and the dapp canisters. Therefore it is the canister by which a particular SNS can be identified. All SNS root canisters, and thus all SNSs, are listed in the NNS canister called SNS wasm modules canister, or ''SNS-W'' for short. As such, the first step is to verify that the root canister in the proposal summary is in the list of '''deployed_snses'''. SNS-W is a fixed canister ID in the NNS subnet and its canister ID is qaa6y-5yaaa-aaaaa-aaafa-cai.
 
Call the method list_deployed_snses and verify that the root canister ID from the proposal is in the returned list.
 
 
 
==== DFX ====
 
<nowiki>$ dfx canister --network ic call qaa6y-5yaaa-aaaaa-aaafa-cai list_deployed_snses '(record {})'</nowiki>
 
 
 
==== Dashboard ====
 
In the [https://dashboard.internetcomputer.org/canister/qaa6y-5yaaa-aaaaa-aaafa-cai SNS-W canister interface], click ‘+’ next to <syntaxhighlight inline>list_deployed_snses</syntaxhighlight>, and then click “Call”.
 
 
 
=== 3. Get all SNS and dapp canisters ===
 
From the last step, the root canister ID has been verified as a “true” SNS root canister ID deployed through the blessed canister wasm path. You can next get the rest of the canister IDs associated with that SNS by calling <syntaxhighlight inline>list_sns_canisters</syntaxhighlight> on the SNS root canister.
 
The response from this method should have a “swap” entry that matches the swap_canister_id in the NNS proposal from Step 1. By verifying that the canister of this decentralization swap matches, you verify that the NNS proposal will indeed call the swap canister of the SNS that you are inspecting.
 
The response from this method also has a “dapps” entry that should match what the proposal suggests is under control of the SNS.
 
 
 
==== DFX ====
 
<nowiki>$ dfx canister --network ic call zxeu2-7aaaa-aaaaq-aaafa-cai list_sns_canisters '(record {} )'</nowiki>
 
You can verify that the human friendly labels match the canister ids returned by inspecting the canister_ids.json file.
 
 
 
==== Dashboard ====
 
On the dashboard, enter the canister ID of SNS root in the search tab. You should see all the methods of SNS root now. Similarly to the last step, click ‘+’ next to <syntaxhighlight inline>list_sns_canisters</syntaxhighlight>, and then click “Call”.
 
 
 
=== 4. Get the summary of all SNS and dapp canisters ===
 
Finally, you can get the summary and ownership graph of the SNS including the dapps. To do so, call <syntaxhighlight inline>get_sns_canisters_summary</syntaxhighlight> on the SNS root canister. This will return the status of each canister in the SNS, including information such as the canister’s controller and cycles balance.
 
 
 
==== DFX ====
 
<nowiki>$ dfx canister --network ic call zxeu2-7aaaa-aaaaq-aaafa-cai get_sns_canisters_summary '(record {} )'</nowiki>
 
 
 
==== Dashboard ====
 
On the dashboard, where you should still be in the SNS root canister interface from the last Step, click ‘+’ next to <syntaxhighlight inline>get_sns_canisters_summary</syntaxhighlight>, and then click “Call”.
 
 
 
== Step 3: Verifying the initial SNS Parameters ==
 
After Step 2, the IDs of all SNS canisters are known. The next step is to verify the parameters that these canisters have been initialized with.
 
 
 
=== 1. Check the initialization parameters ===
 
The SNS governance canister stores all the initial parameters that were provided to SNS-W when the SNS was first installed. SNS governance can be queried for this information to learn how the SNS was set up. This information includes the initial token distribution, as well as the initial neurons, consisting of developer and airdrop neurons.
 
 
 
==== DFX ====
 
<nowiki>$ dfx canister --network ic call zqfso-syaaa-aaaaq-aaafq-cai get_sns_initialization_parameters '(record {})'</nowiki>
 
 
 
==== Dashboard ====
 
On the dashboard, navigate to the SNS governance canister by entering the canister ID in the search bar. Then, click ‘+’ next to <syntaxhighlight inline>get_sns_initialization_parameters</syntaxhighlight>, and click “Call”.
 
 
 
=== 2. List the neurons that exist in SNS Governance ===
 
You can then see that the neurons available add up to the initialization parameters that you just inspected and that the current stake of them is as expected.
 
 
 
==== DFX ====
 
<nowiki>$ dfx canister --network ic call zqfso-syaaa-aaaaq-aaafq-cai list_neurons '(record { of_principal=null; limit=100: nat32; start_page_at=null  } )'</nowiki>
 
 
 
==== Dashboard ====
 
Navigate to the SNS governance canister by entering the canister ID in the search bar.
 
For example for SNS-1, this is <syntaxhighlight inline>zqfso-syaaa-aaaaq-aaafq-cai</syntaxhighlight>.
 
Then, click ‘+’ next to <syntaxhighlight inline>list_neurons</syntaxhighlight>. You don't need to choose anything for <syntaxhighlight inline>of_principle</syntaxhighlight> if you want to look at all neurons. Choose a limit as described above. For the first page you don't need to select a <syntaxhighlight inline>start_page_at</syntaxhighlight> and can click “Call”.
 
For subsequent calls, the last neuron in the response is needed to resume iteration. Copy the vec from the "id" field from the last neuron and paste it into the <syntaxhighlight inline>start_page_at</syntaxhighlight>  box.
 
 
 
=== 3. Verify that the SNS tokens in the decentralization swap match what was claimed in the proposal ===
 
The SNS tokens that are swapped in the decentralization swap are stored in the SNS ledger account that is owned by the SNS swap canister. Thus, to learn how many tokens are in the decentralization swap, call <syntaxhighlight inline>icrc1_balance_of</syntaxhighlight> to get the balance of the Swap canister. The returned value is given in fractions of 10E-8 of an SNS token. You can now compare this value to '''snsTokensE8s''' that is specified in the NNS proposal.
 
 
 
==== DFX ====
 
<syntaxhighlight>
 
$ dfx canister --network https://ic0.app call zfcdd-tqaaa-aaaaq-aaaga-cai --query icrc1_balance_of '(record {owner = principal "zcdfx-6iaaa-aaaaq-aaagq-cai" })'
 
</syntaxhighlight>
 
 
 
==== Dashboard ====
 
On the dashboard, navigate to the SNS ledger canister by entering the canister ID in the search bar. Then, click ‘+’ next to <syntaxhighlight inline>icrc1_balance_of</syntaxhighlight>, and provide as the argument the ID of the SNS swap canister. Then press <syntaxhighlight inline>call</syntaxhighlight>.
 
 
 
=== 4. Learn how many tokens are in the SNS treasury ===
 
The SNS treasury is a SNS ledger account that is owned by SNS governance. Specifically, it is on a defined subaccount of the SNS governance’s ledger account. To query it you need to compute the subaccount from the SNS governance’s ID.
 
Once you have the subaccount, use <syntaxhighlight inline>icrc1_balance_of</syntaxhighlight> to get the balance of the SNS ledger account that belongs to the SNS treasury.
 
This command will be different for every SNS.
 
 
 
==== DFX ====
 
For example for SNS-1, you can get the result by using:
 
<syntaxhighlight>
 
dfx canister --network https://ic0.app call --query zfcdd-tqaaa-aaaaq-aaaga-cai icrc1_balance_of '(record {owner = principal "zqfso-syaaa-aaaaq-aaafq-cai"; subaccount = blob "\ce\c2\14\5a\75\0f\d4\a4\72\b2\a0\21\f6\df\f1\e4\a9\07\29\97\00\06\2a\0a\02\bc\1e\a6\5c\a2\92\58" })'
 
</syntaxhighlight>
 
 
 
==== Dashboard ====
 
On the dashboard, navigate to the SNS ledger canister by entering the canister ID in the search bar. Then, click ‘+’ next to <syntaxhighlight inline>icrc1_balance_of</syntaxhighlight>, and provide as “owner” the canister ID of SNS governance. Also select the additional argument “subaccount (opt vet nat8)” and enter the required subaccount. Then press “Call”.
 
As mentioned, the subaccount depends on the SNS.
 

Latest revision as of 10:43, 20 November 2023

This page refers to a legacy flow of how an SNS is launched that was deprecated in October 2023. A new page how to verify the new flow will be created shortly and linked to from here. Please find more context on the current SNS launch process here.