upgrade clap to v4.5 (#5273)

* upgrade clap to v4.5

* cli fixes

* Merge branch 'unstable' of https://github.com/sigp/lighthouse into upgrade-clap-cli

* value parser for mnemonic

* Merge branch 'unstable' of https://github.com/sigp/lighthouse into upgrade-clap-cli

* merge unstable

* default --format val

* fix eth sim

* fix eth sim

* merge conflicts

* resolve beta compiler issue

* add num args, version

* add custom flag parser, make rate limiter flags clap friendly

* remove unneeded check

* fmt

* update

* alphabetic order

* resolve merge conflict

* fix test

* resolve conflicts

* fix test

* revert removed if statement

* fmt got me again

* fix broken flag

* make cli

* make cli

* update

* remove -e files

* update

* cli help updates

* Merge branch 'unstable' of https://github.com/sigp/lighthouse into upgrade-clap-cli

* cli help updates

* md files

* merge conflict

* merge conflicts

* md

* help text, text width, and a few flag fixes

* fmt

* merge

* revert

* revert

* resolve merge conflicts

* merge conflicts

* revert simulator changes

* require at least one arg

* fix eth sim cli

* resolve merge conflicts

* book changes

* md changes

* cli check

* cli check

* retry cli check

* retry cli check

* Merge branch 'unstable' of https://github.com/sigp/lighthouse into upgrade-clap-cli

* cli

* Merge remote-tracking branch 'origin/unstable' into upgrade-clap-cli

* Update CLI docs for Goerli removal

* Fix cargo lock
This commit is contained in:
Eitan Seri-Levi
2024-05-28 07:46:39 +02:00
committed by GitHub
parent 6a7305a487
commit df983a83e1
61 changed files with 4036 additions and 2868 deletions

View File

@@ -8,13 +8,13 @@ use types::{BeaconState, EthSpec};
pub fn run<E: EthSpec>(testnet_dir: PathBuf, matches: &ArgMatches) -> Result<(), String> {
let path = matches
.value_of("ssz-state")
.get_one::<String>("ssz-state")
.ok_or("ssz-state not specified")?
.parse::<PathBuf>()
.map_err(|e| format!("Unable to parse ssz-state: {}", e))?;
let genesis_time = matches
.value_of("genesis-time")
.get_one::<String>("genesis-time")
.ok_or("genesis-time not specified")?
.parse::<u64>()
.map_err(|e| format!("Unable to parse genesis-time: {}", e))?;

View File

@@ -20,7 +20,9 @@ pub fn run<E: EthSpec>(matches: &ArgMatches) -> Result<(), String> {
);
let base_fee_per_gas = parse_required(matches, "base-fee-per-gas")?;
let gas_limit = parse_required(matches, "gas-limit")?;
let file_name = matches.value_of("file").ok_or("No file supplied")?;
let file_name = matches
.get_one::<String>("file")
.ok_or("No file supplied")?;
let fork_name: ForkName = parse_optional(matches, "fork")?.unwrap_or(ForkName::Bellatrix);
let execution_payload_header: ExecutionPayloadHeader<E> = match fork_name {

View File

@@ -4,7 +4,7 @@ use types::EthSpec;
use eth1_test_rig::{Http, Provider};
pub fn run<E: EthSpec>(env: Environment<E>, matches: &ArgMatches<'_>) -> Result<(), String> {
pub fn run<E: EthSpec>(env: Environment<E>, matches: &ArgMatches) -> Result<(), String> {
let eth1_http: String = clap_utils::parse_required(matches, "eth1-http")?;
let confirmations: usize = clap_utils::parse_required(matches, "confirmations")?;
let validator_count: Option<usize> = clap_utils::parse_optional(matches, "validator-count")?;

View File

@@ -15,15 +15,19 @@ pub const ETH1_GENESIS_UPDATE_INTERVAL: Duration = Duration::from_millis(7_000);
pub fn run<E: EthSpec>(
env: Environment<E>,
testnet_dir: PathBuf,
matches: &ArgMatches<'_>,
matches: &ArgMatches,
) -> Result<(), String> {
let endpoints = matches
.value_of("eth1-endpoint")
.get_one::<String>("eth1-endpoint")
.map(|e| {
warn!("The --eth1-endpoint flag is deprecated. Please use --eth1-endpoints instead");
String::from(e)
})
.or_else(|| matches.value_of("eth1-endpoints").map(String::from));
.or_else(|| {
matches
.get_one::<String>("eth1-endpoints")
.map(String::from)
});
let mut eth2_network_config = Eth2NetworkConfig::load(testnet_dir.clone())?;

View File

@@ -9,12 +9,12 @@ use types::{test_utils::generate_deterministic_keypairs, EthSpec, Hash256};
pub fn run<E: EthSpec>(testnet_dir: PathBuf, matches: &ArgMatches) -> Result<(), String> {
let validator_count = matches
.value_of("validator-count")
.get_one::<String>("validator-count")
.ok_or("validator-count not specified")?
.parse::<usize>()
.map_err(|e| format!("Unable to parse validator-count: {}", e))?;
let genesis_time = if let Some(genesis_time) = matches.value_of("genesis-time") {
let genesis_time = if let Some(genesis_time) = matches.get_one::<String>("genesis-time") {
genesis_time
.parse::<u64>()
.map_err(|e| format!("Unable to parse genesis-time: {}", e))?

File diff suppressed because it is too large Load Diff

View File

@@ -30,7 +30,7 @@ pub fn run<E: EthSpec>(testnet_dir_path: PathBuf, matches: &ArgMatches) -> Resul
let deposit_contract_address: Address = parse_required(matches, "deposit-contract-address")?;
let deposit_contract_deploy_block = parse_required(matches, "deposit-contract-deploy-block")?;
let overwrite_files = matches.is_present("force");
let overwrite_files = matches.get_flag("force");
if testnet_dir_path.exists() && !overwrite_files {
return Err(format!(
@@ -154,7 +154,7 @@ pub fn run<E: EthSpec>(testnet_dir_path: PathBuf, matches: &ArgMatches) -> Resul
(eth1_block_hash, genesis_time)
};
let genesis_state_bytes = if matches.is_present("interop-genesis-state") {
let genesis_state_bytes = if matches.get_flag("interop-genesis-state") {
let keypairs = generate_deterministic_keypairs(validator_count);
let keypairs: Vec<_> = keypairs.into_iter().map(|kp| (kp.clone(), kp)).collect();
@@ -167,7 +167,7 @@ pub fn run<E: EthSpec>(testnet_dir_path: PathBuf, matches: &ArgMatches) -> Resul
)?;
Some(genesis_state.as_ssz_bytes())
} else if matches.is_present("derived-genesis-state") {
} else if matches.get_flag("derived-genesis-state") {
let mnemonic_phrase: String = clap_utils::parse_required(matches, "mnemonic-phrase")?;
let mnemonic = Mnemonic::from_phrase(&mnemonic_phrase, Language::English).map_err(|e| {
format!(

View File

@@ -31,8 +31,12 @@ pub fn run_parse_ssz<E: EthSpec>(
network_config: Eth2NetworkConfig,
matches: &ArgMatches,
) -> Result<(), String> {
let type_str = matches.value_of("type").ok_or("No type supplied")?;
let filename = matches.value_of("ssz-file").ok_or("No file supplied")?;
let type_str = matches
.get_one::<String>("type")
.ok_or("No type supplied")?;
let filename = matches
.get_one::<String>("ssz-file")
.ok_or("No file supplied")?;
let format = parse_required(matches, "format")?;
let bytes = if filename.ends_with("ssz_snappy") {
@@ -58,7 +62,7 @@ pub fn run_parse_ssz<E: EthSpec>(
// More fork-specific decoders may need to be added in future, but shouldn't be 100% necessary,
// as the fork-generic decoder will always be available (requires correct --network flag).
match type_str {
match type_str.as_str() {
"SignedBeaconBlock" => decode_and_print::<SignedBeaconBlock<E>>(
&bytes,
|bytes| SignedBeaconBlock::from_ssz_bytes(bytes, spec),

View File

@@ -13,13 +13,13 @@ use types::{BeaconState, DepositData, EthSpec, Hash256, SignatureBytes, DEPOSIT_
pub fn run<E: EthSpec>(testnet_dir: PathBuf, matches: &ArgMatches) -> Result<(), String> {
let path = matches
.value_of("ssz-state")
.get_one::<String>("ssz-state")
.ok_or("ssz-state not specified")?
.parse::<PathBuf>()
.map_err(|e| format!("Unable to parse ssz-state: {}", e))?;
let mnemonic_phrase = matches
.value_of("mnemonic")
.get_one::<String>("mnemonic")
.ok_or("mnemonic not specified")?;
let eth2_network_config = Eth2NetworkConfig::load(testnet_dir)?;

View File

@@ -75,7 +75,7 @@ pub fn run<E: EthSpec>(
let runs: usize = parse_required(matches, "runs")?;
let slots: u64 = parse_required(matches, "slots")?;
let cli_state_root: Option<Hash256> = parse_optional(matches, "state-root")?;
let partial: bool = matches.is_present("partial-state-advance");
let partial: bool = matches.get_flag("partial-state-advance");
info!("Using {} spec", E::spec_name());
info!("Advancing {} slots", slots);

View File

@@ -117,9 +117,9 @@ pub fn run<E: EthSpec>(
let beacon_url: Option<SensitiveUrl> = parse_optional(matches, "beacon-url")?;
let runs: usize = parse_required(matches, "runs")?;
let config = Config {
no_signature_verification: matches.is_present("no-signature-verification"),
exclude_cache_builds: matches.is_present("exclude-cache-builds"),
exclude_post_block_thc: matches.is_present("exclude-post-block-thc"),
no_signature_verification: matches.get_flag("no-signature-verification"),
exclude_cache_builds: matches.get_flag("exclude-cache-builds"),
exclude_post_block_thc: matches.get_flag("exclude-post-block-thc"),
};
info!("Using {} spec", E::spec_name());