diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b886f82b17..6132901cdf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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: | diff --git a/.github/workflows/promote-stage.yml b/.github/workflows/promote-stage.yml index d1c635dab2..cbfc34cfa9 100644 --- a/.github/workflows/promote-stage.yml +++ b/.github/workflows/promote-stage.yml @@ -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 diff --git a/bin/zk b/bin/zk index 8811e43421..e40204e8e9 100755 --- a/bin/zk +++ b/bin/zk @@ -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 diff --git a/docs/development.md b/docs/development.md index d27e3d57b1..abe8c976cc 100644 --- a/docs/development.md +++ b/docs/development.md @@ -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: @@ -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 @@ -53,28 +65,28 @@ 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. @@ -82,8 +94,8 @@ This command will revert changes in the contract and redeploy it, so the actual 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 @@ -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 @@ -121,40 +133,32 @@ 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 ``` @@ -162,9 +166,9 @@ Adding a new migration requires the following actions: - 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 @@ -175,13 +179,13 @@ 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 ``` ## Contracts @@ -189,11 +193,11 @@ zksync dockerhub-push ### Re-build contracts: ```sh -zksync build-contracts +zk contract build ``` ### Publish source code on etherscan ```sh -zksync publish-source +zk contract publish ``` diff --git a/docs/launch.md b/docs/launch.md index 41eafd11c6..40cb83afed 100644 --- a/docs/launch.md +++ b/docs/launch.md @@ -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 @@ -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 +zk env ``` -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. @@ -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. diff --git a/docs/setup-dev.md b/docs/setup-dev.md index acf8fc5cb1..0e4a1cca9b 100644 --- a/docs/setup-dev.md +++ b/docs/setup-dev.md @@ -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. @@ -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. @@ -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 - ```