Skip to content

Commit 65b020a

Browse files
feat(nns): Change include_empty_neurons_readable_by_caller default to false (dfinity#3612)
# Why The `include_empty_neurons_readable_by_caller` flag was default to true in order to retain the behavior before it was introduced. Now that it has been introduced for a while, changing its default to false will help preserving resources in the NNS Governance. Details can be found at: https://forum.dfinity.org/t/listneurons-api-change-empty-neurons/40311
1 parent 8b5a196 commit 65b020a

File tree

5 files changed

+12
-11
lines changed

5 files changed

+12
-11
lines changed

rs/nervous_system/integration_tests/src/pocket_ic_helpers.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -830,7 +830,7 @@ pub mod nns {
830830
Encode!(&ListNeurons {
831831
neuron_ids: vec![],
832832
include_neurons_readable_by_caller: true,
833-
include_empty_neurons_readable_by_caller: None,
833+
include_empty_neurons_readable_by_caller: Some(true),
834834
include_public_neurons_in_full_neurons: None,
835835
page_number: None,
836836
page_size: None

rs/nns/governance/src/governance.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2285,11 +2285,8 @@ impl Governance {
22852285
.unwrap_or(MAX_LIST_NEURONS_RESULTS as u64)
22862286
.min(MAX_LIST_NEURONS_RESULTS as u64);
22872287

2288-
let include_empty_neurons_readable_by_caller = include_empty_neurons_readable_by_caller
2289-
// This default is to maintain the previous behavior. (Unlike
2290-
// protobuf, we do not have a convention that says "the default
2291-
// value is falsy".)
2292-
.unwrap_or(true);
2288+
let include_empty_neurons_readable_by_caller =
2289+
include_empty_neurons_readable_by_caller.unwrap_or(false);
22932290
let include_public_neurons_in_full_neurons =
22942291
include_public_neurons_in_full_neurons.unwrap_or(false);
22952292

rs/nns/governance/src/governance/tests/list_neurons.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ fn test_list_neurons_with_paging() {
4646
let mut request = ListNeurons {
4747
neuron_ids: vec![],
4848
include_neurons_readable_by_caller: true,
49-
include_empty_neurons_readable_by_caller: None,
49+
include_empty_neurons_readable_by_caller: Some(true),
5050
include_public_neurons_in_full_neurons: None,
5151
page_number: None,
5252
page_size: None,
@@ -64,7 +64,7 @@ fn test_list_neurons_with_paging() {
6464
&ListNeurons {
6565
neuron_ids: vec![],
6666
include_neurons_readable_by_caller: true,
67-
include_empty_neurons_readable_by_caller: None,
67+
include_empty_neurons_readable_by_caller: Some(true),
6868
include_public_neurons_in_full_neurons: None,
6969
page_number: Some(1),
7070
page_size: None,
@@ -80,7 +80,7 @@ fn test_list_neurons_with_paging() {
8080
&ListNeurons {
8181
neuron_ids: vec![],
8282
include_neurons_readable_by_caller: true,
83-
include_empty_neurons_readable_by_caller: None,
83+
include_empty_neurons_readable_by_caller: Some(true),
8484
include_public_neurons_in_full_neurons: None,
8585
page_number: Some(0),
8686
page_size: Some(501),

rs/nns/governance/unreleased_changelog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@ No neurons are actually migrated yet.
7474
* `InstallCode` proposal payload hashes are now computed when making the proposal instead of when
7575
listing proposal. Hashes for existing proposals are backfilled.
7676

77+
* The `list_neurons` behavior is slightly changed: the `include_empty_neurons_readable_by_caller`
78+
was default to true before, and now it's default to true. More details can be found at:
79+
https://forum.dfinity.org/t/listneurons-api-change-empty-neurons/40311
80+
7781
## Deprecated
7882

7983
## Removed

rs/nns/integration_tests/src/governance_neurons.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,6 @@ fn test_list_neurons() {
604604
page_size: None,
605605
},
606606
);
607-
assert_eq!(list_neurons_response.neuron_infos.len(), 3);
608-
assert_eq!(list_neurons_response.full_neurons.len(), 2);
607+
assert_eq!(list_neurons_response.neuron_infos.len(), 2);
608+
assert_eq!(list_neurons_response.full_neurons.len(), 1);
609609
}

0 commit comments

Comments
 (0)