NNS Updates 2025-01-24

Another week, another NNS upgrade proposal.

NNS Governance

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

# Upgrade the Governance Canister to Commit 03393bc

__Proposer__: arshavir.ter.gabrielyan at dfinity.org

__Source code__: [03393bc817da78cdc27190eaa388b8f6f8990365][new-commit]

[new-commit]: https://github.com/dfinity/ic/tree/03393bc817da78cdc27190eaa388b8f6f8990365


## Features & Fixes

###  Added

####  List Neurons Paging

Two new fields are added to the request, and one to the response.

The request now supports `page_size` and `page_number`.  If `page_size` is greater than 
`MAX_LIST_NEURONS_RESULTS` (currently 500), the API will treat it as `MAX_LIST_NEURONS_RESULTS`, and
continue procesisng the request.  If `page_number` is None, the API will treat it as Some(0)

In the response, a field `total_pages_available` is available to tell the user how many
additional requests need to be made.

This will only affect neuron holders with more than 500 neurons, which is a small minority.

This allows neuron holders with many neurons to list all of their neurons, whereas before, 
responses could be too large to be sent by the protocol.

####  Periodic Confirmation

Enabled voting power adjustment and follow pruning.

#####  Prior Work

This section describes related changes in previous releases.

We already started recording how long it's been since neurons have confirmed
their following (aka refreshed voting power). Neurons were also given the
ability to confirm their following. Those who have never confirmed are
considered as having refreshed on Sep 1, 2024.

This feature was proposed and approved in motion [proposal 132411].

[proposal 132411]: https://dashboard.internetcomputer.org/proposal/132411

#####  New Behavior(s) (In This Release)

With this enablement, not refreshing for more than 6 months will start to affect
the neuron. More precisely,

1. If a neuron has not refreshed in 6 months, then votes have less influence on
   the outcome of proposals.

2. If a neuron has not refreshed in 7 months,

    a. It stops following other neurons (except on the NeuronManagement topic;
       those followees are retained).

    b. Its influence on proposals goes to 0.

###  Changed

* `InstallCode` proposal payload hashes are now computed when making the proposal instead of when
  listing proposal. Hashes for existing proposals are backfilled.


## New Commits

```
$ git log --format="%C(auto) %h %s" b5192581ccd35b67fe5a1f795ead9cbcd25956d6..03393bc817da78cdc27190eaa388b8f6f8990365 --  ./rs/nns/governance ./rs/sns/init
 626d1bb787 feat(nns): Add pagination to list_neurons API (#3358)
 026eda8b9a chore: Bump Candid to 0.10.12 (#3566)
 01e83df091 feat(nns): Avoid recomputing wasm/arg hashes during read operations (#3490)
 922017281e refactor(nns): Delete ManageNeuronResponse from governance.proto. (#3573)
 367ab73788 refactor(nns): Deleted ListNeurons from NNS governance.proto. (#3546)
 744f4683df perf(nns): Add a benchmark for listing proposals (#3489)
 fc2787097c chore: bump rust to 1.84 (#3469)
 fb3d35d0dd chore(nns): Remove one-off fix for broken neuron after deployment (#3452)
 f8f274d899 feat(IC-1579): TLA annotations for disburse_to_neuron (#3411)
 16ee8b23a6 chore(nns): Add a comment on MAX_NEURONS_FUND_PARTICIPANTS about its effect on instructions (#3426)
 c8be4fc1b4 feat(IC-1579): TLA instrumentation for `disburse_neuron` (#3337)
```


## Current Version

__Current git hash__: b5192581ccd35b67fe5a1f795ead9cbcd25956d6

__Current wasm hash__: 5b67e1d273afb691a74ff29e0a495fb2ce7ee31196af58d801a8ce86a7dc4320


## Verification

See the general instructions on [how to verify] proposals like this. A "quick
start" guide is provided here.

[how to verify]: https://github.com/dfinity/ic/tree/03393bc817da78cdc27190eaa388b8f6f8990365/rs/nervous_system/docs/proposal_verification.md


### WASM Verification

See ["Building the code"][prereqs] for prerequisites.

[prereqs]: https://github.com/dfinity/ic/tree/03393bc817da78cdc27190eaa388b8f6f8990365/README.adoc#building-the-code

```
# 1. Get a copy of the code.
git clone git@github.com:dfinity/ic.git
cd ic
# Or, if you already have a copy of the ic repo,
git fetch
git checkout 03393bc817da78cdc27190eaa388b8f6f8990365

# 2. Build canisters.
./ci/container/build-ic.sh -c

# 3. Fingerprint the result.
sha256sum ./artifacts/canisters/governance-canister.wasm.gz
```

This should match `wasm_module_hash` field of this proposal.
2 Likes

Proposal 134988 – Zane | CodeGov

Vote: ADOPT

Reason: Build completes successfully, both hashes and reviewed commits match their descriptions, so I’ve decided voted to adopt.
134988

626d1bb787 Added page_number and page_size optional fields to ListNeurons struct, these are used to paginate the response of the list_neurons API, if they aren’t provided the default values are 0 and 500 respectively. Added total_pages_available optional field to ListNeuronsResponse to inform the caller of pages available with the requested paging configuration. get_neuron_ids_by_principal has been slightly modified to return a BTreeSet instead of a Vec of neuron ids, then in list_neurons the requested ids are chunked into a matrix based on the provided page size and only the ones into the requested page number are collected and returned.
This is a nice addition as it makes the API more elastic and future proof, while not causing breaking changes for existing clients, exception made for those who were fetching more than 500 non empty neurons, of which there are apparently none. The only ones affected would be blackholed canisters, whose functionality will be limited in the future if more principals with hundreds of neurons start becoming a thing, but in similar scenarios they’d have probably broken anyway due to the 2MB message limit.

01e83df091 Extended InstallCode struct with wasm_module_hash and arg_hash fields, these are used to store wasm and args hashes for install code proposals, removing the need to recompute them everytime the proposal is fetched, which in turns improves performance for list_proposals API. backfill_install_code_hashes has been added to iterate over all proposals and fill both hashes for old install code proposals, it is called by new_restored so that it runs once after an upgrade. Protobuf conversion logic has been updated so that when converting from an internal representation to the one used in the API, the hashes are not computed but instead fetched from relevant fields and when converting from a InstallCodeRequest to an internal representation, the hashes are computed and stored in the fields.

922017281e Removed ManageNeuronResponse from NNS governance.proto and moved its implementation from governance.rs to ic_nns_governance.pb.v1.rs.

367ab73788 Removed ListNeurons and ListNeuronsResponse from NNS governance.proto alongside related Rust definitions and conversion logic.

744f4683df Added benchmark for list_proposals API.

fc2787097c Bumped Rust version from 1.82 to 1.84, fixed a few issues raised by clippy warnings.

026eda8b9a Bumped candid crate from version 0.10.6 to 0.10.12.

fb3d35d0dd Removed logic and related test that was added with a47dde8acf to fix a locked neuron. Both the bug and neuron have been fixed so there is no need for it anymore.

f8f274d899 Same as description.

16ee8b23a6 Documented MAX_NEURONS_FUND_PARTICIPANTS impact on performance with a comment.

c8be4fc1b4 Same as description.

About CodeGov

CodeGov has a team of developers who review and vote independently on the following proposal topics: IC-OS Version Election, Protocol Canister Management, Subnet Management, Node Admin, and Participant Management. The CodeGov NNS known neuron is configured to follow our reviewers on these topics and Synapse on most other topics. We strive to be a credible and reliable Followee option that votes on every proposal and every proposal topic in the NNS. We also support decentralization of SNS projects such as WaterNeuron and KongSwap with a known neuron and credible Followees.

Learn more about CodeGov and its mission at codegov.org.

1 Like

proposal - 134988 – Cyberowl | CodeGov

Vote: ADOPT

Reason:

I successfully built and verified the hash. All the commit descriptions match their code changes.

Hash Match: MATCH

Feedback: NONE

Proposer Check: MATCH

Overall Summary:

Introduced pagination for neuron management via BTreeSet ordering and consolidating governance APIs to eliminate redundancy. Added formal verification instrumentation (TLA+) and updated core dependencies/Rust toolchains.

Commits Summary

626d1bb787
Added page_number/page_size to ListNeurons request and total_pages_available to response. Changed neuron ID storage from HashSet/Vec to BTreeSet for ordered pagination

026eda8b9a
Updated the candid crate in multiple lockfiles (from 0.10.10 to 0.10.12/0.10.13). Synced Bazel references for candid to a matching version (^0.10.12).

01e83df091
Updated canbench_results.yml with new instruction counts in multiple benchmarks. Added optional wasm_module_hash and arg_hash fields to InstallCode in the governance proto and code. Implemented backfill logic for existing proposals to auto-calculate and store these hashes.

922017281e
Removed the old ManageNeuronResponse definitions from the governance proto in favor of a single, shared version in the ic_nns_governance_api crate. Dropped duplicate code converting between multiple response structs, consolidating everything into the ic_nns_governance_api::pb::v1 module.

367ab73788
Removed the direct ic-nns-governance dependency from Cargo.lock and other files, replacing it with ic-nns-governance-api. Adjusted the Rosetta tests/code to rely on ic-nns-governance-api types for listing and managing neurons.

744f4683df
Updated canbench_results.yml to reflect new instruction counts across a range of benchmarks cascading_vote_all_heap, draw_maturity_from_neurons_fund_heap. Added a helper function create_service_nervous_system_action_with_large_payload to generate test proposals with substantial payload sizes.

fc2787097c
Updated the CI Docker images. Bumped Rust toolchain from 1.82.0 to 1.84.0. Cleaned up numerous code patterns in Rust code.

fb3d35d0dd
Removed schedule_locked_spawning_neuron_fix() from canister.rs and the corresponding fix_locked_spawn_neuron method in governance.rs.

f8f274d899
Added a new disburse_to_neuron TLA instrumentation file (disburse_to_neuron.rs) and references to it in mod.rs. Inserted TLA log statements in the governance method to record critical variables parent_neuron_id, disburse_amount.

16ee8b23a6
Clarifies the rationale and trade-offs behind the MAX_NEURONS_FUND_PARTICIPANTS value.

c8be4fc1b4
Added a new TLA specification and logging for the disburse_neuron . Introduced and integrated async-trait support into TLA instrumentation macros.

About CodeGov…(click to expand)

CodeGov has a team of developers who review and vote independently on the following proposal topics: IC-OS Version Election, Protocol Canister Management, Subnet Management, Node Admin, and Participant Management. The CodeGov NNS known neuron is configured to follow our reviewers on these topics and Synapse on most other topics. We strive to be a credible and reliable Followee option that votes on every proposal and every proposal topic in the NNS. We also support decentralization of SNS projects such as WaterNeuron and KongSwap with a known neuron and credible Followees.

Learn more about CodeGov and it’s mission at codegov.org.

1 Like

Approve Proposal 134988

Proposal

  • Canister id rrkah-fqaaa-aaaaa-aaaaq-cai is indeed the governance canister.
  • The upgrade args correspond to the empty args.
  • The install mode is indeed upgrade.
  • The wasm hash is reproducible.

Screenshot 2025-01-27 at 10.30.46

In-depth Review

  • Paging Implementation:

    • The code handles page_number and page_size with a cap at MAX_LIST_NEURONS_RESULTS (500). The total_pages_available computation is part of the response.
  • Periodic Confirmation:

    • Neurons not refreshed within specified periods see a reduction in voting influence and may stop following others.
  • InstallCode Hashes:

    • Hashes are now generated when proposals are created, ensuring consistency throughout the proposal’s lifecycle.
  • Minor Changes:

    • BUILD.bazel: Adjustments to visibility rules and the introduction of DID_FILES for better module management.

    • API Changes: New fields in ListNeurons and ListNeuronsResponse are reflected in proto files and the corresponding conversion functions in conversions.rs.

    • Performance: Benchmarks in canbench_results.yml reflect minor changes in instruction counts due to the new features.

1 Like

Proposal #134988 for Governance — Zack | CodeGov

Vote: Adopted

Reason:
To be edited

1 Like