Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(cli): handle non-existing actors gracefully in F3 power proportion CLI #5173

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions src/cli/subcommands/f3_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ use crate::{
f3::{F3Instant, F3Manifest, F3PowerEntry, FinalityCertificate},
prelude::*,
},
shim::fvm_shared_latest::ActorID,
};
use ahash::HashSet;
use anyhow::Context as _;
use cid::Cid;
use clap::{Subcommand, ValueEnum};
use itertools::Itertools as _;
use sailfish::TemplateSimple;
use serde::{Deserialize, Serialize};
use serde_with::{serde_as, DisplayFromStr};
Expand Down Expand Up @@ -272,12 +272,6 @@ impl F3PowerTableCommands {
}
}

anyhow::ensure!(
actor_id_set.is_empty(),
"actor ID {} not found in power table",
actor_id_set.into_iter().map(|i| i.to_string()).join(",")
);

let result = F3PowerTableGetProportionCommandResult {
instance,
from_ec: ec,
Expand All @@ -287,6 +281,7 @@ impl F3PowerTableCommands {
},
scaled_sum,
proportion: (scaled_sum as f64) / (scaled_total as f64),
not_found: actor_id_set.into_iter().collect(),
};
println!("{}", serde_json::to_string_pretty(&result)?);
}
Expand Down Expand Up @@ -374,6 +369,7 @@ pub struct F3PowerTableGetProportionCommandResult {
power_table: F3PowerTableCliMinimalJson,
scaled_sum: i64,
proportion: f64,
not_found: Vec<ActorID>,
}

#[serde_as]
Expand Down
Loading