How does get_sns_next_version by principal work?

When I try to use the method get_sns_next_version on the NNS SNS-WASM canister (Canister: NNS SNS-WASM - ICP Dashboard), I have the option to pass a governance_canister_id.

If I do so, I always receive the response that there is no next version

(record { next_version = null })

My expectation would be that this method gives me the hashes of the next version. If I manually enter all the individual hashes to the function by defining the current_version argument, it works.

What should I expect when specifying governance_canister_id?

1 Like

Hi Dustin,

Thanks for the question.

Not sure if this is what you have in your mind when you see the interface of get_sns_next_version (this is just a guess, so please correct me if I’m wrong):

The method takes an opt current_version and an opt governance_canister_id, so I can choose to specify one of them, and if I specify the governance_canister_id, the SNS-WASM will know which SNS I’m talking about, and therefore look up the current version for me.

This is not the case - SNS-WASM doesn’t keep a record of the current versions of all the SNSes, and it does not talk to the SNS on behalf of the caller.

Instead, the governance_canister_id is used for looking up special upgrade paths for for a specific SNS, and such special upgrade paths should only be added when such SNS gets stuck in a bad state. To my knowledge, this was only used once for SNS-1 (now Dragginz) in this proposal: Proposal: 105347 - ICP Dashboard. If no special upgrade paths are found by the given principal, it will fall back to the main upgrade paths.

In other words, the caller is indeed expected to always set the current_version.

I personally believe the documentation can be improved, and perhaps how SNS-WASM handles a request with current_version set to null. I’ll discuss within our team.

2 Likes

Hi @jasonzhu , thank you for the response!

Yes, this is exactly how I understood it :slight_smile: Thank you for clarifying! So for now, I need to copy/pasta each module hash to find our how many upgrades I’m behind.