OpenChat Sale Finalization

TLDR: There was a minor issue when finalizing the Sale for the OpenChat SNS. It was quickly identified and fixed, and the OpenChat Sale is now complete.


After a Decentralization Sale, the sale must be finalized. This happens during a call to finalize_swap.

This finalization happens in 5 stages:

  1. Transfer ICP from sale accounts to the main SNS Governance account on the ICP Ledger
  2. Have NNS Governance settle Community Fund participation
  3. Transfer SNS tokens into the Neuron accounts for configured baskets on the SNS Ledger
  4. Create Sale Neurons by calling claim_swap_neurons on SNS Governance
  5. Set SNS Governance to Normal mode.

The Problem

Steps 1-3 all proceeded without any problem, but step 4 immediately failed with an error:

Encountered a CanisterCallError when claiming a batch of neurons. Err: CanisterCallError { code: Some(5), description: "IC0522: Canister 2jvtu-yqaaa-aaaaq-aaama-cai exceeded the instruction limit for single message execution." }

This happened when the claim_swap_neurons endpoint was called with the maximum batch size from the SNS Swap canister, of 11565 NeuronRecipes.

This problem did not arise during testing, and we are working on identifying the underlying reason why it did not show up in test environments.

The Fix

The solution was to reduce the amount of work done in each request.

This was accomplished by changing the following lines in rs/sns/swap/src/

let neuron_parameters_size = mem::size_of::<NeuronParameters>();
let batch_limit =  

to instead be:

let batch_limit = 500_usize;

In order to ensure no data would be lost, we reproduced a sale in progress in a test environment with a large number of neurons, performed an upgrade to the new version, and finalized successfully.

The changes made were minimal, but we still wanted to be extremely cautious in making changes to a live Sale canister pre-finalization.

Sale canisters are controlled by the NNS root canister. We therefore submitted an NNS proposal to upgrade the sale canister.

You can see the proposal, and below are links to the two commits referenced in the proposal.

Add logging for finalize_swap
Merge branch ‘fixed-batch-length’ into 'master


After the propsal was adopted, finalize_swap was re-run, which immediately resulted in a successful close of the sale.

OpenChat has been successfully decentralized! :tada: