Skip to content

Commit

Permalink
feat: Splitting rust workspace into main and sealevel (#4438)
Browse files Browse the repository at this point in the history
### Description

The single rust workspace has been split into 2 workspaces. The sealevel
workspace includes the contents of the previous `sealevel` folder and
the main workspace includes everything else.

The workspaces differ in rust versions as the sealevel has the old one
to ensure compatability, the main workspace has and updated `rustc`
version of `1.80.1`.

Some dependencies and sub-dependencies have been locked in versions of
the old pre-split workspace to ensure no breaking code changes.

The rust CI workflow has been updated to include both workspaces in the
tests.

### Drive-by changes

N/A

### Related issues

Relates to
#4361

### Backward compatibility

No.

### Testing

Rust Unit tests from the CI
  • Loading branch information
Mantas-M authored Sep 12, 2024
1 parent 1a8cc27 commit 096aeff
Show file tree
Hide file tree
Showing 424 changed files with 11,699 additions and 3,242 deletions.
2 changes: 1 addition & 1 deletion .codespell/.codespellrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[codespell]
skip = .git,node_modules,yarn.lock,Cargo.lock,./typescript/helloworld,./rust/config,./rust/sealevel/environments/mainnet3/chain-config.json
skip = .git,node_modules,yarn.lock,Cargo.lock,./typescript/helloworld,./rust/main/config,./rust/sealevel/environments/mainnet3/chain-config.json
count =
quiet-level = 3
ignore-words = ./.codespell/ignore.txt
62 changes: 38 additions & 24 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ on:
push:
branches: [main]
paths:
- 'rust/**'
- 'rust/main/**'
- 'rust/sealevel/**'
- .github/workflows/rust.yml
pull_request:
branches: [main]
paths:
- 'rust/**'
- 'rust/main/**'
- 'rust/sealevel/**'
- .github/workflows/rust.yml
# Support for merge queues
merge_group:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

concurrency:
Expand All @@ -24,10 +24,6 @@ env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: full

defaults:
run:
working-directory: ./rust

jobs:
test-rs:
runs-on: buildjet-8vcpu-ubuntu-2204
Expand All @@ -42,21 +38,25 @@ jobs:
- name: rust cache
uses: Swatinem/rust-cache@v2
with:
prefix-key: "v3"
shared-key: "rust"
cache-provider: "buildjet"
prefix-key: 'v3'
shared-key: 'rust'
cache-provider: 'buildjet'
save-if: ${{ !startsWith(github.ref, 'refs/heads/gh-readonly-queue') }}
workspaces: |
./rust
./rust/main
./rust/sealevel
- name: Free disk space
run: |
# Based on https://github.com/actions/runner-images/issues/2840#issuecomment-790492173
sudo rm -rf /usr/share/dotnet
sudo rm -rf /opt/ghc
sudo rm -rf "/usr/local/share/boost"
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
- name: Run tests
- name: Run tests for main workspace
run: cargo test
working-directory: ./rust/main
- name: Run tests for sealevel workspace
run: cargo test
working-directory: ./rust/sealevel

lint-rs:
runs-on: buildjet-8vcpu-ubuntu-2204
Expand All @@ -73,26 +73,40 @@ jobs:
- name: rust cache
uses: Swatinem/rust-cache@v2
with:
prefix-key: "v3"
shared-key: "rust"
cache-provider: "buildjet"
prefix-key: 'v3'
shared-key: 'rust'
cache-provider: 'buildjet'
save-if: ${{ !startsWith(github.ref, 'refs/heads/gh-readonly-queue') }}
workspaces: |
./rust
./rust/main
./rust/sealevel
- name: Free disk space
run: |
# Based on https://github.com/actions/runner-images/issues/2840#issuecomment-790492173
sudo rm -rf /usr/share/dotnet
sudo rm -rf /opt/ghc
sudo rm -rf "/usr/local/share/boost"
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
- name: Check
- name: Check for main workspace
run: cargo check --release --all-features --all-targets
- name: Rustfmt
working-directory: ./rust/main
- name: Check for sealevel workspace
run: cargo check --release --all-features --all-targets
working-directory: ./rust/sealevel
- name: Rustfmt for main workspace
run: cargo fmt --all -- --check
- name: Clippy
working-directory: ./rust/main
- name: Rustfmt for sealevel workspace
run: cargo fmt --all --check
working-directory: ./rust/sealevel
- name: Clippy for main workspace
run: cargo clippy -- -D warnings
working-directory: ./rust/main
- name: Clippy for sealevel workspace
run: cargo clippy -- -D warnings
- name: Setup WASM
working-directory: ./rust/sealevel
- name: Setup WASM for main workspace
run: rustup target add wasm32-unknown-unknown
- name: Check WASM
working-directory: ./rust/main
- name: Check WASM for hyperlane-core
run: cargo check --release -p hyperlane-core --features=strum,test-utils --target wasm32-unknown-unknown
working-directory: ./rust/main
21 changes: 16 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -172,12 +172,23 @@ jobs:
- name: rust cache
uses: Swatinem/rust-cache@v2
with:
prefix-key: "v1-${{ runner.os }}-rust-cache"
prefix-key: 'v2-rust-main'
shared-key: ${{ matrix.e2e-type }}
cache-provider: "buildjet"
cache-provider: 'buildjet'
save-if: ${{ !startsWith(github.ref, 'refs/heads/gh-readonly-queue') }}
workspaces: |
./rust
./rust/main
- name: rust cache
uses: Swatinem/rust-cache@v2
if: matrix.e2e-type == 'non-cosmwasm'
with:
prefix-key: 'v2-rust-sealevel'
shared-key: ${{ matrix.e2e-type }}
cache-provider: 'buildjet'
save-if: ${{ !startsWith(github.ref, 'refs/heads/gh-readonly-queue') }}
workspaces: |
./rust/sealevel
- name: Free disk space
run: |
Expand Down Expand Up @@ -209,14 +220,14 @@ jobs:
- name: agent tests (CosmWasm)
run: cargo test --release --package run-locally --bin run-locally --features cosmos test-utils -- cosmos::test --nocapture
if: matrix.e2e-type == 'cosmwasm'
working-directory: ./rust
working-directory: ./rust/main
env:
RUST_BACKTRACE: 'full'

- name: agent tests (EVM and Sealevel)
run: cargo run --release --bin run-locally --features test-utils
if: matrix.e2e-type == 'non-cosmwasm'
working-directory: ./rust
working-directory: ./rust/main
env:
E2E_CI_MODE: 'true'
E2E_CI_TIMEOUT_SEC: '600'
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ yarn-error.log

.idea
**/*.ignore
.vscode
/.vscode
!/.vscode/*

tsconfig.editor.json
35 changes: 19 additions & 16 deletions rust/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,26 @@ RUN apt-get update && \
apt-get install -y musl-tools clang && \
rustup target add x86_64-unknown-linux-musl

RUN mkdir rust
RUN mkdir -p rust/main
RUN mkdir -p rust/sealevel

# Add workspace to workdir
COPY rust/agents rust/agents
COPY rust/chains rust/chains
COPY rust/hyperlane-base rust/hyperlane-base
COPY rust/hyperlane-core rust/hyperlane-core
COPY rust/hyperlane-test rust/hyperlane-test
COPY rust/ethers-prometheus rust/ethers-prometheus
COPY rust/utils rust/utils
COPY rust/main/agents rust/main/agents
COPY rust/main/chains rust/main/chains
COPY rust/main/hyperlane-base rust/main/hyperlane-base
COPY rust/main/hyperlane-core rust/main/hyperlane-core
COPY rust/main/hyperlane-test rust/main/hyperlane-test
COPY rust/main/ethers-prometheus rust/main/ethers-prometheus
COPY rust/main/utils rust/main/utils
COPY rust/sealevel rust/sealevel

COPY rust/Cargo.toml rust/.
COPY rust/Cargo.lock rust/.
COPY rust/main/Cargo.toml rust/main/.
COPY rust/main/Cargo.toml rust/main/.
COPY rust/sealevel/Cargo.lock rust/sealevel/.
COPY rust/sealevel/Cargo.lock rust/sealevel/.

COPY .git .git

WORKDIR /usr/src/rust
WORKDIR /usr/src/rust/main

# Build binaries
RUN \
Expand All @@ -35,9 +37,9 @@ RUN \
--mount=id=cargo-home-git,type=cache,sharing=locked,target=/usr/local/cargo/git \
RUSTFLAGS="--cfg tokio_unstable" cargo build --release --bin validator --bin relayer --bin scraper && \
mkdir -p /release && \
cp /usr/src/rust/target/release/validator /release && \
cp /usr/src/rust/target/release/relayer /release && \
cp /usr/src/rust/target/release/scraper /release
cp /usr/src/rust/main/target/release/validator /release && \
cp /usr/src/rust/main/target/release/relayer /release && \
cp /usr/src/rust/main/target/release/scraper /release

## 2: Copy the binaries to release image
FROM ubuntu:22.04
Expand All @@ -49,7 +51,8 @@ RUN apt-get update && \
rm -rf /var/lib/apt/lists/*

WORKDIR /app
COPY rust/config ./config
RUN mkdir -p /app/config
COPY rust/main/config /app/config
COPY --from=builder /release/* .

RUN chmod 777 /app && \
Expand Down
Loading

0 comments on commit 096aeff

Please sign in to comment.