Skip to content

Commit 980517f

Browse files
authored
BM-218: Improve local devnet docs instructions (github#49)
Also includes: - move to ` ```sh ` and ` ```txt ` code blocks to get `hilight.js` to work better (comments in script snippets mostly) - minor glossary fixes - minor style tweask
1 parent 1a8e242 commit 980517f

File tree

9 files changed

+178
-92
lines changed

9 files changed

+178
-92
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
You can find the documentation in the [docs](./docs) folder.
66
To build it and serve it locally, run the following commands
77

8-
```console
8+
```sh
99
cargo install mdbook
1010
mdbook serve docs --open -p 3031
1111
```

docs/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,21 @@
22

33
## Dependencies
44

5-
```console
5+
```sh
66
cargo install mdbook
77
```
88

99
## Serve the docs locally
1010

11-
```console
12-
mdbook serve --open -p 3001
11+
```sh
12+
mdbook serve -p 3001 --open
1313
```
1414

1515
## Linting & Formatting
1616

1717
From the top-level working directory:
1818

19-
```console
19+
```sh
2020
# Format all files configured in .dprint.jsonc
2121
dprint fmt
2222
# Check all links configured in lychee.toml

docs/src/glossary.md

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,35 @@ Further improving efficiency of inclusion proofs on-chain, this process builds a
1111

1212
> See `crates/aggregation-set/src/lib.rs` and `crates/guest/set-builder/set-builder-guest/src/main.rs` for details.
1313
14+
### Boundless Market
15+
16+
A coordination and clearing mechanism to that connects those requesting proofs generation, along with a commitment of payment, with and those able to fulfill with proof generation and receive payment.
17+
18+
In the initial 0th version, the Market is facilitated on-chain where one is [deployed][page-deployments], but it is expected to evolve into more efficient off-chain mechanisms in future versions.
19+
20+
> See the [Market Section][page-boundless-market] for more details.
21+
1422
### Bento
1523

1624
A cluster of services that coordinate to search for, bid on, and attempt to fulfil [proof order](#proof-order)s.
1725

18-
> See the [Bento Documentation][page-bento] for moe details.
26+
> See the [Bento Section][page-bento] for more details.
1927
2028
### Broker
2129

22-
A cluster of services that coordinate to search for, bid on, and attempt to fulfil [proof order](#proof-order)s.
30+
The Broker monitors a [deployment][page-deployments] of the [Boundless Market](#boundless-market) and, based on customizable criteria, bids on and locks-in on proof requests. Proof generation jobs are subsequently passed to an instance of [Bento](#bento), and ultimately are the request(s) are fulfilled it on the Market.
31+
32+
> See the [Broker Section][page-broker] for more details.
33+
34+
### Preflight
35+
36+
Running a proof request's execution _only_ via [Bento](#bento) (essential using [RISC Zero's `dev-mode`][r0-page-dev-mode]) in order to calculate the required [cycles][r0-term-clock-cycles] for the [proof order](#proof-order).
2337

24-
> See the [Bento Documentation][page-bento] for moe details.
38+
This allows one to:
39+
40+
- Validate an order is possible to fulfill at all (execution completes)
41+
- Confirm execution results match the [proof order](#proof-order) requirements
42+
- Calculate - based on custom heuristics - the bid to lock-in on a [market](#boundless-market) order fulfillment.
2543

2644
### Prover
2745

@@ -31,7 +49,7 @@ The market participant that fulfills [proof order](#proof-order)
3149

3250
<!-- TODO https://linear.app/risczero/issue/BM-201/replace-proof-request-with-order -->
3351

34-
An order placed on the [Boundless Market](#boundless-market) to that includes:
52+
An order - also called a request - placed on the [Boundless Market](#boundless-market) to that includes:
3553

3654
- A Unique ID for the request on the Market
3755
- Proof Requirements for a this order to be fulfilled, including the [Image ID][r0-term-image-id]
@@ -46,13 +64,13 @@ See `contracts/src/IProofMarket.sol` for more details.
4664
<!-- TODO https://linear.app/risczero/issue/BM-202/replace-instances-of-client-with-requestor -->
4765

4866
Also referred to as the Client in the context of contracts, the party submitting orders to the market proofs form the Boundless Market.
49-
50-
### Preflight
51-
52-
is this specific and need a name? (run execution to check cost and see if execution is valid at all)
53-
5467
[r0-term-image-id]: https://dev.risczero.com/terminology#image-id
68+
[r0-term-clock-cycles]: https://dev.risczero.com/terminology#clock-cycles
5569
[r0-term-guest-program]: https://dev.risczero.com/terminology#guest-program
5670
[r0-term-elf-binary]: https://dev.risczero.com/terminology#elf-binary
5771
[r0-term-reciept]: https://dev.risczero.com/terminology#receipt
72+
[r0-page-dev-mode]: https://dev.risczero.com/api/next/generating-proofs/dev-mode
73+
[page-boundless-market]: ./market/README.md
5874
[page-bento]: ./prover-manual/bento/README.md
75+
[page-broker]: ./prover-manual/broker/README.md
76+
[page-deployments]: ./market/deployments.md

docs/src/market/deployments.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,20 @@
22

33
The Boundless Market's contracts are deployed only on [Sepolia](#sepolia) so far, with more to be determined.
44

5+
<div class="warning">
6+
7+
NOTE: there is no versioning presently, and these addresses may change at any time!
8+
9+
</div>
10+
511
## Sepolia ⚠TESTNET⚠
612

713
| Contract Name | Contract Address |
814
| ------------------------ | ----------------------------------------------------------------------------------------------------------------------------- |
915
| `ProofMarket` | [0xb3e579794B6ce24bC7233713289790d9bBEB656c](https://sepolia.etherscan.io/address/0xb3e579794B6ce24bC7233713289790d9bBEB656c) |
1016
| `SetVerifier` | [0x6860e6cC6E4705309b3e946947706b4a346422DB](https://sepolia.etherscan.io/address/0x6860e6cC6E4705309b3e946947706b4a346422DB) |
1117
| `RiscZeroVerifierRouter` | [0x925d8331ddc0a1F0d96E68CF073DFE1d92b69187](https://sepolia.etherscan.io/address/0x925d8331ddc0a1F0d96E68CF073DFE1d92b69187) |
12-
| `Counter` example | [0x830aC8703F9735BF728517fB8946DbDcC222b9f9](https://sepolia.etherscan.io/address/0x830aC8703F9735BF728517fB8946DbDcC222b9f9) |
18+
| (example only) `Counter` | [0x830aC8703F9735BF728517fB8946DbDcC222b9f9](https://sepolia.etherscan.io/address/0x830aC8703F9735BF728517fB8946DbDcC222b9f9) |
1319

1420
## Interactions
1521

docs/src/market/local-development.md

Lines changed: 114 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,102 @@
11
# Local Development Guide
22

3-
Ensure the following software is installed on your machine before proceeding:
3+
To develop Boundless applications both as a requestor and prover, a running Market is required.
4+
The workflow is generally:
5+
6+
1. (One-time [Install](#install-boundless))
7+
2. [Spin up a devnet](#run-a-market-devnet)
8+
3. [Submit proof requests](#submit-proof-requests)
9+
4. Tweak you app & submit more requests
10+
5. [Tear down the devnet](#tear-down)
11+
12+
To accelerate development, there are helpful utilities provided:
13+
14+
- Helpful `make` workflows:
15+
- `devnet-up` (default): spin up a service running in th background to fulfill proof requests
16+
- `devnet-down`: tear down a running devnet
17+
- A CLI tool to interact with the Market:
18+
- `deposit`: Deposit funds
19+
- `withdraw`: Withdraw funds
20+
- `balance`: Check the balance of an account
21+
- `submit-offer`: Submit a proof request, constructed with the given offer, input, and image
22+
- `submit-request`: Submit a fully specified proof request
23+
- `slash`: Slash a prover for a given request
24+
- `get-proof`: Get the journal and seal for a given request
25+
- `verify-proof`: Verify the proof of the given request against the `SetVerifier` contract
26+
- `status`: Get the status of a given request
27+
28+
All utilities and more are provided in the [Boundless monorepo](https://github.com/boundless-xyz/boundless).
29+
30+
## Install Boundless
31+
32+
Ensure the following software is installed on your machine:
433

534
- **[Rust](https://www.rust-lang.org/tools/install) version 1.79 or higher**
635
- **[Foundry](https://book.getfoundry.sh/getting-started/installation) version 0.2 or higher**
736

8-
Before starting, ensure you have cloned with recursive submodules, or pull them with:
9-
10-
```console
11-
git submodule update --init
12-
```
37+
1. Clone Boundless (SSH or github login required)
38+
```sh
39+
# SSH or github login required
40+
git clone git clone [email protected]:boundless-xyz/boundless.git
41+
cd boundless
42+
```
1343

14-
1. Start a local devnet
15-
```console
16-
make devnet-up
17-
source .env
44+
2. Initialize recursive submodules (located in `lib`, required by Foundry)
45+
```sh
46+
git submodule update --init
1847
```
1948

20-
2. Test your deployment with the client CLI.
21-
You can read more about the client on the [proving request][page-requestor-request] page.
49+
## Run a Market devnet
2250

23-
```console
24-
RISC0_DEV_MODE=1 RUST_LOG=info,boundless_market=debug cargo run --bin cli -- submit-request request.yaml --wait
25-
```
51+
For both requestors and provers, you will need to:
2652

27-
> If you see "Error: Market error: Failed to check fulfillment status",
28-
> check the deployment logs from running `forge script` and ensure it matches the addresses listed in `.env`
29-
> If they don't match, adjust the `.env` file or try restarting anvil and deploying again.
53+
- Spin up a local `anvil` (or other EVM) devnet
54+
- Deployed Boundless Market contracts to the devnet
55+
- Run a [Broker][page-broker] instance that will lock in and return proofs to all proof requests
56+
- Submit proof requests to be fulfilled by the Broker
3057

31-
Congratulations! You now have a local devnet running and a prover that will respond to proving requests.
58+
### Spin up
3259

33-
3. To tear down the local devnet run:
60+
An instance of the Market needs to be running in the background for applications to interact with, using the included `make` utilities or manually.
3461

35-
```console
36-
make devnet-down
62+
#### `make`
63+
64+
The included `makefile` in boundless is the most effective way to do this, and can be modified to suit specific needs.
65+
66+
1. Start a local devnet service (running in the background)
67+
```sh
68+
make devnet-up
69+
source .env
3770
```
3871

39-
Check out the is-even example in the [Boundless Foundry template][boundless-foundry-template] for an example of how to run and application using the prover market.
72+
🎉 Congratulations!
73+
You now have a local devnet service running in the background and a prover that will respond to proving requests.
74+
75+
When finished, tear down a running devnet run:
76+
77+
```sh
78+
make devnet-down
79+
```
4080

41-
You can also try editing `request.yaml` to send a request with different values.
42-
Check `cargo run --bin cli -- --help` for a full list of commands available through the CLI.
81+
#### Manually
4382

44-
If instead you prefer setting up a local devnet step by step, you can run the following commands as an alternative to the Makefile:
83+
If you require customizing a local devnet configuration, and need to operate it manually, you can run the following commands:
4584

4685
1. Build the contracts
4786

48-
```console
87+
```sh
4988
forge build
5089
```
5190

5291
2. Build the project
5392

54-
```console
93+
```sh
5594
cargo build
5695
```
5796

58-
3. Start anvil
97+
3. Start `anvil`
5998

60-
```console
99+
```sh
61100
anvil -b 2
62101
```
63102

@@ -67,50 +106,71 @@ If instead you prefer setting up a local devnet step by step, you can run the fo
67106
Configuration environment variables are read from the `.env` file.
68107
By setting the environment variable `RISC0_DEV_MODE`, a mock verifier will be deployed.
69108

70-
```console
109+
```sh
71110
source .env
72111
RISC0_DEV_MODE=1 forge script contracts/scripts/Deploy.s.sol --rpc-url $RPC_URL --broadcast -vv
73112
```
74113

75-
> NOTE: Starting from a fresh Anvil instance, the deployed contract addresses will match the values in `.env`.
76-
> If you need to deploy again, restart Anvil first or change the `.env` file to match your newly deployed contract addresses.
114+
> NOTE: Starting from a fresh `anvil` instance, the deployed contract addresses will match the values in `.env`.
115+
> If you need to deploy again, restart `anvil` first or change the `.env` file to match your newly deployed contract addresses.
77116
78-
5. Deposit Prover funds and start the Broker
79-
80-
The Broker is the service that watches the chain for proving requests, evaluates them, and orchestrates proving the jobs with the proving backend.
117+
5. Deposit Prover funds and start the [Broker][page-broker]
81118

82119
Here we will use a mock prover by setting `RISC0_DEV_MODE`.
83-
The Broker can use either Bonsai or Bento as backend, remove `RISC0_DEV_MODE` and:
120+
The Broker can use either [Bonsai][bonsai-homepage] or [Bento][page-bento] as backend, remove `RISC0_DEV_MODE` and:
84121

85122
- To use Bonsai, export the `BONSAI_API_URL` and `BONSAI_API_KEY` env vars, or the the associated CLI flags.
86123
- To use Bento, export the `BENTO_API_URL` env var or use the `--bento-api-url` CLI flag.
87-
Also, refer to the [Running Bento][page-bento-running] guide.
124+
_This requires there is a Bento service listening, refer to the [Running Bento][page-bento-running] guide to configure and deploy one._
88125

89-
The Broker needs to have funds deposited on the Boundless market contract to cover [lockin-stake][id-rfc-order-matching] on requests.
126+
The Broker needs to have funds deposited on the Boundless market contract to cover lock-in stake on requests.
90127
Setting the `--deposit-amount` flag below has the Broker deposit 10 ETH to the market upon startup.
91128

92-
```console
129+
```sh
93130
RISC0_DEV_MODE=1 RUST_LOG=info cargo run --bin broker -- --private-key ${PRIVATE_KEY:?} --proof-market-addr ${PROOF_MARKET_ADDRESS:?} --set-verifier-addr ${SET_VERIFIER_ADDRESS:?} --deposit-amount 10
94131
```
95132

96-
6. Test your deployment with the boundless CLI.
97-
You can read more about on the [proving request][page-requestor-request] page.
133+
🎉 Congratulations!
134+
You now have a local devnet running and a prover that will respond to proving requests.
98135

99-
```console
100-
RISC0_DEV_MODE=1 RUST_LOG=info,boundless_market=debug cargo run --bin cli -- submit-request request.yaml --wait
101-
```
136+
### Submit Proof Requests
137+
138+
Test your devnet with the boundless CLI:
139+
140+
```sh
141+
RISC0_DEV_MODE=1 RUST_LOG=info,boundless_market=debug cargo run --bin cli -- submit-request request.yaml --wait
142+
```
143+
144+
> If you see `Error: Market error: Failed to check fulfillment status`,
145+
> check the `make devnet-up` deployment logs and ensure addresses match those listed in `.env`
146+
> If they don't match, adjust the `.env` file and try again.
147+
148+
Try editing `request.yaml` to send a request to the Market with different values.
149+
150+
### Tear down
151+
152+
When finished, tear down a running devnet from the [`make devnet-up` workflow](#make) run:
153+
154+
```sh
155+
make devnet-down
156+
```
102157

103-
> If you see "Error: Market error: Failed to check fulfillment status",
104-
> check the deployment logs from running `forge script` and ensure it matches the addresses listed in `.env`
105-
> If they don't match, adjust the `.env` file or try restarting anvil and deploying again.
158+
If running [manually](#manually), kill services and cleanup as needed.
106159

107-
Congratulations! You now have a local devnet running and a prover that will respond to proving requests.
160+
## Application Development
108161

109-
Check out the is-even example in the [Boundless Foundry template][boundless-foundry-template] for an example of how to run and application using the prover market.
162+
Further instructions for:
110163

111-
You can also try editing `request.yaml` to send a request with different values.
112-
Check `cargo run --bin cli -- --help` for a full list of commands available through the CLI.
164+
- the [Requestor Broadcasting][page-requestor-broadcast] page for submitting proofs
165+
- See the [Boundless Foundry template][boundless-foundry-template-repo] for building a stand-alone application to interact with the Market
166+
- the [Prover Manual][page-prover-manual] for fulfilling Market requests
113167

168+
[page-bento]: ../prover-manual/bento/README.md
169+
[page-broker]: ../prover-manual/broker/README.md
114170
[page-bento-running]: ../prover-manual/bento/running_bento.md
115-
[page-requestor-request]: ../requestor-manual/broadcasting.md
116-
[boundless-foundry-template]: https://github.com/boundless-xyz/boundless-foundry-template/
171+
[page-requestor-broadcast]: ../requestor-manual/broadcasting.md
172+
[page-prover-manual]: ../prover-manual/README.md
173+
[page-market-design]: ./matching.md
174+
[boundless-foundry-template-repo]: https://github.com/boundless-xyz/boundless-foundry-template/
175+
[term-broker]: ../prover-manual/broker/README.md
176+
[bonsai-homepage]: https://www.bonsai.xyz/

docs/src/prover-manual/bento/running_bento.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,40 +30,40 @@ At this time Ubuntu is the only supported Operating system. Other operating syst
3030

3131
For a quick set up of boundless host dependencies on Ubuntu 22.04 LTS, please run:
3232

33-
```bash
33+
```sh
3434
scripts/setup.sh
3535
```
3636

3737
## Running
3838

3939
To build and spin up a Bento cluster locally using docker:
4040

41-
```bash
41+
```sh
4242
docker compose --env-file ./.env-compose up --build
4343
```
4444

4545
Optionally you can use the startup script included in this repo:
4646

47-
```bash
47+
```sh
4848
scripts/boundless_service.sh start
4949
```
5050

5151
To stop the boundless service:
5252

53-
```bash
53+
```sh
5454
scripts/boundless_service.sh stop
5555
```
5656

5757
## Sending a sample proof to the cluster
5858

5959
Using a simple test vector for testing different cycle counts (via the -c flag):
6060

61-
```bash
61+
```sh
6262
RUST_LOG=info cargo run --bin bento_cli -- -c 32
6363
```
6464

6565
Or with a existing elf / input file:
6666

67-
```bash
67+
```sh
6868
RUST_LOG=info cargo run --bin bento_cli -- -f ./crates/bento-client/method_name -i /tmp/input.bin
6969
```

0 commit comments

Comments
 (0)