Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.lock

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

9 changes: 6 additions & 3 deletions ad-server/src/endpoints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,13 +268,16 @@ mod tests {
println!("Prebuilding circuits to calculate vd_set...");
let vd_set = &*DEFAULT_VD_SET;
println!("vd_set calculation complete");
let (state_predicates, rev_predicates) = app::build_predicates(&params);
let batches = app::build_predicates(&params);
let pred_update = batches[0]
.predicate_ref_by_name("update")
.expect("update defined");
let shrunk_main_pod_build = ShrunkMainPodSetup::new(&params).build()?;
let pod_config = PodConfig {
params,
vd_set: vd_set.clone(),
state_predicates,
rev_predicates,
batches,
pred_update,
};

let (queue_tx, queue_rx) = mpsc::channel::<queue::Request>(8);
Expand Down
17 changes: 10 additions & 7 deletions ad-server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ use std::{collections::HashMap, str::FromStr, sync::Arc};

use alloy::primitives::Address;
use anyhow::{Context as _, Result};
use app::{Predicates, RevPredicates, build_predicates};
use app::build_predicates;
use common::{
ProofType,
shrink::{ShrunkMainPodBuild, ShrunkMainPodSetup},
};
use pod2::{
backends::plonky2::basetypes::DEFAULT_VD_SET,
middleware::{Params, VDSet},
middleware::{CustomPredicateBatch, CustomPredicateRef, Params, VDSet},
};
use sqlx::{
migrate::MigrateDatabase,
Expand Down Expand Up @@ -70,8 +70,8 @@ impl Config {
pub struct PodConfig {
params: Params,
vd_set: VDSet,
state_predicates: Predicates,
rev_predicates: RevPredicates,
batches: Vec<Arc<CustomPredicateBatch>>,
pred_update: CustomPredicateRef,
}

pub struct Context {
Expand Down Expand Up @@ -137,13 +137,16 @@ async fn main() -> Result<()> {
info!("Prebuilding circuits to calculate vd_set...");
let vd_set = &*DEFAULT_VD_SET;
info!("vd_set calculation complete");
let (state_predicates, rev_predicates) = build_predicates(&params);
let batches = build_predicates(&params);
let pred_update = batches[0]
.predicate_ref_by_name("update")
.expect("update defined");
let shrunk_main_pod_build = ShrunkMainPodSetup::new(&params).build()?;
let pod_config = PodConfig {
params,
vd_set: vd_set.clone(),
state_predicates,
rev_predicates,
batches,
pred_update,
};

if cfg.proof_type == ProofType::Groth16 {
Expand Down
10 changes: 3 additions & 7 deletions ad-server/src/queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ async fn handle_create(ctx: Arc<Context>, req_id: Uuid) -> Result<()> {
// send the payload to ethereum
let payload_bytes = Payload::Create(PayloadCreate {
id: Hash::from(RawValue::from(new_id)), // TODO hash
custom_predicate_ref: ctx.pod_config.state_predicates.update.clone(),
custom_predicate_ref: ctx.pod_config.pred_update.clone(),
vds_root: ctx.pod_config.vd_set.root(),
})
.to_bytes();
Expand Down Expand Up @@ -204,7 +204,7 @@ async fn handle_update(ctx: Arc<Context>, req_id: Uuid, id: i64, op: Op) -> Resu
let start = std::time::Instant::now();

let mut builder = MainPodBuilder::new(&ctx.pod_config.params, &ctx.pod_config.vd_set);
let mut helper = Helper::new(&mut builder, &ctx.pod_config.state_predicates);
let mut helper = Helper::new(&mut builder, &ctx.pod_config.batches);

let op = Dictionary::from(op);
let op_raw = RawValue::from(op.commitment());
Expand Down Expand Up @@ -319,11 +319,7 @@ async fn handle_update_rev(ctx: Arc<Context>, req_id: Uuid, id: i64, num: i64) -
Statement::None
};

let mut rev_helper = RevHelper::new(
&mut builder,
&ctx.pod_config.state_predicates,
&ctx.pod_config.rev_predicates,
);
let mut rev_helper = RevHelper::new(&mut builder, &ctx.pod_config.batches);
let (rev_state, rev_st_update) =
rev_helper.st_rev_sync(rev_state, op, st_update, old_st_rev_sync);

Expand Down
Loading