Skip to content

Commit

Permalink
Slight tweaks to ceremony CLI output
Browse files Browse the repository at this point in the history
  • Loading branch information
cronokirby committed Oct 23, 2023
1 parent 781f196 commit d8c6c40
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
28 changes: 21 additions & 7 deletions crates/bin/pcli/src/command/ceremony.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use crate::App;
use anyhow::{Context, Result};
use anyhow::{anyhow, Context, Result};
use penumbra_asset::Value;
use penumbra_keys::{keys::AddressIndex, Address};
use penumbra_num::Amount;
use penumbra_proof_setup::all::{
Phase1CeremonyContribution, Phase1RawCeremonyCRS, Phase2CeremonyContribution,
Phase2RawCeremonyCRS,
Expand Down Expand Up @@ -124,13 +125,17 @@ impl CeremonyCmd {
.await?
.max_decoding_message_size(max_message_size(*phase))
.max_encoding_message_size(max_message_size(*phase));
println!("connected to coordinator...");

println!(
r#"connected to coordinator!
You may disconnect (CTRL+C) to increase your bid if you don't like your position in the queue.
Otherwise, please keep this window open.
"#
);
use indicatif::{ProgressBar, ProgressDrawTarget, ProgressStyle};
let progress_bar = ProgressBar::with_draw_target(1, ProgressDrawTarget::stdout())
.with_style(ProgressStyle::default_bar().template(
"[{elapsed}] {bar:50.cyan/blue} {pos:>7}/{len:7} {per_sec} ETA: {eta}",
));
"[{elapsed}] {bar:50.cyan/blue} {pos:>7}/{len:7} {per_sec}\tETA: {eta}\t{msg}",
));
progress_bar.set_position(0);

let mut response_rx = client
Expand All @@ -146,11 +151,19 @@ impl CeremonyCmd {
Some(ParticipateResponse {
msg: Some(ResponseMsg::Position(p)),
}) => {
// This makes the progress bar go to 100% at the moment we're ready.
let len = p.connected_participants;
let pos = p.connected_participants - p.position;
progress_bar.set_length(len as u64);
progress_bar.set_position(pos as u64);
progress_bar.set_message(format!(
"(Your bid: {}, Top bid: {})",
Amount::try_from(
p.your_bid.ok_or(anyhow!("expected bid amount"))?
)?,
Amount::try_from(
p.last_slot_bid.ok_or(anyhow!("expected top bid amount"))?
)?
));
}
Some(ParticipateResponse {
msg:
Expand All @@ -167,7 +180,7 @@ impl CeremonyCmd {
}
}
};
println!("preparing contribution...");
println!("preparing contribution... (please keep this window open)");
let contribution = if *phase == 1 {
let parent = Phase1RawCeremonyCRS::unchecked_from_protobuf(unparsed_parent)?
.assume_valid();
Expand All @@ -186,6 +199,7 @@ impl CeremonyCmd {
msg: Some(RequestMsg::Contribution(contribution)),
})
.await?;
println!("coordinator is validating contribution...");
match response_rx.message().await? {
None => anyhow::bail!("Coordinator closed connection"),
Some(ParticipateResponse {
Expand Down
2 changes: 1 addition & 1 deletion tools/summonerd/src/coordinator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ impl ParticipantQueue {
.get(address)
.expect("Ranked participants are chosen from the set of connections");
if let Err(e) =
connection.try_notify((i + 1) as u32, ranked.len() as u32, contributor_bid, *bid)
connection.try_notify(i as u32, ranked.len() as u32, contributor_bid, *bid)
{
tracing::info!(?e, ?address, "pruning connection that we failed to notify");
self.participants.remove(address);
Expand Down

0 comments on commit d8c6c40

Please sign in to comment.