Skip to content

Commit

Permalink
docs(zkstack_cli): update docs to mention foundry zksync (#3134)
Browse files Browse the repository at this point in the history
## What ❔

<!-- What are the changes this PR brings about? -->
<!-- Example: This PR adds a PR template to the repo. -->
<!-- (For bigger PRs adding more context is appreciated) -->
Update docs to mention foundry zksync, and other changes to the CLI.

## Why ❔

<!-- Why are these changes done? What goal do they contribute to? What
are the principles behind them? -->
<!-- Example: PR templates ensure PR reviewers, observers, and future
iterators are in context about the evolution of repos. -->

## Checklist

<!-- Check your PR fulfills the following items. -->
<!-- For draft PRs check the boxes as you complete them. -->

- [x] PR title corresponds to the body of PR (we generate changelog
entries from PRs).
- [x] Tests for the changes have been added / updated.
- [x] Documentation comments have been added / updated.
- [x] Code has been formatted via `zkstack dev fmt` and `zkstack dev
lint`.

---------

Co-authored-by: Daniyar Itegulov <[email protected]>
Co-authored-by: Devashish Dixit <[email protected]>
Co-authored-by: Artur Puzio <[email protected]>
Co-authored-by: Sarah Schwartz <[email protected]>
Co-authored-by: Antonio <[email protected]>
  • Loading branch information
6 people authored Nov 13, 2024
1 parent f783022 commit 4afbc31
Show file tree
Hide file tree
Showing 7 changed files with 351 additions and 425 deletions.
46 changes: 29 additions & 17 deletions docs/guides/advanced/01_initialization.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# ZKsync deeper dive
# ZKsync Deeper Dive

The goal of this doc is to show you some more details on how ZKsync works internally.

Expand All @@ -7,30 +7,42 @@ system).

Now let's take a look at what's inside:

### Initialization (zk init)
### Initialization

Let's take a deeper look into what `zk init` does.
Let's take a deeper look into what `zkstack ecosystem init` does.

#### zk tool
#### ZK Stack CLI

`zk` itself is implemented in typescript (you can see the code in `infrastructure` directory). If you change anything
there, make sure to run `zk` (that compiles this code), before re-running `zk init`.
`zkstack` itself is implemented in Rust (you can see the code in `/zkstack_cli` directory). If you change anything
there, make sure to run `zkstackup --local` from the root folder (that compiles and installs this code), before
re-running any `zkstack` command.

#### zk init
#### Containers

As first step, it gets the docker images for postgres and reth.
The first step to initialize a ZK Stack ecosystem is to run the command `zkstack containers`. This command gets the
docker images for `postgres` and `reth`. If the `--observability` option is passed to the command, or the corresponding
option is selected in the interactive prompt, then Prometheus, Grafana and other observability-related images are
downloaded and run.

Reth (one of the Ethereum clients) will be used to setup our own copy of L1 chain (that our local ZKsync would use).

Postgres is one of the two databases, that is used by ZKsync (the other one is RocksDB). Currently most of the data is
stored in postgres (blocks, transactions etc) - while RocksDB is only storing the state (Tree & Map) - and it used by
VM.

Then we compile JS packages (these include our web3 sdk, tools and testing infrastructure).
#### Ecosystem

Then L1 & L2 contracts.
The next step is to run the command `zkstack ecosystem init`.

And now we're ready to start setting up the system.
This command:

- Collects and finalize the ecosystem configuration.
- Builds and deploys L1 & L2 contracts.
- Initializes each chain defined in the `/chains` folder. (Currently, a single chain `era` is defined there, but you can
create your own chains running `zkstack chain create`).
- Sets up observability.
- Runs the genesis process.
- Initializes the database.

#### Postgres

Expand Down Expand Up @@ -83,8 +95,8 @@ If everything goes well, you should see that L1 blocks are being produced.

Now we can start the main server:

```shell
zk server
```bash
zkstack server
```

This will actually run a cargo binary (`zksync_server`).
Expand All @@ -96,7 +108,7 @@ Currently we don't send any transactions there (so the logs might be empty).

But you should see some initial blocks in postgres:

```
```sql
select * from miniblocks;
```

Expand All @@ -107,7 +119,7 @@ Let's finish this article, by taking a look at our L1:
We will use the `web3` tool to communicate with the L1, have a look at [02_deposits.md](02_deposits.md) for installation
instructions. You can check that you're a (localnet) crypto trillionaire, by running:

```shell
```bash
./web3 --rpc-url http://localhost:8545 balance 0x36615Cf349d7F6344891B1e7CA7C72883F5dc049
```

Expand All @@ -120,14 +132,14 @@ In order to communicate with L2 (our ZKsync) - we have to deploy multiple contra
Ethereum). You can look on the `deployL1.log` file - to see the list of contracts that were deployed and their accounts.

First thing in the file, is the deployer/governor wallet - this is the account that can change, freeze and unfreeze the
contracts (basically the owner). You can also verify (using the getBalance method above), that is has a lot of tokens.
contracts (basically the owner). You can verify the token balance using the `getBalance` method above.

Then, there are a bunch of contracts (CRATE2_FACTOR, DIAMOND_PROXY, L1_ALLOW_LIST etc etc) - for each one, the file
contains the address.

You can quickly verify that they were really deployed, by calling:

```shell
```bash
./web3 --rpc-url http://localhost:8545 address XXX
```

Expand Down
2 changes: 1 addition & 1 deletion docs/guides/advanced/05_how_call_works.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Since the 'call' method is only for reading data, all the calculations will happ
### Calling the 'call' method

If you need to make calls quickly, you can use the 'cast' binary from the
[foundry](https://github.com/foundry-rs/foundry) suite:
[Foundry ZKsync](https://foundry-book.zksync.io/getting-started/installation) suite:

```shell=
cast call 0x23DF7589897C2C9cBa1C3282be2ee6a938138f10 "myfunction()()" --rpc-url http://localhost:3050
Expand Down
4 changes: 2 additions & 2 deletions docs/guides/advanced/91_docker_and_ci.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ zk

After this, you can run any commands you need.

When you see a command like `ci_run zk contract build` in the CI - this simply means that it executed
`zk contract build` inside that docker container.
When you see a command like `ci_run zkstack dev contracts` in the CI - this simply means that it executed
`zkstack dev contracts` inside that docker container.

**IMPORTANT** - by default, docker is running in the mode, where it does NOT persist the changes. So if you exit that
shell, all the changes will be removed (so when you restart, you'll end up in the same pristine condition). You can
Expand Down
Loading

0 comments on commit 4afbc31

Please sign in to comment.