From d3775733a57f0a5cac4d0419589b29106e477877 Mon Sep 17 00:00:00 2001 From: xyz <2523269+antojoseph@users.noreply.github.com> Date: Sat, 27 Jul 2024 03:40:03 +0530 Subject: [PATCH 1/6] Add docker desktop support, tested on macOS Sonoma --- .hack/devnet/run.sh | 119 ++++++++++++++++++++++++++--------------- .hack/devnet/run_dd.sh | 84 +++++++++++++++++++++++++++++ Makefile | 7 +++ 3 files changed, 168 insertions(+), 42 deletions(-) create mode 100755 .hack/devnet/run_dd.sh diff --git a/.hack/devnet/run.sh b/.hack/devnet/run.sh index bd2adee..12b293e 100755 --- a/.hack/devnet/run.sh +++ b/.hack/devnet/run.sh @@ -1,4 +1,15 @@ #!/bin/bash +DOCKER_DESKTOP=0 +# Run docker version and grep for the Server line +server_line=$(docker version | grep Server) +# Check if "Docker Desktop" is in the server line +if [[ $server_line == *"Docker Desktop"* ]]; then + echo "Server is running Docker Desktop" + DOCKER_DESKTOP=1 +else + echo "Server is not running Docker Desktop" +fi + __dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ## Run devnet using kurtosis @@ -26,49 +37,73 @@ EXECUTION_NODES=$(docker ps -aq -f "label=enclave_uuid=$ENCLAVE_UUID" \ -f "label=com.kurtosistech.app-id=kurtosis" \ -f "label=com.kurtosistech.custom.ethereum-package.client-type=execution" | tac) -cat < "${__dir}/generated-dora-config.yaml" -logging: - outputLevel: "info" -chain: - name: $ENCLAVE_NAME - configPath: "${__dir}/generated-chain-config.yaml" -server: - host: "0.0.0.0" - port: "8080" -frontend: - enabled: true - debug: false - pprof: true - minimize: false - siteName: "Dora the Explorer" - siteSubtitle: "$ENCLAVE_NAME - Kurtosis" - ethExplorerLink: "" -beaconapi: - localCacheSize: 10 - redisCacheAddr: "" - redisCachePrefix: "" - endpoints: -$(docker inspect -f " - { name: {{ with index .Config.Labels \"com.kurtosistech.id\"}}{{.}}{{end}}, url: http://{{ with index .NetworkSettings.Networks \"kt-$ENCLAVE_NAME\"}}{{.IPAddress }}:4000{{end}} }" $BEACON_NODES) -executionapi: - depositLogBatchSize: 1000 - endpoints: -$(docker inspect -f " - { name: {{ with index .Config.Labels \"com.kurtosistech.id\"}}{{.}}{{end}}, url: http://{{ with index .NetworkSettings.Networks \"kt-$ENCLAVE_NAME\"}}{{.IPAddress }}:8545{{end}} }" $EXECUTION_NODES) -indexer: - inMemoryEpochs: 8 - cachePersistenceDelay: 8 - disableIndexWriter: false - syncEpochCooldown: 1 -database: - engine: "sqlite" - sqlite: - file: "${__dir}/generated-database.sqlite" +# Conditionally execute this block +if [[ $DOCKER_DESKTOP -eq 1 ]]; then + cat < "${__dir}/generated-dora-config.yaml" + logging: + outputLevel: "info" + chain: + name: $ENCLAVE_NAME + configPath: "${__dir}/generated-chain-config.yaml" + server: + host: "0.0.0.0" + port: "8080" + frontend: + enabled: true + debug: false + pprof: true + minimize: false + siteName: "Dora the Explorer" + siteSubtitle: "$ENCLAVE_NAME - Kurtosis" + ethExplorerLink: "" + beaconapi: + localCacheSize: 10 + redisCacheAddr: "" + redisCachePrefix: "" + endpoints: EOF + # Append beacon nodes to the config file + for node in $BEACON_NODES; do + name=$(docker inspect -f "{{ with index .Config.Labels \"com.kurtosistech.id\"}}{{.}}{{end}}" $node) + ip='127.0.0.1' + port=$(docker inspect --format='{{ (index (index .NetworkSettings.Ports "4000/tcp") 0).HostPort }}' $node) + echo " - { name: $name, url: http://$ip:$port }" >> "${__dir}/generated-dora-config.yaml" + done -cat <> "${__dir}/generated-dora-config.yaml" + executionapi: + depositLogBatchSize: 1000 + endpoints: EOF + + # Append execution nodes to the config file + for node in $EXECUTION_NODES; do + name=$(docker inspect -f "{{ with index .Config.Labels \"com.kurtosistech.id\"}}{{.}}{{end}}" $node) + ip='127.0.0.1' + port=$(docker inspect --format='{{ (index (index .NetworkSettings.Ports "8545/tcp") 0).HostPort }}' $node) + echo " - { name: $name, url: http://$ip:$port }" >> "${__dir}/generated-dora-config.yaml" + done + + cat <> "${__dir}/generated-dora-config.yaml" + indexer: + inMemoryEpochs: 8 + cachePersistenceDelay: 8 + disableIndexWriter: false + syncEpochCooldown: 1 + database: + engine: "sqlite" + sqlite: + file: "${__dir}/generated-database.sqlite" +EOF + + cat < /dev/null; then + echo "Kurtosis enclave '$ENCLAVE_NAME' is already up." +else + kurtosis run github.com/ethpandaops/ethereum-package \ + --image-download always \ + --enclave "$ENCLAVE_NAME" \ + --args-file "${__dir}/kurtosis.devnet.config.yaml" +fi + +# Get chain config +kurtosis files inspect "$ENCLAVE_NAME" el_cl_genesis_data ./config.yaml | tail -n +2 > "${__dir}/generated-chain-config.yaml" + +## Generate Dora config +ENCLAVE_UUID=$(kurtosis enclave inspect "$ENCLAVE_NAME" --full-uuids | grep 'UUID:' | awk '{print $2}') + +BEACON_NODES=$(docker ps -aq -f "label=enclave_uuid=$ENCLAVE_UUID" \ + -f "label=com.kurtosistech.app-id=kurtosis" \ + -f "label=com.kurtosistech.custom.ethereum-package.client-type=beacon" | tac) + +EXECUTION_NODES=$(docker ps -aq -f "label=enclave_uuid=$ENCLAVE_UUID" \ + -f "label=com.kurtosistech.app-id=kurtosis" \ + -f "label=com.kurtosistech.custom.ethereum-package.client-type=execution" | tac) + +cat < "${__dir}/generated-dora-config.yaml" +logging: + outputLevel: "info" +chain: + name: $ENCLAVE_NAME + configPath: "${__dir}/generated-chain-config.yaml" +server: + host: "0.0.0.0" + port: "8080" +frontend: + enabled: true + debug: false + pprof: true + minimize: false + siteName: "Dora the Explorer" + siteSubtitle: "$ENCLAVE_NAME - Kurtosis" + ethExplorerLink: "" +beaconapi: + localCacheSize: 10 + redisCacheAddr: "" + redisCachePrefix: "" + endpoints: +$(for node in $BEACON_NODES; do + name=$(docker inspect -f "{{ with index .Config.Labels \"com.kurtosistech.id\"}}{{.}}{{end}}" $node) + ip=$(echo '127.0.0.1') + port=$(docker inspect --format='{{ (index (index .NetworkSettings.Ports "4000/tcp") 0).HostPort }}' $node) + echo " - { name: $name, url: http://$ip:$port }" +done) +executionapi: + depositLogBatchSize: 1000 + endpoints: +$(for node in $EXECUTION_NODES; do + name=$(docker inspect -f "{{ with index .Config.Labels \"com.kurtosistech.id\"}}{{.}}{{end}}" $node) + ip=$(echo '127.0.0.1') + port=$(docker inspect --format='{{ (index (index .NetworkSettings.Ports "8545/tcp") 0).HostPort }}' $node) + echo " - { name: $name, url: http://$ip:$port }" +done) +indexer: + inMemoryEpochs: 8 + cachePersistenceDelay: 8 + disableIndexWriter: false + syncEpochCooldown: 1 +database: + engine: "sqlite" + sqlite: + file: "${__dir}/generated-database.sqlite" +EOF + + +cat < Date: Sat, 27 Jul 2024 04:02:06 +0530 Subject: [PATCH 2/6] Delete .hack/devnet/run.sh No changes are needed to this file, hence removing Signed-off-by: xyz <2523269+antojoseph@users.noreply.github.com> --- .hack/devnet/run.sh | 109 -------------------------------------------- 1 file changed, 109 deletions(-) delete mode 100755 .hack/devnet/run.sh diff --git a/.hack/devnet/run.sh b/.hack/devnet/run.sh deleted file mode 100755 index 12b293e..0000000 --- a/.hack/devnet/run.sh +++ /dev/null @@ -1,109 +0,0 @@ -#!/bin/bash -DOCKER_DESKTOP=0 -# Run docker version and grep for the Server line -server_line=$(docker version | grep Server) -# Check if "Docker Desktop" is in the server line -if [[ $server_line == *"Docker Desktop"* ]]; then - echo "Server is running Docker Desktop" - DOCKER_DESKTOP=1 -else - echo "Server is not running Docker Desktop" -fi - -__dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" - -## Run devnet using kurtosis -ENCLAVE_NAME="${ENCLAVE_NAME:-dora}" -if kurtosis enclave inspect "$ENCLAVE_NAME" > /dev/null; then - echo "Kurtosis enclave '$ENCLAVE_NAME' is already up." -else - kurtosis run github.com/ethpandaops/ethereum-package \ - --image-download always \ - --enclave "$ENCLAVE_NAME" \ - --args-file "${__dir}/kurtosis.devnet.config.yaml" -fi - -# Get chain config -kurtosis files inspect "$ENCLAVE_NAME" el_cl_genesis_data ./config.yaml | tail -n +2 > "${__dir}/generated-chain-config.yaml" - -## Generate Dora config -ENCLAVE_UUID=$(kurtosis enclave inspect "$ENCLAVE_NAME" --full-uuids | grep 'UUID:' | awk '{print $2}') - -BEACON_NODES=$(docker ps -aq -f "label=enclave_uuid=$ENCLAVE_UUID" \ - -f "label=com.kurtosistech.app-id=kurtosis" \ - -f "label=com.kurtosistech.custom.ethereum-package.client-type=beacon" | tac) - -EXECUTION_NODES=$(docker ps -aq -f "label=enclave_uuid=$ENCLAVE_UUID" \ - -f "label=com.kurtosistech.app-id=kurtosis" \ - -f "label=com.kurtosistech.custom.ethereum-package.client-type=execution" | tac) - -# Conditionally execute this block -if [[ $DOCKER_DESKTOP -eq 1 ]]; then - cat < "${__dir}/generated-dora-config.yaml" - logging: - outputLevel: "info" - chain: - name: $ENCLAVE_NAME - configPath: "${__dir}/generated-chain-config.yaml" - server: - host: "0.0.0.0" - port: "8080" - frontend: - enabled: true - debug: false - pprof: true - minimize: false - siteName: "Dora the Explorer" - siteSubtitle: "$ENCLAVE_NAME - Kurtosis" - ethExplorerLink: "" - beaconapi: - localCacheSize: 10 - redisCacheAddr: "" - redisCachePrefix: "" - endpoints: -EOF - - # Append beacon nodes to the config file - for node in $BEACON_NODES; do - name=$(docker inspect -f "{{ with index .Config.Labels \"com.kurtosistech.id\"}}{{.}}{{end}}" $node) - ip='127.0.0.1' - port=$(docker inspect --format='{{ (index (index .NetworkSettings.Ports "4000/tcp") 0).HostPort }}' $node) - echo " - { name: $name, url: http://$ip:$port }" >> "${__dir}/generated-dora-config.yaml" - done - - cat <> "${__dir}/generated-dora-config.yaml" - executionapi: - depositLogBatchSize: 1000 - endpoints: -EOF - - # Append execution nodes to the config file - for node in $EXECUTION_NODES; do - name=$(docker inspect -f "{{ with index .Config.Labels \"com.kurtosistech.id\"}}{{.}}{{end}}" $node) - ip='127.0.0.1' - port=$(docker inspect --format='{{ (index (index .NetworkSettings.Ports "8545/tcp") 0).HostPort }}' $node) - echo " - { name: $name, url: http://$ip:$port }" >> "${__dir}/generated-dora-config.yaml" - done - - cat <> "${__dir}/generated-dora-config.yaml" - indexer: - inMemoryEpochs: 8 - cachePersistenceDelay: 8 - disableIndexWriter: false - syncEpochCooldown: 1 - database: - engine: "sqlite" - sqlite: - file: "${__dir}/generated-database.sqlite" -EOF - - cat < Date: Fri, 26 Jul 2024 22:35:58 +0000 Subject: [PATCH 3/6] Adding back the run.sh command --- .hack/devnet/run.sh | 74 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 .hack/devnet/run.sh diff --git a/.hack/devnet/run.sh b/.hack/devnet/run.sh new file mode 100644 index 0000000..5d63af7 --- /dev/null +++ b/.hack/devnet/run.sh @@ -0,0 +1,74 @@ +#!/bin/bash +__dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" + +## Run devnet using kurtosis +ENCLAVE_NAME="${ENCLAVE_NAME:-dora}" +if kurtosis enclave inspect "$ENCLAVE_NAME" > /dev/null; then + echo "Kurtosis enclave '$ENCLAVE_NAME' is already up." +else + kurtosis run github.com/ethpandaops/ethereum-package \ + --image-download always \ + --enclave "$ENCLAVE_NAME" \ + --args-file "${__dir}/kurtosis.devnet.config.yaml" +fi + +# Get chain config +kurtosis files inspect "$ENCLAVE_NAME" el_cl_genesis_data ./config.yaml | tail -n +2 > "${__dir}/generated-chain-config.yaml" + +## Generate Dora config +ENCLAVE_UUID=$(kurtosis enclave inspect "$ENCLAVE_NAME" --full-uuids | grep 'UUID:' | awk '{print $2}') + +BEACON_NODES=$(docker ps -aq -f "label=enclave_uuid=$ENCLAVE_UUID" \ + -f "label=com.kurtosistech.app-id=kurtosis" \ + -f "label=com.kurtosistech.custom.ethereum-package.client-type=beacon" | tac) + +EXECUTION_NODES=$(docker ps -aq -f "label=enclave_uuid=$ENCLAVE_UUID" \ + -f "label=com.kurtosistech.app-id=kurtosis" \ + -f "label=com.kurtosistech.custom.ethereum-package.client-type=execution" | tac) + +cat < "${__dir}/generated-dora-config.yaml" +logging: + outputLevel: "info" +chain: + name: $ENCLAVE_NAME + configPath: "${__dir}/generated-chain-config.yaml" +server: + host: "0.0.0.0" + port: "8080" +frontend: + enabled: true + debug: false + pprof: true + minimize: false + siteName: "Dora the Explorer" + siteSubtitle: "$ENCLAVE_NAME - Kurtosis" + ethExplorerLink: "" +beaconapi: + localCacheSize: 10 + redisCacheAddr: "" + redisCachePrefix: "" + endpoints: +$(docker inspect -f " - { name: {{ with index .Config.Labels \"com.kurtosistech.id\"}}{{.}}{{end}}, url: http://{{ with index .NetworkSettings.Networks \"kt-$ENCLAVE_NAME\"}}{{.IPAddress }}:4000{{end}} }" $BEACON_NODES) +executionapi: + depositLogBatchSize: 1000 + endpoints: +$(docker inspect -f " - { name: {{ with index .Config.Labels \"com.kurtosistech.id\"}}{{.}}{{end}}, url: http://{{ with index .NetworkSettings.Networks \"kt-$ENCLAVE_NAME\"}}{{.IPAddress }}:8545{{end}} }" $EXECUTION_NODES) +indexer: + inMemoryEpochs: 8 + cachePersistenceDelay: 8 + disableIndexWriter: false + syncEpochCooldown: 1 +database: + engine: "sqlite" + sqlite: + file: "${__dir}/generated-database.sqlite" +EOF + + +cat < Date: Thu, 15 Aug 2024 05:51:40 +0000 Subject: [PATCH 4/6] made changes to run.sh file so it works with docker desktop and orbstack as per review comments --- .hack/devnet/run.sh | 14 ++++++- .hack/devnet/run_dd.sh | 84 ------------------------------------------ Makefile | 37 ------------------- 3 files changed, 12 insertions(+), 123 deletions(-) delete mode 100755 .hack/devnet/run_dd.sh delete mode 100644 Makefile diff --git a/.hack/devnet/run.sh b/.hack/devnet/run.sh index 5d63af7..18f860a 100644 --- a/.hack/devnet/run.sh +++ b/.hack/devnet/run.sh @@ -48,11 +48,21 @@ beaconapi: redisCacheAddr: "" redisCachePrefix: "" endpoints: -$(docker inspect -f " - { name: {{ with index .Config.Labels \"com.kurtosistech.id\"}}{{.}}{{end}}, url: http://{{ with index .NetworkSettings.Networks \"kt-$ENCLAVE_NAME\"}}{{.IPAddress }}:4000{{end}} }" $BEACON_NODES) +$(for node in $BEACON_NODES; do + name=$(docker inspect -f "{{ with index .Config.Labels \"com.kurtosistech.id\"}}{{.}}{{end}}" $node) + ip=$(echo '127.0.0.1') + port=$(docker inspect --format='{{ (index (index .NetworkSettings.Ports "4000/tcp") 0).HostPort }}' $node) + echo " - { name: $name, url: http://$ip:$port }" +done) executionapi: depositLogBatchSize: 1000 endpoints: -$(docker inspect -f " - { name: {{ with index .Config.Labels \"com.kurtosistech.id\"}}{{.}}{{end}}, url: http://{{ with index .NetworkSettings.Networks \"kt-$ENCLAVE_NAME\"}}{{.IPAddress }}:8545{{end}} }" $EXECUTION_NODES) +$(for node in $EXECUTION_NODES; do + name=$(docker inspect -f "{{ with index .Config.Labels \"com.kurtosistech.id\"}}{{.}}{{end}}" $node) + ip=$(echo '127.0.0.1') + port=$(docker inspect --format='{{ (index (index .NetworkSettings.Ports "8545/tcp") 0).HostPort }}' $node) + echo " - { name: $name, url: http://$ip:$port }" +done) indexer: inMemoryEpochs: 8 cachePersistenceDelay: 8 diff --git a/.hack/devnet/run_dd.sh b/.hack/devnet/run_dd.sh deleted file mode 100755 index b15d6b5..0000000 --- a/.hack/devnet/run_dd.sh +++ /dev/null @@ -1,84 +0,0 @@ -#!/bin/bash -__dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" - -## Run devnet using kurtosis -ENCLAVE_NAME="${ENCLAVE_NAME:-dora}" -if kurtosis enclave inspect "$ENCLAVE_NAME" > /dev/null; then - echo "Kurtosis enclave '$ENCLAVE_NAME' is already up." -else - kurtosis run github.com/ethpandaops/ethereum-package \ - --image-download always \ - --enclave "$ENCLAVE_NAME" \ - --args-file "${__dir}/kurtosis.devnet.config.yaml" -fi - -# Get chain config -kurtosis files inspect "$ENCLAVE_NAME" el_cl_genesis_data ./config.yaml | tail -n +2 > "${__dir}/generated-chain-config.yaml" - -## Generate Dora config -ENCLAVE_UUID=$(kurtosis enclave inspect "$ENCLAVE_NAME" --full-uuids | grep 'UUID:' | awk '{print $2}') - -BEACON_NODES=$(docker ps -aq -f "label=enclave_uuid=$ENCLAVE_UUID" \ - -f "label=com.kurtosistech.app-id=kurtosis" \ - -f "label=com.kurtosistech.custom.ethereum-package.client-type=beacon" | tac) - -EXECUTION_NODES=$(docker ps -aq -f "label=enclave_uuid=$ENCLAVE_UUID" \ - -f "label=com.kurtosistech.app-id=kurtosis" \ - -f "label=com.kurtosistech.custom.ethereum-package.client-type=execution" | tac) - -cat < "${__dir}/generated-dora-config.yaml" -logging: - outputLevel: "info" -chain: - name: $ENCLAVE_NAME - configPath: "${__dir}/generated-chain-config.yaml" -server: - host: "0.0.0.0" - port: "8080" -frontend: - enabled: true - debug: false - pprof: true - minimize: false - siteName: "Dora the Explorer" - siteSubtitle: "$ENCLAVE_NAME - Kurtosis" - ethExplorerLink: "" -beaconapi: - localCacheSize: 10 - redisCacheAddr: "" - redisCachePrefix: "" - endpoints: -$(for node in $BEACON_NODES; do - name=$(docker inspect -f "{{ with index .Config.Labels \"com.kurtosistech.id\"}}{{.}}{{end}}" $node) - ip=$(echo '127.0.0.1') - port=$(docker inspect --format='{{ (index (index .NetworkSettings.Ports "4000/tcp") 0).HostPort }}' $node) - echo " - { name: $name, url: http://$ip:$port }" -done) -executionapi: - depositLogBatchSize: 1000 - endpoints: -$(for node in $EXECUTION_NODES; do - name=$(docker inspect -f "{{ with index .Config.Labels \"com.kurtosistech.id\"}}{{.}}{{end}}" $node) - ip=$(echo '127.0.0.1') - port=$(docker inspect --format='{{ (index (index .NetworkSettings.Ports "8545/tcp") 0).HostPort }}' $node) - echo " - { name: $name, url: http://$ip:$port }" -done) -indexer: - inMemoryEpochs: 8 - cachePersistenceDelay: 8 - disableIndexWriter: false - syncEpochCooldown: 1 -database: - engine: "sqlite" - sqlite: - file: "${__dir}/generated-database.sqlite" -EOF - - -cat < Date: Thu, 15 Aug 2024 05:57:15 +0000 Subject: [PATCH 5/6] removed make file by mistake, adding it back --- Makefile | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..74d5960 --- /dev/null +++ b/Makefile @@ -0,0 +1,30 @@ +# dora +BUILDTIME := $(shell date -u '+%Y-%m-%dT%H:%M:%SZ') +VERSION := $(shell git rev-parse --short HEAD) + +GOLDFLAGS += -X 'github.com/ethpandaops/dora/utils.BuildVersion="$(VERSION)"' +GOLDFLAGS += -X 'github.com/ethpandaops/dora/utils.Buildtime="$(BUILDTIME)"' +GOLDFLAGS += -X 'github.com/ethpandaops/dora/utils.BuildRelease="$(RELEASE)"' + +.PHONY: all test clean + +all: test build + +test: + go test ./... + +build: + @echo version: $(VERSION) + env CGO_ENABLED=1 go build -v -o bin/ -ldflags="-s -w $(GOLDFLAGS)" ./cmd/* + +clean: + rm -f bin/* + +devnet: + .hack/devnet/run.sh + +devnet-run: devnet + go run cmd/dora-explorer/main.go --config .hack/devnet/generated-dora-config.yaml + +devnet-clean: + .hack/devnet/cleanup.sh \ No newline at end of file From 2d3f092143337f553aa4dd8396ad6c26cc9cdc30 Mon Sep 17 00:00:00 2001 From: xyz <2523269+antojoseph@users.noreply.github.com> Date: Thu, 15 Aug 2024 06:01:53 +0000 Subject: [PATCH 6/6] make run.sh executable --- .hack/devnet/run.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 .hack/devnet/run.sh diff --git a/.hack/devnet/run.sh b/.hack/devnet/run.sh old mode 100644 new mode 100755