Skip to content

feat(sns): use NNS Governance for maturity modulation#10239

Draft
jasonz-dfinity wants to merge 2 commits into
masterfrom
use-maturity-modulation-for-sns
Draft

feat(sns): use NNS Governance for maturity modulation#10239
jasonz-dfinity wants to merge 2 commits into
masterfrom
use-maturity-modulation-for-sns

Conversation

@jasonz-dfinity
Copy link
Copy Markdown
Contributor

Why

Mission 70 moved the maturity modulation computation from the CMC into NNS
Governance, which now exposes it via the new get_maturity_modulation query.
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

  • Add a NnsGovernanceClient trait + RealNnsGovernanceClient in
    rs/nervous_system/clients/, using bounded-wait ic_cdk calls. Modeled on
    the existing ExchangeRateCanisterClient.
  • SNS Governance: replace the cmc field with nns_governance. The periodic
    update_maturity_modulation task now calls NNS Governance's
    get_maturity_modulation and stores current_value_permyriad (numerically
    equivalent to basis points) in SNS's existing current_basis_points field.
    SNS keeps the prior "skip update when no value" contract.
  • NNS Governance: at canister init, seed heap_data.maturity_modulation with
    a neutral 0 permyriad value so callers get a usable response immediately
    rather than None while update_icp_xdr_rate_related_data accumulates
    enough XRC price history to compute a real value.
    updated_at_days_since_epoch is left None so the periodic task does not
    treat the placeholder as "already updated today".
  • Test fixtures and call sites in SNS Governance migrate from
    MockCMC/FakeCmc to a new FakeNnsGovernanceClient.

Testing

  • New unit test in get_maturity_modulation covers the init default.
  • Updated update_icp_xdr_rate_related_data_tests assertions to reflect the
    new init default.
  • The SNS integration test
    //rs/sns/integration_tests:neuron_test exercises the SNS to NNS Governance
    path end-to-end (including disburse_maturity and stake_maturity flows).

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 NnsGovernanceClient trait, RealNnsGovernanceClient (bounded-wait ic_cdk call), and FakeNnsGovernanceClient in rs/nervous_system/clients/.
  • SNS Governance replaces its cmc field with nns_governance; update_maturity_modulation now skips when NNS returns None, otherwise stores current_value_permyriad into current_basis_points.
  • NNS Governance init seeds heap_data.maturity_modulation to a neutral Some(0) permyriad with updated_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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants