Skip to content
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

fix(nns): Move omitting large fields logic into domain->api conversion code #3453

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 2 additions & 25 deletions rs/nns/governance/api/src/ic_nns_governance.pb.v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1987,61 +1987,41 @@ pub struct WaitForQuietState {
/// This is a view of the ProposalData returned by API queries and is NOT used
/// for storage. The ballots are restricted to those of the caller's neurons and
/// additionally it has the computed fields, topic, status, and reward_status.
#[derive(candid::CandidType, candid::Deserialize, serde::Serialize, comparable::Comparable)]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
#[derive(candid::CandidType, candid::Deserialize, serde::Serialize, Clone, Debug, PartialEq)]
pub struct ProposalInfo {
/// The unique id for this proposal.
#[prost(message, optional, tag = "1")]
pub id: Option<::ic_nns_common::pb::v1::ProposalId>,
/// The ID of the neuron that made this proposal.
#[prost(message, optional, tag = "2")]
pub proposer: Option<NeuronId>,
/// The amount of ICP in E8s to be charged to the proposer if the proposal is
/// rejected.
#[prost(uint64, tag = "3")]
pub reject_cost_e8s: u64,
/// The proposal originally submitted.
#[prost(message, optional, tag = "4")]
pub proposal: Option<Proposal>,
/// The timestamp, in seconds from the Unix epoch, when this proposal was made.
#[prost(uint64, tag = "5")]
pub proposal_timestamp_seconds: u64,
/// See \[ProposalData::ballots\].
#[prost(map = "fixed64, message", tag = "6")]
pub ballots: ::std::collections::HashMap<u64, Ballot>,
/// See \[ProposalData::latest_tally\].
#[prost(message, optional, tag = "7")]
pub latest_tally: Option<Tally>,
/// See \[ProposalData::decided_timestamp_seconds\].
#[prost(uint64, tag = "8")]
pub decided_timestamp_seconds: u64,
/// See \[ProposalData::executed_timestamp_seconds\].
#[prost(uint64, tag = "12")]
pub executed_timestamp_seconds: u64,
/// See \[ProposalData::failed_timestamp_seconds\].
#[prost(uint64, tag = "13")]
pub failed_timestamp_seconds: u64,
/// See \[ProposalData::failure_reason\].
#[prost(message, optional, tag = "18")]
pub failure_reason: Option<GovernanceError>,
/// See \[ProposalData::reward_event_round\].
#[prost(uint64, tag = "14")]
pub reward_event_round: u64,
/// Derived - see \[Topic\] for more information
#[prost(enumeration = "Topic", tag = "15")]
pub topic: i32,
/// Derived - see \[ProposalStatus\] for more information
#[prost(enumeration = "ProposalStatus", tag = "16")]
pub status: i32,
/// Derived - see \[ProposalRewardStatus\] for more information
#[prost(enumeration = "ProposalRewardStatus", tag = "17")]
pub reward_status: i32,
#[prost(uint64, optional, tag = "19")]
pub deadline_timestamp_seconds: Option<u64>,
#[prost(message, optional, tag = "20")]
pub derived_proposal_information: Option<DerivedProposalInformation>,
#[prost(uint64, optional, tag = "21")]
pub total_potential_voting_power: ::core::option::Option<u64>,
}

Expand Down Expand Up @@ -3308,11 +3288,8 @@ pub struct ListProposalInfo {
#[prost(bool, optional, tag = "7")]
pub omit_large_fields: Option<bool>,
}
#[derive(candid::CandidType, candid::Deserialize, serde::Serialize, comparable::Comparable)]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
#[derive(candid::CandidType, candid::Deserialize, serde::Serialize, Clone, Debug, PartialEq)]
pub struct ListProposalInfoResponse {
#[prost(message, repeated, tag = "1")]
pub proposal_info: Vec<ProposalInfo>,
}
/// A request to list neurons. The "requested list", i.e., the list of
Expand Down
38 changes: 19 additions & 19 deletions rs/nns/governance/canbench/canbench_results.yml
Original file line number Diff line number Diff line change
@@ -1,55 +1,55 @@
benches:
add_neuron_active_maximum:
total:
instructions: 42559874
instructions: 42556627
heap_increase: 1
stable_memory_increase: 0
scopes: {}
add_neuron_active_typical:
total:
instructions: 2160611
instructions: 2160472
heap_increase: 0
stable_memory_increase: 0
scopes: {}
add_neuron_inactive_maximum:
total:
instructions: 112126649
instructions: 112123402
heap_increase: 1
stable_memory_increase: 0
scopes: {}
add_neuron_inactive_typical:
total:
instructions: 8465215
instructions: 8465076
heap_increase: 0
stable_memory_increase: 0
scopes: {}
cascading_vote_all_heap:
total:
instructions: 35565672
instructions: 34853041
heap_increase: 0
stable_memory_increase: 128
scopes: {}
cascading_vote_heap_neurons_stable_index:
total:
instructions: 61721390
instructions: 61008759
heap_increase: 0
stable_memory_increase: 128
scopes: {}
cascading_vote_stable_everything:
total:
instructions: 188861073
instructions: 188854175
heap_increase: 0
stable_memory_increase: 128
scopes: {}
cascading_vote_stable_neurons_with_heap_index:
total:
instructions: 162571959
instructions: 162565061
heap_increase: 0
stable_memory_increase: 128
scopes: {}
centralized_following_all_stable:
total:
instructions: 78285442
instructions: 78286335
heap_increase: 0
stable_memory_increase: 128
scopes: {}
Expand All @@ -61,7 +61,7 @@ benches:
scopes: {}
draw_maturity_from_neurons_fund_heap:
total:
instructions: 7549569
instructions: 7473869
heap_increase: 0
stable_memory_increase: 0
scopes: {}
Expand All @@ -73,13 +73,13 @@ benches:
scopes: {}
list_active_neurons_fund_neurons_heap:
total:
instructions: 436248
instructions: 425548
heap_increase: 0
stable_memory_increase: 0
scopes: {}
list_active_neurons_fund_neurons_stable:
total:
instructions: 2755320
instructions: 2745520
heap_increase: 0
stable_memory_increase: 0
scopes: {}
Expand All @@ -91,19 +91,19 @@ benches:
scopes: {}
list_neurons_ready_to_unstake_maturity_heap:
total:
instructions: 158257
instructions: 158253
heap_increase: 0
stable_memory_increase: 0
scopes: {}
list_neurons_ready_to_unstake_maturity_stable:
total:
instructions: 41326673
instructions: 41326675
heap_increase: 0
stable_memory_increase: 0
scopes: {}
list_neurons_stable:
total:
instructions: 113166221
instructions: 113168021
heap_increase: 5
stable_memory_increase: 0
scopes: {}
Expand All @@ -115,19 +115,19 @@ benches:
scopes: {}
list_ready_to_spawn_neuron_ids_stable:
total:
instructions: 41298569
instructions: 41298578
heap_increase: 0
stable_memory_increase: 0
scopes: {}
neuron_data_validation_heap:
total:
instructions: 407871691
instructions: 407849853
heap_increase: 0
stable_memory_increase: 0
scopes: {}
neuron_data_validation_stable:
total:
instructions: 363603468
instructions: 363580728
heap_increase: 0
stable_memory_increase: 0
scopes: {}
Expand All @@ -151,7 +151,7 @@ benches:
scopes: {}
single_vote_all_stable:
total:
instructions: 2802680
instructions: 2802518
heap_increase: 0
stable_memory_increase: 128
scopes: {}
Expand Down
17 changes: 7 additions & 10 deletions rs/nns/governance/canister/canister.rs
Original file line number Diff line number Diff line change
Expand Up @@ -782,9 +782,7 @@ fn get_neuron_info_by_id_or_subaccount(
#[query]
fn get_proposal_info(id: ProposalId) -> Option<ProposalInfo> {
debug_log("get_proposal_info");
governance()
.get_proposal_info(&caller(), id)
.map(ProposalInfo::from)
GOVERNANCE.with_borrow(|governance| governance.get_proposal_info(&caller(), id))
}

#[query]
Expand All @@ -800,17 +798,13 @@ fn get_neurons_fund_audit_info(
#[query]
fn get_pending_proposals() -> Vec<ProposalInfo> {
debug_log("get_pending_proposals");
governance()
.get_pending_proposals(&caller())
.into_iter()
.map(ProposalInfo::from)
.collect()
GOVERNANCE.with_borrow(|governance| governance.get_pending_proposals(&caller()))
}

#[query]
fn list_proposals(req: ListProposalInfo) -> ListProposalInfoResponse {
debug_log("list_proposals");
governance().list_proposals(&caller(), &(req.into())).into()
GOVERNANCE.with_borrow(|governance| governance.list_proposals(&caller(), &req.into()))
}

#[query]
Expand Down Expand Up @@ -892,7 +886,10 @@ fn get_latest_reward_event() -> RewardEvent {
#[query]
fn get_neuron_ids() -> Vec<NeuronId> {
debug_log("get_neuron_ids");
let votable = governance().get_neuron_ids_by_principal(&caller());
let votable = governance()
.get_neuron_ids_by_principal(&caller())
.into_iter()
.collect();

governance()
.get_managed_neuron_ids_for(votable)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1780,64 +1780,6 @@ message WaitForQuietState {
uint64 current_deadline_timestamp_seconds = 1;
}

// This is a view of the ProposalData returned by API queries and is NOT used
// for storage. The ballots are restricted to those of the caller's neurons and
// additionally it has the computed fields, topic, status, and reward_status.
message ProposalInfo {
// The unique id for this proposal.
ic_nns_common.pb.v1.ProposalId id = 1;

// The ID of the neuron that made this proposal.
ic_nns_common.pb.v1.NeuronId proposer = 2;

// The amount of ICP in E8s to be charged to the proposer if the proposal is
// rejected.
uint64 reject_cost_e8s = 3;

// The proposal originally submitted.
Proposal proposal = 4;

// The timestamp, in seconds from the Unix epoch, when this proposal was made.
uint64 proposal_timestamp_seconds = 5;

// See [ProposalData::ballots].
map<fixed64, Ballot> ballots = 6;

// See [ProposalData::latest_tally].
Tally latest_tally = 7;

// See [ProposalData::decided_timestamp_seconds].
uint64 decided_timestamp_seconds = 8;

// See [ProposalData::executed_timestamp_seconds].
uint64 executed_timestamp_seconds = 12;

// See [ProposalData::failed_timestamp_seconds].
uint64 failed_timestamp_seconds = 13;

// See [ProposalData::failure_reason].
GovernanceError failure_reason = 18;

// See [ProposalData::reward_event_round].
uint64 reward_event_round = 14;

// Derived - see [Topic] for more information
Topic topic = 15;

// Derived - see [ProposalStatus] for more information
ProposalStatus status = 16;

// Derived - see [ProposalRewardStatus] for more information
ProposalRewardStatus reward_status = 17;

optional uint64 deadline_timestamp_seconds = 19;

DerivedProposalInformation derived_proposal_information = 20;

// See [ProposalData::total_potential_voting_power].
optional uint64 total_potential_voting_power = 21;
}

// Network economics contains the parameters for several operations related
// to the economy of the network. When submitting a NetworkEconomics proposal
// default values (0) are considered unchanged, so a valid proposal only needs
Expand Down Expand Up @@ -2626,10 +2568,6 @@ message ListProposalInfo {
optional bool omit_large_fields = 7;
}

message ListProposalInfoResponse {
repeated ProposalInfo proposal_info = 1;
}

// A request to list neurons. The "requested list", i.e., the list of
// neuron IDs to retrieve information about, is the union of the list
// of neurons listed in `neuron_ids` and, if `caller_neurons` is true,
Expand Down
Loading
Loading