Bump to Rust 1.58

This commit is contained in:
Thomas Eizinger 2022-02-07 09:38:07 +11:00
parent 50ae541412
commit 641274019d
No known key found for this signature in database
GPG key ID: 651AC83A6C6C8B96
18 changed files with 29 additions and 62 deletions

View file

@ -13,7 +13,7 @@ pub const MONEROD_DEFAULT_NETWORK: &str = "monero_network";
/// this doesn't matter. /// this doesn't matter.
pub const RPC_PORT: u16 = 18081; pub const RPC_PORT: u16 = 18081;
#[derive(Debug)] #[derive(Default, Debug)]
pub struct Monerod { pub struct Monerod {
args: MonerodArgs, args: MonerodArgs,
} }
@ -58,15 +58,7 @@ impl Image for Monerod {
} }
} }
impl Default for Monerod { #[derive(Default, Debug)]
fn default() -> Self {
Self {
args: MonerodArgs::default(),
}
}
}
#[derive(Debug)]
pub struct MoneroWalletRpc { pub struct MoneroWalletRpc {
args: MoneroWalletRpcArgs, args: MoneroWalletRpcArgs,
} }
@ -111,14 +103,6 @@ impl Image for MoneroWalletRpc {
} }
} }
impl Default for MoneroWalletRpc {
fn default() -> Self {
Self {
args: MoneroWalletRpcArgs::default(),
}
}
}
impl MoneroWalletRpc { impl MoneroWalletRpc {
pub fn new(name: &str, daemon_address: String) -> Self { pub fn new(name: &str, daemon_address: String) -> Self {
Self { Self {

View file

@ -71,7 +71,7 @@ impl<'c> Monero {
let miner = "miner"; let miner = "miner";
tracing::info!("Starting miner wallet: {}", miner); tracing::info!("Starting miner wallet: {}", miner);
let (miner_wallet, miner_container) = let (miner_wallet, miner_container) =
MoneroWalletRpc::new(cli, &miner, &monerod, prefix.clone()).await?; MoneroWalletRpc::new(cli, miner, &monerod, prefix.clone()).await?;
wallets.push(miner_wallet); wallets.push(miner_wallet);
containers.push(miner_container); containers.push(miner_container);
@ -83,7 +83,7 @@ impl<'c> Monero {
// trying for 5 minutes // trying for 5 minutes
let (wallet, container) = tokio::time::timeout(Duration::from_secs(300), async { let (wallet, container) = tokio::time::timeout(Duration::from_secs(300), async {
loop { loop {
let result = MoneroWalletRpc::new(cli, &wallet, &monerod, prefix.clone()).await; let result = MoneroWalletRpc::new(cli, wallet, &monerod, prefix.clone()).await;
match result { match result {
Ok(tuple) => { return tuple; } Ok(tuple) => { return tuple; }
@ -188,7 +188,6 @@ fn random_prefix() -> String {
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
pub struct Monerod { pub struct Monerod {
rpc_port: u16,
name: String, name: String,
network: String, network: String,
client: monerod::Client, client: monerod::Client,
@ -196,9 +195,7 @@ pub struct Monerod {
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
pub struct MoneroWalletRpc { pub struct MoneroWalletRpc {
rpc_port: u16,
name: String, name: String,
network: String,
client: wallet::Client, client: wallet::Client,
} }
@ -220,7 +217,6 @@ impl<'c> Monerod {
Ok(( Ok((
Self { Self {
rpc_port: monerod_rpc_port,
name, name,
network, network,
client: monerod::Client::localhost(monerod_rpc_port)?, client: monerod::Client::localhost(monerod_rpc_port)?,
@ -252,7 +248,7 @@ impl<'c> MoneroWalletRpc {
prefix: String, prefix: String,
) -> Result<(Self, Container<'c, Cli, image::MoneroWalletRpc>)> { ) -> Result<(Self, Container<'c, Cli, image::MoneroWalletRpc>)> {
let daemon_address = format!("{}:{}", monerod.name, RPC_PORT); let daemon_address = format!("{}:{}", monerod.name, RPC_PORT);
let image = image::MoneroWalletRpc::new(&name, daemon_address); let image = image::MoneroWalletRpc::new(name, daemon_address);
let network = monerod.network.clone(); let network = monerod.network.clone();
let run_args = RunArgs::default() let run_args = RunArgs::default()
@ -272,9 +268,7 @@ impl<'c> MoneroWalletRpc {
Ok(( Ok((
Self { Self {
rpc_port: wallet_rpc_port,
name: name.to_string(), name: name.to_string(),
network,
client, client,
}, },
container, container,

View file

@ -184,12 +184,7 @@ pub struct Refreshed {
#[derive(Debug, Clone, Deserialize)] #[derive(Debug, Clone, Deserialize)]
pub struct SweepAll { pub struct SweepAll {
amount_list: Vec<u64>,
fee_list: Vec<u64>,
multisig_txset: String,
pub tx_hash_list: Vec<String>, pub tx_hash_list: Vec<String>,
unsigned_txset: String,
weight_list: Vec<u32>,
} }
#[derive(Debug, Copy, Clone, Deserialize)] #[derive(Debug, Copy, Clone, Deserialize)]
@ -244,7 +239,7 @@ mod tests {
} }
}"#; }"#;
let _: Response<SweepAll> = serde_json::from_str(&response).unwrap(); let _: Response<SweepAll> = serde_json::from_str(response).unwrap();
} }
#[test] #[test]
@ -256,6 +251,6 @@ mod tests {
} }
}"#; }"#;
let _: Response<WalletCreated> = serde_json::from_str(&response).unwrap(); let _: Response<WalletCreated> = serde_json::from_str(response).unwrap();
} }
} }

View file

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

View file

@ -95,7 +95,7 @@ async fn main() -> Result<()> {
tracing::debug!(peer_id = %swarm.local_peer_id(), "Network layer initialized"); tracing::debug!(peer_id = %swarm.local_peer_id(), "Network layer initialized");
let (event_loop, mut event_loop_handle) = let (event_loop, mut event_loop_handle) =
EventLoop::new(swap_id, swarm, seller_peer_id, env_config)?; EventLoop::new(swap_id, swarm, seller_peer_id)?;
let event_loop = tokio::spawn(event_loop.run()); let event_loop = tokio::spawn(event_loop.run());
let max_givable = || bitcoin_wallet.max_giveable(TxLock::script_size()); let max_givable = || bitcoin_wallet.max_giveable(TxLock::script_size());
@ -268,7 +268,7 @@ async fn main() -> Result<()> {
} }
let (event_loop, event_loop_handle) = let (event_loop, event_loop_handle) =
EventLoop::new(swap_id, swarm, seller_peer_id, env_config)?; EventLoop::new(swap_id, swarm, seller_peer_id)?;
let handle = tokio::spawn(event_loop.run()); let handle = tokio::spawn(event_loop.run());
let monero_receive_address = db.get_monero_address(swap_id).await?; let monero_receive_address = db.get_monero_address(swap_id).await?;

View file

@ -171,7 +171,7 @@ pub fn verify_sig(
) -> Result<()> { ) -> Result<()> {
let ecdsa = ECDSA::verify_only(); let ecdsa = ECDSA::verify_only();
if ecdsa.verify(&verification_key.0, &transaction_sighash.into_inner(), &sig) { if ecdsa.verify(&verification_key.0, &transaction_sighash.into_inner(), sig) {
Ok(()) Ok(())
} else { } else {
bail!(InvalidSignature) bail!(InvalidSignature)
@ -194,7 +194,7 @@ pub fn verify_encsig(
&verification_key.0, &verification_key.0,
&encryption_key.0, &encryption_key.0,
&digest.into_inner(), &digest.into_inner(),
&encsig, encsig,
) { ) {
Ok(()) Ok(())
} else { } else {

View file

@ -262,7 +262,7 @@ mod tests {
amount: Amount, amount: Amount,
) -> PartiallySignedTransaction { ) -> PartiallySignedTransaction {
let change = wallet.new_address().await.unwrap(); let change = wallet.new_address().await.unwrap();
TxLock::new(&wallet, amount, A, B, change) TxLock::new(wallet, amount, A, B, change)
.await .await
.unwrap() .unwrap()
.into() .into()

View file

@ -128,7 +128,7 @@ impl TxRedeem {
let sig = sigs let sig = sigs
.into_iter() .into_iter()
.find(|sig| verify_sig(&B, &self.digest(), &sig).is_ok()) .find(|sig| verify_sig(&B, &self.digest(), sig).is_ok())
.context("Neither signature on witness stack verifies against B")?; .context("Neither signature on witness stack verifies against B")?;
Ok(sig) Ok(sig)

View file

@ -132,7 +132,7 @@ impl TxRefund {
let sig = sigs let sig = sigs
.into_iter() .into_iter()
.find(|sig| verify_sig(&B, &self.digest(), &sig).is_ok()) .find(|sig| verify_sig(&B, &self.digest(), sig).is_ok())
.context("Neither signature on witness stack verifies against B")?; .context("Neither signature on witness stack verifies against B")?;
Ok(sig) Ok(sig)

View file

@ -38,6 +38,7 @@ pub struct Arguments {
} }
/// Represents the result of parsing the command-line parameters. /// Represents the result of parsing the command-line parameters.
#[allow(clippy::large_enum_variant)]
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq)]
pub enum ParseResult { pub enum ParseResult {
/// The arguments we were invoked in. /// The arguments we were invoked in.

View file

@ -4,7 +4,7 @@ use crate::network::encrypted_signature;
use crate::network::quote::BidQuote; use crate::network::quote::BidQuote;
use crate::network::swap_setup::bob::NewSwap; use crate::network::swap_setup::bob::NewSwap;
use crate::protocol::bob::State2; use crate::protocol::bob::State2;
use crate::{env, monero}; use crate::{monero};
use anyhow::{Context, Result}; use anyhow::{Context, Result};
use futures::future::{BoxFuture, OptionFuture}; use futures::future::{BoxFuture, OptionFuture};
use futures::{FutureExt, StreamExt}; use futures::{FutureExt, StreamExt};
@ -50,7 +50,6 @@ impl EventLoop {
swap_id: Uuid, swap_id: Uuid,
swarm: Swarm<Behaviour>, swarm: Swarm<Behaviour>,
alice_peer_id: PeerId, alice_peer_id: PeerId,
env_config: env::Config,
) -> Result<(Self, EventLoopHandle)> { ) -> Result<(Self, EventLoopHandle)> {
let execution_setup = bmrng::channel_with_timeout(1, Duration::from_secs(60)); let execution_setup = bmrng::channel_with_timeout(1, Duration::from_secs(60));
let transfer_proof = bmrng::channel_with_timeout(1, Duration::from_secs(60)); let transfer_proof = bmrng::channel_with_timeout(1, Duration::from_secs(60));
@ -75,8 +74,7 @@ impl EventLoop {
swap_setup: execution_setup.0, swap_setup: execution_setup.0,
transfer_proof: transfer_proof.1, transfer_proof: transfer_proof.1,
encrypted_signature: encrypted_signature.0, encrypted_signature: encrypted_signature.0,
quote: quote.0, quote: quote.0
env_config,
}; };
Ok((event_loop, handle)) Ok((event_loop, handle))
@ -220,7 +218,6 @@ pub struct EventLoopHandle {
transfer_proof: bmrng::RequestReceiver<monero::TransferProof, ()>, transfer_proof: bmrng::RequestReceiver<monero::TransferProof, ()>,
encrypted_signature: bmrng::RequestSender<EncryptedSignature, ()>, encrypted_signature: bmrng::RequestSender<EncryptedSignature, ()>,
quote: bmrng::RequestSender<(), BidQuote>, quote: bmrng::RequestSender<(), BidQuote>,
env_config: env::Config,
} }
impl EventLoopHandle { impl EventLoopHandle {

View file

@ -271,7 +271,7 @@ impl EventLoop {
QuoteStatus::Received(Status::Online(quote)) => { QuoteStatus::Received(Status::Online(quote)) => {
let address = self let address = self
.reachable_asb_address .reachable_asb_address
.get(&peer_id) .get(peer_id)
.expect("if we got a quote we must have stored an address"); .expect("if we got a quote we must have stored an address");
Ok(Seller { Ok(Seller {
@ -282,7 +282,7 @@ impl EventLoop {
QuoteStatus::Received(Status::Unreachable) => { QuoteStatus::Received(Status::Unreachable) => {
let address = self let address = self
.unreachable_asb_address .unreachable_asb_address
.get(&peer_id) .get(peer_id)
.expect("if we got a quote we must have stored an address"); .expect("if we got a quote we must have stored an address");
Ok(Seller { Ok(Seller {

View file

@ -138,7 +138,7 @@ mod monero_network {
Network::Stagenet => "stagenet", Network::Stagenet => "stagenet",
Network::Testnet => "testnet", Network::Testnet => "testnet",
}; };
s.serialize_str(&str) s.serialize_str(str)
} }
} }

View file

@ -274,9 +274,7 @@ mod wire {
#[derive(Debug, Deserialize)] #[derive(Debug, Deserialize)]
pub struct TickerData { pub struct TickerData {
#[serde(rename = "a")] #[serde(rename = "a")]
ask: Vec<RateElement>, ask: Vec<RateElement>
#[serde(rename = "b")]
bid: Vec<RateElement>,
} }
#[derive(Debug, Deserialize)] #[derive(Debug, Deserialize)]

View file

@ -6,7 +6,7 @@ pub mod ecdsa_fun {
use ::ecdsa_fun::fun::{Point, Scalar, G}; use ::ecdsa_fun::fun::{Point, Scalar, G};
pub fn point() -> impl Strategy<Value = Point> { pub fn point() -> impl Strategy<Value = Point> {
scalar().prop_map(|mut scalar| Point::from_scalar_mul(&G, &mut scalar).mark::<Normal>()) scalar().prop_map(|mut scalar| Point::from_scalar_mul(G, &mut scalar).mark::<Normal>())
} }
pub fn scalar() -> impl Strategy<Value = Scalar> { pub fn scalar() -> impl Strategy<Value = Scalar> {

View file

@ -29,7 +29,7 @@ impl Image for Bitcoind {
container container
.logs() .logs()
.stdout .stdout
.wait_for_message(&"init message: Done loading") .wait_for_message("init message: Done loading")
.unwrap(); .unwrap();
} }

View file

@ -14,7 +14,6 @@ pub struct Electrs {
entrypoint: Option<String>, entrypoint: Option<String>,
wait_for_message: String, wait_for_message: String,
volume: String, volume: String,
bitcoind_container_name: String,
} }
impl Image for Electrs { impl Image for Electrs {
@ -73,7 +72,6 @@ impl Default for Electrs {
entrypoint: Some("/build/electrs".into()), entrypoint: Some("/build/electrs".into()),
wait_for_message: "Running accept thread".to_string(), wait_for_message: "Running accept thread".to_string(),
volume: uuid::Uuid::new_v4().to_string(), volume: uuid::Uuid::new_v4().to_string(),
bitcoind_container_name: uuid::Uuid::new_v4().to_string(),
} }
} }
} }

View file

@ -146,14 +146,14 @@ async fn init_containers(cli: &Cli) -> (Monero, Containers<'_>) {
let prefix = random_prefix(); let prefix = random_prefix();
let bitcoind_name = format!("{}_{}", prefix, "bitcoind"); let bitcoind_name = format!("{}_{}", prefix, "bitcoind");
let (bitcoind, bitcoind_url) = let (bitcoind, bitcoind_url) =
init_bitcoind_container(&cli, prefix.clone(), bitcoind_name.clone(), prefix.clone()) init_bitcoind_container(cli, prefix.clone(), bitcoind_name.clone(), prefix.clone())
.await .await
.expect("could not init bitcoind"); .expect("could not init bitcoind");
let electrs = init_electrs_container(&cli, prefix.clone(), bitcoind_name, prefix) let electrs = init_electrs_container(cli, prefix.clone(), bitcoind_name, prefix)
.await .await
.expect("could not init electrs"); .expect("could not init electrs");
let (monero, monerod_container, monero_wallet_rpc_containers) = let (monero, monerod_container, monero_wallet_rpc_containers) =
Monero::new(&cli, vec![MONERO_WALLET_NAME_ALICE, MONERO_WALLET_NAME_BOB]) Monero::new(cli, vec![MONERO_WALLET_NAME_ALICE, MONERO_WALLET_NAME_BOB])
.await .await
.unwrap(); .unwrap();
@ -237,7 +237,7 @@ async fn start_alice(
let resume_only = false; let resume_only = false;
let mut swarm = swarm::asb( let mut swarm = swarm::asb(
&seed, seed,
min_buy, min_buy,
max_buy, max_buy,
latest_rate, latest_rate,
@ -485,7 +485,7 @@ impl BobParams {
.behaviour_mut() .behaviour_mut()
.add_address(self.alice_peer_id, self.alice_address.clone()); .add_address(self.alice_peer_id, self.alice_address.clone());
cli::EventLoop::new(swap_id, swarm, self.alice_peer_id, self.env_config) cli::EventLoop::new(swap_id, swarm, self.alice_peer_id)
} }
} }