Skip to content

Commit

Permalink
Merge pull request #7 from iosis-tech/build_rs_bootloader
Browse files Browse the repository at this point in the history
full_test switch
  • Loading branch information
Okm165 authored Apr 21, 2024
2 parents 0c686f6 + 9e9e2ec commit 6e725fc
Show file tree
Hide file tree
Showing 12 changed files with 39 additions and 68 deletions.
11 changes: 1 addition & 10 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
pull_request:

jobs:
formatting-and-testing:
check-formatting:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
Expand All @@ -25,14 +25,5 @@ jobs:
with:
python-version: '3.9'

- name: Provision Environment
run: python install.py

- name: Format code
run: cargo fmt --check

- name: Run cargo tests
run: cargo test

- name: Run snforge tests
run: snforge test
10 changes: 5 additions & 5 deletions crates/common/src/job.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ use std::{

#[derive(Debug, PartialEq, Eq, Clone)]
pub struct Job {
pub reward: u32, // The reward offered for completing the task
pub reward: u32, // The reward offered for completing the task
pub num_of_steps: u32, // The number of steps expected to complete the task (executor ensures that this number is greater than or equal to the actual steps; in the future, the executor may charge a fee to the delegator if not met)
pub cairo_pie: Vec<u8>, // The task bytecode in compressed zip format, to conserve memory
pub cairo_pie_compressed: Vec<u8>, // The task bytecode in compressed zip format, to conserve memory
pub registry_address: String, // The address of the registry contract where the delegator expects the proof to be verified
pub public_key: PublicKey, // The public key of the delegator, used in the bootloader stage to confirm authenticity of the Job<->Delegator relationship
pub signature: Signature, // The signature of the delegator, used in the bootloader stage to confirm authenticity of the Job<->Delegator relationship
Expand All @@ -37,7 +37,7 @@ impl Job {
Self {
reward,
num_of_steps,
cairo_pie: fs::read(cairo_pie_file).unwrap(),
cairo_pie_compressed: fs::read(cairo_pie_file).unwrap(),
registry_address: registry_address.to_string(),
public_key: PublicKey::from_secret_key(&secret_key),
signature: libsecp256k1::sign(
Expand All @@ -62,7 +62,7 @@ impl Default for Job {
Self {
reward: 0,
num_of_steps: 0,
cairo_pie: vec![1, 2, 3],
cairo_pie_compressed: vec![1, 2, 3],
public_key,
signature,
registry_address: "0x0".to_string(),
Expand All @@ -74,7 +74,7 @@ impl Hash for Job {
fn hash<H: Hasher>(&self, state: &mut H) {
self.reward.hash(state);
self.num_of_steps.hash(state);
self.cairo_pie.hash(state);
self.cairo_pie_compressed.hash(state);
self.registry_address.hash(state);
}
}
Expand Down
5 changes: 4 additions & 1 deletion crates/prover/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,7 @@ strum.workspace = true
tempfile.workspace = true
thiserror.workspace = true
tokio.workspace = true
tracing.workspace = true
tracing.workspace = true

[features]
full_test = []
2 changes: 1 addition & 1 deletion crates/prover/src/stone_prover/tests/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pub mod models;

#[cfg(test)]
#[cfg(all(test, feature = "full_test"))]
pub mod multiple_job;
#[cfg(test)]
pub mod single_job;
27 changes: 17 additions & 10 deletions crates/prover/src/stone_prover/tests/models.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
use crate::stone_prover::types::{config::Config, params::Params};
use crate::stone_prover::types::{
config::Config,
params::{Fri, Params, Stark},
};
use sharp_p2p_common::job_trace::JobTrace;
use std::{env, fs, io::Write, path::PathBuf};
use tempfile::NamedTempFile;
Expand All @@ -18,9 +21,6 @@ pub fn fixture() -> TestFixture {
let memory_path = ws_root.join("crates/tests/cairo/memory");
let trace_path = ws_root.join("crates/tests/cairo/trace");

let cpu_air_prover_config_path = ws_root.join("crates/tests/cairo/cpu_air_prover_config.json");
let cpu_air_params_path = ws_root.join("crates/tests/cairo/cpu_air_params.json");

let mut air_public_input = NamedTempFile::new().unwrap();
air_public_input.write_all(&fs::read(air_public_input_path).unwrap()).unwrap();

Expand All @@ -35,11 +35,18 @@ pub fn fixture() -> TestFixture {

TestFixture {
job_trace: JobTrace { air_public_input, air_private_input, memory, trace },
cpu_air_prover_config: serde_json::from_str(
&fs::read_to_string(cpu_air_prover_config_path).unwrap(),
)
.unwrap(),
cpu_air_params: serde_json::from_str(&fs::read_to_string(cpu_air_params_path).unwrap())
.unwrap(),
cpu_air_prover_config: Config::default(),
cpu_air_params: Params {
stark: Stark {
fri: Fri {
fri_step_list: vec![0, 4, 4, 3],
last_layer_degree_bound: 128,
n_queries: 1,
proof_of_work_bits: 1,
},
log_n_cosets: 1,
},
..Default::default()
},
}
}
5 changes: 4 additions & 1 deletion crates/runner/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,7 @@ tempfile.workspace = true
thiserror.workspace = true
tokio.workspace = true
tracing.workspace = true
zip-extensions.workspace = true
zip-extensions.workspace = true

[features]
full_test = []
2 changes: 1 addition & 1 deletion crates/runner/src/cairo_runner/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ impl RunnerController for CairoRunner {
let layout: &str = Layout::RecursiveWithPoseidon.into();

let mut cairo_pie = NamedTempFile::new()?;
cairo_pie.write_all(&job.cairo_pie)?;
cairo_pie.write_all(&job.cairo_pie_compressed)?;

let input = BootloaderInput {
tasks: vec![BootloaderTask {
Expand Down
2 changes: 1 addition & 1 deletion crates/runner/src/cairo_runner/tests/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pub mod models;

#[cfg(test)]
#[cfg(all(test, feature = "full_test"))]
pub mod multiple_job;
#[cfg(test)]
pub mod single_job;
5 changes: 4 additions & 1 deletion crates/tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,7 @@ license-file.workspace = true
futures.workspace = true
sharp-p2p-prover.workspace = true
sharp-p2p-runner.workspace = true
tokio.workspace = true
tokio.workspace = true

[features]
full_test = []
28 changes: 0 additions & 28 deletions crates/tests/cairo/cpu_air_params.json

This file was deleted.

9 changes: 0 additions & 9 deletions crates/tests/cairo/cpu_air_prover_config.json

This file was deleted.

1 change: 1 addition & 0 deletions crates/tests/src/tests/mod.rs
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
#[cfg(all(test, feature = "full_test"))]
mod runner_prover_flow;

0 comments on commit 6e725fc

Please sign in to comment.