Skip to content

Commit

Permalink
feat: introduce Geth archive node profile
Browse files Browse the repository at this point in the history
  • Loading branch information
mrekucci committed Aug 30, 2024
1 parent 86e18aa commit 8c0034d
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 12 deletions.
42 changes: 33 additions & 9 deletions infrastructure/nomad/cluster.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@ profile_name="devnet"
datadog_key=""
l1_rpc_url=""
otel_collector_endpoint_url=""
genesis_file_url=""
geth_bootnode_url=""

help() {
echo "Usage:"
echo "$0 [init [--environment <name=devenv>] [--skip-certificates-setup] [--debug]]"
echo "$0 [deploy [version=HEAD] [--environment <name=devenv>] [--profile <name=devnet>] [--force-build-templates] [--no-logs-collection] [--datadog-key <key>] [--l1-rpc-url <url>] [--otel-collector-endpoint-url <url>] [--release] [--debug]]"
echo "$0 [deploy [version=HEAD] [--environment <name=devenv>] [--profile <name=devnet>] [--force-build-templates] [--no-logs-collection] [--datadog-key <key>] [--l1-rpc-url <url>] [--otel-collector-endpoint-url <url>] [--genesis-file-url <url>] [--geth-bootnode-url <url>] [--release] [--debug]]"
echo "$0 [destroy [--backup] [--debug]]"
echo "$0 --help"
echo
Expand All @@ -32,13 +34,15 @@ help() {
echo " --debug Enable debug mode for detailed output."
echo
echo " deploy [version=HEAD] Deploy the specified artifact version (a git commit hash or an existing AWS S3 tag). If not specified or set to HEAD, a local build is triggered."
echo " --environment <name=devenv> Specify the environment to use (default is devenv)."
echo " --profile <name=devnet> Specify the profile to use (default is devnet)."
echo " --environment <name=devenv>] Specify the environment to use (default is devenv)."
echo " --profile <name=devnet>] Specify the profile to use (default is devnet)."
echo " --force-build-templates Force the build of all job templates before deployment."
echo " --no-logs-collection Disable the collection of logs from deployed jobs."
echo " --datadog-key <key> Datadog API key, cannot be empty."
echo " --l1-rpc-url <url> L1 RPC URL, cannot be empty."
echo " --otel-collector-endpoint-url <url> OpenTelemetry Collector Endpoint URL, cannot be empty."
echo " --datadog-key <key>] Datadog API key, cannot be empty."
echo " --l1-rpc-url <url>] L1 RPC URL, cannot be empty."
echo " --otel-collector-endpoint-url <url>] OpenTelemetry Collector Endpoint URL, cannot be empty."
echo " --genesis-file-url <url>] URL to the genesis file, cannot be empty."
echo " --geth-bootnode-url <url>] URL to the Geth bootnode, cannot be empty."
echo " --release It will ignore the specified deployment version and use the current HEAD tag as the build version."
echo " --debug Enable debug mode for detailed output."
echo
Expand Down Expand Up @@ -70,8 +74,8 @@ help() {
echo " Deploy with a specific version, environment, profile and force to build all job templates:"
echo " $0 deploy v0.1.0 --environment devenv --profile testnet --force-build-templates"
echo
echo " Deploy with a specific version, environment, profile in debug mode with disabled logs collection, Datadog API key, L1 RPC URL, and OpenTememetry Collector Endpoint URL:"
echo " $0 deploy v0.1.0 --environment devenv --profile testnet --no-logs-collection --datadog-key your_datadog_key --l1-rpc-url your_rpc_url --otel-collector-endpoint-url your_otel_url --debug"
echo " Deploy with a specific version, environment, profile in debug mode with disabled logs collection, Datadog API key, L1 RPC URL, OpenTelemetry Collector Endpoint URL, genesis file URL, and Geth bootnode URL:"
echo " $0 deploy v0.1.0 --environment devenv --profile testnet --no-logs-collection --datadog-key your_datadog_key --l1-rpc-url your_rpc_url --otel-collector-endpoint-url your_otel_url --genesis-file-url your_genesis_file_url --geth-bootnode-url your_geth_bootnode_url --debug"
echo
echo " Destroy all jobs but backup before do so:"
echo " $0 destroy --backup --debug"
Expand All @@ -81,7 +85,7 @@ help() {
usage() {
echo "Usage:"
echo "$0 [init [--environment <name=devenv>] [--skip-certificates-setup] [--debug]]"
echo "$0 [deploy [version=HEAD] [--environment <name=devenv>] [--profile <name=devnet>] [--force-build-templates] [--no-logs-collection] [--datadog-key <key>] [--l1-rpc-url <url>] [--otel-collector-endpoint-url <url>] [--release] [--debug]]"
echo "$0 [deploy [version=HEAD] [--environment <name=devenv>] [--profile <name=devnet>] [--force-build-templates] [--no-logs-collection] [--datadog-key <key>] [--l1-rpc-url <url>] [--otel-collector-endpoint-url <url>] [--genesis-file-url <url>] [--geth-bootnode-url <url>] [--release] [--debug]]"
echo "$0 [destroy [--backup] [--debug]]"
echo "$0 --help"
exit 1
Expand Down Expand Up @@ -229,6 +233,24 @@ parse_args() {
usage
fi
fi
if [[ $# -gt 0 && $1 == "--genesis-file-url" ]]; then
if [[ $# -gt 1 && ! $2 =~ ^-- ]]; then
genesis_file_url="$2"
shift 2
else
echo "Error: --genesis-file-url requires a value."
usage
fi
fi
if [[ $# -gt 0 && $1 == "--geth-bootnode-url" ]]; then
if [[ $# -gt 1 && ! $2 =~ ^-- ]]; then
geth_bootnode_url="$2"
shift 2
else
echo "Error: --geth-bootnode-url requires a value."
usage
fi
fi
if [[ $# -gt 0 && $1 == "--release" ]]; then
release_flag=true
shift
Expand Down Expand Up @@ -290,6 +312,8 @@ main() {
[[ -n "${datadog_key}" ]] && flags+=("--extra-vars" "datadog_key=${datadog_key}")
[[ -n "${l1_rpc_url}" ]] && flags+=("--extra-vars" "l1_rpc_url=${l1_rpc_url}")
[[ -n "${otel_collector_endpoint_url}" ]] && flags+=("--extra-vars" "otel_collector_endpoint_url=${otel_collector_endpoint_url}")
[[ -n "${genesis_file_url}" ]] && flags+=("--extra-vars" "genesis_file_url=${genesis_file_url}")
[[ -n "${geth_bootnode_url}" ]] && flags+=("--extra-vars" "geth_bootnode_url=${geth_bootnode_url}")
[[ "${release_flag}" == true ]] && flags+=("--extra-vars" "release=true")
;;
"${destroy_flag}")
Expand Down
15 changes: 12 additions & 3 deletions infrastructure/nomad/playbooks/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
release: false
build_artifacts: false
build_templates: false
genesis_file_url: ""
otel_collector_endpoint_url: ""
aws_s3_bucket: "primev-infrastructure-artifacts"

Expand Down Expand Up @@ -523,10 +524,18 @@
) | jq -c '.' > "{{ dist_dir }}/genesis_{{ environments[env].version }}.json"
args:
executable: bash
register: genesis_facts
delegate_to: localhost
run_once: true
when: build_artifacts
when: build_artifacts and genesis_file_url | trim | length == 0

- name: Fetch Genesis File
ansible.builtin.uri:
url: "{{ genesis_file_url }}"
dest: "{{ dist_dir }}/genesis_{{ environments[env].version }}.json"
return_content: no
delegate_to: localhost
run_once: true
when: build_artifacts and genesis_file_url | trim | length > 0

- name: Prepare launchmevcommit Script
ansible.builtin.shell: |
Expand All @@ -548,7 +557,7 @@
executable: bash
delegate_to: localhost
run_once: true
when: build_artifacts and env == 'devenv'
when: build_artifacts and env == 'devenv' and profile != 'archive'

- name: Filter Artifacts for Upload
ansible.builtin.find:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,13 +238,17 @@ job "{{ job.name }}" {
{% endif %}
GETH_SYNC_MODE="{{ job.env['sync_mode'] }}"
{% if job.env['type'] != 'bootnode' %}
{% if geth_bootnode_url is defined %}
BOOTNODE_ENDPOINT="{{ geth_bootnode_url }}"
{% else %}
{%- raw %}
{{- range nomadService "mev-commit-geth-bootnode1" }}
{{- if contains "p2p" .Tags }}
BOOTNODE_ENDPOINT="enode://{{ with secret "secret/data/mev-commit" }}{{ .Data.data.geth_bootnode1_boot_key_address }}{{ end }}@{{ .Address }}:{{ .Port }}"
{{- end }}
{{- end }}
{% endraw %}
{% endif %}
{% endif %}
EOH
destination = "secrets/.env"
Expand Down
31 changes: 31 additions & 0 deletions infrastructure/nomad/playbooks/variables/profiles.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,30 @@ jobs:
type: member
sync_mode: snap

mev_commit_geth_archive_node: &mev_commit_geth_archive_node_job
name: mev-commit-geth-archive-node
template: mev-commit-geth.nomad.j2
artifacts:
- *geth_artifact
count: 1
ports:
- metrics:
to: 6060
http:
static: 8565
to: 8545
ws:
static: 8566
to: 8546
p2p:
to: 30311
env:
ip: 0.0.0.0
public_ip: "{{ ansible_facts['default_ipv4']['address'] }}"
net_restrict: 0.0.0.0/0
type: archive
sync_mode: full

contracts_deployer: &contracts_deployer_job
name: contracts-deployer
template: contracts-deployer.nomad.j2
Expand Down Expand Up @@ -632,3 +656,10 @@ profiles:
- *mev_commit_oracle_job
- *mev_commit_faucet_job
- *datadog_agent_metrics_collector_job

archive:
jobs:
- *artifacts_job
- *datadog_agent_logs_collector_job
- *otel_collector_job
- *mev_commit_geth_archive_node_job

0 comments on commit 8c0034d

Please sign in to comment.