Proposal to Upgrade the Oldest Swap Canisters

,

Dear SNS Communities,

TL;DR: In the coming weeks, DFINITY’s Governance team plans to submit NNS proposals to upgrade the oldest Swap canisters. If adopted, these upgrades will enhance Swaps in several key ways, as outlined below.

Currently, the Swap canister is the only component within the SNS framework that is upgraded by the NNS (rather than an SNS) community. Since the primary purpose of a Swap canister is fulfilled once an SNS is decentralized, SNS communities typically do not upgrade their Swaps. As a result, some SNSs still operate on very outdated Swap versions (dating back to early 2023) that haven’t been updated since.

Meanwhile, numerous improvements have been made to the Swap canister code in recent months. These include upgrading the CDK, moving periodic tasks from heartbeats to ic-cdk timers, and stopping these tasks after a swap completes (which wasn’t feasible with heartbeats).

The API has also been enhanced, adding fields like direct_participation_icp_e8s and neurons_fund_participation_icp_e8s. For existing Swaps, these API changes enable more systematic audits, bringing them in line with the more recently launched SNSs.

Upgrading Swaps to the Latest Version

Each Swap canister can be upgraded to the latest version with just one NNS proposal. It is not necessary to run all intermediate upgrades — our testing indicates that simply populating the two new fields with existing data allows for a safe upgrade of older Swaps. We verified this by comparing the Swap.get_state responses before and after the upgrade, covering both post-upgrade hooks and migrations, and ensuring that a subsequent upgrade functions correctly (covering pre-upgrade hooks).

Periodic Tasks in Swap

Swaps rely on periodic tasks for two main purposes:

  1. Advancing the Swap state machine before the SNS is launched, including transitions such as Adopted → Open, Open → Committed, or Open → Aborted.
  2. Automatically finalizing the swap process once the state reaches Committed or Aborted.

These periodic tasks are no longer necessary after the SNS is launched. Therefore, we propose to stop them for all launched SNSs. For upcoming SNSs, this will happen automatically (more details can be found here: SNS Updates, October 11, 2024).

Further information about the Swap canister is available here: Swap.proto.

Next steps

The Governance team has already proposed publishing a new version of Swap ( SNS Updates 2024-11-24) which includes the necessary data migration for upgrading older Swaps. Our next step will be to propose upgrading the oldest Swap canister (from Dragginz) to this newly published version.

To maintain a steady pace of NNS proposals, we plan to limit the number of Swap upgrade proposals to approximately 10 per week, continuing this process until all remaining Swaps have been updated to the desired version with the more efficient implementation of periodic tasks.

Planned upgrade order of existing Swap canisters

No SNS Swap Release date Swap canister ID Swap Module hash Swap git_commit_id
1 Dragginz 2023-02-23 zcdfx-6iaaa-aaaaq-aaagq-cai 6e6ac7ca6bce8f24524ba131a852637e10e711cddeb25e6be9f9ab1b0af4c611 9bb8f35cccd013b38657c67964c39d48fac6353f
2 OpenChat 2023-03-03 2hx64-daaaa-aaaaq-aaana-cai 028aa2d9817903fe8c5b94f2f31c596b682b013d4ac8acbb74d5a91ac56bc0b7 932c1bfc04728783a815e0867b579c1eb26df99d
3 ICGhost 2023-05-24 4f5dx-pyaaa-aaaaq-aaa3q-cai 9ed73e1547a29255d28878f40da303b9069119e4c8d73ac5e8295b300777f358 a1f503d20b7846375c74ce5f7d0f8f6620ab7511
4 Kinic 2023-05-24 7sppf-6aaaa-aaaaq-aaata-cai 9ed73e1547a29255d28878f40da303b9069119e4c8d73ac5e8295b300777f358 a1f503d20b7846375c74ce5f7d0f8f6620ab7511
5 YRAL 2023-05-24 6eexo-lqaaa-aaaaq-aaawa-cai 9ed73e1547a29255d28878f40da303b9069119e4c8d73ac5e8295b300777f358 a1f503d20b7846375c74ce5f7d0f8f6620ab7511
6 BOOM DAO 2023-07-24 vuqiy-liaaa-aaaaq-aabiq-cai 4d020100fd96d39d1429dee74a8032e0acbc1a6343e540a2ceb6f6da79f9f2dc af4f0fc316a5b607365253fb67026a34412c208e
7 Catalyze 2023-07-24 uc3qt-6yaaa-aaaaq-aabnq-cai 4d020100fd96d39d1429dee74a8032e0acbc1a6343e540a2ceb6f6da79f9f2dc af4f0fc316a5b607365253fb67026a34412c208e
8 DecideAI DAO 2023-07-24 xhply-dqaaa-aaaaq-aabga-cai 4d020100fd96d39d1429dee74a8032e0acbc1a6343e540a2ceb6f6da79f9f2dc af4f0fc316a5b607365253fb67026a34412c208e
9 Nuance 2023-08-21 q2nfe-mqaaa-aaaaq-aabua-cai 0575c056225b15465f11ca79f7297335f7a264e9498c7464ae1c0ac5bd96f921 d7024323737506a270ad2c4d4872eb8e77effb54
10 Seers 2023-08-21 rmg5p-zaaaa-aaaaq-aabra-cai 0575c056225b15465f11ca79f7297335f7a264e9498c7464ae1c0ac5bd96f921 d7024323737506a270ad2c4d4872eb8e77effb54
11 SONIC 2023-08-21 qils5-aaaaa-aaaaq-aabxa-cai 0575c056225b15465f11ca79f7297335f7a264e9498c7464ae1c0ac5bd96f921 d7024323737506a270ad2c4d4872eb8e77effb54
12 Gold DAO 2023-12-08 t7z6p-ryaaa-aaaaq-aab7q-cai 1ffb5738c9c9acde14c5fd83395579665cb41829f7819acf87feb66d3c2caf4e d1315a1b9b002f177526faa5ee6d7e1e1aa3a22a
13 Neutrinite 2023-12-08 f25or-jiaaa-aaaaq-aaceq-cai 1ffb5738c9c9acde14c5fd83395579665cb41829f7819acf87feb66d3c2caf4e d1315a1b9b002f177526faa5ee6d7e1e1aa3a22a
14 TRAX 2023-12-08 ezrhx-5qaaa-aaaaq-aacca-cai 1ffb5738c9c9acde14c5fd83395579665cb41829f7819acf87feb66d3c2caf4e d1315a1b9b002f177526faa5ee6d7e1e1aa3a22a
15 ICLighthouse DAO 2024-01-12 habgn-xyaaa-aaaaq-aaclq-cai f1414b67ca335d15a7d9fc021f6afa9002143af3c7ce10edf48d4ccd9b9d1703 6ed74ab9788e4601bbbf02ae1ce92b7f480387df
16 Sneed 2024-01-12 hshru-3iaaa-aaaaq-aaciq-cai f1414b67ca335d15a7d9fc021f6afa9002143af3c7ce10edf48d4ccd9b9d1703 6ed74ab9788e4601bbbf02ae1ce92b7f480387df
17 ICPanda DAO 2024-02-22 c424i-4qaaa-aaaaq-aacua-cai 9531eafc54069e835636011e17a19a4709a3123c6a4d2f56c58a44c3cc31e1d6 48e7e1f072c259810236488ff770c809f362fb63
18 ELNA AI 2024-02-22 grlys-pqaaa-aaaaq-aacoa-cai 9531eafc54069e835636011e17a19a4709a3123c6a4d2f56c58a44c3cc31e1d6 48e7e1f072c259810236488ff770c809f362fb63
19 OpenFPL 2024-02-22 dkred-jaaaa-aaaaq-aacra-cai 9531eafc54069e835636011e17a19a4709a3123c6a4d2f56c58a44c3cc31e1d6 48e7e1f072c259810236488ff770c809f362fb63
20 ICPSwap 2024-02-22 ch7an-giaaa-aaaaq-aacwq-cai 9531eafc54069e835636011e17a19a4709a3123c6a4d2f56c58a44c3cc31e1d6 48e7e1f072c259810236488ff770c809f362fb63
21 Yuku DAO 2024-02-22 a2cof-vaaaa-aaaaq-aacza-cai 9531eafc54069e835636011e17a19a4709a3123c6a4d2f56c58a44c3cc31e1d6 48e7e1f072c259810236488ff770c809f362fb63
22 EstateDAO 2024-03-28 bcl3g-3aaaa-aaaaq-aac5a-cai a76073744c6ff5e4e4f0bb0d5f8589abd9b70e4123cceb75d27171d3f209993f 300dc603a92b5f70dae79229793c902f346af3cc
23 ICPCC DAO LLC 2024-04-12 lwslc-cyaaa-aaaaq-aadfq-cai a4b4008c9ae41e3a06cd0a81b74542270184024d8ca5d71a7f71137aa7e575e5 d7ddd2969837fc6c9c0b86d331f7bc61e9e78bd1
24 Motoko 2024-04-12 kv6ce-waaaa-aaaaq-aadda-cai a4b4008c9ae41e3a06cd0a81b74542270184024d8ca5d71a7f71137aa7e575e5 d7ddd2969837fc6c9c0b86d331f7bc61e9e78bd1
25 ORIGYN 2024-04-12 jxl73-gqaaa-aaaaq-aadia-cai a4b4008c9ae41e3a06cd0a81b74542270184024d8ca5d71a7f71137aa7e575e5 d7ddd2969837fc6c9c0b86d331f7bc61e9e78bd1
26 WaterNeuron 2024-05-24 ipcky-iqaaa-aaaaq-aadma-cai 59ec188507b12fcb6e579db7b570a59f2a7236e80c46494a6ef228ef8acd1ef5 d1504fc4265703c5c6a73098732a4256ea8ff6bf
27 CYCLES-TRANSFER-STATION 2024-06-21 iuhw5-siaaa-aaaaq-aadoq-cai 67f64e705afd70c0de03529a8b914f122b3fb8920d9e9d81e357b8b5e2a4d10a b39f782ae9e976f6f25c8f1d75b977bd22c81507
28 DOGMI 2024-06-21 n223b-vqaaa-aaaaq-aadsa-cai 67f64e705afd70c0de03529a8b914f122b3fb8920d9e9d81e357b8b5e2a4d10a b39f782ae9e976f6f25c8f1d75b977bd22c81507
29 ICVC 2024-06-21 mzwsh-biaaa-aaaaq-aaduq-cai 67f64e705afd70c0de03529a8b914f122b3fb8920d9e9d81e357b8b5e2a4d10a b39f782ae9e976f6f25c8f1d75b977bd22c81507
4 Likes

The NNS proposal to upgrade Dragginz’s Swap canister is live:

https://dashboard.internetcomputer.org/proposal/133460

Those changes look good to me, I definitely understood some of those words you used.

1 Like

The upgrade for Dragginz Swap canister succeeded, and the periodic tasks were ported from heartbeats to timers which run approximately 60 times less frequently than heartbeats.

However, I made a mistake in the condition to decide if timers are needed, relying on automatic Swap finalization (automatic finalization was introduced after Dragginz, a.k.a SNS-1, first launched). Due to this mistake, Dragginz Swap did not stop running periodic tasks just yet. This mistake has since been fixed, and regression tests were added to ensure that all existing Swaps would stop running their periodic tasks (since there’s no more work left for a Swap after it launched).

We have thus proposed (1) to publish another Swap upgrade and (2) to upgrade Dragginz Swap once more, ensuring it won’t waste resources by running (useless) periodic tasks.

  1. https://dashboard.internetcomputer.org/proposal/133488
  2. https://dashboard.internetcomputer.org/proposal/133489

DFINITY plans to vote on these two proposals this Friday. Assuming this time the upgrade goes as expected, we will proceed with the above-mentioned plan from next week.

2 Likes

Update.

The community has adopted the first batch of 10 Swap upgrade proposals:

  1. Upgrade Dragginz Swap canister (zcdfx-6iaaa-aaaaq-aaagq-cai): https://dashboard.internetcomputer.org/proposal/133806
  2. Upgrade OpenChat Swap canister (2hx64-daaaa-aaaaq-aaana-cai): https://dashboard.internetcomputer.org/proposal/133807
  3. Upgrade ICGhost Swap canister (4f5dx-pyaaa-aaaaq-aaa3q-cai): https://dashboard.internetcomputer.org/proposal/133808
  4. Upgrade Kinic Swap canister (7sppf-6aaaa-aaaaq-aaata-cai): https://dashboard.internetcomputer.org/proposal/133809
  5. Upgrade YRAL Swap canister (6eexo-lqaaa-aaaaq-aaawa-cai): https://dashboard.internetcomputer.org/proposal/133810
  6. Upgrade BOOM DAO Swap canister (vuqiy-liaaa-aaaaq-aabiq-cai): https://dashboard.internetcomputer.org/proposal/133811
  7. Upgrade Catalyze Swap canister (uc3qt-6yaaa-aaaaq-aabnq-cai): https://dashboard.internetcomputer.org/proposal/133812
  8. Upgrade DecideAI DAO Swap canister (xhply-dqaaa-aaaaq-aabga-cai): https://dashboard.internetcomputer.org/proposal/133813
  9. Upgrade Nuance Swap canister (q2nfe-mqaaa-aaaaq-aabua-cai): https://dashboard.internetcomputer.org/proposal/133814
  10. Upgrade Seers Swap canister (rmg5p-zaaaa-aaaaq-aabra-cai): https://dashboard.internetcomputer.org/proposal/133815

The second batch of another 10 Swap upgrade proposals is live:

  1. SONIC qils5-aaaaa-aaaaq-aabxa-cai
    https://dashboard.internetcomputer.org/proposal/133864
  2. Gold DAO t7z6p-ryaaa-aaaaq-aab7q-cai
    https://dashboard.internetcomputer.org/proposal/133865
  3. Neutrinite f25or-jiaaa-aaaaq-aaceq-cai
    https://dashboard.internetcomputer.org/proposal/133866
  4. TRAX ezrhx-5qaaa-aaaaq-aacca-cai
    https://dashboard.internetcomputer.org/proposal/133867
  5. ICLighthouse DAO habgn-xyaaa-aaaaq-aaclq-cai
    https://dashboard.internetcomputer.org/proposal/133868
  6. Sneed hshru-3iaaa-aaaaq-aaciq-cai
    https://dashboard.internetcomputer.org/proposal/133869
  7. ICPanda DAO c424i-4qaaa-aaaaq-aacua-cai
    https://dashboard.internetcomputer.org/proposal/133870
  8. ELNA AI grlys-pqaaa-aaaaq-aacoa-cai
    https://dashboard.internetcomputer.org/proposal/133871
  9. OpenFPL dkred-jaaaa-aaaaq-aacra-cai
    https://dashboard.internetcomputer.org/proposal/133872
  10. ICPSwap ch7an-giaaa-aaaaq-aacwq-cai
    https://dashboard.internetcomputer.org/proposal/133873

Please note that there’s a typo in the verification instructions,

Instead of
sha256sum ./artifacts/canisters/swap-canister.wasm.gz, the command should be
sha256sum ./artifacts/canisters/sns-swap-canister.wasm.gz. This will be fixed for the third batch.

2 Likes

Final update. With the following proposals being adopted, all 30 Swaps are now updated to the latest version with the more efficient implementation of periodic tasks (using timers rather than heartbeats).

  1. Yuku DAO a2cof-vaaaa-aaaaq-aacza-cai
    https://dashboard.internetcomputer.org/proposal/133910

  2. EstateDAO bcl3g-3aaaa-aaaaq-aac5a-cai
    https://dashboard.internetcomputer.org/proposal/133911

  3. ICPCC DAO LLC lwslc-cyaaa-aaaaq-aadfq-cai
    https://dashboard.internetcomputer.org/proposal/133912

  4. Motoko kv6ce-waaaa-aaaaq-aadda-cai
    https://dashboard.internetcomputer.org/proposal/133913

  5. ORIGYN jxl73-gqaaa-aaaaq-aadia-cai
    https://dashboard.internetcomputer.org/proposal/133914

  6. WaterNeuron ipcky-iqaaa-aaaaq-aadma-cai
    https://dashboard.internetcomputer.org/proposal/133915

  7. CYCLES-TRANSFER-STATION iuhw5-siaaa-aaaaq-aadoq-cai
    https://dashboard.internetcomputer.org/proposal/133916

  8. DOGMI n223b-vqaaa-aaaaq-aadsa-cai
    https://dashboard.internetcomputer.org/proposal/133917

  9. ICVC mzwsh-biaaa-aaaaq-aaduq-cai
    https://dashboard.internetcomputer.org/proposal/133918

  10. KongSwap okjrh-jqaaa-aaaaq-aad2a-cai
    https://dashboard.internetcomputer.org/proposal/133919

3 Likes