mirror of
https://github.com/arnaucube/sonobe-light-btc.git
synced 2026-01-18 19:51:34 +01:00
chore: update sh script and number of blocks being proven
This commit is contained in:
2
Cargo.lock
generated
2
Cargo.lock
generated
@@ -229,7 +229,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "ark-light-bitcoin-client"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/dmpierre/ark-light-bitcoin-client.git#1a089539ccf92e80a3a97824bbbc11f8fe5eb2b7"
|
||||
source = "git+https://github.com/dmpierre/ark-light-bitcoin-client.git#d43d366f8553c8cf0d8fd3c1a08890128d7b55ce"
|
||||
dependencies = [
|
||||
"ark-bn254",
|
||||
"ark-crypto-primitives",
|
||||
|
||||
8
setup-machine-and-run-proving.sh
Executable file
8
setup-machine-and-run-proving.sh
Executable file
@@ -0,0 +1,8 @@
|
||||
#!/bin/bash
|
||||
# run with `source ./setup-machine-and-run-proving.sh`
|
||||
sudo apt-get update
|
||||
sudo apt install build-essential -y
|
||||
curl https://sh.rustup.rs -sSf | sh -s -- -y
|
||||
. "$HOME/.cargo/env"
|
||||
git clone https://github.com/dmpierre/folding-schemes-light-btc.git
|
||||
cd folding-schemes-light-btc && cargo run -r
|
||||
@@ -1,6 +0,0 @@
|
||||
#!/bin/bash
|
||||
# script for setting up a new machine to generate light client btc proofs
|
||||
sudo apt-get update
|
||||
curl https://sh.rustup.rs -sSf | sh -s -- -y # install rust, defaulting to yes
|
||||
. "$HOME/.cargo/env"
|
||||
|
||||
46
src/main.rs
46
src/main.rs
@@ -20,7 +20,7 @@ use folding_schemes::{
|
||||
use folding_schemes::{folding::nova::decider_eth_circuit::DeciderEthCircuit, FoldingScheme};
|
||||
use num_bigint::BigUint;
|
||||
use num_traits::Num;
|
||||
use std::marker::PhantomData;
|
||||
use std::{marker::PhantomData, time::Instant};
|
||||
use utils::setup;
|
||||
mod utils;
|
||||
|
||||
@@ -78,17 +78,9 @@ impl<F: PrimeField> FCircuit<F> for BTCBlockCheckerFCircuit<F> {
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn run_main() {
|
||||
// this is done to avoid computing large circuits
|
||||
fn main() {
|
||||
let file = include_str!("./data/btc-blocks.json");
|
||||
let (mut prev_block_hash, blocks) = read_blocks(20, 1, file);
|
||||
let (mut prev_block_hash, blocks) = read_blocks(100, 1, file);
|
||||
|
||||
let mut blocks_prepared = vec![];
|
||||
for batch in blocks.iter() {
|
||||
@@ -98,9 +90,7 @@ mod tests {
|
||||
let block_headers =
|
||||
serde_json::from_value::<Vec<Vec<u8>>>(batch.get("blockHeaders").unwrap().clone())
|
||||
.unwrap();
|
||||
for (i, (block_hash, block_header)) in
|
||||
block_hashes.iter().zip(block_headers).enumerate()
|
||||
{
|
||||
for (block_hash, block_header) in block_hashes.iter().zip(block_headers) {
|
||||
let block = Block {
|
||||
block_header,
|
||||
block_hash: block_hash.to_string(),
|
||||
@@ -120,6 +110,7 @@ mod tests {
|
||||
KZG<'static, Bn254>,
|
||||
Pedersen<Projective2>,
|
||||
>;
|
||||
|
||||
type DECIDER = Decider<
|
||||
Projective,
|
||||
GVar,
|
||||
@@ -128,8 +119,8 @@ mod tests {
|
||||
BTCBlockCheckerFCircuit<Fr>,
|
||||
KZG<'static, Bn254>,
|
||||
Pedersen<Projective2>,
|
||||
Groth16<Bn254>, // here we define the Snark to use in the decider
|
||||
NOVA, // here we define the FoldingScheme to use
|
||||
Groth16<Bn254>,
|
||||
NOVA,
|
||||
>;
|
||||
|
||||
let n_blocks_checked = blocks_prepared.len();
|
||||
@@ -138,11 +129,20 @@ mod tests {
|
||||
let z_0 = vec![Fr::from(0)];
|
||||
let mut nova = NOVA::init(&prover_params, circuit, z_0.clone()).unwrap();
|
||||
|
||||
for _ in 0..n_blocks_checked {
|
||||
nova.prove_step().unwrap();
|
||||
println!("Computing folds...");
|
||||
let now = Instant::now();
|
||||
for i in 0..n_blocks_checked {
|
||||
let current_state = nova.z_i[0].into_bigint();
|
||||
println!("Checked block: {}", current_state);
|
||||
if i % 10 == 0 {
|
||||
println!("--- At block: {}/{} ---", current_state, n_blocks_checked);
|
||||
}
|
||||
nova.prove_step().unwrap();
|
||||
}
|
||||
let elapsed = now.elapsed();
|
||||
println!(
|
||||
"Done folding. Checked {} blocks in: {:.2?}",
|
||||
n_blocks_checked, elapsed
|
||||
);
|
||||
|
||||
let circuit = DeciderEthCircuit::<
|
||||
Projective,
|
||||
@@ -155,14 +155,21 @@ mod tests {
|
||||
.unwrap();
|
||||
let mut rng = rand::rngs::OsRng;
|
||||
|
||||
// decider setup
|
||||
println!("Starting setup...");
|
||||
let now = Instant::now();
|
||||
let (g16_pk, g16_vk) =
|
||||
Groth16::<Bn254>::circuit_specific_setup(circuit.clone(), &mut rng).unwrap();
|
||||
let elapsed = now.elapsed();
|
||||
println!("Setup done in: {:.2?}", elapsed);
|
||||
|
||||
// decider proof generation
|
||||
println!("Generating proof...");
|
||||
let now = Instant::now();
|
||||
let decider_pp = (poseidon_config.clone(), g16_pk, prover_params.cs_params);
|
||||
let proof = DECIDER::prove(decider_pp, rng, nova.clone()).unwrap();
|
||||
let elapsed = now.elapsed();
|
||||
println!("Proof generated in: {:.2?}", elapsed);
|
||||
|
||||
// decider proof verification
|
||||
println!("Verifying proof...");
|
||||
@@ -173,4 +180,3 @@ mod tests {
|
||||
.unwrap();
|
||||
assert!(verified);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user