Initialize NNS Governance with Candid

TL;DR

If you don’t have any code/tool to initialize NNS Governance in your local/testing environment, you can stop reading. In short, NNS Governance has been using protobuf to decode the init arguments, and it’s being migrated to using candid.

Background

NNS Governance uses a mixture of protobuf/candid for its interface. As we recognize that having multiple serialization formats is confusing and it makes development unnecessarily complex, both for the people who develop the canister and its clients, we’ve been making some effort to move away from protobuf completely (as part of its interface, note that it still uses protobuf for storage). So far, we have removed all protobuf uses except for 3 API methods: (1) list_neurons_pb (2) manage_neuron_pb (3) init. The first 2 are being deprecated (more details here), and this post is about the init argument.

Note: we expect the init method to be only used in testing/local environments, since we don’t expect the mainnet NNS Governance to be installed/reinstalled.

Proposed Changes

On a high level, there are 3 steps involved:

  1. The NNS Governance canister supports both protobuf/candid formats (#4537 released in 136006)
  2. Clients to switch from protobuf to candid
  3. The NNS Governance canister removes protobuf support (tentative ETA: Apr. 14)

Below we will discuss various cases where someone can be impacted.

Migration Paths

Dfx NNS Extension

The dfx nns extension can be used to initialize NNS canisters locally in order to run tests that depend on NNS canisters. In most cases, we don’t expect any issues using the extension after the NNS Governance init switches to candid, after some changes are added to the extension for backwards compatibility. However, in some cases the users might use the DFX_IC_COMMIT env variable to download an arbitrary version of the NNS Governance canister, which might cause issues if the canister is newer (after step 3) while the code to provide the init argument is older (before step 2). Such issues can be fixed by dfx cache delete and reinstall the NNS extension.

Custom Setup

There can be some cases where the NNS Governance canister wasm is directly installed onto a local replica for testing, where the init argument is prepared by some user code using protobuf encoding. In this case, there will be some migration effort needed to encode using candid instead. Note that if the client uses a pinned version of NNS Governance canister wasm, they should not experience breakage until they try to use a version without protobuf support (when step (3) happens).

Request for Feedback

Any feedback is welcome, especially regarding the timeline when the step (3) happens.

4 Likes

Where are the DID types for the initial parameters? If I’m not mistaken, governance.did in the IC repo doesn’t include those.

1 Like

It does have one. The problem was, it was lying - having the param in .did implies that such a candid-encoded type can be used to initialize it, but it couldn’t. Now it can.

OTOH, I do think the type has more fields than it should have (it has been this way since genesis though). Perhaps a future improvement is to remove some fields that don’t make sense as part of init.

1 Like

Ah right I missed that early morning, thanks.

To summarize, I’ll have to replace - some day - those protobuf stuff:

With a copy/paste (:cry:) of those JS DID records available here: