Skip to content

feat(nns): Allow ManageNeuron proposals to make small ManageNeuron proposals - #12209

Merged
Dfinity-Bjoern merged 10 commits into
masterfrom
nns-nested-manage-neuron-make-proposal
Nov 23, 2026
Merged

Dfinity-Bjoern merged 10 commits into
masterfrom
nns-nested-manage-neuron-make-proposal

Conversation

@Dfinity-Bjoern

@Dfinity-Bjoern Dfinity-Bjoern commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Why

An earlier hot fix broke support for multiple levels of neuron management following, i.e. where neuron A controls neuron B, which controls neuron C. MakeProposal inside a ManageNeuron proposal was disabled in #4509, because a nested proposal can be large (e.g. a WASM), and ManageNeuron proposals are cheap (0.01 ICP) with up to 10,000 open at once. However, that broke the use case entirely.

What

Size bound. The action of every ManageNeuron proposal can be at most MANAGE_NEURON_ACTION_ENCODED_BYTES_MAX = 10,000 bytes (protobuf encoded_len). Every command other than MakeProposal is far below this (a unit test checks the largest valid SetFollowing); with MakeProposal, it bounds the nested proposal.

Nested MakeProposal. A ManageNeuron proposal for neuron B may again have the MakeProposal command, but only for a ManageNeuron proposal (validate_nested_make_proposal):

  • The nested proposal must be a ManageNeuron proposal. The size bound alone is not enough for other types: their actions can expand a lot when decoded (e.g. a RewardNodeProviders with thousands of empty elements).
  • Its command must not be MakeProposal (at most one level of nesting).
  • It is otherwise validated like any proposal.

Whether B is among the target's NeuronManagement followees is deliberately not checked when the outer proposal is made: that validation runs before the caller is authorized, so it would disclose the target's (possibly private) followees to anyone. It is checked, after authorization, when B makes the nested proposal; if it fails, the outer proposal fails to execute.

When the outer proposal is adopted, B (acting as its controller, as for any ManageNeuron proposal) makes the nested proposal and votes yes on it. If B is the target's only manager, the nested proposal is adopted and executed right away. No API, Candid, or stable-storage changes: MakeProposal : Proposal was already part of ManageNeuronProposalCommand.

Self-describing action. A nested MakeProposal is now rendered as {title, summary, url, action: {ManageNeuron: ...}} instead of a placeholder.

Not in this PR: letting the controllers and hotkeys of A read the full neuron C and see ManageNeuron proposals for C. That is in the stacked follow-up #12218.

Behavior worth knowing

  • B pays the (non-refundable) neuron management fee for each nested proposal, so it needs at least that much minted stake. The member who proposes the outer proposal pays it too.
  • The outer proposal is marked executed once the nested proposal is created; the nested proposal's own outcome is recorded on the nested proposal.

Testing

  • New unit tests: self-describing MakeProposal, largest valid SetFollowing fits the size bound.
  • New tests in tests/governance.rs: end-to-end A → B → C flow (including fees), rejection of a non-ManageNeuron nested proposal, of two levels of nesting, and of a too-large nested proposal, and a nested proposal for a neuron B does not manage (outer proposal fails at execution). test_disallow_large_manage_neuron_proposals now expects InvalidProposal.
  • Locally: cargo check, cargo fmt --check, rust-lint.sh, bazel build of the directly affected targets, and the affected Bazel tests. All passed except //rs/nns/integration_tests:upgrade_canisters_with_golden_nns_state, which could not download the golden NNS state in the environment it ran in (no SSH access to the state host). It has not been run with this change yet.

🤖 Generated with Claude Code

…oposals

A ManageNeuron proposal can again have the MakeProposal command, but only
to make another ManageNeuron proposal. This lets a group of neurons
{A, B, C} manage many neurons E1..En through one intermediate neuron D
(each Ei follows D on NeuronManagement, D follows A, B, C): A, B, C make D
propose (and vote for) a ManageNeuron proposal for any Ei. Membership
changes only touch D's followees.

The nested proposal is kept small (the reason MakeProposal was disabled
in #4509): it must be a ManageNeuron proposal, its command must not be
MakeProposal (one level of nesting), its summary is capped at 2,000
bytes, and it must not set self_describing_action. It is otherwise
validated like any proposal, and D must be a manager of the target.

Read access follows the same two levels: controllers/hotkeys of A, B, C
can read the full Ei (get_full_neuron, list_neurons) and see ManageNeuron
proposals for Ei in list_proposals.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Copilot AI left a comment

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.

🟡 Changes recommended

The change exposes private neuron manager lists to unauthorized callers through validation errors and introduces unbounded follower scans and allocations when listing proposals.

2 open issues
What changed in this PR

This PR enables neuron groups to manage many neurons through one intermediate neuron, while restricting nested proposals to small ManageNeuron actions.

Changes:

  • Allows one level of nested ManageNeuron proposals with validation and a 2,000-byte summary limit.
  • Extends neuron and proposal read access through two management levels.
  • Adds nested-action rendering, tests, and release notes.
File Description
rs/​nns/​governance/​unreleased_changelog.md Documents nested proposals and expanded read access.
rs/​nns/​governance/​tests/​governance.rs Tests nested execution, fees, access, and rejection cases.
rs/​nns/​governance/​src/​proposals/​manage_neuron.rs Renders nested proposals as self-describing values.
rs/​nns/​governance/​src/​proposals/​manage_neuron_tests.rs Tests nested proposal rendering.
rs/​nns/​governance/​src/​neuron_store/​neuron_store_tests.rs Tests indirect read access and its depth limit.
rs/​nns/​governance/​src/​neuron_store.rs Adds two-level management checks for neuron reads.
rs/​nns/​governance/​src/​governance/​tests/​list_proposals.rs Tests proposal visibility through intermediate neurons.
rs/​nns/​governance/​src/​governance.rs Validates nested proposals and extends listing access.

Review effort: Balanced

Comment thread rs/nns/governance/src/governance.rs Resolved
Comment thread rs/nns/governance/src/governance.rs Resolved
…wees

Addresses review feedback on the nested ManageNeuron MakeProposal change:

- list_proposals: instead of enumerating all NeuronManagement followers of
  the caller's neurons (unbounded, and growable by anyone), check each
  manager of the targeted neuron (at most 15) by loading its followees,
  and cache the result per manager for the duration of the call.
- Validation of a nested MakeProposal no longer checks whether the
  intermediate neuron manages the nested target. Validation runs before
  the caller is authorized, so the error disclosed the target's (possibly
  private) followees. The check still happens, after authorization, when
  the intermediate neuron makes the nested proposal.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Copilot AI left a comment

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.

🔵 Needs a closer look

Reading a single neuron now unconditionally scans and allocates all caller-associated neuron IDs, including in narrowly scoped list requests, creating an avoidable performance cost that other controllers can amplify by adding the caller as a hotkey.

No open issues 🎉

1 previously missed issue

In code that hasn't changed since last review

Medium severity Bound neuron visibility checks to the requested neuron's managers

rs/​nns/​governance/​src/​neuron_store.rs:725

Reading one managed neuron now scans and allocates every neuron ID associated with the caller, a population that other controllers can enlarge by adding the caller as a hotkey. The same scan runs unconditionally in governance.rs:1716, even when list_neurons explicitly requests only one caller-owned neuron and disables implicit inclusion. Use principal-index contains_entry lookups for the target's managers and their managers, and reuse that bounded check in list_neurons after its controller/public fast paths.

2 resolved since last review

Review effort: Balanced

@Dfinity-Bjoern
Dfinity-Bjoern marked this pull request as ready for review November 20, 2026 13:58
@Dfinity-Bjoern
Dfinity-Bjoern requested a review from a team as a code owner November 20, 2026 13:58

@github-actions github-actions Bot left a comment

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.

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

@zeropath-ai

zeropath-ai Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

✅ No security or compliance issues detected. Reviewed 5 of 6 changed files (1 skipped) up to 84e2a71.

Security Overview
Detected Code Changes
Change Type Relevant files
Enhancement ► rs/nns/governance/src/governance.rs
    Add MANAGE_NEURON_ACTION_ENCODED_BYTES_MAX constant and validate nested MakeProposal in ManageNeuron proposals
► rs/nns/governance/src/governance.rs
    Validate nested MakeProposal and implement validate_nested_make_proposal
► rs/nns/governance/src/proposals/manage_neuron.rs
    Update imports to include Proposal and Action for nested proposals
► rs/nns/governance/src/proposals/manage_neuron.rs
    Describe nested nested proposal handling in SelfDescribingValue
► rs/nns/governance/src/proposals/manage_neuron.rs
    Add helper describe_nested_proposal for nested MakeProposal handling
► rs/nns/governance/src/proposals/manage_neuron_tests.rs
    Add tests for MakeProposal inside ManageNeuron and related validation
► rs/nns/governance/tests/governance.rs
    Expose MANAGE_NEURON_ACTION_ENCODED_BYTES_MAX in tests
► rs/nns/governance/unreleased_changelog.md
    Document new ManageNeuron MakeProposal nesting and encoded size limit

Reading a single (managed) neuron used to collect all neuron IDs that
the caller is controller or hotkey of. That set is unbounded, and anyone
can grow it by adding the caller as a hotkey to their own neurons.

Instead, check the neuron's managers (and their managers) with point
lookups in the principal index: at most 15 followee loads and
15 * 16 index lookups per neuron, regardless of the caller.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Dfinity-Bjoern

Copy link
Copy Markdown
Contributor Author

Re Copilot's "Bound neuron visibility checks to the requested neuron's managers" (review 5993822093): fixed in 151c7d7. get_full_neuron / list_neurons no longer collect all neuron IDs associated with the caller. They check the requested neuron's managers (and their managers) with point lookups in the principal index, so the cost is bounded by the neuron (at most 15 followee loads and 15 × 16 index lookups), not by the caller's (externally growable) hotkey set.

🤖 Addressed by Claude Code

Copilot AI balanced review requested due to automatic review settings November 20, 2026 14:14

Copilot AI left a comment

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.

🔵 Needs a closer look

Re-enabling a command disabled by a deployed memory-exhaustion hotfix and expanding private-neuron read access require human security review of resource bounds and access rules, while the golden-state upgrade test remains unrun.

No open issues 🎉

Review effort: Balanced

This PR now only allows nested MakeProposal in ManageNeuron proposals.
Reading neurons and listing proposals through an intermediate neuron
moves to a follow-up PR.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Copilot AI left a comment

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.

🟡 Changes recommended

Two-level read access remains unimplemented, so a principal can initiate a nested proposal but cannot retrieve the target neuron’s full data or see the proposal in default listings.

1 open issue

Review effort: Balanced

Comment thread rs/nns/governance/src/governance.rs Resolved

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.

Most of my inline feedback is just about wording.

The one behavioral suggestion is this: to protect main memory, let's use encoded_len, since that addresses the issue of size DIRECTLY.

It is a bit weird to me that the second proposal MUST be a ManageNeuron proposal. Would it be HARMFUL if we allow other proposal types, or are we having this limitation simply because other proposal types do not seem useful (in this context)? I mean, I do not HATE this limitation. It just seems a little arbitrary, which sort of goes against the principle of least astonishment.

Tangents

I can't tell you how many times we have been like, "yeah, but who would ever want that ability? Let's just ban it" only to later find users who have legitimate use cases. I feel like the moral of the story is, do not make decisions based on failure of imagination.

Regarding planned follow up PRs, I am a bit worried about the new read authorizations (for neurons and proposals), both from a security and performance perspective. IIUC, list_neurons is already giving us performance head aches. What you plan to do squares the cost.

Comment thread rs/nns/governance/src/governance.rs Resolved
Comment thread rs/nns/governance/src/governance.rs Resolved
Comment thread rs/nns/governance/src/governance.rs Resolved
Comment thread rs/nns/governance/src/governance.rs Resolved
Comment thread rs/nns/governance/src/governance.rs Resolved
Comment thread rs/nns/governance/src/governance.rs Resolved
Comment thread rs/nns/governance/src/governance.rs Resolved
Comment thread rs/nns/governance/src/governance.rs Resolved
Comment thread rs/nns/governance/src/governance.rs Resolved
Comment thread rs/nns/governance/src/governance.rs Resolved
Address review feedback: limit the size of a ManageNeuron proposal's
action directly (MANAGE_NEURON_ACTION_ENCODED_BYTES_MAX = 10,000 bytes,
protobuf encoded), instead of limiting the summary of a nested proposal.
Also reorder and reword the doc comment and error messages of
validate_nested_make_proposal.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings November 22, 2026 22:50

Copilot AI left a comment

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.

🟡 Changes recommended

The advertised 2,000-byte nested-summary limit is not enforced by the implemented 10,000-byte aggregate ManageNeuron cap, so the description or validation needs updating.

1 open issue
1 resolved since last review

Review effort: Balanced

Comment thread rs/nns/governance/src/governance.rs Resolved
…oc comment

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Dfinity-Bjoern Dfinity-Bjoern changed the title feat(nns): Allow ManageNeuron proposals to make small ManageNeuron proposals feat(nns): Allow ManageNeuron proposals to make proposals Nov 22, 2026
@Dfinity-Bjoern

Copy link
Copy Markdown
Contributor Author

Regarding planned follow up PRs, I am a bit worried about the new read authorizations (for neurons and proposals), both from a security and performance perspective. IIUC, list_neurons is already giving us performance head aches. What you plan to do squares the cost.

Let's discuss on #12218 but that isn't as urgent. There are other ways to achieve this, like setting the neurons to public, so this is less of an absolute blocker for the use case compared with this PR.

A ManageNeuron proposal's MakeProposal command can now make a proposal
of any type, not only a ManageNeuron proposal. The size of the nested
proposal is bounded by MANAGE_NEURON_ACTION_ENCODED_BYTES_MAX, and it
still cannot itself be a ManageNeuron proposal with MakeProposal.

Nested proposals are described without calling other canisters (the
payload of a nested ExecuteNnsFunction is not decoded).

Also remove the redundant self_describing_action check, trim the
changelog entry, and drop a test case for early validation.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings November 22, 2026 23:37
@Dfinity-Bjoern Dfinity-Bjoern changed the title feat(nns): Allow ManageNeuron proposals to make proposals feat(nns): Allow ManageNeuron proposals to make proposals again Nov 22, 2026

Copilot AI left a comment

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.

🟡 Changes recommended

Validation permits compact nested rewards to expand into gigabytes of stored allocations across open proposals, risking governance low-memory mode because repeated-element counts and the expanded representation are not bounded.

1 open issue

Review effort: Balanced

Comment thread rs/nns/governance/src/governance.rs Resolved
@Dfinity-Bjoern

Copy link
Copy Markdown
Contributor Author

The restriction to nested ManageNeuron proposals is not fundamentally necessary (and it would even be nicer to remove it), but as pointed out it is at least currently a restriction necessary for security.

For the concrete example given there: Maybe we should just get rid of the RewardNodeProviders proposals entirely, since they haven't been used for several years at all.

Restore the restriction that a proposal made via a ManageNeuron
proposal's MakeProposal command must itself be a ManageNeuron proposal.
The size bound on the protobuf encoding does not bound memory for other
proposal types: e.g. a RewardNodeProviders action with thousands of
empty elements fits in 10 KB but expands much more when decoded and
self-described, and up to 10,000 cheap ManageNeuron proposals can be
open at a time.

This also reverts the canister-call-free description of arbitrary
nested actions, which pushed the test canister over its size limit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings November 23, 2026 00:02
@Dfinity-Bjoern Dfinity-Bjoern changed the title feat(nns): Allow ManageNeuron proposals to make proposals again feat(nns): Allow ManageNeuron proposals to make small ManageNeuron proposals Nov 23, 2026

Copilot AI left a comment

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.

🟡 Changes recommended

The PR description claims support for arbitrary nested actions and describes rendering and fees that do not apply to the ManageNeuron-only implementation.

1 open issue
1 resolved since last review

Review effort: Balanced

Comment thread rs/nns/governance/src/governance.rs Resolved

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.

I still need to read other files in this PR, but I'm ok with what this PR does now.

(I would really like to get rid of limitations that would seem arbitrary from the outside, but then, it is not clear how to prevent space blow up. IOW, I accept this as a compromise so that we can get through this quickly and unblock you.)

Comment thread rs/nns/governance/src/governance.rs Resolved
Comment thread rs/nns/governance/src/governance.rs Resolved
Comment thread rs/nns/governance/src/governance.rs Resolved
Comment thread rs/nns/governance/src/governance.rs Resolved
Comment thread rs/nns/governance/src/governance.rs Resolved
Use the prost::Message trait method for encoded_len, and simplify the doc
comment: say what is enforced, and drop the note about where the followee
check happens.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings November 23, 2026 13:36

Copilot AI left a comment

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.

🔵 Needs a closer look

Reopening the security-hotfixed proposal path requires human validation of retained Wasm memory at 10,000 open proposals and upgrade compatibility, since the size test bounds only protobuf bytes and the golden-state upgrade test remains unrun.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

Comment thread rs/nns/governance/tests/governance.rs Resolved
Comment thread rs/nns/governance/tests/governance.rs Resolved
Comment thread rs/nns/governance/tests/governance.rs Resolved
Comment thread rs/nns/governance/tests/governance.rs Resolved
Comment thread rs/nns/governance/tests/governance.rs Resolved
Comment thread rs/nns/governance/tests/governance.rs Resolved
…l tests

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings November 23, 2026 16:33

Copilot AI left a comment

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.

🔵 Needs a closer look

Re-enabling proposal nesting after a security hotfix requires human security review of worst-case memory amplification, since native tests skip production self-description generation and the production golden-state upgrade test remains unrun.

No open issues 🎉

Review effort: Balanced

@Dfinity-Bjoern
Dfinity-Bjoern added this pull request to the merge queue Nov 23, 2026
Merged via the queue into master with commit 1a8f8cd Nov 23, 2026
44 checks passed
@Dfinity-Bjoern
Dfinity-Bjoern deleted the nns-nested-manage-neuron-make-proposal branch November 23, 2026 17:26

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.

Thanks!

Comment thread rs/nns/governance/tests/governance.rs Resolved
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.

3 participants