Skip to content

Commit

Permalink
Update some existing docs
Browse files Browse the repository at this point in the history
  • Loading branch information
ly0va committed Oct 30, 2020
1 parent a547055 commit 35cf708
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 123 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
docker pull matterlabs/ci-integration-test:latest
- name: zk
run: pushd infrastructure/zk && yarn && yarn build
run: zk

- name: lints
run: |
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/promote-stage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ jobs:
- name: init
run: |
cargo sqlx --version || cargo install --version=0.1.0-beta.1 sqlx-cli
zk
zk run yarn
cp etc/tokens/{test,localhost}.json
zk run verify-keys unpack
Expand Down
8 changes: 7 additions & 1 deletion bin/zk
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
#!/bin/bash

yarn --silent --cwd $ZKSYNC_HOME/infrastructure/zk start $@
cd $ZKSYNC_HOME/infrastructure/zk

if [ -z $@ ]; then
yarn && yarn build
else
yarn --silent start $@
fi
92 changes: 48 additions & 44 deletions docs/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,22 @@ This document covers development-related actions in zkSync.

## Initializing the project

To setup the main toolkit, `zk`, simply run:

```
zk
```

You may also configure autocompletion for your shell via:

```
zk completion install
```

Once all the dependencies were installed, project can be initialized:

```sh
zksync init
zk init
```

This command will do the following:
Expand All @@ -25,17 +37,17 @@ This command will do the following:
Initializing may take pretty long, but many steps (such as downloading & unpacking keys and initializing containers) are
required to be done only once.

Usually, it is a good idea to do `zksync init` once after each merge to the `dev` branch (as application setup may change).
Usually, it is a good idea to do `zk init` once after each merge to the `dev` branch (as application setup may change).

**Note:** If after getting new functionality from the `dev` branch your code stopped working and `zksync init` doesn't help,
you may try removing `$ZKSYNC_HOME/etc/env/dev.env` and running `zksync init` once again. This may help if the application
**Note:** If after getting new functionality from the `dev` branch your code stopped working and `zk init` doesn't help,
you may try removing `$ZKSYNC_HOME/etc/env/dev.env` and running `zk init` once again. This may help if the application
configuration has changed.

If you don't need all of the `zksync init` functionality, but just need to start/stop containers, use the following commands:
If you don't need all of the `zk init` functionality, but just need to start/stop containers, use the following commands:

```sh
zksync dev-up # Set up `geth` and `postgres` containers
zksync dev-down # Shut down `geth` and `postgres` containers
zk up # Set up `geth` and `postgres` containers
zk down # Shut down `geth` and `postgres` containers
```

## Committing changes
Expand All @@ -53,37 +65,37 @@ Currently the following criteria are checked:

Using the real prover for the development can be not really handy, since it's pretty slow and resource consuming.

Instead, one may want to use the Dummy Prover: lightweight version of prover, which does not actually proves anything,
Instead, one may want to use the Dummy Prover: lightweight version of the prover, which does not actually prove anything,
but acts like it does.

To enable the dummy prover, run:

```sh
zksync dummy-prover enable
zk dummy-prover enable
```

And after that you will be able to use the dummy prover instead of actual prover:

```sh
zksync dummy-prover # Instead of `zksync prover`
zk dummy-prover run # Instead of `zk prover`
```

**Warning:** `setup-dummy-prover` subcommand changes the `Verifier.sol` contract, which is a part of `git` repository.
**Warning:** `dummy-prover enable` subcommand changes the `Verifier.sol` contract, which is a part of `git` repository.
Be sure not to commit these changes when using the dummy prover!

If one will need to switch back to the real prover, a following command is required:

```sh
zksync dummy-prover disable
zk dummy-prover disable
```

This command will revert changes in the contract and redeploy it, so the actual prover will be usable again.

Also you can always check the current status of the dummy verifier:

```sh
$ zksync dummy-prover status
Dummy Verifier status: disabled
$ zk dummy-prover status
Dummy Prover status: disabled
```

## Database migrations
Expand All @@ -103,13 +115,13 @@ Adding a new migration requires the following actions:
diesel migration generate name-of-your-migration
```
3. Implement migration: `up.sql` must contain new changes for the DB, and `down.sql`
must revert the migration and return the database into previous state.
4. Run `zksync db-init` to apply migration.
must revert the migration and return the database into previous state.
4. Run `zk db migrate` to apply migration.
5. Implement corresponding changes in the `storage` crate.
6. Implement tests for new functionality.
7. Run database tests:
```sh
zksync db-tests
zk test db
```

## Testing
Expand All @@ -121,50 +133,42 @@ Adding a new migration requires the following actions:
```

- Running the database tests:

```sh
zksync db-tests

```
- Running the integration test:

```sh
zksync server # Has to be run in the 1st terminal
zksync prover # Has to be run in the 2nd terminal
zksync integration-simple # Has to be run in the 3rd terminal
zk test db
```
- Running the integration test:

- Running the integration tests for Full Exit operations

```sh
zksync server # Has to be run in the 1st terminal
zksync prover # Has to be run in the 2nd terminal
zksync integration-full-exit # Has to be run in the 3rd terminal
zk server # Has to be run in the 1st terminal
zk dummy-prover run # Has to be run in the 2nd terminal
zk test i server # Has to be run in the 3rd terminal
```

- Running the circuit tests:

```sh
zksync circuit-tests
zk test circuit
```

- Running the prover tests:

```sh
zksync prover-tests
zk test prover
```

- Running the benchmarks:

```sh
f cargo bench
```

- Running the loadtest:

```sh
zksync server # Has to be run in the 1st terminal
zksync prover # Has to be run in the 2nd terminal
zksync loadtest # Has to be run in the 3rd terminal
zk server # Has to be run in the 1st terminal
zk prover # Has to be run in the 2nd terminal
zk run loadtest # Has to be run in the 3rd terminal
```

## Developing circuit
Expand All @@ -175,25 +179,25 @@ Adding a new migration requires the following actions:
Steps to do after updating circuit:
1. Update circuit version by updating `KEY_DIR` in your env file (don't forget to place it to `dev.env.example`)
(last parts of this variable usually means last commit where you updated circuit).
2. Regenerate verification keys and Verifier contract using `zksync verify-keys gen` command.
3. Pack generated verification keys using `zksync verify-keys pack` command and commit resulting file to repo.
2. Regenerate verification keys and Verifier contract using `zk run verify-keys gen` command.
3. Pack generated verification keys using `zk run verify-keys pack` command and commit resulting file to repo.

## Build and push Docker images to dockerhub:

```sh
zksync dockerhub-push
zk docker push <IMAGE>
```

## Contracts

### Re-build contracts:

```sh
zksync build-contracts
zk contract build
```

### Publish source code on etherscan

```sh
zksync publish-source
zk contract publish
```
25 changes: 13 additions & 12 deletions docs/launch.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,30 +11,31 @@ Prepare dev environment prerequisites: see [setup-dev.md](setup-dev.md).
Setup:

```sh
zksync init
zk # installs and builds zk itself
zk init
```

During the first initialization you have to download around 8 GB of setup files, this should be done once.
If you have a problem on this step of the initialization, see help for the `zksync plonk-setup` command.
If you have a problem on this step of the initialization, see help for the `zk run plonk-setup` command.

To completely reset the dev environment:

- Stop services:
```sh
zksync dev-down
zk down
```
- Repeat the setup procedure above

If `zksync init` has already been executed, and now you only need to start docker containers (e.g. after reboot), simply launch:
If `zk init` has already been executed, and now you only need to start docker containers (e.g. after reboot), simply launch:

```sh
zksync dev-up
zk up
```

## (Re)deploy db and contraсts:

```sh
zksync redeploy
zk contract redeploy
```

## Environment configurations
Expand All @@ -44,23 +45,23 @@ Env config files are held in `etc/env/`
List configurations:

```sh
zksync env
zk env
```

Switch between configurations:

```sh
zksync env <ENV_NAME>
zk env <ENV_NAME>
```

Default confiruration is `dev.env`, which is generated automatically from `dev.env.example` during `zksync init` command execution.
Default confiruration is `dev.env`, which is generated automatically from `dev.env.example` during `zk init` command execution.

## Build and run server + prover locally for development:

Run server:

```sh
zksync server
zk server
```

Server is configured using env files in `./etc/env` directory.
Expand All @@ -76,8 +77,8 @@ for details).
Run prover:

```sh
zksync prover
zk prover
```

Make sure you have environment variables set right, you can check it by running:
`zksync env`. You should see `* dev` in output.
`zk env`. You should see ` * dev` in output.
65 changes: 0 additions & 65 deletions docs/setup-dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,31 +55,6 @@ On debian-based linux:
sudo apt-get install axel
```
## `gnu-sed`
On mac:
```sh
brew install gnu-sed
```
On linux `sed` is available by default in most cases.
## `Envsubst` (to transpile k8s `yaml` files)
On mac:
```sh
brew install gettext
brew link --force gettext
```
On debian-based linux it should be available by default, if not, run:
```sh
sudo apt-get install gettext
```
## `Rust`
Install the latest `rust` version.
Expand All @@ -105,20 +80,6 @@ rustflags = [
```
**Warning:** This is only viable for linux since `lld` doesn't work on mac.

# `JQ`

`jq` is used to work with JSON when managing DigitalOcean.

On mac:

```brew install jq```

On debian-based linux:

```sh
sudo apt-get install jq
```

# PSQL

Install `psql` CLI tool to interact with postgres.
Expand Down Expand Up @@ -186,29 +147,3 @@ export PATH=$ZKSYNC_HOME/bin:$PATH
# If you're like me, uncomment:
# cd $ZKSYNC_HOME
```

Autocomplete configuration:

- `bash`:

```sh
complete -W "\`grep -oE '^[a-zA-Z0-9_.-]+:([^=]|$)' $ZKSYNC_HOME/Makefile | sed 's/[^a-zA-Z0-9_.-]*$//'\`" zksync
```

- `zsh`:

```sh
echo "fpath=(~/.zsh_comp $fpath)" >> ~/.zshrc
mkdir -p ~/.zsh_comp
```

add `~/.zsh_comp/_zksync`:

```sh
#compdef zksync
cmds=( ${(uf)"$(grep -oE '^[a-zA-Z0-9_.-]+:([^=]|$)' $ZKSYNC_HOME/Makefile | sed 's/[^a-zA-Z0-9_.-]*$//')"} )
_describe 'zksync make cmds' cmds
```

0 comments on commit 35cf708

Please sign in to comment.