Skip to content

Commit 28ef5ff

Browse files
chore(nns): Delete flags related to periodic confirmation of following. (#3782)
The "Periodic Confirmation of Following/Voting Power" feature started having its full effect at the beginning of April, and no reason to recall it has emerged (knock on wood). DFINITY has looked at the practical consequences of this, and it does not seem like any interventions are needed. Therefore, now is a good time to get rid of these flags. As with all such clean ups, it is not super important that this go in soon. If there are any objections to merging this now, then we can definitely delay. # References Closes [NNS1-3601]. [NNS1-3601]: https://dfinity.atlassian.net/browse/NNS1-3601
1 parent 13b6e26 commit 28ef5ff

File tree

7 files changed

+8
-97
lines changed

7 files changed

+8
-97
lines changed

rs/nns/governance/canister/canister.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ use ic_nns_constants::LEDGER_CANISTER_ID;
2121
#[cfg(feature = "test")]
2222
use ic_nns_governance::governance::TimeWarp as GovTimeWarp;
2323
use ic_nns_governance::{
24-
canister_state::CanisterEnv,
25-
canister_state::{governance, governance_mut, set_governance},
24+
canister_state::{governance, governance_mut, set_governance, CanisterEnv},
2625
encode_metrics,
2726
governance::Governance,
2827
neuron_data_validation::NeuronDataValidationSummary,

rs/nns/governance/src/lib.rs

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -200,11 +200,6 @@ pub const DEFAULT_VOTING_POWER_REFRESHED_TIMESTAMP_SECONDS: u64 = 1725148800;
200200
// leave this here indefinitely, but it will just be clutter after a modest
201201
// amount of time.
202202
thread_local! {
203-
// TODO(NNS1-3601): Delete these (assuming all goes well, ofc) in mid March.
204-
// There is already a draft PR for this.
205-
static IS_VOTING_POWER_ADJUSTMENT_ENABLED: Cell<bool> = const { Cell::new(true) };
206-
static IS_PRUNE_FOLLOWING_ENABLED: Cell<bool> = const { Cell::new(true) };
207-
208203
static ALLOW_ACTIVE_NEURONS_IN_STABLE_MEMORY: Cell<bool> = const { Cell::new(true) };
209204

210205
static MIGRATE_ACTIVE_NEURONS_TO_STABLE_MEMORY: Cell<bool> = const { Cell::new(true) };
@@ -226,38 +221,6 @@ thread_local! {
226221
const { Cell::new(0) };
227222
}
228223

229-
pub fn is_voting_power_adjustment_enabled() -> bool {
230-
IS_VOTING_POWER_ADJUSTMENT_ENABLED.get()
231-
}
232-
233-
/// Only integration tests should use this.
234-
#[cfg(any(test, feature = "canbench-rs", feature = "test"))]
235-
pub fn temporarily_enable_voting_power_adjustment() -> Temporary {
236-
Temporary::new(&IS_VOTING_POWER_ADJUSTMENT_ENABLED, true)
237-
}
238-
239-
/// Only integration tests should use this.
240-
#[cfg(any(test, feature = "canbench-rs", feature = "test"))]
241-
pub fn temporarily_disable_voting_power_adjustment() -> Temporary {
242-
Temporary::new(&IS_VOTING_POWER_ADJUSTMENT_ENABLED, false)
243-
}
244-
245-
pub fn is_prune_following_enabled() -> bool {
246-
IS_PRUNE_FOLLOWING_ENABLED.get()
247-
}
248-
249-
/// Only integration tests should use this.
250-
#[cfg(any(test, feature = "canbench-rs", feature = "test"))]
251-
pub fn temporarily_enable_prune_following() -> Temporary {
252-
Temporary::new(&IS_PRUNE_FOLLOWING_ENABLED, true)
253-
}
254-
255-
/// Only integration tests should use this.
256-
#[cfg(any(test, feature = "canbench-rs", feature = "test"))]
257-
pub fn temporarily_disable_prune_following() -> Temporary {
258-
Temporary::new(&IS_PRUNE_FOLLOWING_ENABLED, false)
259-
}
260-
261224
pub fn allow_active_neurons_in_stable_memory() -> bool {
262225
ALLOW_ACTIVE_NEURONS_IN_STABLE_MEMORY.get()
263226
}

rs/nns/governance/src/neuron/types.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ use crate::{
33
LOG_PREFIX, MAX_DISSOLVE_DELAY_SECONDS, MAX_NEURON_AGE_FOR_AGE_BONUS,
44
MAX_NEURON_RECENT_BALLOTS, MAX_NUM_HOT_KEYS_PER_NEURON,
55
},
6-
is_voting_power_adjustment_enabled,
76
neuron::{combine_aged_stakes, dissolve_state_and_age::DissolveStateAndAge, neuron_stake_e8s},
87
neuron_store::NeuronStoreError,
98
pb::v1::{
@@ -304,15 +303,13 @@ impl Neuron {
304303
) -> u64 {
305304
// Main inputs to main calculation.
306305

307-
let adjustment_factor: Decimal = if is_voting_power_adjustment_enabled() {
306+
let adjustment_factor: Decimal = {
308307
let time_since_last_refreshed = Duration::from_secs(
309308
now_seconds.saturating_sub(self.voting_power_refreshed_timestamp_seconds),
310309
);
311310

312311
voting_power_economics
313312
.deciding_voting_power_adjustment_factor(time_since_last_refreshed)
314-
} else {
315-
Decimal::from(1)
316313
};
317314

318315
let potential_voting_power = self.potential_voting_power(now_seconds);

rs/nns/governance/src/neuron/types/tests.rs

Lines changed: 1 addition & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ use crate::{
66
manage_neuron::{SetDissolveTimestamp, StartDissolving},
77
VotingPowerEconomics,
88
},
9-
temporarily_disable_voting_power_adjustment, temporarily_enable_voting_power_adjustment,
109
};
1110
use ic_cdk::println;
1211
use ic_nervous_system_common::{E8, ONE_MONTH_SECONDS, ONE_YEAR_SECONDS};
@@ -616,9 +615,7 @@ fn test_visibility_when_converting_neuron_to_neuron_info_and_neuron_proto() {
616615
}
617616

618617
#[test]
619-
fn test_adjust_voting_power_enabled() {
620-
let _restore_on_drop = temporarily_enable_voting_power_adjustment();
621-
618+
fn test_adjust_voting_power() {
622619
let principal_id = PrincipalId::new_user_test_id(42);
623620
let created_timestamp_seconds = 1729791574;
624621

@@ -711,44 +708,6 @@ fn test_adjust_voting_power_enabled() {
711708
}
712709
}
713710

714-
#[test]
715-
fn test_adjust_voting_power_disabled() {
716-
let _restore_on_drop = temporarily_disable_voting_power_adjustment();
717-
718-
let principal_id = PrincipalId::new_user_test_id(42);
719-
let created_timestamp_seconds = 1729791574;
720-
721-
let neuron = NeuronBuilder::new(
722-
NeuronId { id: 42 },
723-
Subaccount::try_from(vec![42u8; 32].as_slice()).unwrap(),
724-
principal_id,
725-
DissolveStateAndAge::NotDissolving {
726-
dissolve_delay_seconds: 12 * ONE_MONTH_SECONDS,
727-
aging_since_timestamp_seconds: created_timestamp_seconds + 42,
728-
},
729-
created_timestamp_seconds, // created
730-
)
731-
.with_cached_neuron_stake_e8s(100 * E8)
732-
.build();
733-
let original_potential_voting_power = neuron.potential_voting_power(created_timestamp_seconds);
734-
assert!(original_potential_voting_power > 0);
735-
736-
// At all times, deciding voting power is exactly the same as potential
737-
// voting power, because adjustment is disabled.
738-
for months in [
739-
0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 6.001, 6.1, 6.25, 6.5, 6.75, 6.9, 6.999, 7.0, 7.001,
740-
7.1, 7.25, 7.5, 8.0, 9.0, 10.0,
741-
] {
742-
let now_seconds = created_timestamp_seconds + (months * ONE_MONTH_SECONDS as f64) as u64;
743-
let current_potential_voting_power = neuron.potential_voting_power(now_seconds);
744-
745-
assert_eq!(
746-
neuron.deciding_voting_power(&VotingPowerEconomics::DEFAULT, now_seconds),
747-
current_potential_voting_power,
748-
);
749-
}
750-
}
751-
752711
#[test]
753712
fn test_conversion_from_old_ballot_storage_full() {
754713
let principal_id = PrincipalId::new_user_test_id(42);

rs/nns/governance/src/neuron_store/metrics/tests.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -776,7 +776,6 @@ fn test_compute_neuron_metrics_public_neurons() {
776776
fn test_compute_neuron_metrics_stale_and_expired_voting_power_neurons() {
777777
// Step 1: Prepare the world.
778778

779-
let _reset_on_drop = crate::temporarily_enable_voting_power_adjustment();
780779
let now_seconds = 1718213756;
781780

782781
// Step 1.1: Construct neurons (as described in the docstring).

rs/nns/governance/src/timer_tasks/mod.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@ use seeding::SeedingTask;
88
use snapshot_voting_power::SnapshotVotingPowerTask;
99
use std::cell::RefCell;
1010

11-
use crate::{
12-
canister_state::GOVERNANCE, is_prune_following_enabled, storage::VOTING_POWER_SNAPSHOTS,
13-
};
11+
use crate::{canister_state::GOVERNANCE, storage::VOTING_POWER_SNAPSHOTS};
1412

1513
mod calculate_distributable_rewards;
1614
mod distribute_rewards;
@@ -25,10 +23,9 @@ thread_local! {
2523
pub fn schedule_tasks() {
2624
SeedingTask::new(&GOVERNANCE).schedule(&METRICS_REGISTRY);
2725
CalculateDistributableRewardsTask::new(&GOVERNANCE).schedule(&METRICS_REGISTRY);
28-
if is_prune_following_enabled() {
29-
PruneFollowingTask::new(&GOVERNANCE).schedule(&METRICS_REGISTRY);
30-
}
26+
PruneFollowingTask::new(&GOVERNANCE).schedule(&METRICS_REGISTRY);
3127
SnapshotVotingPowerTask::new(&GOVERNANCE, &VOTING_POWER_SNAPSHOTS).schedule(&METRICS_REGISTRY);
28+
3229
run_distribute_rewards_periodic_task();
3330
}
3431

rs/nns/integration_tests/src/neuron_following.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use ic_nns_governance_api::pb::v1::{
1212
};
1313
use ic_nns_governance_init::GovernanceCanisterInitPayloadBuilder;
1414
use ic_nns_test_utils::{
15-
common::{build_test_governance_wasm, NnsInitPayloadsBuilder},
15+
common::{build_governance_wasm, NnsInitPayloadsBuilder},
1616
neuron_helpers::{
1717
get_neuron_1, get_neuron_2, get_neuron_3, get_nonexistent_neuron, get_unauthorized_neuron,
1818
submit_proposal, TestNeuronOwner,
@@ -484,10 +484,7 @@ async fn test_prune_some_following() {
484484
"NNS Governance",
485485
GOVERNANCE_CANISTER_ID,
486486
governance_proto.encode_to_vec(),
487-
// TODO(NNS1-3446): Once following pruning is released, replace with
488-
// vanilla build_governance_wasm(). For now, the feature is only enabled
489-
// when built with feature = "test".
490-
build_test_governance_wasm(),
487+
build_governance_wasm(),
491488
Some(ROOT_CANISTER_ID.get()),
492489
)
493490
.await;

0 commit comments

Comments
 (0)