-
Notifications
You must be signed in to change notification settings - Fork 336
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
feat(nns): Add neuron_minimum_dissolve_delay_to_vote_seconds
to VotingPowerEconomics
#4180
Open
aterga
wants to merge
8
commits into
master
Choose a base branch
from
arshavir/leo-nns-VotingPowerEconomics
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+162
−0
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ use ic_nervous_system_linear_map::LinearMap; | |
use ic_nervous_system_proto::pb::v1::{Decimal as DecimalProto, Percentage}; | ||
use icp_ledger::DEFAULT_TRANSFER_FEE; | ||
use rust_decimal::Decimal; | ||
use std::ops::RangeInclusive; | ||
use std::time::Duration; | ||
|
||
impl NetworkEconomics { | ||
|
@@ -273,8 +274,16 @@ impl VotingPowerEconomics { | |
Self::DEFAULT_START_REDUCING_VOTING_POWER_AFTER_SECONDS, | ||
), | ||
clear_following_after_seconds: Some(Self::DEFAULT_CLEAR_FOLLOWING_AFTER_SECONDS), | ||
neuron_minimum_dissolve_delay_to_vote_seconds: Some( | ||
Self::MIN_DISSOLVE_DELAY_FOR_VOTE_ELIGIBILITY_SECONDS, | ||
), | ||
}; | ||
|
||
// [MIN_DISSOLVE_DELAY_FOR_VOTE_ELIGIBILITY_SECONDS] represents the default time threshold (in seconds) | ||
// after which voting power begins to decrease in the network economics configuration. This is a preset | ||
// value for the system, but it should be updated to align with [MIN_DISSOLVE_DELAY_FOR_VOTE_ELIGIBILITY_SECONDS]. | ||
pub const MIN_DISSOLVE_DELAY_FOR_VOTE_ELIGIBILITY_SECONDS: u64 = | ||
crate::governance::MIN_DISSOLVE_DELAY_FOR_VOTE_ELIGIBILITY_SECONDS; | ||
pub const DEFAULT_START_REDUCING_VOTING_POWER_AFTER_SECONDS: u64 = 6 * ONE_MONTH_SECONDS; | ||
pub const DEFAULT_CLEAR_FOLLOWING_AFTER_SECONDS: u64 = ONE_MONTH_SECONDS; | ||
|
||
|
@@ -351,6 +360,21 @@ impl VotingPowerEconomics { | |
defects.push("clear_following_after_seconds must be set.".to_string()); | ||
} | ||
|
||
if let Some(delay) = self.neuron_minimum_dissolve_delay_to_vote_seconds { | ||
pub const MIN_DISSOLVE_DELAY_FOR_VOTE_ELIGIBILITY_SECONDS_BOUNDS: RangeInclusive<u64> = | ||
(3 * ONE_MONTH_SECONDS)..=(6 * ONE_MONTH_SECONDS); | ||
|
||
if !MIN_DISSOLVE_DELAY_FOR_VOTE_ELIGIBILITY_SECONDS_BOUNDS.contains(&delay) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm confused by this - why not just do >= and <= instead of constructing a range and seeing if the value is inside of it? |
||
let defect = format!( | ||
"neuron_minimum_dissolve_delay_to_vote_seconds ({:?}) must be between three and six months.", | ||
self.neuron_minimum_dissolve_delay_to_vote_seconds | ||
); | ||
defects.push(defect); | ||
} | ||
} else { | ||
defects.push("neuron_minimum_dissolve_delay_to_vote_seconds must be set.".to_string()); | ||
} | ||
|
||
if !defects.is_empty() { | ||
return Err(defects); | ||
} | ||
|
@@ -522,6 +546,9 @@ impl InheritFrom for VotingPowerEconomics { | |
clear_following_after_seconds: self | ||
.clear_following_after_seconds | ||
.inherit_from(&base.clear_following_after_seconds), | ||
neuron_minimum_dissolve_delay_to_vote_seconds: self | ||
.neuron_minimum_dissolve_delay_to_vote_seconds | ||
.inherit_from(&base.neuron_minimum_dissolve_delay_to_vote_seconds), | ||
} | ||
} | ||
} | ||
|
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So my main question is - if we're exposing this as an API parameter, does that mean that the value is actually being used to see if a neuron can vote? It looks like not yet. Is there a followup PR planned to actually use the value on VotingPowerEconomics to determine neuron voting eligibility?