Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 43 additions & 55 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,18 @@ jobs:
sudo apt update
sudo apt install -y protobuf-compiler
- name: Setup Rust
run: |
# Nightly to be able to use `--report-time` below
rustup install nightly
rustup override set nightly
uses: dtolnay/rust-toolchain@stable
with:
toolchain: nightly
- name: Download circuits files
run: |
git clone --depth 1 https://github.com/openmina/circuit-blobs.git
ln -s -b $PWD/circuit-blobs/* ledger/
make download-circuits
- name: Build ledger tests
run: |
cd ledger
cargo build --release --tests
make build-ledger
- name: Run ledger tests
run: |
cd ledger
cargo test --release -- -Z unstable-options --report-time
make test-ledger

ledger-32x9-tests:
runs-on: ubuntu-22.04
Expand All @@ -53,14 +49,12 @@ jobs:
sudo apt update
sudo apt install -y protobuf-compiler
- name: Setup Rust
run: |
# Nightly to be able to use `--report-time` below
rustup install nightly
rustup override set nightly
uses: dtolnay/rust-toolchain@stable
with:
toolchain: nightly
- name: Download circuits files
run: |
git clone --depth 1 https://github.com/openmina/circuit-blobs.git
ln -s -b $PWD/circuit-blobs/* ledger/
make download-circuits
- name: Enable 32x9 fields implementation
run: |
cargo install sd
Expand All @@ -70,12 +64,10 @@ jobs:
cat ./Cargo.toml
- name: Build ledger tests
run: |
cd ledger
cargo build --release --tests
make build-ledger
- name: Run ledger tests
run: |
cd ledger
cargo test --release -- -Z unstable-options --report-time
make test-ledger

vrf-tests:
runs-on: ubuntu-22.04
Expand All @@ -87,18 +79,15 @@ jobs:
sudo apt update
sudo apt install -y protobuf-compiler
- name: Setup Rust
run: |
# Nightly to be able to use `--report-time` below
rustup install nightly
rustup override set nightly
uses: dtolnay/rust-toolchain@stable
with:
toolchain: nightly
- name: Build vrf tests
run: |
cd vrf
cargo build --release --tests
make build-vrf
- name: Run vrf tests
run: |
cd vrf
cargo test --release -- -Z unstable-options --report-time
make test-vrf

p2p-tests:
runs-on: ubuntu-22.04
Expand All @@ -112,9 +101,10 @@ jobs:
sudo apt install -y protobuf-compiler

- name: Setup Rust
run: |
rustup default 1.84
rustup component add rustfmt
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt
toolchain: 1.84

- name: Setup Rust Cache
uses: Swatinem/rust-cache@v2
Expand All @@ -123,8 +113,7 @@ jobs:

- name: Test p2p crate
run: |
cargo test -p p2p --tests

make test-p2p

build:
runs-on: ubuntu-22.04
Expand All @@ -138,9 +127,10 @@ jobs:
sudo apt install -y protobuf-compiler

- name: Setup Rust
run: |
rustup default 1.84
rustup component add rustfmt
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt
toolchain: 1.84

- name: Setup Rust Cache
uses: Swatinem/rust-cache@v2
Expand All @@ -149,7 +139,7 @@ jobs:

- name: Release build
run: |
cargo build --release --bin openmina
make build-release

- name: Upload binaries
uses: actions/upload-artifact@v4
Expand All @@ -169,9 +159,13 @@ jobs:
sudo apt install -y protobuf-compiler

- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, rust-src
toolchain: nightly

- name: Install wasm32 and wasm-bindgen-cli
run: |
rustup default nightly
rustup component add rustfmt rust-src
rustup target add wasm32-unknown-unknown
cargo install -f wasm-bindgen-cli --version 0.2.99

Expand All @@ -182,10 +176,7 @@ jobs:

- name: Release build
run: |
cd node/web
rustup component add rust-src rustfmt --toolchain nightly-x86_64-unknown-linux-gnu
cargo +nightly build --release --target wasm32-unknown-unknown
wasm-bindgen --keep-debug --web --out-dir pkg ../../target/wasm32-unknown-unknown/release/openmina_node_web.wasm
make build-wasm

build-tests:
runs-on: ubuntu-22.04
Expand All @@ -199,9 +190,10 @@ jobs:
sudo apt install -y protobuf-compiler

- name: Setup Rust
run: |
rustup default 1.84
rustup component add rustfmt
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt
toolchain: 1.84

- name: Setup Rust Cache
uses: Swatinem/rust-cache@v2
Expand Down Expand Up @@ -235,9 +227,10 @@ jobs:
sudo apt install -y protobuf-compiler

- name: Setup Rust
run: |
rustup default 1.84
rustup component add rustfmt
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt
toolchain: 1.84

- name: Setup Rust Cache
uses: Swatinem/rust-cache@v2
Expand All @@ -246,12 +239,7 @@ jobs:

- name: Build tests
run: |
mkdir -p target/release/tests

cargo build --release --features=scenario-generators,p2p-webrtc --package=openmina-node-testing --tests
cargo build --release --features=scenario-generators,p2p-webrtc --package=openmina-node-testing --tests --message-format=json > cargo-build-test.json
jq -r '. | select(.executable != null and (.target.kind | (contains(["test"])))) | [.target.name, .executable ] | @tsv' cargo-build-test.json > tests.tsv
while read NAME FILE; do cp -a $FILE target/release/tests/webrtc_$NAME; done < tests.tsv
make build-tests-webrtc

- name: Upload tests
uses: actions/upload-artifact@v4
Expand Down
10 changes: 9 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
/target
/node/testing/res/
circuit-blobs
.DS_Store
*.profraw
node_modules
node_modules

# Output of build-wasm
pkg/

# Outputs of build-tests-webrtc
cargo-build-test.json
tests.tsv
74 changes: 66 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# OpenMina Makefile

NIGHTLY_RUST_VERSION = "nightly"

.PHONY: help
help: ## Ask for help!
@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
Expand All @@ -8,17 +10,45 @@ help: ## Ask for help!
build: ## Build the project in debug mode
cargo build

.PHONY: build-ledger
build-ledger: download-circuits ## Build the ledger binary and library, requires nightly Rust
@cd ledger && cargo +nightly build --release --tests

.PHONY: build-release
build-release: ## Build the project in release mode
cargo build --release --bin openmina

.PHONY: build-tests
build-tests: ## Build test binaries
cargo build --release --tests --package=openmina-node-testing --package=cli
.PHONY: build-tests-webrtc
build-tests-webrtc: ## Build tests for WebRTC
@mkdir -p target/release/tests
@cargo build --release --tests \
--package=openmina-node-testing \
--package=cli
# Update ./.gitignore accordingly if cargo-build-test.json is changed
@cargo build --release \
--features=scenario-generators,p2p-webrtc \
--package=openmina-node-testing \
--tests \
--message-format=json \
> cargo-build-test.json
# Update ./.gitignore accordingly if tests.json is changed
@jq -r '. | select(.executable != null and (.target.kind | (contains(["test"])))) | [.target.name, .executable ] | @tsv' cargo-build-test.json > tests.tsv
@while read NAME FILE; do \
cp -a $$FILE target/release/tests/webrtc_$$NAME; \
done < tests.tsv

.PHONY: build-vrf
build-vrf: ## Build the VRF package
@cd vrf && cargo +nightly build --release --tests

.PHONY: build-wasm
build-wasm: ## Build WebAssembly node
cd node/web && cargo +nightly build --release --target wasm32-unknown-unknown
@cd node/web && cargo +nightly build \
--release --target wasm32-unknown-unknown
# Update ./.gitignore accordingly if the out-dir is changed
@wasm-bindgen --keep-debug --web \
--out-dir pkg \
target/wasm32-unknown-unknown/release/openmina_node_web.wasm

.PHONY: check
check: ## Check code for compilation errors
Expand All @@ -42,6 +72,15 @@ check-md: ## Check if markdown files are properly formatted
clean: ## Clean build artifacts
cargo clean

.PHONY: download-circuits
download-circuits: ## Download the circuits used by Mina from GitHub
@if [ ! -d "circuit-blobs" ]; then \
git clone --depth 1 https://github.com/openmina/circuit-blobs.git; \
ln -s -b "$$PWD"/circuit-blobs/* ledger/; \
else \
echo "circuit-blobs already exists, skipping download."; \
fi

.PHONY: format
format: ## Format code using rustfmt
cargo +nightly fmt
Expand All @@ -56,13 +95,32 @@ format-md: ## Format all markdown files to wrap at 80 characters
lint: ## Run linter (clippy)
cargo clippy --all-targets -- -D warnings --allow clippy::mutable_key_type

.PHONY: setup-wasm-toolchain
setup-wasm-toolchain: ## Setup the WebAssembly toolchain, using nightly
@ARCH=$$(uname -m); \
OS=$$(uname -s | tr A-Z a-z); \
case $$OS in \
linux) OS_PART="unknown-linux-gnu" ;; \
darwin) OS_PART="apple-darwin" ;; \
*) echo "Unsupported OS: $$OS" && exit 1 ;; \
esac; \
case $$ARCH in \
x86_64) ARCH_PART="x86_64" ;; \
aarch64) ARCH_PART="aarch64" ;; \
arm64) ARCH_PART="aarch64" ;; \
*) echo "Unsupported architecture: $$ARCH" && exit 1 ;; \
esac; \
TARGET="$$ARCH_PART-$$OS_PART"; \
echo "Installing rust-src and rustfmt for ${NIGHTLY_RUST_VERSION}-$$TARGET with wasm32 target"; \
rustup target add wasm32-unknown-unknown --toolchain ${NIGHTLY_RUST_VERSION}-$$TARGET

.PHONY: test
test: ## Run tests
cargo test

.PHONY: test-ledger
test-ledger: ## Run ledger tests
cd ledger && cargo test --release
test-ledger: build-ledger ## Run ledger tests in release mode, requires nightly Rust
@cd ledger && cargo +nightly test --release -- -Z unstable-options --report-time

.PHONY: test-p2p
test-p2p: ## Run P2P tests
Expand All @@ -73,5 +131,5 @@ test-release: ## Run tests in release mode
cargo test --release

.PHONY: test-vrf
test-vrf: ## Run VRF tests
cd vrf && cargo test --release
test-vrf: ## Run VRF tests, requires nightly Rust
@cd vrf && cargo +nightly test --release -- -Z unstable-options --report-time
Loading