From 6729e9b41c1b626d91b865f4cb0e02f4b71afbfb Mon Sep 17 00:00:00 2001 From: Hamish Peebles Date: Wed, 3 Jan 2024 15:10:34 +0000 Subject: [PATCH 1/3] Only disburse 1 ICP rather than full amount until we've seen it working --- .../impl/src/jobs/process_neurons.rs | 11 +++++++++-- .../external_canisters/nns_governance/api/Cargo.toml | 1 - .../nns_governance/api/src/types.rs | 6 +++++- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/backend/canisters/neuron_controller/impl/src/jobs/process_neurons.rs b/backend/canisters/neuron_controller/impl/src/jobs/process_neurons.rs index a13ce1a223..b775145148 100644 --- a/backend/canisters/neuron_controller/impl/src/jobs/process_neurons.rs +++ b/backend/canisters/neuron_controller/impl/src/jobs/process_neurons.rs @@ -1,6 +1,7 @@ use crate::updates::manage_nns_neuron::manage_nns_neuron_impl; use crate::{mutate_state, read_state}; use ic_ledger_types::{AccountIdentifier, DEFAULT_SUBACCOUNT}; +use nns_governance_canister::types::manage_neuron::disburse::Amount; use nns_governance_canister::types::manage_neuron::{Command, Disburse, Spawn}; use nns_governance_canister::types::ListNeurons; use std::time::Duration; @@ -79,13 +80,19 @@ async fn spawn_neurons(neuron_ids: Vec) { } async fn disburse_neurons(neuron_ids: Vec) { + let account = nns_governance_canister::types::AccountIdentifier { + hash: AccountIdentifier::new(&SNS_GOVERNANCE_CANISTER_ID, &DEFAULT_SUBACCOUNT) + .as_ref() + .to_vec(), + }; + for neuron_id in neuron_ids { info!(neuron_id, "Disbursing neuron"); manage_nns_neuron_impl( neuron_id, Command::Disburse(Disburse { - to_account: Some(AccountIdentifier::new(&SNS_GOVERNANCE_CANISTER_ID, &DEFAULT_SUBACCOUNT)), - amount: None, + to_account: Some(account.clone()), + amount: Some(Amount { e8s: E8S_PER_ICP }), }), ) .await; diff --git a/backend/external_canisters/nns_governance/api/Cargo.toml b/backend/external_canisters/nns_governance/api/Cargo.toml index 7a4cece428..4078156ffb 100644 --- a/backend/external_canisters/nns_governance/api/Cargo.toml +++ b/backend/external_canisters/nns_governance/api/Cargo.toml @@ -8,7 +8,6 @@ edition = "2021" [dependencies] candid = { workspace = true } canister_time = { path = "../../../libraries/canister_time" } -ic-ledger-types = { workspace = true } serde = { workspace = true } serde_json = { workspace = true } types = { path = "../../../libraries/types" } diff --git a/backend/external_canisters/nns_governance/api/src/types.rs b/backend/external_canisters/nns_governance/api/src/types.rs index 40b3bb2fe1..a7ba674e30 100644 --- a/backend/external_canisters/nns_governance/api/src/types.rs +++ b/backend/external_canisters/nns_governance/api/src/types.rs @@ -1,5 +1,4 @@ use candid::{CandidType, Principal}; -use ic_ledger_types::AccountIdentifier; use serde::{Deserialize, Deserializer, Serialize}; use std::collections::HashMap; use types::TimestampMillis; @@ -663,6 +662,11 @@ pub struct Countries { pub iso_codes: Vec, } +#[derive(CandidType, Serialize, Deserialize, Clone, Debug)] +pub struct AccountIdentifier { + pub hash: Vec, +} + impl TryFrom for types::Proposal { type Error = String; From 9572633f9e90e7fb6c480afc14983f11a6bf6d06 Mon Sep 17 00:00:00 2001 From: Hamish Peebles Date: Wed, 3 Jan 2024 15:15:52 +0000 Subject: [PATCH 2/3] Update CHANGELOG --- backend/canisters/neuron_controller/CHANGELOG.md | 4 ++++ backend/canisters/neuron_controller/api/can.did | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/backend/canisters/neuron_controller/CHANGELOG.md b/backend/canisters/neuron_controller/CHANGELOG.md index c3f06ff183..fb52ac53b2 100644 --- a/backend/canisters/neuron_controller/CHANGELOG.md +++ b/backend/canisters/neuron_controller/CHANGELOG.md @@ -5,6 +5,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## [unreleased] +### Changed + +- Only disburse 1 ICP rather than full amount until we've seen it working ([#5103](https://github.com/open-chat-labs/open-chat/pull/5103)) + ### Added - Automatically spawn neurons then disburse into the treasury ([#5097](https://github.com/open-chat-labs/open-chat/pull/5097)) diff --git a/backend/canisters/neuron_controller/api/can.did b/backend/canisters/neuron_controller/api/can.did index 7ae4b584df..39c63a67d7 100644 --- a/backend/canisters/neuron_controller/api/can.did +++ b/backend/canisters/neuron_controller/api/can.did @@ -1,4 +1,4 @@ -type AccountIdentifier = vec nat8; +type AccountIdentifier = record { hash : vec nat8 }; type AddHotKey = record { new_hot_key : opt principal }; type Amount = record { e8s : nat64 }; type By = variant { From dccc6924089069eafeaa96e21efaad55e3172f1b Mon Sep 17 00:00:00 2001 From: Hamish Peebles Date: Wed, 3 Jan 2024 16:02:14 +0000 Subject: [PATCH 3/3] Update lock file --- Cargo.lock | 1 - 1 file changed, 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 1b5e78e243..7063a5c27a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4110,7 +4110,6 @@ version = "0.1.0" dependencies = [ "candid", "canister_time", - "ic-ledger-types", "serde", "serde_json", "types",