diff --git a/.github/workflows/build-dev.yaml b/.github/workflows/build-dev.yaml index 52e5ac8680..354b3f7eff 100644 --- a/.github/workflows/build-dev.yaml +++ b/.github/workflows/build-dev.yaml @@ -45,23 +45,6 @@ jobs: docker tag defichain-x86_64-pc-linux-gnu:${ver} defi/defichain:${ver} docker push defi/defichain:${ver} - linux-armhf: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - - name: Populate environment - run: GIT_VERSION=1 ./make.sh ci-export-vars - - - name: Build and package - run: GIT_VERSION=1 TARGET="arm-linux-gnueabihf" ./make.sh docker-release - - - name: Publish artifact - arm-linux-gnueabihf - uses: actions/upload-artifact@v3 - with: - name: defichain-${{ env.BUILD_VERSION }}-arm-linux-gnueabihf - path: ./build/defichain-${{ env.BUILD_VERSION }}-arm-linux-gnueabihf.tar.gz - win-x64: runs-on: ubuntu-latest steps: @@ -79,7 +62,7 @@ jobs: name: defichain-${{ env.BUILD_VERSION }}-x86_64-w64-mingw32 path: ./build/defichain-${{ env.BUILD_VERSION }}-x86_64-w64-mingw32.tar.gz - mac-x64: + osx-x64: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 diff --git a/.github/workflows/build-release.yaml b/.github/workflows/build-release.yaml index 93f816093a..1977418353 100644 --- a/.github/workflows/build-release.yaml +++ b/.github/workflows/build-release.yaml @@ -10,7 +10,7 @@ env: DOCKER_HUB_USER: defi jobs: - linux: + linux-x64: runs-on: ubuntu-latest if: startsWith(github.ref, 'refs/tags/') @@ -43,7 +43,45 @@ jobs: done docker push defi/defichain:${ver} - windows: + linux-armhf: + runs-on: ubuntu-latest + if: startsWith(github.ref, 'refs/tags/') + + steps: + - uses: actions/checkout@v3 + + - name: Populate environment + run: GIT_VERSION=1 ./make.sh ci-export-vars + + - name: Build and package + run: GIT_VERSION=1 TARGET="arm-linux-gnueabihf" ./make.sh docker-release + + - name: Publish artifact - arm-linux-gnueabihf + uses: actions/upload-artifact@v3 + with: + name: defichain-${{ env.BUILD_VERSION }}-arm-linux-gnueabihf + path: ./build/defichain-${{ env.BUILD_VERSION }}-arm-linux-gnueabihf.tar.gz + + linux-aarch64: + runs-on: ubuntu-latest + if: startsWith(github.ref, 'refs/tags/') + + steps: + - uses: actions/checkout@v3 + + - name: Populate environment + run: GIT_VERSION=1 ./make.sh ci-export-vars + + - name: Build and package + run: GIT_VERSION=1 TARGET="aarch64-linux-gnu" ./make.sh docker-release + + - name: Publish artifact - aarch64-linux-gnu + uses: actions/upload-artifact@v3 + with: + name: defichain-${{ env.BUILD_VERSION }}-aarch64-linux-gnu + path: ./build/defichain-${{ env.BUILD_VERSION }}-aarch64-linux-gnu.tar.gz + + win-x64: runs-on: ubuntu-latest if: startsWith(github.ref, 'refs/tags/') @@ -62,7 +100,7 @@ jobs: name: defichain-${{ env.BUILD_VERSION }}-x86_64-w64-mingw32 path: ./build/defichain-${{ env.BUILD_VERSION }}-x86_64-w64-mingw32.tar.gz - macos: + osx-x64: runs-on: ubuntu-latest if: startsWith(github.ref, 'refs/tags/') @@ -81,11 +119,33 @@ jobs: name: defichain-${{ env.BUILD_VERSION }}-x86_64-apple-darwin path: ./build/defichain-${{ env.BUILD_VERSION }}-x86_64-apple-darwin.tar.gz + osx-aarch64: + runs-on: ubuntu-latest + if: startsWith(github.ref, 'refs/tags/') + + steps: + - uses: actions/checkout@v3 + + - name: Populate environment + run: GIT_VERSION=1 ./make.sh ci-export-vars + + - name: Build and package + run: GIT_VERSION=1 TARGET="aarch64-apple-darwin" ./make.sh docker-release + + - name: Publish artifact - aarch64-apple-darwin + uses: actions/upload-artifact@v3 + with: + name: defichain-${{ env.BUILD_VERSION }}-aarch64-apple-darwin + path: ./build/defichain-${{ env.BUILD_VERSION }}-aarch64-apple-darwin.tar.gz + create-release: needs: - - linux - - windows - - macos + - linux-x64 + - linux-armhf + - linux-aarch64 + - win-x64 + - osx-x64 + - osx-aarch64 runs-on: ubuntu-latest if: startsWith(github.ref, 'refs/tags/') @@ -101,7 +161,7 @@ jobs: - name: Get artifacts uses: actions/download-artifact@v3 - - name: zip package for windows + - name: zip package for win-x64 run: | set -e; ver=${{ env.BUILD_VERSION }} cd defichain-${ver}-x86_64-w64-mingw32 @@ -121,12 +181,18 @@ jobs: set -e; ver=${{ env.BUILD_VERSION }} cd ./defichain-${ver}-x86_64-pc-linux-gnu sha256sum ./defichain-${ver}-x86_64-pc-linux-gnu.tar.gz > ./defichain-${ver}-x86_64-pc-linux-gnu.tar.gz.SHA256 + cd ./defichain-${ver}-arm-linux-gnueabihf + sha256sum ./defichain-${ver}-arm-linux-gnueabihf.tar.gz > ./defichain-${ver}-arm-linux-gnueabihf.tar.gz.SHA256 + cd ./defichain-${ver}-aarch64-linux-gnu + sha256sum ./defichain-${ver}-aarch64-linux-gnu.tar.gz > ./defichain-${ver}-aarch64-linux-gnu.tar.gz.SHA256 cd .. && cd ./defichain-${ver}-x86_64-w64-mingw32 sha256sum ./defichain-${ver}-x86_64-w64-mingw32.zip > ./defichain-${ver}-x86_64-w64-mingw32.zip.SHA256 cd .. && cd ./defichain-${ver}-x86_64-apple-darwin sha256sum ./defichain-${ver}-x86_64-apple-darwin.tar.gz > ././defichain-${ver}-x86_64-apple-darwin.tar.gz.SHA256 + cd .. && cd ./defichain-${ver}-aarch64-apple-darwin + sha256sum ./defichain-${ver}-aarch64-apple-darwin.tar.gz > ././defichain-${ver}-aarch64-apple-darwin.tar.gz.SHA256 - - name: Upload release asset - linux + - name: Upload release asset - linux-x64 uses: actions/upload-release-asset@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -136,7 +202,7 @@ jobs: asset_name: defichain-${{ env.BUILD_VERSION }}-x86_64-pc-linux-gnu.tar.gz asset_content_type: application/gzip - - name: Upload checksum - linux + - name: Upload checksum - linux-x64 uses: actions/upload-release-asset@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -145,8 +211,48 @@ jobs: asset_path: ./defichain-${{ env.BUILD_VERSION }}-x86_64-pc-linux-gnu/defichain-${{ env.BUILD_VERSION }}-x86_64-pc-linux-gnu.tar.gz.SHA256 asset_name: defichain-${{ env.BUILD_VERSION }}-x86_64-pc-linux-gnu.tar.gz.SHA256 asset_content_type: text/plain + + - name: Upload release asset - linux-armhf + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.get_release_by_tag.outputs.upload_url }} + asset_path: ./defichain-${{ env.BUILD_VERSION }}-arm-linux-gnueabihf/defichain-${{ env.BUILD_VERSION }}-arm-linux-gnueabihf.tar.gz + asset_name: defichain-${{ env.BUILD_VERSION }}-arm-linux-gnueabihf.tar.gz + asset_content_type: application/gzip + + - name: Upload checksum - linux-armhf + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.get_release_by_tag.outputs.upload_url }} + asset_path: ./defichain-${{ env.BUILD_VERSION }}-arm-linux-gnueabihf/defichain-${{ env.BUILD_VERSION }}-arm-linux-gnueabihf.tar.gz.SHA256 + asset_name: defichain-${{ env.BUILD_VERSION }}-arm-linux-gnueabihf.tar.gz.SHA256 + asset_content_type: text/plain + + - name: Upload release asset - linux-aarch64 + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.get_release_by_tag.outputs.upload_url }} + asset_path: ./defichain-${{ env.BUILD_VERSION }}-aarch64-linux-gnu/defichain-${{ env.BUILD_VERSION }}-aarch64-linux-gnu.tar.gz + asset_name: defichain-${{ env.BUILD_VERSION }}-aarch64-linux-gnu.tar.gz + asset_content_type: application/gzip + + - name: Upload checksum - linux-aarch64 + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.get_release_by_tag.outputs.upload_url }} + asset_path: ./defichain-${{ env.BUILD_VERSION }}-aarch64-linux-gnu/defichain-${{ env.BUILD_VERSION }}-aarch64-linux-gnu.tar.gz.SHA256 + asset_name: defichain-${{ env.BUILD_VERSION }}-aarch64-linux-gnu.tar.gz.SHA256 + asset_content_type: text/plain - - name: Upload release asset - windows + - name: Upload release asset - win-x64 uses: actions/upload-release-asset@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -156,7 +262,7 @@ jobs: asset_name: defichain-${{ env.BUILD_VERSION }}-x86_64-w64-mingw32.zip asset_content_type: application/zip - - name: Upload checksum asset - windows + - name: Upload checksum asset - win-x64 uses: actions/upload-release-asset@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -166,7 +272,7 @@ jobs: asset_name: defichain-${{ env.BUILD_VERSION }}-x86_64-w64-mingw32.zip.SHA256 asset_content_type: text/plain - - name: Upload release asset - macos + - name: Upload release asset - osx-x64 uses: actions/upload-release-asset@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -176,7 +282,7 @@ jobs: asset_name: defichain-${{ env.BUILD_VERSION }}-x86_64-apple-darwin.tar.gz asset_content_type: application/gzip - - name: Upload checksum asset - macos + - name: Upload checksum asset - osx-x64 uses: actions/upload-release-asset@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -185,3 +291,23 @@ jobs: asset_path: ./defichain-${{ env.BUILD_VERSION }}-x86_64-apple-darwin/defichain-${{ env.BUILD_VERSION }}-x86_64-apple-darwin.tar.gz.SHA256 asset_name: defichain-${{ env.BUILD_VERSION }}-x86_64-apple-darwin.tar.gz.SHA256 asset_content_type: text/plain + + - name: Upload release asset - osx-aarch64 + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.get_release_by_tag.outputs.upload_url }} + asset_path: ./defichain-${{ env.BUILD_VERSION }}-aarch64-apple-darwin/defichain-${{ env.BUILD_VERSION }}-aarch64-apple-darwin.tar.gz + asset_name: defichain-${{ env.BUILD_VERSION }}-aarch64-apple-darwin.tar.gz + asset_content_type: application/gzip + + - name: Upload checksum asset - osx-aarch64 + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.get_release_by_tag.outputs.upload_url }} + asset_path: ./defichain-${{ env.BUILD_VERSION }}-aarch64-apple-darwin/defichain-${{ env.BUILD_VERSION }}-aarch64-apple-darwin.tar.gz.SHA256 + asset_name: defichain-${{ env.BUILD_VERSION }}-aarch64-apple-darwin.tar.gz.SHA256 + asset_content_type: text/plain diff --git a/.github/workflows/build-staging.yaml b/.github/workflows/build-staging.yaml new file mode 100644 index 0000000000..eb62714d8a --- /dev/null +++ b/.github/workflows/build-staging.yaml @@ -0,0 +1,121 @@ +name: Build - Staging + +on: + workflow_dispatch: + release: + types: [created] + +jobs: + linux-x64: + runs-on: ubuntu-latest + if: startsWith(github.ref, 'refs/tags/') + + steps: + - uses: actions/checkout@v3 + + - name: Populate environment + run: GIT_VERSION=1 ./make.sh ci-export-vars + + - name: Build and package + run: GIT_VERSION=1 DOCKERFILE="x86_64-pc-linux-gnu-clang" TARGET="x86_64-pc-linux-gnu" ./make.sh docker-release + + - name: Publish artifacts + uses: actions/upload-artifact@v3 + with: + name: defichain-${{ env.BUILD_VERSION }}-x86_64-pc-linux-gnu + path: ./build/defichain-${{ env.BUILD_VERSION }}-x86_64-pc-linux-gnu.tar.gz + + linux-armhf: + runs-on: ubuntu-latest + if: startsWith(github.ref, 'refs/tags/') + + steps: + - uses: actions/checkout@v3 + + - name: Populate environment + run: GIT_VERSION=1 ./make.sh ci-export-vars + + - name: Build and package + run: GIT_VERSION=1 TARGET="arm-linux-gnueabihf" ./make.sh docker-release + + - name: Publish artifact - arm-linux-gnueabihf + uses: actions/upload-artifact@v3 + with: + name: defichain-${{ env.BUILD_VERSION }}-arm-linux-gnueabihf + path: ./build/defichain-${{ env.BUILD_VERSION }}-arm-linux-gnueabihf.tar.gz + + linux-aarch64: + runs-on: ubuntu-latest + if: startsWith(github.ref, 'refs/tags/') + + steps: + - uses: actions/checkout@v3 + + - name: Populate environment + run: GIT_VERSION=1 ./make.sh ci-export-vars + + - name: Build and package + run: GIT_VERSION=1 TARGET="aarch64-linux-gnu" ./make.sh docker-release + + - name: Publish artifact - aarch64-linux-gnu + uses: actions/upload-artifact@v3 + with: + name: defichain-${{ env.BUILD_VERSION }}-aarch64-linux-gnu + path: ./build/defichain-${{ env.BUILD_VERSION }}-aarch64-linux-gnu.tar.gz + + win-x64: + runs-on: ubuntu-latest + if: startsWith(github.ref, 'refs/tags/') + + steps: + - uses: actions/checkout@v3 + + - name: Populate environment + run: GIT_VERSION=1 ./make.sh ci-export-vars + + - name: Build and package + run: GIT_VERSION=1 TARGET="x86_64-w64-mingw32" ./make.sh docker-release + + - name: Publish artifact - x86_64-w64-mingw32 + uses: actions/upload-artifact@v3 + with: + name: defichain-${{ env.BUILD_VERSION }}-x86_64-w64-mingw32 + path: ./build/defichain-${{ env.BUILD_VERSION }}-x86_64-w64-mingw32.tar.gz + + osx-x64: + runs-on: ubuntu-latest + if: startsWith(github.ref, 'refs/tags/') + + steps: + - uses: actions/checkout@v3 + + - name: Populate environment + run: GIT_VERSION=1 ./make.sh ci-export-vars + + - name: Build and package + run: GIT_VERSION=1 TARGET="x86_64-apple-darwin" ./make.sh docker-release + + - name: Publish artifact - x86_64-apple-darwin + uses: actions/upload-artifact@v3 + with: + name: defichain-${{ env.BUILD_VERSION }}-x86_64-apple-darwin + path: ./build/defichain-${{ env.BUILD_VERSION }}-x86_64-apple-darwin.tar.gz + + osx-aarch64: + runs-on: ubuntu-latest + if: startsWith(github.ref, 'refs/tags/') + + steps: + - uses: actions/checkout@v3 + + - name: Populate environment + run: GIT_VERSION=1 ./make.sh ci-export-vars + + - name: Build and package + run: GIT_VERSION=1 TARGET="aarch64-apple-darwin" ./make.sh docker-release + + - name: Publish artifact - aarch64-apple-darwin + uses: actions/upload-artifact@v3 + with: + name: defichain-${{ env.BUILD_VERSION }}-aarch64-apple-darwin + path: ./build/defichain-${{ env.BUILD_VERSION }}-aarch64-apple-darwin.tar.gz \ No newline at end of file diff --git a/contrib/dockerfiles/aarch64-apple-darwin.dockerfile b/contrib/dockerfiles/aarch64-apple-darwin.dockerfile new file mode 100644 index 0000000000..be55ea8312 --- /dev/null +++ b/contrib/dockerfiles/aarch64-apple-darwin.dockerfile @@ -0,0 +1,27 @@ +ARG TARGET=aarch64-apple-darwin + +# ----------- +FROM --platform=linux/amd64 ubuntu:latest as builder +ARG TARGET +LABEL org.defichain.name="defichain-builder" +LABEL org.defichain.arch=${TARGET} + +WORKDIR /work +COPY ./make.sh . + +RUN export DEBIAN_FRONTEND=noninteractive && ./make.sh pkg_update_base +RUN export DEBIAN_FRONTEND=noninteractive && ./make.sh pkg_install_deps +RUN export DEBIAN_FRONTEND=noninteractive && ./make.sh pkg_install_rust +RUN export DEBIAN_FRONTEND=noninteractive && ./make.sh pkg_install_deps_osx_tools +ENV PATH="/root/.cargo/bin:${PATH}" +RUN rustup target add aarch64-apple-darwin + +COPY . . +RUN ./make.sh clean-depends && ./make.sh build-deps +RUN ./make.sh clean-conf && ./make.sh build-conf +RUN ./make.sh build-make + +RUN mkdir /app && cd build/${TARGET} && \ + make -s prefix=/ DESTDIR=/app install + +# NOTE: These are not runnable images. So we do not add into a scratch base image. diff --git a/contrib/dockerfiles/aarch64-linux-gnu.dockerfile b/contrib/dockerfiles/aarch64-linux-gnu.dockerfile index 2cbd6f017f..be259aa678 100644 --- a/contrib/dockerfiles/aarch64-linux-gnu.dockerfile +++ b/contrib/dockerfiles/aarch64-linux-gnu.dockerfile @@ -1,7 +1,7 @@ ARG TARGET=aarch64-linux-gnu # ----------- -FROM ubuntu:latest as builder +FROM --platform=linux/amd64 ubuntu:latest as builder ARG TARGET LABEL org.defichain.name="defichain-builder" LABEL org.defichain.arch=${TARGET} @@ -11,7 +11,10 @@ COPY ./make.sh . RUN export DEBIAN_FRONTEND=noninteractive && ./make.sh pkg_update_base RUN export DEBIAN_FRONTEND=noninteractive && ./make.sh pkg_install_deps +RUN export DEBIAN_FRONTEND=noninteractive && ./make.sh pkg_install_rust RUN export DEBIAN_FRONTEND=noninteractive && ./make.sh pkg_install_deps_arm64 +ENV PATH="/root/.cargo/bin:${PATH}" +RUN rustup target add aarch64-unknown-linux-gnu COPY . . RUN ./make.sh clean-depends && ./make.sh build-deps diff --git a/contrib/dockerfiles/arm-linux-gnueabihf.dockerfile b/contrib/dockerfiles/arm-linux-gnueabihf.dockerfile index 26c268cafe..3a0a95019d 100644 --- a/contrib/dockerfiles/arm-linux-gnueabihf.dockerfile +++ b/contrib/dockerfiles/arm-linux-gnueabihf.dockerfile @@ -1,7 +1,7 @@ ARG TARGET=arm-linux-gnueabihf # ----------- -FROM ubuntu:latest as builder +FROM --platform=linux/amd64 ubuntu:latest as builder ARG TARGET LABEL org.defichain.name="defichain-builder" LABEL org.defichain.arch=${TARGET} @@ -11,7 +11,10 @@ COPY ./make.sh . RUN export DEBIAN_FRONTEND=noninteractive && ./make.sh pkg_update_base RUN export DEBIAN_FRONTEND=noninteractive && ./make.sh pkg_install_deps +RUN export DEBIAN_FRONTEND=noninteractive && ./make.sh pkg_install_rust RUN export DEBIAN_FRONTEND=noninteractive && ./make.sh pkg_install_deps_armhf +ENV PATH="/root/.cargo/bin:${PATH}" +RUN rustup target add armv7-unknown-linux-gnueabihf COPY . . RUN ./make.sh clean-depends && ./make.sh build-deps diff --git a/contrib/dockerfiles/x86_64-apple-darwin.dockerfile b/contrib/dockerfiles/x86_64-apple-darwin.dockerfile index bd64484409..39a4ab0150 100644 --- a/contrib/dockerfiles/x86_64-apple-darwin.dockerfile +++ b/contrib/dockerfiles/x86_64-apple-darwin.dockerfile @@ -1,7 +1,7 @@ ARG TARGET=x86_64-apple-darwin # ----------- -FROM ubuntu:latest as builder +FROM --platform=linux/amd64 ubuntu:latest as builder ARG TARGET LABEL org.defichain.name="defichain-builder" LABEL org.defichain.arch=${TARGET} @@ -11,7 +11,10 @@ COPY ./make.sh . RUN export DEBIAN_FRONTEND=noninteractive && ./make.sh pkg_update_base RUN export DEBIAN_FRONTEND=noninteractive && ./make.sh pkg_install_deps +RUN export DEBIAN_FRONTEND=noninteractive && ./make.sh pkg_install_rust RUN export DEBIAN_FRONTEND=noninteractive && ./make.sh pkg_install_deps_osx_tools +ENV PATH="/root/.cargo/bin:${PATH}" +RUN rustup target add x86_64-apple-darwin COPY . . RUN ./make.sh clean-depends && ./make.sh build-deps diff --git a/contrib/dockerfiles/x86_64-pc-linux-gnu-clang.dockerfile b/contrib/dockerfiles/x86_64-pc-linux-gnu-clang.dockerfile index cd1e18f61d..96ee972ec7 100644 --- a/contrib/dockerfiles/x86_64-pc-linux-gnu-clang.dockerfile +++ b/contrib/dockerfiles/x86_64-pc-linux-gnu-clang.dockerfile @@ -1,7 +1,7 @@ ARG TARGET=x86_64-pc-linux-gnu # ----------- -FROM debian:10 as builder +FROM --platform=linux/amd64 debian:10 as builder ARG TARGET ARG CLANG_VERSION=15 LABEL org.defichain.name="defichain-builder" @@ -12,7 +12,10 @@ COPY ./make.sh . RUN export DEBIAN_FRONTEND=noninteractive && ./make.sh pkg_update_base RUN export DEBIAN_FRONTEND=noninteractive && ./make.sh pkg_install_deps +RUN export DEBIAN_FRONTEND=noninteractive && ./make.sh pkg_install_rust RUN export DEBIAN_FRONTEND=noninteractive && ./make.sh pkg_install_llvm +ENV PATH="/root/.cargo/bin:${PATH}" +RUN rustup target add x86_64-unknown-linux-gnu COPY . . RUN ./make.sh clean-depends && \ @@ -31,7 +34,7 @@ RUN mkdir /app && cd build/${TARGET} && \ # ----------- ### Actual image that contains defi binaries -FROM debian:10 +FROM --platform=linux/amd64 debian:10 ARG TARGET LABEL org.defichain.name="defichain" LABEL org.defichain.arch=${TARGET} diff --git a/contrib/dockerfiles/x86_64-pc-linux-gnu.dockerfile b/contrib/dockerfiles/x86_64-pc-linux-gnu.dockerfile index 53d8cbbe86..3f1ac80a5e 100644 --- a/contrib/dockerfiles/x86_64-pc-linux-gnu.dockerfile +++ b/contrib/dockerfiles/x86_64-pc-linux-gnu.dockerfile @@ -1,7 +1,7 @@ ARG TARGET=x86_64-pc-linux-gnu # ----------- -FROM ubuntu:latest as builder +FROM --platform=linux/amd64 ubuntu:latest as builder ARG TARGET LABEL org.defichain.name="defichain-builder" LABEL org.defichain.arch=${TARGET} @@ -11,6 +11,9 @@ COPY ./make.sh . RUN export DEBIAN_FRONTEND=noninteractive && ./make.sh pkg_update_base RUN export DEBIAN_FRONTEND=noninteractive && ./make.sh pkg_install_deps +RUN export DEBIAN_FRONTEND=noninteractive && ./make.sh pkg_install_rust +ENV PATH="/root/.cargo/bin:${PATH}" +RUN rustup target add x86_64-unknown-linux-gnu COPY . . RUN ./make.sh clean-depends && ./make.sh build-deps @@ -23,7 +26,7 @@ RUN mkdir /app && cd build/${TARGET} && \ # ----------- ### Actual image that contains defi binaries -FROM ubuntu:latest +FROM --platform=linux/amd64 ubuntu:latest ARG TARGET LABEL org.defichain.name="defichain" LABEL org.defichain.arch=${TARGET} diff --git a/contrib/dockerfiles/x86_64-w64-mingw32.dockerfile b/contrib/dockerfiles/x86_64-w64-mingw32.dockerfile index d6af1ddb85..76a89cbc1c 100644 --- a/contrib/dockerfiles/x86_64-w64-mingw32.dockerfile +++ b/contrib/dockerfiles/x86_64-w64-mingw32.dockerfile @@ -1,7 +1,7 @@ ARG TARGET=x86_64-w64-mingw32 # ----------- -FROM ubuntu:latest as builder +FROM --platform=linux/amd64 ubuntu:latest as builder ARG TARGET LABEL org.defichain.name="defichain-builder" LABEL org.defichain.arch=${TARGET} @@ -11,7 +11,10 @@ COPY ./make.sh . RUN export DEBIAN_FRONTEND=noninteractive && ./make.sh pkg_update_base RUN export DEBIAN_FRONTEND=noninteractive && ./make.sh pkg_install_deps +RUN export DEBIAN_FRONTEND=noninteractive && ./make.sh pkg_install_rust RUN export DEBIAN_FRONTEND=noninteractive && ./make.sh pkg_install_deps_mingw_x86_64 +ENV PATH="/root/.cargo/bin:${PATH}" +RUN rustup target add x86_64-pc-windows-gnu RUN update-alternatives --set x86_64-w64-mingw32-gcc /usr/bin/x86_64-w64-mingw32-gcc-posix RUN update-alternatives --set x86_64-w64-mingw32-g++ /usr/bin/x86_64-w64-mingw32-g++-posix diff --git a/doc/build-quick.md b/doc/build-quick.md index 82c702b0ec..feeddce2c7 100644 --- a/doc/build-quick.md +++ b/doc/build-quick.md @@ -61,7 +61,7 @@ an environment with correct arch and pre-requisites configured. - aarch64-linux-gnu - arm-linux-gnueabihf -- arm-apple-darwin +- aarch64-apple-darwin ## Defined `env` variables diff --git a/lib/Makefile.am b/lib/Makefile.am index 660d7627c1..53a4fda2a6 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -24,4 +24,4 @@ clean-local: $(CARGO) clean \ --manifest-path "$(CARGO_MANIFEST_PATH)" \ --target-dir "$(TARGET_DIR)" && \ - rm -rf $(TARGET_DIR)/{include,lib,src} \ No newline at end of file + rm -rf $(TARGET_DIR)/{include,lib,src} diff --git a/lib/ain-grpc/src/gen/types.rs b/lib/ain-grpc/src/gen/types.rs index 3636b0ed20..dd800c73df 100644 --- a/lib/ain-grpc/src/gen/types.rs +++ b/lib/ain-grpc/src/gen/types.rs @@ -156,150 +156,6 @@ pub struct PubKey { #[derive(Serialize, Deserialize)] #[serde(rename_all = "camelCase")] #[allow(clippy::derive_partial_eq_without_eq)] -pub struct Block { - /// Block hash (same as input, if any) - #[prost(string, tag = "1")] - #[serde(skip_serializing_if = "String::is_empty")] - pub hash: ::prost::alloc::string::String, - /// The number of confirmations, or -1 if the block is not on the main chain - #[prost(int64, tag = "2")] - pub confirmations: i64, - /// Block size - #[prost(uint64, tag = "3")] - pub size: u64, - /// Block size without witness data - #[prost(uint64, tag = "4")] - pub strippedsize: u64, - /// The block weight as defined in BIP 141 - #[prost(uint64, tag = "5")] - pub weight: u64, - /// The block height or index - #[prost(uint64, tag = "6")] - pub height: u64, - /// The block version - #[prost(uint64, tag = "7")] - pub version: u64, - /// The block version in hex - #[prost(string, tag = "8")] - #[serde(skip_serializing_if = "String::is_empty")] - pub version_hex: ::prost::alloc::string::String, - /// The merkle root - #[prost(string, tag = "9")] - #[serde(skip_serializing_if = "String::is_empty")] - pub merkleroot: ::prost::alloc::string::String, - /// List of transaction IDs - #[prost(message, repeated, tag = "10")] - #[serde(skip_serializing_if = "Vec::is_empty")] - pub tx: ::prost::alloc::vec::Vec, - /// The block time in seconds since UNIX epoch - #[prost(uint64, tag = "11")] - pub time: u64, - /// The median block time in seconds since UNIX epoch - #[prost(uint64, tag = "12")] - pub mediantime: u64, - /// The nonce used to generate the block (property exists only when PoW is used) - #[prost(uint64, tag = "13")] - pub nonce: u64, - /// The bits which represent the target difficulty - #[prost(string, tag = "14")] - #[serde(skip_serializing_if = "String::is_empty")] - pub bits: ::prost::alloc::string::String, - /// The difficulty of the block - #[prost(double, tag = "15")] - pub difficulty: f64, - /// Expected number of hashes required to produce the chain up to this block (in hex) - #[prost(string, tag = "16")] - #[serde(skip_serializing_if = "String::is_empty")] - pub chainwork: ::prost::alloc::string::String, - /// Number of transactions in the block - #[prost(uint32, tag = "17")] - pub n_tx: u32, - /// The hash of the previous block - #[prost(string, tag = "18")] - #[serde(skip_serializing_if = "String::is_empty")] - #[serde(rename = "previousblockhash")] - pub previous_block_hash: ::prost::alloc::string::String, - /// The hash of the next block - #[prost(string, tag = "19")] - #[serde(skip_serializing_if = "String::is_empty")] - #[serde(rename = "nextblockhash")] - pub next_block_hash: ::prost::alloc::string::String, - /// DeFiChain fields - #[prost(string, tag = "101")] - #[serde(skip_serializing_if = "String::is_empty")] - pub masternode: ::prost::alloc::string::String, - #[prost(string, tag = "102")] - #[serde(skip_serializing_if = "String::is_empty")] - pub minter: ::prost::alloc::string::String, - #[prost(uint64, tag = "103")] - pub minted_blocks: u64, - #[prost(string, tag = "104")] - #[serde(skip_serializing_if = "String::is_empty")] - pub stake_modifier: ::prost::alloc::string::String, - #[prost(message, repeated, tag = "105")] - #[serde(skip_serializing_if = "Vec::is_empty")] - pub nonutxo: ::prost::alloc::vec::Vec, -} -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Serialize, Deserialize)] -#[serde(rename_all = "PascalCase")] -pub struct NonUtxo { - #[prost(double, tag = "1")] - pub anchor_reward: f64, - #[prost(double, tag = "2")] - pub burnt: f64, - #[prost(double, tag = "3")] - pub incentive_funding: f64, - #[prost(double, tag = "4")] - pub loan: f64, - #[prost(double, tag = "5")] - pub options: f64, - #[prost(double, tag = "6")] - pub unknown: f64, -} -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -#[derive(Serialize, Deserialize)] -#[serde(rename_all = "camelCase")] -#[allow(clippy::derive_partial_eq_without_eq)] -pub struct BlockInput { - /// Block hash - #[prost(string, tag = "1")] - #[serde(skip_serializing_if = "String::is_empty")] - pub blockhash: ::prost::alloc::string::String, - /// 0 for hex-encoded data, 1 for a json object, and 2 for json object with transaction data [default: 1] - #[prost(uint32, tag = "2")] - pub verbosity: u32, -} -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -#[allow(clippy::derive_partial_eq_without_eq)] -pub struct BlockResult { - /// Hex-encoded data for block hash (for verbosity 0) - #[prost(string, tag = "1")] - pub hash: ::prost::alloc::string::String, - /// Block data (for verbosity 1 and 2) - #[prost(message, optional, tag = "2")] - pub block: ::core::option::Option, -} -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -#[derive(Serialize, Deserialize)] -#[serde(rename_all = "camelCase")] -#[allow(clippy::derive_partial_eq_without_eq)] -pub struct BlockHashResult { - /// Hex-encoded data for block hash - #[prost(string, tag = "1")] - #[serde(skip_serializing_if = "String::is_empty")] - pub hash: ::prost::alloc::string::String, -} -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -#[derive(Serialize, Deserialize)] -#[serde(rename_all = "camelCase")] -#[allow(clippy::derive_partial_eq_without_eq)] pub struct EthAccountsResult { /// Accounts #[prost(string, repeated, tag = "1")] @@ -317,27 +173,25 @@ pub struct EthTransactionInfo { #[serde(skip_serializing_if = "String::is_empty")] pub from: ::prost::alloc::string::String, /// The address to which the transaction is addressed - #[prost(string, optional, tag = "2")] - pub to: ::core::option::Option<::prost::alloc::string::String>, + #[prost(string, tag = "2")] + #[serde(skip_serializing_if = "String::is_empty")] + pub to: ::prost::alloc::string::String, /// The integer of gas provided for the transaction execution #[prost(uint64, tag = "3")] pub gas: u64, /// The integer of gas price used for each paid gas encoded as hexadecimal - #[prost(string, tag = "4")] - #[serde(skip_serializing_if = "String::is_empty")] - pub price: ::prost::alloc::string::String, + #[prost(uint64, tag = "4")] + pub price: u64, /// The integer of value sent with this transaction encoded as hexadecimal - #[prost(string, tag = "5")] - #[serde(skip_serializing_if = "String::is_empty")] - pub value: ::prost::alloc::string::String, + #[prost(uint64, tag = "5")] + pub value: u64, /// The hash of the method signature and encoded parameters. #[prost(string, tag = "6")] #[serde(skip_serializing_if = "String::is_empty")] pub data: ::prost::alloc::string::String, /// The integer of a nonce. This allows to overwrite your own pending transactions that use the same nonce. - #[prost(string, tag = "7")] - #[serde(skip_serializing_if = "String::is_empty")] - pub nonce: ::prost::alloc::string::String, + #[prost(uint64, tag = "7")] + pub nonce: u64, } #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -492,11 +346,13 @@ pub struct EthTransactionReceipt { #[serde(rename = "type")] pub field_type: ::prost::alloc::string::String, /// 32 bytes of post-transaction stateroot (pre Byzantium) - #[prost(string, optional, tag = "14")] - pub root: ::core::option::Option<::prost::alloc::string::String>, + #[prost(string, tag = "14")] + #[serde(skip_serializing_if = "String::is_empty")] + pub root: ::prost::alloc::string::String, /// Either 1 (success) or 0 (failure) - #[prost(string, optional, tag = "15")] - pub status: ::core::option::Option<::prost::alloc::string::String>, + #[prost(string, tag = "15")] + #[serde(skip_serializing_if = "String::is_empty")] + pub status: ::prost::alloc::string::String, } #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -814,8 +670,9 @@ pub struct EthEstimateGasInput { #[prost(message, optional, tag = "1")] pub transaction_info: ::core::option::Option, /// Block number in hexadecimal format or the string latest, earliest, pending, safe or finalized - #[prost(string, optional, tag = "2")] - pub block_number: ::core::option::Option<::prost::alloc::string::String>, + #[prost(string, tag = "2")] + #[serde(skip_serializing_if = "String::is_empty")] + pub block_number: ::prost::alloc::string::String, } #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -1255,8 +1112,152 @@ pub struct EthSyncingInfo { #[serde(rename_all = "camelCase")] #[allow(clippy::derive_partial_eq_without_eq)] pub struct EthSyncingResult { - #[prost(bool, optional, tag = "1")] - pub status: ::core::option::Option, + #[prost(bool, tag = "1")] + pub status: bool, #[prost(message, optional, tag = "2")] pub sync_info: ::core::option::Option, } +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +#[derive(Serialize, Deserialize)] +#[serde(rename_all = "camelCase")] +#[allow(clippy::derive_partial_eq_without_eq)] +pub struct Block { + /// Block hash (same as input, if any) + #[prost(string, tag = "1")] + #[serde(skip_serializing_if = "String::is_empty")] + pub hash: ::prost::alloc::string::String, + /// The number of confirmations, or -1 if the block is not on the main chain + #[prost(int64, tag = "2")] + pub confirmations: i64, + /// Block size + #[prost(uint64, tag = "3")] + pub size: u64, + /// Block size without witness data + #[prost(uint64, tag = "4")] + pub strippedsize: u64, + /// The block weight as defined in BIP 141 + #[prost(uint64, tag = "5")] + pub weight: u64, + /// The block height or index + #[prost(uint64, tag = "6")] + pub height: u64, + /// The block version + #[prost(uint64, tag = "7")] + pub version: u64, + /// The block version in hex + #[prost(string, tag = "8")] + #[serde(skip_serializing_if = "String::is_empty")] + pub version_hex: ::prost::alloc::string::String, + /// The merkle root + #[prost(string, tag = "9")] + #[serde(skip_serializing_if = "String::is_empty")] + pub merkleroot: ::prost::alloc::string::String, + /// List of transaction IDs + #[prost(message, repeated, tag = "10")] + #[serde(skip_serializing_if = "Vec::is_empty")] + pub tx: ::prost::alloc::vec::Vec, + /// The block time in seconds since UNIX epoch + #[prost(uint64, tag = "11")] + pub time: u64, + /// The median block time in seconds since UNIX epoch + #[prost(uint64, tag = "12")] + pub mediantime: u64, + /// The nonce used to generate the block (property exists only when PoW is used) + #[prost(uint64, tag = "13")] + pub nonce: u64, + /// The bits which represent the target difficulty + #[prost(string, tag = "14")] + #[serde(skip_serializing_if = "String::is_empty")] + pub bits: ::prost::alloc::string::String, + /// The difficulty of the block + #[prost(double, tag = "15")] + pub difficulty: f64, + /// Expected number of hashes required to produce the chain up to this block (in hex) + #[prost(string, tag = "16")] + #[serde(skip_serializing_if = "String::is_empty")] + pub chainwork: ::prost::alloc::string::String, + /// Number of transactions in the block + #[prost(uint32, tag = "17")] + pub n_tx: u32, + /// The hash of the previous block + #[prost(string, tag = "18")] + #[serde(skip_serializing_if = "String::is_empty")] + #[serde(rename = "previousblockhash")] + pub previous_block_hash: ::prost::alloc::string::String, + /// The hash of the next block + #[prost(string, tag = "19")] + #[serde(skip_serializing_if = "String::is_empty")] + #[serde(rename = "nextblockhash")] + pub next_block_hash: ::prost::alloc::string::String, + /// DeFiChain fields + #[prost(string, tag = "101")] + #[serde(skip_serializing_if = "String::is_empty")] + pub masternode: ::prost::alloc::string::String, + #[prost(string, tag = "102")] + #[serde(skip_serializing_if = "String::is_empty")] + pub minter: ::prost::alloc::string::String, + #[prost(uint64, tag = "103")] + pub minted_blocks: u64, + #[prost(string, tag = "104")] + #[serde(skip_serializing_if = "String::is_empty")] + pub stake_modifier: ::prost::alloc::string::String, + #[prost(message, repeated, tag = "105")] + #[serde(skip_serializing_if = "Vec::is_empty")] + pub nonutxo: ::prost::alloc::vec::Vec, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Serialize, Deserialize)] +#[serde(rename_all = "PascalCase")] +pub struct NonUtxo { + #[prost(double, tag = "1")] + pub anchor_reward: f64, + #[prost(double, tag = "2")] + pub burnt: f64, + #[prost(double, tag = "3")] + pub incentive_funding: f64, + #[prost(double, tag = "4")] + pub loan: f64, + #[prost(double, tag = "5")] + pub options: f64, + #[prost(double, tag = "6")] + pub unknown: f64, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +#[derive(Serialize, Deserialize)] +#[serde(rename_all = "camelCase")] +#[allow(clippy::derive_partial_eq_without_eq)] +pub struct BlockInput { + /// Block hash + #[prost(string, tag = "1")] + #[serde(skip_serializing_if = "String::is_empty")] + pub blockhash: ::prost::alloc::string::String, + /// 0 for hex-encoded data, 1 for a json object, and 2 for json object with transaction data [default: 1] + #[prost(uint32, tag = "2")] + pub verbosity: u32, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +#[allow(clippy::derive_partial_eq_without_eq)] +pub struct BlockResult { + /// Hex-encoded data for block hash (for verbosity 0) + #[prost(string, tag = "1")] + pub hash: ::prost::alloc::string::String, + /// Block data (for verbosity 1 and 2) + #[prost(message, optional, tag = "2")] + pub block: ::core::option::Option, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +#[derive(Serialize, Deserialize)] +#[serde(rename_all = "camelCase")] +#[allow(clippy::derive_partial_eq_without_eq)] +pub struct BlockHashResult { + /// Hex-encoded data for block hash + #[prost(string, tag = "1")] + #[serde(skip_serializing_if = "String::is_empty")] + pub hash: ::prost::alloc::string::String, +} diff --git a/make.sh b/make.sh index 7ef1da5070..96708a6463 100755 --- a/make.sh +++ b/make.sh @@ -225,7 +225,7 @@ package() { echo "> packaging: ${pkg_name} from ${versioned_release_dir}" _ensure_enter_dir "${versioned_release_dir}" - tar --transform "s,^./,${versioned_name}/," -czf "${pkg_path}" ./* + _tar --transform "s,^./,${versioned_name}/," -czf ${pkg_path} ./* _exit_dir echo "> package: ${pkg_path}" @@ -422,7 +422,7 @@ pkg_install_deps() { libboost-filesystem-dev libboost-chrono-dev libboost-test-dev libboost-thread-dev \ libminiupnpc-dev libzmq3-dev libqrencode-dev wget \ libdb-dev libdb++-dev libdb5.3 libdb5.3-dev libdb5.3++ libdb5.3++-dev \ - curl cmake unzip + curl cmake unzip protobuf-compiler _fold_end } @@ -469,14 +469,17 @@ pkg_local_ensure_osx_sysroot() { local release_depends_dir=${DEPENDS_DIR} _ensure_enter_dir "$release_depends_dir/SDKs" - if [[ -d "${sdk_name}" ]]; then return; fi + if [[ -d "${sdk_name}" ]]; then + _exit_dir + return + fi _fold_start "pkg-local-mac-sdk" if [[ ! -f "${pkg}" ]]; then wget https://bitcoincore.org/depends-sources/sdks/${pkg} fi - tar -zxf "${pkg}" + _tar -zxf "${pkg}" rm "${pkg}" 2>/dev/null || true _exit_dir @@ -491,7 +494,7 @@ pkg_install_llvm() { } pkg_install_rust() { - curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | bash -s -- -y } clean_pkg_local_osx_sysroot() { @@ -603,7 +606,13 @@ clean() { _get_default_target() { local default_target="" if [[ "${OSTYPE}" == "darwin"* ]]; then - default_target="x86_64-apple-darwin" + local macos_arch="" + macos_arch=$(uname -m || true) + if [[ "$macos_arch" == "x86_64" ]]; then + default_target="x86_64-apple-darwin" + else + default_target="aarch64-apple-darwin" + fi elif [[ "${OSTYPE}" == "msys" ]]; then default_target="x86_64-w64-mingw32" else @@ -703,6 +712,23 @@ _platform_init() { readlink -m "$@" } fi + + if [[ $(command -v gtar) ]]; then + _tar() { + gtar "$@" + } + else + if [[ $(command -v tar ) ]]; then + _tar() { + tar "$@" + } + else + echo "error: GNU version of tar is required for \`--transform\` support" + echo "tip: debian/ubunti: apt install tar" + echo "tip: osx: brew install gnu-tar" + exit 1 + fi + fi } _nproc() { diff --git a/test/functional/test_framework/test_framework.py b/test/functional/test_framework/test_framework.py index f1e78b4bd2..6097345446 100755 --- a/test/functional/test_framework/test_framework.py +++ b/test/functional/test_framework/test_framework.py @@ -80,14 +80,14 @@ def __new__(cls, clsname, bases, dct): def get_default_config_path(): current_file_path=os.path.abspath(os.path.dirname(os.path.realpath(__file__))) default_config_paths = [ - current_file_path + "/../../../build/test/config.ini", - current_file_path + "/../../config.ini", + # priority build selections for standard dev envs current_file_path + "/../../../build/x86_64-pc-linux-gnu/test/config.ini", + current_file_path + "/../../../build/aarch64-apple-darwin/test/config.ini", + current_file_path + "/../../../build/x86_64-apple-darwin/test/config.ini", + current_file_path + "/../../../build/x86_64-w64-migw32/test/config.ini", + # aarch64 / arm builds current_file_path + "/../../../build/arm-linux-gnueabihf/test/config.ini", current_file_path + "/../../../build/aarch64-linux-gnu/test/config.ini", - current_file_path + "/../../../build/x86_64-w64-mingw32/test/config.ini", - current_file_path + "/../../../build/x86_64-apple-darwin/test/config.ini", - current_file_path + "/../../../build/aarch64-apple-darwin/test/config.ini", ] for p in default_config_paths: if os.path.exists(p):