Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(website): Add dev-mode instructions #1033

Merged
merged 24 commits into from
Nov 1, 2023
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
4e3729f
docs(FAQ): Add answer about RISC0_DEV_MODE flag
Cardosaum Oct 25, 2023
40526fc
docs: Add additional context to Fake InnerReceipt
Cardosaum Oct 25, 2023
3e82c51
docs(quickstart): Add note on developer mode
Cardosaum Oct 25, 2023
b1cb39b
chore: format website
Cardosaum Oct 25, 2023
468dda6
Merge branch 'main' into cardosaum/docs/add-risc0-dev-mode-to-website
Cardosaum Oct 25, 2023
4153f94
chore(faq): Minor editings
Cardosaum Oct 25, 2023
5b7d0d3
Merge branch 'cardosaum/docs/add-risc0-dev-mode-to-website' of https:…
Cardosaum Oct 25, 2023
2bd1ac5
Update quickstart.md
SchmErik Oct 25, 2023
80cb0e7
docs(quickstart): improve dev-mode headline
Cardosaum Oct 26, 2023
2f68ed9
docs(website): Rename `developer mode` to `dev-mode`
Cardosaum Oct 26, 2023
e8b8417
Merge branch 'cardosaum/docs/add-risc0-dev-mode-to-website' of https:…
Cardosaum Oct 26, 2023
70b637c
docs(faq): Change workflow for function
Cardosaum Oct 26, 2023
a50a135
docs(quickstart): Enhance description for dev mode
Cardosaum Oct 26, 2023
55aebcc
Merge branch 'main' into cardosaum/docs/add-risc0-dev-mode-to-website
Cardosaum Oct 26, 2023
9d1431a
docs(faq): Clarify runtime dev-mode check, not compile-time
Cardosaum Oct 26, 2023
d7dd47a
docs(dev-mode): Move dev-mode docs to its own page
Cardosaum Oct 26, 2023
90f8094
Merge branch 'main' into cardosaum/docs/add-risc0-dev-mode-to-website
Cardosaum Oct 26, 2023
581b108
docs(quickstart): Inform about dev-mode before teaching how to run th…
Cardosaum Oct 26, 2023
9e03e16
docs(receipt.rs): Link to proper dev-mode page doc
Cardosaum Oct 26, 2023
31b2b8b
chore: Update docs.rs links to latest version using wildcard
Cardosaum Oct 31, 2023
6bb8aa5
Merge branch 'main' into cardosaum/docs/add-risc0-dev-mode-to-website
Cardosaum Oct 31, 2023
6d4e399
chore: Format website
Cardosaum Oct 31, 2023
54c393d
fix potential yarn build issue
SchmErik Oct 31, 2023
206c319
Merge branch 'main' into cardosaum/docs/add-risc0-dev-mode-to-website
SchmErik Oct 31, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion bonsai/ethereum/contracts/BonsaiTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ abstract contract BonsaiTest is Test, BonsaiCheats {
_;
}

/// @notice Returns whether we are using the prover and verifier in dev mode, or fully verifying.
/// @notice Returns whether we are using the prover and verifier in dev-mode, or fully verifying.
function devMode() internal returns (bool) {
return vm.envOr("RISC0_DEV_MODE", true);
}
Expand Down
9 changes: 9 additions & 0 deletions risc0/zkvm/src/host/receipt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,15 @@ pub enum InnerReceipt {
Succinct(SuccinctReceipt),

/// A fake receipt for testing and development.
///
/// This receipt is not valid and will fail verification unless the
/// environment variable `RISC0_DEV_MODE` is set to `true`, in which case a
/// pass-through 'verification' will be performed, but it *does not*
/// represent any meaningful attestation of receipt's integrity.
///
/// This type solely exists to improve development experience, for further
/// information about development-only mode see our [dev-mode
/// documentation](https://dev.risczero.com/zkvm/dev-mode).
Fake,
}

Expand Down
2 changes: 0 additions & 2 deletions website/docs/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,6 @@ Because the data structures supporting all three of these need to match very car
## Security

<a class="anchor" id="image-id-security"></a>

<details closed>
<summary>
Q:
Expand Down Expand Up @@ -284,5 +283,4 @@ A: Like other zk-STARKs, RISC Zero’s implementation makes it cryptographically
- If the binary is modified, then the receipt’s seal will not match the ImageID of the expected binary.
- If the execution is modified, then the execution trace will be invalid.
- If the output is modified, then the journal’s hash will not match the hash recorded in the receipt.

</details>
26 changes: 26 additions & 0 deletions website/docs/zkvm/dev-mode.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
slug: ./
---

# What is dev-mode, and how can you use it safely?

We support a development-only mode for standalone risc0 projects in which code is executed but not proven. This adds efficiency to the development cycle during development stages where proving correct execution is not yet critical.

A risc0 project, when run in dev-mode by setting the `RISC0_DEV_MODE` environment variable, supports ([fake](https://docs.rs/risc0-zkvm/0.19.0/risc0_zkvm/enum.InnerReceipt.html#variant.Fake)) receipt creation and pass-through (fake) 'verification' function, so that dev-mode may be switched on and off at runtime without impacting project workflows.
In particular, receipts generated in dev-mode still include public outputs written to the [journal](https://dev.risczero.com/terminology#journal).

However, because the proving process is bypassed, receipts generated when dev-mode is enabled will fail a standard receipt verification check. Only when the verifier is also run with dev-mode enabled will it perform pass-through 'verification' of the fake receipt.

**To keep this mode out of production environments, we recommend building production-ready projects with the "disable-dev-mode" [feature flag](https://github.com/risc0/risc0/#feature-flags); it is absent by default.**

Only projects built without this flag may run dev-mode. Enabling dev-mode requires also that the environment variable `RISC0_DEV_MODE` be set.

As additional protection, if the dev-mode [environment variable](https://docs.rs/risc0-zkvm/0.18.0/risc0_zkvm/fn.is_dev_mode.html) is present alongside a project built with the "disable-dev-mode" feature flag, the project will panic.

For further reference, take a look at the table below. To learn more about usage, see the [risc0 project README](https://github.com/risc0/risc0/#readme). For a closer look at implementation, take a look at the [dev-mode source](https://github.com/risc0/risc0/blob/v0.19.0-rc.1/risc0/zkvm/src/host/server/prove/dev_mode.rs).

| | `disable-dev-mode` off | `disable-dev-mode` on |
| ----------------------------- | ------------------------ | ------------------------ |
| RISC0_DEV_MODE=true | dev-mode activated | Prover panic |
| RISCO_DEV_MODE={false, unset} | Default project behavior | Default project behavior |

39 changes: 33 additions & 6 deletions website/docs/zkvm/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,39 @@ In the codebase for your new project, you'll find a handful of places marked `TO

Don't worry -- each `TODO` comes with instructions for what you need to do, and the [Hello World tutorial] contains step-by-step instructions.

## 4. Run your project, locally or remotely
## 4. Quick Development: Leveraging Dev Mode

The readme for your project includes instructions for how to run it, both locally or remotely.
You can build your example and run the prover locally with:
During the development of your project, you might find that running your code can take a long time due to the proof generation process. To address this issue and allow for faster iterations of your code, we suggest utilizing [dev-mode]. This mode bypasses the time-consuming proof generation process. To activate dev-mode, simply set the environment variable `RISC0_DEV_MODE=true` when executing your project (other acceptable values include `1` and `yes`).

Example:

```bash
RISC0_DEV_MODE=true cargo run --release
```

For a deeper understanding of dev-mode and its safe usage, please refer to our page explaining [what is dev-mode]. Please note that dev-mode is only meant to be used during development and testing. It should **never** be used in production.

Cardosaum marked this conversation as resolved.
Show resolved Hide resolved
## 5. Real Proof Generation

Once you've reached a point where you're ready to generate real proofs, you can do so by unseting the `RISC0_DEV_MODE` environment variable (or setting it to `RISC0_DEV_MODE=false`). We recommend that you additionally specify the feature flag `disable-dev-mode`, which will ensure that dev-mode is not accidentally enabled. Please consult more information about `disable-dev-mode` in the [feature flags] table, and the [dev-mode] page for more information.

Proceeding with the example above, generating proofs locally would be achieved by running:

```bash
cargo run --release
RISC0_DEV_MODE=false cargo run --release --features disable-dev-mode
```

> **Congratulations!** <br/>_That's all it takes to build and run a minimal RISC Zero application._
Note that `RISC0_DEV_MODE=false` is the default behavior, so you can also simply run:

```bash
cargo run --release --features disable-dev-mode
```

## Local & Remote Proving
We would always recommend using `disable-dev-mode` in production, as it ensures that dev-mode is not accidentally enabled.

Also, note that since now proofs are being generated, the execution time of your project will be significantly longer than when running in dev-mode. You might want to consider using [Bonsai] to generate proofs remotely, as it will likely be faster than running proofs locally.

## 6. Local & Remote Proving

You can build and run your zkVM applications using your own hardware, or you can upload your [guest program] to [Bonsai] and make requests for proof generation as needed.

Expand All @@ -69,6 +90,10 @@ Additional information is available in the [starter template](https://github.com

Options such as GPU acceleration and skipping the proof generation are documented in the [feature flags].

> **Congratulations!**
>
> _That's all it takes to build and run a minimal RISC Zero application._

[zkVM]: ../zkvm/zkvm_overview.md
[guest program]: ../terminology.md#guest-program
[Bonsai]: ../bonsai/bonsai-overview.md
Expand All @@ -80,3 +105,5 @@ Options such as GPU acceleration and skipping the proof generation are documente
[demo applications]: https://github.com/risc0/risc0/tree/v0.18.0/examples
[Bonsai Quick Start]: ../bonsai/quickstart.md
[request access]: https://bonsai.xyz/apply
[dev-mode]: ./dev-mode.md
[what is dev-mode]: ./dev-mode.md
5 changes: 5 additions & 0 deletions website/sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ const sidebars = {
label: "Quick Start",
id: "zkvm/quickstart",
},
{
type: "doc",
label: "Dev Mode",
id: "zkvm/dev-mode",
},
{
type: "link",
label: "API Reference Docs",
Expand Down