Skip to content

Commit

Permalink
Automatically submit proposals
Browse files Browse the repository at this point in the history
  • Loading branch information
anchpop committed Feb 1, 2025
1 parent 3be2fb7 commit 7a4bf6d
Showing 1 changed file with 135 additions and 8 deletions.
143 changes: 135 additions & 8 deletions rs/nervous_system/tools/release-runscript/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use clap::{Parser, Subcommand};
use colored::*;
use std::io::{self, Write};
use std::path::PathBuf;
use std::process::Command;
use std::process::{Command, Stdio};

#[derive(Debug, Parser)]
struct DetermineTargets {
Expand Down Expand Up @@ -32,7 +32,12 @@ struct CreateProposalTexts {
}

#[derive(Debug, Parser)]
struct SubmitProposals;
struct SubmitProposals {
#[arg(long)]
nns_proposal_text_paths: Vec<PathBuf>,
#[arg(long)]
sns_proposal_text_paths: Vec<PathBuf>,
}

#[derive(Debug, Parser)]
struct CreateForumPost;
Expand Down Expand Up @@ -354,17 +359,139 @@ SNS proposal texts: {}",
)
);

run_submit_proposals(SubmitProposals);
run_submit_proposals(SubmitProposals {
nns_proposal_text_paths,
sns_proposal_text_paths,
});
}

fn run_submit_proposals(_: SubmitProposals) {
fn run_submit_proposals(cmd: SubmitProposals) {
let SubmitProposals {
nns_proposal_text_paths,
sns_proposal_text_paths,
} = cmd;

// Ask the user for the SUBMITTING_NEURON_ID (example: 51)
print!("Do you want to submit upgrade proposals? (y/N): ");
io::stdout().flush().unwrap();
let mut input = String::new();
io::stdin().read_line(&mut input).unwrap();
if input.trim().to_lowercase() != "y" {
println!("Skipping upgrade proposal submission and all following steps.");
return;
}
println!();

println!("We are now going to submit the proposals. For this step, we need your neuron ID. If you are submitting on behalf of DFINITY, your neuron ID is written at this notion page: <https://www.notion.so/dfinityorg/3a1856c603704d51a6fcd2a57c98f92f?v=fc597afede904e499744f3528cad6682>.");
print!("Enter your neuron ID (e.g. 51): ");
io::stdout().flush().unwrap();
let mut neuron_id = String::new();
io::stdin().read_line(&mut neuron_id).unwrap();
let neuron_id = neuron_id.trim().to_string();

println!("Plug in your HSM key. Unplug your Ubikey.");
println!("Once you have done that, you can test your key hardware with the following command:");
println!(" pkcs11-tool --list-slots");
println!("And you can practice entering your password with: ");
println!(" pkcs11-tool --login --test");
println!("Press Enter to continue...");
io::stdout().flush().unwrap();
io::stdin().read_line(&mut input).unwrap();

let ic = ic_dir();

let mut sns_proposal_ids = Vec::new();
let mut nns_proposal_ids = Vec::new();

// For each NNS proposal, run the submission script.
for proposal_path in &nns_proposal_text_paths {
println!("Submitting NNS proposal: {}", proposal_path.display());
let script = ic.join("testnet/tools/nns-tools/submit-mainnet-nns-upgrade-proposal.sh");
let output = Command::new(script)
.arg(proposal_path.to_str().expect("Invalid proposal path"))
.arg(&neuron_id)
.current_dir(&ic)
.stdin(Stdio::inherit())
.stdout(Stdio::inherit())
.stderr(Stdio::inherit())
.output()
.expect("Failed to run submit-mainnet-nns-upgrade-proposal.sh");
if !output.status.success() {
panic!(
"Submission failed for {}: {}",
proposal_path.display(),
String::from_utf8_lossy(&output.stderr)
);
}

println!("Submission successful for {}", proposal_path.display());

// ask the user for the proposal id
print!("Enter the proposal ID: ");
io::stdout().flush().unwrap();
let mut proposal_id = String::new();
io::stdin().read_line(&mut proposal_id).unwrap();
let proposal_id = proposal_id.trim().to_string();
nns_proposal_ids.push(proposal_id);
}

// For each SNS proposal, run the submission script.
for proposal_path in &sns_proposal_text_paths {
println!("Submitting SNS proposal: {}", proposal_path.display());
let script = ic.join("testnet/tools/nns-tools/submit-mainnet-publish-sns-wasm-proposal.sh");
let output = Command::new(script)
.arg(proposal_path.to_str().expect("Invalid proposal path"))
.arg(&neuron_id)
.current_dir(&ic)
.stdin(Stdio::inherit())
.stdout(Stdio::inherit())
.stderr(Stdio::inherit())
.output()
.expect("Failed to run submit-mainnet-publish-sns-wasm-proposal.sh");
if !output.status.success() {
panic!(
"Submission failed for {}: {}",
proposal_path.display(),
String::from_utf8_lossy(&output.stderr)
);
}
println!("Submission successful for {}", proposal_path.display());
println!("Output: {}", String::from_utf8_lossy(&output.stdout));

// ask the user for the proposal id
print!("Enter the proposal ID: ");
io::stdout().flush().unwrap();
let mut proposal_id = String::new();
io::stdin().read_line(&mut proposal_id).unwrap();
let proposal_id = proposal_id.trim().to_string();
sns_proposal_ids.push(proposal_id);
}

use std::fmt::Write;
print_step(
5,
"Submit Proposals",
"Submit the proposals on Friday
Follow detailed instructions at:
testnet/tools/nns-tools/README.md#submit-the-proposals",
&format!(
"I submitted the following proposals:
NNS: {}
SNS: {}",
nns_proposal_ids.iter().fold(String::new(), |mut acc, id| {
let _ = write!(
acc,
"\n - https://dashboard.internetcomputer.org/proposal/{}",
id
);
acc
}),
sns_proposal_ids.iter().fold(String::new(), |mut acc, id| {
let _ = write!(
acc,
"\n - https://dashboard.internetcomputer.org/proposal/{}",
id
);
acc
})
),
);

run_create_forum_post(CreateForumPost);
Expand Down

0 comments on commit 7a4bf6d

Please sign in to comment.