-
Notifications
You must be signed in to change notification settings - Fork 190
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* proof serialization * proof verification on deployed contract * calling verifier contract from rust * cleaned implementation * cleaned dependecies * refined custom serialization * most of state fetched * fetching prev and genesis blocks * minimal reproduction * final touches * typo * fetching optimization * minor PR fixes * removed leftover scsript * using cartridge repository for parser * moved setup to the new method * passing prover and veryfier to cli * insuffiecient fee fix * typo in cli Co-authored-by: glihm <[email protected]> * typo in cli Co-authored-by: glihm <[email protected]> * typo in the comment Co-authored-by: glihm <[email protected]> * removed unneeded dependency Co-authored-by: glihm <[email protected]> * changes after review * formatting * fix: minor formatting and skip empty blocks * fix: ensure correct parsing of enums + fix args test * dev: add podman to the dev container * ci: test new container image with podman * fix: disable DinD which is not supported for now by CI * devcontainer: remove podman for now --------- Co-authored-by: Mateusz Zając <[email protected]> Co-authored-by: Mateusz Zając <[email protected]> Co-authored-by: glihm <[email protected]>
- Loading branch information
1 parent
b8ed6db
commit ad58e43
Showing
16 changed files
with
766 additions
and
29 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
//! Selecting prover and verifier. | ||
use std::fmt::Display; | ||
use std::str::FromStr; | ||
|
||
use anyhow::Result; | ||
use clap::builder::PossibleValue; | ||
use clap::{Args, ValueEnum}; | ||
use saya_core::prover::ProverIdentifier; | ||
use saya_core::verifier::VerifierIdentifier; | ||
|
||
#[derive(Debug, Clone, Copy, PartialEq, Eq)] | ||
pub enum Prover { | ||
Stone, | ||
} | ||
|
||
impl From<Prover> for ProverIdentifier { | ||
fn from(p: Prover) -> Self { | ||
match p { | ||
Prover::Stone => ProverIdentifier::Stone, | ||
} | ||
} | ||
} | ||
|
||
#[derive(Debug, Clone, Copy, PartialEq, Eq)] | ||
pub enum Verifier { | ||
StoneLocal, | ||
HerodotusStarknetSepolia, | ||
} | ||
|
||
impl From<Verifier> for VerifierIdentifier { | ||
fn from(p: Verifier) -> Self { | ||
match p { | ||
Verifier::StoneLocal => VerifierIdentifier::StoneLocal, | ||
Verifier::HerodotusStarknetSepolia => VerifierIdentifier::HerodotusStarknetSepolia, | ||
} | ||
} | ||
} | ||
|
||
#[derive(Debug, Args, Clone)] | ||
pub struct ProofOptions { | ||
#[arg(long)] | ||
#[arg(help = "Prover to generated the proof from the provable program.")] | ||
pub prover: Prover, | ||
|
||
#[arg(long)] | ||
#[arg(help = "Verifier on which the proof should be sent to.")] | ||
pub verifier: Verifier, | ||
} | ||
|
||
// -- Prover. | ||
impl Default for Prover { | ||
fn default() -> Self { | ||
Self::Stone | ||
} | ||
} | ||
|
||
impl ValueEnum for Prover { | ||
fn value_variants<'a>() -> &'a [Self] { | ||
&[Self::Stone] | ||
} | ||
|
||
fn to_possible_value(&self) -> Option<PossibleValue> { | ||
match self { | ||
Self::Stone => Some(PossibleValue::new("stone").alias("Stone")), | ||
} | ||
} | ||
} | ||
|
||
impl FromStr for Prover { | ||
type Err = anyhow::Error; | ||
|
||
fn from_str(s: &str) -> Result<Self> { | ||
match s { | ||
"stone" | "Stone" => Ok(Self::Stone), | ||
_ => Err(anyhow::anyhow!("unknown prover: {}", s)), | ||
} | ||
} | ||
} | ||
|
||
impl Display for Prover { | ||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
match self { | ||
Prover::Stone => write!(f, "stone"), | ||
} | ||
} | ||
} | ||
|
||
// -- Verifier. | ||
impl Default for Verifier { | ||
fn default() -> Self { | ||
Self::StoneLocal | ||
} | ||
} | ||
|
||
impl ValueEnum for Verifier { | ||
fn value_variants<'a>() -> &'a [Self] { | ||
&[Self::StoneLocal, Self::HerodotusStarknetSepolia] | ||
} | ||
|
||
fn to_possible_value(&self) -> Option<PossibleValue> { | ||
match self { | ||
Self::StoneLocal => { | ||
Some(PossibleValue::new("stone-local").alias("stone_local").alias("StoneLocal")) | ||
} | ||
Self::HerodotusStarknetSepolia => Some( | ||
PossibleValue::new("herodotus_starknet_sepolia") | ||
.alias("herodotus-starknet-sepolia") | ||
.alias("HerodotusStarknetSepolia"), | ||
), | ||
} | ||
} | ||
} | ||
|
||
impl FromStr for Verifier { | ||
type Err = anyhow::Error; | ||
|
||
fn from_str(s: &str) -> Result<Self> { | ||
match s { | ||
"stone-local" | "stone_local" | "StoneLocal" => Ok(Self::StoneLocal), | ||
"herodotus-starknet-sepolia" | ||
| "herodotus_starknet_sepolia" | ||
| "HerodotusStarknetSepolia" => Ok(Self::HerodotusStarknetSepolia), | ||
_ => Err(anyhow::anyhow!("unknown verifier: {}", s)), | ||
} | ||
} | ||
} | ||
|
||
impl Display for Verifier { | ||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
match self { | ||
Verifier::StoneLocal => write!(f, "local-stone"), | ||
Verifier::HerodotusStarknetSepolia => write!(f, "herodotus-starknet-sepolia"), | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,5 +7,7 @@ | |
"node_auth_token": "your_auth_token", | ||
"namespace": "katana" | ||
} | ||
} | ||
}, | ||
"prover": "Stone", | ||
"verifier": "StoneLocal" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.