From 0a7a27327e5653d945042b28ed7a9152533852d9 Mon Sep 17 00:00:00 2001 From: Byron Hambly Date: Tue, 9 Aug 2022 12:36:18 +0200 Subject: [PATCH 1/3] feat: upgrade to monero 0.18 --- CHANGELOG.md | 2 +- monero-harness/src/image.rs | 4 ++-- monero-harness/src/lib.rs | 5 +++-- swap/src/monero/wallet_rpc.rs | 13 ++++++++----- 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 24cd669d..fc3d0395 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,8 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed +- Update from Monero v0.17.2.0 to Monero v0.18.0.0 - Change Monero nodes to [Rino tool nodes](https://community.rino.io/nodes.html) -- Update from monero v17.2.0 to monero v17.3.0 - Always write logs as JSON to files - Change to UTC time for log messages, due to a bug causing no logging at all to be printed (linux/macos), and an [unsoundness issue](https://docs.rs/tracing-subscriber/latest/tracing_subscriber/fmt/time/struct.LocalTime.html) with local time in [the time crate](https://github.com/time-rs/time/issues/293#issuecomment-748151025) - Fix potential integer overflow in ASB when calculating maximum Bitcoin amount for Monero balance diff --git a/monero-harness/src/image.rs b/monero-harness/src/image.rs index 20370288..1b8fc422 100644 --- a/monero-harness/src/image.rs +++ b/monero-harness/src/image.rs @@ -25,7 +25,7 @@ impl Image for Monerod { type EntryPoint = str; fn descriptor(&self) -> String { - "rinocommunity/monero:v0.17.2.0".to_owned() + "rinocommunity/monero:v0.18.0.0".to_owned() } fn wait_until_ready(&self, container: &Container<'_, D, Self>) { @@ -70,7 +70,7 @@ impl Image for MoneroWalletRpc { type EntryPoint = str; fn descriptor(&self) -> String { - "rinocommunity/monero:v0.17.2.0".to_owned() + "rinocommunity/monero:v0.18.0.0".to_owned() } fn wait_until_ready(&self, container: &Container<'_, D, Self>) { diff --git a/monero-harness/src/lib.rs b/monero-harness/src/lib.rs index 0267c754..bdcfc206 100644 --- a/monero-harness/src/lib.rs +++ b/monero-harness/src/lib.rs @@ -117,11 +117,12 @@ impl<'c> Monero { let miner_wallet = self.wallet("miner")?; let miner_address = miner_wallet.address().await?.address; - // generate the first 70 as bulk + // generate the first 120 as bulk + let amount_of_blocks = 120; let monerod = &self.monerod; let res = monerod .client() - .generateblocks(70, miner_address.clone()) + .generateblocks(amount_of_blocks, miner_address.clone()) .await?; tracing::info!("Generated {:?} blocks", res.blocks.len()); miner_wallet.refresh().await?; diff --git a/swap/src/monero/wallet_rpc.rs b/swap/src/monero/wallet_rpc.rs index f3fbec90..7b391288 100644 --- a/swap/src/monero/wallet_rpc.rs +++ b/swap/src/monero/wallet_rpc.rs @@ -17,18 +17,21 @@ use tokio_util::io::StreamReader; #[cfg(not(any(target_os = "macos", target_os = "linux", target_os = "windows")))] compile_error!("unsupported operating system"); -#[cfg(target_os = "macos")] -const DOWNLOAD_URL: &str = "http://downloads.getmonero.org/cli/monero-mac-x64-v0.17.3.0.tar.bz2"; +#[cfg(all(target_os = "macos", target_arch = "x86_64"))] +const DOWNLOAD_URL: &str = "http://downloads.getmonero.org/cli/monero-mac-x64-v0.18.0.0.tar.bz2"; + +#[cfg(all(target_os = "macos", target_arch = "arm"))] +const DOWNLOAD_URL: &str = "https://downloads.getmonero.org/cli/monero-mac-armv8-v0.18.0.0.tar.bz2"; #[cfg(all(target_os = "linux", target_arch = "x86_64"))] -const DOWNLOAD_URL: &str = "https://downloads.getmonero.org/cli/monero-linux-x64-v0.17.3.0.tar.bz2"; +const DOWNLOAD_URL: &str = "https://downloads.getmonero.org/cli/monero-linux-x64-v0.18.0.0.tar.bz2"; #[cfg(all(target_os = "linux", target_arch = "arm"))] const DOWNLOAD_URL: &str = - "https://downloads.getmonero.org/cli/monero-linux-armv7-v0.17.3.0.tar.bz2"; + "https://downloads.getmonero.org/cli/monero-linux-armv7-v0.18.0.0.tar.bz2"; #[cfg(target_os = "windows")] -const DOWNLOAD_URL: &str = "https://downloads.getmonero.org/cli/monero-win-x64-v0.17.3.0.zip"; +const DOWNLOAD_URL: &str = "https://downloads.getmonero.org/cli/monero-win-x64-v0.18.0.0.zip"; #[cfg(any(target_os = "macos", target_os = "linux"))] const PACKED_FILE: &str = "monero-wallet-rpc"; From 249e97826f122e7f6cb4c45205ea68d3144f600d Mon Sep 17 00:00:00 2001 From: Byron Hambly Date: Wed, 10 Aug 2022 21:19:08 +0200 Subject: [PATCH 2/3] feat: check swap cli wallet rpc version and remove if not fluorine fermi - swap cli will check its wallet rpc version and delete the binary if its version does not match on "Fluorine Fermi". it will then download the newer version. - adds download progress for wallet rpc --- CHANGELOG.md | 2 +- swap/src/monero/wallet_rpc.rs | 32 +++++++++++++++++++++++++++++++- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fc3d0395..24036bf3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,9 +21,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Adjust quote based on Bitcoin balance. If the max_buy_btc in the ASB config is higher than the available balance to trade, it will return the max available balance discounting the Monero locking fees. In the case the balance is lower than the min_buy_btc config it will return 0 to the CLI. If the ASB returns a quote of 0 the CLI will not allow you continue with a trade. - Reduce required confirmations for Bitcoin transactions from 2 to 1 -- Update from monero v17.2.0 to monero v17.3.0 - Both the ASB and CLI now support the [Identify](https://github.com/libp2p/specs/blob/master/identify/README.md) protocol. This makes its version and network (testnet/mainnet) avaliable to others - Display minimum BTC deposit required to cover the minimum quantity plus fee in the Swap CLI +- Swap CLI will check its monero-wallet-rpc version and remove it if it's older than Fluorine Fermi (0.18) ## [0.10.2] - 2021-12-25 diff --git a/swap/src/monero/wallet_rpc.rs b/swap/src/monero/wallet_rpc.rs index 7b391288..6c398cf4 100644 --- a/swap/src/monero/wallet_rpc.rs +++ b/swap/src/monero/wallet_rpc.rs @@ -39,6 +39,8 @@ const PACKED_FILE: &str = "monero-wallet-rpc"; #[cfg(target_os = "windows")] const PACKED_FILE: &str = "monero-wallet-rpc.exe"; +const CODENAME: &str = "Fluorine Fermi"; + #[derive(Debug, Clone, Copy, thiserror::Error)] #[error("monero wallet rpc executable not found in downloaded archive")] pub struct ExecutableNotFoundInArchive; @@ -75,6 +77,22 @@ impl WalletRpc { remove_file(monero_wallet_rpc.archive_path()).await?; } + // check the monero-wallet-rpc version + let exec_path = monero_wallet_rpc.exec_path(); + tracing::debug!("exec path: {}", exec_path.display()); + + if exec_path.exists() { + let output = Command::new(&exec_path).arg("--version").output().await?; + let version = String::from_utf8_lossy(&output.stdout); + tracing::debug!("RPC version output: {}", version); + + if !version.contains(CODENAME) { + tracing::info!("Removing old version of monero-wallet-rpc"); + tokio::fs::remove_file(exec_path).await?; + } + } + + // if monero-wallet-rpc doesn't exist then download it if !monero_wallet_rpc.exec_path().exists() { let mut options = OpenOptions::new(); let mut file = options @@ -112,12 +130,24 @@ impl WalletRpc { let mut stream = FramedRead::new(StreamReader::new(byte_stream), BytesCodec::new()) .map_ok(|bytes| bytes.freeze()); + let (mut received, mut notified) = (0, 0); while let Some(chunk) = stream.next().await { - file.write(&chunk?).await?; + let bytes = chunk?; + received += bytes.len(); + // the stream is decompressed as it is downloaded + // file is compressed approx 3:1 in bz format + let total = 3 * content_length; + let percent = 100 * received as u64 / total; + if percent != notified && percent % 10 == 0 { + tracing::debug!("{}%", percent); + notified = percent; + } + file.write(&bytes).await?; } file.flush().await?; + tracing::debug!("Extracting archive"); Self::extract_archive(&monero_wallet_rpc).await?; } Ok(monero_wallet_rpc) From bf23eee0cba0459373867cf12d126667df008111 Mon Sep 17 00:00:00 2001 From: Byron Hambly Date: Thu, 11 Aug 2022 13:05:21 +0200 Subject: [PATCH 3/3] docs: add gpg key readme and delta1.asc --- swap/src/monero/wallet_rpc.rs | 2 +- utils/gpg_keys/delta1.asc | 41 +++++++++++++++++++++++++++++++++++ utils/gpg_keys/readme.md | 21 ++++++++++++++++++ 3 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 utils/gpg_keys/delta1.asc create mode 100644 utils/gpg_keys/readme.md diff --git a/swap/src/monero/wallet_rpc.rs b/swap/src/monero/wallet_rpc.rs index 6c398cf4..8466a36b 100644 --- a/swap/src/monero/wallet_rpc.rs +++ b/swap/src/monero/wallet_rpc.rs @@ -79,7 +79,7 @@ impl WalletRpc { // check the monero-wallet-rpc version let exec_path = monero_wallet_rpc.exec_path(); - tracing::debug!("exec path: {}", exec_path.display()); + tracing::debug!("RPC exec path: {}", exec_path.display()); if exec_path.exists() { let output = Command::new(&exec_path).arg("--version").output().await?; diff --git a/utils/gpg_keys/delta1.asc b/utils/gpg_keys/delta1.asc new file mode 100644 index 00000000..a50043fe --- /dev/null +++ b/utils/gpg_keys/delta1.asc @@ -0,0 +1,41 @@ +-----BEGIN PGP PUBLIC KEY BLOCK----- + +mQGNBGJErX8BDACmu7qbNe7k1/b0VtExFbZNXYJRNV02J9O5fvBHCM24ZhAn+ETF +FwxyN8A2HqtQNKGbQAlX4L9XiBUmy98AamWamypUki2Mc6ldrn1NLQI2dsd3/MyJ +fo0h3MrbNwmCDsEg2Y8pJfde4OJdqWNH5v1oPTvAgcN/eljk8H+RPYUpLAiR/jDG +1hVaet8QSm7w8IUDvZX2q3gYO0bYAgegze+pxZe2rZirhZYO9zV7tML4Oj0R8422 +RnDTbG1e0Gjk9LBH7bEB7+cSRY7FIW8iRL/tVxZqQLLEIY3R3X+RPgGBEI9RbvIO +nIlnKSr+7Kz490mDfd+wlXZ6vaPgc8UTgyy/jkfQIBgL6Yv2nNEok1kv7ubIzo87 +4UQ75YqJVuHPpLRU/W5oLsQK7mao+4vsE60CqOlWx73BGjxG0CD1yKDphd47oXJ+ +9KpmEGfhb/H6kGsJV4CItK6MfghCBEVCQ3Adyf4loK20uQ7+rs9Ixx57Z5Q0bm9B +sAGcDtEVzQGQ36EAEQEAAbQmQnlyb24gSGFtYmx5IDxiaGFtYmx5QGJsb2Nrc3Ry +ZWFtLmNvbT6JAc4EEwEKADgWIQRxDkTC2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GfWMDI5el1pO2SWN9TXW3VN5KZI7CYxN3N0iJAtACtXRjsQa4dhLLCt +dbrNRwARAQABiQG2BBgBCgAgFiEEcQ5Ewtquk493h0Sh3o9uogpmFpcFAmJErX8C +GwwACgkQ3o9uogpmFpflXAv8CYtgryhT9z5HcRtRn27GmWtJbNuP9NIenicvhu/Y +wlMigUEqvTrK9h5SsFHsTggInmt4seJ3ZO2jmfGg9GJeH63K5A+slghMCv9uQhTl +1r2fqLzMXFB2Jz7EkLHT6nSzW5/F/gxavLpnhBTkOkZaC74RRJvG3I+twltsN6S9 +Ufo3PUCaRtdrxqemYeT3IOyn2cq3t3JWXrsog8rwT/yqXYyqEwzT2dcksY8+bxx6 +3EYb94dVuSiZ79vOTpFSWzQECRt7pN2hOpAjPzHKqWFhWROxo2Jg0wYhJgFpaIkm +rrcsDI3AOs46iIpsBFjAg2WLj0wPPyquHHXKSDKPCOJWPTHj4VsjfYOFCNu1YDI0 +AUdRjvM/RdTODJ6qRqj0u7dRrrYc7epxmh41ESAZP8vkBw7csRR3FcLBxV3rpm5K +gJvodtCMBBKNGGI9KrvwVb56rJfiGZwgxsUMAmJGEsLJoH/FY3xMPljWA0481gZo +xPW6B0es4tKytUDVqDDS1xb2 +=DTie +-----END PGP PUBLIC KEY BLOCK----- diff --git a/utils/gpg_keys/readme.md b/utils/gpg_keys/readme.md new file mode 100644 index 00000000..461856e4 --- /dev/null +++ b/utils/gpg_keys/readme.md @@ -0,0 +1,21 @@ +# GPG Keys + +Maintainer GPG Public Keys go in this directory, for verifying signed binary hashes. + +- Export your public key with: + +```bash +# get your key id (16 hex chars) +$ gpg --list-secret-keys --keyid-format=long + +# export your public key +$ gpg --armor --export your_key_id > your_github_handle.asc + +# example +# gpg --armor --export DE8F6EA20A661697 > delta1.asc +``` + +- Copy that file to this directory. +- Create a new PR to add your key to the repo. + +- See also "Generating a new GPG key": https://docs.github.com/en/authentication/managing-commit-signature-verification/generating-a-new-gpg-key