From 9e3756e2e0a1e9646011d938d25f00889f0d962f Mon Sep 17 00:00:00 2001 From: cryptoAtwill Date: Mon, 9 Oct 2023 21:34:09 +0800 Subject: [PATCH] update review --- Cargo.lock | 9 +++++---- ipc/cli/src/commands/subnet/create.rs | 6 ++++-- ipc/cli/src/commands/subnet/join.rs | 9 ++++----- ipc/provider/src/lib.rs | 4 ++-- 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 08189bec..0754b0f7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2691,6 +2691,7 @@ dependencies = [ [[package]] name = "ipc_actors_abis" version = "0.1.0" +source = "git+https://github.com/consensus-shipyard/ipc-solidity-actors.git?branch=dev#081fea80569ff11c080de7281340c8faa167d3b0" dependencies = [ "anyhow", "ethers", @@ -3994,9 +3995,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.17" +version = "0.38.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f25469e9ae0f3d0047ca8b93fc56843f38e6774f0914a107ff8b41be8be8e0b7" +checksum = "5a74ee2d7c2581cd139b42447d7d9389b889bdaad3a73f1ebb16f2a3237bb19c" dependencies = [ "bitflags 2.4.0", "errno", @@ -4873,9 +4874,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.32.0" +version = "1.33.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17ed6077ed6cd6c74735e21f37eb16dc3935f96878b1fe961074089cc80893f9" +checksum = "4f38200e3ef7995e5ef13baec2f432a6da0aa9ac495b2c0e8f3b7eec2c92d653" dependencies = [ "backtrace", "bytes", diff --git a/ipc/cli/src/commands/subnet/create.rs b/ipc/cli/src/commands/subnet/create.rs index 00bccf48..37ff12f4 100644 --- a/ipc/cli/src/commands/subnet/create.rs +++ b/ipc/cli/src/commands/subnet/create.rs @@ -13,6 +13,8 @@ use std::str::FromStr; use crate::commands::get_ipc_provider; use crate::{f64_to_token_amount, CommandLineHandler, GlobalArguments}; +const DEFAULT_ACTIVE_VALIDATORS: u16 = 100; + /// The command to create a new subnet actor. pub struct CreateSubnet; @@ -36,7 +38,7 @@ impl CreateSubnet { arguments.min_validators, f64_to_token_amount(arguments.min_validator_stake)?, arguments.bottomup_check_period, - arguments.active_validators_limit, + arguments.active_validators_limit.unwrap_or(DEFAULT_ACTIVE_VALIDATORS), ) .await?; @@ -79,5 +81,5 @@ pub struct CreateSubnetArgs { #[arg(long, help = "The bottom up checkpoint period in number of blocks")] pub bottomup_check_period: ChainEpoch, #[arg(long, help = "The max number of active validators in subnet")] - pub active_validators_limit: u16, + pub active_validators_limit: Option, } diff --git a/ipc/cli/src/commands/subnet/join.rs b/ipc/cli/src/commands/subnet/join.rs index c66633fd..d9b1fe32 100644 --- a/ipc/cli/src/commands/subnet/join.rs +++ b/ipc/cli/src/commands/subnet/join.rs @@ -27,14 +27,13 @@ impl CommandLineHandler for JoinSubnet { Some(address) => Some(Address::from_str(address)?), None => None, }; - let metadata = - base64::engine::general_purpose::STANDARD_NO_PAD.decode(&arguments.metadata)?; + let public_key = hex::decode(&arguments.public_key)?; provider .join_subnet( subnet, from, f64_to_token_amount(arguments.collateral)?, - metadata, + public_key, ) .await } @@ -53,6 +52,6 @@ pub struct JoinSubnetArgs { help = "The collateral to stake in the subnet (in whole FIL units)" )] pub collateral: f64, - #[arg(long, short, help = "The validator's metadata, base64 encoded")] - pub metadata: String, + #[arg(long, short, help = "The validator's metadata, hex encoded")] + pub public_key: String, } diff --git a/ipc/provider/src/lib.rs b/ipc/provider/src/lib.rs index cfea7c3a..70716c46 100644 --- a/ipc/provider/src/lib.rs +++ b/ipc/provider/src/lib.rs @@ -262,7 +262,7 @@ impl IpcProvider { subnet: SubnetID, from: Option
, collateral: TokenAmount, - metadata: Vec, + public_key: Vec, ) -> anyhow::Result<()> { let parent = subnet.parent().ok_or_else(|| anyhow!("no parent found"))?; let conn = match self.connection(&parent) { @@ -274,7 +274,7 @@ impl IpcProvider { let sender = self.check_sender(subnet_config, from)?; conn.manager() - .join_subnet(subnet, sender, collateral, metadata) + .join_subnet(subnet, sender, collateral, public_key) .await }