Skip to content

Commit

Permalink
feat: verifiable build 2.0 (#528)
Browse files Browse the repository at this point in the history
* try ci

* Install solana

* go

* add chmod

* try

* create target debug too

* fix: remove unused files

* add new flow for idl

* add release workflow

* bump:2.0.0
  • Loading branch information
guibescos authored Sep 10, 2024
1 parent 3481eef commit f3d5d2f
Show file tree
Hide file tree
Showing 15 changed files with 77 additions and 92 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/anchor-idl.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Anchor IDL CI

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: "18.19.1"
- name: Npm install
run: npm ci
- name: Install Solana
run: |
sh -c "$(curl -sSfL https://release.solana.com/v1.18.16/install)"
echo "/home/runner/.local/share/solana/install/active_release/bin" >> $GITHUB_PATH
- name: Install Anchor
working-directory: ./staking
run: npm i -g @coral-xyz/[email protected]
- name: Build IDL
working-directory: ./staking
run: anchor build
- name: Check commited idl is up to date
working-directory: ./staking
run: git diff -G".*" --exit-code target/*
11 changes: 4 additions & 7 deletions .github/workflows/anchor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ jobs:
run: |
sh -c "$(curl -sSfL https://release.solana.com/v1.18.16/install)"
echo "/home/runner/.local/share/solana/install/active_release/bin" >> $GITHUB_PATH
- name: Install Anchor
working-directory: ./staking
run: npm i -g @coral-xyz/[email protected]
- name: Anchor tests
- name: Install Solana Verify CLI
run: |
cargo install solana-verify --git https://github.com/Ellipsis-Labs/solana-verifiable-build --rev 098551f
- name: Javascript tests
working-directory: ./staking
run: npm run test:ci
# Remove debug folder to avoid hitting space limit in ci
Expand All @@ -36,6 +36,3 @@ jobs:
- name: Cargo tests
working-directory: ./staking
run: RUST_MIN_STACK=33554432 cargo test
- name: Check commited idl is up to date
working-directory: ./staking
run: git diff -G".*" --exit-code target/*
30 changes: 30 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Release

on:
tags:
- v*

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: "18.19.1"
- name: Install Solana Verify CLI
run: |
cargo install solana-verify --git https://github.com/Ellipsis-Labs/solana-verifiable-build --rev 098551f
- name: Build
working-directory: ./staking
run: solana-verify build
- name: Publish program binaries
working-directory: ./staking
uses: svenstaro/upload-release-action@133984371c30d34e38222a64855679a414cb7575
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ./target/deploy/*.so
tag: ${{ github.ref }}
file_glob: true
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ repos:
- id: end-of-file-fixer
exclude: staking/target
- id: check-added-large-files
exclude: package-lock.json
exclude: package-lock.json|staking/tests/programs
# Hook to format many type of files in the repo
- repo: https://github.com/pre-commit/mirrors-prettier
rev: "v2.7.1"
Expand Down
4 changes: 2 additions & 2 deletions staking/Anchor.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ ledger_dir = "./.anchor/test-ledger"
[path]
idl_path = "./target/idl/staking.json"
binary_path = "./target/deploy/staking.so"
governance_path = "./target/deploy/governance.so"
chat_path = "./target/deploy/chat.so"
governance_path = "./tests/programs/governance.so" # This is the version of governance with the extra instructions for testing, check PR 184 for more info
chat_path = "./tests/programs/chat.so"
wallet_tester_path = "./target/deploy/wallet_tester.so"
profile_path = "./target/deploy/profile.so"
integrity_pool_path = "./target/deploy/integrity_pool.so"
2 changes: 1 addition & 1 deletion staking/Cargo.lock

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

16 changes: 0 additions & 16 deletions staking/Dockerfile

This file was deleted.

13 changes: 0 additions & 13 deletions staking/clone_programs.sh

This file was deleted.

7 changes: 3 additions & 4 deletions staking/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,10 @@
"wasm-pack": "^0.10.2"
},
"scripts": {
"test": "npm run build_wasm && anchor build -- --features mock-clock && npm run dump_governance && ts-mocha --parallel -p ./tsconfig.json -t 1000000",
"test:ci": "npm run build_wasm && ./scripts/build_verifiable_staking_program.sh -t && npm run dump_governance && ts-mocha --parallel -p ./tsconfig.json -t 1000000 tests/*.ts",
"test": "npm run build_wasm && anchor build -- --features mock-clock && ts-mocha --parallel -p ./tsconfig.json -t 1000000",
"test:ci": "npm run build_wasm && mkdir -p target/debug && solana-verify build -- --features mock-clock && ts-mocha --parallel -p ./tsconfig.json -t 1000000 tests/*.ts",
"build": "npm run build_wasm && tsc -p tsconfig.api.json",
"build_wasm": "./scripts/build_wasm.sh",
"localnet": "anchor build && npm run dump_governance && ts-node ./app/scripts/localnet.ts",
"dump_governance": "./clone_programs.sh"
"localnet": "anchor build && ts-node ./app/scripts/localnet.ts"
}
}
2 changes: 1 addition & 1 deletion staking/programs/staking/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "pyth-staking-program"
version = "1.2.0"
version = "2.0.0"
description = "Created with Anchor"
edition = "2018"

Expand Down
45 changes: 0 additions & 45 deletions staking/scripts/build_verifiable_staking_program.sh

This file was deleted.

2 changes: 1 addition & 1 deletion staking/target/idl/staking.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"address": "pytS9TjG1qyAZypk7n8rw8gfW9sUaqqYyMhJQ4E7JCQ",
"metadata": {
"name": "staking",
"version": "1.2.0",
"version": "2.0.0",
"spec": "0.1.0",
"description": "Created with Anchor"
},
Expand Down
2 changes: 1 addition & 1 deletion staking/target/types/staking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export type Staking = {
"address": "pytS9TjG1qyAZypk7n8rw8gfW9sUaqqYyMhJQ4E7JCQ",
"metadata": {
"name": "staking",
"version": "1.2.0",
"version": "2.0.0",
"spec": "0.1.0",
"description": "Created with Anchor"
},
Expand Down
Binary file added staking/tests/programs/chat.so
Binary file not shown.
Binary file added staking/tests/programs/governance.so
Binary file not shown.

0 comments on commit f3d5d2f

Please sign in to comment.