Skip to content

Commit

Permalink
imp: build programs automatically when operator is building (#95)
Browse files Browse the repository at this point in the history
* just: improve justfile

* build: added build script for programs

* just: simplified ci and justfile

* ci: turned program ci into matrix ci

* ci: renamed job

* ci: fix build ci
  • Loading branch information
srdtrk committed Aug 13, 2024
1 parent 37d3608 commit f6d02a9
Show file tree
Hide file tree
Showing 7 changed files with 76 additions and 78 deletions.
68 changes: 11 additions & 57 deletions .github/workflows/programs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,17 @@ on:
pull_request:

jobs:
update-client:
build-programs:
strategy:
fail-fast: true
name: build-update-client
runs-on: ubuntu-20.04
fail-fast: false
matrix:
programs:
# List your program directories here
- programs/update-client
- programs/membership
- programs/uc-and-membership
name: 'build: ${{ matrix.programs }}'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

Expand All @@ -30,57 +36,5 @@ jobs:
- name: Build SP1 program
run: |
cd programs/update-client
~/.sp1/bin/cargo-prove prove build
membership:
strategy:
fail-fast: true
name: build-membership
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4

- name: Install rust toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true

- name: Install SP1 toolchain
run: |
curl -L https://sp1.succinct.xyz | bash
~/.sp1/bin/sp1up
~/.sp1/bin/cargo-prove prove --version
- name: Build SP1 program
run: |
cd programs/membership
~/.sp1/bin/cargo-prove prove build
uc-and-membership:
strategy:
fail-fast: true
name: build-uc-and-membership
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4

- name: Install rust toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true

- name: Install SP1 toolchain
run: |
curl -L https://sp1.succinct.xyz | bash
~/.sp1/bin/sp1up
~/.sp1/bin/cargo-prove prove --version
- name: Build SP1 program
run: |
cd programs/uc-and-membership
cd ${{ matrix.programs }}
~/.sp1/bin/cargo-prove prove build
14 changes: 2 additions & 12 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,8 @@ jobs:
~/.sp1/bin/cargo-prove prove --version
- name: Install just
uses: extractions/setup-just@v2
- name: Build SP1 Programs
run: just build-programs

- name: Run unit tests
uses: actions-rs/cargo@v1
with:
command: test
args: --workspace --exclude sp1-ics07-tendermint-update-client --exclude sp1-ics07-tendermint-membership --exclude sp1-ics07-tendermint-uc-and-membership --locked
run: just test-cargo
env:
RUST_BACKTRACE: 1

Expand All @@ -88,13 +82,9 @@ jobs:
curl -L https://sp1.succinct.xyz | bash
~/.sp1/bin/sp1up
~/.sp1/bin/cargo-prove prove --version
- name: Install just
uses: extractions/setup-just@v2
- name: Build SP1 Programs
run: just build-programs
- name: Build
uses: actions-rs/cargo@v1
with:
command: build
args: --workspace --exclude sp1-ics07-tendermint-update-client --exclude sp1-ics07-tendermint-membership--locked --exclude sp1-ics07-tendermint-uc-and-membership --all-features
args: --workspace --exclude sp1-ics07-tendermint-update-client --exclude sp1-ics07-tendermint-membership --exclude sp1-ics07-tendermint-uc-and-membership --all-features --locked
24 changes: 24 additions & 0 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ authors = ["srdtrk <[email protected]>"]
[workspace.dependencies]
# Used by the programs
sp1-zkvm = "1.1"
sp1-helper = "1.1"

sp1-ics07-tendermint-solidity = { path = "./packages/solidity/" }
sp1-ics07-tendermint-update-client = { path = "./programs/update-client/" }
Expand Down Expand Up @@ -47,6 +46,7 @@ serde_json = { version = "1.0", default-features = false, features = ["alloc"] }

# Used by the operator
sp1-sdk = "1.1"
sp1-helper = "1.1"

sp1-ics07-tendermint-utils = { path = "./packages/utils/" }

Expand Down
11 changes: 3 additions & 8 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,15 @@ set dotenv-load

# Build riscv elf file using `~/.sp1/bin/cargo-prove`
build-programs:
cd programs/update-client && ~/.sp1/bin/cargo-prove prove build
mv elf/riscv32im-succinct-zkvm-elf elf/update-client-riscv32im-succinct-zkvm-elf
cd programs/update-client && ~/.sp1/bin/cargo-prove prove build --elf-name update-client-riscv32im-succinct-zkvm-elf
@echo "ELF created at 'elf/update-client-riscv32im-succinct-zkvm-elf'"
cd programs/membership && ~/.sp1/bin/cargo-prove prove build
mv elf/riscv32im-succinct-zkvm-elf elf/membership-riscv32im-succinct-zkvm-elf
cd programs/membership && ~/.sp1/bin/cargo-prove prove build --elf-name membership-riscv32im-succinct-zkvm-elf
@echo "ELF created at 'elf/membership-riscv32im-succinct-zkvm-elf'"
cd programs/uc-and-membership && ~/.sp1/bin/cargo-prove prove build
mv elf/riscv32im-succinct-zkvm-elf elf/uc-and-membership-riscv32im-succinct-zkvm-elf
cd programs/uc-and-membership && ~/.sp1/bin/cargo-prove prove build --elf-name uc-and-membership-riscv32im-succinct-zkvm-elf
@echo "ELF created at 'elf/uc-and-membership-riscv32im-succinct-zkvm-elf'"

# Build the operator executable using `cargo build` command
build-operator:
@echo "Building the programs for the operator..."
just build-programs
@echo "Building the operator executable..."
cargo build --bin operator --locked --release
@echo "Built the operator executable"
Expand Down
3 changes: 3 additions & 0 deletions operator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,6 @@ clap = { workspace = true }
log = { workspace = true }
async-trait = { workspace = true }
hex = { workspace = true }

[build-dependencies]
sp1-helper = { workspace = true }
32 changes: 32 additions & 0 deletions operator/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
use sp1_helper::{build_program_with_args, BuildArgs};

// Build script to build the programs if they change.
// Requires SP1 toolchain to be installed.
fn main() {
// Build the update-client program.
build_program_with_args(
"../programs/update-client",
BuildArgs {
elf_name: "update-client-riscv32im-succinct-zkvm-elf".to_string(),
..Default::default()
},
);

// Build the membership program.
build_program_with_args(
"../programs/membership",
BuildArgs {
elf_name: "membership-riscv32im-succinct-zkvm-elf".to_string(),
..Default::default()
},
);

// Build the uc-and-membership program.
build_program_with_args(
"../programs/uc-and-membership",
BuildArgs {
elf_name: "uc-and-membership-riscv32im-succinct-zkvm-elf".to_string(),
..Default::default()
},
);
}

0 comments on commit f6d02a9

Please sign in to comment.