Skip to content

Commit 2c3f7b5

Browse files
authored
Update prover (#184)
* Update prover * Update polylang-prover and polylang abi * Fix unused import
1 parent cd19742 commit 2c3f7b5

File tree

4 files changed

+21
-49
lines changed

4 files changed

+21
-49
lines changed

Cargo.lock

+7-7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

polybase/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ indexer_rocksdb = { path = "../indexer_rocksdb" }
1515
indexer = { path = "../indexer" }
1616
gateway = { path = "../gateway" }
1717
solid = { path = "../solid" }
18-
polylang-prover = { git = "https://github.com/polybase/polylang", rev = "91996dea0efa572666e6f82cbc9a1d2641082ebe", version = "0.1.0" }
19-
abi = { git = "https://github.com/polybase/polylang", rev = "91996dea0efa572666e6f82cbc9a1d2641082ebe", version = "0.1.0" }
18+
polylang-prover = { git = "https://github.com/polybase/polylang", rev = "5f7a0230823284d3478b5a3ae4c885fb57820621", version = "0.1.0" }
19+
abi = { git = "https://github.com/polybase/polylang", rev = "5f7a0230823284d3478b5a3ae4c885fb57820621", version = "0.1.0" }
2020
serde = { version = "1.0", features = ["derive"] }
2121
serde_json = { version = "1.0", features = ["raw_value"] }
2222
serde_with = { version = "2.2", features = ["json"] }

polybase/src/errors.rs

-3
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,6 @@ pub enum AppError {
5757
#[error("failed to compile Miden program")]
5858
MidenCompile(Box<dyn std::error::Error>),
5959

60-
#[error("ABI is missing `this` type")]
61-
ABIIsMissingThisType,
62-
6360
#[error("prover error")]
6461
ProveError(Box<dyn std::error::Error>),
6562

polybase/src/rpc.rs

+12-37
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,13 @@ use crate::errors::AppError;
99
use crate::txn::CallTxn;
1010
use crate::ArcDbIndexer;
1111
use crate::{auth, util::hash};
12-
use abi::Parser;
1312
use actix_cors::Cors;
1413
use actix_server::Server;
1514
use actix_web::{get, post, web, App, HttpRequest, HttpResponse, HttpServer, Responder};
1615
use base64::Engine;
1716
// use indexer::adaptor::IndexerAdaptor;
1817
use indexer::{auth_user::AuthUser, cursor, list_query, where_query};
19-
use polylang_prover::{compile_program, hash_this, Inputs, ProgramExt};
18+
use polylang_prover::{compile_program, Inputs, ProgramExt};
2019
use schema::record;
2120
use serde::{de::IntoDeserializer, Deserialize, Serialize};
2221
use serde_with::serde_as;
@@ -420,8 +419,9 @@ struct ProveRequest {
420419
abi: abi::Abi,
421420
ctx_public_key: Option<abi::publickey::Key>,
422421
this: Option<serde_json::Value>,
422+
this_salts: Vec<u32>,
423423
args: Vec<serde_json::Value>,
424-
other_records: HashMap<String, Vec<serde_json::Value>>,
424+
other_records: HashMap<String, Vec<(serde_json::Value, Vec<u32>)>>,
425425
}
426426

427427
#[tracing::instrument(skip_all, fields(
@@ -458,29 +458,13 @@ async fn prove(req: web::Json<ProveRequest>) -> Result<impl Responder, HTTPError
458458
})?,
459459
);
460460

461-
let this_hash = hash_this(
462-
req.abi.this_type.clone().ok_or_else(|| {
463-
HTTPError::new(
464-
ReasonCode::Internal,
465-
Some(Box::new(AppError::ABIIsMissingThisType)),
466-
)
467-
})?,
468-
&req.abi
469-
.this_type
470-
.as_ref()
471-
.ok_or_else(|| {
472-
HTTPError::new(
473-
ReasonCode::Internal,
474-
Some(Box::new(AppError::ABIIsMissingThisType)),
475-
)
476-
})?
477-
.parse(&this)
478-
.map_err(|err| {
479-
HTTPError::new(
480-
ReasonCode::Internal,
481-
Some(Box::new(AppError::ABIError(Box::new(err)))),
482-
)
483-
})?,
461+
let inputs = Inputs::new(
462+
req.abi.clone(),
463+
req.ctx_public_key.clone(),
464+
req.this_salts.clone(),
465+
this.clone(),
466+
req.args.clone(),
467+
req.other_records.clone(),
484468
)
485469
.map_err(|err| {
486470
HTTPError::new(
@@ -489,15 +473,6 @@ async fn prove(req: web::Json<ProveRequest>) -> Result<impl Responder, HTTPError
489473
)
490474
})?;
491475

492-
let inputs = Inputs {
493-
abi: req.abi.clone(),
494-
ctx_public_key: req.ctx_public_key.clone(),
495-
this: this.clone(),
496-
this_hash,
497-
args: req.args.clone(),
498-
other_records: req.other_records.clone(),
499-
};
500-
501476
let output = polylang_prover::prove(&program, &inputs).map_err(|err| {
502477
HTTPError::new(
503478
ReasonCode::Internal,
@@ -516,12 +491,12 @@ async fn prove(req: web::Json<ProveRequest>) -> Result<impl Responder, HTTPError
516491
Ok(HttpResponse::Ok().json(serde_json::json!({
517492
"old": {
518493
"this": this,
519-
"hash": inputs.this_hash,
494+
"hashes": inputs.this_field_hashes,
520495
},
521496
"new": {
522497
"selfDestructed": output.self_destructed,
523498
"this": new_this,
524-
"hash": output.new_hash,
499+
"hashes": output.new_hashes,
525500
},
526501
"stack": {
527502
"input": output.input_stack,

0 commit comments

Comments
 (0)