Skip to content

Commit 8150d4d

Browse files
authored
chore: update example (#89)
1 parent 8779f2f commit 8150d4d

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

examples/README.md

+1-4
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,7 @@
77
Write your own hello.go, and compile with
88

99
```
10-
export GOOS=linux
11-
export GOARCH=mips
12-
export GOMIPS=softfloat
13-
go build hello.go
10+
GOOS=linux GOARCH=mips GOMIPS=softfloat go build hello.go
1411
```
1512

1613
* Split the ELF hello into segments. Note that the flag `BLOCK_NO` is only necessary for minigeth.

examples/zkmips.rs

+12-6
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ fn split_elf_into_segs() {
2929
// 1. split ELF into segs
3030
let basedir = env::var("BASEDIR").unwrap_or("/tmp/cannon".to_string());
3131
let elf_path = env::var("ELF_PATH").expect("ELF file is missing");
32-
let block_no = env::var("BLOCK_NO").expect("Block number is missing");
32+
let block_no = env::var("BLOCK_NO");
3333
let seg_path = env::var("SEG_OUTPUT").expect("Segment output path is missing");
3434
let seg_size = env::var("SEG_SIZE").unwrap_or(format!("{SEGMENT_STEPS}"));
3535
let seg_size = seg_size.parse::<_>().unwrap_or(SEGMENT_STEPS);
@@ -42,8 +42,14 @@ fn split_elf_into_segs() {
4242
state.patch_go(&file);
4343
state.patch_stack(&args);
4444

45-
let block_path = get_block_path(&basedir, &block_no, "");
46-
state.load_input(&block_path);
45+
let block_path = match block_no {
46+
Ok(no) => {
47+
let block_path = get_block_path(&basedir, &no, "");
48+
state.load_input(&block_path);
49+
block_path
50+
}
51+
_ => "".to_string(),
52+
};
4753

4854
let mut instrumented_state = InstrumentedState::new(state, block_path);
4955
instrumented_state.split_segment(false, &seg_path);
@@ -66,7 +72,7 @@ fn split_elf_into_segs() {
6672

6773
fn prove_single_seg() {
6874
let basedir = env::var("BASEDIR").unwrap_or("/tmp/cannon".to_string());
69-
let block = env::var("BLOCK_NO").expect("Block number is missing");
75+
let block = env::var("BLOCK_NO").unwrap_or("".to_string());
7076
let file = env::var("BLOCK_FILE").unwrap_or(String::from(""));
7177
let seg_file = env::var("SEG_FILE").expect("Segment file is missing");
7278
let seg_size = env::var("SEG_SIZE").unwrap_or(format!("{SEGMENT_STEPS}"));
@@ -127,7 +133,7 @@ fn aggregate_proof() -> anyhow::Result<()> {
127133
type C = PoseidonGoldilocksConfig;
128134

129135
let basedir = env::var("BASEDIR").unwrap_or("/tmp/cannon".to_string());
130-
let block = env::var("BLOCK_NO").expect("Block number is missing");
136+
let block = env::var("BLOCK_NO").unwrap_or("".to_string());
131137
let file = env::var("BLOCK_FILE").unwrap_or(String::from(""));
132138
let seg_file = env::var("SEG_FILE").expect("first segment file is missing");
133139
let seg_file2 = env::var("SEG_FILE2").expect("The next segment file is missing");
@@ -198,7 +204,7 @@ fn aggregate_proof_all() -> anyhow::Result<()> {
198204
type C = PoseidonGoldilocksConfig;
199205

200206
let basedir = env::var("BASEDIR").unwrap_or("/tmp/cannon".to_string());
201-
let block = env::var("BLOCK_NO").expect("Block number is missing");
207+
let block = env::var("BLOCK_NO").unwrap_or("".to_string());
202208
let file = env::var("BLOCK_FILE").unwrap_or(String::from(""));
203209
let seg_dir = env::var("SEG_FILE_DIR").expect("segment file dir is missing");
204210
let seg_file_number = env::var("SEG_FILE_NUM").expect("The segment file number is missing");

0 commit comments

Comments
 (0)