From 58c33f8468909cb7ed5948c56291f437852af929 Mon Sep 17 00:00:00 2001 From: Daniel Karzel Date: Fri, 12 Mar 2021 11:25:30 +1100 Subject: [PATCH 1/5] Add asb to release including ARM build --- .github/workflows/ci.yml | 20 ++++++++++-- .github/workflows/release-cli.yml | 52 ++++++++++++++++++++++++------- Cargo.lock | 11 +++++++ rust-toolchain | 1 + swap/Cargo.toml | 1 + 5 files changed, 71 insertions(+), 14 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b460f3e3..54e7071e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -40,7 +40,7 @@ jobs: build: strategy: matrix: - target: [ x86_64-unknown-linux-gnu, x86_64-apple-darwin, x86_64-pc-windows-msvc ] + target: [ x86_64-unknown-linux-gnu, x86_64-apple-darwin, x86_64-pc-windows-msvc, armv7-unknown-linux-gnueabihf ] include: - target: x86_64-unknown-linux-gnu os: ubuntu-latest @@ -56,7 +56,15 @@ jobs: - uses: Swatinem/rust-cache@v1.2.0 + - name: Install compiler for armhf arch + if: matrix.target == 'armv7-unknown-linux-gnueabihf' + run: | + sudo apt-get update + sudo apt-get install gcc-arm-linux-gnueabihf + - name: Build binary + env: + CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER: arm-linux-gnueabihf-gcc run: | cargo build -p swap --target ${{ matrix.target }} @@ -77,7 +85,7 @@ jobs: RUST_TEST_TASKS: 2 strategy: matrix: - target: [ x86_64-unknown-linux-gnu, x86_64-apple-darwin ] + target: [ x86_64-unknown-linux-gnu, x86_64-apple-darwin, armv7-unknown-linux-gnueabihf ] include: - target: x86_64-unknown-linux-gnu os: ubuntu-latest @@ -91,7 +99,15 @@ jobs: - uses: Swatinem/rust-cache@v1.2.0 + - name: Install compiler for armhf arch + if: matrix.target == 'armv7-unknown-linux-gnueabihf' + run: | + sudo apt-get update + sudo apt-get install gcc-arm-linux-gnueabihf + - name: Build tests + env: + CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER: arm-linux-gnueabihf-gcc run: cargo build --tests --workspace --all-features - name: Run monero-harness tests diff --git a/.github/workflows/release-cli.yml b/.github/workflows/release-cli.yml index ccccae45..0501e090 100644 --- a/.github/workflows/release-cli.yml +++ b/.github/workflows/release-cli.yml @@ -1,4 +1,4 @@ -name: "Release swap" +name: "Release swap and asb" on: release: @@ -10,13 +10,32 @@ jobs: strategy: matrix: include: - - target: x86_64-unknown-linux-gnu + - bin: swap + target: x86_64-unknown-linux-gnu os: ubuntu-latest archive_ext: tar - - target: x86_64-apple-darwin + - bin: swap + target: x86_64-apple-darwin os: macos-latest archive_ext: tar - - target: x86_64-pc-windows-msvc + - bin: swap + target: x86_64-pc-windows-msvc + os: windows-latest + archive_ext: zip + - bin: asb + target: x86_64-unknown-linux-gnu + os: ubuntu-latest + archive_ext: tar + - bin: asb + target: armv7-unknown-linux-gnueabihf + os: ubuntu-latest + archive_ext: tar + - bin: asb + target: x86_64-apple-darwin + os: macos-latest + archive_ext: tar + - bin: asb + target: x86_64-pc-windows-msvc os: windows-latest archive_ext: zip runs-on: ${{ matrix.os }} @@ -29,11 +48,20 @@ jobs: - uses: Swatinem/rust-cache@v1.2.0 - - name: Build ${{ matrix.target }} release binary - run: cargo build --target=${{ matrix.target }} --release --package swap --bin swap + - name: Install compiler for armhf arch + if: matrix.target == 'armv7-unknown-linux-gnueabihf' + run: | + sudo apt-get update + sudo apt-get install gcc-arm-linux-gnueabihf + + - name: Build ${{ matrix.target }} ${{ matrix.bin }} release binary + env: + CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER: arm-linux-gnueabihf-gcc + run: cargo build --target=${{ matrix.target }} --release --package swap --bin ${{ matrix.bin }} - name: Smoke test the binary - run: target/${{ matrix.target }}/release/swap --help + if: matrix.target != 'armv7-unknown-linux-gnueabihf' # armv7-unknown-linux-gnueabihf is only cross-compiled, no smoke test + run: target/${{ matrix.target }}/release/${{ matrix.bin }} --help # Remove once python 3 is the default - uses: actions/setup-python@v1 @@ -51,26 +79,26 @@ jobs: triple = "${{ matrix.target }}".split("-") arch = triple[0] - archive_name=f'swap_${{ github.event.release.tag_name }}_{os_info.system}_{arch}.${{ matrix.archive_ext }}' + archive_name=f'${{ matrix.bin }}_${{ github.event.release.tag_name }}_{os_info.system}_{arch}.${{ matrix.archive_ext }}' print(f'::set-output name=archive::{archive_name}') - name: Pack macos archive if: matrix.os == 'macos-latest' shell: bash - run: gtar -C ./target/${{ matrix.target }}/release --create --file=${{ steps.create-archive-name.outputs.archive }} swap + run: gtar -C ./target/${{ matrix.target }}/release --create --file=${{ steps.create-archive-name.outputs.archive }} ${{ matrix.bin }} - name: Pack linux archive if: matrix.os == 'ubuntu-latest' shell: bash - run: tar -C ./target/${{ matrix.target }}/release --create --file=${{ steps.create-archive-name.outputs.archive }} swap + run: tar -C ./target/${{ matrix.target }}/release --create --file=${{ steps.create-archive-name.outputs.archive }} ${{ matrix.bin }} - name: Pack windows archive if: matrix.os == 'windows-latest' shell: bash run: | - cp target/${{ matrix.target }}/release/swap.exe ./swap.exe - 7z a -tzip ${{ steps.create-archive-name.outputs.archive }} ./swap.exe + cp target/${{ matrix.target }}/release/${{ matrix.bin }}.exe ./${{ matrix.bin }}.exe + 7z a -tzip ${{ steps.create-archive-name.outputs.archive }} ./${{ matrix.bin }}.exe - name: Upload archive uses: actions/upload-release-asset@v1 diff --git a/Cargo.lock b/Cargo.lock index b80a4c92..f6eb58bf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2311,6 +2311,15 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "77af24da69f9d9341038eba93a073b1fdaaa1b788221b00a69bce9e762cb32de" +[[package]] +name = "openssl-src" +version = "111.14.0+1.1.1j" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "055b569b5bd7e5462a1700f595c7c7d487691d73b5ce064176af7f9f0cbb80a9" +dependencies = [ + "cc", +] + [[package]] name = "openssl-sys" version = "0.9.60" @@ -2320,6 +2329,7 @@ dependencies = [ "autocfg 1.0.1", "cc", "libc", + "openssl-src", "pkg-config", "vcpkg", ] @@ -3598,6 +3608,7 @@ dependencies = [ "monero", "monero-harness", "monero-rpc", + "openssl", "pem", "port_check", "prettytable-rs", diff --git a/rust-toolchain b/rust-toolchain index b431082c..6a154529 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1,3 +1,4 @@ [toolchain] channel = "nightly-2021-01-31" components = ["rustfmt", "clippy"] +targets = ["armv7-unknown-linux-gnueabihf"] diff --git a/swap/Cargo.toml b/swap/Cargo.toml index 2b3d8f3b..df100647 100644 --- a/swap/Cargo.toml +++ b/swap/Cargo.toml @@ -31,6 +31,7 @@ libp2p-async-await = { git = "https://github.com/comit-network/rust-libp2p-async miniscript = { version = "5", features = ["serde"] } monero = { version = "0.10", features = ["serde_support"] } monero-rpc = { path = "../monero-rpc" } +openssl = { version = "0.10", features = ["vendored"] } pem = "0.8" prettytable-rs = "0.8" rand = "0.7" From 6e09653d3ffef5f9464bca9008974abf085d747f Mon Sep 17 00:00:00 2001 From: Daniel Karzel Date: Mon, 15 Mar 2021 13:40:03 +1100 Subject: [PATCH 2/5] Remove target section from CI matrix.include does not require the target section to be present because it specifies the specific matrix combinations to be run. --- .github/workflows/ci.yml | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 54e7071e..d99e849e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -40,10 +40,11 @@ jobs: build: strategy: matrix: - target: [ x86_64-unknown-linux-gnu, x86_64-apple-darwin, x86_64-pc-windows-msvc, armv7-unknown-linux-gnueabihf ] include: - target: x86_64-unknown-linux-gnu os: ubuntu-latest + - target: armv7-unknown-linux-gnueabihf + os: ubuntu-latest - target: x86_64-apple-darwin os: macos-latest - target: x86_64-pc-windows-msvc @@ -85,7 +86,6 @@ jobs: RUST_TEST_TASKS: 2 strategy: matrix: - target: [ x86_64-unknown-linux-gnu, x86_64-apple-darwin, armv7-unknown-linux-gnueabihf ] include: - target: x86_64-unknown-linux-gnu os: ubuntu-latest @@ -99,12 +99,6 @@ jobs: - uses: Swatinem/rust-cache@v1.2.0 - - name: Install compiler for armhf arch - if: matrix.target == 'armv7-unknown-linux-gnueabihf' - run: | - sudo apt-get update - sudo apt-get install gcc-arm-linux-gnueabihf - - name: Build tests env: CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER: arm-linux-gnueabihf-gcc From f8360fe853841c69c74310f85ba011d52983a889 Mon Sep 17 00:00:00 2001 From: Daniel Karzel Date: Mon, 15 Mar 2021 13:42:21 +1100 Subject: [PATCH 3/5] .cargo/config.toml for specifying linker To avoid code duplication we specify the linker for the specific target armv7-unknown-linux-gnueabihf in the config.toml file as specified here: https://doc.rust-lang.org/cargo/reference/config.html#targettriplelinker --- .cargo/config.toml | 2 ++ .github/workflows/ci.yml | 4 ---- .github/workflows/release-cli.yml | 3 +-- 3 files changed, 3 insertions(+), 6 deletions(-) create mode 100644 .cargo/config.toml diff --git a/.cargo/config.toml b/.cargo/config.toml new file mode 100644 index 00000000..0c1c209f --- /dev/null +++ b/.cargo/config.toml @@ -0,0 +1,2 @@ +[target.armv7-unknown-linux-gnueabihf] +linker = "arm-linux-gnueabihf-gcc" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d99e849e..85b798f1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -64,8 +64,6 @@ jobs: sudo apt-get install gcc-arm-linux-gnueabihf - name: Build binary - env: - CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER: arm-linux-gnueabihf-gcc run: | cargo build -p swap --target ${{ matrix.target }} @@ -100,8 +98,6 @@ jobs: - uses: Swatinem/rust-cache@v1.2.0 - name: Build tests - env: - CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER: arm-linux-gnueabihf-gcc run: cargo build --tests --workspace --all-features - name: Run monero-harness tests diff --git a/.github/workflows/release-cli.yml b/.github/workflows/release-cli.yml index 0501e090..5d349586 100644 --- a/.github/workflows/release-cli.yml +++ b/.github/workflows/release-cli.yml @@ -55,8 +55,7 @@ jobs: sudo apt-get install gcc-arm-linux-gnueabihf - name: Build ${{ matrix.target }} ${{ matrix.bin }} release binary - env: - CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER: arm-linux-gnueabihf-gcc + run: cargo build --target=${{ matrix.target }} --release --package swap --bin ${{ matrix.bin }} - name: Smoke test the binary From 442c377490ef84c4ecb035863926a4fd5019e362 Mon Sep 17 00:00:00 2001 From: Daniel Karzel Date: Mon, 15 Mar 2021 13:59:14 +1100 Subject: [PATCH 4/5] Remove openssl dependency Upgrade tokio-tungstenite to 0.14 and use feature flag rustls-tls to get rid of the openssl dependency. --- Cargo.lock | 161 ++++-------------------------------------------- swap/Cargo.toml | 3 +- 2 files changed, 13 insertions(+), 151 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f6eb58bf..b363a990 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -682,22 +682,6 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" -[[package]] -name = "core-foundation" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a89e2ae426ea83155dccf10c0fa6b1463ef6d5fcb44cee0b224a408fa640a62" -dependencies = [ - "core-foundation-sys", - "libc", -] - -[[package]] -name = "core-foundation-sys" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea221b5284a47e40033bf9b66f35f984ec0ea2931eb03505246cd27a963f981b" - [[package]] name = "cpuid-bool" version = "0.1.2" @@ -1102,21 +1086,6 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" -[[package]] -name = "foreign-types" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" -dependencies = [ - "foreign-types-shared", -] - -[[package]] -name = "foreign-types-shared" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" - [[package]] name = "form_urlencoded" version = "1.0.0" @@ -2131,24 +2100,6 @@ dependencies = [ "unsigned-varint 0.6.0", ] -[[package]] -name = "native-tls" -version = "0.2.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8d96b2e1c8da3957d58100b09f102c6d9cfdfced01b7ec5a8974044bb09dbd4" -dependencies = [ - "lazy_static", - "libc", - "log", - "openssl", - "openssl-probe", - "openssl-sys", - "schannel", - "security-framework", - "security-framework-sys", - "tempfile", -] - [[package]] name = "nb-connect" version = "1.0.2" @@ -2291,49 +2242,6 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" -[[package]] -name = "openssl" -version = "0.10.32" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "038d43985d1ddca7a9900630d8cd031b56e4794eecc2e9ea39dd17aa04399a70" -dependencies = [ - "bitflags", - "cfg-if 1.0.0", - "foreign-types", - "lazy_static", - "libc", - "openssl-sys", -] - -[[package]] -name = "openssl-probe" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77af24da69f9d9341038eba93a073b1fdaaa1b788221b00a69bce9e762cb32de" - -[[package]] -name = "openssl-src" -version = "111.14.0+1.1.1j" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "055b569b5bd7e5462a1700f595c7c7d487691d73b5ce064176af7f9f0cbb80a9" -dependencies = [ - "cc", -] - -[[package]] -name = "openssl-sys" -version = "0.9.60" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "921fc71883267538946025deffb622905ecad223c28efbfdef9bb59a0175f3e6" -dependencies = [ - "autocfg 1.0.1", - "cc", - "libc", - "openssl-src", - "pkg-config", - "vcpkg", -] - [[package]] name = "parity-multiaddr" version = "0.11.0" @@ -3101,16 +3009,6 @@ version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" -[[package]] -name = "schannel" -version = "0.1.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f05ba609c234e60bee0d547fe94a4c7e9da733d1c962cf6e59efa4cd9c8bc75" -dependencies = [ - "lazy_static", - "winapi 0.3.9", -] - [[package]] name = "scopeguard" version = "1.1.0" @@ -3169,29 +3067,6 @@ dependencies = [ "subtle 2.4.0", ] -[[package]] -name = "security-framework" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1759c2e3c8580017a484a7ac56d3abc5a6c1feadf88db2f3633f12ae4268c69" -dependencies = [ - "bitflags", - "core-foundation", - "core-foundation-sys", - "libc", - "security-framework-sys", -] - -[[package]] -name = "security-framework-sys" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f99b9d5e26d2a71633cc4f2ebae7cc9f874044e0c351a27e17892d76dce5678b" -dependencies = [ - "core-foundation-sys", - "libc", -] - [[package]] name = "semver" version = "0.9.0" @@ -3608,7 +3483,6 @@ dependencies = [ "monero", "monero-harness", "monero-rpc", - "openssl", "pem", "port_check", "prettytable-rs", @@ -3874,16 +3748,6 @@ dependencies = [ "syn", ] -[[package]] -name = "tokio-native-tls" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7d995660bd2b7f8c1568414c1126076c13fbb725c40112dc0120b78eb9b717b" -dependencies = [ - "native-tls", - "tokio", -] - [[package]] name = "tokio-rustls" version = "0.22.0" @@ -3922,17 +3786,19 @@ dependencies = [ [[package]] name = "tokio-tungstenite" -version = "0.13.0" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1a5f475f1b9d077ea1017ecbc60890fda8e54942d680ca0b1d2b47cfa2d861b" +checksum = "1e96bb520beab540ab664bd5a9cfeaa1fcd846fa68c830b42e2c8963071251d2" dependencies = [ "futures-util", "log", - "native-tls", "pin-project 1.0.4", + "rustls 0.19.0", "tokio", - "tokio-native-tls", + "tokio-rustls", "tungstenite", + "webpki", + "webpki-roots 0.21.0", ] [[package]] @@ -4044,9 +3910,9 @@ checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642" [[package]] name = "tungstenite" -version = "0.12.0" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ada8297e8d70872fa9a551d93250a9f407beb9f37ef86494eb20012a2ff7c24" +checksum = "5fe8dada8c1a3aeca77d6b51a4f1314e0f4b8e438b7b1b71e3ddaca8080e4093" dependencies = [ "base64 0.13.0", "byteorder", @@ -4055,11 +3921,14 @@ dependencies = [ "httparse", "input_buffer", "log", - "native-tls", "rand 0.8.2", + "rustls 0.19.0", "sha-1", + "thiserror", "url", "utf-8", + "webpki", + "webpki-roots 0.21.0", ] [[package]] @@ -4191,12 +4060,6 @@ dependencies = [ "serde", ] -[[package]] -name = "vcpkg" -version = "0.2.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b00bca6106a5e23f3eee943593759b7fcddb00554332e856d990c893966879fb" - [[package]] name = "vec-arena" version = "1.0.0" diff --git a/swap/Cargo.toml b/swap/Cargo.toml index df100647..4795c765 100644 --- a/swap/Cargo.toml +++ b/swap/Cargo.toml @@ -31,7 +31,6 @@ libp2p-async-await = { git = "https://github.com/comit-network/rust-libp2p-async miniscript = { version = "5", features = ["serde"] } monero = { version = "0.10", features = ["serde_support"] } monero-rpc = { path = "../monero-rpc" } -openssl = { version = "0.10", features = ["vendored"] } pem = "0.8" prettytable-rs = "0.8" rand = "0.7" @@ -49,7 +48,7 @@ strum = { version = "0.20", features = ["derive"] } thiserror = "1" time = "0.2" tokio = { version = "1.0", features = ["rt-multi-thread", "time", "macros", "sync", "process", "fs"] } -tokio-tungstenite = { version = "0.13", features = [ "tls" ] } +tokio-tungstenite = { version = "0.14", features = [ "rustls-tls" ] } tokio-util = { version = "0.6.3", features = ["io"] } toml = "0.5" tracing = { version = "0.1", features = ["attributes"] } From 222724b59ad90a9e91de6554f8cb4e4a3638f1ae Mon Sep 17 00:00:00 2001 From: Daniel Karzel Date: Mon, 15 Mar 2021 16:04:14 +1100 Subject: [PATCH 5/5] Update bors config Add armv build check to bors. Update build and test names due to matix configuration changes. --- bors.toml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/bors.toml b/bors.toml index 11761796..ea398644 100644 --- a/bors.toml +++ b/bors.toml @@ -1,10 +1,11 @@ status = [ "static_analysis", - "build (x86_64-unknown-linux-gnu)", - "build (x86_64-apple-darwin)", - "build (x86_64-pc-windows-msvc)", - "test (x86_64-unknown-linux-gnu)", - "test (x86_64-apple-darwin)", + "build (x86_64-unknown-linux-gnu, ubuntu-latest)", + "build (armv7-unknown-linux-gnueabihf, ubuntu-latest)", + "build (x86_64-apple-darwin, macos-latest)", + "build (x86_64-pc-windows-msvc, windows-latest)", + "test (x86_64-unknown-linux-gnu, ubuntu-latest)", + "test (x86_64-apple-darwin, macos-latest)", "docker_tests (happy_path)", "docker_tests (happy_path_restart_bob_before_comm)", "docker_tests (bob_refunds_using_cancel_and_refund_command)",