Skip to content

Commit

Permalink
bot: Update proposals candid bindings (#5947)
Browse files Browse the repository at this point in the history
# Motivation
We would like to render all the latest proposal types.
Even with no changes, just updating the reference is good practice.

# Changes
* Update the version of `IC_COMMIT_FOR_PROPOSALS` specified in
`dfx.json`.
* Updated the `proposals` candid files to the versions in that commit.
* Updated the Rust code derived from `.did` files in the proposals
payload rendering crate.

# Tests
- [ ] Please check the API updates for any breaking changes that affect
our code.
  - [ ] Please check for new proposal types and add tests for them.

Breaking changes are:
  * New mandatory fields
    * Removing mandatory fields
    * Renaming fields
    * Changing the type of a field
    * Adding new variants

Co-authored-by: gix-bot <[email protected]>
  • Loading branch information
pr-automation-bot-public[bot] and gix-bot authored Dec 9, 2024
1 parent 1f86c99 commit 808d5c2
Show file tree
Hide file tree
Showing 7 changed files with 112 additions and 8 deletions.
98 changes: 96 additions & 2 deletions declarations/used_by_proposals/nns_governance/nns_governance.did
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! Candid for canister `nns_governance` obtained by `scripts/update_ic_commit` from: <https://raw.githubusercontent.com/dfinity/ic/release-2024-11-28_03-15-revert-hashes-in-blocks/rs/nns/governance/canister/governance.did>
//! Candid for canister `nns_governance` obtained by `scripts/update_ic_commit` from: <https://raw.githubusercontent.com/dfinity/ic/release-2024-12-06_03-16-base/rs/nns/governance/canister/governance.did>
type AccountIdentifier = record {
hash : blob;
};
Expand Down Expand Up @@ -570,6 +570,32 @@ type NetworkEconomics = record {
minimum_icp_xdr_rate : nat64;
maximum_node_provider_rewards_e8s : nat64;
neurons_fund_economics : opt NeuronsFundEconomics;

// Parameters that affect the voting power of neurons.
voting_power_economics : opt VotingPowerEconomics;
};

// Parameters that affect the voting power of neurons.
type VotingPowerEconomics = record {
// If a neuron has not "refreshed" its voting power after this amount of time,
// its deciding voting power starts decreasing linearly. See also
// clear_following_after_seconds.
//
// For explanation of what "refresh" means in this context, see
// https://dashboard.internetcomputer.org/proposal/132411
//
// Initially, set to 0.5 years. (The nominal length of a year is 365.25 days).
start_reducing_voting_power_after_seconds : opt nat64;

// After a neuron has experienced voting power reduction for this amount of
// time, a couple of things happen:
//
// 1. Deciding voting power reaches 0.
//
// 2. Its following on topics other than NeuronManagement are cleared.
//
// Initially, set to 1/12 years.
clear_following_after_seconds : opt nat64;
};

type Neuron = record {
Expand All @@ -596,6 +622,63 @@ type Neuron = record {
known_neuron_data : opt KnownNeuronData;
spawn_at_timestamp_seconds : opt nat64;
voting_power_refreshed_timestamp_seconds : opt nat64;

// The amount of "sway" this neuron has when voting on proposals.
//
// When a proposal is created, each eligible neuron gets a "blank" ballot. The
// amount of voting power in that ballot is set to the neuron's deciding
// voting power at the time of proposal creation. There are two ways that a
// proposal can become decided:
//
// 1. Early: Either more than half of the total voting power in the ballots
// votes in favor (then the proposal is approved), or at least half of the
// votal voting power in the ballots votes against (then, the proposal is
// rejected).
//
// 2. The proposal's voting deadline is reached. At that point, if there is
// more voting power in favor than against, and at least 3% of the total
// voting power voted in favor, then the proposal is approved. Otherwise, it
// is rejected.
//
// If a neuron regularly refreshes its voting power, this has the same value
// as potential_voting_power. Actions that cause a refresh are as follows:
//
// 1. voting directly (not via following)
// 2. set following
// 3. refresh voting power
//
// (All of these actions are performed via the manage_neuron method.)
//
// However, if a neuron has not refreshed in a "long" time, this will be less
// than potential voting power. See VotingPowerEconomics. As a further result
// of less deciding voting power, not only does it have less influence on the
// outcome of proposals, the neuron receives less voting rewards (when it
// votes indirectly via following).
//
// For details, see https://dashboard.internetcomputer.org/proposal/132411.
//
// Per NNS policy, this is opt. Nevertheless, it will never be null.
deciding_voting_power : opt nat64;

// The amount of "sway" this neuron can have if it refreshes its voting power
// frequently enough.
//
// Unlike deciding_voting_power, this does NOT take refreshing into account.
// Rather, this only takes three factors into account:
//
// 1. (Net) staked amount - This is the "base" of a neuron's voting power.
// This primarily consists of the neuron's ICP balance.
//
// 2. Age - Neurons with more age have more voting power (all else being
// equal).
//
// 3. Dissolve delay - Neurons with longer dissolve delay have more voting
// power (all else being equal). Neurons with a dissolve delay of less
// than six months are not eligible to vote. Therefore, such neurons
// are considered to have 0 voting power.
//
// Per NNS policy, this is opt. Nevertheless, it will never be null.
potential_voting_power : opt nat64;
};

type NeuronBasketConstructionParameters = record {
Expand Down Expand Up @@ -634,6 +717,7 @@ type NeuronInFlightCommand = record {
timestamp : nat64;
};

// In general, this is a subset of Neuron.
type NeuronInfo = record {
dissolve_delay_seconds : nat64;
recent_ballots : vec BallotInfo;
Expand All @@ -645,9 +729,19 @@ type NeuronInfo = record {
retrieved_at_timestamp_seconds : nat64;
visibility : opt int32;
known_neuron_data : opt KnownNeuronData;
voting_power : nat64;
age_seconds : nat64;

// Deprecated. Use either deciding_voting_power or potential_voting_power
// instead. Has the same value as deciding_voting_power.
//
// Previously, if a neuron had < 6 months dissolve delay (making it ineligible
// to vote), this would not get set to 0 (zero). That was pretty confusing.
// Now that this is set to deciding_voting_power, this actually does get
// zeroed out.
voting_power : nat64;
voting_power_refreshed_timestamp_seconds : opt nat64;
deciding_voting_power : opt nat64;
potential_voting_power : opt nat64;
};

type NeuronStakeTransfer = record {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! Candid for canister `nns_registry` obtained by `scripts/update_ic_commit` from: <https://raw.githubusercontent.com/dfinity/ic/release-2024-11-28_03-15-revert-hashes-in-blocks/rs/registry/canister/canister/registry.did>
//! Candid for canister `nns_registry` obtained by `scripts/update_ic_commit` from: <https://raw.githubusercontent.com/dfinity/ic/release-2024-12-06_03-16-base/rs/registry/canister/canister/registry.did>
// A brief note about the history of this file: This file used to be
// automatically generated, but now, it is hand-crafted, because the
// auto-generator has some some pretty degenerate behaviors. The worst of those
Expand Down
2 changes: 1 addition & 1 deletion declarations/used_by_proposals/sns_wasm/sns_wasm.did
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! Candid for canister `sns_wasm` obtained by `scripts/update_ic_commit` from: <https://raw.githubusercontent.com/dfinity/ic/release-2024-11-28_03-15-revert-hashes-in-blocks/rs/nns/sns-wasm/canister/sns-wasm.did>
//! Candid for canister `sns_wasm` obtained by `scripts/update_ic_commit` from: <https://raw.githubusercontent.com/dfinity/ic/release-2024-12-06_03-16-base/rs/nns/sns-wasm/canister/sns-wasm.did>
type AddWasmRequest = record {
hash : blob;
wasm : opt SnsWasm;
Expand Down
2 changes: 1 addition & 1 deletion dfx.json
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@
"POCKETIC_VERSION": "3.0.1",
"CARGO_SORT_VERSION": "1.0.9",
"SNSDEMO_RELEASE": "release-2024-12-04",
"IC_COMMIT_FOR_PROPOSALS": "release-2024-11-28_03-15-revert-hashes-in-blocks",
"IC_COMMIT_FOR_PROPOSALS": "release-2024-12-06_03-16-base",
"IC_COMMIT_FOR_SNS_AGGREGATOR": "release-2024-11-28_03-15-revert-hashes-in-blocks"
},
"packtool": ""
Expand Down
12 changes: 11 additions & 1 deletion rs/proposals/src/canisters/nns_governance/api.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//! Rust code created from candid by: `scripts/did2rs.sh --canister nns_governance --out api.rs --header did2rs.header --traits Serialize`
//! Candid for canister `nns_governance` obtained by `scripts/update_ic_commit` from: <https://raw.githubusercontent.com/dfinity/ic/release-2024-11-28_03-15-revert-hashes-in-blocks/rs/nns/governance/canister/governance.did>
//! Candid for canister `nns_governance` obtained by `scripts/update_ic_commit` from: <https://raw.githubusercontent.com/dfinity/ic/release-2024-12-06_03-16-base/rs/nns/governance/canister/governance.did>
#![allow(clippy::all)]
#![allow(missing_docs)]
#![allow(clippy::missing_docs_in_private_items)]
Expand Down Expand Up @@ -397,6 +397,11 @@ pub struct RewardNodeProviders {
pub rewards: Vec<RewardNodeProvider>,
}
#[derive(Serialize, CandidType, Deserialize)]
pub struct VotingPowerEconomics {
pub start_reducing_voting_power_after_seconds: Option<u64>,
pub clear_following_after_seconds: Option<u64>,
}
#[derive(Serialize, CandidType, Deserialize)]
pub struct Decimal {
pub human_readable: Option<String>,
}
Expand All @@ -416,6 +421,7 @@ pub struct NeuronsFundEconomics {
#[derive(Serialize, CandidType, Deserialize)]
pub struct NetworkEconomics {
pub neuron_minimum_stake_e8s: u64,
pub voting_power_economics: Option<VotingPowerEconomics>,
pub max_proposals_to_keep_per_topic: u32,
pub neuron_management_fee_per_proposal_e8s: u64,
pub reject_cost_e8s: u64,
Expand Down Expand Up @@ -747,9 +753,11 @@ pub struct Neuron {
pub recent_ballots: Vec<BallotInfo>,
pub voting_power_refreshed_timestamp_seconds: Option<u64>,
pub kyc_verified: bool,
pub potential_voting_power: Option<u64>,
pub neuron_type: Option<i32>,
pub not_for_profit: bool,
pub maturity_e8s_equivalent: u64,
pub deciding_voting_power: Option<u64>,
pub cached_neuron_stake_e8s: u64,
pub created_timestamp_seconds: u64,
pub auto_stake_maturity: Option<bool>,
Expand Down Expand Up @@ -824,7 +832,9 @@ pub struct NeuronInfo {
pub dissolve_delay_seconds: u64,
pub recent_ballots: Vec<BallotInfo>,
pub voting_power_refreshed_timestamp_seconds: Option<u64>,
pub potential_voting_power: Option<u64>,
pub neuron_type: Option<i32>,
pub deciding_voting_power: Option<u64>,
pub created_timestamp_seconds: u64,
pub state: i32,
pub stake_e8s: u64,
Expand Down
2 changes: 1 addition & 1 deletion rs/proposals/src/canisters/nns_registry/api.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//! Rust code created from candid by: `scripts/did2rs.sh --canister nns_registry --out api.rs --header did2rs.header --traits Serialize`
//! Candid for canister `nns_registry` obtained by `scripts/update_ic_commit` from: <https://raw.githubusercontent.com/dfinity/ic/release-2024-11-28_03-15-revert-hashes-in-blocks/rs/registry/canister/canister/registry.did>
//! Candid for canister `nns_registry` obtained by `scripts/update_ic_commit` from: <https://raw.githubusercontent.com/dfinity/ic/release-2024-12-06_03-16-base/rs/registry/canister/canister/registry.did>
#![allow(clippy::all)]
#![allow(missing_docs)]
#![allow(clippy::missing_docs_in_private_items)]
Expand Down
2 changes: 1 addition & 1 deletion rs/proposals/src/canisters/sns_wasm/api.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//! Rust code created from candid by: `scripts/did2rs.sh --canister sns_wasm --out api.rs --header did2rs.header --traits Serialize`
//! Candid for canister `sns_wasm` obtained by `scripts/update_ic_commit` from: <https://raw.githubusercontent.com/dfinity/ic/release-2024-11-28_03-15-revert-hashes-in-blocks/rs/nns/sns-wasm/canister/sns-wasm.did>
//! Candid for canister `sns_wasm` obtained by `scripts/update_ic_commit` from: <https://raw.githubusercontent.com/dfinity/ic/release-2024-12-06_03-16-base/rs/nns/sns-wasm/canister/sns-wasm.did>
#![allow(clippy::all)]
#![allow(missing_docs)]
#![allow(clippy::missing_docs_in_private_items)]
Expand Down

0 comments on commit 808d5c2

Please sign in to comment.