Skip to content

Commit

Permalink
Add controller and hotkeys information to ClaimSwapNeuronsRequest
Browse files Browse the repository at this point in the history
  • Loading branch information
anchpop committed Jul 26, 2024
1 parent e006612 commit 51319f0
Show file tree
Hide file tree
Showing 9 changed files with 905 additions and 187 deletions.
18 changes: 18 additions & 0 deletions rs/sns/governance/canister/governance.did
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ type ChangeAutoStakeMaturity = record {
type ClaimOrRefresh = record { by : opt By };
type ClaimOrRefreshResponse = record { refreshed_neuron_id : opt NeuronId };
type ClaimSwapNeuronsRequest = record {
recipes : opt NeuronRecipes;
neuron_parameters : vec NeuronParameters;
};
type ClaimSwapNeuronsResponse = record {
Expand Down Expand Up @@ -323,6 +324,7 @@ type Neuron = record {
neuron_fees_e8s : nat64;
};
type NeuronId = record { id : blob };
type NeuronIds = record { ids : vec NeuronId };
type NeuronInFlightCommand = record {
command : opt Command_2;
timestamp : nat64;
Expand All @@ -341,14 +343,30 @@ type NeuronPermission = record {
permission_type : vec int32;
};
type NeuronPermissionList = record { permissions : vec int32 };
type NeuronRecipe = record {
controller : opt principal;
dissolve_delay_seconds : opt nat64;
participant : opt Participant;
stake_e8s : opt nat64;
followees : opt NeuronIds;
neuron_id : opt NeuronId;
};
type NeuronRecipes = record { recipes : vec NeuronRecipe };
type NeuronsFund = record {
nns_neuron_hotkeys : opt Principals;
nns_neuron_controller : opt principal;
nns_neuron_id : opt nat64;
};
type Operation = variant {
ChangeAutoStakeMaturity : ChangeAutoStakeMaturity;
StopDissolving : record {};
StartDissolving : record {};
IncreaseDissolveDelay : IncreaseDissolveDelay;
SetDissolveTimestamp : SetDissolveTimestamp;
};
type Participant = variant { NeuronsFund : NeuronsFund; Direct : record {} };
type Percentage = record { basis_points : opt nat64 };
type Principals = record { principals : vec principal };
type Proposal = record {
url : text;
title : text;
Expand Down
18 changes: 18 additions & 0 deletions rs/sns/governance/canister/governance_test.did
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ type ChangeAutoStakeMaturity = record {
type ClaimOrRefresh = record { by : opt By };
type ClaimOrRefreshResponse = record { refreshed_neuron_id : opt NeuronId };
type ClaimSwapNeuronsRequest = record {
recipes : opt NeuronRecipes;
neuron_parameters : vec NeuronParameters;
};
type ClaimSwapNeuronsResponse = record {
Expand Down Expand Up @@ -329,6 +330,7 @@ type Neuron = record {
neuron_fees_e8s : nat64;
};
type NeuronId = record { id : blob };
type NeuronIds = record { ids : vec NeuronId };
type NeuronInFlightCommand = record {
command : opt Command_2;
timestamp : nat64;
Expand All @@ -347,14 +349,30 @@ type NeuronPermission = record {
permission_type : vec int32;
};
type NeuronPermissionList = record { permissions : vec int32 };
type NeuronRecipe = record {
controller : opt principal;
dissolve_delay_seconds : opt nat64;
participant : opt Participant;
stake_e8s : opt nat64;
followees : opt NeuronIds;
neuron_id : opt NeuronId;
};
type NeuronRecipes = record { recipes : vec NeuronRecipe };
type NeuronsFund = record {
nns_neuron_hotkeys : opt Principals;
nns_neuron_controller : opt principal;
nns_neuron_id : opt nat64;
};
type Operation = variant {
ChangeAutoStakeMaturity : ChangeAutoStakeMaturity;
StopDissolving : record {};
StartDissolving : record {};
IncreaseDissolveDelay : IncreaseDissolveDelay;
SetDissolveTimestamp : SetDissolveTimestamp;
};
type Participant = variant { NeuronsFund : NeuronsFund; Direct : record {} };
type Percentage = record { basis_points : opt nat64 };
type Principals = record { principals : vec principal };
type Proposal = record {
url : text;
title : text;
Expand Down
49 changes: 49 additions & 0 deletions rs/sns/governance/proto/ic_sns_governance/pb/v1/governance.proto
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ message NeuronId {
bytes id = 1;
}

// A sequence of NeuronIds, which is used to get prost to generate a type isomorphic to Option<Vec<NeuronId>>.
message NeuronIds {
repeated NeuronId ids = 1;
}


// The id of a specific proposal.
message ProposalId {
uint64 id = 1;
Expand Down Expand Up @@ -1950,6 +1956,7 @@ message GetModeResponse {
message ClaimSwapNeuronsRequest {
// NeuronParameters groups parameters for creating a neuron in the
// `claim_swap_neurons` method.
// TODO(NNS1-3198): Remove this message once `NeuronRecipe` is used systematically.
message NeuronParameters {
reserved "memo";
reserved 4;
Expand Down Expand Up @@ -1995,8 +2002,50 @@ message ClaimSwapNeuronsRequest {
repeated NeuronId followees = 8;
}

// Replacement for NeuronParameters. Contains the information needed to set up
// a neuron for a swap participant.
message NeuronRecipe {

// The info that for a participant in the Neurons' Fund
message NeuronsFund {
optional uint64 nns_neuron_id = 1;
optional ic_base_types.pb.v1.PrincipalId nns_neuron_controller = 2;
optional ic_nervous_system.pb.v1.Principals nns_neuron_hotkeys = 3;
}

// The info that for a direct participant
message Direct {}

// The principal that should be the controller of the SNS neuron
optional ic_base_types.pb.v1.PrincipalId controller = 1;
// The ID of the SNS neuron
optional NeuronId neuron_id = 2;

// The SNS neuron's stake in e8s (10E-8 of a token)
optional uint64 stake_e8s = 3;

// The duration in seconds that the neuron's dissolve delay will be set to.
optional uint64 dissolve_delay_seconds = 4;
//
optional NeuronIds followees = 5;

oneof participant {
Direct direct = 6;
NeuronsFund neurons_fund = 7;
}
}

// Needed to cause prost to generate a type isomorphic to
// Optional<Vec<NeuronRecipe>>.
message NeuronRecipes {
repeated NeuronRecipe recipes = 1;
}

optional NeuronRecipes recipes = 2;

// The set of parameters that define the neurons created in `claim_swap_neurons`. For
// each NeuronParameter, one neuron will be created.
// Deprecated. Use [`recipes`] instead.
repeated NeuronParameters neuron_parameters = 1;
}

Expand Down
75 changes: 75 additions & 0 deletions rs/sns/governance/src/gen/ic_sns_governance.pb.v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ pub struct NeuronId {
#[serde(with = "serde_bytes")]
pub id: ::prost::alloc::vec::Vec<u8>,
}
/// A sequence of NeuronIds, which is used to get prost to generate a type isomorphic to Option<Vec<NeuronId>>.
#[derive(candid::CandidType, candid::Deserialize, comparable::Comparable)]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct NeuronIds {
#[prost(message, repeated, tag = "1")]
pub ids: ::prost::alloc::vec::Vec<NeuronId>,
}
/// The id of a specific proposal.
#[derive(candid::CandidType, candid::Deserialize, comparable::Comparable, Eq, Copy)]
#[self_describing]
Expand Down Expand Up @@ -2510,15 +2518,19 @@ pub struct GetModeResponse {
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ClaimSwapNeuronsRequest {
#[prost(message, optional, tag = "2")]
pub recipes: ::core::option::Option<claim_swap_neurons_request::NeuronRecipes>,
/// The set of parameters that define the neurons created in `claim_swap_neurons`. For
/// each NeuronParameter, one neuron will be created.
/// Deprecated. Use \[`recipes`\] instead.
#[prost(message, repeated, tag = "1")]
pub neuron_parameters: ::prost::alloc::vec::Vec<claim_swap_neurons_request::NeuronParameters>,
}
/// Nested message and enum types in `ClaimSwapNeuronsRequest`.
pub mod claim_swap_neurons_request {
/// NeuronParameters groups parameters for creating a neuron in the
/// `claim_swap_neurons` method.
/// TODO(NNS1-3198): Remove this message once `NeuronRecipe` is used systematically.
#[derive(candid::CandidType, candid::Deserialize, comparable::Comparable)]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
Expand Down Expand Up @@ -2564,6 +2576,69 @@ pub mod claim_swap_neurons_request {
#[prost(message, repeated, tag = "8")]
pub followees: ::prost::alloc::vec::Vec<super::NeuronId>,
}
/// Replacement for NeuronParameters. Contains the information needed to set up
/// a neuron for a swap participant.
#[derive(candid::CandidType, candid::Deserialize, comparable::Comparable)]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct NeuronRecipe {
/// The principal that should be the controller of the SNS neuron
#[prost(message, optional, tag = "1")]
pub controller: ::core::option::Option<::ic_base_types::PrincipalId>,
/// The ID of the SNS neuron
#[prost(message, optional, tag = "2")]
pub neuron_id: ::core::option::Option<super::NeuronId>,
/// The SNS neuron's stake in e8s (10E-8 of a token)
#[prost(uint64, optional, tag = "3")]
pub stake_e8s: ::core::option::Option<u64>,
/// The duration in seconds that the neuron's dissolve delay will be set to.
#[prost(uint64, optional, tag = "4")]
pub dissolve_delay_seconds: ::core::option::Option<u64>,
///
#[prost(message, optional, tag = "5")]
pub followees: ::core::option::Option<super::NeuronIds>,
#[prost(oneof = "neuron_recipe::Participant", tags = "6, 7")]
pub participant: ::core::option::Option<neuron_recipe::Participant>,
}
/// Nested message and enum types in `NeuronRecipe`.
pub mod neuron_recipe {
/// The info that for a participant in the Neurons' Fund
#[derive(candid::CandidType, candid::Deserialize, comparable::Comparable)]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct NeuronsFund {
#[prost(uint64, optional, tag = "1")]
pub nns_neuron_id: ::core::option::Option<u64>,
#[prost(message, optional, tag = "2")]
pub nns_neuron_controller: ::core::option::Option<::ic_base_types::PrincipalId>,
#[prost(message, optional, tag = "3")]
pub nns_neuron_hotkeys:
::core::option::Option<::ic_nervous_system_proto::pb::v1::Principals>,
}
/// The info that for a direct participant
#[derive(candid::CandidType, candid::Deserialize, comparable::Comparable)]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Direct {}
#[derive(candid::CandidType, candid::Deserialize, comparable::Comparable)]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum Participant {
#[prost(message, tag = "6")]
Direct(Direct),
#[prost(message, tag = "7")]
NeuronsFund(NeuronsFund),
}
}
/// Needed to cause prost to generate a type isomorphic to
/// Optional<Vec<NeuronRecipe>>.
#[derive(candid::CandidType, candid::Deserialize, comparable::Comparable)]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct NeuronRecipes {
#[prost(message, repeated, tag = "1")]
pub recipes: ::prost::alloc::vec::Vec<NeuronRecipe>,
}
}
/// The response for the `claim_swap_neurons` method.
#[derive(candid::CandidType, candid::Deserialize, comparable::Comparable)]
Expand Down
Loading

0 comments on commit 51319f0

Please sign in to comment.