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

Lightnet README-dev documentation. #1333

Merged
merged 1 commit into from
Dec 18, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 46 additions & 8 deletions README-dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ This README includes information that is helpful for o1js core contributors.

## Setting up the repo on your local

After cloning the repo, you must fetch external submodules for the following examples to work.
After cloning the repo, you must fetch external submodules for the following examples to work.

```sh
```shell
git clone https://github.com/o1-labs/o1js.git
cd o1js
git submodule update --init --recursive
```

## Run examples using Node.js

```sh
```shell
npm install
npm run build

Expand All @@ -23,7 +23,7 @@ npm run build

## Run examples in the browser

```sh
```shell
npm install
npm run build:web

Expand All @@ -38,20 +38,20 @@ Note: Some of our examples don't work on the web because they use Node.js APIs.

- Unit tests

```sh
```shell
npm run test
npm run test:unit
```

- Integration tests

```sh
```shell
npm run test:integration
```

- E2E tests

```sh
```shell
npm install
npm run e2e:install
npm run build:web
Expand Down Expand Up @@ -89,8 +89,46 @@ The other base branches (`berkeley`, `develop`) are only used in specific scenar

You can execute the CI locally by using [act](https://github.com/nektos/act). First generate a GitHub token and use:

```
```shell
act -j Build-And-Test-Server --matrix test_type:"Simple integration tests" -s $GITHUB_TOKEN
```

to execute the job "Build-And-Test-Server for the test type `Simple integration tests`.

## Test zkApps against the local blockchain network

In order to be able to test zkApps against the local blockchain network, you need to spin up such a network first.
You can do so in several ways.

1. Using [zkapp-cli](https://www.npmjs.com/package/zkapp-cli)'s sub commands:

```shell
zk lightnet start # start the local network
# Do your tests and other interactions with the network
zk lightnet logs # manage the logs of the local network
zk lightnet explorer # visualize the local network state
zk lightnet stop # stop the local network
```

Please refer to `zk lightnet --help` for more information.

2. Using the corresponding [Docker image](https://hub.docker.com/r/o1labs/mina-local-network) manually:

```shell
docker run --rm --pull=missing -it \
--env NETWORK_TYPE="single-node" \
--env PROOF_LEVEL="none" \
--env LOG_LEVEL="Trace" \
-p 3085:3085 \
-p 5432:5432 \
-p 8080:8080 \
-p 8181:8181 \
-p 8282:8282 \
o1labs/mina-local-network:o1js-main-latest-lightnet
```

Please refer to the [Docker Hub repository](https://hub.docker.com/r/o1labs/mina-local-network) for more information.

Next up, you will need the Mina blockchain accounts information in order to be used in your zkApp.
Once the local network is up and running, you can use the [Lightnet](https://github.com/o1-labs/o1js/blob/ec789794b2067addef6b6f9c9a91c6511e07e37c/src/lib/fetch.ts#L1012) `o1js API namespace` to get the accounts information.
The corresponding example can be found here: [src/examples/zkapps/hello_world/run_live.ts](https://github.com/o1-labs/o1js/blob/ec789794b2067addef6b6f9c9a91c6511e07e37c/src/examples/zkapps/hello_world/run_live.ts)