Skip to content

Commit

Permalink
feat: only call entrypoint in zkvm (#1611)
Browse files Browse the repository at this point in the history
  • Loading branch information
xJonathanLEI authored Oct 7, 2024
1 parent 10ebf6c commit 1c1f84d
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 8 deletions.
8 changes: 8 additions & 0 deletions crates/zkvm/entrypoint/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,14 @@ macro_rules! entrypoint {

#[no_mangle]
fn main() {
// Link to the actual entrypoint only when compiling for zkVM. Doing this avoids
// compilation errors when building for the host target.
//
// Note that, however, it's generally considered wasted effort compiling zkVM
// programs against the host target. This just makes it such that doing so wouldn't
// result in an error, which can happen when building a Cargo workspace containing
// zkVM program crates.
#[cfg(target_os = "zkvm")]
super::ZKVM_ENTRY()
}
}
Expand Down
2 changes: 1 addition & 1 deletion examples/json/program/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ sp1_zkvm::entrypoint!(main);
use lib::{Account, Transaction}; // Custom structs.
use serde_json::Value; // Generic JSON.

fn main() {
pub fn main() {
// read generic JSON example inputs.
let data_str = sp1_zkvm::io::read::<String>();
let key = sp1_zkvm::io::read::<String>();
Expand Down
2 changes: 1 addition & 1 deletion examples/patch-testing/program/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ fn test_secp256k1_patch() {
}

/// To add testing for a new patch, add a new case to the function below.
fn main() {
pub fn main() {
// TODO: Specify which syscalls are linked to each function invocation, iterate
// over this list that is shared between the program and script.
test_keccak();
Expand Down
2 changes: 1 addition & 1 deletion examples/patch-testing/script/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use sp1_sdk::{utils, ProverClient, SP1Stdin};
const PATCH_TEST_ELF: &[u8] = include_bytes!("../../program/elf/riscv32im-succinct-zkvm-elf");

/// This script is used to test that SP1 patches are correctly applied and syscalls are triggered.
fn main() {
pub fn main() {
utils::setup_logger();

let stdin = SP1Stdin::new();
Expand Down
2 changes: 1 addition & 1 deletion examples/ssz-withdrawals/program/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use hex_literal::hex;
use ssz_rs::prelude::*;
use std::collections::HashMap;

fn main() {
pub fn main() {
// Get inputs.
let beacon_block_root =
node_from_bytes(hex!("d00c4da1a3ad4d42bd35f128544227d19e163194569d69d54a3d14112e3c897c"));
Expand Down
2 changes: 1 addition & 1 deletion examples/tendermint/program/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use tendermint_light_client_verifier::{
options::Options, types::LightBlock, ProdVerifier, Verdict, Verifier,
};

fn main() {
pub fn main() {
// Normally we could just do this to read in the LightBlocks, but bincode doesn't work with LightBlock.
// This is likely a bug in tendermint-rs.
// let light_block_1 = sp1_zkvm::io::read::<LightBlock>();
Expand Down
2 changes: 1 addition & 1 deletion examples/tendermint/script/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ fn get_light_blocks() -> (LightBlock, LightBlock) {
(light_block_1, light_block_2)
}

fn main() {
pub fn main() {
// Generate proof.
utils::setup_logger();

Expand Down
2 changes: 1 addition & 1 deletion tests/tendermint-benchmark/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ pub struct BlockValidatorSet {
pub total: String,
}

fn main() {
pub fn main() {
let peer_id: [u8; 20] = [
0x72, 0x6b, 0xc8, 0xd2, 0x60, 0x38, 0x7c, 0xf5, 0x6e, 0xcf, 0xad, 0x3a, 0x6b, 0xf6, 0xfe,
0xcd, 0x90, 0x3e, 0x18, 0xa2,
Expand Down
2 changes: 1 addition & 1 deletion tests/uint256-mul/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ fn biguint_to_bytes_le(x: BigUint) -> [u8; 32] {
}

#[sp1_derive::cycle_tracker]
fn main() {
pub fn main() {
for _ in 0..50 {
// Test with random numbers.
let mut rng = rand::thread_rng();
Expand Down

0 comments on commit 1c1f84d

Please sign in to comment.