lair: a place where a wild animal, especially a fierce or dangerous one, lives
pronounced: layer three Blockchain Deployment Kit
A Kurtosis package that deploys a private, portable, and modular Blockchain Deployment Kit layer3 BDK as devnet
LAIR3-BDK5 is derived from modest improvements to Polygon-SDK and Kurtosis-CDK dual licenced with inspiration from
The Knowledge Complexity of Interactive Proof Systems
instructions are somewhat specific to Ubuntu 22.04LTS
kurtosis-docs
kurtosis ETH local testnet
kurtosis local custom testnet
lighthouse
polygon-cdk
agglayer-docs
manualchunks
pgvectorscale timescale
docker engine install
github quick reference
to begin install the following requirements
#get wget
sudo apt install wget
#wget go
wget https://go.dev/dl/go1.21.6.linux-amd64.tar.gz
#remove existing go
sudo rm -rf /usr/local/go
# possibly necessary
sudo apt remove golang $$ autoremove
#extract verbosely with force
sudo tar -xvf go1.21.6.linux-amd64.tar.gz -C /usr/local/
#add go path to ./bashrc current user with default Ubuntu 22 bash shell
echo 'export PATH="$PATH:/usr/local/go/bin"' | sudo tee -a ./bashrc
#refresh your bash shell
source $HOME/.bashrc
# verify correct version install
go version
nodejs -v
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt-get install nodejs -y
nodejs -v
# docker install https://docs.docker.com/engine/install/ubuntu/
for pkg in docker.io docker-doc docker-compose docker-compose-v2 podman-docker containerd runc; do sudo apt-get remove $pkg; done
sudo groupadd docker
sudo usermod -aG docker $USER
newgrp docker
docker ps
https://docs.kurtosis.com/install/
echo "deb [trusted=yes] https://apt.fury.io/kurtosis-tech/ /" | sudo tee /etc/apt/sources.list.d/kurtosis.list
sudo apt update
sudo apt install kurtosis-cli
sudo apt update && sudo apt install --only-upgrade kurtosis-cli
kurtosis engine restart
blockchain swiss army knife source build
snap install yq
sudo apt install bc protoc
git clone https://github.com/maticnetwork/polygon-cli.git
cd polygon-cli
make install
curl -L https://foundry.paradigm.xyz | bash
source $HOME/.bashrc
foundryup
cd BDK5
git config --global user.email "codephreak@dmg.finance"
git config --global user.name "Professor-Codephreak"
forge init --force
To begin make sure you have installed the above requirements including Docker and Kurtosis
run tool_check to test for version requirements
sh scripts/tool_check.sh
Once that is good and installed on your system, you can run the following command to locally deploy the complete BDK stack
this will take between 5 and 20 minutes depending on your hardware
kurtosis clean --all
kurtosis run --enclave bdk7 --args-file params.yml --image-download always .
To begin install Docker and Kurtosis.
run tool_check to test for version requirements deprecated
sh scripts/tool_check.sh
Once that is good and installed on your system, you can run the following command to locally deploy the complete BDK stack
this will take between 5 and 20 minutes depending on your hardware
kurtosis clean --all
kurtosis run --enclave bdk7 --args-file params.yml --image-download always .
The command above deploys a BDK stack using zkevm-node as the sequencer. Alternatively, to launch a CDK stack using cdk-erigon as a sequencer, you can run the following command.
kurtosis run --enclave bdk7 --args-file cdk-erigon-sequencer-params.yml --image-download always .
First, you will need to figure out which port Kurtois uses for the RPC. You can get a general feel for the entire network layout by running the following command:
kurtosis enclave inspect bdk7
within enclave bdk-v2
for zkevm-node-rpc
service and trusted-rpc
storing the RPC URL as an environment variable:
export ETH_RPC_URL="$(kurtosis port print bdk7 zkevm-node-rpc-001 http-rpc)"
That is the same environment variable that cast
uses, so you should now be able to run this command. Note that the steps below will assume you have the Foundry toolchain installed.
cast block-number
By default, the CDK is configured in test
mode, which means there is some pre-funded value in the admin account with address 0xE34aaF64b29273B7D567FCFc40544c014EEe9970
.
cast balance --ether 0xE34aaF64b29273B7D567FCFc40544c014EEe9970
export PK="0x12d7de8621a77640c9241b2595ba78ce443d05e94090365ab3bb5e19df82c625"
cast send --legacy --private-key "$PK" --value 0.01ether 0x0000000000000000000000000000000000000000
multisend transactions with polygon-cli polygon-cli installed.
polycli loadtest --rpc-url "$ETH_RPC_URL" --legacy --private-key "$PK" --verbosity 700 --requests 500 --rate-limit 5 --mode t
polycli loadtest --rpc-url "$ETH_RPC_URL" --legacy --private-key "$PK" --verbosity 700 --requests 500 --rate-limit 10 --mode t
polycli loadtest --rpc-url "$ETH_RPC_URL" --legacy --private-key "$PK" --verbosity 700 --requests 500 --rate-limit 10 --mode 2
polycli loadtest --rpc-url "$ETH_RPC_URL" --legacy --private-key "$PK" --verbosity 700 --requests 500 --rate-limit 3 --mode uniswapv3
```bash
sudo apt install postgresql-client-common
foundry creates script and src folders
The LAIR3-BDK5 Layer 3 Blockchain Development Kit is designed to facilitate the deployment and management of advanced blockchain solutions specifically supporting zkEVM Rollup and Validium technologies. Merging the best of the Kurtosis SDK, polygon-cli, avalanche subnet-evm and ignite with Starlark the Blockchain Deployment Kit facilitates the creation and deployment of customized blockchain environments with enhanced observability and testing capabilities.
The primary goal is to to make blockchain deployment a sane operation accessiable to regular developers interested in dapplications development.
export POSTGRES_MASTER_PASSWORD="your_secure_password"
Log into PostgreSQL
sudo -u postgres psql
ALTER USER validator1 WITH PASSWORD 'new_validator1_password';
\q
sudo apt install postgresql-client-common
psql -U master_user -h 127.0.0.1 -p 5432 -d master
\dx
SELECT * FROM pg_extension WHERE extname = 'vectorscale';
docker build -t blockchaindeploymentkit/bdk-toolbox-postgres-pgvectorscale -f docker/toolbox.Dockerfile .
docker login
docker tag blockchaindeploymentkit/bdk-toolbox-postgres-pgvectorscale blockchaindeploymentkit/bdk-toolbox-postgres-pgvectorscale
docker push blockchaindeploymentkit/bdk-toolbox-postgres-pgvectorscale
docker rmi blockchaindeploymentkit/bdk-toolbox-postgres-pgvectorscale
docker system prune -a
docker compose version
Create Missing Directories: If directories /var/log/kurtosis/ and similar are missing you can manually create these directories to resolve the issue
sudo mkdir -p /var/log/kurtosis/2024/31
sudo chown -R $USER:docker /var/log/kurtosis
Verify Docker Permissions:
sudo chmod -R 755 /var/log/kurtosis
Restart Kurtosis and Docker:
kurtosis engine restart
sudo systemctl restart docker
requirements include but not limited to
kurtosis service logs cdk-v1 zkevm-bridge-ui-001
docker run -it --rm -p 8080:80 leovct/zkevm-bridge-ui:multi-network
generic instruction
docker run --name zkevm-bridge-ui -p 80:8080 -v /path/to/.env:/app/.env leovct/zkevm-bridge-ui:multi-network
docker --version
docker network create erigon-net
docker run -d --name cdk-erigon-sequencer --network erigon-net -p 8123:8123 -p 6900:6900 -p 9091:9091 -p 6060:6060 -v erigon-data:/home/erigon/data -e CDK_ERIGON_SEQUENCER=1 hermeznetwork/cdk-erigon:2.0.0-beta15 sh -c "sleep 10 && cdk-erigon --pprof=true --pprof.addr 0.0.0.0 --config /etc/cdk-erigon/config.yaml"
docker logs -f cdk-erigon-sequencer
sudo apt install netstat hardinfo
docker run -it --rm -p 50071:50071 -p 50061:50061 hermeznetwork/zkevm-prover:v6.0.2 /bin/bash
kurtosis enclave ls
kurtosis enclave inspect bdk-v5
kurtosis service logs bdk-v5 zkevm-bridge-ui-001
enter the service container to manually inspect and debug example brige-ui
kurtosis service shell bdk-v5 zkevm-bridge-ui-001
Clone the Repository and Install Dependencies
git clone https://github.com/LAIR3/BDK7.git
cd BDK7
sh scripts/tool_check.sh
kurtosis clean --all
stop all running containers
docker stop $(docker ps -aq)
Remove all containers:
docker rm $(docker ps -aq)
Remove all images:
docker rmi -f $(docker images -q)
Remove all volumes:
docker volume rm $(docker volume ls -q)
Remove all networks:
docker network rm $(docker network ls -q)
Prune the system:
docker system prune -a --volumes
docker network ls
docker network inspect NAME
############ START ############
kurtosis run --enclave BDK-v5 --args-file params.yml --image-download always .
kurtosis enclave ls
kurtosis enclave inspect bdk7
kurtosis service logs bdk7 zkevm-agglayer-001
yq -Y --in-place 'with_entries(if .key == "deploy_zkevm_permissionless_node" then .value = true elif .value | type == "boolean" then .value = false else . end)' params.yml
kurtosis run --enclave cdk-v1 --args-file params.yml --image-download always .
cp /path/to/external/genesis.json templates/permissionless-node/genesis.json
yq -Y --in-place 'with_entries(if .key == "deploy_zkevm_permissionless_node" then .value = true elif .value | type == "boolean" then .value = false else . end)' params.yml
kurtosis run --enclave bdk-v5 --args-file params.yml --image-download always .
export ETH_RPC_URL="$(kurtosis port print cdk-v1 zkevm-node-rpc-001 http-rpc)"
cast block-number
cast balance --ether 0xE34aaF64b29273B7D567FCFc40544c014EEe9970
cast send --legacy --private-key 0x12d7de8621a77640c9241b2595ba78ce443d05e94090365ab3bb5e19df82c625 --value 0.01ether 0x0000000000000000000000000000000000000000
polycli loadtest --requests 500 --legacy --rpc-url $ETH_RPC_URL --verbosity 700 --rate-limit 5 --mode t --private-key 0x12d7de8621a77640c9241b2595ba78ce443d05e94090365ab3bb5e19df82c625
Prometheus captures all the metrics for the running services. Accessible via: http://127.0.0.1:49678
open http://127.0.0.1:49651/targets
Dashboards for visualizing metrics. Accessible via: http://127.0.0.1:49701
docker run -d --name=grafana-001 -p 49701:3000 grafana/grafana:latest
docker run -d --name=grafana -p 3000:3000 grafana/grafana:latest
docker start grafana
open http://localhost:49701/login
docker logs grafana
docker logs grafana-001
docker stop graphana
open http://127.0.0.1:49701/dashboards
open http://127.0.0.1:49701/login
Monitors on-chain metrics such as blocks, transactions, and smart contract calls. Accessible via: http://127.0.0.1:49651
kurtosis service logs bdk7 el-1-geth-lighthouse
# check statuss
kurtosis enclave ls
kurtosis enclave inspect bdk7
The LAIR3-BDK provides a comprehensive set of commands and tools to facilitate blockchain deployment, primarily utilizing the Kurtosis SDK. Here is a summary of the key commands:
Install dependencies such as Go, Node.js, Docker, and Kurtosis on Ubuntu.
sudo apt install wget
wget https://go.dev/dl/go1.21.6.linux-amd64.tar.gz
sudo rm -rf /usr/local/go
sudo tar -xvf go1.21.6.linux-amd64.tar.gz -C /usr/local/
echo 'export PATH="$PATH:/usr/local/go/bin"' | sudo tee -a ./bashrc
source $HOME/.bashrc
go version
Install Kurtosis:
echo "deb [trusted=yes] https://apt.fury.io/kurtosis-tech/ /" | sudo tee /etc/apt/sources.list.d/kurtosis.list
sudo apt update
sudo apt install kurtosis-cli
Run BDK locally:
kurtosis clean --all
kurtosis run --enclave bdk7 --args-file params.yml --image-download always .
Alternatively, deploy CDK stack using zkevm-node:
kurtosis run --enclave bdk7 --args-file cdk-erigon-sequencer-params.yml --image-download always .
Inspect the enclave for RPC ports:
kurtosis enclave inspect bdk7
export ETH_RPC_URL="$(kurtosis port print bdk7 zkevm-node-rpc-001 http-rpc)"
Test RPC with Foundry commands:
cast block-number
cast balance --ether 0xE34aaF64b29273B7D567FCFc40544c014EEe9970
Send Ether:
export PK="0x12d7de8621a77640c9241b2595ba78ce443d05e94090365ab3bb5e19df82c625"
cast send --legacy --private-key "$PK" --value 0.01ether 0x0000000000000000000000000000000000000000
Load testing with polygon-cli:
polycli loadtest --rpc-url "$ETH_RPC_URL" --legacy --private-key "$PK" --verbosity 700 --requests 500 --rate-limit 10 --mode t
Use Prometheus and Grafana for metrics:
open http://127.0.0.1:49651/targets # Prometheus
open http://127.0.0.1:49701/login # Grafana
Check logs:
kurtosis service logs bdk7 zkevm-agglayer-001
Open a service shell for debugging:
kurtosis service shell bdk7 zkevm-node-sequencer-001
Remove all Docker containers, images, and volumes:
docker stop $(docker ps -aq)
docker rm $(docker ps -aq)
docker rmi -f $(docker images -q)
docker system prune -a --volumes
A Kurtosis package that deploys a private, portable, and modular Polygon CDK devnet over Docker or Kubernetes.
Specifically, this package will deploy:
- A local L1 chain, fully customizable with multi-client support, using the ethereum-package.
- A local L2 chain, using the Polygon Chain Development Kit (CDK), with customizable components such as sequencer, sequence sender, aggregator, rpc, prover, dac, etc. It will first deploy the Polygon zkEVM smart contracts on the L1 chain before deploying the different components.
- The zkEVM bridge infrastructure to facilitate asset bridging between the L1 and L2 chains, and vice-versa.
- The Agglayer, an in-development interoperability protocol, that allows for trustless cross-chain token transfers and message-passing, as well as more complex operations between L2 chains, secured by zk proofs.
- Additional services such as transaction spammer, monitoring tools, permissionless nodes etc.
🚨 This package is currently designed as a development tool for testing configurations and scenarios within the Polygon CDK stack. It is not recommended for long-running or production environments such as testnets or mainnet. If you need help, you can reach out to the Polygon team or talk to an Implementation Partner (IP).
To begin, you will need to install Docker (>= v4.27.0 for Mac users) and Kurtosis.
If you intend to interact with and debug the stack, you may also want to consider a few additional optional tools such as:
Once that is good and installed on your system, you can run the following command to deploy the complete CDK stack locally. The default deployment includes zkevm-contracts (fork 9), cdk-erigon as the sequencer, and cdk-node functioning as the sequence sender and aggregator. This process typically takes around eight to ten minutes.
kurtosis clean --all
kurtosis run --enclave cdk-v1 --args-file params.yml .
It is also possible to deploy the CDK stack using the legacy zkevm-node sequencer and/or the new zkevm or the legacy zkevm-node sequencer sender and aggregator by modyfing the configuration file params.yml
.
For example, the CDK stack can be alternatively deployed using zkevm-contracts (fork 9), with the legacy zkevm-node serving as the sequencer, sequence sender and aggregator.
yq -Y --in-place '.deploy_cdk_erigon_node = false' params.yml
yq -Y --in-place '.args.sequencer_type = "zkevm"' params.yml
kurtosis run --enclave cdk-v1 --args-file params.yml .
Let's do a simple L2 RPC test call.
First, you will need to figure out which port Kurtosis is using for the RPC. You can get a general feel for the entire network layout by running the following command:
kurtosis enclave inspect cdk-v1
That output, while quite useful, might also be a little overwhelming. Let's store the RPC URL in an environment variable. Note that you may need to adjust the various commands slightly if you deployed the legacy zkevm-node as the sequencer. You should target the zkevm-node-rpc-001
service instead of cdk-erigon-node-001
.
export ETH_RPC_URL="$(kurtosis port print cdk-v1 cdk-erigon-node-001 rpc)"
That is the same environment variable that cast
uses, so you should now be able to run this command. Note that the steps below will assume you have the Foundry toolchain installed.
cast block-number
By default, the CDK is configured in test
mode, which means there is some pre-funded value in the admin account with address 0xE34aaF64b29273B7D567FCFc40544c014EEe9970
.
cast balance --ether 0xE34aaF64b29273B7D567FCFc40544c014EEe9970
Okay, let’s send some transactions...
export PK="0x12d7de8621a77640c9241b2595ba78ce443d05e94090365ab3bb5e19df82c625"
cast send --legacy --private-key "$PK" --value 0.01ether 0x0000000000000000000000000000000000000000
Okay, let’s send even more transactions... Note that this step will assume you have polygon-cli installed.
polycli loadtest --rpc-url "$ETH_RPC_URL" --legacy --private-key "$PK" --verbosity 700 --requests 50000 --rate-limit 50 --concurrency 5 --mode t
polycli loadtest --rpc-url "$ETH_RPC_URL" --legacy --private-key "$PK" --verbosity 700 --requests 500 --rate-limit 10 --mode 2
polycli loadtest --rpc-url "$ETH_RPC_URL" --legacy --private-key "$PK" --verbosity 700 --requests 500 --rate-limit 3 --mode uniswapv3
Pretty often, you will want to check the output from the service. Here is how you can grab some logs:
kurtosis service logs cdk-v1 agglayer --follow
In other cases, if you see an error, you might want to get a shell in the service to be able to poke around.
kurtosis service shell cdk-v1 contracts-001
jq . /opt/zkevm/combined.json
One of the most common ways to check the status of the system is to make sure that batches are going through the normal progression of trusted, virtual, and verified:
cast rpc zkevm_batchNumber
cast rpc zkevm_virtualBatchNumber
cast rpc zkevm_verifiedBatchNumber
If the number of verified batches is increasing, then it means the system works properly.
To access the zkevm-bridge
user interface, open this URL in your web browser.
open "$(kurtosis port print cdk-v1 zkevm-bridge-proxy-001 web-ui)"
When everything is done, you might want to clean up with this command which stops the local devnet and deletes it.
kurtosis clean --all
For more information about the CDK stack, visit the Polygon Knowledge Layer.
This section features documentation specifically designed for advanced users, outlining complex operations and techniques.
- How to deploy additional services alongside the CDK stack, such as transaction spammer, monitoring tools, permissionless nodes etc.
- How to attach multiple CDK chains to the AggLayer.
- How to use CDK policies (doc1 and doc2).
- How to use the different data availability modes.
- How to deploy the stack to an external L1 such as Sepolia.
- How to edit the zkevm contracts.
- How to perform an environment migration with clean copies of the databases.
- How to iterate and debug quickly with Kurtosis.
- How to use zkevm contracts fork 12.
- How to integrate a third-party data availability committee (DAC).
- How to migrate from fork 7 to fork 9.
- How to upgrade forks for isolated CDK chains.
- How to use a native token.
- How to play with the network to introduce latencies.
- How to set up a permissionless zkevm node.
- How to run a debugger.
- How to work with the timelock.
- How to trigger a reorg.
- For technical issues, join our Discord.
- For documentation issues, raise an issue on the published live doc at our main repo.
Copyright (c) 2024 PT Services DMCC
Licensed under either:
- Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0), or
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
as your option.
The SPDX license identifier for this project is MIT
OR Apache-2.0
.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.