feat(sns): use NNS Governance for maturity modulation#10239
Draft
jasonz-dfinity wants to merge 2 commits into
Draft
feat(sns): use NNS Governance for maturity modulation#10239jasonz-dfinity wants to merge 2 commits into
jasonz-dfinity wants to merge 2 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Switches SNS Governance from reading maturity modulation from the CMC to the new get_maturity_modulation query on NNS Governance. Adds a new client abstraction, migrates SNS Governance and its tests, and seeds NNS Governance with a neutral default at init so callers get a usable response immediately.
Changes:
- New
NnsGovernanceClienttrait,RealNnsGovernanceClient(bounded-waitic_cdkcall), andFakeNnsGovernanceClientinrs/nervous_system/clients/. - SNS Governance replaces its
cmcfield withnns_governance;update_maturity_modulationnow skips when NNS returnsNone, otherwise storescurrent_value_permyriadintocurrent_basis_points. - NNS Governance init seeds
heap_data.maturity_modulationto a neutralSome(0)permyriad withupdated_at_days_since_epoch = None; tests updated accordingly.
Reviewed changes
Copilot reviewed 19 out of 19 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| rs/nervous_system/clients/src/nns_governance_client.rs | New client module: trait, real impl, and test fake. |
| rs/nervous_system/clients/src/lib.rs | Expose new nns_governance_client module. |
| rs/nns/governance/src/heap_governance_data.rs | Seed maturity_modulation with neutral 0 permyriad at init. |
| rs/nns/governance/src/governance/tests/get_maturity_modulation.rs | Test renamed and updated for new init default. |
| rs/nns/governance/src/timer_tasks/update_icp_xdr_rate_related_data_tests.rs | Update assertions for new init default. |
| rs/sns/governance/canister/canister.rs | Wire RealNnsGovernanceClient(NNS_GOVERNANCE_CANISTER_ID) into Governance. |
| rs/sns/governance/src/governance.rs | Replace cmc: Box<dyn CMC> with nns_governance and use it in update_maturity_modulation. |
| rs/sns/governance/src/extensions.rs, proposal.rs, proposal/advance_sns_target_version.rs | Test setup migrated from MockCMC to FakeNnsGovernanceClient. |
| rs/sns/governance/src/governance/*_tests.rs | Test setups migrated from FakeCmc to FakeNnsGovernanceClient. |
| rs/sns/governance/tests/fixtures/mod.rs | Remove CmcFixture; switch GovernanceCanisterFixture to FakeNnsGovernanceClient. |
| rs/sns/governance/tests/governance.rs | Update fixture field reference. |
| rs/sns/integration_tests/src/neuron.rs | Migrate imports/comments and call sites to FakeNnsGovernanceClient. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Mission 70 moved the maturity modulation computation from the CMC into NNS
Governance, which now exposes it via the new
get_maturity_modulationquery.This switches SNS Governance to read maturity modulation from NNS Governance
instead of the CMC, so the legacy CMC-side flow can be deprecated.
What
NnsGovernanceClienttrait +RealNnsGovernanceClientinrs/nervous_system/clients/, using bounded-waitic_cdkcalls. Modeled onthe existing
ExchangeRateCanisterClient.cmcfield withnns_governance. The periodicupdate_maturity_modulationtask now calls NNS Governance'sget_maturity_modulationand storescurrent_value_permyriad(numericallyequivalent to basis points) in SNS's existing
current_basis_pointsfield.SNS keeps the prior "skip update when no value" contract.
heap_data.maturity_modulationwitha neutral 0 permyriad value so callers get a usable response immediately
rather than
Nonewhileupdate_icp_xdr_rate_related_dataaccumulatesenough XRC price history to compute a real value.
updated_at_days_since_epochis leftNoneso the periodic task does nottreat the placeholder as "already updated today".
MockCMC/FakeCmcto a newFakeNnsGovernanceClient.Testing
get_maturity_modulationcovers the init default.update_icp_xdr_rate_related_data_testsassertions to reflect thenew init default.
//rs/sns/integration_tests:neuron_testexercises the SNS to NNS Governancepath end-to-end (including disburse_maturity and stake_maturity flows).