Skip to content

Commit

Permalink
Fix docs, CI fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
nazar-pc committed Dec 27, 2023
1 parent 4b91199 commit 1e88a23
Show file tree
Hide file tree
Showing 15 changed files with 162 additions and 67 deletions.
14 changes: 12 additions & 2 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ env:

jobs:
cargo-fmt:
runs-on: ${{ fromJson(github.repository_owner == 'subspace' && '["self-hosted", "ubuntu-20.04-x86-64"]' || 'ubuntu-22.04') }}
runs-on: ${{ fromJson(github.repository_owner == 'subspace' && '["self-hosted", "ubuntu-20.04-x86-64"]' || '"ubuntu-22.04"') }}

steps:
- name: Checkout
Expand Down Expand Up @@ -91,6 +91,11 @@ jobs:
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}

# Needed for hwloc
- name: Install automake (macOS)
run: brew install automake
if: runner.os == 'macOS'

# Workaround to resolve link error with C:\msys64\mingw64\bin\libclang.dll
- name: Remove msys64
run: Remove-Item -LiteralPath "C:\msys64\" -Force -Recurse
Expand All @@ -113,7 +118,7 @@ jobs:
args: --locked --all-targets --features "runtime-benchmarks" -- -D warnings

cargo-docs:
runs-on: ${{ fromJson(github.repository_owner == 'subspace' && '["self-hosted", "ubuntu-20.04-x86-64"]' || 'ubuntu-22.04') }}
runs-on: ${{ fromJson(github.repository_owner == 'subspace' && '["self-hosted", "ubuntu-20.04-x86-64"]' || '"ubuntu-22.04"') }}
steps:
- name: Checkout
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # @v3.1.0
Expand Down Expand Up @@ -170,6 +175,11 @@ jobs:
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}

# Needed for hwloc
- name: Install automake (macOS)
run: brew install automake
if: runner.os == 'macOS'

# Workaround to resolve link error with C:\msys64\mingw64\bin\libclang.dll
- name: Remove msys64
run: Remove-Item -LiteralPath "C:\msys64\" -Force -Recurse
Expand Down
60 changes: 50 additions & 10 deletions .github/workflows/snapshot-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ env:

jobs:
container-linux:
runs-on: ${{ fromJson(github.repository_owner == 'subspace' && '["self-hosted", "ubuntu-20.04-x86-64"]' || 'ubuntu-22.04') }}
runs-on: ${{ fromJson(github.repository_owner == 'subspace' && '["self-hosted", "ubuntu-20.04-x86-64"]' || '"ubuntu-22.04"') }}
permissions:
contents: write
packages: write
Expand Down Expand Up @@ -84,35 +84,35 @@ jobs:
strategy:
matrix:
build:
- os: ${{ fromJson(github.repository_owner == 'subspace' && '["self-hosted", "ubuntu-20.04-x86-64"]' || 'ubuntu-20.04') }}
- os: ${{ fromJson(github.repository_owner == 'subspace' && '["self-hosted", "ubuntu-20.04-x86-64"]' || '"ubuntu-20.04"') }}
target: x86_64-unknown-linux-gnu
suffix: ubuntu-x86_64-skylake-${{ github.ref_name }}
rustflags: "-C target-cpu=skylake"
- os: ${{ fromJson(github.repository_owner == 'subspace' && '["self-hosted", "ubuntu-20.04-x86-64"]' || 'ubuntu-20.04') }}
- os: ${{ fromJson(github.repository_owner == 'subspace' && '["self-hosted", "ubuntu-20.04-x86-64"]' || '"ubuntu-20.04"') }}
target: x86_64-unknown-linux-gnu
suffix: ubuntu-x86_64-v2-${{ github.ref_name }}
rustflags: "-C target-cpu=x86-64-v2 -C target-feature=+aes"
- os: ${{ fromJson(github.repository_owner == 'subspace' && '["self-hosted", "ubuntu-20.04-x86-64"]' || 'ubuntu-20.04') }}
- os: ${{ fromJson(github.repository_owner == 'subspace' && '["self-hosted", "ubuntu-20.04-x86-64"]' || '"ubuntu-20.04"') }}
target: aarch64-unknown-linux-gnu
suffix: ubuntu-aarch64-${{ github.ref_name }}
# TODO: AES flag is such that we have decent performance on ARMv8, remove once `aes` crate bumps MSRV to
# at least 1.61: https://github.com/RustCrypto/block-ciphers/issues/373
rustflags: "-C linker=aarch64-linux-gnu-gcc --cfg aes_armv8"
- os: ${{ fromJson(github.repository_owner == 'subspace' && '["self-hosted", "macos-12-arm64"]' || 'macos-12') }}
- os: ${{ fromJson(github.repository_owner == 'subspace' && '["self-hosted", "macos-12-arm64"]' || '"macos-12"') }}
target: aarch64-apple-darwin
suffix: macos-aarch64-${{ github.ref_name }}
# TODO: AES flag is such that we have decent performance on ARMv8, remove once `aes` crate bumps MSRV to
# at least 1.61: https://github.com/RustCrypto/block-ciphers/issues/373
rustflags: "--cfg aes_armv8"
- os: ${{ fromJson(github.repository_owner == 'subspace' && '["self-hosted", "macos-12-arm64"]' || 'macos-12') }}
- os: ${{ fromJson(github.repository_owner == 'subspace' && '["self-hosted", "macos-12-arm64"]' || '"macos-12"') }}
target: x86_64-apple-darwin
suffix: macos-x86_64-${{ github.ref_name }}
rustflags: ""
- os: ${{ fromJson(github.repository_owner == 'subspace' && '["self-hosted", "windows-server-2022-x86-64"]' || 'windows-2022') }}
- os: ${{ fromJson(github.repository_owner == 'subspace' && '["self-hosted", "windows-server-2022-x86-64"]' || '"windows-2022"') }}
target: x86_64-pc-windows-msvc
suffix: windows-x86_64-skylake-${{ github.ref_name }}
rustflags: "-C target-cpu=skylake"
- os: ${{ fromJson(github.repository_owner == 'subspace' && '["self-hosted", "windows-server-2022-x86-64"]' || 'windows-2022') }}
- os: ${{ fromJson(github.repository_owner == 'subspace' && '["self-hosted", "windows-server-2022-x86-64"]' || '"windows-2022"') }}
target: x86_64-pc-windows-msvc
suffix: windows-x86_64-v2-${{ github.ref_name }}
rustflags: "-C target-cpu=x86-64-v2 -C target-feature=+aes"
Expand Down Expand Up @@ -148,6 +148,11 @@ jobs:
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}

# Needed for hwloc
- name: Install automake (macOS)
run: brew install automake
if: runner.os == 'macOS'

# Workaround to resolve link error with C:\msys64\mingw64\bin\libclang.dll
- name: Remove msys64
run: Remove-Item -LiteralPath "C:\msys64\" -Force -Recurse
Expand All @@ -156,14 +161,49 @@ jobs:
continue-on-error: true

- name: AArch64 cross-compile packages
run: sudo apt-get update && sudo apt-get install -y --no-install-recommends g++-aarch64-linux-gnu gcc-aarch64-linux-gnu libc6-dev-arm64-cross
run: |
FLAVOR="$(lsb_release -sc)"
sudo tee /etc/apt/sources.list.d/arm64.list <<LIST
deb [arch=arm64] http://ports.ubuntu.com/ ${FLAVOR} main restricted
deb [arch=arm64] http://ports.ubuntu.com/ ${FLAVOR}-updates main restricted
deb [arch=arm64] http://ports.ubuntu.com/ ${FLAVOR} universe
deb [arch=arm64] http://ports.ubuntu.com/ ${FLAVOR}-updates universe
deb [arch=arm64] http://ports.ubuntu.com/ ${FLAVOR} multiverse
deb [arch=arm64] http://ports.ubuntu.com/ ${FLAVOR}-updates multiverse
deb [arch=arm64] http://ports.ubuntu.com/ ${FLAVOR}-backports main restricted universe multiverse
LIST
sudo sed -i 's/deb http/deb [arch=amd64] http/' /etc/apt/sources.list
# GitHub runners use mirror file
sudo sed -i 's/deb mirror/deb [arch=amd64] mirror/' /etc/apt/sources.list
sudo dpkg --add-architecture arm64
sudo apt-get update
# zlib1g-dev:arm64 is only necessary because amd64 version is present on the host and cross-compilation of
# hwlocality-sys fails otherwise
sudo apt-get install -y --no-install-recommends \
g++-aarch64-linux-gnu \
gcc-aarch64-linux-gnu \
libc6-dev-arm64-cross \
zlib1g-dev:arm64
echo "PKG_CONFIG_ALLOW_CROSS=true" >> $GITHUB_ENV
if: matrix.build.target == 'aarch64-unknown-linux-gnu'

- name: Build farmer
- name: Build farmer (Linux and Windows)
uses: actions-rs/cargo@ae10961054e4aa8b4aa7dffede299aaf087aa33b # @v1.0.1
with:
command: build
args: --locked -Z build-std --target ${{ matrix.build.target }} --profile production --bin subspace-farmer
if: runner.os != 'macOS'

# We build macOS without `numa` feature, primarily because of https://github.com/HadrienG2/hwlocality/issues/31
- name: Build farmer (macOS)
uses: actions-rs/cargo@ae10961054e4aa8b4aa7dffede299aaf087aa33b # @v1.0.1
with:
command: build
args: --locked -Z build-std --target ${{ matrix.build.target }} --profile production --bin subspace-farmer --no-default-features
if: runner.os == 'macOS'

- name: Build node
uses: actions-rs/cargo@ae10961054e4aa8b4aa7dffede299aaf087aa33b # @v1.0.1
Expand Down
10 changes: 6 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion Dockerfile-bootstrap-node
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ RUN \
git \
llvm \
clang \
cmake \
automake \
libtool \
pkg-config \
make && \
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain $RUSTC_VERSION

Expand Down
5 changes: 4 additions & 1 deletion Dockerfile-bootstrap-node.aarch64
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ RUN \
git \
llvm \
clang \
cmake \
automake \
libtool \
pkg-config \
make && \
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain $RUSTC_VERSION

Expand All @@ -39,6 +41,7 @@ COPY test /code/test
# Up until this line all Rust images in this repo should be the same to share the same layers

ENV RUSTFLAGS="${RUSTFLAGS} -C linker=aarch64-linux-gnu-gcc"
ENV PKG_CONFIG_ALLOW_CROSS=true

# Dependencies necessary for successful cross-compilation
RUN \
Expand Down
4 changes: 3 additions & 1 deletion Dockerfile-farmer
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ RUN \
git \
llvm \
clang \
cmake \
automake \
libtool \
pkg-config \
make && \
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain $RUSTC_VERSION

Expand Down
5 changes: 4 additions & 1 deletion Dockerfile-farmer.aarch64
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ RUN \
git \
llvm \
clang \
cmake \
automake \
libtool \
pkg-config \
make && \
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain $RUSTC_VERSION

Expand All @@ -39,6 +41,7 @@ COPY test /code/test
# Up until this line all Rust images in this repo should be the same to share the same layers

ENV RUSTFLAGS="${RUSTFLAGS} -C linker=aarch64-linux-gnu-gcc"
ENV PKG_CONFIG_ALLOW_CROSS=true

# Dependencies necessary for successful cross-compilation
RUN \
Expand Down
4 changes: 3 additions & 1 deletion Dockerfile-node
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ RUN \
git \
llvm \
clang \
cmake \
automake \
libtool \
pkg-config \
make && \
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain $RUSTC_VERSION

Expand Down
5 changes: 4 additions & 1 deletion Dockerfile-node.aarch64
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ RUN \
git \
llvm \
clang \
cmake \
automake \
libtool \
pkg-config \
make && \
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain $RUSTC_VERSION

Expand All @@ -39,6 +41,7 @@ COPY test /code/test
# Up until this line all Rust images in this repo should be the same to share the same layers

ENV RUSTFLAGS="${RUSTFLAGS} -C linker=aarch64-linux-gnu-gcc"
ENV PKG_CONFIG_ALLOW_CROSS=true

# Dependencies necessary for successful cross-compilation
RUN \
Expand Down
5 changes: 4 additions & 1 deletion Dockerfile-runtime
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,14 @@ RUN \
apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
ca-certificates \
protobuf-compiler \
curl \
git \
llvm \
clang \
cmake \
automake \
libtool \
pkg-config \
make && \
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain $RUSTC_VERSION

Expand Down
3 changes: 1 addition & 2 deletions crates/subspace-farmer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ fdlimit = "0.3.0"
fs4 = "0.7.0"
futures = "0.3.29"
hex = { version = "0.4.3", features = ["serde"] }
# TODO: Upgrade to crates.io version once it is published
hwlocality = { git = "https://github.com/HadrienG2/hwlocality", rev = "3141847b0a463f38adcf623a2d720931757a38ae", features = ["bundled"], optional = true }
hwlocality = { version = "1.0.0-alpha.1", features = ["vendored"], optional = true }
jsonrpsee = { version = "0.16.3", features = ["client"] }
lru = "0.11.0"
mimalloc = "0.1.39"
Expand Down
35 changes: 33 additions & 2 deletions crates/subspace-farmer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,42 @@ It is recommended to follow general farming instructions that explain how to run

Rust toolchain is expected to be installed for anything in this repository to compile, but there are some extra dependencies for farmer specifically.

Autotools and `libtool` on Linux/macOS or CMake on Windows for `hwlocality-sys` (if `numa` features is enabled, it is by default), also LLVM/Clang is necessary:
`automake`,`libtool` and `pkg-config` on Linux/macOS or CMake on Windows for `hwlocality-sys` (if `numa` features is enabled, it is by default), also LLVM/Clang is necessary.

### Ubuntu

```bash
sudo apt-get install automake libtool pkg-config llvm clang
```

### macOS

1. Install via Homebrew:

```bash
brew install automake libtool llvm@15 clang
```

2. Add `llvm` to your `~/.zshrc` or `~/.bashrc`:

```bash
export PATH="/opt/homebrew/opt/llvm@15/bin:$PATH"
```

3. Activate the changes:

```bash
sudo apt-get install llvm clang libtool
source ~/.zshrc
```

4. Verify that `llvm` is installed:

```bash
llvm-config --version
```

### Build

Then build the farmer using Cargo:
```
cargo build --profile production --bin subspace-farmer
Expand Down
34 changes: 32 additions & 2 deletions crates/subspace-node/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,42 @@ It is recommended to follow general farming instructions that explain how to run

Rust toolchain is expected to be installed for anything in this repository to compile, but there are some extra dependencies for farmer specifically.

Prost library from libp2p dependency needs CMake, also LLVM/Clang and `make` are necessary:
### Ubuntu

LLVM/Clang and `make` are necessary:
```bash
sudo apt-get install llvm clang cmake make
```

Then build the farmer using Cargo:
### macOS

1. Install via Homebrew:

```bash
brew install llvm@15 clang cmake make
```

2. Add `llvm` to your `~/.zshrc` or `~/.bashrc`:

```bash
export PATH="/opt/homebrew/opt/llvm@15/bin:$PATH"
```

3. Activate the changes:

```bash
source ~/.zshrc
```

4. Verify that `llvm` is installed:

```bash
llvm-config --version
```

### Build

Then build the node using Cargo:
```
cargo build --profile production --bin subspace-node
target/production/subspace-node --version
Expand Down

0 comments on commit 1e88a23

Please sign in to comment.