Skip to content

Commit

Permalink
add contract (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
xander42280 authored Sep 10, 2024
1 parent 719c05e commit e7fda23
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 1 deletion.
1 change: 1 addition & 0 deletions sdk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ plonky2_maybe_rayon = { git = "https://github.com/zkMIPS/plonky2.git", branch =

tonic = "0.8.1"
prost = "0.11.0"
reqwest = { version = "0.11", features = ["rustls-tls"] }
tokio = { version = "1.21.0", features = ["macros", "rt-multi-thread", "signal"] }
ethers = "2.0.14"

Expand Down
14 changes: 14 additions & 0 deletions sdk/src/network/prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,12 @@ impl NetworkProver {
let signature = self.wallet.sign_message(sign_data).await.unwrap();
request.signature = signature.to_string();
}

pub async fn download_file(url: &str) -> anyhow::Result<Vec<u8>> {
let response = reqwest::get(url).await?;
let content = response.bytes().await?;
Ok(content.to_vec())
}
}

#[async_trait]
Expand Down Expand Up @@ -121,12 +127,20 @@ impl Prover for NetworkProver {

match Status::from_i32(get_status_response.status as i32) {
Some(Status::Computing) => {
log::debug!("generate_proof step: {}", get_status_response.step);
sleep(Duration::from_secs(2)).await;
}
Some(Status::Success) => {
let stark_proof =
NetworkProver::download_file(&get_status_response.stark_proof_url).await?;
let solidity_verifier =
NetworkProver::download_file(&get_status_response.solidity_verifier_url)
.await?;
let proof_result = ProverResult {
output_stream: get_status_response.output_stream,
proof_with_public_inputs: get_status_response.proof_with_public_inputs,
stark_proof,
solidity_verifier,
};
return Ok(Some(proof_result));
}
Expand Down
11 changes: 11 additions & 0 deletions sdk/src/proto/stage.proto
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@ enum Status {
FINAL_ERROR = 8;
}

enum Step {
Init = 0;
InSplit = 1;
InProve = 2;
InAgg = 3;
InAggAll = 4;
InFinal = 5;
End = 6;
}

message BlockFileItem {
string file_name = 1;
bytes file_content = 2;
Expand Down Expand Up @@ -60,4 +70,5 @@ message GetStatusResponse {
string stark_proof_url = 5;
string solidity_verifier_url = 6;
bytes output_stream = 7;
int32 step = 8; // Step
}
3 changes: 2 additions & 1 deletion sdk/src/prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ pub struct ProverInput {
#[derive(Debug, Default, Deserialize, Serialize)]
pub struct ProverResult {
pub output_stream: Vec<u8>,
// pub stark_proof: Vec<u8>,
pub proof_with_public_inputs: Vec<u8>,
pub stark_proof: Vec<u8>,
pub solidity_verifier: Vec<u8>,
}

#[async_trait]
Expand Down

0 comments on commit e7fda23

Please sign in to comment.