Skip to content

Commit

Permalink
Merge branch 'master' into marko-passt-changes
Browse files Browse the repository at this point in the history
  • Loading branch information
marko-k0 authored Dec 10, 2024
2 parents 81f447b + ac17241 commit fb999df
Show file tree
Hide file tree
Showing 23 changed files with 749 additions and 135 deletions.
19 changes: 19 additions & 0 deletions rs/nns/governance/api/src/ic_nns_governance.pb.v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3054,27 +3054,46 @@ pub mod governance {
/// example, count = count_buckets.values().sum().
#[prost(uint64, optional, tag = "1")]
pub count: Option<u64>,

#[prost(uint64, optional, tag = "2")]
pub total_staked_e8s: Option<u64>,
#[prost(uint64, optional, tag = "3")]
pub total_staked_maturity_e8s_equivalent: Option<u64>,
#[prost(uint64, optional, tag = "4")]
pub total_maturity_e8s_equivalent: Option<u64>,

/// Deprecated. Use one of the following instead.
#[prost(uint64, optional, tag = "5")]
pub total_voting_power: Option<u64>,
/// Used to decide proposals. If all neurons refresh their voting
/// power/following frequently enough, this will be equal to potential
/// voting power. If not, this will be less.
#[prost(uint64, optional, tag = "11")]
pub total_deciding_voting_power: ::core::option::Option<u64>,
/// Used for voting rewards.
#[prost(uint64, optional, tag = "12")]
pub total_potential_voting_power: ::core::option::Option<u64>,

/// These fields are keyed by floor(dissolve delay / 0.5 years). These are
/// analogous to the (singular) fields above. Here, the usual definition of
/// year for the IC is used: exactly 365.25 days.
#[prost(map = "uint64, uint64", tag = "6")]
pub count_buckets: ::std::collections::HashMap<u64, u64>,

#[prost(map = "uint64, uint64", tag = "7")]
pub staked_e8s_buckets: ::std::collections::HashMap<u64, u64>,
#[prost(map = "uint64, uint64", tag = "8")]
pub staked_maturity_e8s_equivalent_buckets: ::std::collections::HashMap<u64, u64>,
#[prost(map = "uint64, uint64", tag = "9")]
pub maturity_e8s_equivalent_buckets: ::std::collections::HashMap<u64, u64>,

/// Deprecated. Use one of the following instead.
#[prost(map = "uint64, uint64", tag = "10")]
pub voting_power_buckets: ::std::collections::HashMap<u64, u64>,
#[prost(map = "uint64, uint64", tag = "13")]
pub deciding_voting_power_buckets: ::std::collections::HashMap<u64, u64>,
#[prost(map = "uint64, uint64", tag = "14")]
pub potential_voting_power_buckets: ::std::collections::HashMap<u64, u64>,
}
}
/// Records that making an OpenSnsTokenSwap (OSTS) or CreateServiceNervousSystem (CSNS)
Expand Down
21 changes: 15 additions & 6 deletions rs/nns/governance/canister/governance.did
Original file line number Diff line number Diff line change
Expand Up @@ -761,16 +761,25 @@ type NeuronStakeTransfer = record {
};

type NeuronSubsetMetrics = record {
total_maturity_e8s_equivalent : opt nat64;
maturity_e8s_equivalent_buckets : vec record { nat64; nat64 };
voting_power_buckets : vec record { nat64; nat64 };
total_staked_e8s : opt nat64;
count : opt nat64;

total_staked_e8s : opt nat64;
total_maturity_e8s_equivalent : opt nat64;
total_staked_maturity_e8s_equivalent : opt nat64;
staked_maturity_e8s_equivalent_buckets : vec record { nat64; nat64 };
staked_e8s_buckets : vec record { nat64; nat64 };

total_voting_power : opt nat64;
total_deciding_voting_power : opt nat64;
total_potential_voting_power : opt nat64;

count_buckets : vec record { nat64; nat64 };

staked_e8s_buckets : vec record { nat64; nat64 };
maturity_e8s_equivalent_buckets : vec record { nat64; nat64 };
staked_maturity_e8s_equivalent_buckets : vec record { nat64; nat64 };

voting_power_buckets : vec record { nat64; nat64 };
deciding_voting_power_buckets : vec record { nat64; nat64 };
potential_voting_power_buckets : vec record { nat64; nat64 };
};

type NeuronsFundAuditInfo = record {
Expand Down
21 changes: 15 additions & 6 deletions rs/nns/governance/canister/governance_test.did
Original file line number Diff line number Diff line change
Expand Up @@ -693,16 +693,25 @@ type NeuronStakeTransfer = record {
};

type NeuronSubsetMetrics = record {
total_maturity_e8s_equivalent : opt nat64;
maturity_e8s_equivalent_buckets : vec record { nat64; nat64 };
voting_power_buckets : vec record { nat64; nat64 };
total_staked_e8s : opt nat64;
count : opt nat64;

total_staked_e8s : opt nat64;
total_maturity_e8s_equivalent : opt nat64;
total_staked_maturity_e8s_equivalent : opt nat64;
staked_maturity_e8s_equivalent_buckets : vec record { nat64; nat64 };
staked_e8s_buckets : vec record { nat64; nat64 };

total_voting_power : opt nat64;
total_deciding_voting_power : opt nat64;
total_potential_voting_power : opt nat64;

count_buckets : vec record { nat64; nat64 };

staked_e8s_buckets : vec record { nat64; nat64 };
maturity_e8s_equivalent_buckets : vec record { nat64; nat64 };
staked_maturity_e8s_equivalent_buckets : vec record { nat64; nat64 };

voting_power_buckets : vec record { nat64; nat64 };
deciding_voting_power_buckets : vec record { nat64; nat64 };
potential_voting_power_buckets : vec record { nat64; nat64 };
};

type NeuronsFundAuditInfo = record {
Expand Down
14 changes: 14 additions & 0 deletions rs/nns/governance/proto/ic_nns_governance/pb/v1/governance.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2432,19 +2432,33 @@ message Governance {
// analogous fields (declared a little lower in this message). For
// example, count = count_buckets.values().sum().
optional uint64 count = 1;

optional uint64 total_staked_e8s = 2;
optional uint64 total_staked_maturity_e8s_equivalent = 3;
optional uint64 total_maturity_e8s_equivalent = 4;

// Deprecated. Use one of the following instead.
optional uint64 total_voting_power = 5;
// Used to decide proposals. If all neurons refresh their voting
// power/following frequently enough, this will be equal to potential
// voting power. If not, this will be less.
optional uint64 total_deciding_voting_power = 11;
// Used for voting rewards.
optional uint64 total_potential_voting_power = 12;

// These fields are keyed by floor(dissolve delay / 0.5 years). These are
// analogous to the (singular) fields above. Here, the usual definition of
// year for the IC is used: exactly 365.25 days.
map<uint64, uint64> count_buckets = 6;

map<uint64, uint64> staked_e8s_buckets = 7;
map<uint64, uint64> staked_maturity_e8s_equivalent_buckets = 8;
map<uint64, uint64> maturity_e8s_equivalent_buckets = 9;

// Deprecated. Use one of the following instead.
map<uint64, uint64> voting_power_buckets = 10;
map<uint64, uint64> deciding_voting_power_buckets = 13;
map<uint64, uint64> potential_voting_power_buckets = 14;
}

NeuronSubsetMetrics non_self_authenticating_controller_neuron_subset_metrics = 38;
Expand Down
14 changes: 14 additions & 0 deletions rs/nns/governance/src/gen/ic_nns_governance.pb.v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3629,8 +3629,17 @@ pub mod governance {
pub total_staked_maturity_e8s_equivalent: ::core::option::Option<u64>,
#[prost(uint64, optional, tag = "4")]
pub total_maturity_e8s_equivalent: ::core::option::Option<u64>,
/// Deprecated. Use one of the following instead.
#[prost(uint64, optional, tag = "5")]
pub total_voting_power: ::core::option::Option<u64>,
/// Used to decide proposals. If all neurons refresh their voting
/// power/following frequently enough, this will be equal to potential
/// voting power. If not, this will be less.
#[prost(uint64, optional, tag = "11")]
pub total_deciding_voting_power: ::core::option::Option<u64>,
/// Used for voting rewards.
#[prost(uint64, optional, tag = "12")]
pub total_potential_voting_power: ::core::option::Option<u64>,
/// These fields are keyed by floor(dissolve delay / 0.5 years). These are
/// analogous to the (singular) fields above. Here, the usual definition of
/// year for the IC is used: exactly 365.25 days.
Expand All @@ -3642,8 +3651,13 @@ pub mod governance {
pub staked_maturity_e8s_equivalent_buckets: ::std::collections::HashMap<u64, u64>,
#[prost(map = "uint64, uint64", tag = "9")]
pub maturity_e8s_equivalent_buckets: ::std::collections::HashMap<u64, u64>,
/// Deprecated. Use one of the following instead.
#[prost(map = "uint64, uint64", tag = "10")]
pub voting_power_buckets: ::std::collections::HashMap<u64, u64>,
#[prost(map = "uint64, uint64", tag = "13")]
pub deciding_voting_power_buckets: ::std::collections::HashMap<u64, u64>,
#[prost(map = "uint64, uint64", tag = "14")]
pub potential_voting_power_buckets: ::std::collections::HashMap<u64, u64>,
}
}
/// Records that making an OpenSnsTokenSwap (OSTS) or CreateServiceNervousSystem (CSNS)
Expand Down
25 changes: 22 additions & 3 deletions rs/nns/governance/src/governance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8090,6 +8090,13 @@ impl Governance {

/// Iterate over all neurons and compute `GovernanceCachedMetrics`
pub fn compute_cached_metrics(&self, now: u64, icp_supply: Tokens) -> GovernanceCachedMetrics {
let network_economics = self.economics();
let neuron_minimum_stake_e8s = network_economics.neuron_minimum_stake_e8s;
let voting_power_economics = network_economics
.voting_power_economics
.as_ref()
.unwrap_or(&VotingPowerEconomics::DEFAULT);

let NeuronMetrics {
dissolving_neurons_count,
dissolving_neurons_e8s_buckets,
Expand Down Expand Up @@ -8126,9 +8133,11 @@ impl Governance {
not_dissolving_neurons_e8s_buckets_ect,
non_self_authenticating_controller_neuron_subset_metrics,
public_neuron_subset_metrics,
} = self
.neuron_store
.compute_neuron_metrics(now, self.economics().neuron_minimum_stake_e8s);
} = self.neuron_store.compute_neuron_metrics(
neuron_minimum_stake_e8s,
voting_power_economics,
now,
);

let total_staked_e8s_non_self_authenticating_controller =
Some(non_self_authenticating_controller_neuron_subset_metrics.total_staked_e8s);
Expand Down Expand Up @@ -8202,32 +8211,42 @@ impl From<NeuronSubsetMetrics> for NeuronSubsetMetricsPb {
total_staked_maturity_e8s_equivalent,
total_maturity_e8s_equivalent,
total_voting_power,
total_deciding_voting_power,
total_potential_voting_power,

count_buckets,
staked_e8s_buckets,
staked_maturity_e8s_equivalent_buckets,
maturity_e8s_equivalent_buckets,
voting_power_buckets,
deciding_voting_power_buckets,
potential_voting_power_buckets,
} = src;

let count = Some(count);
let total_staked_e8s = Some(total_staked_e8s);
let total_staked_maturity_e8s_equivalent = Some(total_staked_maturity_e8s_equivalent);
let total_maturity_e8s_equivalent = Some(total_maturity_e8s_equivalent);
let total_voting_power = Some(total_voting_power);
let total_deciding_voting_power = Some(total_deciding_voting_power);
let total_potential_voting_power = Some(total_potential_voting_power);

NeuronSubsetMetricsPb {
count,
total_staked_e8s,
total_staked_maturity_e8s_equivalent,
total_maturity_e8s_equivalent,
total_voting_power,
total_deciding_voting_power,
total_potential_voting_power,

count_buckets,
staked_e8s_buckets,
staked_maturity_e8s_equivalent_buckets,
maturity_e8s_equivalent_buckets,
voting_power_buckets,
deciding_voting_power_buckets,
potential_voting_power_buckets,
}
}
}
Expand Down
Loading

0 comments on commit fb999df

Please sign in to comment.