Skip to content

refactor(nns): drop inner Options on MaturityModulation#10269

Open
jasonz-dfinity wants to merge 1 commit into
masterfrom
change-maturitymodulationinternal-to-avoid-inner-option
Open

refactor(nns): drop inner Options on MaturityModulation#10269
jasonz-dfinity wants to merge 1 commit into
masterfrom
change-maturitymodulationinternal-to-avoid-inner-option

Conversation

@jasonz-dfinity
Copy link
Copy Markdown
Contributor

Why

MaturityModulation's two scalar fields were optional, generating
Option<i32> / Option<u64> in prost. Both inner Options were
redundant: current_value_permyriad had no meaningful absent state
(only ever set, never read as None with distinct semantics), and
updated_at_days_since_epoch already had 0 available as a "never
measured" sentinel — current_day is always >> 0 in practice, so a
real measurement can never collide.

What

  • Drop optional from MaturityModulation in governance.proto;
    regenerate the prost bindings so the fields are bare i32 / u64.
  • initialize_governance continues to pre-seed
    Some(MaturityModulation { current_value_permyriad: 0, updated_at_days_since_epoch: 0 })
    so spawning and disbursement keep their pre-PR behavior at init.
  • update_maturity_modulation keys the "first calculation, no
    speed-limit baseline" branch on updated_at_days_since_epoch == 0.
  • pb→api conversion maps updated_at_days_since_epoch == 0 back to
    None so the public API contract is preserved.

Testing

The wire-format safety of dropping optional is demonstrated by a
review-time scaffold commit on a side branch:
7b92bde
— it defines parallel prost messages with/without optional and
round-trips encoded bytes through the other shape, asserting
Some(v) ↔ v and the default-elision asymmetry (None ↔ 0,
Some(0) → 0) in both directions. Not merged here because the
OldMaturityModulation shape no longer exists in the tree.

@jasonz-dfinity jasonz-dfinity requested a review from Copilot May 20, 2026 22:11
@jasonz-dfinity jasonz-dfinity marked this pull request as ready for review May 20, 2026 22:12
@jasonz-dfinity jasonz-dfinity requested a review from a team as a code owner May 20, 2026 22:12
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

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 removes redundant inner Option wrappers from the protobuf MaturityModulation message by dropping optional on its scalar fields, switching the prost bindings to plain i32/u64. The implementation is updated to use updated_at_days_since_epoch == 0 as the “never measured” sentinel, while preserving the public API behavior by mapping that sentinel back to None in pb→api conversion.

Changes:

  • Update MaturityModulation protobuf schema to use non-optional scalar fields and regenerate Rust prost bindings.
  • Update maturity modulation computation logic to use updated_at_days_since_epoch == 0 as the “no baseline yet” indicator.
  • Adjust call sites and tests to the new non-Option fields and preserve API semantics in conversion code.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated no comments.

Show a summary per file
File Description
rs/nns/governance/tests/governance.rs Update test helper to construct MaturityModulation with scalar fields.
rs/nns/governance/src/timer_tasks/update_icp_xdr_rate_related_data.rs Switch update logic and logging to scalar fields; use 0 sentinel for “never measured”.
rs/nns/governance/src/timer_tasks/update_icp_xdr_rate_related_data_tests.rs Update task tests to the scalar-field representation and sentinel behavior.
rs/nns/governance/src/pb/conversions/mod.rs Map updated_at_days_since_epoch == 0 to None for the public API; wrap scalar permyriad into Some.
rs/nns/governance/src/heap_governance_data.rs Seed maturity_modulation with { current_value_permyriad: 0, updated_at_days_since_epoch: 0 } at init.
rs/nns/governance/src/governance/tla/mod.rs Adjust extraction of permyriad from MaturityModulation now that it’s scalar.
rs/nns/governance/src/governance/tests/get_maturity_modulation.rs Update API-facing tests to expect sentinel-driven updated_at mapping.
rs/nns/governance/src/governance/disburse_maturity.rs Adjust modulation value read path to scalar field.
rs/nns/governance/src/governance/disburse_maturity_tests.rs Update test construction to scalar current_value_permyriad.
rs/nns/governance/src/governance.rs Adjust modulation value read path to scalar field.
rs/nns/governance/src/gen/ic_nns_governance.pb.v1.rs Regenerated prost bindings reflecting non-optional fields and sentinel documentation.
rs/nns/governance/proto/ic_nns_governance/pb/v1/governance.proto Remove optional from MaturityModulation scalar fields and document 0 sentinel.

💡 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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants