Context
The IC Protocol limits message sizes to 2MB, including responses.
Some users need to retrieve over a thousand neurons (typically empty) for various reporting purposes. They are currently unable to list them with this API because of these message size limits, as the responses would be over 2MB.
While there are workarounds, it was determined that adding paging to this API would allow it to scale better into the future, and prevent wasted computation that results in undeliverable messages.
Current Behavior
If a user sends parameter include_neurons_readable_by_caller set to true, the NNS Governance Canister will attempt to send all neurons back to the caller.
In cases where the message size limit is exceeded, the user cannot see any entries on the list, as the response will not be able to be returned through the protocol.
New Behavior
To make it easier for users to retrieve all of their neurons, we propose to serve neurons as a sequence of pages . Each page is a structure with a bounded number of neurons, specifically, at most 500 neurons would be served at a time.
The new API fields will be:
// Canid Request payload
ListNeurons {
... existing fields ...
page_number: opt nat64;
page_size: opt nat64;
}
// Candid Response payload
ListNeuronsResponse {
... existing fields ...
total_pages_available : opt nat64;
}
The new field in the response payload will tell users if more requests are needed.
Most users, who only need active neurons (i.e. neurons with stake or maturity), will get all of the data with one request.
In cases where historical data is required, it will now be accessible, whereas before it was not.
This design should be friendly to users with cold-storage wallets (i.e. air-gapped keys), as they could sign all of the paged requests at the same time, and could send them concurrently as well.
Impact to Existing Clients / Timeline
Currently, fewer than 100 principals have more than 500 neurons, and of those, none have more than 200 active neurons.
Due to the behavior change mentioned in ListNeurons API Change - Empty Neurons, which will omit inactive neurons from the response by default, adding paging to this API should not impact users who need to retrieve their neurons, and will positively impact users who need to retrieve a large number of inactive neurons.
We believe, therefore, that there will be no negative impact of this change, and therefore, it can be rolled out quickly.
We plan to roll out this change in the NNS Governance canister as early as January 27, 2025.
Feedback Requested
Please tell us your thoughts.
If you believe there will be a problem with this plan, please comment below. All feedback is welcome.
Action Required
For users who anticipate needing to get more than 500 neurons from list_neurons, they will need to make their client aware of the paging API.
This means reading the total_pages_available
field, and if its value is greater than 1, making the additional requests needed by reusing the request and adding a 0-indexed page_number (i.e. first page is page_number 0, second page is page_number 1, etc).