Skip to content

Commit

Permalink
fix errors
Browse files Browse the repository at this point in the history
  • Loading branch information
nulltea committed Sep 21, 2023
1 parent cf7fb87 commit 07432db
Show file tree
Hide file tree
Showing 11 changed files with 356 additions and 130 deletions.
8 changes: 6 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,9 @@ snark-verifier-sdk = { git = "https://github.com/timoftime/snark-verifier", bran
ssz-rs = { git = "https://github.com/polytope-labs/ssz-rs", branch = "main", default-features = false }

[patch."https://github.com/polytope-labs/sync-committee-rs"]
sync-committee-prover = { path = "../sync-committee-rs/prover", features=["testnet"] }
sync-committee-primitives = { path = "../sync-committee-rs/primitives", features=["testnet"] }
sync-committee-prover = { git = "https://github.com/timoftime/sync-committee-rs", branch = "dev/accept-ssz", features = [
"testnet",
] }
sync-committee-primitives = { git = "https://github.com/timoftime/sync-committee-rs", branch = "dev/accept-ssz", features = [
"testnet",
] }
4 changes: 2 additions & 2 deletions eth-types/src/spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ pub struct Mainnet;
impl Spec for Mainnet {
const SYNC_COMMITTEE_SIZE: usize = 512;
const DST: &'static [u8] = b"BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_POP_";
const EXECUTION_STATE_ROOT_INDEX: usize = 402;
const EXECUTION_STATE_ROOT_DEPTH: usize = 8;
const EXECUTION_STATE_ROOT_INDEX: usize = 25;
const EXECUTION_STATE_ROOT_DEPTH: usize = 4;
const FINALIZED_HEADER_INDEX: usize = 105;
const FINALIZED_HEADER_DEPTH: usize = 6;
}
15 changes: 2 additions & 13 deletions lightclient-circuits/config/committee_update.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"strategy": "Vertical",
"k": 18,
"num_advice_per_phase": [
11,
1,
0,
0
],
Expand All @@ -15,18 +15,7 @@
"num_fixed": 1
},
"break_points": [
[
262131,
262130,
262131,
262130,
262130,
262131,
262131,
262131,
262130,
262131
],
[],
[],
[]
]
Expand Down
230 changes: 230 additions & 0 deletions lightclient-circuits/config/committee_update_aggregation.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,230 @@
{
"params": {
"strategy": "Vertical",
"k": 17,
"num_advice_per_phase": [
208,
0,
0
],
"num_lookup_advice_per_phase": [
25,
0,
0
],
"num_fixed": 4
},
"break_points": [
[
131060,
131062,
131062,
131062,
131060,
131062,
131062,
131062,
131060,
131062,
131062,
131062,
131060,
131061,
131062,
131062,
131060,
131061,
131061,
131060,
131062,
131060,
131062,
131062,
131062,
131062,
131062,
131061,
131062,
131062,
131062,
131062,
131062,
131062,
131061,
131060,
131062,
131062,
131062,
131060,
131061,
131062,
131062,
131062,
131062,
131061,
131060,
131061,
131062,
131062,
131062,
131060,
131061,
131061,
131062,
131060,
131060,
131060,
131060,
131062,
131062,
131062,
131062,
131062,
131062,
131061,
131060,
131060,
131061,
131062,
131061,
131061,
131061,
131062,
131062,
131060,
131061,
131062,
131061,
131060,
131062,
131060,
131062,
131061,
131062,
131060,
131060,
131062,
131061,
131060,
131062,
131061,
131061,
131061,
131062,
131060,
131062,
131062,
131062,
131062,
131062,
131062,
131060,
131062,
131062,
131062,
131062,
131061,
131062,
131060,
131062,
131062,
131060,
131060,
131062,
131060,
131060,
131060,
131060,
131062,
131062,
131060,
131060,
131062,
131061,
131061,
131062,
131060,
131062,
131062,
131062,
131062,
131062,
131062,
131062,
131062,
131062,
131060,
131061,
131060,
131060,
131061,
131061,
131061,
131061,
131062,
131061,
131060,
131062,
131060,
131061,
131060,
131061,
131061,
131060,
131060,
131062,
131060,
131062,
131061,
131062,
131060,
131061,
131062,
131062,
131060,
131061,
131060,
131060,
131061,
131061,
131061,
131061,
131062,
131061,
131060,
131062,
131060,
131061,
131060,
131061,
131061,
131060,
131060,
131062,
131060,
131062,
131061,
131062,
131060,
131061,
131062,
131062,
131060,
131061,
131060,
131060,
131061,
131061,
131061,
131061,
131062,
131062,
131062,
131060,
131061,
131061
],
[],
[]
]
}
8 changes: 4 additions & 4 deletions lightclient-circuits/config/sync_step.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@
[
2097141,
2097141,
2097142,
2097141,
2097140,
2097142,
2097142,
2097140,
2097140,
2097141,
2097140
2097141,
2097140,
2097141
],
[],
[]
Expand Down
25 changes: 15 additions & 10 deletions lightclient-circuits/src/committee_update_circuit.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::{env::var, marker::PhantomData, vec};

use crate::{
builder::Eth2CircuitBuilder,
gadget::crypto::{
Expand Down Expand Up @@ -85,9 +87,10 @@ impl<S: Spec, F: Field> CommitteeUpdateCircuit<S, F> {
Self::sync_committee_root_ssz(thread_pool, &sha256_chip, compressed_encodings.clone())?;

let pubkeys_x = Self::decode_pubkeys_x(thread_pool.main(), &fp_chip, compressed_encodings);
let poseidon_commit = fq_array_poseidon(thread_pool.main(), range.gate(), &pubkeys_x)?;
// let poseidon_commit = fq_array_poseidon(thread_pool.main(), range.gate(), &pubkeys_x)?;

Ok(vec![poseidon_commit])
// Ok(vec![poseidon_commit])
Ok(vec![])
}

pub fn instance(pubkeys_uncompressed: Vec<Vec<u8>>) -> Vec<Vec<bn256::Fr>> {
Expand Down Expand Up @@ -285,15 +288,14 @@ mod tests {
fn gen_application_snark(
params: &ParamsKZG<bn256::Bn256>,
pk: &ProvingKey<bn256::G1Affine>,
witness: &CommitteeRotationArgs<Testnet, Fr>,
) -> Snark {
let witness = load_circuit_args();

CommitteeUpdateCircuit::<Testnet, Fr>::gen_snark_shplonk(
params,
pk,
"./config/committee_update.json",
None::<String>,
&witness,
witness,
)
.unwrap()
}
Expand Down Expand Up @@ -366,8 +368,8 @@ mod tests {
false,
&CommitteeRotationArgs::<Testnet, Fr>::default(),
);

let snark = gen_application_snark(&params_app, &pk_app);
let witness = load_circuit_args();
let snark = gen_application_snark(&params_app, &pk_app, &witness);

let params = gen_srs(AGG_K);
println!("agg_params k: {:?}", params.k());
Expand All @@ -391,9 +393,12 @@ mod tests {
)
.unwrap();

let instances =
CommitteeUpdateCircuit::<Test, bn256::Fr>::instance(args.pubkeys_compressed);
let num_instances = instances[0].len();
// let instances =
// CommitteeUpdateCircuit::<Testnet, bn256::Fr>::instance(witness.pubkeys_compressed);
// let num_instances = instances[0].len();

let instances = agg_circuit.instances();
let num_instances = agg_circuit.num_instance();

let proof = gen_evm_proof_shplonk(&params, &pk, agg_circuit, instances.clone());
println!("proof size: {}", proof.len());
Expand Down
Loading

0 comments on commit 07432db

Please sign in to comment.