Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into basvandijk/use-main…
Browse files Browse the repository at this point in the history
…net-nns-in-systests
  • Loading branch information
basvandijk committed Aug 3, 2024
2 parents 65757a3 + 99813d3 commit d0fc679
Show file tree
Hide file tree
Showing 25 changed files with 1,931 additions and 267 deletions.
3 changes: 3 additions & 0 deletions Cargo.lock

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

24 changes: 0 additions & 24 deletions ic-os/defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -322,20 +322,6 @@ def icos_build(
tags = ["manual"],
)

gzip_compress(
name = "disk-img.tar.gz",
srcs = [":disk-img.tar"],
visibility = visibility,
tags = ["manual"],
)

sha256sum(
name = "disk-img.tar.gz.sha256",
srcs = [":disk-img.tar.gz"],
visibility = visibility,
tags = ["manual"],
)

# -------------------- Assemble upgrade image --------------------

if upgrades:
Expand Down Expand Up @@ -444,7 +430,6 @@ def icos_build(
name = "upload_disk-img",
inputs = [
":disk-img.tar.zst",
":disk-img.tar.gz",
],
remote_subdir = upload_prefix + "/disk-img" + upload_suffix,
visibility = visibility,
Expand All @@ -458,14 +443,6 @@ def icos_build(
tags = ["manual"],
)

output_files(
name = "disk-img-url-gz",
target = ":upload_disk-img",
basenames = ["upload_disk-img_disk-img.tar.gz.url"],
visibility = visibility,
tags = ["manual"],
)

if upgrades:
upload_artifacts(
name = "upload_update-img",
Expand Down Expand Up @@ -629,7 +606,6 @@ EOF
testonly = malicious,
srcs = [
":disk-img.tar.zst",
":disk-img.tar.gz",
] + ([
":update-img.tar.zst",
":update-img.tar.gz",
Expand Down
20 changes: 19 additions & 1 deletion mainnet-canisters.bzl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
This module defines Bazel targets for the mainnet versions of the core NNS and SNS canisters.
This module defines Bazel targets for the mainnet versions of the core NNS, SNS, and ck canisters.
"""

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_file")
Expand All @@ -22,7 +22,9 @@ CANISTER_NAME_TO_WASM_METADATA = {
"sns_index": ("35e4f2c583b0657aa730740b5c8aca18a8718b8e", "110352d412a97dce090dd902e9dbdc874211d0e7a5179b6814ec1694e45a2807"),
"sns_ledger": ("35e4f2c583b0657aa730740b5c8aca18a8718b8e", "26de3e745b0e98cc83850ebf0f8fd1a574905bf7c73d52fcf61ee3f35e4875e1"),
"sns_archive": ("35e4f2c583b0657aa730740b5c8aca18a8718b8e", "ea2df4e0e3f4e5e91d43baf281728b2443ab3236ba473d78913cfbe2b5763d3c"),
"ck_btc_index": ("a3831c87440df4821b435050c8a8fcb3745d86f6", "cac207cf438df8c9fba46d4445c097f05fd8228a1eeacfe0536b7e9ddefc5f1c"),
"ck_btc_ledger": ("a3831c87440df4821b435050c8a8fcb3745d86f6", "4264ce2952c4e9ff802d81a11519d5e3ffdaed4215d5831a6634e59efd72f7d8"),
"ck_eth_index": ("a3831c87440df4821b435050c8a8fcb3745d86f6", "8104acad6105abb069b2dbc8289692bd63c2d110127f8e91f99db51465962606"),
"ck_eth_ledger": ("a3831c87440df4821b435050c8a8fcb3745d86f6", "e5c8a297d1c0c6d2ab2253c0280aaefd6e23fe3a8a994fc64706a1f3c3116062"),
}

Expand Down Expand Up @@ -132,6 +134,14 @@ def mainnet_ck_canisters():
url = canister_url(git_commit_id, "ic-icrc1-ledger.wasm.gz"),
)

git_commit_id, sha256 = CANISTER_NAME_TO_WASM_METADATA["ck_btc_index"]
http_file(
name = "mainnet_ckbtc-index-ng",
downloaded_file_path = "ic-icrc1-index-ng.wasm.gz",
sha256 = sha256,
url = canister_url(git_commit_id, "ic-icrc1-index-ng.wasm.gz"),
)

git_commit_id, sha256 = CANISTER_NAME_TO_WASM_METADATA["ck_eth_ledger"]
http_file(
name = "mainnet_cketh_ic-icrc1-ledger-u256",
Expand All @@ -140,6 +150,14 @@ def mainnet_ck_canisters():
url = canister_url(git_commit_id, "ic-icrc1-ledger-u256.wasm.gz"),
)

git_commit_id, sha256 = CANISTER_NAME_TO_WASM_METADATA["ck_eth_index"]
http_file(
name = "mainnet_cketh-index-ng",
downloaded_file_path = "ic-icrc1-index-ng-u256.wasm.gz",
sha256 = sha256,
url = canister_url(git_commit_id, "ic-icrc1-index-ng-u256.wasm.gz"),
)

def mainnet_sns_canisters():
"""
Provides Bazel targets for the latest SNS canisters published to the mainnet SNS-W.
Expand Down
16 changes: 12 additions & 4 deletions rs/nns/governance/src/governance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -962,6 +962,11 @@ impl Action {
}
Action::ExecuteNnsFunction(execute_nns_function)
}
Action::InstallCode(mut install_code) => {
install_code.wasm_module = None;
install_code.arg = None;
Action::InstallCode(install_code)
}
action => action,
}
}
Expand Down Expand Up @@ -3646,13 +3651,16 @@ impl Governance {
let voting_period_seconds = self.voting_period_seconds()(topic);
let reward_status = data.reward_status(now_seconds, voting_period_seconds);

// If this is part of a "multi" query and an ExecuteNnsFunction
// proposal then remove the payload if the payload is larger
// than EXECUTE_NNS_FUNCTION_PAYLOAD_LISTING_BYTES_MAX.
// For multi-queries, large fields such as WASM blobs need to be omitted. Otherwise the
// message limit will be exceeded.
let proposal = if multi_query {
if let Some(
proposal @ Proposal {
action: Some(proposal::Action::ExecuteNnsFunction(_)),
action:
Some(
proposal::Action::ExecuteNnsFunction(_)
| proposal::Action::InstallCode(_),
),
..
},
) = data.proposal.clone()
Expand Down
65 changes: 64 additions & 1 deletion rs/nns/governance/tests/governance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ use ic_nns_governance::{
governance_error::ErrorType::{
self, InsufficientFunds, NotAuthorized, NotFound, PreconditionFailed, ResourceExhausted,
},
install_code::CanisterInstallMode,
manage_neuron::{
self,
claim_or_refresh::{By, MemoAndController},
Expand All @@ -78,7 +79,7 @@ use ic_nns_governance::{
AddOrRemoveNodeProvider, ApproveGenesisKyc, Ballot, BallotChange, BallotInfo,
BallotInfoChange, CreateServiceNervousSystem, Empty, ExecuteNnsFunction,
Governance as GovernanceProto, GovernanceChange, GovernanceError,
IdealMatchedParticipationFunction, KnownNeuron, KnownNeuronData, ListNeurons,
IdealMatchedParticipationFunction, InstallCode, KnownNeuron, KnownNeuronData, ListNeurons,
ListProposalInfo, ListProposalInfoResponse, ManageNeuron, ManageNeuronResponse,
MonthlyNodeProviderRewards, Motion, NetworkEconomics, Neuron, NeuronChange, NeuronState,
NeuronType, NeuronsFundData, NeuronsFundParticipation, NeuronsFundSnapshot, NnsFunction,
Expand Down Expand Up @@ -7589,6 +7590,68 @@ fn test_list_proposals_removes_execute_nns_function_payload() {
);
}

#[test]
fn test_list_proposals_removes_install_code_large_fields() {
let original_install_code = InstallCode {
wasm_module: Some(vec![0; 100_000]),
arg: Some(vec![0; 1_000]),
install_mode: Some(CanisterInstallMode::Upgrade as i32),
canister_id: Some(GOVERNANCE_CANISTER_ID.into()),
skip_stopping_before_installing: Some(false),
};
let proto = GovernanceProto {
economics: Some(NetworkEconomics::with_default_values()),
proposals: btreemap! {
1 => ProposalData {
id: Some(ProposalId { id: 1 }),
proposal: Some(Proposal {
title: Some("Upgrade canister".to_string()),
action: Some(proposal::Action::InstallCode(original_install_code.clone())),
..Default::default()
}),
..Default::default()
}
},
..Default::default()
};
let driver = fake::FakeDriver::default();
let gov = Governance::new(
proto,
driver.get_fake_env(),
driver.get_fake_ledger(),
driver.get_fake_cmc(),
);
let caller = &principal(1);

let results = gov.list_proposals(
caller,
&ListProposalInfo {
..Default::default()
},
);

let action = results.proposal_info[0]
.proposal
.as_ref()
.unwrap()
.action
.as_ref()
.unwrap();
match action {
proposal::Action::InstallCode(install_code) => {
assert_eq!(
install_code,
&InstallCode {
wasm_module: None,
arg: None,
..original_install_code
}
);
}
_ => panic!("Unexpected action"),
};
}

#[test]
fn test_list_proposals_retains_execute_nns_function_payload() {
// ARRANGE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ DEPENDENCIES = [
"//rs/rosetta-api/icrc1/rosetta/client:ic-icrc-rosetta-client",
"//rs/rosetta-api/rosetta_core:rosetta-core",
"//rs/test_utilities/load_wasm",
"@crate_index//:anyhow",
"@crate_index//:candid",
"@crate_index//:ic-agent",
"@crate_index//:num-traits",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,5 @@ serde_json = { workspace = true }
tempfile = { workspace = true }
tokio = { workspace = true }
url = { workspace = true }
num-traits = { workspace = true }
num-traits = { workspace = true }
anyhow = { workspace = true }
13 changes: 9 additions & 4 deletions rs/rosetta-api/icp_ledger/rosetta-integration-tests/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ pub async fn start_rosetta(
ledger_canister_id: Principal,
state_directory: Option<PathBuf>,
enable_rosetta_blocks: bool,
persistent_storage: bool,
) -> (RosettaClient, RosettaContext) {
assert!(
rosetta_bin.exists(),
Expand All @@ -68,16 +69,20 @@ pub async fn start_rosetta(
}
}
}
let store_location = state_directory.join("data");
let mut cmd = Command::new(rosetta_bin);
cmd.arg("--ic-url")
.arg(ic_url.to_string())
.arg("--canister-id")
.arg(ledger_canister_id.to_string())
.arg("--port-file")
.arg(port_file.clone())
.arg("--store-location")
.arg(store_location.clone());
.arg(port_file.clone());

if persistent_storage {
let store_location = state_directory.join("data");
cmd.arg("--store-location").arg(store_location);
} else {
cmd.arg("--store-type").arg("sqlite-in-memory");
}

if enable_rosetta_blocks {
cmd.arg("--enable-rosetta-blocks");
Expand Down
Loading

0 comments on commit d0fc679

Please sign in to comment.