From 935748052284a730f1acec692485f0ae2577cd44 Mon Sep 17 00:00:00 2001 From: Andre Popovitch Date: Thu, 9 Jan 2025 21:19:55 -0600 Subject: [PATCH] governance needs to deserialize to its proto type, not the api type --- rs/sns/governance/canister/canister.rs | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/rs/sns/governance/canister/canister.rs b/rs/sns/governance/canister/canister.rs index 2c5e83ebaf48..3e5ed5be2ee3 100644 --- a/rs/sns/governance/canister/canister.rs +++ b/rs/sns/governance/canister/canister.rs @@ -26,6 +26,7 @@ use ic_sns_governance::{ pb::v1 as sns_gov_pb, types::{Environment, HeapGrowthPotential}, upgrade_journal::serve_journal, + upgrade_journal::serve_journal, }; use ic_sns_governance_api::pb::v1::{ get_running_sns_version_response::UpgradeInProgress, governance::Version, @@ -40,6 +41,18 @@ use ic_sns_governance_api::pb::v1::{ ListProposalsResponse, ManageNeuron, ManageNeuronResponse, NervousSystemParameters, RewardEvent, SetMode, SetModeResponse, }; +use ic_sns_governance_api::pb::v1::{ + get_running_sns_version_response::UpgradeInProgress, governance::Version, + ClaimSwapNeuronsRequest, ClaimSwapNeuronsResponse, FailStuckUpgradeInProgressRequest, + FailStuckUpgradeInProgressResponse, GetMaturityModulationRequest, + GetMaturityModulationResponse, GetMetadataRequest, GetMetadataResponse, GetMode, + GetModeResponse, GetNeuron, GetNeuronResponse, GetProposal, GetProposalResponse, + GetRunningSnsVersionRequest, GetRunningSnsVersionResponse, + GetSnsInitializationParametersRequest, GetSnsInitializationParametersResponse, + GetUpgradeJournalRequest, GetUpgradeJournalResponse, ListNervousSystemFunctionsResponse, + ListNeurons, ListNeuronsResponse, ListProposals, ListProposalsResponse, ManageNeuron, + ManageNeuronResponse, NervousSystemParameters, RewardEvent, SetMode, SetModeResponse, +}; #[cfg(feature = "test")] use ic_sns_governance_api::pb::v1::{ AddMaturityRequest, AddMaturityResponse, AdvanceTargetVersionRequest, @@ -211,8 +224,7 @@ fn caller() -> PrincipalId { /// In contrast to canister_init(), this method does not do deserialization. /// In addition to canister_init, this method is called by canister_post_upgrade. #[init] -fn canister_init_(init_payload: GovernanceProto) { - let init_payload = sns_gov_pb::Governance::from(init_payload); +fn canister_init_(init_payload: sns_gov_pb::Governance) { let init_payload = ValidGovernanceProto::try_from(init_payload).expect( "Cannot start canister, because the deserialized \ GovernanceProto is invalid in some way", @@ -277,7 +289,7 @@ fn canister_post_upgrade() { let reader = BufferedStableMemReader::new(STABLE_MEM_BUFFER_SIZE); - match GovernanceProto::decode(reader) { + match sns_gov_pb::Governance::decode(reader) { Err(err) => { log!( ERROR, @@ -304,7 +316,7 @@ fn canister_post_upgrade() { log!(INFO, "Completed post upgrade"); } -fn populate_finalize_disbursement_timestamp_seconds(governance_proto: &mut GovernanceProto) { +fn populate_finalize_disbursement_timestamp_seconds(governance_proto: &mut sns_gov_pb::Governance) { for neuron in governance_proto.neurons.values_mut() { for disbursement in neuron.disburse_maturity_in_progress.iter_mut() { disbursement.finalize_disbursement_timestamp_seconds = Some(