Skip to content

Commit

Permalink
refactor: Migrate more type dependencies to use ic_nns_governance_api (
Browse files Browse the repository at this point in the history
…#628)

As part of an ongoing effort to remove dependencies on the nns
governance crate, additional dependencies on ic_nns_governance::pb are
being redirected to depend on ic_nns_governance_api::pb, with minimal
implementations being ported to support them.

Additional followup work to disentangle further dependencies is needed,
as not all dependencies on ic_nns_governance::pb were migrated with this
PR.

---------

Co-authored-by: IDX GitHub Automation <[email protected]>
  • Loading branch information
max-dfinity and IDX GitHub Automation authored Aug 7, 2024
1 parent 0f75497 commit 12e89bb
Show file tree
Hide file tree
Showing 135 changed files with 925 additions and 731 deletions.
28 changes: 17 additions & 11 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion rs/nervous_system/common/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ BUILD_DEPENDENCIES = [

DEV_DEPENDENCIES = [
# Keep sorted.
"//rs/nns/governance",
"//rs/nns/governance/api",
"@crate_index//:proptest",
"@crate_index//:serde_bytes",
] + select({
Expand Down
2 changes: 1 addition & 1 deletion rs/nervous_system/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,6 @@ assert_matches = { workspace = true }
build-info-build = { workspace = true }

[dev-dependencies]
ic-nns-governance = { path = "../../nns/governance" }
ic-nns-governance-api = { path = "../../nns/governance/api" }
proptest = "1.0"
serde_bytes = { workspace = true }
2 changes: 1 addition & 1 deletion rs/nervous_system/common/src/dfn_core_stable_mem_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ impl Buf for BufferedStableMemReader {
mod test {
use super::*;
use bytes::Buf;
use ic_nns_governance::pb::v1::{Governance, NetworkEconomics, Neuron};
use ic_nns_governance_api::pb::v1::{Governance, NetworkEconomics, Neuron};
use prost::Message;

fn allocate_governance(num_neurons: u64) -> Governance {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ mod test {
},
};
use bytes::{Buf, BufMut};
use ic_nns_governance::pb::v1::{Governance, NetworkEconomics, Neuron};
use ic_nns_governance_api::pb::v1::{Governance, NetworkEconomics, Neuron};
use ic_stable_structures::{vec_mem::VectorMemory, Memory};
use prost::Message;

Expand Down
1 change: 1 addition & 0 deletions rs/nervous_system/integration_tests/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ BASE_DEPENDENCIES = [
DEPENDENCIES_WITH_TEST_FEATURES = BASE_DEPENDENCIES + [
"//rs/sns/init:init--test_feature",
"//rs/nns/governance:governance--test_feature",
"//rs/nns/governance/api:api--test_feature",
"//rs/nns/sns-wasm:sns-wasm--test_feature",
"//rs/nns/handlers/root/impl:root--test_feature",
"//rs/sns/governance:governance--test_feature",
Expand Down
1 change: 1 addition & 0 deletions rs/nervous_system/integration_tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ ic-nervous-system-root = { path = "../root" }
ic-nervous-system-proto = { path = "../proto" }
ic-nns-common = { path = "../../nns/common" }
ic-nns-governance = { path = "../../nns/governance" }
ic-nns-governance-api = { path = "../../nns/governance/api" }
ic-sns-root = { path = "../../sns/root" }
ic-sns-governance = { path = "../../sns/governance" }
ic-sns-swap = { path = "../../sns/swap" }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
use ic_base_types::{CanisterId, PrincipalId};
use ic_nervous_system_common::E8;
use ic_nervous_system_proto::pb::v1::{Canister, Duration as DurationPb, Tokens as TokensPb};
use ic_nns_governance::{
governance::test_data::CREATE_SERVICE_NERVOUS_SYSTEM_WITH_MATCHED_FUNDING,
pb::v1::{
create_service_nervous_system::{
initial_token_distribution::developer_distribution::NeuronDistribution, SwapParameters,
},
CreateServiceNervousSystem,
use ic_nns_governance::governance::test_data::CREATE_SERVICE_NERVOUS_SYSTEM_WITH_MATCHED_FUNDING;
use ic_nns_governance_api::pb::v1::{
create_service_nervous_system::{
initial_token_distribution::developer_distribution::NeuronDistribution, SwapParameters,
},
CreateServiceNervousSystem,
};

#[derive(Clone, Debug)]
Expand All @@ -20,6 +18,7 @@ impl Default for CreateServiceNervousSystemBuilder {
let swap_parameters = CREATE_SERVICE_NERVOUS_SYSTEM_WITH_MATCHED_FUNDING
.swap_parameters
.clone()
.map(|x| x.into())
.unwrap();
let swap_parameters = SwapParameters {
// Ensure just one huge direct participant can finalize the swap.
Expand All @@ -37,7 +36,9 @@ impl Default for CreateServiceNervousSystemBuilder {
CreateServiceNervousSystemBuilder(CreateServiceNervousSystem {
dapp_canisters: vec![],
swap_parameters: Some(swap_parameters),
..CREATE_SERVICE_NERVOUS_SYSTEM_WITH_MATCHED_FUNDING.clone()
..CREATE_SERVICE_NERVOUS_SYSTEM_WITH_MATCHED_FUNDING
.clone()
.into()
})
}
}
Expand Down
4 changes: 2 additions & 2 deletions rs/nervous_system/integration_tests/src/pocket_ic_helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use ic_nns_constants::{
self, ALL_NNS_CANISTER_IDS, GOVERNANCE_CANISTER_ID, LEDGER_CANISTER_ID, LIFELINE_CANISTER_ID,
REGISTRY_CANISTER_ID, ROOT_CANISTER_ID, SNS_WASM_CANISTER_ID,
};
use ic_nns_governance::pb::v1::{
use ic_nns_governance_api::pb::v1::{
manage_neuron, manage_neuron_response, proposal, CreateServiceNervousSystem,
ExecuteNnsFunction, GetNeuronsFundAuditInfoRequest, GetNeuronsFundAuditInfoResponse,
ListNeurons, ListNeuronsResponse, ManageNeuron, ManageNeuronResponse, NetworkEconomics,
Expand Down Expand Up @@ -2150,7 +2150,7 @@ pub mod sns {
pub mod swap {
use super::*;
use assert_matches::assert_matches;
use ic_nns_governance::pb::v1::create_service_nervous_system::SwapParameters;
use ic_nns_governance_api::pb::v1::create_service_nervous_system::SwapParameters;
use ic_sns_swap::{
pb::v1::{BuyerState, GetOpenTicketRequest, GetOpenTicketResponse},
swap::principal_to_subaccount,
Expand Down
12 changes: 5 additions & 7 deletions rs/nervous_system/integration_tests/tests/sns_lifecycle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,11 @@ use ic_nervous_system_integration_tests::{
};
use ic_nervous_system_proto::pb::v1::{Duration as DurationPb, Tokens as TokensPb};
use ic_nns_constants::{GOVERNANCE_CANISTER_ID, ROOT_CANISTER_ID};
use ic_nns_governance::{
neurons_fund::neurons_fund_neuron::pick_most_important_hotkeys,
pb::v1::{
create_service_nervous_system::initial_token_distribution::developer_distribution::NeuronDistribution,
get_neurons_fund_audit_info_response, neurons_fund_snapshot::NeuronsFundNeuronPortion,
CreateServiceNervousSystem, Neuron,
},
use ic_nns_governance::neurons_fund::neurons_fund_neuron::pick_most_important_hotkeys;
use ic_nns_governance_api::pb::v1::{
create_service_nervous_system::initial_token_distribution::developer_distribution::NeuronDistribution,
get_neurons_fund_audit_info_response, neurons_fund_snapshot::NeuronsFundNeuronPortion,
CreateServiceNervousSystem, Neuron,
};
use ic_sns_governance::{
governance::TREASURY_SUBACCOUNT_NONCE,
Expand Down
Loading

0 comments on commit 12e89bb

Please sign in to comment.