Skip to content

Commit

Permalink
fix: local debug and better ergonomics (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
vcastellm authored Aug 14, 2024
1 parent 1ca79f9 commit bb8ff47
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 24 deletions.
14 changes: 14 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,20 @@
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Debug cdk",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "cmd/",
"cwd": "${workspaceFolder}",
"args":[
"run",
"-cfg", "tmp/cdk/local_config/test.kurtosis.toml",
"-components", "sequence-sender,aggregator",
"-custom-network-file", "tmp/cdk/local_config/local_config/genesis.json"
]
},
{
"type": "lldb",
"request": "launch",
Expand Down
28 changes: 11 additions & 17 deletions docs/local_debug.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,25 @@
# Setup environment to local debug on VSCode

## Clone kurtosis
## Requirements

Set KURTOSIS_FOLDER to the folder where do you want to clone `kurtosis_cdk`
* Working and running [kurtosis-cdk](https://github.com/0xPolygon/kurtosis-cdk) environment setup.
* In `test/scripts/env.sh` setup `KURTOSIS_FOLDER` pointing to your setup.

```bash
KURTOSIS_FOLDER="/tmp/kurtosis/" ./test/scripts/clone_kurtosis.sh develop $KURTOSIS_FOLDER
```

## Run kurtosis

Set KURTOSIS_FOLDER to the folder where do you clone `kurtosis_cdk`

```bash
KURTOSIS_FOLDER="/tmp/kurtosis/" kurtosis run --enclave cdk-v1 --args-file $KURTOSIS_FOLDER/params.yml --image-download always $KURTOSIS_FOLDER
```
> [!TIP]
> Use your WIP branch in Kurtosis as needed
## Create configuration for this kurtosis environment

`./test/scripts/config_kurtosis_for_local_run.sh`
```
scripts/local_config
```

## Stop sequence-sender started by Kurtosis
## Stop cdk-node started by Kurtosis

```bash
kurtosis service stop cdk-v1 zkevm-node-sequence-sender-001
kurtosis service stop cdk-v1 cdk-node-001
```

## Add to vscode launch.json

After execution `config_kurtosis_for_local_run.sh` it suggest a entry for `launch.json` configurations
After execution `scripts/local_config` it suggest an entry for `launch.json` configurations
18 changes: 11 additions & 7 deletions scripts/config_kurtosis_for_local_run.sh → scripts/local_config
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash
#Include common varaibles
source $(dirname $0)/env.sh
source $(dirname $0)/../test/scripts/env.sh



Expand Down Expand Up @@ -56,8 +56,9 @@ zkevm_data_streamer_port=$(kurtosis port print $ENCLAVE cdk-erigon-sequencer-001
kurtosis files download $ENCLAVE cdk-node-config-artifact $DEST
export zkevm_l2_sequencer_address=$(cat $DEST/cdk-node-config.toml |grep L2Coinbase | cut -f 2 -d "="| tr -d '"' | tr -d ' ')
export zkevm_l2_keystore_password=$(cat $DEST/cdk-node-config.toml |grep -A1 L2Coinbase | tr ',' '\n' | grep Password | cut -f 2 -d '=' | tr -d '}' | tr -d '"' | tr -d ' ')
export l1_chain_id=$(cat $DEST/cdk-node-config.toml |grep L1ChainID | cut -f 2 -d '=')
export zkevm_is_validium=$(cat $DEST/cdk-node-config.toml |grep IsValidiumMode | cut -f 2 -d '=')
export l1_chain_id=$(cat $DEST/cdk-node-config.toml | grep L1ChainID | cut -f 2 -d '=' | head -n 1)
echo $l1_chain_id
export zkevm_is_validium=$(cat $DEST/cdk-node-config.toml | grep IsValidiumMode | cut -f 2 -d '=')

if [ "$zkevm_is_validium" == "true" ]; then
echo "Validium mode detected... Retrieving the dac_port"
Expand All @@ -76,14 +77,17 @@ echo " "
echo "- Add next configuration to vscode launch.json"
cat << EOF
{
"name": "run local_docker",
"name": "Debug cdk"",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "cmd/",
"args":["run","-cfg","$DEST/test.kurtosis.toml",
"--components", "sequence-sender,aggregator",
"--custom-network-file", "$DEST/local_config/genesis.json"
"cwd": "\${workspaceFolder}",
"args":[
"run",
"-cfg", "$DEST/test.kurtosis.toml",
"-components", "sequence-sender,aggregator",
"-custom-network-file", "$DEST/local_config/genesis.json"
]
},
EOF

0 comments on commit bb8ff47

Please sign in to comment.