Skip to content

Commit

Permalink
refactor: install plonk artifacts before proving (#44)
Browse files Browse the repository at this point in the history
* refactor: install plonk artifacts before proving

Signed-off-by: Thomas Chataigner <[email protected]>

* docs: 128core bare metal

Signed-off-by: Thomas Chataigner <[email protected]>

---------

Signed-off-by: Thomas Chataigner <[email protected]>
  • Loading branch information
tchataigner authored Jun 24, 2024
1 parent 4890486 commit 0fe52b5
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 17 deletions.
24 changes: 12 additions & 12 deletions aptos/Cargo.lock

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

10 changes: 5 additions & 5 deletions aptos/docs/src/run/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ inclusion proofs.
As the computational requirements for the Proof Server are heavy, here are the recommended specs for the machine that
should be running each component:

| | CPU | Memory (GB) | Disk Size (GB) | Example |
|-----------------------------------------------------------------------|----------------------------------------------------------------------------------------------|-------------|----------------|--------------------------------------------------------------------------|
| Client | 8 cores, 16 threads | 32 | 64 | [GCP C3](https://cloud.google.com/compute/docs/general-purpose-machines) |
| Proof Server | Intel x86_64 Sapphire Rapids, 64 vCPU, bare metal, supports `avx512_ifma` and `avx512_vbmi2` | 512 | 500 | [AWS R7iz](https://aws.amazon.com/ec2/instance-types/r7iz/) |
| [Aptos Full Node](https://aptos.dev/nodes/full-node/pfn-requirements) | 8 cores, 16 threads (Intel Xeon Skylake or newer) | 32 | A few 100's GB | [GCP C3](https://cloud.google.com/compute/docs/general-purpose-machines) |
| | CPU | Memory (GB) | Disk Size (GB) | Example |
|-----------------------------------------------------------------------|-----------------------------------------------------------------------------------------------|-------------|----------------|--------------------------------------------------------------------------|
| Client | 8 cores, 16 threads | 32 | 64 | [GCP C3](https://cloud.google.com/compute/docs/general-purpose-machines) |
| Proof Server | Intel x86_64 Sapphire Rapids, 128 vCPU, bare metal, supports `avx512_ifma` and `avx512_vbmi2` | 512 | 500 | [AWS R7iz bare metal](https://aws.amazon.com/ec2/instance-types/r7iz/) |
| [Aptos Full Node](https://aptos.dev/nodes/full-node/pfn-requirements) | 8 cores, 16 threads (Intel Xeon Skylake or newer) | 32 | A few 100's GB | [GCP C3](https://cloud.google.com/compute/docs/general-purpose-machines) |
4 changes: 4 additions & 0 deletions aptos/light-client/benches/e2e.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ use aptos_lc_core::crypto::hash::{CryptoHash, HashValue};
use aptos_lc_core::types::trusted_state::{EpochChangeProof, TrustedState, TrustedStateChange};
use aptos_lc_core::types::validator::ValidatorVerifier;
use serde::Serialize;
use sphinx_sdk::artifacts::try_install_plonk_bn254_artifacts;
use sphinx_sdk::utils::setup_logger;
use sphinx_sdk::{ProverClient, SphinxPlonkBn254Proof, SphinxProof, SphinxStdin};
use std::env;
Expand Down Expand Up @@ -197,6 +198,9 @@ fn main() {
// Finally, set environment for snark proofs.
set_snark_environment();

// Install PLONK artifacts.
try_install_plonk_bn254_artifacts(false);

// Execute snark generation for epoch change.
let start_epoch_change_snark_proving = Instant::now();
let _ = prove_epoch_change(
Expand Down
4 changes: 4 additions & 0 deletions aptos/light-client/src/epoch_change.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ fn prove_epoch_change(
mod test {
use crate::epoch_change::setup_assets;
use crate::error::LightClientError;
use sphinx_sdk::artifacts::try_install_plonk_bn254_artifacts;
use sphinx_sdk::utils::setup_logger;
use sphinx_sdk::{ProverClient, SphinxStdin};

Expand Down Expand Up @@ -173,6 +174,9 @@ mod test {

let stdin = generate_stdin(trusted_state.as_slice(), &epoch_change_proof);

// Install PLONK artifacts.
try_install_plonk_bn254_artifacts(false);

let start = Instant::now();
println!("Starting generation of prove_epoch_change proof...");
let snark_proof = client.prove_plonk(&pk, stdin).unwrap();
Expand Down
4 changes: 4 additions & 0 deletions aptos/light-client/src/inclusion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ mod test {
setup_assets, SparseMerkleProofAssets, TransactionProofAssets, ValidatorVerifierAssets,
};
use aptos_lc_core::types::validator::ValidatorVerifier;
use sphinx_sdk::artifacts::try_install_plonk_bn254_artifacts;
use sphinx_sdk::utils::setup_logger;
use sphinx_sdk::{ProverClient, SphinxStdin};

Expand Down Expand Up @@ -317,6 +318,9 @@ mod test {
&validator_verifier_assets,
);

// Install PLONK artifacts.
try_install_plonk_bn254_artifacts(false);

let start = Instant::now();
println!("Starting generation of inclusion proof...");
let snark_proof = client.prove_plonk(&pk, stdin).unwrap();
Expand Down
6 changes: 6 additions & 0 deletions aptos/proof-server/benches/proof_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use proof_server::types::aptos::{AccountInclusionProofResponse, EpochChangeProof
use proof_server::types::proof_server::{EpochChangeData, InclusionData, Request};
use proof_server::utils::{read_bytes, write_bytes};
use serde::Serialize;
use sphinx_sdk::artifacts::try_install_plonk_bn254_artifacts;
use std::env;
use std::fs::File;
use std::io::Read;
Expand Down Expand Up @@ -44,6 +45,11 @@ fn main() -> Result<(), anyhow::Error> {

let rt = Runtime::new().unwrap();

if final_snark {
// Install PLONK artifacts.
try_install_plonk_bn254_artifacts(false);
}

// Start secondary server
let mut secondary_server_process = rt.block_on(start_secondary_server(final_snark))?;

Expand Down

0 comments on commit 0fe52b5

Please sign in to comment.