Skip to content

Commit

Permalink
refactor: remove test + pre download plonk artifacts if needed
Browse files Browse the repository at this point in the history
  • Loading branch information
tchataigner committed Oct 25, 2024
1 parent 4f7d491 commit 1093cd5
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 81 deletions.
81 changes: 0 additions & 81 deletions .github/workflows/bench.yml
Original file line number Diff line number Diff line change
Expand Up @@ -287,87 +287,6 @@ jobs:
uses: peter-evans/commit-comment@v3
with:
body-path: ${{ github.workspace }}/${{ matrix.light-client }}/light-client/summary.md
- name: Send report to Zulip
uses: zulip/github-actions-zulip/send-message@v1
with:
api-key: ${{ secrets.ZULIP_API_KEY }}
email: "[email protected]"
organization-url: "https://zulip.argument.xyz"
to: "${{ env.STREAM }}"
type: "${{ env.TYPE }}"
# Ignored if `type: private`
topic: "${{ env.TOPIC }}"
content: "${{ steps.run-benchmarks.outputs.report }}"

bench-test:
name: Light client benchmark test
runs-on: warp-custom-r7iz-metal-32xl
steps:
- uses: actions/checkout@v4
with:
repository: argumentcomputer/ci-workflows
- uses: ./.github/actions/ci-env
- uses: actions/checkout@v4
- name: Setup CI
uses: ./.github/actions/setup
- name: Install extra deps
run: |
sudo apt-get update && sudo apt-get install -y python3-pip
pip3 --version
pip3 install --break-system-packages jtbl
echo 'PATH="$HOME/.local/bin:$PATH"' >> ~/.profile
source ~/.profile
which jtbl
- name: Set env
run: |
# Default benchmark settings optimized for light clients, can be overwritten with `env` input
echo "RUSTFLAGS=-C target-cpu=native --cfg tokio_unstable -C opt-level=3" | tee -a $GITHUB_ENV
echo "SHARD_SIZE=4194304" | tee -a $GITHUB_ENV
echo "SHARD_BATCH_SIZE=0" | tee -a $GITHUB_ENV
echo "RECONSTRUCT_COMMITMENTS=false" | tee -a $GITHUB_ENV
echo "SHARD_CHUNKING_MULTIPLIER=1" | tee -a $GITHUB_ENV
echo "MODE=SNARK" | tee -a $GITHUB_ENV
IFS=',' read -ra ENV_VARS <<< "ethereum"
for VAR in "${ENV_VARS[@]}"; do
VAR_NAME="${VAR%%=*}"
VAR_VALUE="${VAR#*=}"
echo "${VAR_NAME}=${VAR_VALUE}" | tee -a $GITHUB_ENV
done
- name: Parse Zulip inputs
run: |
echo "TYPE=private" | tee -a $GITHUB_ENV
echo "STREAM=114" | tee -a $GITHUB_ENV
- name: Run benchmarks
id: run-benchmarks
run: |
make bench-ci BENCH=spv 2>&1 | tee out.txt
grep 'cycles=' out.txt > cycles.txt
grep 'proving_time' out.txt > timings.txt
while IFS=$'\t' read -r f1 f2
do
num_cycles=$(echo "$f1" | grep -o 'cycles=[0-9]*' | awk -F'=' '{ print $2 }')
echo "$f2" | jq -c --argjson cycles "$num_cycles" '. += {cycles: $cycles}' >> summary.json
done < <(paste cycles.txt timings.txt)
echo "# Kadena Benchmark Results " | tee -a summary.md
echo "## SPV Prove" | tee -a summary.md
cat summary.json | jtbl -m | tee -a summary.md
echo "" | tee -a summary.md
echo "Time unit = milliseconds" | tee -a summary.md
echo "Workflow URL: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" | tee -a summary.md
echo "report<<EOF" >> $GITHUB_OUTPUT
cat summary.md >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
working-directory: ${{ github.workspace }}/kadena/light-client
#- name: Write bench on commit comment
# uses: peter-evans/commit-comment@v3
# with:
# body-path: ${{ github.workspace }}/${{ inputs.light-client }}/light-client/summary.md
- name: Send report to Zulip
uses: zulip/github-actions-zulip/send-message@v1
with:
Expand Down
5 changes: 5 additions & 0 deletions aptos/light-client/benches/epoch_change.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ use aptos_lc_core::aptos_test_utils::wrapper::AptosWrapper;
use aptos_lc_core::crypto::hash::CryptoHash;
use aptos_lc_core::types::trusted_state::TrustedState;
use serde::Serialize;
use sphinx_sdk::artifacts::try_install_plonk_bn254_artifacts;
use sphinx_sdk::utils::setup_logger;
use sphinx_sdk::{ProverClient, SphinxProofWithPublicValues, SphinxStdin};
use std::env;
Expand Down Expand Up @@ -131,6 +132,10 @@ fn main() {
// Initialize the proving assets and benchmark the proving process.
let proving_assets = ProvingAssets::new(mode);

if mode == ProvingMode::SNARK {
let _ = try_install_plonk_bn254_artifacts(false);
}

let start_proving = Instant::now();
let mut epoch_change_proof = proving_assets.prove();
let proving_time = start_proving.elapsed();
Expand Down
6 changes: 6 additions & 0 deletions aptos/light-client/benches/inclusion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ use aptos_lc_core::types::ledger_info::LedgerInfoWithSignatures;
use aptos_lc_core::types::trusted_state::TrustedState;
use aptos_lc_core::types::validator::ValidatorVerifier;
use serde::Serialize;
use sphinx_sdk::artifacts::try_install_plonk_bn254_artifacts;
use sphinx_sdk::utils::setup_logger;
use sphinx_sdk::{ProverClient, SphinxProofWithPublicValues, SphinxStdin};
use std::env;
Expand Down Expand Up @@ -173,6 +174,11 @@ struct Timings {
fn main() {
let mode_str: String = env::var("MODE").unwrap_or_else(|_| "STARK".into());
let mode = ProvingMode::try_from(mode_str.as_str()).expect("MODE should be STARK or SNARK");

if mode == ProvingMode::SNARK {
let _ = try_install_plonk_bn254_artifacts(false);
}

for nbr_leaves in NBR_LEAVES {
let proving_assets = ProvingAssets::from_nbr_leaves(mode, nbr_leaves);

Expand Down
5 changes: 5 additions & 0 deletions aptos/light-client/benches/sig.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
use anyhow::anyhow;
use aptos_lc_core::aptos_test_utils::wrapper::AptosWrapper;
use serde::Serialize;
use sphinx_sdk::artifacts::try_install_plonk_bn254_artifacts;
use sphinx_sdk::utils::setup_logger;
use sphinx_sdk::{ProverClient, SphinxProofWithPublicValues, SphinxStdin};
use std::env;
Expand Down Expand Up @@ -99,6 +100,10 @@ fn main() {

let proving_assets = ProvingAssets::new(mode);

if mode == ProvingMode::SNARK {
let _ = try_install_plonk_bn254_artifacts(false);
}

let start_proving = Instant::now();
let proof = proving_assets.prove();
let proving_time = start_proving.elapsed();
Expand Down
5 changes: 5 additions & 0 deletions ethereum/light-client/benches/committee_change.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use ethereum_lc_core::types::bootstrap::Bootstrap;
use ethereum_lc_core::types::store::LightClientStore;
use ethereum_lc_core::types::update::Update;
use serde::Serialize;
use sphinx_sdk::artifacts::try_install_plonk_bn254_artifacts;
use std::env::current_dir;
use std::time::Instant;
use std::{env, fs};
Expand Down Expand Up @@ -79,6 +80,10 @@ fn main() {
let mode_str: String = env::var("MODE").unwrap_or_else(|_| "STARK".into());
let mode = ProvingMode::try_from(mode_str.as_str()).expect("MODE should be STARK or SNARK");

if mode == ProvingMode::SNARK {
let _ = try_install_plonk_bn254_artifacts(false);
}

// Instantiate BenchmarkAssets
let mut benchmark_assets = BenchmarkAssets::generate();

Expand Down
5 changes: 5 additions & 0 deletions ethereum/light-client/benches/inclusion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use ethereum_lc_core::types::bootstrap::Bootstrap;
use ethereum_lc_core::types::store::LightClientStore;
use ethereum_lc_core::types::update::{FinalityUpdate, Update};
use serde::Serialize;
use sphinx_sdk::artifacts::try_install_plonk_bn254_artifacts;
use std::env::current_dir;
use std::time::Instant;
use std::{env, fs};
Expand Down Expand Up @@ -92,6 +93,10 @@ fn main() {
let mode_str: String = env::var("MODE").unwrap_or_else(|_| "STARK".into());
let mode = ProvingMode::try_from(mode_str.as_str()).expect("MODE should be STARK or SNARK");

if mode == ProvingMode::SNARK {
let _ = try_install_plonk_bn254_artifacts(false);
}

// Instantiate BenchmarkAssets
let benchmark_assets = BenchmarkAssets::generate();

Expand Down
5 changes: 5 additions & 0 deletions kadena/light-client/benches/longest_chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use kadena_lc::proofs::{Prover, ProvingMode};
use kadena_lc_core::test_utils::get_layer_block_headers;
use kadena_lc_core::types::header::layer::ChainwebLayerHeader;
use serde::Serialize;
use sphinx_sdk::artifacts::try_install_plonk_bn254_artifacts;
use std::env;
use std::time::Instant;

Expand Down Expand Up @@ -37,6 +38,10 @@ fn main() {
let mode_str: String = env::var("MODE").unwrap_or_else(|_| "STARK".into());
let mode = ProvingMode::try_from(mode_str.as_str()).expect("MODE should be STARK or SNARK");

if mode == ProvingMode::SNARK {
let _ = try_install_plonk_bn254_artifacts(false);
}

let benchmark_assets = BenchmarkAssets::generate();

let inputs = LongestChainIn::new(benchmark_assets.layer_headers.clone());
Expand Down
5 changes: 5 additions & 0 deletions kadena/light-client/benches/spv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use kadena_lc_core::merkle::spv::Spv;
use kadena_lc_core::test_utils::get_test_assets;
use kadena_lc_core::types::header::layer::ChainwebLayerHeader;
use serde::Serialize;
use sphinx_sdk::artifacts::try_install_plonk_bn254_artifacts;
use std::env;
use std::time::Instant;

Expand Down Expand Up @@ -43,6 +44,10 @@ fn main() {
let mode_str: String = env::var("MODE").unwrap_or_else(|_| "STARK".into());
let mode = ProvingMode::try_from(mode_str.as_str()).expect("MODE should be STARK or SNARK");

if mode == ProvingMode::SNARK {
let _ = try_install_plonk_bn254_artifacts(false);
}

let benchmark_assets = BenchmarkAssets::generate();

let inputs = SpvIn::new(
Expand Down

0 comments on commit 1093cd5

Please sign in to comment.