Skip to content

DO NOT MERGE until maturity modulation validated in mainnet feat(governance): switch spawning and disbursement to locally computed maturity modulation#9848

Open
jasonz-dfinity wants to merge 10 commits into
masterfrom
jason/NNS1-4319-switch-maturity-modulation
Open

DO NOT MERGE until maturity modulation validated in mainnet feat(governance): switch spawning and disbursement to locally computed maturity modulation#9848
jasonz-dfinity wants to merge 10 commits into
masterfrom
jason/NNS1-4319-switch-maturity-modulation

Conversation

@jasonz-dfinity
Copy link
Copy Markdown
Contributor

@jasonz-dfinity jasonz-dfinity commented Apr 13, 2026

Why

The previous PR added local maturity modulation computation. This PR switches the actual consumers to use it.

https://dfinity.atlassian.net/browse/NNS1-4319

What

  • maybe_spawn_neurons() reads from icp_xdr_rate_history.current_maturity_modulation_permyriad instead of cached_daily_maturity_modulation_basis_points
  • try_finalize_maturity_disbursement() reads from the same new source
  • TLA state export updated accordingly
  • Tests updated to set up icp_xdr_rate_history instead of the old field

The old CMC-polled fields are not yet removed; that happens in the next PR.

PR Chain

Testing

Existing disburse_maturity and maybe_spawn_neurons tests updated and passing.

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

This PR aims to switch governance maturity-modulation consumers (neuron spawning + maturity disbursement finalization) to read the locally computed maturity modulation value, and updates TLA export + tests accordingly.

Changes:

  • Update maybe_spawn_neurons and try_finalize_maturity_disbursement to read maturity modulation from a new heap-data source.
  • Update TLA global export to reflect the new maturity-modulation source.
  • Update disburse-maturity tests to set up the new maturity-modulation source.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
rs/nns/governance/src/timer_tasks/mod.rs Adds imports intended for XRC-related logic (currently unused in this module).
rs/nns/governance/src/governance/tla/mod.rs Switches TLA export of cached maturity modulation to the new source.
rs/nns/governance/src/governance/disburse_maturity_tests.rs Updates test setup to populate the new maturity-modulation source.
rs/nns/governance/src/governance/disburse_maturity.rs Switches maturity disbursement finalization to read modulation from the new source.
rs/nns/governance/src/governance.rs Switches neuron spawning to read modulation from the new source.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread rs/nns/governance/src/governance/disburse_maturity_tests.rs Outdated
Comment thread rs/nns/governance/src/timer_tasks/mod.rs Outdated
Comment thread rs/nns/governance/src/governance.rs Outdated
Comment thread rs/nns/governance/src/governance/disburse_maturity.rs Outdated
Comment thread rs/nns/governance/src/governance/tla/mod.rs Outdated
Comment thread rs/nns/governance/src/governance/disburse_maturity_tests.rs Outdated
Comment thread rs/nns/governance/src/governance/disburse_maturity_tests.rs Outdated
@jasonz-dfinity jasonz-dfinity force-pushed the jason/NNS1-4319-compute-maturity-modulation branch from 0724790 to 9a31ba9 Compare April 15, 2026 19:27
@jasonz-dfinity jasonz-dfinity force-pushed the jason/NNS1-4319-switch-maturity-modulation branch from 2263afa to f607ce6 Compare April 15, 2026 19:27
@jasonz-dfinity jasonz-dfinity force-pushed the jason/NNS1-4319-compute-maturity-modulation branch from 9a31ba9 to a7108f0 Compare April 15, 2026 21:29
@jasonz-dfinity jasonz-dfinity force-pushed the jason/NNS1-4319-switch-maturity-modulation branch from f607ce6 to 9da51a1 Compare April 15, 2026 21:29
@jasonz-dfinity jasonz-dfinity force-pushed the jason/NNS1-4319-switch-maturity-modulation branch from 9da51a1 to 8577ae1 Compare April 15, 2026 22:29
@jasonz-dfinity jasonz-dfinity marked this pull request as ready for review April 15, 2026 22:32
@jasonz-dfinity jasonz-dfinity requested a review from a team as a code owner April 15, 2026 22:32
Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

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

This pull request changes code owned by the Governance team. Therefore, make sure that
you have considered the following (for Governance-owned code):

  1. Update unreleased_changelog.md (if there are behavior changes, even if they are
    non-breaking).

  2. Are there BREAKING changes?

  3. Is a data migration needed?

  4. Security review?

How to Satisfy This Automatic Review

  1. Go to the bottom of the pull request page.

  2. Look for where it says this bot is requesting changes.

  3. Click the three dots to the right.

  4. Select "Dismiss review".

  5. In the text entry box, respond to each of the numbered items in the previous
    section, declare one of the following:

  • Done.

  • $REASON_WHY_NO_NEED. E.g. for unreleased_changelog.md, "No
    canister behavior changes.", or for item 2, "Existing APIs
    behave as before.".

Brief Guide to "Externally Visible" Changes

"Externally visible behavior change" is very often due to some NEW canister API.

Changes to EXISTING APIs are more likely to be "breaking".

If these changes are breaking, make sure that clients know how to migrate, how to
maintain their continuity of operations.

If your changes are behind a feature flag, then, do NOT add entrie(s) to
unreleased_changelog.md in this PR! But rather, add entrie(s) later, in the PR
that enables these changes in production.

Reference(s)

For a more comprehensive checklist, see here.

GOVERNANCE_CHECKLIST_REMINDER_DEDUP

@jasonz-dfinity jasonz-dfinity changed the title feat(governance): switch spawning and disbursement to locally computed maturity modulation DO NOT MERGE until maturity modulation validated in mainnet feat(governance): switch spawning and disbursement to locally computed maturity modulation Apr 15, 2026
@jasonz-dfinity jasonz-dfinity force-pushed the jason/NNS1-4319-switch-maturity-modulation branch from 8577ae1 to bc807c4 Compare April 16, 2026 05:21
Copy link
Copy Markdown
Contributor

@daniel-wong-dfinity-org daniel-wong-dfinity-org left a comment

Choose a reason for hiding this comment

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

I would put this behind a flag.

};

// Sanity check that the maturity modulation returned is within bounds.
if !VALID_MATURITY_MODULATION_BASIS_POINTS_RANGE.contains(&maturity_modulation) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Range still has the old values


let now_seconds = self.env.now();
let maturity_modulation = match self.heap_data.cached_daily_maturity_modulation_basis_points
let maturity_modulation = match self
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe we should add another sanity check that makes sure that the maturity modulation value is the one for the current day (also in the disburse maturity case)?

@jasonz-dfinity jasonz-dfinity force-pushed the jason/NNS1-4319-compute-maturity-modulation branch from 1455d28 to 876292a Compare May 5, 2026 23:05
Base automatically changed from jason/NNS1-4319-compute-maturity-modulation to master May 7, 2026 17:01
pull Bot pushed a commit to mikeyhodl/ic that referenced this pull request May 7, 2026
…e history (dfinity#9847)

## Why

Previously, Governance relied on CMC (Cycles Minting Canister) as a
middleman for ICP price data used in maturity modulation. This PR cuts
out the middleman by having Governance fetch ICP/XDR rates directly from
the Exchange Rate Canister (XRC) and derive Mission 70 maturity
modulation locally.

https://dfinity.atlassian.net/browse/NNS1-4319

## What

- `IcpPriceHistory`: bounded sorted vector of up to 365 daily ICP/XDR
rates in Governance state (new proto field 33)
- `UpdateIcpXdrRateRelatedData`: timer task that fetches rates directly
from XRC, backfills the last 365 days on first upgrade (~30 min at
5-second intervals), then switches to daily fetches aligned to UTC
midnight; recomputes Mission 70 maturity modulation after each update
- The existing CMC-polled maturity modulation remains active for
spawning/disbursement (switchover is in a later PR)

### PR Chain
- ⬅️ Previous: dfinity#9846
- ➡️ Next: dfinity#9848, dfinity#9879

## Testing

Unit tests for the price history buffer, maturity modulation
computation, and UTC midnight timer logic.
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.

4 participants