Skip to content

Commit

Permalink
Merge branch 'NNS1-2178' into 'master'
Browse files Browse the repository at this point in the history
NNS1-2178: Add endpoint to manually fail stalled UpgradeSnsToNextVersion proposals in SNS Governance

Add an endpoint to reset the proposal and the pending_version in SNS Governance if it's past mark_failed_at seconds (which should happen in heartbeat).  This is a failsafe mechanism and should not have any side-effects in normal circumstances.

Additionally, this refactors some protobuf generator files. 

See merge request dfinity-lab/public/ic!11777
  • Loading branch information
daniel-wong-dfinity-org committed Apr 18, 2023
2 parents 60b5499 + a7ce41a commit 16a1bf3
Show file tree
Hide file tree
Showing 9 changed files with 641 additions and 580 deletions.
16 changes: 10 additions & 6 deletions rs/sns/governance/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,13 @@ MACRO_DEV_DEPENDENCIES = []

ALIASES = {}

LIB_SRCS = glob(
["src/**"],
# Ensures that we do not need to rebuild just because a _test.rs file
# changed.
exclude = ["**/*_tests.rs"],
)

cargo_build_script(
name = "build_script",
srcs = ["build.rs"],
Expand All @@ -99,9 +106,7 @@ cargo_build_script(

rust_library(
name = "governance",
srcs = glob([
"src/**",
]),
srcs = LIB_SRCS,
aliases = ALIASES,
crate_name = "ic_sns_governance",
proc_macro_deps = MACRO_DEPENDENCIES,
Expand All @@ -111,9 +116,7 @@ rust_library(

rust_library(
name = "governance_test_feature",
srcs = glob([
"src/**",
]),
srcs = LIB_SRCS,
aliases = ALIASES,
crate_features = ["test"],
crate_name = "ic_sns_governance",
Expand Down Expand Up @@ -173,6 +176,7 @@ rust_canister(

rust_test(
name = "governance_test",
srcs = glob(["src/**"]),
aliases = ALIASES,
crate = ":governance",
proc_macro_deps = MACRO_DEPENDENCIES + MACRO_DEV_DEPENDENCIES,
Expand Down
18 changes: 18 additions & 0 deletions rs/sns/governance/canister/canister.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ use ic_nervous_system_common::{
};
use ic_nns_constants::LEDGER_CANISTER_ID as NNS_LEDGER_CANISTER_ID;
use ic_sns_governance::logs::{ERROR, INFO};
use ic_sns_governance::pb::v1::{
FailStuckUpgradeInProgressRequest, FailStuckUpgradeInProgressResponse,
};
#[cfg(feature = "test")]
use ic_sns_governance::pb::v1::{GovernanceError, Neuron};
use ic_sns_governance::{
Expand Down Expand Up @@ -527,6 +530,21 @@ fn get_running_sns_version_(_: GetRunningSnsVersionRequest) -> GetRunningSnsVers
}
}

/// Marks an in progress upgrade that has passed its deadline as failed.
#[export_name = "canister_update fail_stuck_upgrade_in_progress"]
fn fail_stuck_upgrade_in_progress() {
log!(INFO, "fail_stuck_upgrade_in_progress");
over(candid_one, fail_stuck_upgrade_in_progress_)
}

/// Internal method for calling fail_stuck_upgrade_in_progress.
#[candid_method(update, rename = "fail_stuck_upgrade_in_progress")]
fn fail_stuck_upgrade_in_progress_(
request: FailStuckUpgradeInProgressRequest,
) -> FailStuckUpgradeInProgressResponse {
governance_mut().fail_stuck_upgrade_in_progress(request)
}

/// Sets the mode. Only the swap canister is allowed to call this.
///
/// In practice, the only mode that the swap canister would ever choose is
Expand Down
1 change: 1 addition & 0 deletions rs/sns/governance/canister/governance.did
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,7 @@ type VotingRewardsParameters = record {
type WaitForQuietState = record { current_deadline_timestamp_seconds : nat64 };
service : (Governance) -> {
claim_swap_neurons : (ClaimSwapNeuronsRequest) -> (ClaimSwapNeuronsResponse);
fail_stuck_upgrade_in_progress : (record {}) -> (record {});
get_build_metadata : () -> (text) query;
get_latest_reward_event : () -> (RewardEvent) query;
get_metadata : (record {}) -> (GetMetadataResponse) query;
Expand Down
1 change: 1 addition & 0 deletions rs/sns/governance/canister/governance_test.did
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,7 @@ type VotingRewardsParameters = record {
type WaitForQuietState = record { current_deadline_timestamp_seconds : nat64 };
service : (Governance) -> {
claim_swap_neurons : (ClaimSwapNeuronsRequest) -> (ClaimSwapNeuronsResponse);
fail_stuck_upgrade_in_progress : (record {}) -> (record {});
get_build_metadata : () -> (text) query;
get_latest_reward_event : () -> (RewardEvent) query;
get_metadata : (record {}) -> (GetMetadataResponse) query;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1296,6 +1296,15 @@ message GetRunningSnsVersionResponse {
Governance.UpgradeInProgress pending_version = 2;
}

// Request to fail an upgrade proposal that is Adopted but not Executed or
// Failed if it is past the time when it should have been marked as failed.
// This is useful in the case where the asynchronous process may have failed to
// complete
message FailStuckUpgradeInProgressRequest {}

// Response to FailStuckUpgradeInProgressRequest
message FailStuckUpgradeInProgressResponse {}

// Empty message to use in oneof fields that represent empty
// enums.
message Empty {}
Expand Down
Loading

0 comments on commit 16a1bf3

Please sign in to comment.