Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
neotheprogramist committed Apr 26, 2024
1 parent 441c534 commit a035868
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 12 deletions.
5 changes: 4 additions & 1 deletion bin/saya/src/args/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,10 @@ mod tests {
celestia_namespace: None,
},
},
proof: ProofOptions { world_address: Default::default(), fact_registry_address: Default::default() },
proof: ProofOptions {
world_address: Default::default(),
fact_registry_address: Default::default(),
},
};

let config: SayaConfig = args.try_into().unwrap();
Expand Down
18 changes: 12 additions & 6 deletions crates/saya/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ use crate::prover::{extract_messages, ProgramInput};

pub mod blockchain;
pub mod data_availability;
pub mod dojo_os;
pub mod error;
pub mod prover;
pub mod dojo_os;
pub mod verifier;

pub(crate) const LOG_TARGET: &str = "saya::core";
Expand Down Expand Up @@ -205,19 +205,25 @@ impl Saya {
trace!(target: LOG_TARGET, world_da = ?world_da_printable, "World DA computed.");

trace!(target: LOG_TARGET, "Proving block {block_number}.");
let proof = prover::prove(new_program_input.serialize(self.config.world_address)?, ProverIdentifier::Http(self.config.prover_url.clone())).await?;
let proof = prover::prove(
new_program_input.serialize(self.config.world_address)?,
ProverIdentifier::Http(self.config.prover_url.clone()),
)
.await?;
info!(target: LOG_TARGET, block_number, "Block proven.");

let serialized_proof: Vec<FieldElement> = parse(&proof)?.into();

trace!(target: LOG_TARGET, block_number, "Verifying block.");
let transaction_hash =
verifier::verify(VerifierIdentifier::HerodotusStarknetSepolia(self.config.fact_registry_address), serialized_proof).await?;
let transaction_hash = verifier::verify(
VerifierIdentifier::HerodotusStarknetSepolia(self.config.fact_registry_address),
serialized_proof,
)
.await?;
info!(target: LOG_TARGET, block_number, transaction_hash, "Block verified.");

let ExtractProgramResult { program: _, program_hash } = extract_program(&proof)?;
let ExtractOutputResult { program_output, program_output_hash } =
extract_output(&proof)?;
let ExtractOutputResult { program_output, program_output_hash } = extract_output(&proof)?;
let expected_fact = poseidon_hash_many(&[program_hash, program_output_hash]).to_string();
info!(target: LOG_TARGET, expected_fact, "Expected fact.");

Expand Down
2 changes: 1 addition & 1 deletion crates/saya/core/src/prover/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ pub async fn prove(input: String, prover: ProverIdentifier) -> anyhow::Result<St
ProverIdentifier::Sharp => todo!(),
ProverIdentifier::Stone => todo!(),
ProverIdentifier::Platinum => todo!(),
ProverIdentifier::Http(prover_url) => http_prove(prover_url, input).await
ProverIdentifier::Http(prover_url) => http_prove(prover_url, input).await,
}
}

Expand Down
11 changes: 8 additions & 3 deletions crates/saya/core/src/verifier/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
//! an interface to query the on-chain verifier, but also
//! submitting facts and proofs.
use serde::{Deserialize, Serialize};
use ::starknet::core::types::FieldElement;
use serde::{Deserialize, Serialize};

mod starknet;

Expand All @@ -20,12 +20,17 @@ pub enum VerifierIdentifier {
StarkwareEthereum,
}

pub async fn verify(verifier: VerifierIdentifier, serialized_proof: Vec<FieldElement>) -> anyhow::Result<String> {
pub async fn verify(
verifier: VerifierIdentifier,
serialized_proof: Vec<FieldElement>,
) -> anyhow::Result<String> {
match verifier {
VerifierIdentifier::HerodotusStarknetSepolia(fact_registry_address) => {
starknet::starknet_verify(fact_registry_address, serialized_proof).await
}
VerifierIdentifier::StoneLocal => unimplemented!("Stone Verifier not yet supported"),
VerifierIdentifier::StarkwareEthereum => unimplemented!("Herodotus Starknet not yet supported"),
VerifierIdentifier::StarkwareEthereum => {
unimplemented!("Herodotus Starknet not yet supported")
}
}
}
1 change: 0 additions & 1 deletion crates/saya/core/src/verifier/starknet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ use tokio::time::sleep;

use crate::dojo_os::STARKNET_ACCOUNT;


pub async fn starknet_verify(
fact_registry_address: FieldElement,
serialized_proof: Vec<FieldElement>,
Expand Down

0 comments on commit a035868

Please sign in to comment.