576: Bump to Rust 1.53 r=thomaseizinger a=thomaseizinger



Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
This commit is contained in:
bors[bot] 2021-06-23 03:17:17 +00:00 committed by GitHub
commit 858c6d85ce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 72 additions and 108 deletions

View File

@ -1,4 +1,4 @@
[toolchain] [toolchain]
channel = "1.52" channel = "1.53"
components = ["clippy"] components = ["clippy"]
targets = ["armv7-unknown-linux-gnueabihf"] targets = ["armv7-unknown-linux-gnueabihf"]

View File

@ -55,11 +55,10 @@ where
env_config: env_config(is_testnet), env_config: env_config(is_testnet),
cmd: Command::Balance, cmd: Command::Balance,
}, },
RawCommand::ManualRecovery(manual_recovery) => match manual_recovery { RawCommand::ManualRecovery(ManualRecovery::Redeem {
ManualRecovery::Redeem {
redeem_params: RecoverCommandParams { swap_id, force }, redeem_params: RecoverCommandParams { swap_id, force },
do_not_await_finality, do_not_await_finality,
} => Arguments { }) => Arguments {
testnet: is_testnet, testnet: is_testnet,
json: is_json, json: is_json,
config_path: config_path(config, is_testnet)?, config_path: config_path(config, is_testnet)?,
@ -70,41 +69,40 @@ where
do_not_await_finality, do_not_await_finality,
}, },
}, },
ManualRecovery::Cancel { RawCommand::ManualRecovery(ManualRecovery::Cancel {
cancel_params: RecoverCommandParams { swap_id, force }, cancel_params: RecoverCommandParams { swap_id, force },
} => Arguments { }) => Arguments {
testnet: is_testnet, testnet: is_testnet,
json: is_json, json: is_json,
config_path: config_path(config, is_testnet)?, config_path: config_path(config, is_testnet)?,
env_config: env_config(is_testnet), env_config: env_config(is_testnet),
cmd: Command::Cancel { swap_id, force }, cmd: Command::Cancel { swap_id, force },
}, },
ManualRecovery::Refund { RawCommand::ManualRecovery(ManualRecovery::Refund {
refund_params: RecoverCommandParams { swap_id, force }, refund_params: RecoverCommandParams { swap_id, force },
} => Arguments { }) => Arguments {
testnet: is_testnet, testnet: is_testnet,
json: is_json, json: is_json,
config_path: config_path(config, is_testnet)?, config_path: config_path(config, is_testnet)?,
env_config: env_config(is_testnet), env_config: env_config(is_testnet),
cmd: Command::Refund { swap_id, force }, cmd: Command::Refund { swap_id, force },
}, },
ManualRecovery::Punish { RawCommand::ManualRecovery(ManualRecovery::Punish {
punish_params: RecoverCommandParams { swap_id, force }, punish_params: RecoverCommandParams { swap_id, force },
} => Arguments { }) => Arguments {
testnet: is_testnet, testnet: is_testnet,
json: is_json, json: is_json,
config_path: config_path(config, is_testnet)?, config_path: config_path(config, is_testnet)?,
env_config: env_config(is_testnet), env_config: env_config(is_testnet),
cmd: Command::Punish { swap_id, force }, cmd: Command::Punish { swap_id, force },
}, },
ManualRecovery::SafelyAbort { swap_id } => Arguments { RawCommand::ManualRecovery(ManualRecovery::SafelyAbort { swap_id }) => Arguments {
testnet: is_testnet, testnet: is_testnet,
json: is_json, json: is_json,
config_path: config_path(config, is_testnet)?, config_path: config_path(config, is_testnet)?,
env_config: env_config(is_testnet), env_config: env_config(is_testnet),
cmd: Command::SafelyAbort { swap_id }, cmd: Command::SafelyAbort { swap_id },
}, },
},
}; };
Ok(arguments) Ok(arguments)

View File

@ -343,7 +343,7 @@ async fn determine_btc_to_swap<FB, TB, FMG, TMG, FS, TS>(
bid_quote: impl Future<Output = Result<BidQuote>>, bid_quote: impl Future<Output = Result<BidQuote>>,
get_new_address: impl Future<Output = Result<bitcoin::Address>>, get_new_address: impl Future<Output = Result<bitcoin::Address>>,
balance: FB, balance: FB,
max_giveable: FMG, max_giveable_fn: FMG,
sync: FS, sync: FS,
) -> Result<(bitcoin::Amount, bitcoin::Amount)> ) -> Result<(bitcoin::Amount, bitcoin::Amount)>
where where
@ -363,11 +363,9 @@ where
"Received quote: 1 XMR ~ ", "Received quote: 1 XMR ~ ",
); );
let mut current_maximum_giveable = max_giveable().await?; let mut max_giveable = max_giveable_fn().await?;
let max_giveable = if current_maximum_giveable == bitcoin::Amount::ZERO if max_giveable == bitcoin::Amount::ZERO || max_giveable < bid_quote.min_quantity {
|| current_maximum_giveable < bid_quote.min_quantity
{
let deposit_address = get_new_address.await?; let deposit_address = get_new_address.await?;
let minimum_amount = bid_quote.min_quantity; let minimum_amount = bid_quote.min_quantity;
let maximum_amount = bid_quote.max_quantity; let maximum_amount = bid_quote.max_quantity;
@ -378,7 +376,7 @@ where
info!( info!(
%deposit_address, %deposit_address,
%current_maximum_giveable, %max_giveable,
%minimum_amount, %minimum_amount,
%maximum_amount, %maximum_amount,
"Please deposit BTC you want to swap to", "Please deposit BTC you want to swap to",
@ -387,19 +385,19 @@ where
loop { loop {
sync().await?; sync().await?;
let new_max_givable = max_giveable().await?; let new_max_givable = max_giveable_fn().await?;
if new_max_givable != current_maximum_giveable { if new_max_givable != max_giveable {
current_maximum_giveable = new_max_givable; max_giveable = new_max_givable;
let new_balance = balance().await?; let new_balance = balance().await?;
tracing::info!( tracing::info!(
%new_balance, %new_balance,
%current_maximum_giveable, %max_giveable,
"Received BTC", "Received BTC",
); );
if current_maximum_giveable >= bid_quote.min_quantity { if max_giveable >= bid_quote.min_quantity {
break; break;
} else { } else {
tracing::info!( tracing::info!(
@ -412,10 +410,6 @@ where
tokio::time::sleep(Duration::from_secs(1)).await; tokio::time::sleep(Duration::from_secs(1)).await;
} }
current_maximum_giveable
} else {
current_maximum_giveable
}; };
let balance = balance().await?; let balance = balance().await?;

View File

@ -55,12 +55,7 @@ where
Ok(matches) => RawArguments::from_clap(&matches), Ok(matches) => RawArguments::from_clap(&matches),
Err(clap::Error { Err(clap::Error {
message, message,
kind: clap::ErrorKind::HelpDisplayed, kind: clap::ErrorKind::HelpDisplayed | clap::ErrorKind::VersionDisplayed,
..
})
| Err(clap::Error {
message,
kind: clap::ErrorKind::VersionDisplayed,
.. ..
}) => return Ok(ParseResult::PrintAndExitZero { message }), }) => return Ok(ParseResult::PrintAndExitZero { message }),
Err(e) => anyhow::bail!(e), Err(e) => anyhow::bail!(e),

View File

@ -77,14 +77,12 @@ fn fmt_as_address_string(multi: Multiaddr) -> Result<String, TransportError<io::
// Deal with non-onion addresses // Deal with non-onion addresses
Some(Protocol::Ip4(addr)) => format!("{}", addr), Some(Protocol::Ip4(addr)) => format!("{}", addr),
Some(Protocol::Ip6(addr)) => format!("{}", addr), Some(Protocol::Ip6(addr)) => format!("{}", addr),
Some(Protocol::Dns(addr)) => format!("{}", addr), Some(Protocol::Dns(addr) | Protocol::Dns4(addr)) => format!("{}", addr),
Some(Protocol::Dns4(addr)) => format!("{}", addr),
_ => return Err(TransportError::MultiaddrNotSupported(multi)), _ => return Err(TransportError::MultiaddrNotSupported(multi)),
}; };
let port = match protocols.next() { let port = match protocols.next() {
Some(Protocol::Tcp(port)) => port, Some(Protocol::Tcp(port) | Protocol::Udp(port)) => port,
Some(Protocol::Udp(port)) => port,
_ => return Err(TransportError::MultiaddrNotSupported(multi)), _ => return Err(TransportError::MultiaddrNotSupported(multi)),
}; };

View File

@ -3,7 +3,6 @@ use crate::database::Database;
use crate::env::Config; use crate::env::Config;
use crate::network::quote::BidQuote; use crate::network::quote::BidQuote;
use crate::network::transfer_proof; use crate::network::transfer_proof;
use crate::protocol::alice::spot_price::Error;
use crate::protocol::alice::{AliceState, Behaviour, OutEvent, State0, State3, Swap}; use crate::protocol::alice::{AliceState, Behaviour, OutEvent, State0, State3, Swap};
use crate::{bitcoin, kraken, monero}; use crate::{bitcoin, kraken, monero};
use anyhow::{Context, Result}; use anyhow::{Context, Result};
@ -208,20 +207,8 @@ where
self.swarm.behaviour_mut().execution_setup.run(peer, state0); self.swarm.behaviour_mut().execution_setup.run(peer, state0);
} }
SwarmEvent::Behaviour(OutEvent::SwapRequestDeclined { peer, error }) => { SwarmEvent::Behaviour(OutEvent::SwapRequestDeclined { peer, error }) => {
match error {
Error::ResumeOnlyMode
| Error::AmountBelowMinimum { .. }
| Error::AmountAboveMaximum { .. }
| Error::BlockchainNetworkMismatch { .. } => {
tracing::warn!(%peer, "Ignoring spot price request because: {}", error); tracing::warn!(%peer, "Ignoring spot price request because: {}", error);
} }
Error::BalanceTooLow { .. }
| Error::LatestRateFetchFailed(_)
| Error::SellQuoteCalculationFailed(_) => {
tracing::error!(%peer, "Ignoring spot price request because: {}", error);
}
}
}
SwarmEvent::Behaviour(OutEvent::QuoteRequested { channel, peer }) => { SwarmEvent::Behaviour(OutEvent::QuoteRequested { channel, peer }) => {
// TODO: Move the spot-price update into dedicated update stream to decouple it from quote requests // TODO: Move the spot-price update into dedicated update stream to decouple it from quote requests
let current_balance = self.monero_wallet.get_balance().await; let current_balance = self.monero_wallet.get_balance().await;
@ -324,16 +311,12 @@ where
SwarmEvent::IncomingConnectionError { send_back_addr: address, error, .. } => { SwarmEvent::IncomingConnectionError { send_back_addr: address, error, .. } => {
tracing::warn!(%address, "Failed to set up connection with peer. Error {:#}", error); tracing::warn!(%address, "Failed to set up connection with peer. Error {:#}", error);
} }
SwarmEvent::ConnectionClosed { peer_id: peer, num_established, endpoint, cause } if num_established == 0 => { SwarmEvent::ConnectionClosed { peer_id: peer, num_established, endpoint, cause: Some(error) } if num_established == 0 => {
match cause {
Some(error) => {
tracing::warn!(%peer, address = %endpoint.get_remote_address(), "Lost connection. Error {:#}", error); tracing::warn!(%peer, address = %endpoint.get_remote_address(), "Lost connection. Error {:#}", error);
}, }
None => { SwarmEvent::ConnectionClosed { peer_id: peer, num_established, endpoint, cause: None } if num_established == 0 => {
tracing::info!(%peer, address = %endpoint.get_remote_address(), "Successfully closed connection"); tracing::info!(%peer, address = %endpoint.get_remote_address(), "Successfully closed connection");
} }
}
}
SwarmEvent::NewListenAddr(address) => { SwarmEvent::NewListenAddr(address) => {
tracing::info!(%address, "New listen address detected"); tracing::info!(%address, "New listen address detected");
} }

View File

@ -176,18 +176,14 @@ impl EventLoop {
SwarmEvent::Dialing(peer_id) if peer_id == self.alice_peer_id => { SwarmEvent::Dialing(peer_id) if peer_id == self.alice_peer_id => {
tracing::debug!("Dialling Alice at {}", peer_id); tracing::debug!("Dialling Alice at {}", peer_id);
} }
SwarmEvent::ConnectionClosed { peer_id, endpoint, num_established, cause } if peer_id == self.alice_peer_id && num_established == 0 => { SwarmEvent::ConnectionClosed { peer_id, endpoint, num_established, cause: Some(error) } if peer_id == self.alice_peer_id && num_established == 0 => {
match cause {
Some(error) => {
tracing::warn!("Lost connection to Alice at {}, cause: {}", endpoint.get_remote_address(), error); tracing::warn!("Lost connection to Alice at {}, cause: {}", endpoint.get_remote_address(), error);
}, }
None => { SwarmEvent::ConnectionClosed { peer_id, num_established, cause: None, .. } if peer_id == self.alice_peer_id && num_established == 0 => {
// no error means the disconnection was requested // no error means the disconnection was requested
tracing::info!("Successfully closed connection to Alice"); tracing::info!("Successfully closed connection to Alice");
return; return;
} }
}
}
SwarmEvent::UnreachableAddr { peer_id, address, attempts_remaining, error } if peer_id == self.alice_peer_id && attempts_remaining == 0 => { SwarmEvent::UnreachableAddr { peer_id, address, attempts_remaining, error } if peer_id == self.alice_peer_id && attempts_remaining == 0 => {
tracing::warn!(%address, "Failed to dial Alice: {}", error); tracing::warn!(%address, "Failed to dial Alice: {}", error);

View File

@ -157,7 +157,7 @@ impl State0 {
let valid = CROSS_CURVE_PROOF_SYSTEM.verify( let valid = CROSS_CURVE_PROOF_SYSTEM.verify(
&msg.dleq_proof_s_a, &msg.dleq_proof_s_a,
( (
msg.S_a_bitcoin.clone().into(), msg.S_a_bitcoin.into(),
msg.S_a_monero msg.S_a_monero
.point .point
.decompress() .decompress()