Skip to content

Commit 6396e51

Browse files
eigmaxUbuntu
andauthored
chore: use powdr to get vk (#238)
* fix: bump to main * fix: bump to main * chore: update dependencies * feat: export circom verifier * fix: remove existing path --------- Co-authored-by: Ubuntu <devadmin@zkevm-prover-uat-vm1.qf0bt0i4yvdutbhtrpicnmptkg.ix.internal.cloudapp.net>
1 parent bbf17ce commit 6396e51

File tree

15 files changed

+212
-160
lines changed

15 files changed

+212
-160
lines changed

dsl_compile/src/input_user.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use crate::errors::{bail, DslError, Result};
22
use ansi_term::Colour;
33
use std::path::{Path, PathBuf};
44

5+
#[allow(dead_code)]
56
pub struct Input {
67
pub input_program: PathBuf,
78
pub out_r1cs: PathBuf,

recursion/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ starky = { path = "../starky", default-features = false }
3333
plonky = { path = "../plonky", default-features = false }
3434
algebraic = { path = "../algebraic", default-features = false }
3535

36-
powdr-pil-analyzer = { git = "https://github.com/eigmax/powdr.git", branch = "main" }
37-
powdr-number = { git = "https://github.com/eigmax/powdr.git", branch = "main" }
38-
powdr-ast = { git = "https://github.com/eigmax/powdr.git", branch = "main" }
36+
powdr = { git = "https://github.com/powdr-labs/powdr.git", rev = "450e3f1" }
37+
powdr-ast = { git = "https://github.com/powdr-labs/powdr.git", rev = "450e3f1" }
38+
powdr-pil-analyzer = { git = "https://github.com/powdr-labs/powdr.git", rev = "450e3f1" }
3939

4040
[dev-dependencies]
4141
env_logger = "0.10"

recursion/src/pilcom.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
//! Poring from https://github.com/powdr-labs/powdr.git.
2+
use std::rc::Rc;
23
mod export;
34
mod expression_counter;
45

5-
use powdr_number::GoldilocksField;
6+
pub use export::export;
7+
8+
use powdr::number::GoldilocksField;
69
use starky::types::PIL;
710
use std::path::Path;
811

912
pub fn compile_pil_from_str(pil_str: &str) -> PIL {
1013
let analyze = powdr_pil_analyzer::analyze_string::<GoldilocksField>(pil_str);
11-
12-
export::export(&analyze)
14+
export(Rc::new(analyze))
1315
}
1416
pub fn compile_pil_from_path(pil_path: &str) -> PIL {
15-
let analyze = powdr_pil_analyzer::analyze::<GoldilocksField>(Path::new(pil_path));
16-
17-
export::export(&analyze)
17+
let analyze = powdr_pil_analyzer::analyze_file::<GoldilocksField>(Path::new(pil_path));
18+
export(Rc::new(analyze))
1819
}
1920

2021
#[cfg(test)]

recursion/src/pilcom/export.rs

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//! porting it from powdr
2-
use powdr_number::FieldElement;
2+
use powdr::number::FieldElement;
33
use std::cmp;
44
use std::collections::HashMap;
55
use std::path::PathBuf;
@@ -36,8 +36,8 @@ struct Exporter<'a, T> {
3636
number_q: u64,
3737
}
3838

39-
pub fn export<T: FieldElement>(analyzed: &Analyzed<T>) -> PIL {
40-
let mut exporter = Exporter::new(analyzed);
39+
pub fn export<T: FieldElement>(analyzed: std::rc::Rc<Analyzed<T>>) -> PIL {
40+
let mut exporter = Exporter::new(&analyzed);
4141
let mut publics = Vec::new();
4242
let mut pol_identities = Vec::new();
4343
let mut plookup_identities = Vec::new();
@@ -48,11 +48,13 @@ pub fn export<T: FieldElement>(analyzed: &Analyzed<T>) -> PIL {
4848
StatementIdentifier::Definition(name) => {
4949
if let Some((poly, value)) = analyzed.intermediate_columns.get(name) {
5050
assert_eq!(poly.kind, SymbolKind::Poly(PolynomialType::Intermediate));
51-
let expression_id = exporter.extract_expression(value, 1);
52-
assert_eq!(
53-
expression_id,
54-
exporter.intermediate_poly_expression_ids[&poly.id] as usize
55-
);
51+
for ((_, id), value) in poly.array_elements().zip(value) {
52+
let expression_id = exporter.extract_expression(value, 1);
53+
assert_eq!(
54+
expression_id,
55+
exporter.intermediate_poly_expression_ids[&id.id] as usize
56+
);
57+
}
5658
}
5759
}
5860
StatementIdentifier::PublicDeclaration(name) => {
@@ -284,6 +286,15 @@ impl<'a, T: FieldElement> Exporter<'a, T> {
284286
..DEFAULT_EXPR
285287
},
286288
),
289+
Expression::Challenge(challenge) => (
290+
0,
291+
StarkyExpr {
292+
op: "challenge".to_string(),
293+
deg: 0,
294+
id: Some(challenge.id as usize),
295+
..DEFAULT_EXPR
296+
},
297+
),
287298
Expression::Number(value) => (
288299
0,
289300
StarkyExpr {

recursion/src/pilcom/expression_counter.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ pub fn compute_intermediate_expression_ids<T>(analyzed: &Analyzed<T>) -> HashMap
2121
poly.expression_count()
2222
} else if let Some((poly, _)) = analyzed.intermediate_columns.get(name) {
2323
assert!(poly.kind == SymbolKind::Poly(PolynomialType::Intermediate));
24-
ids.insert(poly.id, expression_counter as u64);
24+
for (index, (_, id)) in poly.array_elements().enumerate() {
25+
ids.insert(id.id, (expression_counter + index) as u64);
26+
}
2527
poly.expression_count()
2628
} else {
2729
unreachable!()
@@ -49,7 +51,11 @@ impl<Expr> ExpressionCounter for Identity<Expr> {
4951

5052
impl ExpressionCounter for Symbol {
5153
fn expression_count(&self) -> usize {
52-
(self.kind == SymbolKind::Poly(PolynomialType::Intermediate)).into()
54+
if self.kind == SymbolKind::Poly(PolynomialType::Intermediate) {
55+
self.length.unwrap_or(1) as usize
56+
} else {
57+
0
58+
}
5359
}
5460
}
5561

starkjs/fibonacci/fibonacci.pil

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ namespace Fibonacci(%N);
33
pol constant L1, LLAST;
44
pol commit l1,l2;
55

6-
pol l2c = l2;
6+
//pol l2c = l2;
77

8-
public in1 = l2c(0);
8+
public in1 = l2(0);
99
public in2 = l1(0);
1010
public out = l1(%N-1);
1111

zkvm/Cargo.toml

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,9 @@ itertools = "0.12.0"
1010
# serialization
1111
log = "0.4.0"
1212

13-
#powdr-backend = { git = "https://github.com/powdr-labs/powdr", rev = "97ea8d0" }
14-
#powdr-pipeline = { git = "https://github.com/powdr-labs/powdr", rev = "97ea8d0" }
15-
#powdr-riscv = { git = "https://github.com/powdr-labs/powdr", rev = "97ea8d0" }
16-
#powdr-riscv-executor = { git = "https://github.com/powdr-labs/powdr", rev = "97ea8d0" }
17-
#powdr-number = { git = "https://github.com/powdr-labs/powdr", rev = "97ea8d0" }
18-
19-
powdr-backend = { git = "https://github.com/eigmax/powdr", branch = "main" }
20-
powdr-pipeline = { git = "https://github.com/eigmax/powdr", branch = "main" }
21-
powdr-riscv = { git = "https://github.com/eigmax/powdr", branch = "main" }
22-
powdr-riscv-executor = { git = "https://github.com/eigmax/powdr", branch = "main" }
23-
powdr-number = { git = "https://github.com/eigmax/powdr", branch = "main" }
13+
powdr = { git = "https://github.com/powdr-labs/powdr", rev = "450e3f1" }
14+
starky = { path = "../starky" }
15+
recursion = { path = "../recursion" }
2416

2517
hex = "0.4.3"
2618
thiserror = "1.0"

zkvm/vm/evm/Cargo.toml renamed to zkvm/program/evm/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ edition = "2021"
55

66
[dependencies]
77
revm = { git = "https://github.com/powdr-labs/revm", branch = "serde-no-std", default-features = false, features = [ "serde" ] }
8-
powdr-riscv-runtime = { git = "https://github.com/eigmax/powdr", branch = "main" }
8+
powdr-riscv-runtime = { git = "https://github.com/powdr-labs/powdr", rev = "450e3f1" }
99
models = { git = "https://github.com/eigmax/powdr-revme", branch = "continuations", package = "models" }
1010
serde = { version = "1.0", default-features = false, features = ["alloc", "derive", "rc"] }
1111
serde_json = { version = "1.0", default-features = false, features = ["alloc"] }
File renamed without changes.

zkvm/vm/evm/src/lib.rs renamed to zkvm/program/evm/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ use alloc::string::String;
1818
use alloc::string::ToString;
1919

2020
use k256::ecdsa::SigningKey;
21+
const TEST_CHANNEL: u32 = 1;
2122

2223
/// Recover the address from a private key (SigningKey).
2324
pub fn recover_address(private_key: &[u8]) -> Option<Address> {
@@ -28,7 +29,7 @@ pub fn recover_address(private_key: &[u8]) -> Option<Address> {
2829

2930
#[no_mangle]
3031
fn main() {
31-
let suite_json: String = get_data_serde(666);
32+
let suite_json: String = get_data_serde(TEST_CHANNEL);
3233
print!("suite_json: {suite_json}\n");
3334
let suite = read_suite(&suite_json);
3435

zkvm/vm/lr/Cargo.toml renamed to zkvm/program/lr/Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ edition = "2021"
66
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
77

88
[dependencies]
9-
powdr-riscv-runtime = { git = "https://github.com/eigmax/powdr", branch = "main" }
10-
9+
powdr-riscv-runtime = { git = "https://github.com/powdr-labs/powdr", rev = "450e3f1" }
1110

1211
[workspace]
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)