Skip to content

Commit 8f4814e

Browse files
committed
Use known exit codes for sdk examples (nexus-xyz#571)
* Use known exit codes for sdk examples. * Formatting. * Add for comment. * More formatting. * Get rid of cmake * Skip formatting. * Minimal exclusion.
1 parent 3c09204 commit 8f4814e

File tree

4 files changed

+24
-11
lines changed

4 files changed

+24
-11
lines changed

sdk/README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ A simple, misuse-resistant SDK for programmatic use of the Nexus zkVM.
88

99
First, install Rust: https://www.rust-lang.org/tools/install.
1010

11-
Also, make sure you have a working version of [cmake](https://cmake.org/).
12-
1311
Next, install the RISC-V target:
1412

1513
```shell

sdk/examples/stwo_build.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@ fn main() {
2121
">>>>> Logging\n{}<<<<<",
2222
view.logs().expect("failed to retrieve debug logs").join("")
2323
);
24-
assert_eq!(view.exit_code().expect("failed to retrieve exit code"), 0);
24+
assert_eq!(
25+
view.exit_code().expect("failed to retrieve exit code"),
26+
nexus_sdk::KnownErrorCodes::ExitSuccess as u32
27+
);
2528

2629
// Normally the prover communicates the seralized proof to the verifier who deserializes it.
2730
//
@@ -39,17 +42,19 @@ fn main() {
3942
// print!("Verifying execution...");
4043
// proof.verify_expected_from_program_path::<&str, (), ()>(
4144
// &(), // no public input
42-
// 0, // exit code = 0
45+
// nexus_sdk::KnownErrorCodes::ExitSuccess as u32,
4346
// &(), // no public output
4447
// &path, // path to expected program binary
4548
// &[] // no associated data,
4649
// ).expect("failed to verify proof");
4750

4851
print!("Verifying execution...");
52+
53+
#[rustfmt::skip]
4954
proof
5055
.verify_expected::<(), ()>(
5156
&(), // no public input
52-
0, // exit code = 0
57+
nexus_sdk::KnownErrorCodes::ExitSuccess as u32,
5358
&(), // no public output
5459
&elf, // expected elf (program binary)
5560
&[], // no associated data,

sdk/examples/stwo_io.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,10 @@ fn main() {
2626
.prove_with_input::<u32, u32>(&3, &5)
2727
.expect("failed to prove program"); // x = 5, y = 3
2828

29-
assert_eq!(view.exit_code().expect("failed to retrieve exit code"), 0);
29+
assert_eq!(
30+
view.exit_code().expect("failed to retrieve exit code"),
31+
nexus_sdk::KnownErrorCodes::ExitSuccess as u32
32+
);
3033

3134
let output: u32 = view
3235
.public_output::<u32>()
@@ -55,17 +58,19 @@ fn main() {
5558
// print!("Verifying execution...");
5659
// proof.verify_expected_from_program_path::<&str, u32, u32>(
5760
// &5, // x = 5
58-
// 0, // exit code = 0
61+
// nexus_sdk::KnownErrorCodes::ExitSuccess as u32,
5962
// &15, // z = 15
6063
// &path, // path to expected program binary
6164
// &[] // no associated data,
6265
// ).expect("failed to verify proof");
6366

6467
print!("Verifying execution...");
68+
69+
#[rustfmt::skip]
6570
proof
6671
.verify_expected::<u32, u32>(
6772
&5, // x = 5
68-
0, // exit code = 0
73+
nexus_sdk::KnownErrorCodes::ExitSuccess as u32,
6974
&15, // z = 15
7075
&elf, // expected elf (program binary)
7176
&[], // no associated data,

sdk/examples/stwo_nobuild.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@ fn main() {
2828
">>>>> Logging\n{}<<<<<",
2929
view.logs().expect("failed to retrieve debug logs").join("")
3030
);
31-
assert_eq!(view.exit_code().expect("failed to retrieve exit code"), 0);
31+
assert_eq!(
32+
view.exit_code().expect("failed to retrieve exit code"),
33+
nexus_sdk::KnownErrorCodes::ExitSuccess as u32
34+
);
3235

3336
// Normally the prover communicates the seralized proof to the verifier who deserializes it.
3437
//
@@ -46,17 +49,19 @@ fn main() {
4649
// print!("Verifying execution...");
4750
// proof.verify_expected_from_program_path::<&str, (), ()>(
4851
// &(), // no public input
49-
// 0, // exit code = 0
52+
// nexus_sdk::KnownErrorCodes::ExitSuccess as u32,
5053
// &(), // no public output
5154
// &path, // path to expected program binary
5255
// &[] // no associated data,
5356
// ).expect("failed to verify proof");
5457

5558
print!("Verifying execution...");
59+
60+
#[rustfmt::skip]
5661
proof
5762
.verify_expected::<(), ()>(
5863
&(), // no public input
59-
0, // exit code = 0
64+
nexus_sdk::KnownErrorCodes::ExitSuccess as u32,
6065
&(), // no public output
6166
&elf, // expected elf (program binary)
6267
&[], // no associated data,

0 commit comments

Comments
 (0)