Skip to content

fix(quasar/pulsar): DoS bound is 1-based (PartyID <= ValidatorSetSize) #999

fix(quasar/pulsar): DoS bound is 1-based (PartyID <= ValidatorSetSize)

fix(quasar/pulsar): DoS bound is 1-based (PartyID <= ValidatorSetSize) #999

Workflow file for this run

name: CI
on:
push:
branches: [main]
tags:
- 'v*'
pull_request:
branches: [main]
permissions:
contents: read
jobs:
test:
name: Test
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.26.4"
cache: true
- name: Get dependencies
run: go mod download
- name: Run tests
timeout-minutes: 20
run: go test -v -race -timeout=15m -coverprofile=coverage.txt -covermode=atomic ./...
- name: Upload coverage
uses: codecov/codecov-action@v4
with:
file: ./coverage.txt
flags: unittests
token: ${{ secrets.CODECOV_TOKEN }}
benchmark:
name: Benchmark
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.26.4"
cache: true
- name: Get dependencies
run: go mod download
- name: Build consensus tool
run: go build -o bin/consensus ./cmd/consensus
- name: Run consensus benchmarks
timeout-minutes: 10
run: |
echo "=== Running Fast Consensus Benchmarks (core + protocol only) ==="
echo "Note: Full benchmarks including engine/BFT run in benchmark.yml workflow"
go test -bench=. -benchmem -benchtime=100ms -timeout=8m -run=^$ $(go list ./... | grep -E '^github.com/luxfi/consensus/(core|protocol|utils)') | tee consensus-benchmark-results.txt || true
- name: Display consensus benchmark results
run: |
echo "## Consensus Benchmark Results" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
cat consensus-benchmark-results.txt >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
- name: Run consensus demo
run: |
echo "## Consensus Demo" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### 5-node consensus" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
./bin/consensus -nodes 5 -rounds 5 >> $GITHUB_STEP_SUMMARY || true
echo '```' >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
- name: Upload benchmark results
uses: actions/upload-artifact@v4
with:
name: benchmark-results
path: |
consensus-benchmark-results.txt
- name: Comment PR with benchmark results
if: github.event_name == 'pull_request'
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const consensusResults = fs.readFileSync('consensus-benchmark-results.txt', 'utf8');
const comment = `## Benchmark Results
### Consensus Benchmarks
\`\`\`
${consensusResults}
\`\`\``;
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: comment
});
test-c:
name: Test C
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install dependencies
run: sudo apt-get update && sudo apt-get install -y build-essential
- name: Build C library
working-directory: pkg/c
run: make all
- name: Run C tests
working-directory: pkg/c
run: make test
test-rust:
name: Test Rust
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Build C library (Rust depends on it)
working-directory: pkg/c
run: make all
- name: Build and test Rust
working-directory: pkg/rust
run: |
cargo build --release
LD_LIBRARY_PATH=../c/lib:$LD_LIBRARY_PATH cargo test --release
test-python:
name: Test Python
runs-on: ubuntu-latest
continue-on-error: true # Python tests optional (may need additional deps)
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y build-essential
pip install --upgrade pip setuptools wheel
pip install cython
- name: Build C library (Python depends on it)
working-directory: pkg/c
run: make all
- name: Build and test Python
working-directory: pkg/python
run: |
python setup.py build_ext --inplace || echo "Python build failed"
python test_consensus_comprehensive.py || echo "Python tests skipped"
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.26.4"
cache: true
- name: Install golangci-lint v2
run: go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@latest
- name: Run golangci-lint
run: golangci-lint run --timeout=10m
build:
name: Build
runs-on: ubuntu-latest
strategy:
matrix:
os: [linux, darwin, windows]
arch: [amd64, arm64]
exclude:
- os: windows
arch: arm64
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.26.4"
cache: true
- name: Build
env:
GOOS: ${{ matrix.os }}
GOARCH: ${{ matrix.arch }}
run: |
go build -v -o consensus-${{ matrix.os }}-${{ matrix.arch }} ./cmd/consensus
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: consensus-${{ matrix.os }}-${{ matrix.arch }}
path: consensus-${{ matrix.os }}-${{ matrix.arch }}
release:
name: Release
# Only require core implementations (Go, C, Rust) + lint + build
# C++ and Python are optional (continue-on-error: true)
needs: [test, test-c, test-rust, lint, build]
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Download artifacts
uses: actions/download-artifact@v4
- name: Create Release
uses: softprops/action-gh-release@v1
with:
files: |
consensus-linux-amd64/consensus-linux-amd64
consensus-linux-arm64/consensus-linux-arm64
consensus-darwin-amd64/consensus-darwin-amd64
consensus-darwin-arm64/consensus-darwin-arm64
consensus-windows-amd64/consensus-windows-amd64
generate_release_notes: true
draft: false
prerelease: false