Skip to content

Commit

Permalink
ci
Browse files Browse the repository at this point in the history
  • Loading branch information
yourbuddyconner committed Oct 30, 2024
1 parent 0257f31 commit df6cce9
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 88 deletions.
40 changes: 0 additions & 40 deletions .github/workflows/foundry-test.yml

This file was deleted.

53 changes: 37 additions & 16 deletions .github/workflows/prove.yml
Original file line number Diff line number Diff line change
@@ -1,39 +1,60 @@
name: Build Program
name: Rust CI

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

env:
FOUNDRY_PROFILE: ci

jobs:
check:
strategy:
fail-fast: true

name: Build
name: Check and Lint
runs-on: ubuntu-20.04
env:
CARGO_NET_GIT_FETCH_WITH_CLI: "true"
RUST_BACKTRACE: "1"
SP1_PATH: "/home/runner/.sp1"
RUSTUP_HOME: "/home/runner/.rustup"

steps:
- uses: actions/checkout@v4
with:
submodules: recursive

- name: Install rust toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: 1.79.0
toolchain: 1.81.0
components: clippy
override: true

- name: Install SP1 toolchain
run: |
curl -L https://sp1.succinct.xyz | bash
~/.sp1/bin/sp1up
~/.sp1/bin/cargo-prove prove --version
~/.sp1/bin/sp1up
echo "$SP1_PATH/bin" >> $GITHUB_PATH
echo "$SP1_PATH/toolchains/succinct/bin" >> $GITHUB_PATH
- name: Build SP1 program
- name: Verify SP1 installation
run: |
cd program
~/.sp1/bin/cargo-prove prove build
cargo prove --version
- name: Run cargo fmt
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
env:
CARGO_INCREMENTAL: 1

- name: debug env
run: |
echo $PATH
- name: Run cargo clippy
uses: actions-rs/cargo@v1
env:
CARGO_INCREMENTAL: 1
PATH: ${{ env.SP1_PATH }}/bin:${{ env.SP1_PATH }}/toolchains/succinct/bin:${{ env.PATH }}
with:
command: clippy
args: --all-features --all-targets -- -D warnings -A incomplete-features
37 changes: 5 additions & 32 deletions crates/zkdb-merkle/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,13 @@ use alloc::string::ToString;
use alloc::vec::Vec;
use rs_merkle::proof_serializers;
use rs_merkle::{algorithms::Sha256, Hasher, MerkleTree};
use serde::ser::{SerializeSeq, Serializer};
use serde::{Deserialize, Serialize};
use sp1_zkvm::io;
use zkdb_core::{Command, DatabaseEngine, DatabaseError, QueryResult};

/// Key-value pair type.
type Key = String;
type Value = String;
// type Value = String;

/// Serializable state of the Merkle tree.
#[derive(Serialize, Deserialize)]
Expand All @@ -40,23 +39,6 @@ impl MerkleState {
}
}

/// Custom wrapper for MerkleProof serialization
struct ProofWrapper(rs_merkle::MerkleProof<Sha256>);

impl Serialize for ProofWrapper {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
let proof_hashes = self.0.proof_hashes();
let mut seq = serializer.serialize_seq(Some(proof_hashes.len()))?;
for hash in proof_hashes {
seq.serialize_element(&hex::encode(hash))?;
}
seq.end()
}
}

pub struct MerkleEngine;

impl DatabaseEngine for MerkleEngine {
Expand Down Expand Up @@ -97,19 +79,10 @@ fn main_internal(state: &[u8], command: &Command) -> Result<QueryResult, Databas
.map_err(|e| DatabaseError::QueryExecutionFailed(e.to_string()))?
};

let (result) = match command {
Command::Insert { key, value } => {
let insert_result = insert(&mut merkle_state, key.clone(), value.clone())?;
(insert_result)
}
Command::Query { key } => {
let query_result = query(&merkle_state, key)?;
(query_result)
}
Command::Prove { key } => {
let prove_result = prove(&merkle_state, key)?;
(prove_result)
}
let result = match command {
Command::Insert { key, value } => insert(&mut merkle_state, key.clone(), value.clone())?,
Command::Query { key } => query(&merkle_state, key)?,
Command::Prove { key } => prove(&merkle_state, key)?,
};
Ok(result)
}
Expand Down

0 comments on commit df6cce9

Please sign in to comment.