Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(nns-governance): Delete *_voting_power fields from governance.proto. #3643

Open
wants to merge 13 commits into
base: master
Choose a base branch
from

Conversation

daniel-wong-dfinity-org
Copy link
Contributor

@daniel-wong-dfinity-org daniel-wong-dfinity-org commented Jan 27, 2025

Rationale/Motivation

These values are derived. Hence, they do not need to be and should not be stored.

Overview

Got rid of into_proto.

Reintroduced pb::Neuron::from.

Added into_api.

Depending on the situation, into_proto calls were replaced with either pb::Neuron::from or into_api. The difference is that the former is easier (requires less inputs), but the latter provides (deciding|potential)_voting_power.

References

Closes NNS1-3500.

@daniel-wong-dfinity-org daniel-wong-dfinity-org changed the base branch from master to delete-neuron-info-from-governance-proto-daniel-wong January 27, 2025 20:13
Base automatically changed from delete-neuron-info-from-governance-proto-daniel-wong to master January 28, 2025 12:46
@daniel-wong-dfinity-org daniel-wong-dfinity-org force-pushed the delete-voting-power-fields-from-governance-proto-daniel-wong branch 8 times, most recently from c05002c to bccde58 Compare January 29, 2025 10:46
…overnance.proto. These are derived, and therefore, do not need to be stored in stable memory. They are part of the API though, so we do not remove them from governance.did.
…information is needed to perform this conversion. Specifically, in order to populate the deciding_voting_power field, VotingPowerEconomics is needed. Also deleted transcribing from *_voting_power fields in the other direction.
…ecause we deleted that in a recent commit. Resurrected `impl From<Neuron> for NeuronProto`, which replaces `into_proto`, which is no longer needed, because converting to NeuronProto no longer requires auxiliary data (used to calculate *_voting_power fields that have been deleted). Still need to implement convertion to API Neuron. That will be done in next commit. //rs/nns/governance builds 🤘
…fix affected tests, it was simply a matter of instead using pb::Neuron::from.
…ing *_voting_power fields from NNS governance.proto).
@daniel-wong-dfinity-org daniel-wong-dfinity-org force-pushed the delete-voting-power-fields-from-governance-proto-daniel-wong branch 2 times, most recently from 8fe714c to be7b682 Compare January 29, 2025 13:37
@daniel-wong-dfinity-org daniel-wong-dfinity-org marked this pull request as ready for review January 29, 2025 14:48
@daniel-wong-dfinity-org daniel-wong-dfinity-org requested a review from a team as a code owner January 29, 2025 14:48
Copy link
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.

If this pull request affects the behavior of any canister owned by
the Governance team, remember to update the corresponding
unreleased_changes.md file(s).

To acknowldge this reminder (and unblock the PR), dismiss this
code review by going to the bottom of the pull request page, and
supply one of the following reasons:

  1. Done.

  2. No canister behavior changes.

@daniel-wong-dfinity-org daniel-wong-dfinity-org dismissed github-actions[bot]’s stale review January 29, 2025 14:53

No canister behavior change. Just a refactor.

Copy link
Contributor Author

@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.

Diff reading guide.

// we are using a circular buffer to store them. This solution is not ideal, but
// we need to do a larger refactoring to use the correct API types instead of the internal
// governance proto at this level.
proto.recent_ballots = neuron.sorted_recent_ballots();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm. I may have forgotten to replace this... Not sure why this was done outside of conversion... That also seems like a mistake...

Copy link
Contributor

Choose a reason for hiding this comment

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

It should be added to the conversion, definitely. It wasn't added in the conversion b/c it didn't seem possible at the time without a lot of other work, though I forget the details.

rs/nns/governance/src/neuron/types.rs Show resolved Hide resolved
rs/nns/governance/src/neuron/types.rs Show resolved Hide resolved
rs/nns/governance/src/neuron/types/tests.rs Show resolved Hide resolved
rs/nns/governance/src/pb/conversions.rs Show resolved Hide resolved
rs/nns/governance/src/pb/conversions.rs Show resolved Hide resolved
created_timestamp_seconds,
spawn_at_timestamp_seconds,
followees,
recent_ballots,
Copy link
Contributor

@max-dfinity max-dfinity Jan 29, 2025

Choose a reason for hiding this comment

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

I think this is all you need to do to get the ballots in the right order here:

let recent_ballots = self.sorted_recent_ballots();
let Neuron {
...
recent_ballots: _,
...
} = self;

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