Skip to content

Commit

Permalink
feat: Add static ports (#677)
Browse files Browse the repository at this point in the history
## Summary

This PR adds the possibility to define static ports for most of the
components included in the ethereum-package for kurtosis.

Furthermore, some parts of the code, which are relevant for this PR,
will be refactored.

## Tasks

- [x] Add new settings to network_params
- [x] Update input_parser
- [x] Update shared_utils
- [x] Add static ports to el clients
- [x] Add static ports to cl clients
- [x] Add static ports to vc clients
- [x] Add static ports to additional services
- [x] Update documentation

---------

Co-authored-by: Barnabas Busa <busa.barnabas@gmail.com>
  • Loading branch information
TobiWo and barnabasbusa authored Jul 3, 2024
1 parent cc2949b commit 4f054d0
Show file tree
Hide file tree
Showing 45 changed files with 1,057 additions and 724 deletions.
13 changes: 12 additions & 1 deletion .github/tests/mix-public.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,15 @@ participants:
cl_type: grandine
additional_services: []
port_publisher:
public_port_start: 30000
el:
enabled: true
public_port_start: 32000
cl:
enabled: true
public_port_start: 33000
vc:
enabled: true
public_port_start: 34000
additional_services:
enabled: true
public_port_start: 35000
22 changes: 16 additions & 6 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,19 @@ jobs:
echo "Skipping ./.github/tests/mix-with-tools-mev.yaml"
fi
- name: Check if Discord Webhook is Set
id: check_discord_webhook
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
run: |
if [ -z "$DISCORD_WEBHOOK" ]; then
echo "discord_webhook_set=false" >> $GITHUB_ENV
else
echo "discord_webhook_set=true" >> $GITHUB_ENV
fi
- name: Notify
if: cancelled() || failure()
if: (cancelled() || failure()) && env.discord_webhook_set == 'true'
uses: Ilshidur/action-discord@master
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
Expand All @@ -54,12 +65,11 @@ jobs:
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Extract branch name
shell: bash
run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT
id: extract_branch
- name: Kurtosis Assertoor GitHub Action
uses: ethpandaops/kurtosis-assertoor-github-action@v1
with:
ethereum_package_branch: ${{ steps.extract_branch.outputs.branch }}
kurtosis_extra_args: "--image-download always --non-blocking-tasks --verbosity DETAILED"
ethereum_package_branch: ""
ethereum_package_args: .github/tests/mix-assert.yaml
ethereum_package_url: "$GITHUB_WORKSPACE"
persistent_logs: "true"
23 changes: 19 additions & 4 deletions .github/workflows/run-k8s.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
pull_request:
workflow_dispatch:
schedule:
- cron: '0 2 * * *'
- cron: '0 2 * * *'

concurrency:
group: "scheduled-test"
Expand All @@ -21,15 +21,18 @@ jobs:
steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Setup minikube
id: minikube
uses: medyagh/setup-minikube@latest

- name: Get kubeconfig
id: kubeconfig
shell: bash
run: |
cat ~/.kube/config > kubeconfig
echo "kubeconfig=$(cat kubeconfig | base64 -w 0)" >> $GITHUB_OUTPUT
# run kurtosis test and assertoor
- name: Run kurtosis testnet
id: testnet
Expand All @@ -40,15 +43,27 @@ jobs:
kubernetes_config: "${{ steps.kubeconfig.outputs.kubeconfig }}"
kubernetes_cluster: "minikube"
kubernetes_storage_class: "standard"
ethereum_package_branch: "${{ github.head_ref || github.ref_name }}"
ethereum_package_branch: ""
ethereum_package_args: "${{ matrix.payload.file }}"
ethereum_package_url: "$GITHUB_WORKSPACE"
enclave_name: "ethereum-package-${{ matrix.payload.name }}-${{ github.run_id }}"
persistent_logs: "true"

- name: Check if Discord Webhook is Set
id: check_discord_webhook
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
run: |
if [ -z "$DISCORD_WEBHOOK" ]; then
echo "discord_webhook_set=false" >> $GITHUB_ENV
else
echo "discord_webhook_set=true" >> $GITHUB_ENV
fi
- name: Notify
if: cancelled() || failure()
if: (cancelled() || failure()) && env.discord_webhook_set == 'true'
uses: Ilshidur/action-discord@master
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
with:
args: "The k8s nightly/per PR test for ${{matrix.payload.name}} on ethereum-package has failed find it here ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
args: "The k8s nightly/per PR test for ${{matrix.payload.name}} on ethereum-package has failed. Find it here: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
31 changes: 28 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -797,9 +797,34 @@ port_publisher:
# Defaults to constants.PRIVATE_IP_ADDRESS_PLACEHOLDER
# The default value just means its the IP address of the container in which the service is running
nat_exit_ip: KURTOSIS_IP_ADDR_PLACEHOLDER
# The start value gets used as a seed for TCP and UDP discovery ports for el/cl client
# Defaults to None - no public ports
public_port_start: null
# Execution Layer public port exposed to your local machine
# Disabled by default
# Public port start defaults to 32000
# You can't run multiple enclaves on the same port settings
el:
enabled: false
public_port_start: 32000
# Consensus Layer public port exposed to your local machine
# Disabled by default
# Public port start defaults to 33000
# You can't run multiple enclaves on the same port settings
cl:
enabled: false
public_port_start: 33000
# Validator client public port exposed to your local machine
# Disabled by default
# Public port start defaults to 34000
# You can't run multiple enclaves on the same port settings
vc:
enabled: false
public_port_start: 34000
# Additional services public port exposed to your local machine
# Disabled by default
# Public port start defaults to 35000
# You can't run multiple enclaves on the same port settings
additional_services:
enabled: false
public_port_start: 35000
```

#### Example configurations
Expand Down
24 changes: 23 additions & 1 deletion main.star
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,9 @@ def run(plan, args={}):
return output

launch_prometheus_grafana = False
for additional_service in args_with_right_defaults.additional_services:
for index, additional_service in enumerate(
args_with_right_defaults.additional_services
):
if additional_service == "tx_spammer":
plan.print("Launching transaction spammer")
tx_spammer_params = args_with_right_defaults.tx_spammer_params
Expand Down Expand Up @@ -421,6 +423,8 @@ def run(plan, args={}):
el_forkmon_config_template,
all_el_contexts,
global_node_selectors,
args_with_right_defaults.port_publisher,
index,
)
plan.print("Successfully launched execution layer forkmon")
elif additional_service == "beacon_metrics_gazer":
Expand All @@ -431,6 +435,8 @@ def run(plan, args={}):
all_cl_contexts,
network_params,
global_node_selectors,
args_with_right_defaults.port_publisher,
index,
)
)
launch_prometheus_grafana = True
Expand All @@ -445,6 +451,8 @@ def run(plan, args={}):
all_el_contexts,
persistent,
global_node_selectors,
args_with_right_defaults.port_publisher,
index,
)
plan.print("Successfully launched blockscout")
elif additional_service == "dora":
Expand All @@ -462,6 +470,8 @@ def run(plan, args={}):
global_node_selectors,
mev_endpoints,
mev_endpoint_names,
args_with_right_defaults.port_publisher,
index,
)
plan.print("Successfully launched dora")
elif additional_service == "dugtrio":
Expand All @@ -476,6 +486,8 @@ def run(plan, args={}):
args_with_right_defaults.participants,
network_params,
global_node_selectors,
args_with_right_defaults.port_publisher,
index,
)
plan.print("Successfully launched dugtrio")
elif additional_service == "blutgang":
Expand All @@ -490,6 +502,8 @@ def run(plan, args={}):
args_with_right_defaults.participants,
network_params,
global_node_selectors,
args_with_right_defaults.port_publisher,
index,
)
plan.print("Successfully launched blutgang")
elif additional_service == "blobscan":
Expand All @@ -501,6 +515,8 @@ def run(plan, args={}):
network_params.network_id,
persistent,
global_node_selectors,
args_with_right_defaults.port_publisher,
index,
)
plan.print("Successfully launched blobscan")
elif additional_service == "forky":
Expand All @@ -517,6 +533,8 @@ def run(plan, args={}):
network_params,
global_node_selectors,
final_genesis_timestamp,
args_with_right_defaults.port_publisher,
index,
)
plan.print("Successfully launched forky")
elif additional_service == "tracoor":
Expand All @@ -533,6 +551,8 @@ def run(plan, args={}):
network_params,
global_node_selectors,
final_genesis_timestamp,
args_with_right_defaults.port_publisher,
index,
)
plan.print("Successfully launched tracoor")
elif additional_service == "apache":
Expand All @@ -559,6 +579,8 @@ def run(plan, args={}):
all_el_contexts,
persistent,
global_node_selectors,
args_with_right_defaults.port_publisher,
index,
)
plan.print("Successfully launched full-beaconchain-explorer")
elif additional_service == "prometheus_grafana":
Expand Down
13 changes: 12 additions & 1 deletion network_params.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -153,5 +153,16 @@ global_tolerations: []
global_node_selectors: {}
keymanager_enabled: false
port_publisher:
public_port_start: null
nat_exit_ip: KURTOSIS_IP_ADDR_PLACEHOLDER
el:
enabled: false
public_port_start: 32000
cl:
enabled: false
public_port_start: 33000
vc:
enabled: false
public_port_start: 34000
additional_services:
enabled: false
public_port_start: 35000
25 changes: 21 additions & 4 deletions src/beacon_metrics_gazer/beacon_metrics_gazer_launcher.star
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
shared_utils = import_module("../shared_utils/shared_utils.star")
prometheus = import_module("../prometheus/prometheus_launcher.star")

constants = import_module("../package_io/constants.star")

SERVICE_NAME = "beacon-metrics-gazer"
IMAGE_NAME = "ethpandaops/beacon-metrics-gazer:master"

HTTP_PORT_ID = "http"
HTTP_PORT_NUMBER = 8080

METRICS_PATH = "/metrics"
Expand All @@ -17,7 +16,7 @@ BEACON_METRICS_GAZER_CONFIG_MOUNT_DIRPATH_ON_SERVICE = "/config"
VALIDATOR_RANGES_ARTIFACT_NAME = "validator-ranges"

USED_PORTS = {
HTTP_PORT_ID: shared_utils.new_port_spec(
constants.HTTP_PORT_ID: shared_utils.new_port_spec(
HTTP_PORT_NUMBER,
shared_utils.TCP_PROTOCOL,
shared_utils.HTTP_APPLICATION_PROTOCOL,
Expand All @@ -36,10 +35,14 @@ def launch_beacon_metrics_gazer(
cl_contexts,
network_params,
global_node_selectors,
port_publisher,
additional_service_index,
):
config = get_config(
cl_contexts[0].beacon_http_url,
global_node_selectors,
port_publisher,
additional_service_index,
)

beacon_metrics_gazer_service = plan.add_service(SERVICE_NAME, config)
Expand All @@ -56,14 +59,28 @@ def launch_beacon_metrics_gazer(
)


def get_config(beacon_http_url, node_selectors):
def get_config(
beacon_http_url,
node_selectors,
port_publisher,
additional_service_index,
):
config_file_path = shared_utils.path_join(
BEACON_METRICS_GAZER_CONFIG_MOUNT_DIRPATH_ON_SERVICE,
BEACON_METRICS_GAZER_CONFIG_FILENAME,
)

public_ports = shared_utils.get_additional_service_standard_public_port(
port_publisher,
constants.HTTP_PORT_ID,
additional_service_index,
0,
)

return ServiceConfig(
image=IMAGE_NAME,
ports=USED_PORTS,
public_ports=public_ports,
files={
BEACON_METRICS_GAZER_CONFIG_MOUNT_DIRPATH_ON_SERVICE: VALIDATOR_RANGES_ARTIFACT_NAME,
},
Expand Down
Loading

0 comments on commit 4f054d0

Please sign in to comment.