-
Notifications
You must be signed in to change notification settings - Fork 329
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(nns): Deleted ListNeurons from NNS governance.proto. (#3546)
Also ListNeuronsResponse. # Motivation/Inspiration I started working on deleting `(deciding|potential)_voting_power` fields from `governance.proto` ([NNS1-3500]). Some of those fields appear in `NeuronInfo`. I looked into that type, and it seems like we could delete it, because AFAICT, it is only used in a couple of response types, such as `ListNeuronsResponse`. Therefore, this indirectly helps with getting rid of `*_voting_power` fields in `governance.proto`. [NNS1-3500]: https://dfinity.atlassian.net/browse/NNS1-3500 We should be able to delete most request and response types from `governance.proto`, because we do not store those in stable memory. This shows how we would delete other request and response types. This also shows that such deletions can be fairly straightforward. # Bonus Changes Switch rosetta from using `//rs/nns/governance` to `//rs/nns/governance/api`. This made it possible to "lock down" //rs/nns/governance, i.e. reduce its visibility. Because [min visibility good]. [min visibility good]: https://bazel.build/concepts/visibility#rule-target-visibility Make aliases generated by rust_canister inherit visibility. This was needed to lock down //rs/nns/governance. # How to Delete Request & Response Types from governance.proto Here is an overview of how this PR was constructed; the same steps can (very likely) be used to delete other request and response types: <ol> <li>Delete the definitions from <code>governance.proto</code>. <li>Delete the conversions in <code>rs/nns/governance/src/pb/conversions.rs</code>. <li>Run <code>bazel build //rs/nns/governance</code>. This will reveal all the places that need to be updated in the main lib. <li>In every file that used the types that were deleted in step 1, <i>replace them with the analogous API types</i>. E.g. the following will probably get you more than 90% of the way there: <pre><code>-use crate::pb::v1::{FooRequest, FooResponse}; +use ic_nns_governance_api::pb::v1::{FooRequest, FooResponse}; </code></pre> The reason this is pretty effective is that the definitions of the API types were simply copied from the Prost-generated type. <li>Fix problems that arise from this replacement. E.g. there may cases where you need to convert from an API type "back" to a Prost-generated type, or the other way around. This is likely the most difficult step. <li>Fix <code>canister.rs</code>. It might well be that the only thing you need to do here is remove some <code>.into()</code>. Those are no longer necessary, because now, they just convert T into T. Ofc, this change is not strictly necessary, but clippy might yell at you, and in any case, it confuses humans when you do <code>.into()</code> even though the object is already of the desired type. <li>Fix tests. Again, we apply steps 3-5, but this time, the goal is to make <code>//rs/nns/governance/...</code> build. </ol> The only "insight" here is that it is fairly easy to replace Prost-generated request and response types with API types. Other than that, these steps are more or less corollaries of "delete request and response types". # Why Min Visibility Good When you want to change something, you won't need to change the whole world. I.e. encapsulation, modularity, loose coupling, non-entanglement. Being able to make changes in the future is extrem imperative, because change is the only constant. This is the exact same rationale that is used to justify [private ALL the things]. [private ALL the things]: https://google.github.io/styleguide/cppguide.html#Access_Control
- Loading branch information
1 parent
5993fe2
commit 367ab73
Showing
15 changed files
with
92 additions
and
197 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.