Skip to Content

Deploy a CDK chain with Avail DA

Introduction

In this guide, we will walk you through the process of deploying a Polygon CDK Validium chain using Avail as the data availability layer. This setup allows you to leverage the scalability and security of Avail for your rollup.

By following this guide, you will learn how to launch a CDK chain on Local or Sepolia testnet, configure it to use Avail for data availability, and interact with your rollup.

In this guide, we will cover:

Prerequisites:

  • CPU: 4 CPUs, amd64
  • Memory: 32 GB
  • Storage: 100 GB
  • OS: Linux
SoftwareVersion
GitOS Default
DockerLatest
Docker ComposeLatest
KurtosisLatest
GOLatest
MakeOS Default
Polygon-cliLatest
FoundryLatest

After executing the following commands you will have installed all the prerequisites needed.

Deploying CDK with AvailDA on Local

1. Build CDK image

CDK  is a modular framework to build and deploy ZKP enabled rollups and validiums. This framework allows you to build a rollup or validium chain with a few simple commands, which is verifiable using zkEVM prover from Polygon.

git clone https://github.com/availproject/cdk.git cd cdk git checkout avail-develop-v0.5.3-rc1 make build-docker docker tag cdk availproject/cdk:avail-develop-v0.5.3-rc1

2. Build cdk-zkevm-contracts  image with mock AvailDABridge and proof verification

git clone https://github.com/availproject/kurtosis-cdk.git cd kurtosis-cdk/docker git checkout avail-develop-v0.3.4 docker build . \ --tag availproject/cdk-zkevm-contracts:avail-develop-v9.0.0-rc.6-pp-fork.12 \ --build-arg ZKEVM_CONTRACTS_BRANCH=mock-bridge-avail-develop-v9.0.0-rc.6-pp \ --build-arg POLYCLI_VERSION="v0.1.73" \ --build-arg FOUNDRY_VERSION=stable \ --file zkevm-contracts.Dockerfile

3. Add AvailDA config values in cdk-node-config.toml

cd kurtosis-cdk/templates/trusted-node vim cdk-node-config.toml

Enter your Seed Phrase and appID. Other information are prefilled for you.

4. Run local CDK chain with AvailDA using Kurtosis-cdk

cd kurtosis-cdk kurtosis run --enclave cdk .

This command will start a local CDK chain with Avail as the data availability layer. It will take a few minutes to initialize the chain and all the services.

5. Chain is up and running

Now you should have a local CDK chain with AvailDA up and running. Try interacting with it as defined in these docs .

Some useful examples to interact with the chain can be Read/write opertations.

  1. First export the RPC URL of your L2 to an environment variable called ETH_RPC_URL:
export ETH_RPC_URL="$(kurtosis port print cdk cdk-erigon-sequencer-001 rpc)"
  1. Use cast to view information about the chain:
cast block-number
  1. To View the balance of a pre-funded admin account:
cast balance --ether 0xE34aaF64b29273B7D567FCFc40544c014EEe9970

To check Avail Logs of cdk-node-001, use kurtosis service logs -f <enclave-name> <service-id>

Deploying CDK with AvailDA on Sepolia

1. Build CDK image

CDK  is a modular framework to build and deploy ZKP enabled rollups and validiums. This framework allows you to build a rollup or validium chain with a few simple commands, which is verifiable using zkEVM prover from Polygon.

git clone https://github.com/availproject/cdk.git git checkout avail-develop-v0.5.3-rc1 make build-docker docker tag cdk availproject/cdk:avail-develop-v0.5.3-rc1

2. Build cdk-zkevm-contracts  image with Sepolia AvailDABridge and proof verification

git clone https://github.com/availproject/kurtosis-cdk.git git checkout avail-develop-v0.3.4 cd kurtosis-cdk/docker docker build . \ --tag availproject/cdk-zkevm-contracts:avail-develop-v9.0.0-rc.6-pp-fork.12 \ --build-arg ZKEVM_CONTRACTS_BRANCH=avail-develop-v9.0.0-rc.6-pp \ --build-arg POLYCLI_VERSION="v0.1.73" \ --build-arg FOUNDRY_VERSION=stable \ --file zkevm-contracts.Dockerfile

3. Modify Deployment scalability

In order to deploy on Sepolia, you need to change the salt  value to avoid a deployment failure. This can be done easily by running this script in kurtosis-cdk:

if sed --version 2>/dev/null | grep -q GNU; then sed -i 's/"salt": "0x.*",/"salt": "0x'$(xxd -p < /dev/random | tr -d "\n" | head -c 64)'",/' templates/contract-deploy/deploy_parameters.json else sed -i '' 's/"salt": "0x.*",/"salt": "0x'$(xxd -p < /dev/random | tr -d "\n" | head -c 64)'",/' templates/contract-deploy/deploy_parameters.json fi

4. Change Finality Time for erigon

We also need to change the finality time for the Erigon node to avoid any waiting time for the contracts deployment to finalize. This can be achieved by using this small snippet of code:

if sed --version 2>/dev/null | grep -q GNU; then sed -i 's/zkevm.l1-highest-block-type: finalized/zkevm.l1-highest-block-type: latest/' templates/cdk-erigon/config.yml else sed -i '' 's/zkevm.l1-highest-block-type: finalized/zkevm.l1-highest-block-type: latest/' templates/cdk-erigon/config.yml fi

5. Deploy CDK to Sepolia file

You need to have a file from Kurtosis-cdk to deploy to Sepolia. Copy the file deploy-cdk-to-sepolia.yml from /kurtosis-cdk/.github/tests/external-l1/deploy-cdk-to-sepolia.yml or this link . Name this file as params.yml in your cdk directory.

Now you need to set necessary configs for deploying to Sepolia. You can do this by running the following command L1 Configs:

## L1 Config l1_chain_id: 11155111 # TODO: Create another mnemonic seed phrase for running the contract deployment on L1. l1_preallocated_mnemonic: CHANGE_ME # TODO: Adjust the amount of ETH you want to spend on this deployment. l1_funding_amount: 5ether # TODO: Configure the L1 RPC URLs to be valid Sepolia endpoints. l1_rpc_url: CHANGE_ME l1_ws_url: CHANGE_ME

In order to Derive application keys, you can use the following command:

seed="film crazy inform bind stomach weather cruel hold quarter stage country purpose" polycli wallet inspect --mnemonic "$seed" --addresses 9 | \ jq -r '.Addresses[] | [.ETHAddress, .HexPrivateKey] | @tsv' | \ awk 'BEGIN{split("sequencer,aggregator,claimtxmanager,timelock,admin,loadtest,agglayer,dac,proofsigner",roles,",")} {print "zkevm_l2_" roles[NR] "address: \"" $1 "\""; print "zkevm_l2" roles[NR] "_private_key: \"0x" $2 "\"\n"}'

6. Add AvailDA config values in cdk-node-config.toml

cd kurtosis-cdk/templates/trusted-node vim cdk-node-config.toml

Enter your Seed Phrase and appID. Other information are prefilled for you.

7. Run deployment to Sepolia with AvailDA using Kurtosis-cdk

cd kurtosis-cdk kurtosis run --enclave cdk . --args-file ./params.yml

8. Chain is up and running

Now you should have a CDK chain with AvailDA deployed on Sepolia. You can interact with it using the same methods as mentioned in the local deployment section. Try interacting with it as defined in these docs .

Congratulations! You have successfully deployed a Polygon CDK Validium chain with AvailDA on Local & Sepolia. For anymore information on CDK, you can refer to the Polygon CDK documentation .

Enable DA attestation verification over Avail Bridge (optional)

The default depolyment of Polygon CDK validium chain using AvailDA, is with DA attestation verfication disabled over AvailAttestation 

To learn more about DA attestation verification, follow this 

To enable the verification, follow these steps

1. Enable the bridge verification on CDK node

There is a config called bridge_enabled in kurtosis-cdk/templates/trusted-node for sequencer-sender and aggregator component of CDK, Make it true

2. Enable the bridge verfication on AvailAttestation contract

cast send <availAttestationAddress> "setAvailBridgeVerificationEnabled(bool)" true \ --private-key <key> \ --rpc-url https://sepolia.drpc.org

This feature is available for both local and Sepolia deployement, and have these same steps to follow

Now you will able to see the DA attestation verification happening over the Polygon CDK chain.

Congratulations! You have successfully deployed a Polygon CDK Validium chain with AvailDA on Local & Sepolia. For anymore information on CDK, you can refer to the Polygon CDK documentation 

Last updated on