From 42d62c38b938bffe45e7bfca67e4c4e1c603a05a Mon Sep 17 00:00:00 2001 From: Luke Parker Date: Sat, 23 Jul 2022 03:35:32 -0500 Subject: [PATCH] Remove the Monero build (#64) * Remove the Monero CMake and make * Download the Monero daemon instead of building it * Cache the Monero daemon Prevents hammering the Monero servers, should reduce CI time. * Correct YAML * Add back sodium-dev * Create an independent job for downloading the Monero daemon Improves parallelism while decreasing the amount of work re-done if build fails. Also increases modularity. * Correct Monero job definition * Correct skipping the Monero download on cache hit --- .github/workflows/tests.yml | 79 ++++++++++++++++++------------------- coins/monero/build.rs | 71 +-------------------------------- coins/monero/c/wrapper.cpp | 2 - 3 files changed, 39 insertions(+), 113 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 2ca43021..4d3be7e8 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -7,6 +7,31 @@ on: pull_request: jobs: + monero-daemon: + runs-on: ubuntu-latest + steps: + - name: Monero cache + id: cache-monerod + uses: actions/cache@v3 + with: + path: monerod + key: monerod-${{ runner.os }}-${{ runner.arch }}-v0.17.3.2 + + - name: Download the Monero Daemon + if: steps.cache-monerod.outputs.cache-hit != 'true' + # Calculates OS/ARCH to demonstrate it, yet then locks to linux-x64 due + # to the contained folder not following the same naming scheme and + # requiring further expansion not worth doing right now + run: | + RUNNER_OS=${{ runner.os }} + RUNNER_ARCH=${{ runner.arch }} + OS_ARCH=${RUNNER_OS,,}-${RUNNER_ARCH,,} + OS_ARCH=linux-x64 + + wget https://downloads.getmonero.org/cli/monero-$OS_ARCH-v0.17.3.2.tar.bz2 + tar -xvf monero-$OS_ARCH-v0.17.3.2.tar.bz2 + mv monero-x86_64-linux-gnu-v0.17.3.2/monerod monerod + build: runs-on: ubuntu-latest steps: @@ -23,9 +48,7 @@ jobs: - name: Install Monero Dependencies run: | sudo apt update - sudo apt install build-essential cmake pkg-config libboost-all-dev \ - libssl-dev libzmq3-dev libpgm-dev libunbound-dev \ - libsodium-dev ccache + sudo apt install build-essential libboost-all-dev libsodium-dev - name: Install Rust uses: actions-rs/toolchain@v1 @@ -41,18 +64,6 @@ jobs: profile: minimal target: wasm32-unknown-unknown - # Cache everything, not only for performance, yet to export these to the - # following jobs - - name: Monero cache - uses: actions/cache@v3 - with: - path: | - ./coins/monero/c/.build - ./coins/monero/c/monero/build - # Hash src, as theoretically, a different version of Monero warranting - # a rebuild would've changed *something* under src - key: ${{ runner.os }}-${{ hashFiles('./coins/monero/c/monero/src') }} - - name: Cargo/Rust cache uses: actions/cache@v3 with: @@ -81,9 +92,7 @@ jobs: - name: Install Monero Dependencies run: | sudo apt update - sudo apt install build-essential cmake pkg-config libboost-all-dev \ - libssl-dev libzmq3-dev libpgm-dev libunbound-dev \ - libsodium-dev ccache + sudo apt install build-essential libboost-all-dev libsodium-dev - name: Install Rust uses: actions-rs/toolchain@v1 @@ -101,15 +110,6 @@ jobs: profile: minimal target: wasm32-unknown-unknown - # Grab the Monero cache since it'll be unaffected by Rust versioning - - name: Monero cache - uses: actions/cache@v3 - with: - path: | - ./coins/monero/c/.build - ./coins/monero/c/monero/build - key: ${{ runner.os }}-${{ hashFiles('./coins/monero/c/monero/src') }} - # Define a separate cache for nightly Rust - name: Cargo/Rust nightly cache uses: actions/cache@v3 @@ -124,7 +124,7 @@ jobs: test: runs-on: ubuntu-latest - needs: build + needs: [monero-daemon, build] steps: - uses: actions/checkout@v3 with: @@ -144,8 +144,16 @@ jobs: - name: Install Monero Dependencies run: | sudo apt update - sudo apt install libboost-all-dev libssl-dev libzmq3-dev libpgm-dev \ - libunbound-dev libsodium-dev + sudo apt install build-essential libboost-all-dev libsodium-dev + + - name: Monero cache + uses: actions/cache@v3 + with: + path: monerod + key: monerod-${{ runner.os }}-${{ runner.arch }}-v0.17.3.2 + + - name: Monero Regtest Daemon + run: ./monerod --regtest --offline --fixed-difficulty=1 --detach - name: Install Rust uses: actions-rs/toolchain@v1 @@ -161,14 +169,6 @@ jobs: profile: minimal target: wasm32-unknown-unknown - - name: Monero cache - uses: actions/cache@v3 - with: - path: | - ./coins/monero/c/.build - ./coins/monero/c/monero/build - key: ${{ runner.os }}-${{ hashFiles('./coins/monero/c/monero/src') }} - - name: Cargo/Rust cache uses: actions/cache@v3 with: @@ -177,9 +177,6 @@ jobs: ./target key: ${{ runner.os }}-cargo-rust - - name: Monero Regtest Daemon - run: ./coins/monero/c/monero/build/release/bin/monerod --regtest --offline --fixed-difficulty=1 --detach - - name: Run tests run: cargo test --all-features diff --git a/coins/monero/build.rs b/coins/monero/build.rs index 16697b16..98b25044 100644 --- a/coins/monero/build.rs +++ b/coins/monero/build.rs @@ -1,4 +1,4 @@ -use std::{env, path::Path, process::Command}; +use std::process::Command; fn main() { if !Command::new("git") @@ -10,71 +10,6 @@ fn main() { panic!("git failed to init submodules"); } - if !Command::new("mkdir") - .args(&["-p", ".build"]) - .current_dir(&Path::new("c")) - .status() - .unwrap() - .success() - { - panic!("failed to create a directory to track build progress"); - } - - let out_dir = &env::var("OUT_DIR").unwrap(); - - // Use a file to signal if Monero was already built, as that should never be rebuilt - // If the signaling file was deleted, run this script again to rebuild Monero though - println!("cargo:rerun-if-changed=c/.build/monero"); - if !Path::new("c/.build/monero").exists() { - if !Command::new("mkdir") - .args(&["-p", "build/release"]) - .current_dir(&Path::new("c/monero")) - .status() - .unwrap() - .success() - { - panic!("failed to mkdir"); - } - - if !Command::new("cmake") - .args(&[ - "-D", - &format!("ARCH={}", &env::var("ARCH").unwrap_or_else(|_| "native".to_string())), - "-D", - "BUILD_TESTS=OFF", - "-D", - "CMAKE_BUILD_TYPE=Release", - "../..", - ]) - .current_dir(&Path::new("c/monero/build/release")) - .status() - .unwrap() - .success() - { - panic!("failed to call cmake. Please check your dependencies"); - } - - if !Command::new("make") - .arg(format!("-j{}", &env::var("THREADS").unwrap_or_else(|_| "2".to_string()))) - .current_dir(&Path::new("c/monero/build/release")) - .status() - .unwrap() - .success() - { - panic!("make failed to build Monero. Please check your dependencies"); - } - - if !Command::new("touch") - .arg("monero") - .current_dir(&Path::new("c/.build")) - .status() - .unwrap() - .success() - { - panic!("failed to create a file to label Monero as built"); - } - } - println!("cargo:rerun-if-changed=c/wrapper.cpp"); #[rustfmt::skip] cc::Build::new() @@ -101,9 +36,6 @@ fn main() { .file("c/monero/src/crypto/keccak.c") .file("c/monero/src/crypto/hash.c") - .include("c/monero/src/device") - .file("c/monero/src/device/device_default.cpp") - .include("c/monero/src/ringct") .file("c/monero/src/ringct/rctCryptoOps.c") .file("c/monero/src/ringct/rctTypes.cpp") @@ -115,7 +47,6 @@ fn main() { .file("c/wrapper.cpp") .compile("wrapper"); - println!("cargo:rustc-link-search={}", out_dir); println!("cargo:rustc-link-lib=wrapper"); println!("cargo:rustc-link-lib=stdc++"); } diff --git a/coins/monero/c/wrapper.cpp b/coins/monero/c/wrapper.cpp index 7ed31ac8..d9436579 100644 --- a/coins/monero/c/wrapper.cpp +++ b/coins/monero/c/wrapper.cpp @@ -1,7 +1,5 @@ #include -#include "device/device_default.hpp" - #include "ringct/bulletproofs.h" #include "ringct/rctSigs.h"