From bb8ff477dc1a85fb8e0ffab10dc65453b671984a Mon Sep 17 00:00:00 2001 From: Victor Castell Date: Wed, 14 Aug 2024 15:31:37 +0200 Subject: [PATCH] fix: local debug and better ergonomics (#42) --- .vscode/launch.json | 14 ++++++++++ docs/local_debug.md | 28 ++++++++----------- ...kurtosis_for_local_run.sh => local_config} | 18 +++++++----- 3 files changed, 36 insertions(+), 24 deletions(-) rename scripts/{config_kurtosis_for_local_run.sh => local_config} (85%) diff --git a/.vscode/launch.json b/.vscode/launch.json index da517d398..9f1494306 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -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", diff --git a/docs/local_debug.md b/docs/local_debug.md index 59a4de80b..dc6e998bb 100644 --- a/docs/local_debug.md +++ b/docs/local_debug.md @@ -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 diff --git a/scripts/config_kurtosis_for_local_run.sh b/scripts/local_config similarity index 85% rename from scripts/config_kurtosis_for_local_run.sh rename to scripts/local_config index 1d5d92131..ed8aaec33 100755 --- a/scripts/config_kurtosis_for_local_run.sh +++ b/scripts/local_config @@ -1,6 +1,6 @@ #!/bin/bash #Include common varaibles -source $(dirname $0)/env.sh +source $(dirname $0)/../test/scripts/env.sh @@ -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" @@ -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