diff --git a/multinode-demo/client.sh b/multinode-demo/client.sh index 0e6e8ff739d773..d3d9ebb7f11e8c 100755 --- a/multinode-demo/client.sh +++ b/multinode-demo/client.sh @@ -15,8 +15,8 @@ rsync_leader_url=$(rsync_url "$leader") set -ex mkdir -p $SOLANA_CONFIG_DIR -rsync -vPz "$rsync_leader_url"/config/leader.json $SOLANA_CONFIG_DIR/ -rsync -vPz "$rsync_leader_url"/config-private/mint.json $SOLANA_CONFIG_DIR/ +$rsync -vPz "$rsync_leader_url"/config/leader.json $SOLANA_CONFIG_DIR/ +$rsync -vPz "$rsync_leader_url"/config-private/mint.json $SOLANA_CONFIG_DIR/ # shellcheck disable=SC2086 # $solana_client_demo should not be quoted exec $solana_client_demo \ diff --git a/multinode-demo/common.sh b/multinode-demo/common.sh index 03f97ca2a713b8..dbd0ab9ab0f349 100644 --- a/multinode-demo/common.sh +++ b/multinode-demo/common.sh @@ -3,11 +3,13 @@ # Disable complaints about unused variables in this file: # shellcheck disable=2034 +rsync=rsync if [[ -d "$SNAP" ]]; then # Running inside a Linux Snap? solana_program() { declare program="$1" printf "%s/command-%s.wrapper" "$SNAP" "$program" } + rsync="$SNAP"/bin/rsync SOLANA_CUDA="$(snapctl get enable-cuda)" elif [[ -n "$USE_SNAP" ]]; then # Use the Linux Snap binaries diff --git a/multinode-demo/drone.sh b/multinode-demo/drone.sh index d2677dd113edaf..74f7dcdfac701a 100755 --- a/multinode-demo/drone.sh +++ b/multinode-demo/drone.sh @@ -27,8 +27,8 @@ fi rsync_leader_url=$(rsync_url "$leader") set -ex mkdir -p $SOLANA_CONFIG_DIR -rsync -vPz "$rsync_leader_url"/config/leader.json $SOLANA_CONFIG_DIR/ -rsync -vPz "$rsync_leader_url"/config-private/mint.json $SOLANA_CONFIG_DIR/ +$rsync -vPz "$rsync_leader_url"/config/leader.json $SOLANA_CONFIG_DIR/ +$rsync -vPz "$rsync_leader_url"/config-private/mint.json $SOLANA_CONFIG_DIR/ # shellcheck disable=SC2086 # $solana_drone should not be quoted exec $solana_drone \ diff --git a/multinode-demo/validator.sh b/multinode-demo/validator.sh index 5735895800a4f0..2c40c03a4c1afb 100755 --- a/multinode-demo/validator.sh +++ b/multinode-demo/validator.sh @@ -68,7 +68,7 @@ rsync_leader_url=$(rsync_url "$leader") set -ex SOLANA_LEADER_CONFIG_DIR="$SOLANA_CONFIG_DIR"/leader-config rm -rf "$SOLANA_LEADER_CONFIG_DIR" -rsync -vPrz "$rsync_leader_url"/config/ "$SOLANA_LEADER_CONFIG_DIR" +$rsync -vPrz "$rsync_leader_url"/config/ "$SOLANA_LEADER_CONFIG_DIR" ls -lh "$SOLANA_LEADER_CONFIG_DIR" # shellcheck disable=SC2086 # $program should not be quoted diff --git a/multinode-demo/wallet.sh b/multinode-demo/wallet.sh index 049abc5c9a7fc6..efab71fd065e8d 100755 --- a/multinode-demo/wallet.sh +++ b/multinode-demo/wallet.sh @@ -8,8 +8,8 @@ here=$(dirname "$0") source "$here"/common.sh SOLANA_CONFIG_DIR=config-client -# if $1 isn't host:path or some local path -if [[ ${1%:} != "$1" || -d $1 ]]; then +# if $1 isn't host:path, something.com, or a valid local path +if [[ ${1%:} != "$1" || "$1" =~ [^.].[^.] || -d $1 ]]; then leader=$1 # interpret shift else @@ -21,7 +21,7 @@ rsync_leader_url=$(rsync_url "$leader") set -e mkdir -p $SOLANA_CONFIG_DIR if [[ ! -r $SOLANA_CONFIG_DIR/leader.json ]]; then - rsync -vPz "$rsync_leader_url"/config/leader.json $SOLANA_CONFIG_DIR/ + $rsync -vPz "$rsync_leader_url"/config/leader.json $SOLANA_CONFIG_DIR/ fi client_json=$SOLANA_CONFIG_DIR/client.json diff --git a/src/bin/wallet.rs b/src/bin/wallet.rs index d290de898373e8..0afc2689f5cbca 100644 --- a/src/bin/wallet.rs +++ b/src/bin/wallet.rs @@ -35,6 +35,7 @@ enum WalletCommand { #[derive(Debug, Clone)] enum WalletError { CommandNotRecognized(String), + BadParameter(String), } impl fmt::Display for WalletError { @@ -173,6 +174,11 @@ fn parse_args() -> Result> { let pubkey_vec = bs58::decode(pay_matches.value_of("to").unwrap()) .into_vec() .expect("base58-encoded public key"); + + if pubkey_vec.len() != std::mem::size_of::() { + display_actions(); + Err(WalletError::BadParameter("Invalid public key".to_string()))?; + } to = PublicKey::clone_from_slice(&pubkey_vec); } else { to = id.pubkey(); @@ -187,8 +193,14 @@ fn parse_args() -> Result> { let sig_vec = bs58::decode(confirm_matches.value_of("signature").unwrap()) .into_vec() .expect("base58-encoded signature"); - let sig = Signature::clone_from_slice(&sig_vec); - Ok(WalletCommand::Confirm(sig)) + + if sig_vec.len() == std::mem::size_of::() { + let sig = Signature::clone_from_slice(&sig_vec); + Ok(WalletCommand::Confirm(sig)) + } else { + display_actions(); + Err(WalletError::BadParameter("Invalid signature".to_string())) + } } ("balance", Some(_balance_matches)) => Ok(WalletCommand::Balance), ("address", Some(_address_matches)) => Ok(WalletCommand::Address), @@ -238,7 +250,7 @@ fn process_command( WalletCommand::AirDrop(tokens) => { println!("Airdrop requested..."); println!("Airdropping {:?} tokens", tokens); - let _airdrop = request_airdrop(&config.drone_addr, &config.id, tokens as u64); + let _airdrop = request_airdrop(&config.drone_addr, &config.id, tokens as u64)?; // TODO: return airdrop Result from Drone sleep(Duration::from_millis(100)); println!( @@ -301,8 +313,12 @@ fn mk_client(r: &ReplicatedData) -> io::Result { )) } -fn request_airdrop(drone_addr: &SocketAddr, id: &Mint, tokens: u64) { - let mut stream = TcpStream::connect(drone_addr).unwrap(); +fn request_airdrop( + drone_addr: &SocketAddr, + id: &Mint, + tokens: u64, +) -> Result<(), Box> { + let mut stream = TcpStream::connect(drone_addr)?; let req = DroneRequest::GetAirdrop { airdrop_request_amount: tokens, client_public_key: id.pubkey(), @@ -310,6 +326,7 @@ fn request_airdrop(drone_addr: &SocketAddr, id: &Mint, tokens: u64) { let tx = serialize(&req).expect("serialize drone request"); stream.write_all(&tx).unwrap(); // TODO: add timeout to this function, in case of unresponsive drone + Ok(()) } fn main() -> Result<(), Box> {