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
18 changes: 9 additions & 9 deletions Cargo.lock

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

14 changes: 7 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ resolver = "2"
[workspace.dependencies]
mina-p2p-messages = { path = "mina-p2p-messages" }
ledger = { path = "ledger", package = "mina-tree" }
mina-hasher = { git = "https://github.com/openmina/proof-systems", branch = "ledger-newtypes-rampup4-vrf" }
mina-signer = { git = "https://github.com/openmina/proof-systems", branch = "ledger-newtypes-rampup4-vrf" }
mina-curves = { git = "https://github.com/openmina/proof-systems", branch = "ledger-newtypes-rampup4-vrf" }
o1-utils = { git = "https://github.com/openmina/proof-systems", branch = "ledger-newtypes-rampup4-vrf" }
kimchi = { git = "https://github.com/openmina/proof-systems", branch = "ledger-newtypes-rampup4-vrf" }
mina-poseidon = {git = "https://github.com/openmina/proof-systems", branch = "ledger-newtypes-rampup4-vrf"}
poly-commitment = {git = "https://github.com/openmina/proof-systems", branch = "ledger-newtypes-rampup4-vrf"}
mina-hasher = { git = "https://github.com/openmina/proof-systems", rev = "7755e09" }
mina-signer = { git = "https://github.com/openmina/proof-systems", rev = "7755e09" }
mina-curves = { git = "https://github.com/openmina/proof-systems", rev = "7755e09" }
o1-utils = { git = "https://github.com/openmina/proof-systems", rev = "7755e09" }
kimchi = { git = "https://github.com/openmina/proof-systems", rev = "7755e09" }
mina-poseidon = {git = "https://github.com/openmina/proof-systems", rev = "7755e09"}
poly-commitment = {git = "https://github.com/openmina/proof-systems", rev = "7755e09"}
libp2p = { git = "https://github.com/openmina/rust-libp2p", rev = "5c44c7d9", default-features = false }
vrf = { path = "vrf" }
openmina-node-account = { path = "node/account" }
Expand Down
17 changes: 14 additions & 3 deletions cli/src/commands/node/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
use std::{fs::File, path::PathBuf, sync::Arc};

use anyhow::Context;
use node::{account::AccountSecretKey, transition_frontier::genesis::GenesisConfig};
use ledger::proofs::gates::BlockProver;
use node::{
account::AccountSecretKey,
snark::{get_verifier_index, VerifierKind},
transition_frontier::genesis::GenesisConfig,
};

use openmina_node_account::AccountPublicKey;
use reqwest::Url;
Expand Down Expand Up @@ -198,13 +203,19 @@ impl Node {
node_builder.initial_peers_from_url(url)?;
}

let block_verifier_index = Arc::new(get_verifier_index(VerifierKind::Blockchain));
let work_verifier_index = Arc::new(get_verifier_index(VerifierKind::Transaction));
node_builder
.block_verifier_index(block_verifier_index.clone())
.work_verifier_index(work_verifier_index.clone());

if let (Some(producer_key_path), Some(pasword)) =
(self.producer_key, &self.producer_key_password)
{
node::core::info!(node::core::log::system_time(); summary = "loading provers index");
ledger::proofs::gates::BlockProver::make();
let provers = BlockProver::make(Some(block_verifier_index), Some(work_verifier_index));
node::core::info!(node::core::log::system_time(); summary = "loaded provers index");
node_builder.block_producer_from_file(producer_key_path, pasword)?;
node_builder.block_producer_from_file(provers, producer_key_path, pasword)?;

if let Some(pub_key) = self.coinbase_receiver {
node_builder
Expand Down
4 changes: 2 additions & 2 deletions ledger/src/proofs/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1872,10 +1872,10 @@ pub(super) fn generate_block_proof(
};

let dlog_plonk_index = super::merge::dlog_plonk_index(block_wrap_prover);
let verifier_index = block_wrap_prover.index.verifier_index.as_ref().unwrap();
let verifier_index = &**block_wrap_prover.index.verifier_index.as_ref().unwrap();

let tx_dlog_plonk_index = super::merge::dlog_plonk_index(tx_wrap_prover);
let tx_verifier_index = tx_wrap_prover.index.verifier_index.as_ref().unwrap();
let tx_verifier_index = &**tx_wrap_prover.index.verifier_index.as_ref().unwrap();

let dlog_plonk_index_cvar = dlog_plonk_index.to_cvar(CircuitVar::Var);
let tx_dlog_plonk_index_cvar = tx_dlog_plonk_index.to_cvar(CircuitVar::Constant);
Expand Down
73 changes: 54 additions & 19 deletions ledger/src/proofs/gates.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::{collections::HashMap, path::Path, sync::Arc};

use kimchi::circuits::gate::CircuitGate;
use kimchi::verifier_index::VerifierIndex;
use mina_curves::pasta::Fq;
use mina_hasher::Fp;
use once_cell::sync::OnceCell;
Expand Down Expand Up @@ -242,6 +243,9 @@ async fn make_gates<F: FieldWitness>(

macro_rules! get_or_make {
($constant: ident, $type: ty, $filename: expr) => {{
get_or_make!($constant, $type, None, $filename)
}};
($constant: ident, $type: ty, $verifier_index: expr, $filename: expr) => {{
if let Some(prover) = $constant.get() {
return prover.clone();
}
Expand All @@ -254,7 +258,7 @@ macro_rules! get_or_make {
res
};

let index = make_prover_index::<$type, _>(gates);
let index = make_prover_index::<$type, _>(gates, $verifier_index);
let prover = Prover {
internal_vars,
rows_rev,
Expand Down Expand Up @@ -289,10 +293,14 @@ mod prover_makers {
config.step_transaction_gates
)
}
fn get_or_make_tx_wrap_prover(config: &CircuitsConfig) -> Arc<Prover<Fq>> {
fn get_or_make_tx_wrap_prover(
config: &CircuitsConfig,
verifier_index: Option<Arc<VerifierIndex<<Fq as FieldWitness>::OtherCurve>>>,
) -> Arc<Prover<Fq>> {
get_or_make!(
TX_WRAP_PROVER,
WrapTransactionProof,
verifier_index,
config.wrap_transaction_gates
)
}
Expand All @@ -306,10 +314,14 @@ mod prover_makers {
config.step_blockchain_gates
)
}
fn get_or_make_block_wrap_prover(config: &CircuitsConfig) -> Arc<Prover<Fq>> {
fn get_or_make_block_wrap_prover(
config: &CircuitsConfig,
verifier_index: Option<Arc<VerifierIndex<<Fq as FieldWitness>::OtherCurve>>>,
) -> Arc<Prover<Fq>> {
get_or_make!(
BLOCK_WRAP_PROVER,
WrapBlockProof,
verifier_index,
config.wrap_blockchain_gates
)
}
Expand Down Expand Up @@ -338,11 +350,14 @@ mod prover_makers {
}

impl BlockProver {
pub fn make() -> Self {
pub fn make(
block_verifier_index: Option<Arc<VerifierIndex<<Fq as FieldWitness>::OtherCurve>>>,
tx_verifier_index: Option<Arc<VerifierIndex<<Fq as FieldWitness>::OtherCurve>>>,
) -> Self {
let config = default_circuits_config();
let block_step_prover = get_or_make_block_step_prover(config);
let block_wrap_prover = get_or_make_block_wrap_prover(config);
let tx_wrap_prover = get_or_make_tx_wrap_prover(config);
let block_wrap_prover = get_or_make_block_wrap_prover(config, block_verifier_index);
let tx_wrap_prover = get_or_make_tx_wrap_prover(config, tx_verifier_index);

Self {
block_step_prover,
Expand All @@ -353,10 +368,12 @@ mod prover_makers {
}

impl TransactionProver {
pub fn make() -> Self {
pub fn make(
tx_verifier_index: Option<Arc<VerifierIndex<<Fq as FieldWitness>::OtherCurve>>>,
) -> Self {
let config = default_circuits_config();
let tx_step_prover = get_or_make_tx_step_prover(config);
let tx_wrap_prover = get_or_make_tx_wrap_prover(config);
let tx_wrap_prover = get_or_make_tx_wrap_prover(config, tx_verifier_index);
let merge_step_prover = get_or_make_merge_step_prover(config);

Self {
Expand All @@ -368,9 +385,11 @@ mod prover_makers {
}

impl ZkappProver {
pub fn make() -> Self {
pub fn make(
tx_verifier_index: Option<Arc<VerifierIndex<<Fq as FieldWitness>::OtherCurve>>>,
) -> Self {
let config = default_circuits_config();
let tx_wrap_prover = get_or_make_tx_wrap_prover(config);
let tx_wrap_prover = get_or_make_tx_wrap_prover(config, tx_verifier_index);
let merge_step_prover = get_or_make_merge_step_prover(config);
let step_opt_signed_opt_signed_prover =
get_or_make_zkapp_step_opt_signed_opt_signed_prover(config);
Expand Down Expand Up @@ -399,10 +418,14 @@ mod prover_makers {
config.step_transaction_gates
)
}
async fn get_or_make_tx_wrap_prover(config: &CircuitsConfig) -> Arc<Prover<Fq>> {
async fn get_or_make_tx_wrap_prover(
config: &CircuitsConfig,
verifier_index: Option<Arc<VerifierIndex<<Fq as FieldWitness>::OtherCurve>>>,
) -> Arc<Prover<Fq>> {
get_or_make!(
TX_WRAP_PROVER,
WrapTransactionProof,
verifier_index,
config.wrap_transaction_gates
)
}
Expand All @@ -416,10 +439,14 @@ mod prover_makers {
config.step_blockchain_gates
)
}
async fn get_or_make_block_wrap_prover(config: &CircuitsConfig) -> Arc<Prover<Fq>> {
async fn get_or_make_block_wrap_prover(
config: &CircuitsConfig,
verifier_index: Option<Arc<VerifierIndex<<Fq as FieldWitness>::OtherCurve>>>,
) -> Arc<Prover<Fq>> {
get_or_make!(
BLOCK_WRAP_PROVER,
WrapBlockProof,
verifier_index,
config.wrap_blockchain_gates
)
}
Expand Down Expand Up @@ -448,11 +475,15 @@ mod prover_makers {
}

impl BlockProver {
pub async fn make() -> Self {
pub async fn make(
block_verifier_index: Option<Arc<VerifierIndex<<Fq as FieldWitness>::OtherCurve>>>,
tx_verifier_index: Option<Arc<VerifierIndex<<Fq as FieldWitness>::OtherCurve>>>,
) -> Self {
let config = default_circuits_config();
let block_step_prover = get_or_make_block_step_prover(config).await;
let block_wrap_prover = get_or_make_block_wrap_prover(config).await;
let tx_wrap_prover = get_or_make_tx_wrap_prover(config).await;
let block_wrap_prover =
get_or_make_block_wrap_prover(config, block_verifier_index).await;
let tx_wrap_prover = get_or_make_tx_wrap_prover(config, tx_verifier_index).await;

Self {
block_step_prover,
Expand All @@ -463,10 +494,12 @@ mod prover_makers {
}

impl TransactionProver {
pub async fn make() -> Self {
pub async fn make(
tx_verifier_index: Option<Arc<VerifierIndex<<Fq as FieldWitness>::OtherCurve>>>,
) -> Self {
let config = default_circuits_config();
let tx_step_prover = get_or_make_tx_step_prover(config).await;
let tx_wrap_prover = get_or_make_tx_wrap_prover(config).await;
let tx_wrap_prover = get_or_make_tx_wrap_prover(config, tx_verifier_index).await;
let merge_step_prover = get_or_make_merge_step_prover(config).await;

Self {
Expand All @@ -478,9 +511,11 @@ mod prover_makers {
}

impl ZkappProver {
pub async fn make() -> Self {
pub async fn make(
tx_verifier_index: Option<Arc<VerifierIndex<<Fq as FieldWitness>::OtherCurve>>>,
) -> Self {
let config = default_circuits_config();
let tx_wrap_prover = get_or_make_tx_wrap_prover(config).await;
let tx_wrap_prover = get_or_make_tx_wrap_prover(config, tx_verifier_index).await;
let merge_step_prover = get_or_make_merge_step_prover(config).await;
let step_opt_signed_opt_signed_prover =
get_or_make_zkapp_step_opt_signed_opt_signed_prover(config).await;
Expand Down
4 changes: 2 additions & 2 deletions ledger/src/proofs/merge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ fn merge_main(
}

pub fn dlog_plonk_index(wrap_prover: &Prover<Fq>) -> PlonkVerificationKeyEvals<Fp> {
PlonkVerificationKeyEvals::from(wrap_prover.index.verifier_index.as_ref().unwrap())
PlonkVerificationKeyEvals::from(&**wrap_prover.index.verifier_index.as_ref().unwrap())
}

impl From<&v2::PicklesProofProofsVerified2ReprStableV2StatementProofStateDeferredValuesPlonkFeatureFlags> for crate::proofs::step::FeatureFlags::<bool> {
Expand Down Expand Up @@ -261,7 +261,7 @@ pub(super) fn generate_merge_proof(

let dlog_plonk_index = dlog_plonk_index(wrap_prover);
let dlog_plonk_index_cvar = dlog_plonk_index.to_cvar(CircuitVar::Var);
let verifier_index = wrap_prover.index.verifier_index.as_ref().unwrap();
let verifier_index = &**wrap_prover.index.verifier_index.as_ref().unwrap();

let tx_data = make_step_transaction_data(&dlog_plonk_index_cvar);
let for_step_datas = [&tx_data, &tx_data];
Expand Down
Loading
Loading